Hello all,
Background
- Board: S32K148
- SDK: v4.0.3
- OS: freeRTOS
Problem
I am currently working on a project which requires me to monitor an i2c bus and record all information passing between the master and slave. Initially I thought you would be able to configure the lpi2c as a slave, give it an arbitrary address, and configure the callback to execute whenever anything was detected on the lines. The issue is that it appears the callback routine only triggers whenever an i2c frame is directed at my sniffer node (same slave address). Otherwise, the program never enters the callback even though traffic is seen on the bus.
Because of the previous issue, I then resorted to use a regular GPIO to trigger on SCL and decode the data that way. I then ran into issue with this method:
- I do not know how to to let the software know when all bytes have been received because it is a regular interrupt (No TX/RX complete flags).
- Because I have to process interrupts back-to-back I ran into issues writing some logic within the ISR handler to notify the program when the last byte was received. (I tried adding some logic, but this causes the program to miss some bits).
I tried using a freeRTOS timer that will continuously reset every time it receives a bit, therefore whenever the timer expires, I can set a flag to notify my software. Unfortunately, this causes some latency in the interrupts and I'll miss bits.
So my question: Is there a way to configure lpi2c to sniff the bus and store all data in a buffer (regardless of node address)? If lpi2c cannot be used, what method do you guys recommend for creating the sniffer?
I appreciate the help!
Thank you.