nitacku / nI2C

A non-blocking I2C library for Arduino/AVR without limitations!
MIT License
47 stars 7 forks source link

Not compiling slave_receiver example #5

Open altdaps opened 1 year ago

altdaps commented 1 year ago

Arduino IDE 1.8.9, board mega2560

C:\Program Files (x86)\Arduino\libraries\nI2C\nTWI.cpp: In member function 'void CTWI::InterruptHandler()':

C:\Program Files (x86)\Arduino\libraries\nI2C\nTWI.cpp:598:9: warning: attributes at the beginning of statement are ignored [-Wattributes]

     [[gnu::fallthrough]]; // Fall-through

     ^

C:\Users\SONY\AppData\Local\Temp\cc9495FG.ltrans0.ltrans.o: In function `main':

:(.text.startup+0x280): undefined reference to `CTWI::SetLocalDeviceAddress(unsigned char)' :(.text.startup+0x28c): undefined reference to `CTWI::SetSlaveReceiveHandler(void (*)(unsigned char const*, unsigned char))' collect2.exe: error: ld returned 1 exit status
nit4cku commented 1 year ago

It's not explained, but there is a define statement which controls whether the slave functions are enabled: CTWI_ENABLE_SLAVE_MODE: https://github.com/nitacku/nI2C/blob/master/nTWI.h#L29

Simply uncomment this line to enable slave mode.

altdaps commented 1 year ago

Thanks.