hi,
i'm trying configure arduino work i2c slave, don't understand i'm doing wrong:
(ide 1.5.6)
i compiler error msg:
resolved.
corrected function call
void receivedata(int16_t bytecount) // although bytecount not used far
i'm trying configure arduino work i2c slave, don't understand i'm doing wrong:
(ide 1.5.6)
code: [select]
#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 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 30 bytes complete
i=0; // init counter var
while(wire.available()>0) // read bytes
{
val=wire.read();
recvarray[i++]=val;
}
}
// callback sending data
void senddata()
{
wire.write(sendarray, msgsize); // send 30 bytes master..
}
i compiler error msg:
quote
i2cev30001.ino: in function 'void setup()':edit:
i2cev30001:368: error: invalid conversion 'void (*)()' 'void (*)(int)' [-fpermissive]
in file included 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 'void (*)()' 'void (*)(int)' [-fpermissive]
resolved.
corrected function call
void receivedata(int16_t bytecount) // although bytecount not used far
now code compiles fine on mega,
but same code due again error messages:
but same code due again error messages:
quote
arduino: 1.6.5 (windows xp), platine: "arduino due (programming port)"edit: hmmmhm, changing 1nt16_t int seemed trick.....
i2cev30001.ino: in function 'void setup()':
i2cev30001:370: error: invalid conversion 'void (*)(int16_t) {aka void (*)(short int)}' 'void (*)(int)' [-fpermissive]
in file included i2cev30001.ino:2:0:
c:\dokumente und einstellungen\user1\anwendungsdaten\arduino15\packages\arduino\hardware\sam\1.6.4\libraries\wire/wire.h:53:7: error: initializing argument 1 of 'void twowire::onreceive(void (*)(int))' [-fpermissive]
void onreceive(void(*)(int));
^
invalid conversion 'void (*)(int16_t) {aka void (*)(short int)}' 'void (*)(int)' [-fpermissive]
Arduino Forum > Using Arduino > Networking, Protocols, and Devices (Moderator: fabioc84) > [new issue] Wire: what's wrong with Wire.onReceive() ?
arduino
Comments
Post a Comment