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.
main.cpp@1:e5497e7c8c79, 2020-07-09 (annotated)
- Committer:
- rary
- Date:
- Thu Jul 09 15:42:27 2020 +0000
- Revision:
- 1:e5497e7c8c79
- Parent:
- 0:f6e222782355
- Child:
- 2:292423de1497
128bite
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| rary | 0:f6e222782355 | 1 | #include "mbed.h" | 
| rary | 0:f6e222782355 | 2 | #include "EEPROM.h" | 
| rary | 0:f6e222782355 | 3 | |
| rary | 0:f6e222782355 | 4 | EEPROM rom(p9, p10); | 
| rary | 0:f6e222782355 | 5 | Serial pc(USBTX, USBRX); | 
| rary | 0:f6e222782355 | 6 | |
| rary | 0:f6e222782355 | 7 | #define ADDR 0xA0 //EEPROMコントロールアドレス | 
| rary | 0:f6e222782355 | 8 | int pointerAddress = 0; //EEPROM保存アドレス | 
| rary | 0:f6e222782355 | 9 | |
| rary | 0:f6e222782355 | 10 | int main() | 
| rary | 0:f6e222782355 | 11 | { | 
| rary | 1:e5497e7c8c79 | 12 | char data_read[128]; | 
| rary | 0:f6e222782355 | 13 | pc.baud(460800); //ボーレート変更 | 
| rary | 0:f6e222782355 | 14 | |
| rary | 0:f6e222782355 | 15 | pc.printf("Start!"); | 
| rary | 0:f6e222782355 | 16 | |
| rary | 1:e5497e7c8c79 | 17 | for(int i = 0;i < 500; i++) | 
| rary | 0:f6e222782355 | 18 | { | 
| rary | 1:e5497e7c8c79 | 19 | rom.write(ADDR, pointerAddress, '\0', 128); // write tha data | 
| rary | 1:e5497e7c8c79 | 20 | pointerAddress = pointerAddress + 128; //アドレスずらし | 
| rary | 0:f6e222782355 | 21 | } | 
| rary | 0:f6e222782355 | 22 | |
| rary | 0:f6e222782355 | 23 | pointerAddress = 0; | 
| rary | 0:f6e222782355 | 24 | pc.printf("Data read\r\n"); | 
| rary | 0:f6e222782355 | 25 | |
| rary | 1:e5497e7c8c79 | 26 | for(int n = 0; n < 500; n++) | 
| rary | 0:f6e222782355 | 27 | { | 
| rary | 1:e5497e7c8c79 | 28 | rom.read(ADDR, pointerAddress, data_read, 128); | 
| rary | 1:e5497e7c8c79 | 29 | wait_ms(5); | 
| rary | 0:f6e222782355 | 30 | pc.printf("%s\r\n", data_read); | 
| rary | 0:f6e222782355 | 31 | |
| rary | 1:e5497e7c8c79 | 32 | pointerAddress = pointerAddress + 128; //アドレスずらし | 
| rary | 1:e5497e7c8c79 | 33 | memset(data_read, '\0', 128 ); //初期化 | 
| rary | 0:f6e222782355 | 34 | } | 
| rary | 0:f6e222782355 | 35 | pc.printf("Finish!\r\n"); | 
| rary | 0:f6e222782355 | 36 | } |