Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:25f0bf2e4247, committed 2015-11-14
- Comitter:
- Gennanio
- Date:
- Sat Nov 14 11:24:59 2015 +0000
- Commit message:
- 0508_Lab5
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/eeprom.lib Sat Nov 14 11:24:59 2015 +0000 @@ -0,0 +1,1 @@ +https://developer.mbed.org/teams/FRA221_2015/code/eeprom/#c648c5e93d5e
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sat Nov 14 11:24:59 2015 +0000 @@ -0,0 +1,70 @@ +// Lab 5 +// 8/11/2015 +#include "mbed.h" +#include "eeprom.h" + +EEPROM ee(I2C_SDA,I2C_SCL,0); +// PB_9(D14),PB_8(D15) +BusOut led(D4,D5,D6,A0,A1,A2,A3); +DigitalIn in1(D7),in2(D8),in3(D9),in4(D10),in5(D11),in6(D12),in7(D13); +DigitalIn sw(D2),mode(D3); + +int main() +{ + int8_t a=0,sum; + int8_t wc=0,rc=0; + while(1) + { + if(sw) + { + if(mode) //read + { + led=0; + if(rc<wc) + { + ee.read(rc,a); + wait_ms(1); + rc++; + led=a; + } + else + { + led=127; wait(0.2); + led=0; wait(0.2); + led=127; wait(0.2); + led=0; + rc=0; + ee.read(rc,a); + wait_ms(1); + rc++; + led=a; + } + } + else //write + { + if(wc>60||rc>60) + { + //warning data can be overflow + led=63; wait(1); + led=0; wait(1); + led=63; wait(1); + led=0; + //reset eeprom go to address 0 + wc=0; rc=0; + } + sum=0; + if(in1) sum+=1; + if(in2) sum+=2; + if(in3) sum+=4; + if(in4) sum+=8; + if(in5) sum+=16; + if(in6) sum+=32; + if(in7) sum+=64; + ee.write(wc,sum); //save + wait_ms(1); + wc++; + } + } + wait(0.2); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sat Nov 14 11:24:59 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/9296ab0bfc11 \ No newline at end of file