embassy
embassy copied to clipboard
Feature i2c slave
Hereby I created a proposal for an async i2c slave implementation. It is not finished yet, but working for my use case. Work in progress. Requirements are:
- Must be able to handle 2 addresses read and write.
- Must be able to handle arbitration lost Implementation is fully autonomous, after enabling. It runs fully in the interrupt context, is fast (no buffer copy in interrupt context)
Work to do still:
- Not based on a generic hal interface. (not available at this moment as far as I know)
- Handling of NACK not fully under control. I do not yet understand fully all the reload / sbc / nack combinations.But for the slave side the case is working for an actual implementation.
- Master write_read transaction not yet working
- Buffer size is allocated at compile time, and all buffers are equal. I can imagine this should be done with a macro and that the buffer size for address 1 can be different than address 2
For test purpose I did create 3 tests in the STM32G0 directory, for target nucleo-g070rb. Sometimes you have to modify the led and the uart as I also use a slightly different target.