// // Callback function for HID application // void usbHidAppPoll(void) { // // Output keyboard LED status on LEDs 2-4 // if (hidData.keyboardOutReport.ledStatus & 0x01) { bspLedSet(BSP_LED_2); } else { bspLedClear(BSP_LED_2); } if (hidData.keyboardOutReport.ledStatus & 0x02) { bspLedSet(BSP_LED_3); } else { bspLedClear(BSP_LED_3); } if (hidData.keyboardOutReport.ledStatus & 0x04) { bspLedSet(BSP_LED_4); } else { bspLedClear(BSP_LED_4); } }
void leds_error_blink() { uint8_t i; volatile uint16_t delay; // turn all LEDs off bspLedClear(BSP_LED_ALL); // blink error LED for ~10s for (i=0;i<80;i++) { bspLedToggle(BSP_LED_1); //10 seconds more or less.. for (delay=0xffff;delay>0;delay--); for (delay=0xffff;delay>0;delay--); } }
static void state_led_timer(void) { switch(app_state) { case APP_STATE_INIT: bspLedSet(BSP_LED_1); break; case APP_STATE_SCANNING: bspLedToggle(BSP_LED_1); WS_TIMER_SET(state_led_timer, 200); break; case APP_STATE_ASSOCIATING: case APP_STATE_AUTHENTICATING: bspLedClear(BSP_LED_1); bspLedToggle(BSP_LED_2); WS_TIMER_SET(state_led_timer, 200); break; case APP_STATE_CONNECTED: bspLedClear(BSP_LED_1); bspLedClear(BSP_LED_2); if (connected_led) bspLedSet(BSP_LED_3); else bspLedClear(BSP_LED_3); break; default: bspLedClear(BSP_LED_1); bspLedClear(BSP_LED_2); break; } }
static void connected_led_timer(void) { connected_led = false; bspLedClear(BSP_LED_3); }
/***************************************************************************//** * @brief Runs the main routine * * This function covers the main application code. * * @note Depending on the application, you can use either one or several * calls from the following functions from the SIGFOX Library: * * @note \li SfxSendFrame(message, length, NULL, NULL) : Send an Uplink frame * @note \li SfxSendFrame(message, length, ReceivedPayload, TRUE) : Downlink with ack * @note \li SfxSendBit( 0, NULL, NULL) : Send a bit * @note \li SfxSendOutOfBand() : Send OOB frame * @note \li SfxTxTestMode(nb_frames, channel_number) : Tx TestModeFrame activation ******************************************************************************/ void main(void) { SFX_error_t volatile err; // error returned from sigfox api functions. (For debug purpose) #if defined(AT_CMD) host_cmd_status_t hostCmdStatus; char cmd[40]; unsigned char length; #endif #if defined(PB_KEY) unsigned char buttonPressed; #endif //Initialize the memory dynamic_memory_init(); // Initialize MCU and Peripherals initMCU(); #ifdef __MSP430F5438A__ // Display welcome screen on LCD welcomeLCD(); #endif // Write the uplink and downlink frequencies if device is programmed for first time resetCF(); // SIGFOX library init err = SfxInit(); assert(SFX_ERR_NONE == err); // Infinite loop for(;;) { GPIO_setAsOutputPin(GPIO_PORT_P4, GPIO_PIN7); // GPIO_setOutputLowOnPin(GPIO_PORT_P4, GPIO_PIN7); // P4OUT |= 0x00; P4OUT &= ~BIT7; #if defined(AT_CMD) // Detect Carriage Return in the string if(uartGetRxEndOfStr() == END_OF_LINE_DETECTED) { // Reset end of string detection uartResetRxEndOfStr(); // Get the input string and its length length = uartGetRxStrLength(); uartGetStr(cmd, length); // Parse the string to find AT commands hostCmdStatus = parseHostCmd((unsigned char *)cmd, length); assert(HOST_CMD_NOT_FOUND != hostCmdStatus); } #endif #if defined(PB_KEY) buttonPressed = bspKeyPushed(BSP_KEY_ALL); // Detect button push to send the message if((buttonPressed == BSP_KEY_SELECT) || (buttonPressed == BSP_KEY_UP)) { #if defined(__MSP430F5438A__) // Update LCD updateLCD(); // Toggle LED indicators bspLedClear(BSP_LED_3); bspLedClear(BSP_LED_4); #endif bspLedClear(BSP_LED_2); bspLedSet(BSP_LED_1); if(buttonPressed == BSP_KEY_UP) { // Send uplink only frame err = SfxSendFrame(message, sizeof(message), NULL, NULL); } else if(buttonPressed == BSP_KEY_SELECT) { // Send a bi-directional frame err = SfxSendFrame(message, sizeof(message), ReceivedPayload, TRUE); } // Reset button status buttonPressed = 0; #if defined (__MSP430F5438A__) // Clear LED1 bspLedClear(BSP_LED_1); // LED indicator for sigfox API error status if (err == SFX_ERR_NONE) { bspLedSet(BSP_LED_3); } else { bspLedSet(BSP_LED_4); } // Update LCD updateLCD(); #elif defined (__MSP430F5529__) if (err == SFX_ERR_NONE) { bspLedSet(BSP_LED_2); } else { bspLedClear(BSP_LED_2); } #endif // Increment in message message[11]++; } else { #if defined (__MSP430F5438A__) // Set LED2 bspLedSet(BSP_LED_2); #elif defined (__MSP430F5529__) // Clear LED1 bspLedClear(BSP_LED_1); #endif //MSP } #endif //INTERFACE } }
void leds_debug_off() { bspLedClear(BSP_LED_3); }
void leds_radio_off() { bspLedClear(BSP_LED_4); }
void leds_sync_off() { bspLedClear(BSP_LED_2); }
void leds_error_off() { bspLedClear(BSP_LED_1); }
void leds_all_off() { bspLedClear(BSP_LED_ALL); }