昇润CC2640 SDK应用入门教程13
发布日期:2017.07.31 浏览次数:290
1.CC2640R2F 框架图
2.工程介绍
在打开TTC_SDK_3.1.2的工程时,大家都可以看到如下图:
右上角的Workpace栏目下有好几个工程选择,主要可分4种角色工程:
1. 从机
2. 从机+观察者组合模式
3. 主机
4. 主机+广播组合模式
其中,在从机的功能下为了方便用户操作,省去复杂的配置,从机又细分了片内OAD和片外OAD模式,从机观察者同理。
3.使用介绍
首先,我们打开工程,默认路径:C:TTC_BLE_CC2640_R2_SDK3.1.2TTC_CC2640_R2_SDKexamples tosCC2640R2_LAUNCHXLlestackSDK irtosiar
切记IAR版本必须在 7.8.0以上
查看版本在IAR -> 工具栏 -> Help -> About -> Product Info...
在学习从机工程的操作前,建议用户仔细阅读“TTC SDK V3.x 使用说明V1.2.pdf”,里面其实很详细的说明个角色及SDK所有演示驱动代码讲解。
默认路径:C:TTC_BLE_CC2640_R2_SDK3.1.2Documents

打开工程后,我们先查看下TTCBleSDK文件夹里的TTCDriverTimer.h文件

这里面的参数比较多,需要耐心点看完,然后我们再来看看可供调用的函数:
定时器初始化
TTCDriverTimerInit(TTCDriverTimerInit_t timerInitParam, Timer_Handle *timerHandle);
定时器设置中断函数回调
TTCDriverTimerRegisterIntCallBack(Timer_Handle *timerHandle, TTCSdkTimerCB_t pCB);
定时器计数参数设置
TTCDriverTimerCounterSetParam(Timer_Handle *timerHandle, TCDriverTimerCounterParam_t param,
bool enable);
定时器边沿计数模式参数设置
TCDriverTimerEdgCountSetParam(Timer_Handle *timerHandle,TTCDriverTimerEdgeCountParam_t param,
PIN_Id edgeCountPin,bool enable);
定时器边沿定时模式参数设置
TTCDriverTimerEdgTimingSetParam(Timer_Handle *timerHandle,
TTCDriverTimerEdgeTimingParam_t param,
PIN_Id edgeTimerPin, bool enable);
定时器PWM模式参数设置
TTCDriverTimerPwmSetParam(Timer_Handle *timerHandle, TTCDriverTimerPwmParams_t param,
PIN_Id pwmPin, bool enable);
定时器启动
TTCDriverTimerStart(Timer_Handle *timerHandle);
定时器停止
TTCDriverTimerStop(Timer_Handle *timerHandle);
定时器关闭
TTCDriverTimerClose(Timer_Handle *timerHandle);
选择同步启动的定时器
TTCDriverTimerSync(Timer_Handle *timerHandle,CC2650_TimerSync syncTimer);
大致了解了函数及相关结构体的意思,接下来我们就尝试下个代码来测试下,首先,我们先新建UserTimer.c及UserTimer.h文件。

新建完成后,我们就开始在UserTimer.c上编写我们需要的程序,首先,我们先初始化Timer,如下图:



执行到这一步几乎已经接近尾声,接下来我们就是要在线程上去添加我们的初始化函数及配置一些参数如下:

接下来在选项栏右键开启配置选项 C/C++

执行到这一步工程算是完成了,剩下的就是编译工程及下载程序去验证测试看看结果如何。首先打开Statck工程,编译,下载,然后再打开App工程,编译下载,操作如下图:

下载完毕后如下图:

点击运行,结果如下图:
