CC2640R2F&TI-RTOS 拿到 TI CC2640R2F 开发板 第四件事就是 修改第三件事信号量超时改为 事件 超时,并增加 事件控制 ,用于控制LED 闪烁时间或者关闭

2022-12-19,,,,

/*
* data_process.c
*
* Created on: 2018年7月5日
* Author: admin
*/ #include "board_led.h"
#include "board_uart.h" #include "data_process.h" // Task configuration
#define LF_TASK_PRIORITY 1
#define LF_TASK_STACK_SIZE 512 // Task configuration
Task_Struct lfTask;
Char lfTaskStack[LF_TASK_STACK_SIZE]; Event_Handle eventLedFickerHandle; /*********************************************************************
* @fn LedFicker_createTask
*
* @brief Task creation function for the led ficker.
*
* @param None.
*
* @return None.
*/
void LedFicker_createTask(void)
{
Task_Params taskParams; // Configure task
Task_Params_init(&taskParams);
taskParams.stack = lfTaskStack;
taskParams.stackSize = LF_TASK_STACK_SIZE;
taskParams.priority = LF_TASK_PRIORITY; Task_construct(&lfTask, LedFicker_taskFxn, &taskParams, NULL);
} /*********************************************************************
* @fn LedFicker_taskFxn
*
* @brief Application task entry point for the Led Ficker.
*
* @param a0, a1 - not used.
*
* @return None.
*/
static void LedFicker_taskFxn(UArg a0, UArg a1)
{/* LED 闪烁任务,默认200ms闪烁一次,可以通过事件通知的方式更改LED闪烁频率 */ uint32_t events;
uint32_t timeoutInTicks = * (/Clock_tickPeriod); Event_Params eventParams;
Event_Struct structEvent; /* Memory allocated at build time */ Event_Params_init(&eventParams);
Event_construct(&structEvent, &eventParams); /* It's optional to store the handle */
eventLedFickerHandle = Event_handle(&structEvent); if (eventLedFickerHandle == NULL) {
/* PIN_open() failed */
bspDebugPrintf( true,"eventLedFickerHandle Init false.\r\n" );
while ();
}
else
{
bspDebugPrintf( true,"eventLedFickerHandle Init ok.\r\n" );
} // Application main loop
for (;;)
{ /* Wait for an event to be posted */
events = Event_pend(eventLedFickerHandle,
Event_Id_NONE,
LED_FICKER_OFF_EVT |
LED_FICKER_100MS_EVT |
LED_FICKER_1S_EVT,
timeoutInTicks); //翻转LED灯
ledBoardToggle( ledBlueBoard );
ledBoardToggle( ledRedBoard ); if (events & LED_FICKER_OFF_EVT)
{
timeoutInTicks = BIOS_WAIT_FOREVER;/* 超时时间改为永久,这样就关闭了LED */ //关闭LED灯
ledBoardOff( ledBlueBoard );
ledBoardOff( ledRedBoard );
} if (events & LED_FICKER_100MS_EVT)
{
timeoutInTicks = * (/Clock_tickPeriod);/* 超时时间改为100ms,这样LED就会100ms翻转一次 */
} if (events & LED_FICKER_1S_EVT)
{
timeoutInTicks = * (/Clock_tickPeriod);/* 超时时间改为1s,这样LED就会1s翻转一次 */
} }
} void eventLedFicker_post( uint32_t event )
{
if( eventLedFickerHandle )
Event_post(eventLedFickerHandle, event);
}
/*
* data_process.h
*
* Created on: 2018年7月5日
* Author: admin
*/ #ifndef APPLICATION_DATA_PROCESS_H_
#define APPLICATION_DATA_PROCESS_H_ #include <ti/sysbios/knl/Task.h>
#include <ti/sysbios/knl/Clock.h>
#include <ti/sysbios/knl/Event.h>
#include <ti/sysbios/BIOS.h> #define LED_FICKER_OFF_EVT Event_Id_00 /* led 闪烁关闭 */
#define LED_FICKER_100MS_EVT Event_Id_01 /* led 100MS 闪烁一次 */
#define LED_FICKER_1S_EVT Event_Id_02 /* led 1S 闪烁一次 */ void LedFicker_createTask(void); static void LedFicker_taskFxn(UArg a0, UArg a1); void eventLedFicker_post( uint32_t event ); #endif /* APPLICATION_DATA_PROCESS_H_ */

官方教程链接

BLE5-Stack User’s Guide

CC2640R2F / CC2640 / CC2650入门和常见问题解答

CC2640R2F&TI-RTOS 拿到 TI CC2640R2F 开发板 第四件事就是 修改第三件事信号量超时改为 事件 超时,并增加 事件控制 ,用于控制LED 闪烁时间或者关闭的相关教程结束。

《CC2640R2F&TI-RTOS 拿到 TI CC2640R2F 开发板 第四件事就是 修改第三件事信号量超时改为 事件 超时,并增加 事件控制 ,用于控制LED 闪烁时间或者关闭.doc》

下载本文的Word格式文档,以方便收藏与打印。