- 通过函数指针使程序的可读性更强。在开发外设较少而程序比较复杂的单片机时函数指针能给无论是开发者还是维护者一个比较清晰的思路。
以51单片机为例
/***************************************
main.h
***************************************/
#ifndef _MAIN_H_
#define _MAIN_H_
#define MAXTASK (10)
typedef unsigned int uint;
typedef unsigned int u32;
typedef unsigned char uchar;
typedef unsigned char u8;
typedef struct
{
uint period;
uchar runMe;
void (*pTask)();
}Task;
vo