rrr
Dependencies: mbed
Revision 0:0b1cea62a239, committed 2018-06-25
- Comitter:
- BIGBOSS04
- Date:
- Mon Jun 25 05:37:31 2018 +0000
- Commit message:
- test;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jun 25 05:37:31 2018 +0000 @@ -0,0 +1,54 @@ +#include "mbed.h" +I2C i2c(D14, D15); +Serial pic(D8, D2); +DigitalOut PWL1(D9); +DigitalOut PWL2(D7); +DigitalOut PWL3(D6); +int ADRR = 0x0a; +int data,rcv_data; +/* +void i2c_send() //MDへのデータ送信 +{ + i2c.start(); + i2c.write(ADRR); + i2c.write(data); + i2c.stop(); +} +*/ +void judge() +{ + if(rcv_data == 0x01){ + PWL2 = 1; + PWL3 = 0; + data = 0x01; + //i2c_send(); + }else if(rcv_data == 0x02){ + PWL2 = 0; + PWL3 = 1; + data = 0x60; + //i2c_send(); + }else{ + PWL2 = 0; + PWL3 = 0; + data = 0xff; + } +} +int main() +{ + PWL1 = 1; + i2c.frequency(400000); + //NVIC_SetPriority(USART2_IRQn,2); + NVIC_SetPriority(I2C1_EV_IRQn,1); + wait(5); + + while(1){ + rcv_data = pic.getc(); + judge(); + + i2c.start(); + i2c.write(0x0a); + i2c.write(data); + i2c.stop(); + + } +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jun 25 05:37:31 2018 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/ef9c61f8c49f \ No newline at end of file