Nucleo同士でのi2C通信(受信プログラム)
Dependencies: mbed
main.cpp
- Committer:
- BIGBOSS04
- Date:
- 2018-06-26
- Revision:
- 1:fe1e055b834e
- Parent:
- 0:f6c56f4e8f3e
File content as of revision 1:fe1e055b834e:
#include <mbed.h> DigitalOut myled(LED1); I2CSlave slave(D14, D15); int check = 0; char buf[1]; i2c_rcv() void i2c_rcv() { int check = slave.receive(); if(check == I2CSlave::WriteAddressed:) { if(check == I2CSlave::WriteAddressed) { slave.read(buf,1); } } int main() void check_data() { slave.address(0xA0); i2c_rcv(); if(buf[0] == 0x01) { myled = 0; } else { myled = 1; { if(buf[0] == 0x01) { myled = 0; } else { myled = 1; } } } int main() { slave.address(0xA0); while (1) { i2c_rcv(); check_data(); } }