5 years, 11 months ago.

How do I instantiate an I2C Slave for the nRF51822?

I am getting: Error: Identifier "I2CSlave" is undefined in "main.cpp", Line: 43, Col: 2

for the code:

I2C_Slave instance

#define I2C_Slave_ADDR     (0x0a) // Slave address (preshifted left 1 bit)
I2CSlave slave(P0_9, P0_11);     //(I2C_SDA, I2C_SCL);   //I2CSlave Class pin assignments see I2C.h
DigitalInOut i2c_sda(P0_9);
DigitalInOut i2c_scl(P0_11);

Where is this "I2C.h" anyway? Steve

1 Answer

5 years, 11 months ago.

Hi Steve,

Unfortunately you can't instantiate one, because it doesn't exist. If you check the nRF51822 reference manual, you'll see that it only has an I2C Master (which they call TWI).

We found a discussion for a possible work around here on the Nordic site:

Regards,

Ralph, Team Mbed