Example for using the MAX1472 RF Transmitter for low power data transmission.
Dependencies: mbed-dev2 max32630fthr USBDevice
main.cpp
- Committer:
- MI
- Date:
- 2018-01-09
- Revision:
- 0:41ed595f83f5
- Child:
- 1:8834bc22c2e7
File content as of revision 0:41ed595f83f5:
#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 } } }