/** * Main function, initialization and main message loop * */ int main(void) { irq_initialize_vectors(); /* Initialize the board.*/ board_init(); /* Initialize the Software timer */ sw_timer_init(); /* Init the RF4CE Network layer */ if (nwk_init()!= NWK_SUCCESS) { app_alert(); } #ifdef RF4CE_CALLBACK_PARAM /* Register the ZID Callback indication */ zid_ind.zid_report_data_indication_cb = zid_report_data_indication; zid_ind.zid_get_report_indication_cb = zid_get_report_indication; register_zid_indication_callback(&zid_ind); #endif /* * The stack is initialized above, * hence the global interrupts are enabled here. */ cpu_irq_enable(); sw_timer_get_id(&APP_TIMER_ACC_READ); if (get_zid_keyrc_button(button_scan()) == ZID_COLD_START) { /* Cold start */ LED_On(ZID_APP_LED); node_status = COLD_START; nlme_reset_request(true #ifdef RF4CE_CALLBACK_PARAM ,(FUNC_PTR)nlme_reset_confirm #endif ); } else { /* Warm start */ node_status = WARM_START; nlme_reset_request(false #ifdef RF4CE_CALLBACK_PARAM ,(FUNC_PTR)nlme_reset_confirm #endif ); } /* Endless while loop */ while (1) { app_task(); /* Application task */ nwk_task(); /* RF4CE network layer task */ } }
/** * @brief This function registers the callback function for indications from the stack. * */ static void zid_indication_callback_init(void) { zid_ind.zid_heartbeat_indication_cb = zid_heartbeat_indication; zid_ind.zid_report_data_indication_cb = zid_report_data_indication; register_zid_indication_callback(&zid_ind); nwk_ind.nlme_unpair_indication_cb = nlme_unpair_indication; zid_ind.zid_standby_leave_indication_cb = zid_standby_leave_indication; register_nwk_indication_callback(&nwk_ind); }