![](/media/cache/group/ppp_Bl1j27I.jpg.50x50_q85.jpg)
YEAH
Fork of Nucleo_eeprom by
main.cpp@4:401e0b8e182a, 2015-11-08 (annotated)
- Committer:
- NamSom
- Date:
- Sun Nov 08 13:53:08 2015 +0000
- Revision:
- 4:401e0b8e182a
- Parent:
- 3:8d9d440c1a2c
c
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
soulx | 0:8b5e53600ba0 | 1 | #include "mbed.h" |
soulx | 0:8b5e53600ba0 | 2 | #include "eeprom.h" |
NamSom | 4:401e0b8e182a | 3 | EEPROM memory(I2C_SDA,I2C_SCL,0); |
soulx | 0:8b5e53600ba0 | 4 | |
NamSom | 4:401e0b8e182a | 5 | BusIn inbutton(D8,D7,D6,D5,D4,D3,D2); |
NamSom | 4:401e0b8e182a | 6 | BusOut led(A1,A0,D13,D12,D11,D10,D9); |
soulx | 0:8b5e53600ba0 | 7 | |
NamSom | 4:401e0b8e182a | 8 | DigitalIn selectmode(PB_7); |
soulx | 0:8b5e53600ba0 | 9 | |
NamSom | 4:401e0b8e182a | 10 | DigitalIn trigger(PC_13); |
NamSom | 4:401e0b8e182a | 11 | |
soulx | 0:8b5e53600ba0 | 12 | int main() |
soulx | 0:8b5e53600ba0 | 13 | { |
NamSom | 4:401e0b8e182a | 14 | int i=1,j=1,check=0,oldtrigger=0,currenttrigger; |
NamSom | 4:401e0b8e182a | 15 | int8_t data_dummy; |
NamSom | 4:401e0b8e182a | 16 | int8_t data; |
soulx | 3:8d9d440c1a2c | 17 | |
NamSom | 4:401e0b8e182a | 18 | while(1) |
NamSom | 4:401e0b8e182a | 19 | { |
NamSom | 4:401e0b8e182a | 20 | currenttrigger=trigger; |
NamSom | 4:401e0b8e182a | 21 | |
NamSom | 4:401e0b8e182a | 22 | if(selectmode==0 && oldtrigger==0 && currenttrigger==1) //0 is write mode |
NamSom | 4:401e0b8e182a | 23 | { |
NamSom | 4:401e0b8e182a | 24 | if(check==1){i=1;j=1;check=0;} |
NamSom | 4:401e0b8e182a | 25 | data_dummy=inbutton; |
NamSom | 4:401e0b8e182a | 26 | |
NamSom | 4:401e0b8e182a | 27 | memory.write(i,(int8_t)data_dummy); |
NamSom | 4:401e0b8e182a | 28 | wait_ms(1); |
NamSom | 4:401e0b8e182a | 29 | i++; |
NamSom | 4:401e0b8e182a | 30 | } |
soulx | 3:8d9d440c1a2c | 31 | |
NamSom | 4:401e0b8e182a | 32 | if(selectmode==1 && oldtrigger==0 && currenttrigger==1) |
NamSom | 4:401e0b8e182a | 33 | { |
NamSom | 4:401e0b8e182a | 34 | check=1; |
NamSom | 4:401e0b8e182a | 35 | if(j<i) |
NamSom | 4:401e0b8e182a | 36 | { |
NamSom | 4:401e0b8e182a | 37 | memory.read(j,data); |
NamSom | 4:401e0b8e182a | 38 | wait_ms(1); |
NamSom | 4:401e0b8e182a | 39 | led = data; |
NamSom | 4:401e0b8e182a | 40 | wait(1); |
NamSom | 4:401e0b8e182a | 41 | |
NamSom | 4:401e0b8e182a | 42 | j++; |
NamSom | 4:401e0b8e182a | 43 | } |
NamSom | 4:401e0b8e182a | 44 | else |
NamSom | 4:401e0b8e182a | 45 | {led=0;} |
NamSom | 4:401e0b8e182a | 46 | } |
NamSom | 4:401e0b8e182a | 47 | oldtrigger=currenttrigger; |
NamSom | 4:401e0b8e182a | 48 | } |
soulx | 3:8d9d440c1a2c | 49 | |
soulx | 0:8b5e53600ba0 | 50 | } |