AnsweredAssumed Answered

I2C Slave implementation with blocking reads

Question asked by Nabeel Hasan on May 12, 2014
Latest reply on May 15, 2014 by Nabeel Hasan



I am working on implementing driver for Interrupt driven I2C slave.


I wrote some basic code where a task would wait for bytes to come from the master. As I started implementing this, I realized that the fread function is not a blocking call. If I were to use a UART interrupt driven driver, the driver would block the task till there is something in the buffer. But in the i2c driver, an fread simply reads whats in the buffer. If there is nothing then it will just return a 0 byte read. The only way to implement this would be to constantly poll Fread() and wait for bytes to come, but that defeats the purpose of using an interrupt driven I2C.


I started looking at older threads but did not find the answer to my question.


how to implement a SLAVE-mode MQX i2c driver??

In this thread, the person asks why i2c driver does not block tasks, and no one answered that question.


I2C Slave sample code

This thread only talks about a polled i2c slave driver.


If any one has implemented a interrupt I2c Slave driver, where a task can be blocked till bytes start filling the i2c RX buffer, please let me know