nRF52832 Timer

nrf52832 SDK中的timer使用还是很简单的,这里也没有深入.
timer在app_timer.h中
SDK中的说明:

Usage

Configuration of the app_timer module is static. It is located in the sdk_config.h file. Use function app_timer_init to initialize the library.

To define a timer, use the APP_TIMER_DEF macro. This macro allocates memory for the timer instance and declares an identifier that can later on be used to refer to the specific instance. Before starting a timer, the timer must be created:
APP_TIMER_DEF(my_timer_id);

err_code = app_timer_create(&my_timer_id, mode, timeout_handler)

After the timer is created, it can be controlled using app_timer_start and app_timer_stop.

When app_timer_start() or app_timer_stop() are called, the timer operation is only queued, not executed. A software interrupt is triggered and the actual timer start/stop operation is executed by the SWI0 interrupt handler. If the application code that calls the timer function is running at the same or higher interrupt priority level, the timer operation will not be performed until the application handler has returned. This is the case, for example, when stopping a timer from a time-out handler when not using the scheduler.

所以使用倒是很简单了:
初始化定时器:ret_code_t err_code = app_timer_init();
定义:APP_TIMER_DEF(timer_name);
创建:err_code=app_timer_create(&timer_name,APP_TIMER_MODE_SINGLE_SHOT,user_timer_out);
启动:err_code=app_timer_start(timer_name,APP_TIMER_TICKS(300),NULL);
停止:err_code=app_timer_stop(timer_name);

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 12,196评论 0 10
  • 先创建服务端的APP 1.官网下载Winrun4j。http://winrun4j.sourceforge.net...
    Alex_1799阅读 6,025评论 1 2
  • 请你爱我,不必忌惮天高路远 我的步子蹒跚或趔趄 不都是 向你靠近 直到我终于能和你四目相对 苦难没有白费,苍白的...
    瞒青兮阅读 1,778评论 0 5
  • 刚才表哥给我打电话问我在哪,我很随意的说出在家,家,租住了不到俩月的房子。忽然感觉归属感太强了,以前以为家只是父母...
    就这样与你擦肩而过阅读 1,950评论 0 0
  • 越想忘记,记忆就越深刻 我不知道,不明白 他到底与我而言有多重要 说了那么多次的再见,却始终放不下 是的,今天我又...
    一叶流浪的独木舟阅读 1,180评论 0 0

友情链接更多精彩内容