// // Function Name: bootloadGpioInit // Description: This function selects the chip's GPIO configuration. These // settings are the minimum base configuration needed to // support the bootloader functionality. These settings can // be modified for custom applications as long as the base // settings are preserved. // Parameters: none // Returns: none // void bootloadGpioInit(void) { halInternalEnableWatchDog(); #ifdef BTL_HAS_RADIO if (paIsPresent()) { // The PHY_CONFIG token indicates that a power amplifier is present. // Not all power amplifiers require both TX_ACTIVE and nTX_ACTIVE. If // your design does not require TX_ACTIVE or nTX_ACTIVE, you can remove // the GPIO configuration for the unused signal to save a bit of flash. // Configure GPIO PC5 to support TX_ACTIVE alternate output function. halGpioSetConfig(PORTC_PIN(5),GPIOCFG_OUT_ALT); // Configure GPIO PC6 to support nTX_ACTIVE alternate output function. halGpioSetConfig(PORTC_PIN(6),GPIOCFG_OUT_ALT); } #endif #ifndef NO_LED halGpioSetConfig(BOARD_ACTIVITY_LED, GPIOCFG_OUT); halClearLed(BOARD_ACTIVITY_LED); halGpioSetConfig(BOARD_HEARTBEAT_LED, GPIOCFG_OUT); halSetLed(BOARD_HEARTBEAT_LED); #endif CONFIGURE_EXTERNAL_REGULATOR_ENABLE(); }
// Event function stubs void buttonEventHandler(void) { if (emberAfRf4ceZrc11EnableAutoDiscoveryResponse() == EMBER_SUCCESS) { halPlayTune_P(waitTune, TRUE); halSetLed(LED); } else { halPlayTune_P(sadTune, TRUE); } emberEventControlSetInactive(buttonEventControl); }
void halStackIndicateActivity(bool turnOn) { #if NO_LED // Don't touch LEDs when built with NO_LED #else//!NO_LED if(turnOn) { halSetLed(BOARD_ACTIVITY_LED); } else { halClearLed(BOARD_ACTIVITY_LED); } #endif//NO_LED }
// 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 }
/** @brief Server Attribute Changed * * On/off cluster, Server Attribute Changed * * @param endpoint Endpoint that is being initialized Ver.: always * @param attributeId Attribute that changed Ver.: always */ void emberAfOnOffClusterServerAttributeChangedCallback(int8u endpoint, EmberAfAttributeId attributeId) { // When the on/off attribute changes, set the LED appropriately. If an error // occurs, ignore it because there's really nothing we can do. if (attributeId == ZCL_ON_OFF_ATTRIBUTE_ID) { boolean onOff; if (emberAfReadServerAttribute(endpoint, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, (int8u *)&onOff, sizeof(onOff)) == EMBER_ZCL_STATUS_SUCCESS) { if (onOff) { halSetLed(LED); } else { halClearLed(LED); } } } }
// Cluster: On/off, server EmberAfStatus emberAfOnOffClusterServerCommandParse(EmberAfClusterCommand *cmd) { boolean wasHandled = FALSE; int8u OnOfffCmdBeforeNumber; if (!cmd->mfgSpecific) { switch (cmd->apsFrame->destinationEndpoint){ case 1 : OnOfffCmdBeforeNumber = 1; break; case 3 : OnOfffCmdBeforeNumber = 2; break; case 5 : OnOfffCmdBeforeNumber = 3; break; case 7 : OnOfffCmdBeforeNumber = 4; break; case LedLightOptionEndpoint: OnOfffCmdBeforeNumber = 5; break; } if (CommonGetDurationTime(OnOffCmdBeforeTimer[OnOfffCmdBeforeNumber]) > 1000){ OnOffCmdBeforeTimer[OnOfffCmdBeforeNumber] = (int16u)halCommonGetInt32uMillisecondTick(); switch (cmd->commandId) { case ZCL_OFF_COMMAND_ID: { // Command is fixed length: 0 wasHandled = emberAfOnOffClusterOffCallback(); break; } case ZCL_ON_COMMAND_ID: { // Command is fixed length: 0 wasHandled = emberAfOnOffClusterOnCallback(); break; } case ZCL_TOGGLE_COMMAND_ID: { // Command is fixed length: 0 wasHandled = emberAfOnOffClusterToggleCallback(); break; } } // User Controller Command int8u CurrentState; emberAfReadServerAttribute(cmd->apsFrame->destinationEndpoint, ZCL_ON_OFF_CLUSTER_ID, ZCL_ON_OFF_ATTRIBUTE_ID, &CurrentState, sizeof(CurrentState)); if (status(wasHandled, cmd->mfgSpecific) == EMBER_ZCL_STATUS_SUCCESS) { if (cmd->apsFrame->destinationEndpoint == LedLightOptionEndpoint) { if (CurrentState == 1) { halClearLed(LED_LIGHT); } else{ halSetLed(LED_LIGHT); } } else { if (CurrentState == 1) { UartSendSwitchControlNumber( (((cmd->apsFrame->destinationEndpoint) >> 1) + 1), OnRelay); } else { UartSendSwitchControlNumber( (((cmd->apsFrame->destinationEndpoint) >> 1) + 1), OffRelay); } // Send to Bind Device SendViaBindingTable(cmd->apsFrame->destinationEndpoint, CurrentState, OnOffType); // Send On-Off AttributeResponse, Zipato stupid update :D-----------------------------// SendOnOffControlReadAttribute(cmd->apsFrame->destinationEndpoint, CurrentState); // on-off led if (CurrentState == 1) { CommonSetLed(cmd->apsFrame->destinationEndpoint >> 1); } else {