A7
/
Nucleo_eeprom
EEPROM
Fork of Nucleo_eeprom by
Revision 8:0be8f8d2ece2, committed 2017-11-24
- Comitter:
- 59340500018
- Date:
- Fri Nov 24 04:06:22 2017 +0000
- Parent:
- 7:8faeff100e3a
- Commit message:
- EEPROM;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8faeff100e3a -r 0be8f8d2ece2 main.cpp --- a/main.cpp Sun Oct 29 16:05:01 2017 +0000 +++ b/main.cpp Fri Nov 24 04:06:22 2017 +0000 @@ -1,9 +1,68 @@ - #include "mbed.h" #include "eeprom.h" EEPROM memory(I2C_SDA,I2C_SCL,0); //EEPROM abc(I2C_SDA,I2C_SCL,1); +Serial pc(D1,D0); +DigitalIn sw1(D9), sw2(D10), sw3(D11), sw4(D12), sw5(D13), sw6(A0), sw7(A1), sw8(A2), sw9(A3); +DigitalOut led_0(D2), led_1(D3), led_2(D4), led_3(D5), led_4(D6), led_5(D7), led_6(D8); + +int main() +{ + + int8_t data[7] = {0,0,0,0,0,0,0}; + uint8_t data_a; + while(1){ + if (sw1.read()==1){ + if (sw2.read()==0){ + memory.write(1,(int8_t)sw3.read()); + wait_ms(1); + memory.write(2,(int8_t)sw4.read()); + wait_ms(1); + memory.write(3,(int8_t)sw5.read()); + wait_ms(1); + memory.write(4,(int8_t)sw6.read()); + wait_ms(1); + memory.write(5,(int8_t)sw7.read()); + wait_ms(1); + memory.write(6,(int8_t)sw8.read()); + wait_ms(1); + memory.write(7,(int8_t)sw9.read()); + wait_ms(1); + } + } + else if (sw1.read()==0){ + if (sw2.read()==0){ + memory.read(1,data,7); + wait_ms(1); + } + } + led_0 = data[0]; + wait_ms(1); + led_1 = data[1]; + wait_ms(1); + led_2 = data[2]; + wait_ms(1); + led_3 = data[3]; + wait_ms(1); + led_4 = data[4]; + wait_ms(1); + led_5 = data[5]; + wait_ms(1); + led_6 = data[6]; + wait_ms(1); + if(pc.readable()) { + data_a = pc.getc(); + if (data_a == 'a'){ + pc.printf("data[0]:%d data[1]:%d data[2]:%d data[3]:%d data[4]:%d data[5]:%d data[6]:%d\n",data[0],data[1],data[2],data[3],data[4],data[5],data[6]); + pc.printf("sw1(D9):%d, sw2(D10):%d, sw3(D11):%d, sw4(D12):%d, sw5(D13):%d, sw6(A0):%d, sw7(A1):%d, sw8(A2):%d, sw9(A3):%d",sw1.read(),sw2.read(),sw3.read(),sw3.read(),sw4.read(),sw5.read(),sw6.read(),sw7.read(),sw8.read(),sw9.read()); + } + } + + } +} +/*EEPROM memory(I2C_SDA,I2C_SCL,0); +//EEPROM abc(I2C_SDA,I2C_SCL,1); int main() { @@ -42,4 +101,4 @@ printf("int16 =%d\n",z); -} \ No newline at end of file +}*/ \ No newline at end of file