嵌入式系统中GPIO与SPI HAL开发全解析
1. GPIO HAL开发
在嵌入式系统开发里,将硬件抽象层(HAL)移植到实际目标设备是极为关键的一步。以NXP KL25Z Freedom Board为例,该开发板配备了ARM Cortex - M微控制器,下面详细介绍GPIO HAL的实现过程。
1.1 指针数组内存映射
为了方便对GPIO寄存器进行访问,可把不同类型的寄存器组织成指针数组,并映射到内存中。以下是各类寄存器指针数组的定义:
/**
* Defines a table of pointers to the Port Data Input Register
*/
uint32 volatile * const portsin[NUM_PORTS] =
{
(uint32*)&GPIOA_PDIR, (uint32*)&GPIOB_PDIR,
};
/**
* Defines a table of pointers to the port’s data - direction register
*/
uint32 volatile * const portsddr[NUM_PORTS] =
{
(uint32*)&GPIOA_PDDR, (uint32*)&GPIOB_PDDR
};
/**
* Defines a table of pointers to the Port Data Output Register
*/
uint32 volatile * const ports[NUM_PORTS] =
{
超级会员免费看
订阅专栏 解锁全文
1689

被折叠的 条评论
为什么被折叠?



