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.
Dependencies: BufferedSerial mbed
main.cpp@0:d84cdaf22096, 2016-04-18 (annotated)
- Committer:
- geky
- Date:
- Mon Apr 18 20:36:49 2016 +0000
- Revision:
- 0:d84cdaf22096
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
geky | 0:d84cdaf22096 | 1 | #include "mbed.h" |
geky | 0:d84cdaf22096 | 2 | #include "BufferedSerial.h" |
geky | 0:d84cdaf22096 | 3 | |
geky | 0:d84cdaf22096 | 4 | |
geky | 0:d84cdaf22096 | 5 | // Include the actual image |
geky | 0:d84cdaf22096 | 6 | #include "flash_image.h" |
geky | 0:d84cdaf22096 | 7 | |
geky | 0:d84cdaf22096 | 8 | // Cross include definitions |
geky | 0:d84cdaf22096 | 9 | //#define DEBUG 1 |
geky | 0:d84cdaf22096 | 10 | #define LED_STATUS 1 |
geky | 0:d84cdaf22096 | 11 | DigitalOut led_blue(LED_BLUE); |
geky | 0:d84cdaf22096 | 12 | DigitalOut led_green(LED_GREEN); |
geky | 0:d84cdaf22096 | 13 | |
geky | 0:d84cdaf22096 | 14 | #include "slip.h" |
geky | 0:d84cdaf22096 | 15 | #include "esp_command.h" |
geky | 0:d84cdaf22096 | 16 | |
geky | 0:d84cdaf22096 | 17 | |
geky | 0:d84cdaf22096 | 18 | int main() { |
geky | 0:d84cdaf22096 | 19 | ESPCommand<BufferedSerial> esp(D1, D0, D2, D3); |
geky | 0:d84cdaf22096 | 20 | led_blue = 1; |
geky | 0:d84cdaf22096 | 21 | led_green = 1; |
geky | 0:d84cdaf22096 | 22 | |
geky | 0:d84cdaf22096 | 23 | for (int i = 0; i < FLASH_COUNT; i++) { |
geky | 0:d84cdaf22096 | 24 | if (!esp.flash_write( |
geky | 0:d84cdaf22096 | 25 | FLASH_PAGES[i].address, |
geky | 0:d84cdaf22096 | 26 | FLASH_PAGES[i].data, |
geky | 0:d84cdaf22096 | 27 | FLASH_PAGES[i].size)) |
geky | 0:d84cdaf22096 | 28 | error("Error writing flash at 0x%05x!\r\n", FLASH_PAGES[i].address); |
geky | 0:d84cdaf22096 | 29 | } |
geky | 0:d84cdaf22096 | 30 | |
geky | 0:d84cdaf22096 | 31 | // Signal we're done |
geky | 0:d84cdaf22096 | 32 | printf("Finished\r\n"); |
geky | 0:d84cdaf22096 | 33 | |
geky | 0:d84cdaf22096 | 34 | while (true) { |
geky | 0:d84cdaf22096 | 35 | led_green = !led_green; // toggle led |
geky | 0:d84cdaf22096 | 36 | wait(0.2f); |
geky | 0:d84cdaf22096 | 37 | } |
geky | 0:d84cdaf22096 | 38 | } |