Hi there,
following issues when running Mbed OS 5.15.5 on a FRDM-KL82Z and an Aardvark as the Master.
slave.read() also takes the slave address and stores it.
I.E.
slave.read((char *)Hashed_Data, 10);
Hashed_Data[0] holds the slave address instead of the first data byte, which can be seen on Master side when using
slave.write((char *)Hashed_Data, 100);
Also requesting a write to Master, every other transfer fails.
#include "MKL82Z7.h"
#include "PinNames.h"
#include "mbed.h"
volatile int g_I2C_operation, g_I2C_status;
unsigned char Hashed_Data[100] = {0};
const char message[] = "Slave!";
I2CSlave slave(I2C_SDA, I2C_SCL);
int main() {
slave.address(0x40);
printf("Start \n\r");
while (1) {
g_I2C_operation = slave.receive();
switch (g_I2C_operation) {
case I2CSlave::WriteAddressed:
g_I2C_status = slave.read((char *)Hashed_Data, 10);
printf("%d", g_I2C_status);
break;
case I2CSlave::ReadAddressed:
g_I2C_status = slave.write((char *)Hashed_Data, 100);
printf("%d", g_I2C_status);
break;
}
}
}
this is just an example, the actual project is using Hashed_Data[65000]
but I don’t see this working properly anytime soon.