USB serial demo passes data from virtual serial port to debug serial port
Dependencies: USBDevice max32630hsp3
Run the Code
- Import it into the mbed online compiler.
- Compile the program.
- It will automatically download the .bin file.
- Drag-drop or copy-paste the .bin file to the programmer drive. (PICO DAPLINK).
- Open a serial terminal (Putty, Tera Term, etc.)
- Find the COM port that the device is connected to and set that COM port in the terminal. Adjust the baudrate to 9600.
- Press the reset button on the microcontroller board. Now you should see another COM port on the device manager
- You should now see the temperature values on the terminal with 0.5-second intervals.
Revision 2:bc6feae09da3, committed 2018-04-24
- Comitter:
- Emre.Eken
- Date:
- Tue Apr 24 15:20:52 2018 +0300
- Parent:
- 1:138f024f15f6
- Child:
- 3:fe12fc83084f
- Commit message:
- First revision
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Tue Apr 24 15:17:30 2018 +0300
+++ b/main.cpp Tue Apr 24 15:20:52 2018 +0300
@@ -0,0 +1,38 @@
+#include "mbed.h"
+#include "max32630hsp.h"
+#include "USBSerial.h"
+
+MAX32630HSP icarus(MAX32630HSP::VIO_3V3);
+
+// Hardware serial port over DAPLink
+Serial daplink(P2_0, P2_1);
+
+// Virtual serial port over USB
+USBSerial microUSB;
+
+DigitalOut rLED(LED1);
+DigitalOut gLED(LED2);
+DigitalOut bLED(LED3);
+
+// main() runs in its own thread in the OS
+// (note the calls to Thread::wait below for delays)
+int main()
+{
+ int c;
+
+ daplink.printf("daplink serial port\r\n");
+ microUSB.printf("micro USB serial port\r\n");
+ rLED = LED_ON;
+ gLED = LED_ON;
+ bLED = LED_OFF;
+
+ rLED = LED_OFF;
+
+ while(1) {
+ c = microUSB.getc();
+ microUSB.putc(c);
+ daplink.putc(c);
+ bLED = c & 1;
+ }
+}
+