LP Transmitter Wakeup

Dependencies:   max32630fthr USBDevice

Files at this revision

API Documentation at this revision

Comitter:
MI
Date:
Tue Jan 09 19:10:44 2018 +0000
Child:
1:8834bc22c2e7
Commit message:
Initial Commit

Changed in this revision

USBDevice.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
max32630fthr.lib Show annotated file Show diff for this revision Revisions of this file
mbed-dev.lib Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice.lib	Tue Jan 09 19:10:44 2018 +0000
@@ -0,0 +1,1 @@
+https://developer.mbed.org/teams/MaximIntegrated/code/USBDevice/#17ac7abb27a7
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Jan 09 19:10:44 2018 +0000
@@ -0,0 +1,102 @@
+#include "mbed.h"
+#include "max32630fthr.h"
+#include "USBSerial.h"
+#include "mxc_config.h"
+#include "lp.h"
+#include "gpio.h"
+
+MAX32630FTHR pegasus(MAX32630FTHR::VIO_3V3);
+
+DigitalOut rLED(LED1);
+DigitalOut gLED(LED2);
+DigitalOut bLED(LED3);
+
+DigitalIn sw1(SW1);
+
+gpio_cfg_t gpioLP0;
+
+#define LP0_WAKE_GPIO_PORT  2
+#define LP0_WAKE_GPIO_PIN   PIN_3
+
+// *****************************************************************************
+void Wakeup_blinks()
+{
+    int numBlinks = 3;
+
+    bLED = LED_OFF;
+    gLED = LED_OFF;
+    
+    while(numBlinks) {
+        rLED = LED_ON;
+        wait_ms(167);
+        rLED = LED_OFF;
+        wait_ms(167);
+
+        numBlinks--;
+    }
+    
+}
+
+// *****************************************************************************
+void Powerdown_blinks()
+{
+    gLED = LED_OFF;
+    
+    int numBlinks = 3;
+
+    while(numBlinks) {
+        bLED = LED_ON;
+        wait_ms(167);
+        bLED = LED_OFF;
+        wait_ms(167);
+
+        numBlinks--;
+    }
+    
+}
+
+/******************************************************************************/
+int main(void)
+{
+    //check if starting at main because of LP0 wake-up
+    if(LP_IsLP0WakeUp())
+        Wakeup_blinks();        //blinks red LED 3 times
+    else {
+        //We did not wake up from sleep and this is first power-on
+
+    }
+
+    //initialize LEDs
+    gLED = LED_ON;
+    bLED = LED_OFF;
+    rLED = LED_OFF;
+    
+    //use the gpio_cfg_t type to control GPIO operation with built-in Maxim library functions
+    gpioLP0.port = LP0_WAKE_GPIO_PORT;
+    gpioLP0.mask = LP0_WAKE_GPIO_PIN;
+    gpioLP0.func = GPIO_FUNC_GPIO;
+    gpioLP0.pad = GPIO_PAD_INPUT_PULLUP;
+    GPIO_Config(&gpioLP0);
+
+    while(1) {
+        //Wait for user to push sw1 to enter LP0
+        if(sw1 == 0)
+        {
+            Powerdown_blinks();     //blinks blue LED 3 times
+
+            //Clear existing wake-up config
+            LP_ClearWakeUpConfig();
+
+            //Clear any event flags
+            LP_ClearWakeUpFlags();
+
+            //configure wake-up on GPIO
+            LP_ConfigGPIOWakeUpDetect(&gpioLP0, 0, LP_WEAK_PULL_UP);
+
+            //interrupts are disabled in LP_EnterLP0
+            LP_EnterLP0();
+
+            //firmware will reset with no prior knowledge on wake-up
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/max32630fthr.lib	Tue Jan 09 19:10:44 2018 +0000
@@ -0,0 +1,1 @@
+http://developer.mbed.org/teams/MaximIntegrated/code/max32630fthr/#9eb360063579
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed-dev.lib	Tue Jan 09 19:10:44 2018 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed-dev/#b0033dcd6934