当前位置: 首页>>代码示例>>C++>>正文


C++ APP_TIMER_TICKS函数代码示例

本文整理汇总了C++中APP_TIMER_TICKS函数的典型用法代码示例。如果您正苦于以下问题:C++ APP_TIMER_TICKS函数的具体用法?C++ APP_TIMER_TICKS怎么用?C++ APP_TIMER_TICKS使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了APP_TIMER_TICKS函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: blesi7021_write_handler

/**@brief Function for handling write events to the si7021 characteristic.
 *
 * @param[in] p_si7021  Instance of si7021 Service to which the write applies.
 * @param[in] led_state Written/desired state of the LED.
 */
static void blesi7021_write_handler(ble_si7021_t * p_si7021, ble_si7021_evt_t *evt) {
    uint32_t err_code;

    if (evt->evt_type == BLE_si7021_EVT_NOTIFICATION_ENABLED) {
    	NRF_LOG_INFO("BLE_si7021_EVT_NOTIFICATION_ENABLED\r\n");
        err_code = app_timer_start(m_si7021_timer_id, APP_TIMER_TICKS(p_si7021->interval, APP_TIMER_PRESCALER), NULL);
        APP_ERROR_CHECK(err_code);
        p_si7021->running=1;
    } else if (evt->evt_type == BLE_si7021_EVT_INTERVAL_CHANGE) {
    	NRF_LOG_INFO("BLE_si7021_EVT_INTERVAL_CHANGE %d\r\n",p_si7021->interval);
    	if (p_si7021->running==1) {
            err_code = app_timer_stop(m_si7021_timer_id);
            APP_ERROR_CHECK(err_code);
            p_si7021->running=0;

            err_code = app_timer_start(m_si7021_timer_id, APP_TIMER_TICKS(p_si7021->interval, APP_TIMER_PRESCALER), NULL);
            APP_ERROR_CHECK(err_code);
            p_si7021->running=1;
    	}
    } else { // BLE_si7021_EVT_NOTIFICATION_DISABLED | BLE_si7021_EVT_DISCONNECTED
    	NRF_LOG_INFO("BLE_si7021_EVT_NOTIFICATION_DISABLED\r\n");
        err_code = app_timer_stop(m_si7021_timer_id);
        APP_ERROR_CHECK(err_code);
        p_si7021->running=0;
    }
}
开发者ID:pcbreflux,项目名称:nordic,代码行数:31,代码来源:main.c

示例2: utils_setup

/**
 * @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);
}
开发者ID:kevin-ledinh,项目名称:banana-tree,代码行数:38,代码来源:main.c

示例3: btle_gap_init

error_t btle_gap_init(void)
{
    ble_gap_conn_params_t gap_conn_params = {0};

    gap_conn_params.min_conn_interval = msec_to_1_25msec(
                                            CFG_GAP_CONNECTION_MIN_INTERVAL_MS);  // in 1.25ms units
    gap_conn_params.max_conn_interval = msec_to_1_25msec(
                                            CFG_GAP_CONNECTION_MAX_INTERVAL_MS);  // in 1.25ms unit
    gap_conn_params.slave_latency     = CFG_GAP_CONNECTION_SLAVE_LATENCY;
    gap_conn_params.conn_sup_timeout  =
        CFG_GAP_CONNECTION_SUPERVISION_TIMEOUT_MS / 10; // in 10ms unit

    ble_gap_conn_sec_mode_t sec_mode;
    BLE_GAP_CONN_SEC_MODE_SET_OPEN(&sec_mode); // no security is needed

    // ASSERT_STATUS( sd_ble_gap_device_name_set(&sec_mode,   //_modify
                   // (const uint8_t *)
                   // CFG_GAP_LOCAL_NAME,
                   // strlen(CFG_GAP_LOCAL_NAME)));
    // ASSERT_STATUS( sd_ble_gap_appearance_set(CFG_GAP_APPEARANCE));
    // ASSERT_STATUS( sd_ble_gap_ppcp_set(&gap_conn_params));
    // ASSERT_STATUS( sd_ble_gap_tx_power_set(CFG_BLE_TX_POWER_LEVEL));
    nrf_err_check( sd_ble_gap_device_name_set(&sec_mode,  
                   (const uint8_t *)
                   CFG_GAP_LOCAL_NAME,
                   strlen(CFG_GAP_LOCAL_NAME)) );
    nrf_err_check( sd_ble_gap_appearance_set(CFG_GAP_APPEARANCE) );
    nrf_err_check( sd_ble_gap_ppcp_set(&gap_conn_params) );
    nrf_err_check( sd_ble_gap_tx_power_set(CFG_BLE_TX_POWER_LEVEL) );
    
    /* Connection Parameters */
    enum {
        FIRST_UPDATE_DELAY = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER),
        NEXT_UPDATE_DELAY  = APP_TIMER_TICKS(5000, CFG_TIMER_PRESCALER),
        MAX_UPDATE_COUNT   = 3
    };

    ble_conn_params_init_t cp_init = {0};

    cp_init.p_conn_params                  = NULL;
    cp_init.first_conn_params_update_delay = FIRST_UPDATE_DELAY;
    cp_init.next_conn_params_update_delay  = NEXT_UPDATE_DELAY;
    cp_init.max_conn_params_update_count   = MAX_UPDATE_COUNT;
    cp_init.start_on_notify_cccd_handle    = BLE_GATT_HANDLE_INVALID;
    cp_init.disconnect_on_fail             = true;
    cp_init.evt_handler                    = NULL;
    cp_init.error_handler                  = error_callback;

    //ASSERT_STATUS ( ble_conn_params_init(&cp_init));   //_modify
    nrf_err_check( ble_conn_params_init(&cp_init) );
    
    return ERROR_NONE;
}
开发者ID:A-L-E-X,项目名称:nRF51822-Arduino,代码行数:53,代码来源:btle_gap.cpp

示例4: twi_light_sampling

static void twi_light_sampling(void * p_context){
	UNUSED_PARAMETER(p_context);	
	static bool startup = true;
	static bool set_pin = true;
	uint32_t err_code;
	if(do_measurements){
		if(set_pin){
			set_pin = false;
			//TURN ON THE TRANSISTOR AND WAIT FOR IT TO STABILIZE
			nrf_gpio_pin_set(TSL2561_BASE_PIN);
			err_code = app_timer_start(iss_struct.meas_timer, APP_TIMER_TICKS(50, APP_TIMER_PRESCALER), NULL);
			APP_ERROR_CHECK(err_code);
		}else{
			uint8_t twi_data_tx[2] = {0,0};
			uint8_t twi_data_rx[2] = {0,0};
			uint8_t light_twi_command = TSL2561_COMMAND_BIT | TSL2561_CLEAR_BIT | TSL2561_WORD_BIT;
			if(startup){
				// POWER ON and wait 450 ms
				startup = false;
				twi_data_tx[0] = light_twi_command | TSL2561_REGISTER_CONTROL;
				twi_data_tx[1] = TSL2561_CONTROL_POWERON;
				err_code = !twi_master_write(light_sens_adr, twi_data_tx, 2,&my_twi_config);
				APP_ERROR_CHECK(err_code);
				err_code = app_timer_start(iss_struct.meas_timer, APP_TIMER_TICKS(450, APP_TIMER_PRESCALER), NULL);
				APP_ERROR_CHECK(err_code);
			}else{
				uint16_t ch0,ch1 = 0;
				twi_data_tx[0] = light_twi_command | TSL2561_REGISTER_CHAN0_LOW;	
				err_code = !twi_master_write_read(light_sens_adr, twi_data_tx, 1, twi_data_rx, 2,&my_twi_config);
				APP_ERROR_CHECK(err_code);
				ch0 = twi_data_rx[0];
				ch0 = ch0 | (((uint16_t)(twi_data_rx[1]))<<8);
				
				twi_data_tx[0] = light_twi_command | TSL2561_REGISTER_CHAN1_LOW;
				err_code = !twi_master_write_read(light_sens_adr, twi_data_tx, 1, twi_data_rx, 2,&my_twi_config);
				APP_ERROR_CHECK(err_code);
				ch1 = twi_data_rx[0];
				ch1 = ch1 | (((uint16_t)(twi_data_rx[1]))<<8);
				
				nrf_gpio_pin_clear(TSL2561_BASE_PIN);

				int32_t lux = calc_lux(ch0,ch1);
				err_code = update_iss_measurement(&iss_struct, &lux);
				APP_ERROR_CHECK(err_code);
				startup = true;
				set_pin = true;
				err_code = app_timer_start(iss_struct.meas_timer, APP_TIMER_TICKS(iss_struct.samp_freq_in_m_sec, APP_TIMER_PRESCALER), &iss_struct);
				APP_ERROR_CHECK(err_code);
			}	
		}		
	}
}
开发者ID:EnergyFutures,项目名称:ITU_BLE_Measurement_Service,代码行数:52,代码来源:light_sensor_TSL2561.c

示例5: main

/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    // Initialize.
    app_trace_init();
    ble_stack_init();
    device_manager_init();
    timers_init();
    APP_GPIOTE_INIT(APP_GPIOTE_MAX_USERS);
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS,
                        APP_TIMER_TICKS(100, APP_TIMER_PRESCALER),
                        NULL);
    APP_ERROR_CHECK(err_code);
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();

    // Start execution.
    application_timers_start();
    advertising_start();

    // Enter main loop.
    for (;; )
    {
        power_manage();
    }
}
开发者ID:tkadom,项目名称:TWBLE,代码行数:31,代码来源:main.c

示例6: main

/**
 * @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();
    }
}
开发者ID:Goodjamp,项目名称:ble_app_template,代码行数:37,代码来源:main.c

示例7: main

int main(void)
{
    uint32_t err_code;
    // Initialize.
    timers_init();
    err_code = bsp_init(BSP_INIT_LED, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);

    uart_init();
    ble_stack_init();

    twi_master_init();

    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);
    nrf_delay_ms(200);
    bsp_indication_set(BSP_INDICATE_IDLE);
    nrf_delay_ms(200);
    err_code = bsp_indication_set(BSP_INDICATE_ADVERTISING);

    update_sensor(0);
    start_advertising();
    timers_start();

    // Enter main loop.
    for (;; )
    {
        power_manage();
    }
}
开发者ID:ix-wetterstation,项目名称:sensor,代码行数:29,代码来源:main.c

示例8: advertising_timer_init

void advertising_timer_init(void){

  app_timer_create(&advertising_timer, APP_TIMER_MODE_REPEATED, &radio_notification_evt_handler);
  //Starts the timer, sets it up for repeated start.
  app_timer_start(advertising_timer, APP_TIMER_TICKS(300, APP_TIMER_PRESCALER), NULL);

}
开发者ID:jtguggedal,项目名称:Physical_Web_Toy_SDK_11,代码行数:7,代码来源:main.c

示例9: utils_setup

/**@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);
		
}
开发者ID:pavarinna,项目名称:AntBleCommunication,代码行数:34,代码来源:main.c

示例10: sensor_timer_start

static void sensor_timer_start(uint16_t offset)
{
		uint32_t err_code;
		err_code = app_timer_start(iss_struct_h.meas_timer, APP_TIMER_TICKS(offset ? offset : iss_struct_h.samp_freq_in_m_sec, APP_TIMER_PRESCALER), NULL);
		APP_ERROR_CHECK(err_code);
		iss_struct_h.timer_running = true;
}
开发者ID:EnergyFutures,项目名称:ITU_BLE_Measurement_Service,代码行数:7,代码来源:HT_sensor_SI7021.c

示例11: main

/**@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);
    }
}
开发者ID:kevin-ledinh,项目名称:banana-tree,代码行数:28,代码来源:main.c

示例12: main

/**
 * @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();
        }
    }
}
开发者ID:AaltoNEPPI,项目名称:nRF52_dev,代码行数:29,代码来源:main.c

示例13: main

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();
    }
}
开发者ID:NordicSemiconductor,项目名称:ble_app_uart_c_S120,代码行数:27,代码来源:main.c

示例14: main

/**@brief Function for application main entry.
 */
int main(void)
{
    uint32_t err_code;
    // Initialize.
    ble_stack_init();
    timers_init();
    APP_GPIOTE_INIT(1);
    err_code = bsp_init(BSP_INIT_LED | BSP_INIT_BUTTONS, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL);
    APP_ERROR_CHECK(err_code);
    device_manager_init();
    gap_params_init();
    advertising_init();
    services_init();
    sensor_simulator_init();
    conn_params_init();

    ble_evt_pool      = osPoolCreate(osPool(ble_evt_pool));
    ble_stack_msg_box = osMessageCreate(osMessageQ(ble_stack_msg_box), NULL);

    // Start execution.
    ble_stack_thread_id = osThreadCreate(osThread(ble_stack_thread), NULL);
    UNUSED_VARIABLE(ble_stack_thread_id);
    application_timers_start();
    advertising_start();

    // Enter main loop.
    for (;; )
    {
        UNUSED_VARIABLE(osDelay(1000));
    }
}
开发者ID:dhruvkakadiya,项目名称:OpenSJ_Bluz,代码行数:33,代码来源:main.c

示例15: app_nfc_callback

/**@brief Function for handling NFC events.
 * Schedulers call to handler.
 */
void app_nfc_callback(void* p_context, nfc_t2t_event_t event, const uint8_t* p_data, size_t data_length)
{
  NRF_LOG_INFO("NFC\r\n");
  switch (event)
  {
    case NFC_T2T_EVENT_FIELD_ON:
      // NFC activation causes tag to hang sometimes. Fix this by reseting tag after a delay on NFC read.
      NRF_LOG_INFO("NFC Field detected \r\n");
      app_timer_start(reset_timer_id, APP_TIMER_TICKS(NFC_RESET_DELAY, RUUVITAG_APP_TIMER_PRESCALER), NULL);
      break;

    case NFC_T2T_EVENT_FIELD_OFF:
      NRF_LOG_INFO("NFC Field lost \r\n");
      app_sched_event_put (NULL, 0, reinit_nfc);
      if(APP_GATT_PROFILE_ENABLED)
      {
        app_sched_event_put (NULL, 0, become_connectable);
      }
      break;

    case NFC_T2T_EVENT_DATA_READ:
      NRF_LOG_INFO("Data read\r\n");
      break;
    
    default:
      break;
  }
}
开发者ID:ruuvi,项目名称:ruuvitag_fw,代码行数:31,代码来源:main.c


注:本文中的APP_TIMER_TICKS函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。