int main(void) { nrf_gpio_cfg_output(PIN_LED_0); nrf_gpio_cfg_output(PIN_LED_1); nrf_gpio_cfg_input(PIN_BUTTON_0, GPIO_PIN_CNF_PULL_Pullup); nrf_gpio_pin_clear(PIN_LED_0); nrf_gpio_pin_clear(PIN_LED_1); lfclk_request(); APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, app_timer_evt_schedule); APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); create_timers(); timer_start(0); timer_start(1); while (1) { app_sched_execute(); __WFI(); } }
/**@brief Function for initializing the BLE stack. * * @details Initializes the SoftDevice and the BLE event interrupt. * * @param[in] init_softdevice true if SoftDeviceshould be initialized. The SoftDevice must only * be initialized if a chip reset has occured. Soft reset from * application must not reinitialize the SoftDevice. */ static void ble_stack_init(bool init_softdevice) { uint32_t err_code; sd_mbr_command_t com = {SD_MBR_COMMAND_INIT_SD, }; if (init_softdevice) { err_code = sd_mbr_command(&com); APP_ERROR_CHECK(err_code); } err_code = sd_softdevice_vector_table_base_set(BOOTLOADER_REGION_START); APP_ERROR_CHECK(err_code); // TODO: enable if we're on a device with 32kHz xtal /*nrf_clock_lf_cfg_t clock_lf_cfg = { .source = NRF_CLOCK_LF_SRC_XTAL, .rc_ctiv = 0, .rc_temp_ctiv = 0, .xtal_accuracy = NRF_CLOCK_LF_XTAL_ACCURACY_20_PPM};*/ nrf_clock_lf_cfg_t clock_lf_cfg = { .source = NRF_CLOCK_LF_SRC_RC, .rc_ctiv = 16, // recommended for nRF52 .rc_temp_ctiv = 2, // recommended for nRF52 .xtal_accuracy = 0}; SOFTDEVICE_HANDLER_APPSH_INIT(&clock_lf_cfg, true); // Enable BLE stack. ble_enable_params_t ble_enable_params; // Only one connection as a central is used when performing dfu. err_code = softdevice_enable_get_default_config(1, 1, &ble_enable_params); APP_ERROR_CHECK(err_code); ble_enable_params.gatts_enable_params.service_changed = IS_SRVC_CHANGED_CHARACT_PRESENT; err_code = softdevice_enable(&ble_enable_params); APP_ERROR_CHECK(err_code); err_code = softdevice_sys_evt_handler_set(sys_evt_dispatch); APP_ERROR_CHECK(err_code); } /**@brief Function for event scheduler initialization. */ static void scheduler_init(void) { APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); }
/**@brief Main function of the connectivity application. */ int main(void) { uint32_t err_code = NRF_SUCCESS; #if ( defined(SER_PHY_HCI_DEBUG_ENABLE) || defined(SER_PHY_DEBUG_APP_ENABLE)) debug_init(NULL); #endif /* Initialize scheduler queue. */ APP_SCHED_INIT(SER_CONN_SCHED_MAX_EVENT_DATA_SIZE, SER_CONN_SCHED_QUEUE_SIZE); /* Initialize SoftDevice. * SoftDevice Event IRQ is not scheduled but immediately copies BLE events to the application * scheduler queue */ SOFTDEVICE_HANDLER_INIT(NRF_CLOCK_LFCLKSRC_XTAL_20_PPM, false); /* Subscribe for BLE events. */ err_code = softdevice_ble_evt_handler_set(ser_conn_ble_event_handle); APP_ERROR_CHECK(err_code); /* Open serialization HAL Transport layer and subscribe for HAL Transport events. */ err_code = ser_hal_transport_open(ser_conn_hal_transport_event_handle); APP_ERROR_CHECK(err_code); /* Enter main loop. */ for (;;) { /* Process SoftDevice events. */ app_sched_execute(); /* Process received packets. * We can NOT add received packets as events to the application scheduler queue because * received packets have to be processed before SoftDevice events but the scheduler queue * does not have priorities. */ err_code = ser_conn_rx_process(); APP_ERROR_CHECK(err_code); /* Sleep waiting for an application event. */ err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); } }
int main() { HardwareInit(); APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); timers_init(); BLEStart(); // timers_start(); // blink(); while (1) { app_sched_execute(); uint32_t err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); //BlueIOADCStart(); } }
/**@brief Function for application main entry. */ int main(void) { bool erase_bonds; uint32_t err_code; // Initialize. app_trace_init(); timers_init(); uart_init(); buttons_leds_init(&erase_bonds); ble_stack_init(); APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); device_manager_init(erase_bonds); db_discovery_init(); scheduler_init(); gap_params_init(); service_init(); advertising_init(); conn_params_init(); LOG("ANT ANCS\n"); ant_profile_setup(); // Start execution. err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;;) { app_sched_execute(); power_manage(); } }
int main() { //APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS); nrf_gpio_cfg_output(LED_CONNECTED); APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); timers_init(); uart_init(); // blink(); nrf_gpio_pin_clear(LED_CONNECTED); BLEStart(); // timers_start(); // blink(); while (1) { app_sched_execute(); uint32_t err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); //BlueIOADCStart(); } }
/**@brief Function for event scheduler initialization. */ static void scheduler_init(void) { APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); }
/**@brief Function for the Event Scheduler initialization. */ static void scheduler_init(void) { APP_SCHED_INIT(APP_TIMER_SCHED_EVT_SIZE, SCHED_QUEUE_SIZE); }
EventManager::EventManager( SafetyMode safety ) { APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHEDULER_QUEUE_SIZE); }
static void timers_init(void) { APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, SCHED_QUEUE_SIZE); // Initialize timer module. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); }