FRA221_7B
/
Nucleo_eeprom
-
Fork of Nucleo_eeprom by
Revision 4:bbe1edd50fb6, committed 2015-11-17
- Comitter:
- lolopo008
- Date:
- Tue Nov 17 03:09:37 2015 +0000
- Parent:
- 3:8d9d440c1a2c
- Commit message:
- -
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Mon Oct 26 16:44:20 2015 +0000 +++ b/main.cpp Tue Nov 17 03:09:37 2015 +0000 @@ -1,46 +1,39 @@ #include "mbed.h" #include "eeprom.h" - +BusOut led(D2,D3,D4,D5,D6,D7,D8); +BusIn sw(D9,D10,D11,D12,D13,A0,A1); - EEPROM memory(I2C_SDA,I2C_SCL,0); +DigitalIn swm(A2); +DigitalIn swd(A3); + +EEPROM memory(I2C_SDA,I2C_SCL,0); + int main() { - - - int8_t data_dummy='r'; - int8_t data[4]; - float x=0.0f,j=9785.26844; - int16_t y=0x3321,z; - - - memory.write(1,(int8_t)data_dummy); - wait_ms(1); - - memory.write(2,(int8_t)'c'); - wait_ms(1); - memory.read(1,data,2); - wait_ms(1); - - - memory.write(10,j); - wait_ms(1); - - memory.read(10,x); - wait_ms(1); - - - memory.write(1,(int16_t)y); - wait_ms(1); - memory.read(1,z); - wait_ms(1); - - printf("read[1] = %c\n",data[0]); - printf("read[2] = %c\n",data[1]); - - printf("float = %f\n",x); - - printf("int16 =%d\n",z); - - + int In,Out; + while(1) { + if(swm==1) { + while(1) { + if(swd==1) { + In=sw; + memory.write(1,In); + + } else if(swm==0) { + memory.read(1,Out); + break; + } + } + } else { + while(1) { + if(swd==1) { + led=Out; + + } else if(swm==1) { + + break; + } + } + } + } } \ No newline at end of file