DS21372

Dependencies:   max32625pico SerialInterface USBDevice

Files at this revision

API Documentation at this revision

Comitter:
switches
Date:
Thu Jan 25 18:46:58 2018 +0000
Parent:
13:fed6ff32bf5d
Child:
15:e8b28cadf100
Commit message:
Added max32625pico library and example of using mixed voltages.; Changed USB VID/PID

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
max32625pico.lib Show annotated file Show diff for this revision Revisions of this file
--- a/main.cpp	Thu Apr 13 15:03:15 2017 +0000
+++ b/main.cpp	Thu Jan 25 18:46:58 2018 +0000
@@ -1,6 +1,7 @@
 #include "mbed.h"
 #include "rtos.h"
 #include "USBSerial.h"
+#include "max32625pico.h"
 #include "SerialInterface.h"
 
 #define UART_MAX_RESP_LENGTH  255
@@ -8,15 +9,15 @@
 #define USB_MAX_RESP_LENGTH  255
 #define USB_MAX_CMD_LENGTH  255
 
-// Virtual serial port over USB
-USBSerial microUSB;
+// configure VDDIOH to local 3.3V supply, set dipVio and swdVio to 1.8V supply
+MAX32625PICO pico(MAX32625PICO::IOH_3V3, MAX32625PICO::VIO_1V8, MAX32625PICO::VIO_1V8);
 
-// Hardware serial port over DAPLink
-Serial daplink(P2_1, P2_0);
+// Virtual serial port over USB
+USBSerial microUSB(0x0B6A, 0x4360);
 
 // Serial Interfaces
 I2C i2c(P1_6, P1_7);
-SPI spi(P1_5, P1_6, P1_4);
+SPI spi(P0_5, P0_6, P0_4);
 DigitalInOut gpio[] = {P0_0, P0_1, P0_2, P0_3, P4_4, P4_5, P4_6, P4_7};
 AnalogIn ain[] = {AIN_0, AIN_1, AIN_2, AIN_3, AIN_4, AIN_5, AIN_6, AIN_7};
 
@@ -25,7 +26,6 @@
 
 // Threads
 Thread threadUSB;
-Thread threadUART;
 
 DigitalOut rLED(LED1);
 DigitalOut gLED(LED2);
@@ -63,37 +63,6 @@
     }
 }
 
-void uart_thread()
-{
-    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();
-            if (ibuf[i]!='\r') {
-                if (i < UART_MAX_CMD_LENGTH) {
-                    i += 1;
-                }
-            } else {
-                bLED = LED_ON;
-                if (i < UART_MAX_CMD_LENGTH) {
-                    ibuf[i]=0;
-//                    daplink.printf("UART CMD:  %s=", ibuf);
-                    serInt.call(ibuf, obuf);
-                    daplink.printf("%s\r\n", obuf);
-                } else {
-                    daplink.printf("[-1]\r\n");
-                }
-                i=0;
-                bLED = LED_OFF;
-            }
-        }
-    }
-}
 
 // main() runs in its own thread in the OS
 // (note the calls to Thread::wait below for delays)
@@ -103,24 +72,17 @@
     gLED = LED_ON;
     bLED = LED_OFF;
 
-/*  Board Initialization
- *  This is done automatically if you specify vio
- *  when you instantiate the MAX32630FTHR library
- */
-//    pegasus.init(MAX32630FTHR::VIO_3V3);
-
-//  Initialize primary SPI CS
-    gpio[0].write(1);
-    gpio[0].output();
+//  Configure P4_4 through P4_7 for 3.3V I/O
+    pico.vddioh(P4_4, MAX32625PICO::VIO_IOH);
+    pico.vddioh(P4_5, MAX32625PICO::VIO_IOH);
+    pico.vddioh(P4_6, MAX32625PICO::VIO_IOH);
+    pico.vddioh(P4_7, MAX32625PICO::VIO_IOH);
 
     rLED = LED_OFF;
 
 // Start USB serial thread
     threadUSB.start(usb_thread);
 
-// Start UART serial thread
-    threadUART.start(uart_thread);
-
 // Start main loop
     while(1) {
         Thread::wait(500);
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max32625pico.lib	Thu Jan 25 18:46:58 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/users/switches/code/max32625pico/#65bda25808e4