[Sorry if I jump in here late. I have not read the past 20 pages of this thread, so maybe the following has been discussed already.]
Recently I tried to use the new I2C support with an STM32 in the "2.3.3 unstable" version. Apparently something is wrong in either the communication between the I2C partners or some hardware problem as the I2C_SR2_BUSY bit does not go away on me.
But that is not actually the important part here.
What bothers me is that as a result, i2c_lld_master_transmit() hangs completely. Since it is called with interrupts disabled, i.e. from within chSysLockFromIsr() context, the whole system hangs up!
The reason for the hangup is the following interrupt-related code:
Code: Select all
void i2c_lld_master_transmit(...) {
...
i2cp->id_i2c->CR1 |= I2C_CR1_START;
while (!(i2cp->id_i2c->SR1 & I2C_SR1_SB))
;
i2cp->id_i2c->DR = i2cp->slave_addr1;
while (!(i2cp->id_i2c->SR1 & I2C_SR1_ADDR))
;
while (!(i2cp->id_i2c->SR2 & I2C_SR2_BUSY))
;
...
This code does not seem to have the same quality as all the other ChibiOS kernel code I have seen so far. Relying (i.e. "active waiting") on any external event to happen within interrupt-related context can (and will) break the robustness of the whole system.
Just my 2 cents.
Stephan