ajkdvgoqueg
Revision 1:95c54222290a, committed 2018-11-18
- Comitter:
- sunninety1
- Date:
- Sun Nov 18 08:05:12 2018 +0000
- Parent:
- 0:8d6e82c584a0
- Commit message:
- xxcxcxc;
Changed in this revision
LAB5.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/LAB5.cpp Fri Nov 16 16:50:31 2018 +0000 +++ b/LAB5.cpp Sun Nov 18 08:05:12 2018 +0000 @@ -2,48 +2,62 @@ #include "eeprom.h" EEPROM memory(PB_9,PB_8,5);// Pinname sda=PB_9 , Pinname scl=PB_8 , address=1 -BusOut le(D2,D3,D4,D5,D6,D7,D8); +InterruptIn gogo(PA_0); BusIn sw1(D10,D11,D12,D13,PC_0,PC_1,PB_0); DigitalIn sw(D9); -DigitalIn tog(PA_0); +int mode,check; Serial pc(D1,D0); - void _Read(int8_t x,int16_t y) { - memory.write(y,x); wait_ms(1); pc.printf("write to %d with value: %d\n",(int)x,(int)y); } - +void eiei() +{ + if(sw==0){ + mode=0; + check=1; + } + else{ + mode=1; + check=1; + } + } void _write(int16_t y) { + BusOut le(D8,D7,D6,D5,D4,D3,D2); int8_t st; - memory.read(y,st); + le=st; wait_ms(1); pc.printf("Read from %d value is: %d\n",(int)y,st); - le=st; + } - int main() { int c1=2,c2=2; + gogo.rise(&eiei); + for(int i=0 ;i<1000;i++){ + memory.write(i,0); + } while(1) { - if(tog==0){ - while(tog==0); - if (sw==0) { + + if (mode==0 && check==1) { c2=2; _Read((int8_t)sw1,(int16_t)c1); c1+=1; + check=0; } - else{ + if (mode==1 && check==1) + { c1=2; _write((int16_t)c2); c2+=1; + check=0; } } - } + } \ No newline at end of file