Hi,
I tested the modifications, now the driver seems to work but there is still a problem somewhere. Try the test application under ./testhal/STM32F37x/I2C, you can easily adapt it to the F0xx or the F3xx.
This is the relevant code (it reads from a small I2C memory):
Code: Select all
/*
* Normal main() thread activity, in this demo it does nothing.
*/
while (TRUE) {
unsigned i;
msg_t msg;
static const uint8_t cmd[] = {0, 0};
uint8_t data[16];
msg = i2cMasterTransmitTimeout(&I2CD2, 0x52, cmd, sizeof(cmd),
data, sizeof(data), TIME_INFINITE);
if (msg != RDY_OK)
palTogglePad(GPIOC, GPIOC_LED3);
for (i = 0; i < 256; i++) {
chThdSleepMilliseconds(2);
msg = i2cMasterReceiveTimeout(&I2CD2, 0x52,
data, sizeof(data), TIME_INFINITE);
if (msg != RDY_OK)
palTogglePad(GPIOC, GPIOC_LED3);
}
chThdSleepMilliseconds(500);
palTogglePad(GPIOC, GPIOC_LED2);
}
It works perfectly but if I remove that chThdSleepMilliseconds(2) then it hangs after few seconds, it is like it does not like repeated operations. When it hangs the ISR register contains BUSY=1 and the function does not return because no interrupt is ever triggered.
Enabling timeout would probably unlock it but not explain the behavior, I don't consider it a solution.
Giovanni