hi,
I’m trying to configure my Arduino to work as a i2c slave, but I don’t understand what I’m doing wrong:
(IDE 1.5.6)
#define SLAVE_ADDRESS 0x04
#define MSGSIZE 30
byte RecvArray[MSGSIZE];
byte SendArray[MSGSIZE];
void setup() {
Serial.begin(115200);
// Wire (i2c)
Wire.begin(SLAVE_ADDRESS); // start Arduino as a I2C slave, addr=0x04 (7-bit coded)
Wire.onReceive(receiveData);
Wire.onRequest(sendData);
}
void receiveData() {
int32_t i;
byte val;
while(Wire.available()<MSGSIZE) ; // wait for 30 bytes to complete
i=0; // init counter var
while(Wire.available()>0) // read all bytes
{
val=Wire.read();
RecvArray[i++]=val;
}
}
// callback for sending data
void sendData()
{
Wire.write(SendArray, MSGSIZE); // send 30 bytes back to master..
}
I get the compiler error msg:
i2cEV30001.ino: In function ‘void setup()’:
i2cEV30001:368: error: invalid conversion from ‘void ()()’ to 'void ()(int)’ [-fpermissive]
In file included from i2cEV30001.ino:2:0:
C:\Programme\Arduino\hardware\arduino\avr\libraries\Wire/Wire.h:67:10: error: initializing argument 1 of 'void TwoWire::onReceive(void ()(int))’ [-fpermissive]
void onReceive( void ()(int) );
^
invalid conversion from ‘void ()()’ to 'void ()(int)’ [-fpermissive]
edit:
resolved.
corrected by function call
void receiveData(int16_t byteCount) // although byteCount not used so far