PuG
/
eepromlab
YEAH
Fork of Nucleo_eeprom by
Revision 4:401e0b8e182a, committed 2015-11-08
- Comitter:
- NamSom
- Date:
- Sun Nov 08 13:53:08 2015 +0000
- Parent:
- 3:8d9d440c1a2c
- Commit message:
- c
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 8d9d440c1a2c -r 401e0b8e182a main.cpp --- a/main.cpp Mon Oct 26 16:44:20 2015 +0000 +++ b/main.cpp Sun Nov 08 13:53:08 2015 +0000 @@ -1,46 +1,50 @@ #include "mbed.h" #include "eeprom.h" +EEPROM memory(I2C_SDA,I2C_SCL,0); +BusIn inbutton(D8,D7,D6,D5,D4,D3,D2); +BusOut led(A1,A0,D13,D12,D11,D10,D9); +DigitalIn selectmode(PB_7); - EEPROM memory(I2C_SDA,I2C_SCL,0); +DigitalIn trigger(PC_13); + int main() { - - - int8_t data_dummy='r'; - int8_t data[4]; - float x=0.0f,j=9785.26844; - int16_t y=0x3321,z; - + int i=1,j=1,check=0,oldtrigger=0,currenttrigger; + int8_t data_dummy; + int8_t data; - 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); - + while(1) + { + currenttrigger=trigger; + + if(selectmode==0 && oldtrigger==0 && currenttrigger==1) //0 is write mode + { + if(check==1){i=1;j=1;check=0;} + data_dummy=inbutton; + + memory.write(i,(int8_t)data_dummy); + wait_ms(1); + i++; + } - 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); - + if(selectmode==1 && oldtrigger==0 && currenttrigger==1) + { + check=1; + if(j<i) + { + memory.read(j,data); + wait_ms(1); + led = data; + wait(1); + + j++; + } + else + {led=0;} + } + oldtrigger=currenttrigger; + } } \ No newline at end of file