Hi guys !
I'm encountering a huge problem.
I'm working with a IMU MPU 9150, a NFC PN532 Reader and a SD Card.
On one board, i retrieve imu data and send it to the second board via I2C. I use beginTransmission, write and endTransmission to send data. It works fine.
On the second board, i retrieve data via onReceive event. It works fine too.
Retreive NFC alone works fine too.
However, when i'm trying to retrieve the NFC tag via SPI when the onReceive handler is active, it does not work. I cannot stop the I2C interruption (something like semaphore would be great).
Here is the scheme of my code :
CPU1 :
| setup()
| init imu
| loop : every 100 ms
| retrieve IMU data
| compute and fusion pose
| send data to CPU2
(this is called 6 times because I2C buffer is only 32 BYTES)
| beginTransmission(addr)
| write
| endTransmission()
CPU2 :
| setup()
| init SD and NFC board
| attach handler onReceive
| onReceive :
| while data available
| save char to string
| set boolean dataReady to true
| loop
| get NFC tag
| check flags
| if tag present, write log file
| if (dataReady)
| write log file
You'll find the code as an attachment.
Thank you very much !
CPU1.ino (14.7 KB)
CPU2.ino (8.86 KB)