Create a UART to USB Serial bridge with the DipCortex

Dependencies:   USBDevice mbed

Fork of DipCortex-USB-CDC by Carl - SolderSplash Labs

Files at this revision

API Documentation at this revision

Comitter:
SolderSplashLabs
Date:
Sun Feb 23 22:53:22 2014 +0000
Parent:
2:ec470dd97c6e
Child:
4:4d7bb9e0afe5
Commit message:
DipCortex example showing USB CDC and reading/writing to the on chip EEprom

Changed in this revision

DipCortex-EEprom.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/DipCortex-EEprom.lib	Sun Feb 23 22:53:22 2014 +0000
@@ -0,0 +1,1 @@
+DipCortex-EEprom#53297f36733d
--- 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++;
     }
 }