void emberAfPluginHeartbeatTickCallback(void) { static uint32_t lastMs = 0; uint32_t nowMs = halCommonGetInt32uMillisecondTick(); if (EMBER_AF_PLUGIN_HEARTBEAT_PERIOD_QS * MILLISECOND_TICKS_PER_QUARTERSECOND < elapsedTimeInt32u(lastMs, nowMs)) { halToggleLed(BOARD_HEARTBEAT_LED); lastMs = nowMs; } }
// bootloadStateIndicator // // Called by the bootloader state macros (in bootloader-gpio.h). Used to blink // the LED's or otherwise signal bootloader activity. // // Current settings: // Enabled: Turn on yellow activity LED on bootloader up and successful bootload // Turn off yellow activity LED on bootload failure // Disabled: Blink red heartbeat LED during idle polling. void bootloadStateIndicator(enum blState_e state) { // sample state indication using LEDs #ifndef NO_LED static uint16_t pollCntr = 0; switch(state) { case BL_ST_UP: // bootloader up halSetLed(BOARD_ACTIVITY_LED); break; case BL_ST_DOWN: // bootloader going down break; case BL_ST_POLLING_LOOP: // Polling for serial or radio input in // standalone bootloader. if(0 == pollCntr--) { halToggleLed(BOARD_HEARTBEAT_LED); pollCntr = 10000; } break; case BL_ST_DOWNLOAD_LOOP: // processing download image halClearLed(BOARD_HEARTBEAT_LED); halToggleLed(BOARD_ACTIVITY_LED); break; case BL_ST_DOWNLOAD_SUCCESS: halSetLed(BOARD_ACTIVITY_LED); break; case BL_ST_DOWNLOAD_FAILURE: halClearLed(BOARD_ACTIVITY_LED); break; default: break; } #endif }
/******************************************************************************* * Function Name : main. * Description : talk main routine. * Input : None * Output : None * Return : None *******************************************************************************/ void main(void) { u8 i; u32 seed; StStatus status = ST_SUCCESS; /* Initialization */ halInit(); ST_RadioGetRandomNumbers((u16 *)&seed, 2); halCommonSeedRandom(seed); uartInit(115200, 8, PARITY_NONE, 1); INTERRUPTS_ON(); /* init leds */ halInitLed(); /* Initialize radio (analog section, digital baseband and MAC). Leave radio powered up in non-promiscuous rx mode */ status = ST_RadioInit(ST_RADIO_POWER_MODE_RX_ON); assert(status==ST_SUCCESS); /* Setup some node and pan ids. The packet above is also sent to a device with the same node and pan id so that two nodes running this same image will talk to each other, even though its not right to have two nodes with the same node id */ ST_RadioSetNodeId(0x1604); ST_RadioSetPanId(0x1604); printf("\r\nSimpleMAC (%s) Talk Application\r\n",SIMPLEMAC_VERSION_STRING); while(1) { processSerialInput(); /* print out any packets that were received */ if(packetReceived == TRUE) { for (i = 8; i <= rxPacket[0]; i++) putchar(rxPacket[i]); /* The packet has been processed, so free the single entry queue up */ packetReceived = FALSE; } ledTime++; if (ledTime > 20000) { halToggleLed(LED_D1); ledTime = 0; } } }/* end main ()*/
void identifyEventHandler(void) { if (identifyDurationMs == 0) { halClearLed(LED); emberEventControlSetInactive(identifyEventControl); } else { halToggleLed(LED); if (identifyDurationMs >= MILLISECOND_TICKS_PER_QUARTERSECOND) { identifyDurationMs -= MILLISECOND_TICKS_PER_QUARTERSECOND; } else { identifyDurationMs = 0; } emberEventControlSetDelayMS(identifyEventControl, MILLISECOND_TICKS_PER_QUARTERSECOND); } }