基于TI_BLE协议栈_ZStack协议栈解析
基于STM32的虚拟多线程,可以很好的用于裸机程序中,用于模拟小型操作系统的多线程概念。本实例参考TI_BLE协议栈_ZStack协议栈。
#include “Hal_Led/Hal_Led.h”
#include “Hal_delay/delay.h”
#include “Hal_Key/Hal_Key.h”
#include “ringbuffer.h”
#define APP_LED2_BLINK_EVENT 0x0001
#define HAL_LED1_BLINK_EVENT 0x0001
#define TASK_NO_TASK_RUNNING 0xFF
unsigned short Hal_ProcessEvent(unsigned char task_id,unsigned short events ); unsigned short App_ProcessEvent(unsigned char task_id,unsigned short events ); typedef unsigned short uint16;
typedef unsigned char uint8;
#define TASK_CNT 2 //定义线程的个数
//定义函数指针
typedef unsigned short (*pTaskEventHandlerFn)(unsigned char task_id,unsigned short events );
//线程函数表
const pTaskEventHandlerFn tasksArr[]=
{
Hal_ProcessEvent,
App_ProcessEvent
};
const unsigned char tasksCnt = sizeof(tasksArr )/ sizeof(tasksArr[0]);