I2C Slave NUCLEO-F411RE
Hello,
I am currently working on a project where I need to configure a NUCLEO F411RE Board as an I2C slave. It will be connected to a Raspberry Pi Master.
I am able to detect the NUCLEO on the raspberry Pi, however I am unsure how to get the read byte. I created a simple code where when the byte received is 0x01 or 0x10 the LED should turn on, if it receives anything else it turns off. However this doesn't seem to be working.
This is the code I am using:
uint8_t buffer[0];
for (;;)
{
HAL_I2C_Slave_Receive(&hi2c1, (uint8_t *)buffer, sizeof(buffer), HAL_MAX_DELAY);
if ((*buffer == 0x01)|| (*buffer == 0x10)){
HAL_GPIO_WritePin (GPIOA, GPIO_PIN_5, GPIO_PIN_SET);
HAL_Delay (100);
}
else{
HAL_GPIO_WritePin (GPIOA, GPIO_PIN_5, GPIO_PIN_RESET);
HAL_Delay (100);
}
}
If anyone can help me with this issue, it would be greatly appreciated. (I am sending a 0x01 on the Raspberry Pi side)
