STM32F401 Discovery Board模擬I2C Master/Slave來互相傳收資料, 由於預設的I2C GPIO是
PB6和PB9, 因此我們必須將2塊Discovery Board的PB6/PB9互接.
2. Master Main Flow:
- I2C GPIO Init.
- write one byte(0xEF) to slave.
- write six bytes(0x12,0x34,0x56,0x78,0xAB,0xCD) to slave.
- read one byte(0x55) from slave.
- read six bytes(0x11,0x22,0x33,0x44,0x55,0x66) from slave.
3. Slave Main Flow:
- 除了設定I2C GPIO外, 還需要利用Start Condition一個特性, SDA會由High to Low, 因此我們可以在SDA GPIO設定一個Falling edge Interrupt來偵測何時發生I2C傳輸.
- slave discovery board address = 0x72.
4. Test Flow:(Logic analyzer)
- write one byte to slave:
5. Test Code Download Link: