/**@brief Function for the timer, tracer, and BSP initialization. */ static void utils_setup(bool * p_erase_bonds) { uint32_t err_code; bsp_event_t startup_event; app_trace_init(); APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); //bsp init ant err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL); //FROM BLE uint32_t err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),bsp_event_handler); APP_ERROR_CHECK(err_code); // Create timers for BLE err_code = app_timer_create(&m_battery_timer_id, APP_TIMER_MODE_REPEATED, battery_level_meas_timeout_handler); APP_ERROR_CHECK(err_code); // Create battery timer. err_code = app_timer_create(&m_rsc_meas_timer_id, APP_TIMER_MODE_REPEATED, rsc_meas_timeout_handler); APP_ERROR_CHECK(err_code); err_code = bsp_btn_ble_init(NULL, &startup_event); APP_ERROR_CHECK(err_code); *p_erase_bonds = (startup_event == BSP_EVENT_CLEAR_BONDING_DATA); }
/**@brief Timer initialization. * * @details Initializes the timer module. This creates and starts application timers. */ void timers_init(void) { uint32_t err_code; // Initialize timer module APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); // Create battery timer err_code = app_timer_create(&m_battery_timer_id, APP_TIMER_MODE_REPEATED, battery_level_meas_timeout_handler); APP_ERROR_CHECK(err_code); err_code = app_timer_create(&m_alert_led_blink_timer_id, APP_TIMER_MODE_SINGLE_SHOT, mild_alert_timeout_handler); APP_ERROR_CHECK(err_code); err_code = app_timer_create(&m_adv_led_blink_timer_id, APP_TIMER_MODE_SINGLE_SHOT, adv_led_blink_timeout_handler); APP_ERROR_CHECK(err_code); err_code = app_timer_create(&m_rtc_update_timer_id, APP_TIMER_MODE_REPEATED, rtc_timeout_handler); APP_ERROR_CHECK(err_code); }
/** * @brief Function for application main entry. */ int main(void) { uint8_t new_duty_cycle; uint32_t err_code; lfclk_init(); // Start APP_TIMER to generate timeouts. APP_TIMER_INIT(APP_TIMER_PRESCALER, OP_QUEUES_SIZE, NULL); /*Initialize low power PWM for all 3 channels of RGB or 3 channels of leds on pca10028*/ pwm_init(); while (true) { /* Duty cycle can also be changed from main context. */ new_duty_cycle = low_power_pwm_2.period - low_power_pwm_2.duty_cycle; err_code = low_power_pwm_duty_set(&low_power_pwm_2, new_duty_cycle); APP_ERROR_CHECK(err_code); nrf_delay_ms(500); new_duty_cycle = low_power_pwm_2.period - low_power_pwm_2.duty_cycle; err_code = low_power_pwm_duty_set(&low_power_pwm_2, new_duty_cycle); APP_ERROR_CHECK(err_code); nrf_delay_ms(500); } }
/**@brief Application main function. */ int main(void) { uint32_t err_code; bool erase_bonds; uint8_t start_string[] = START_STRING; // Initialize. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); uart_init(); buttons_leds_init(&erase_bonds); ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); printf("%s",start_string); UnityMain(0, NULL, RunAllTests); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;;) { power_manage(); } }
/**@brief Function for application main entry. */ int main(void) { uint32_t err_code = NRF_SUCCESS; // Initialize. ble_stack_init(); APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL); err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(APP_BUTTON_DETECTION_DELAY, APP_TIMER_PRESCALER), bsp_event_handler); APP_ERROR_CHECK(err_code); // Initialize advertising. advertising_init(); // Start execution. advertising_start(); // Enter main loop. for (;;) { err_code = sd_app_evt_wait(); APP_ERROR_CHECK(err_code); } }
/** * @brief Function for application main entry. */ int main(void) { uint32_t err_code; // Initialize. err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code); ble_stack_init(); advertising_init(); // Start execution. NRF_LOG_INFO("BLE Beacon started\r\n"); advertising_start(); // Enter main loop. for (;; ) { if (NRF_LOG_PROCESS() == false) { power_manage(); } } }
int main(void) { uint32_t err_code; APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL); err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),NULL); APP_ERROR_CHECK(err_code); leds_init(); timers_init(); uart_init(); ble_stack_init(); device_manager_init(); db_discovery_init(); uart_c_init(); printf("Scanning ...\r\n"); // Start scanning for peripherals and initiate connection // with devices that advertise NUS UUID. scan_start(); for (;;) { power_manage(); } }
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(); } }
/*JSON{ "type" : "staticmethod", "class" : "Bluetooth", "name" : "init", "generate" : "jswrap_nrf_bluetooth_init" }*/ void jswrap_nrf_bluetooth_init(void) { uint32_t err_code; bool erase_bonds; // Initialize. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); buttons_leds_init(&erase_bonds); ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); ble_com = false; // Enter main loop. //for (;;) //{ //power_manage(); //} }
uint32_t socket_medium_init(void) { APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); static ipv6_medium_init_params_t ipv6_medium_init_params; memset(&ipv6_medium_init_params, 0x00, sizeof(ipv6_medium_init_params)); ipv6_medium_init_params.ipv6_medium_evt_handler = on_ipv6_medium_evt; ipv6_medium_init_params.ipv6_medium_error_handler = on_ipv6_medium_error; ipv6_medium_init_params.use_scheduler = false; uint32_t err_code = ipv6_medium_init(&ipv6_medium_init_params, IPV6_MEDIUM_ID_BLE, &m_ipv6_medium); APP_ERROR_CHECK(err_code); eui48_t ipv6_medium_eui48; err_code = ipv6_medium_eui48_get(m_ipv6_medium.ipv6_medium_instance_id, &ipv6_medium_eui48); ipv6_medium_eui48.identifier[EUI_48_SIZE - 1] = 0x00; err_code = ipv6_medium_eui48_set(m_ipv6_medium.ipv6_medium_instance_id, &ipv6_medium_eui48); APP_ERROR_CHECK(err_code); err_code = ipv6_medium_eui64_get(m_ipv6_medium.ipv6_medium_instance_id, &eui64_local_iid); APP_ERROR_CHECK(err_code); return NRF_SUCCESS; }
/** * @brief Function for setup all thinks not directly associated witch ANT stack/protocol. * @desc Initialization of: @n * - app_tarce for debug. * - app_timer, presetup for bsp and ant pulse simulation. * - bsp for signaling leds and user buttons (if use button is enabled in example). * - ant pulse simulate for task of filling hrm profile data. */ static void utils_setup(void) { uint32_t err_code; app_trace_init(); // Initialize and start a single continuous mode timer, which is used to update the event time // on the main data page. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL); #if (MODIFICATION_TYPE == MODIFICATION_TYPE_BUTTON) /** @snippet [ANT Pulse simulator button init] */ err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), bsp_evt_handler); /** @snippet [ANT Pulse simulator button init] */ #else err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code); #endif err_code = app_timer_create(&m_tick_timer, APP_TIMER_MODE_REPEATED, app_tick_handler); APP_ERROR_CHECK(err_code); // Schedule a timeout event every 2 seconds err_code = app_timer_start(m_tick_timer, APP_TICK_EVENT_INTERVAL, NULL); APP_ERROR_CHECK(err_code); }
int main(void) { bool erase_bonds; // Initialize. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL); buttons_leds_init(&erase_bonds); uart_init(); printf("Battery collector example\r\n"); ble_stack_init(); device_manager_init(erase_bonds); db_discovery_init(); //hrs_c_init(); bas_c_init(); pwm_init(); // Start scanning for peripherals and initiate connection // with devices that advertise Heart Rate UUID. scan_start(); for (;; ) { power_manage(); } }
/**@brief Application main function. */ int main(void) { uint32_t err_code; bool erase_bonds; // Initialize. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); buttons_leds_init(&erase_bonds); ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); gpio_init(); timer_init(); //timer task to refresh RGB LED Board game_init(); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;;) { power_manage(); moveDisc(getInput()); } }
/**@brief Application main function. */ int main(void) { uint32_t err_code; bool erase_bonds; // Initialize. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); uart_init(); buttons_leds_init(&erase_bonds); ble_stack_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); printf("\r\nUART Start!\r\n"); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;;) { power_manage(); } }
int main(void) { // uint32_t err_code; APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS); ble_stack_init(); sys_Initialize(); sys_Timer_Handler_Init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); sec_params_init(); sys_printf("Gift Air Project Start\n\r"); advertising_start(); sys_Timer_Handler_Start(); NRF_WDT->RR[0] = WDT_RR_RR_Reload; //Reload watchdog register 0 // Enter main loop for (;;) { power_manage(); //2sec, 200ms } }
/**@brief Function for the Timer initialization. * * @details Initializes the timer module. This creates and starts application timers. */ static void timers_init(void) { uint32_t err_code; // Initialize timer module. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); // Create timers. err_code = app_timer_create(&m_battery_timer_id, APP_TIMER_MODE_REPEATED, battery_level_meas_timeout_handler); APP_ERROR_CHECK(err_code); err_code = app_timer_create(&m_heart_rate_timer_id, APP_TIMER_MODE_REPEATED, heart_rate_meas_timeout_handler); APP_ERROR_CHECK(err_code); err_code = app_timer_create(&m_rr_interval_timer_id, APP_TIMER_MODE_REPEATED, rr_interval_timeout_handler); APP_ERROR_CHECK(err_code); err_code = app_timer_create(&m_sensor_contact_timer_id, APP_TIMER_MODE_REPEATED, sensor_contact_detected_timeout_handler); APP_ERROR_CHECK(err_code); }
/** * @brief Function for application main entry. */ int main(void) { uint32_t err_code; clock_init(); // Start APP_TIMER to generate timeouts. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL); leds_init(); err_code = bsp_init(BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), bsp_evt_handler); APP_ERROR_CHECK(err_code); nfc_init(); m_active_led_mask = BSP_LED_0_MASK; err_code = led_softblink_start(m_active_led_mask); APP_ERROR_CHECK(err_code); while (true) { __WFE(); softblink_led_update(); } }
void timers_app_init(void) { APP_TIMER_INIT(BIKE_TIMER_PRESCALER, BIKE_TIMER_MAX_TIMERS, BIKE_TIMER_OP_QUEUE_SIZE, false); APP_TIMER_APPSH_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, true); }
int main(void) { ret_code_t err_code; err_code = NRF_LOG_INIT(); APP_ERROR_CHECK(err_code); NRF_LOG_PRINTF("[APP]: Multilink Example\r\n"); leds_init(); APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL); buttons_init(); ble_stack_init(); db_discovery_init(); lbs_c_init(); // Start scanning for peripherals and initiate connection to devices which // advertise. scan_start(); // Turn on the LED to signal scanning. LEDS_ON(CENTRAL_SCANNING_LED); for (;;) { // Wait for BLE events. power_manage(); } }
/**@brief Application main function. */ int main(void) { //printf("main"); uint8_t start_string[] = START_STRING; uint32_t err_code; // Initialize. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS); ble_stack_init(); //uart_init(); err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code); err_code = bsp_buttons_enable(1 << WAKEUP_BUTTON_ID); APP_ERROR_CHECK(err_code); gap_params_init(); services_init(); advertising_init(); conn_params_init(); sec_params_init(); printf("%s",start_string); advertising_start(); init_leds(); for (;;) { power_manage(); } }
int main(void) { uint32_t err_code; bool erase_bonds; // Initialize. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL); buttons_leds_init(&erase_bonds); uart_init(); printf("Relay Example\r\n"); ble_stack_init(); device_manager_init(erase_bonds); db_discovery_init(); hrs_c_init(); rscs_c_init(); gap_params_init(); services_init(); advertising_init(); conn_params_init(); // Start scanning for peripherals and initiate connection // with devices that advertise Heart Rate UUID. scan_start(); // Start advertising. err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); for (;; ) { power_manage(); } }
/** * @brief Function for application main entry. * @return 0. int return type required by ANSI/ISO standard. */ int main(void) { uint32_t err_code = NRF_SUCCESS; clock_initialization(); APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, NULL); err_code = NRF_LOG_INIT(NULL); APP_ERROR_CHECK(err_code); err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code); // Set radio configuration parameters radio_configure(); NRF_RADIO->PACKETPTR = (uint32_t)&packet; err_code = bsp_indication_set(BSP_INDICATE_USER_STATE_OFF); NRF_LOG_INFO("Wait for first packet\r\n"); APP_ERROR_CHECK(err_code); NRF_LOG_FLUSH(); while (true) { uint32_t received = read_packet(); err_code = bsp_indication_set(BSP_INDICATE_RCV_OK); NRF_LOG_INFO("Packet was received\r\n"); APP_ERROR_CHECK(err_code); NRF_LOG_INFO("The contents of the package is %u\r\n", (unsigned int)received); NRF_LOG_FLUSH(); } }
/** * Function for application main entry. */ int main(void) { init_leds(); init_clock(); uint32_t err_code; // Button configuration structure. static app_button_cfg_t p_button[] = { {BUTTON_1, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}, {BUTTON_2, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}, {BUTTON_3, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}, {BUTTON_4, APP_BUTTON_ACTIVE_LOW, NRF_GPIO_PIN_PULLUP, button_handler}}; // Macro for initializing the application timer module. // It will handle dimensioning and allocation of the memory buffer required by the timer, making sure that the buffer is correctly aligned. It will also connect the timer module to the scheduler (if specified). APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, NULL); // Macro for initializing the GPIOTE module. // It will handle dimensioning and allocation of the memory buffer required by the module, making sure that the buffer is correctly aligned. APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS); // Initializing the buttons. err_code = app_button_init(p_button, sizeof(p_button) / sizeof(p_button[0]), BUTTON_DEBOUNCE_DELAY); APP_ERROR_CHECK(err_code); // Enabling the buttons. err_code = app_button_enable(); APP_ERROR_CHECK(err_code); while(true) { // Do nothing. } }
/**@brief Function for the Timer initialization. * * @details Initializes the timer module. This creates and starts application timers. */ static void timers_init(void) { uint32_t err_code; /* Initialise timer module */ APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_OP_QUEUE_SIZE, false); // Create timers. err_code = app_timer_create(&m_battery_timer_id, APP_TIMER_MODE_REPEATED, battery_level_meas_timeout_handler); if (err_code == NRF_SUCCESS) debug_printf("Battery timer initialised!\r\n"); else { debug_printf("Error with initialising battery timer.\r\n"); APP_ERROR_CHECK(err_code); } err_code = app_timer_create(&m_temperature_timer_id, APP_TIMER_MODE_REPEATED, temperature_timeout_handler); err_code = app_timer_create(&m_door_timer_id, APP_TIMER_MODE_REPEATED, door_timeout_handler); }
static void timers_init(void) { // Initialize timer module. APP_TIMER_INIT(APP_TIMER_PRESCALER, 1, 2, false); // Create timers. }
/**@brief Function for the Timer initialization. * * @details Initializes the timer module. */ static void timers_init(void) { // Initialize timer module, making it use the scheduler APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); uint32_t err_code = app_timer_create(&m_advdata_update_timer, APP_TIMER_MODE_REPEATED, advdata_update_timer_timeout_handler); APP_ERROR_CHECK(err_code); }
/**@brief Ladybug_Flash uses an app timer. App timers require the low frequency clock to be ticking. * Initialize the timer module. * \callgraph */ static void timers_init(void){ // Initialize the low frequency clock. uint32_t err_code = nrf_drv_clock_init(NULL); APP_ERROR_CHECK(err_code); nrf_drv_clock_lfclk_request(); // Initialize the timer queue. APP_TIMER_INIT(m_app_timer_prescaler, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); }
/**@brief Function for application main entry, does not return. * * @details The main function will do all necessary initalization. This includes sdm rx module * and SoftDevice. */ int main(void) { uint32_t err_code; #if defined(TRACE_UART) app_uart_comm_params_t comm_params = { RX_PIN_NUMBER, TX_PIN_NUMBER, RTS_PIN_NUMBER, CTS_PIN_NUMBER, APP_UART_FLOW_CONTROL_DISABLED, false, UART_BAUDRATE_BAUDRATE_Baud38400 }; APP_UART_FIFO_INIT(&comm_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_error_handle, APP_IRQ_PRIORITY_LOW, err_code); APP_ERROR_CHECK(err_code); #endif // TRACE_UART #if defined(TRACE_GPIO) // Initialize timer module. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL); APP_ERROR_CHECK(err_code); #endif // TRACE_GPIO // In case of logging enabled, we enable sdm_rx module first. err_code = sdm_rx_init(); APP_ERROR_CHECK(err_code); // Enable SoftDevice. err_code = sd_softdevice_enable(NRF_CLOCK_LFCLKSRC_XTAL_50_PPM, softdevice_assert_callback); 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); err_code = ant_stack_static_config(); APP_ERROR_CHECK(err_code); // Setup Channel_0 as a SDM RX. ant_channel_sdm_rx_setup(); sdm_main_loop(); }
int main(void) { uint32_t err_code; bool erase_bonds; // uint8_t start_string[] = START_STRING; //const ble_gap_addr_t t_addr={0,{0xaa,0x55,0x33,0x44,0x55,0x66}}; // const char temp_str[]={0xaa,0x5c,0x00,0x02,0x00,0x00,0xa1,0x55}; // Initialize. //bsp_configuration(); APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); buttons_leds_init(&erase_bonds); #if ENABLE_COS simple_uart_init(UART_POWEROFF_BT_DELAY); #else uart_init_lowPower(); #endif etSpim1NorFlashInit(); #if DEBUG_UART_EN //DbgPrintf("\r\n===flash_init===\r\n"); #endif ble_stack_init(); #ifdef BLE_DFU_APP_SUPPORT device_manager_init(erase_bonds); #endif //BT_set_address((UINT8 *)DEVICE_MAC_ADDR); BT_set_address(); gap_params_init(); advertising_init(); services_init(); //advertising_init(); conn_params_init(); #if ENABLE_COS SetToGetKEYID(); #endif dev_init(); //err_code = ble_advertising_start(BLE_ADV_MODE_SLOW); #if DEBUG_UART_EN // DbgPrintf("go to advertising7\r\n"); #endif err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;;) { main_loop(); power_manage(); #if TAP_DOUBLE_CLCIK_ENABLE test_display_step_num(test_click_count); #endif } }
static void timers_init(void) { app_timer_id_t clockTimerId; // Initialize timer module. APP_TIMER_INIT(APP_TIMER_PRESCALER, APP_TIMER_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); app_timer_create( &clockTimerId, APP_TIMER_MODE_REPEATED, clockTickHandler ); app_timer_start( clockTimerId, APP_TIMER_TICKS( 500, APP_TIMER_PRESCALER), NULL ); }