CC2640 软件定时器 Util_constructClock()
来源:互联网 发布:js获取父级节点 编辑:程序博客网 时间:2024/05/22 07:52
转自 : http://blog.csdn.net/haozi0_0/article/details/50970268
最近有客户在使用 CC2640 的 Util_constructClock()过程中遇到问题,在帮助客户解决问题之后就想把解决方法记录一下,一是帮助自己记忆,而是帮助给遇到问题的朋友提供一个思路。
以 SimpleBLEPeripheral 工程为例:
1. 首先要在初始化函数中创建一个软件定时 Util_constructClock()
static void SimpleBLEPeripheral_init(void){// ****************************************************************** // N0 STACK API CALLS CAN OCCUR BEFORE THIS CALL TO ICall_registerApp // ****************************************************************** // Register the current thread as an ICall dispatcher application // so that the application can send and receive messages. ICall_registerApp(&selfEntity, &sem); // Hard code the BD Address till CC2650 board gets its own IEEE address // uint8 bdAddress[B_ADDR_LEN] = { 0xF0, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA }; // HCI_EXT_SetBDADDRCmd(bdAddress); // Set device's Sleep Clock Accuracy //HCI_EXT_SetSCACmd(40); // Create an RTOS queue for message from profile to be sent to app. appMsgQueue = Util_constructQueue(&appMsg); // Create one-shot clocks for internal periodic events. Util_constructClock(&periodicClock, SimpleBLEPeripheral_clockHandler, SBP_PERIODIC_EVT_PERIOD, 0, false, SBP_PERIODIC_EVT); //创建定时 Board_openLCD(); // Setup the GAP GAP_SetParamValue(TGAP_CONN_PAUSE_PERIPHERAL, DEFAULT_CONN_PAUSE_PERIPHERAL);
先看一下 Util_constructClock()中定义的回调函数 SimpleBLEPeripheral_clockHandler(),这个函数就是当定时时间到了之后的处理函数。
static void SimpleBLEPeripheral_clockHandler(UArg arg){ // Store the event. events |= arg; // Wake up the application. Semaphore_post(sem);}
2. 第二步就是要启动这个定时器了,原例程中的代码如下:
static void SimpleBLEPeripheral_taskFxn(UArg a0, UArg a1){ // Initialize application SimpleBLEPeripheral_init(); // Application main loop for (;;) { //....省略 if (events & SBP_PERIODIC_EVT) { events &= ~SBP_PERIODIC_EVT; Util_startClock(&periodicClock); //开启定时 // Perform periodic application task SimpleBLEPeripheral_performPeriodicTask(); } }}
注意这个 Util_startClock()函数是放在 for 循环里的,说明他是重复执行的,当一次定时结束后,要重新开启 Util_startClock,这个很像 CC2541 中的定时功能。所以如果你的定时功能出了问题,只能执行一次,那就说明你在第一次定时结束后没有重新启动定时。也就是说在定时功能执行一次之后,需要再次调用 Util_startClock()函数来开启定时功能。
阅读全文
1 0
- CC2640 软件定时器 Util_constructClock()
- CC2640 软件定时器 Util_constructClock()
- Util_constructClock()
- [BLE]CC2640之定时器(Clock)事件
- [BLE]CC2640之定时器(Clock)事件
- CC2640软件架构
- 【CC2640】CC2640开发板、软件以及协议栈介绍
- CC2640
- 软件定时器(一)
- CC2650/CC2640 软件不同封装问题
- 【CC2640】CC2640无线MCU BLE-Stack™软件开发套件发行说明
- 【CC2640】CC2640软件开发从入门到专家的注意点
- 软件定时器
- 软件定时器
- 软件定时器
- 软件定时器
- CC2640 创建周期任务(时钟)
- BLE开发-CC2640开发笔记(1)
- caffe源码解析之solver
- Collections.sort(list); 轻松实现 字符的集合 含有数字的排序
- redis
- .Net MVC中使用css 和js
- 常用adb命令(5)
- CC2640 软件定时器 Util_constructClock()
- Android 图像处理(一) : Shader
- 决策树、SVM及集成方法
- ssh-配置自定义中文乱码过滤器和配置opensessionview解决懒加载
- ios16进制转换成UIColor
- 每天一个linux命令(56):netstat命令
- Java 框架之Hibernate (一、Hibernate环境搭建)
- void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference
- react中css导致mocha运行报错(解决)