This forum is dedicated to feedback, discussions about ongoing or future developments, ideas and suggestions regarding the ChibiOS projects are welcome. This forum is NOT for support.
barthess wrote:matis Fixed. Check out rev. 3561. If you want to handle situations of communicating with non-exisiting I2C node use error callback, for example:
Thanks in advance, I'll check this first thing in the morning. Because we have hot pluggable I2C nodes, it is possible that they don't reply. I've already implemented the error callbacks, but due to the low level crashes, it didn't reach the error trap.
In my particular case, a I2CD_ACK_FAILURE isn't a bad thing, so I can return in that function. Because of the synchronization mechanism in my caller function, will the i2drv->id_state also become I2C_READY?
barthess wrote:matis Fixed. Check out rev. 3561. If you want to handle situations of communicating with non-exisiting I2C node use error callback, for example:
After I got rid of the compile error, I tried your code (rev 3564). I see that you added the following chDbgCheck(...) in i2c.c void i2cMasterTransmit(...) on line 158:
That because of rotten I2C cell in stm32 family. There is not possible to read 1 byte via DMA. If your hardware allow than read 2 bytes and drop unneeded one. Otherwise you must to fall back to I2Cv1, but I not recommend to do that because it too knotty.
Hi, Giovanni I measure time of polling STOP bit. It take about 2.24uS and very stable (SCL period is 2.40uS). Is it really necessary to use delayed polling via dedicated hardware timer? Without it driver code is beautiful and clean. Also, now we can set I2C IRQ priority to lowest value because of DMA usage. My I2CConfig:
Such a polling in IRQ context would degrade heavily the response time of the whole system (we are talking of an RTOS here) which, in case of the STM32F4 is well below the microsecond. I also think that that time is dependent on the I2C speed, probably by setting lower speeds that time would increase making degradation worse.
If the driver API was purely synchronous then a polling of 3uS would be perfectly acceptable because it would be performed in thread context.
In a synchronous driver I would, make a transmission API implementation this way:
1) Poll if there is a STOP ongoing from a *previous* transmission. 2) Start the transmission and wait for completion on a semaphore or a Thread *. 3) On the final IRQ wakeup the waiting thread. 4) Return status (RDY_OK=ok, RDY_TIMEOUT=timeout, you may use a VT to establish a maximum execution time for extra safety).
Note that the polling would be done at the beginning, this way the wait would most certainly be masked by the time between a transmission and next one. This is not much different from what you are doing now, it just don't have callbacks. The API name would be i2CTransmitTimeout() instead of i2cStartTransmission() because it would be synchronous, I-class variants would also no more be required.
We need to evaluate tradeoffs but I think we would get a couple of serious advantages vs losing callbacks.