Create a UART to USB Serial bridge with the DipCortex
Fork of DipCortex-USB-CDC by
Diff: main.cpp
- Revision:
- 3:5fffa4cb4ca1
- Parent:
- 2:ec470dd97c6e
- Child:
- 5:dbe3aba53ebf
diff -r ec470dd97c6e -r 5fffa4cb4ca1 main.cpp --- a/main.cpp Thu Jan 30 21:33:45 2014 +0000 +++ b/main.cpp Sun Feb 23 22:53:22 2014 +0000 @@ -4,6 +4,7 @@ #include "mbed.h" #include "USBSerial.h" +#include "DipCortex-EEprom.h" // Serial TX Pin19, Serial RX Pin20 // Using port and pin names as the mbed definitions pin defs for the M0 are incorrect @@ -25,15 +26,40 @@ int main() { +volatile char charIn; +char tempBuf[15] = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; +int i = 0; + + IAP_Init(); pc.attach(settingsChanged); - while (1) { - while (uart.readable()) { - pc.putc(uart.getc()); - } + // wait for a key press + charIn = pc.getc(); + + while (1) + { + pc.printf("Press a key to start\r\n"); + charIn = pc.getc(); + + // Test read + tempBuf[0] = 0; + IAP_Eeprom_Read(1, (uint8_t *)&tempBuf, 15); + pc.printf("EEprom Read : %s\r\n", &tempBuf[0]); - while (pc.readable()) { - uart.putc(pc.getc()); - } + // Write + sprintf( &tempBuf[0], "Testing %i", i ); + IAP_Eeprom_Write(1, (uint8_t *)&tempBuf, 15); + pc.printf("EEprom Writen : %s\r\n", &tempBuf[0]); + + tempBuf[0] = 0; + pc.printf("Press a key to read back\r\n"); + charIn = pc.getc(); + + // Read Back + tempBuf[0] = 0; + IAP_Eeprom_Read(1, (uint8_t *)&tempBuf, 15); + pc.printf("EEprom Read : %s\r\n", &tempBuf[0]); + + i++; } }