/**@brief Function for application main entry. Does not return. */ int main(void) { utils_setup(); softdevice_setup(); ant_channel_tx_broadcast_setup(); // Main loop. for (;;) { #ifdef CPU_LOAD_TRACE // Disabling interrupts in this way is highly not recommended. It has an impact on the work // of the softdecive and it is used only in order to show CPU load. __disable_irq(); LEDS_OFF(BSP_LED_0_MASK); __WFI(); LEDS_ON(BSP_LED_0_MASK); __enable_irq(); #else // Put CPU in sleep if possible. uint32_t err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); #endif // CPU_LOAD_TRACE } }
/**@brief Function for application main entry. Does not return. */ int main(void) { // ANT event message buffer. static ANT_MESSAGE ant_message_buffer; // Enable SoftDevice. uint32_t err_code; #if defined(S212) || defined(S332) err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback, ANT_LICENSE_KEY); #else err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback); #endif APP_ERROR_CHECK(err_code); // Set application IRQ to lowest priority. err_code = sd_nvic_SetPriority(SD_EVT_IRQn, NRF_APP_PRIORITY_LOW); APP_ERROR_CHECK(err_code); // Enable application IRQ (triggered from protocol). err_code = sd_nvic_EnableIRQ(SD_EVT_IRQn); APP_ERROR_CHECK(err_code); // Configure ant stack regards used channels. err_code = ant_stack_static_config(); APP_ERROR_CHECK(err_code); // Setup channel ant_channel_tx_broadcast_setup(); uint8_t event; uint8_t ant_channel; // Main loop. for (;;) { // Put CPU in sleep if possible. err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); // Extract and process all pending ANT events as long as there are any left. do { // Fetch the event. err_code = sd_ant_event_get(&ant_channel, &event, ant_message_buffer.aucMessage); if (err_code == NRF_SUCCESS) { // Handle event channel_event_handle(event, &ant_message_buffer); } } while (err_code == NRF_SUCCESS); } }