感谢EEWorld提供的CC1350 LunchPad-433MHz开发板测评机会,虽然这款开发板目前已经停产了,但是对于TI芯片的初学者还是挺有意义的
CC1350 LunchPad-433MHz是一款双频带无线开发板,可以在学习TI芯片的基础操作的同时学习TI的无线传输技术SimpleLink,该芯片数据手册与开发板原理图如下
GPIO的测试将基于CCS进行开发,为了实现对这款开发板的开发,需要安装以下几个链接的内容
CCSTUDIO IDE、配置、编译器或调试器 | 德州仪器 TI.com.cn
SIMPLELINK-CC13X0-SDK 软件开发套件 (SDK) | 德州仪器 TI.com.cn
ARM-CGT IDE、配置、编译器或调试器 | 德州仪器 TI.com.cn
进入CCS,选择开发板空白工程并创建
生成文件目录如下
观察生成的主函数,可以看到它使用了RTOS,并调用了mainThread这个线程
int main(void)
{
pthread_t thread;
pthread_attr_t attrs;
struct sched_param priParam;
int retc;
/* Call driver init functions */
Board_init();
/* Initialize the attributes structure with default values */
pthread_attr_init(&attrs);
/* Set priority, detach state, and stack size attributes */
priParam.sched_priority = 1;
retc = pthread_attr_setschedparam(&attrs, &priParam);
retc |= pthread_attr_setdetachstate(&attrs, PTHREAD_CREATE_DETACHED);
retc |= pthread_attr_setstacksize(&attrs, THREADSTACKSIZE);
if (retc != 0) {
/* failed to set attributes */
while (1) {}
}
retc = pthread_create(&thread, &attrs, mainThread, NULL);
if (retc != 0) {
/* pthread_create() failed */
while (1) {}
}
BIOS_start();
return (0);
}
mainThread在empty.c中的定义如下,可以看到这里已经为我们定义好了基本的外设,并且实现了基本的闪灯逻辑
void *mainThread(void *arg0)
{
/* 1 second delay */
uint32_t time = 1;
/* Call driver init functions */
GPIO_init();
// I2C_init();
// SPI_init();
// UART_init();
// Watchdog_init();
/* Configure the LED pin */
GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
/* Turn on user LED */
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
while (1) {
sleep(time);
GPIO_toggle(Board_GPIO_LED0);
}
}
修改empty.c中的内容,利用下降沿中断触发LED灯翻转电平
/*
* ======== gpioButtonFxn0 ========
* Callback function for the GPIO interrupt on Board_GPIO_BUTTON0.
*/
void gpioButtonFxn0(uint_least8_t index)
{
/* Clear the GPIO interrupt and toggle an LED */
GPIO_toggle(Board_GPIO_LED0);
}
/*
* ======== gpioButtonFxn1 ========
* Callback function for the GPIO interrupt on Board_GPIO_BUTTON1.
* This may not be used for all boards.
*/
void gpioButtonFxn1(uint_least8_t index)
{
/* Clear the GPIO interrupt and toggle an LED */
GPIO_toggle(Board_GPIO_LED1);
}
/*
* ======== mainThread ========
*/
void *mainThread(void *arg0)
{
/* Call driver init functions */
GPIO_init();
/* Configure the LED pins */
GPIO_setConfig(Board_GPIO_LED0, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
GPIO_setConfig(Board_GPIO_LED1, GPIO_CFG_OUT_STD | GPIO_CFG_OUT_LOW);
/* Configure the Button pins */
GPIO_setConfig(Board_GPIO_BUTTON0, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING);
GPIO_setConfig(Board_GPIO_BUTTON1, GPIO_CFG_IN_PU | GPIO_CFG_IN_INT_FALLING);
/* Turn on user LEDs */
GPIO_write(Board_GPIO_LED0, Board_GPIO_LED_ON);
GPIO_write(Board_GPIO_LED1, Board_GPIO_LED_ON);
/* install Button callback */
GPIO_setCallback(Board_GPIO_BUTTON0, gpioButtonFxn0);
GPIO_setCallback(Board_GPIO_BUTTON1, gpioButtonFxn1);
/* Enable interrupts */
GPIO_enableInt(Board_GPIO_BUTTON0);
GPIO_enableInt(Board_GPIO_BUTTON1);
}
最终实现效果如下
附件代码如下