只关心应用,不关系内部实现机制:
是时候秀一波操作了:
随便找一个sdk里面的ble例子,我使用的是sdk9里的ble_app_uart_s110_pca10028例程,工程路径为:XXnRF51_SDK_9.0.0_2e23562examplesble_peripheralble_app_uartpca10028s110arm4
代码很简单,只是用app timer来翻转一个led灯,我的板子是18脚连着一个led灯。
复制代码
编译完下载进去就可以看到led闪烁了
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41app_timer_id_t my_timer; static void my_timer_handler(void * p_context) { nrf_gpio_pin_toggle(18); } /**@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_MAX_TIMERS, APP_TIMER_OP_QUEUE_SIZE, false); uart_init(); buttons_leds_init(&erase_bonds); ble_stack_init(); nrf_gpio_pin_dir_set(18, NRF_GPIO_PIN_DIR_OUTPUT); app_timer_create(&my_timer, APP_TIMER_MODE_REPEATED, my_timer_handler); app_timer_start(my_timer, APP_TIMER_TICKS(100, APP_TIMER_PRESCALER), NULL); while(1); gap_params_init(); services_init(); advertising_init(); conn_params_init(); printf("%s",start_string); err_code = ble_advertising_start(BLE_ADV_MODE_FAST); APP_ERROR_CHECK(err_code); // Enter main loop. for (;;) { power_manage(); } }
最后
以上就是热情唇彩最近收集整理的关于nrf51822 app timer简单使用的全部内容,更多相关nrf51822内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复