生活随笔
收集整理的這篇文章主要介紹了
面向对象写单片机程序-程序分层
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
面向?qū)ο髮憜纹瑱C程序-程序分層
typedef struct InputDevice {char *name
;int (*GetInputEvent
)(PInputEvent ptInputEvent
);int (*DeviceInit
)(void);int (*DeviceExit
)(void);struct InputDevice *pNext
;
}InputDevice
, *PInputDevice
;static PInputDevice g_ptInputDevices
;void InitInputDevices(void)
{PInputDevice pDev
= g_ptInputDevices
;while(pDev
){pDev
->DeviceInit();pDev
= pDev
->pNext
;}
}
......
static int GPIOKeyInit(void)
{KAL_GPIOKkeyInit();return 0;
}static InputDevice g_tKeyDevice
= {"gpio_key",NULL,GPIOKeyInit
,NULL,
};
- KAL(Kernel Abstract Layer):設備抽象層
void KAL_GPIOKkeyInit(void)
{
#if defined(CONFIG_NOOS) CAL_GPIOKkeyInit();
#elif defined(CONFIG_FREERTOS) FreeRTOS_GPIOKkeyInit();
#elif defined(CONFIG_RTTHREAD) RTTread_GPIOKkeyInit();
#endif
}
- CAL(Chip Abstract Layer):芯片抽象層
void CAL_GPIOKkeyInit(void)
{
#if defined(CONFIG_ST_HAL)KEY_GPIO_ReInit();
#elseMY_KEY_GPIO_ReInit
#endif
}
總結(jié)
以上是生活随笔為你收集整理的面向对象写单片机程序-程序分层的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。