[SOLVED] Error with i2cdev library

icelon
Thu Aug 24, 2017 1:35 pm
[tr][/tr]this arduino new ide in i2cdevlib

In file included from /home/icelon/midro/hardware/Arduino_STM32-master/STM32F1/cores/maple/wirish.h:60:0,
from /home/icelon/midro/hardware/Arduino_STM32-master/STM32F1/cores/maple/Arduino.h:30,
from /home/icelon/midro/libraries/I2Cdev/I2Cdev.h:77,
from /home/icelon/midro/libraries/I2Cdev/I2Cdev.cpp:46:
/home/icelon/midro/libraries/I2Cdev/I2Cdev.cpp: In static member function 'static int8_t I2Cdev::readBytes(uint8_t, uint8_t, uint8_t, uint8_t*, uint16_t)':
/home/icelon/midro/libraries/I2Cdev/I2Cdev.cpp:276:62: error: 'BUFFER_LENGTH' was not declared in this scope
for (uint8_t k = 0; k < length; k += min(length, BUFFER_LENGTH)) {
^
/home/icelon/midro/hardware/Arduino_STM32-master/STM32F1/cores/maple/wirish_math.h:107:39: note: in definition of macro 'min'
#define min(a,b) ((a)<(b)?(a):(b))
^
/home/icelon/midro/libraries/I2Cdev/I2Cdev.cpp: In static member function 'static int8_t I2Cdev::readWords(uint8_t, uint8_t, uint8_t, uint16_t*, uint16_t)':
/home/icelon/midro/libraries/I2Cdev/I2Cdev.cpp:414:70: error: 'BUFFER_LENGTH' was not declared in this scope
for (uint8_t k = 0; k < length * 2; k += min(length * 2, BUFFER_LENGTH)) {
^
/home/icelon/midro/hardware/Arduino_STM32-master/STM32F1/cores/maple/wirish_math.h:107:39: note: in definition of macro 'min'
#define min(a,b) ((a)<(b)?(a):(b))
^
exit status 1
Error compilando para la tarjeta Maple Mini.


fpiSTM
Thu Aug 24, 2017 2:51 pm
It’s link to the change made to use HardWire instead of SoftWire.
https://github.com/rogerclarkmelbourne/ … d44d874L60
In Wire.h BUFFER_LENGTH is no more defined.

As a workaround:
Change the include in the library I2Cdev from Wire.h to SoftWire.h
https://github.com/jrowberg/i2cdevlib/b … Cdev.h#L83

Or you can test to add in Wire.h:
#define BUFFER_LENGTH 32


zmemw16
Thu Aug 24, 2017 3:15 pm
and where did you get I2Cdev ? a guess github so https://github.com/jrowberg/i2cdev and then more info from
http://www.i2cdevlib.com/ ? (approx 15secs)

in their forums i found i saw on the main i2cdevlib page that STM32 was a future target
it seems to have Due port though, might be be a good place to start.
look for another project with a Due and a STM32 ports, compare those to see what might need changing, timers, irq stuff

stephen


fpiSTM
Thu Aug 24, 2017 3:28 pm
As it use Wire class from the core, it should not need specific update for stm32.
I think the original question is why it does not built anymore.

Edit: Tested with Arduino_Core_STM32 and it’s ok.


icelon
Thu Aug 24, 2017 4:18 pm
thank very thanks …. word fine ,,,,hardwire and add wire . used a jrowberg git … thanks

fpiSTM
Thu Aug 24, 2017 4:38 pm
Welcome.
Maybe it should be fine to add the define for HardWire and this will be more compatible with Lib using this define.
I let @RogerClark check that point ;)

RogerClark
Thu Aug 24, 2017 9:30 pm
Is BUFFER_LENGTH defined for the AVR Wire library.

It seems strange to define someone with a global name like BUFFER_LENGTH that does not describe what the buffer is associated with


fpiSTM
Fri Aug 25, 2017 7:30 am
+1 Roger.

icelon
Fri Aug 25, 2017 7:53 am
thanks roger !!!!

I’ve seen what you tell me but I still do not give up, I’m modifying a firmware of a stm32f030 … Wemos controller type although I darn the possibility to use TLC5490 or a PCA9685 type hat ….


RogerClark
Fri Aug 25, 2017 8:02 am
It looks like BUFFER_LENGTH is defined in Wire.h for the SAM architecture

https://github.com/arduino/ArduinoCore- … NGTH&type=

and also for AVR

But not for SAMD

I can see its referenced in http://playground.arduino.cc/Main/WireL … dReference

But its not really part of the public API for Wire.

https://www.arduino.cc/en/Reference/Wire

Looking in libmaple, WireBase defines #define WIRE_BUFSIZ 32
I will change the definition to BUFFER_LENGTH = 32, Just for maximum compatibility.

But personally, I don’t think its good practice for any external libraries to use that define (as its not part of the public API)


RogerClark
Fri Aug 25, 2017 8:36 am
[icelon – Fri Aug 25, 2017 7:53 am] –
thanks roger !!!!

I’ve seen what you tell me but I still do not give up, I’m modifying a firmware of a stm32f030 … Wemos controller type although I darn the possibility to use TLC5490 or a PCA9685 type hat ….

Download the latest version.

I’ve updated Wirebase.h and Wirebase.cpp and also Softwire.h

BUFFER_LENGTH is now defined in Wirebase.h and removed from Software.h as Softwire.h includes Wirebase.h


icelon
Fri Aug 25, 2017 2:04 pm
tanks !!!

Leave a Reply

Your email address will not be published. Required fields are marked *