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: max32625pico maxim-dev mbed-rtos USBDevice
Fork of PICO_USB_I2C_SPI by
Diff: main.cpp
- Revision:
- 5:2436ae0a9eb1
- Parent:
- 3:aa55728c8e09
- Child:
- 6:bff339370df6
diff -r bf2b2b0cd5d3 -r 2436ae0a9eb1 main.cpp
--- a/main.cpp Thu Dec 08 16:34:41 2016 +0000
+++ b/main.cpp Thu Dec 08 21:10:46 2016 +0000
@@ -10,12 +10,6 @@
MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
-// Hardware serial port over DAPLink
-Serial daplink(P2_1, P2_0);
-
-// Virtual serial port over USB
-USBSerial microUSB;
-
// Serial Interface Adapter
SerialInterface serInt;
@@ -33,10 +27,14 @@
void usb_thread()
{
+// Virtual serial port over USB
+ USBSerial microUSB;
char obuf[USB_MAX_RESP_LENGTH+1];
char ibuf[USB_MAX_CMD_LENGTH+1];
int i = 0;
+ microUSB.printf("micro USB serial port\r\n");
+
while(1) {
if (microUSB.readable()) {
ibuf[i]=microUSB.getc();
@@ -63,10 +61,14 @@
void uart_thread()
{
+// Hardware serial port over DAPLink
+ Serial daplink(P2_1, P2_0);
char obuf[UART_MAX_RESP_LENGTH+1];
char ibuf[UART_MAX_CMD_LENGTH+1];
int i = 0;
+ daplink.printf("daplink serial port\r\n");
+
while(1) {
if (daplink.readable()) {
ibuf[i]=daplink.getc();
@@ -95,8 +97,6 @@
// (note the calls to Thread::wait below for delays)
int main()
{
- daplink.printf("daplink serial port\r\n");
- microUSB.printf("micro USB serial port\r\n");
rLED = LED_ON;
gLED = LED_ON;
bLED = LED_OFF;
@@ -108,10 +108,10 @@
serInt.init(&i2c, &spi);
rLED = LED_OFF;
-
+
// Start USB serial thread
threadUSB.start(usb_thread);
-
+
// Start UART serial thread
threadUART.start(uart_thread);
