I use chibios 2.5.1 up2date from git, on a specific build dev board with stm32f4.
The problems occurs with i2c1 ou i2c2, not tested other one.
when using i2cMasterTransmitTimeout to send a register address to be read, it works without any problem
if rxlen is > 1.
if rxlen equals 1, it hangs with stange behavior :
Code: Select all
static const I2CConfig i2cfg1 = {
OPMODE_I2C,
400000,
STD_DUTY_CYCLE,
};
i2cStart(&I2CD1, &i2cfg1);
static uint8_t rxbuf[16];
static uint8_t txbuf[16];
txbuf[0] = 0;
status = i2cMasterTransmitTimeout(&I2CD1, 0x1d, txbuf, 1, rxbuf, 1, 1000);
at first i2cMasterTransmitTimeout, it does not hangs, but when can see on the chronogram that i2c master ask for 2 bytes on the bus
instead one :

then, if i resend the same i2cMasterTransmitTimeout for one byte, it hangs :

^C0x08000d06 in _port_irq_epilogue () at ../../ChibiOS/os/ports/GCC/ARMCMx/chcore_v7m.c:144
144 if ((SCB_ICSR & ICSR_RETTOBASE) != 0) {
(gdb) where
#0 0x08000d06 in _port_irq_epilogue () at ../../ChibiOS/os/ports/GCC/ARMCMx/chcore_v7m.c:144
#1 0x080065d2 in VectorBC () at ../../ChibiOS/os/hal/platforms/STM32/i2c_lld.c:473
#2 0xfffffffc in ?? ()
I have tried to see in source code an obvious error, but does not find anything, execpt
a thing which is not relative to my bug but that i don't understand :
in file llc_i2c.c :
Code: Select all
chDbgCheck(((rxbytes == 0) || ((rxbytes > 1) && (rxbuf != NULL))),
"i2c_lld_master_transmit_timeout");if rxbytes is equal to 1, the test that rxbuf if not null is not done, does'nt the function need a valid buffer even for just one byte ?
Thanks for any help
Alexandre
