测试环境
协议栈版本:BLE-STACK V2.1
IAR开发环境版本:IAR for Arm 7.40
硬件设备:Amo-SmartRF v2.0 开发板(对应TI官方的SmartRF06EB 开发板)
添加IIC定义
TI 释放的SDK中没有IIC的定义,为了我们后面的使用,我们一起来看一下,如何添加IIC定义:
1.打开“C:\ti\tirtos_simplelink_2_13_00_06\packages\ti\boards\SRF06EB\CC2650EM_7ID”目录下的“Board.c”文件,在文件的最后添加如下代码:
/*
* ============================= I2C Begin=====================================
*/
/* Place into subsections to allow the TI linker to remove items properly */
#if defined(__TI_COMPILER_VERSION__)
#pragma DATA_SECTION(I2C_config, ".const:I2C_config")
#pragma DATA_SECTION(i2cCC26xxHWAttrs, ".const:i2cCC26xxHWAttrs")
#endif
/* Include drivers */
#include <ti/drivers/i2c/I2CCC26XX.h>
/* I2C objects */
I2CCC26XX_Object i2cCC26xxObjects[CC2650_I2CCOUNT];
/* I2C configuration structure, describing which pins are to be used */
const I2CCC26XX_HWAttrs i2cCC26xxHWAttrs[CC2650_I2CCOUNT] = {
{
.baseAddr = I2C0_BASE,
.powerMngrId = PERIPH_I2C0,
.intNum = INT_I2C,
.sdaPin = Board_I2C0_SDA0,
.sclPin = Board_I2C0_SCL0,
}
};
const I2C_Config I2C_config[] = {
{&I2CCC26XX_fxnTable, &i2cCC26xxObjects[0], &i2cCC26xxHWAttrs[0]},
{NULL, NULL, NULL}
};
/*
* ========================== I2C end =========================================
*/
2.打开“C:\ti\tirtos_simplelink_2_13_00_06\packages\ti\boards\SRF06EB\CC2650EM_7ID”目录下的“Board.h”文件,在文件的最后添加如下代码:
/* I2C */
#define Board_I2C0_SDA0 IOID_5
#define Board_I2C0_SCL0 IOID_6
#define Board_I2C0_SDA1 IOID_8
#define Board_I2C0_SCL1 IOID_9
该文件中TI将IOID_6引脚定义到LED灯上了,所以需要对LED灯的配置进行修改,将
#define Board_LED4 IOID_6 /* RF1.4 */
改为:
#define Board_LED4 IOID_0//IOID_6
通过上述配置,我们就在TIRTOS中添加了IIC的配置。