MQX4.0:MK60DZ10.h头文件PORT模块代码分析
来源:互联网 发布:mac os 无法验证 编辑:程序博客网 时间:2024/05/22 04:46
/* ---------------------------------------------------------------------------- -- PORT ---------------------------------------------------------------------------- *//** * @addtogroup PORT_Peripheral PORT * @{ *//** PORT - Peripheral register structure */typedef struct PORT_MemMap { uint32_t PCR[32]; /**< Pin Control Register n, array offset: 0x0, array step: 0x4 */ uint32_t GPCLR; /**< Global Pin Control Low Register, offset: 0x80 */ uint32_t GPCHR; /**< Global Pin Control High Register, offset: 0x84 */ uint8_t RESERVED_0[24]; uint32_t ISFR; /**< Interrupt Status Flag Register, offset: 0xA0 */ uint8_t RESERVED_1[28]; uint32_t DFER; /**< Digital Filter Enable Register, offset: 0xC0 */ uint32_t DFCR; /**< Digital Filter Clock Register, offset: 0xC4 */ uint32_t DFWR; /**< Digital Filter Width Register, offset: 0xC8 */} volatile *PORT_MemMapPtr;/* ---------------------------------------------------------------------------- -- PORT - Register accessor macros ---------------------------------------------------------------------------- *//** * @addtogroup PORT_Register_Accessor_Macros PORT - Register accessor macros * @{ *//* PORT - Register accessors */#define PORT_PCR_REG(base,index) ((base)->PCR[index])#define PORT_GPCLR_REG(base) ((base)->GPCLR)#define PORT_GPCHR_REG(base) ((base)->GPCHR)#define PORT_ISFR_REG(base) ((base)->ISFR)#define PORT_DFER_REG(base) ((base)->DFER)#define PORT_DFCR_REG(base) ((base)->DFCR)#define PORT_DFWR_REG(base) ((base)->DFWR)/** * @} */ /* end of group PORT_Register_Accessor_Macros *//* ---------------------------------------------------------------------------- -- PORT Register Masks ---------------------------------------------------------------------------- *//** * @addtogroup PORT_Register_Masks PORT Register Masks * @{ *//* PCR Bit Fields */#define PORT_PCR_PS_MASK 0x1u#define PORT_PCR_PS_SHIFT 0#define PORT_PCR_PE_MASK 0x2u#define PORT_PCR_PE_SHIFT 1#define PORT_PCR_SRE_MASK 0x4u#define PORT_PCR_SRE_SHIFT 2#define PORT_PCR_PFE_MASK 0x10u#define PORT_PCR_PFE_SHIFT 4#define PORT_PCR_ODE_MASK 0x20u#define PORT_PCR_ODE_SHIFT 5#define PORT_PCR_DSE_MASK 0x40u#define PORT_PCR_DSE_SHIFT 6#define PORT_PCR_MUX_MASK 0x700u#define PORT_PCR_MUX_SHIFT 8#define PORT_PCR_MUX(x) (((uint32_t)(((uint32_t)(x))<<PORT_PCR_MUX_SHIFT))&PORT_PCR_MUX_MASK)#define PORT_PCR_LK_MASK 0x8000u#define PORT_PCR_LK_SHIFT 15#define PORT_PCR_IRQC_MASK 0xF0000u#define PORT_PCR_IRQC_SHIFT 16#define PORT_PCR_IRQC(x) (((uint32_t)(((uint32_t)(x))<<PORT_PCR_IRQC_SHIFT))&PORT_PCR_IRQC_MASK)#define PORT_PCR_ISF_MASK 0x1000000u#define PORT_PCR_ISF_SHIFT 24/* GPCLR Bit Fields */#define PORT_GPCLR_GPWD_MASK 0xFFFFu#define PORT_GPCLR_GPWD_SHIFT 0#define PORT_GPCLR_GPWD(x) (((uint32_t)(((uint32_t)(x))<<PORT_GPCLR_GPWD_SHIFT))&PORT_GPCLR_GPWD_MASK)#define PORT_GPCLR_GPWE_MASK 0xFFFF0000u#define PORT_GPCLR_GPWE_SHIFT 16#define PORT_GPCLR_GPWE(x) (((uint32_t)(((uint32_t)(x))<<PORT_GPCLR_GPWE_SHIFT))&PORT_GPCLR_GPWE_MASK)/* GPCHR Bit Fields */#define PORT_GPCHR_GPWD_MASK 0xFFFFu#define PORT_GPCHR_GPWD_SHIFT 0#define PORT_GPCHR_GPWD(x) (((uint32_t)(((uint32_t)(x))<<PORT_GPCHR_GPWD_SHIFT))&PORT_GPCHR_GPWD_MASK)#define PORT_GPCHR_GPWE_MASK 0xFFFF0000u#define PORT_GPCHR_GPWE_SHIFT 16#define PORT_GPCHR_GPWE(x) (((uint32_t)(((uint32_t)(x))<<PORT_GPCHR_GPWE_SHIFT))&PORT_GPCHR_GPWE_MASK)/* ISFR Bit Fields */#define PORT_ISFR_ISF_MASK 0xFFFFFFFFu#define PORT_ISFR_ISF_SHIFT 0#define PORT_ISFR_ISF(x) (((uint32_t)(((uint32_t)(x))<<PORT_ISFR_ISF_SHIFT))&PORT_ISFR_ISF_MASK)/* DFER Bit Fields */#define PORT_DFER_DFE_MASK 0xFFFFFFFFu#define PORT_DFER_DFE_SHIFT 0#define PORT_DFER_DFE(x) (((uint32_t)(((uint32_t)(x))<<PORT_DFER_DFE_SHIFT))&PORT_DFER_DFE_MASK)/* DFCR Bit Fields */#define PORT_DFCR_CS_MASK 0x1u#define PORT_DFCR_CS_SHIFT 0/* DFWR Bit Fields */#define PORT_DFWR_FILT_MASK 0x1Fu#define PORT_DFWR_FILT_SHIFT 0#define PORT_DFWR_FILT(x) (((uint32_t)(((uint32_t)(x))<<PORT_DFWR_FILT_SHIFT))&PORT_DFWR_FILT_MASK)/** * @} */ /* end of group PORT_Register_Masks *//* PORT - Peripheral instance base addresses *//** Peripheral PORTA base pointer */#define PORTA_BASE_PTR ((PORT_MemMapPtr)0x40049000u)/** Peripheral PORTB base pointer */#define PORTB_BASE_PTR ((PORT_MemMapPtr)0x4004A000u)/** Peripheral PORTC base pointer */#define PORTC_BASE_PTR ((PORT_MemMapPtr)0x4004B000u)/** Peripheral PORTD base pointer */#define PORTD_BASE_PTR ((PORT_MemMapPtr)0x4004C000u)/** Peripheral PORTE base pointer */#define PORTE_BASE_PTR ((PORT_MemMapPtr)0x4004D000u)/* ---------------------------------------------------------------------------- -- PORT - Register accessor macros ---------------------------------------------------------------------------- *//** * @addtogroup PORT_Register_Accessor_Macros PORT - Register accessor macros * @{ *//* PORT - Register instance definitions *//* PORTA */#define PORTA_PCR0 PORT_PCR_REG(PORTA_BASE_PTR,0)#define PORTA_PCR1 PORT_PCR_REG(PORTA_BASE_PTR,1)#define PORTA_PCR2 PORT_PCR_REG(PORTA_BASE_PTR,2)#define PORTA_PCR3 PORT_PCR_REG(PORTA_BASE_PTR,3)#define PORTA_PCR4 PORT_PCR_REG(PORTA_BASE_PTR,4)#define PORTA_PCR5 PORT_PCR_REG(PORTA_BASE_PTR,5)#define PORTA_PCR6 PORT_PCR_REG(PORTA_BASE_PTR,6)#define PORTA_PCR7 PORT_PCR_REG(PORTA_BASE_PTR,7)#define PORTA_PCR8 PORT_PCR_REG(PORTA_BASE_PTR,8)#define PORTA_PCR9 PORT_PCR_REG(PORTA_BASE_PTR,9)#define PORTA_PCR10 PORT_PCR_REG(PORTA_BASE_PTR,10)#define PORTA_PCR11 PORT_PCR_REG(PORTA_BASE_PTR,11)#define PORTA_PCR12 PORT_PCR_REG(PORTA_BASE_PTR,12)#define PORTA_PCR13 PORT_PCR_REG(PORTA_BASE_PTR,13)#define PORTA_PCR14 PORT_PCR_REG(PORTA_BASE_PTR,14)#define PORTA_PCR15 PORT_PCR_REG(PORTA_BASE_PTR,15)#define PORTA_PCR16 PORT_PCR_REG(PORTA_BASE_PTR,16)#define PORTA_PCR17 PORT_PCR_REG(PORTA_BASE_PTR,17)#define PORTA_PCR18 PORT_PCR_REG(PORTA_BASE_PTR,18)#define PORTA_PCR19 PORT_PCR_REG(PORTA_BASE_PTR,19)#define PORTA_PCR20 PORT_PCR_REG(PORTA_BASE_PTR,20)#define PORTA_PCR21 PORT_PCR_REG(PORTA_BASE_PTR,21)#define PORTA_PCR22 PORT_PCR_REG(PORTA_BASE_PTR,22)#define PORTA_PCR23 PORT_PCR_REG(PORTA_BASE_PTR,23)#define PORTA_PCR24 PORT_PCR_REG(PORTA_BASE_PTR,24)#define PORTA_PCR25 PORT_PCR_REG(PORTA_BASE_PTR,25)#define PORTA_PCR26 PORT_PCR_REG(PORTA_BASE_PTR,26)#define PORTA_PCR27 PORT_PCR_REG(PORTA_BASE_PTR,27)#define PORTA_PCR28 PORT_PCR_REG(PORTA_BASE_PTR,28)#define PORTA_PCR29 PORT_PCR_REG(PORTA_BASE_PTR,29)#define PORTA_PCR30 PORT_PCR_REG(PORTA_BASE_PTR,30)#define PORTA_PCR31 PORT_PCR_REG(PORTA_BASE_PTR,31)#define PORTA_GPCLR PORT_GPCLR_REG(PORTA_BASE_PTR)#define PORTA_GPCHR PORT_GPCHR_REG(PORTA_BASE_PTR)#define PORTA_ISFR PORT_ISFR_REG(PORTA_BASE_PTR)#define PORTA_DFER PORT_DFER_REG(PORTA_BASE_PTR)#define PORTA_DFCR PORT_DFCR_REG(PORTA_BASE_PTR)#define PORTA_DFWR PORT_DFWR_REG(PORTA_BASE_PTR)/* PORTB */#define PORTB_PCR0 PORT_PCR_REG(PORTB_BASE_PTR,0)#define PORTB_PCR1 PORT_PCR_REG(PORTB_BASE_PTR,1)#define PORTB_PCR2 PORT_PCR_REG(PORTB_BASE_PTR,2)#define PORTB_PCR3 PORT_PCR_REG(PORTB_BASE_PTR,3)#define PORTB_PCR4 PORT_PCR_REG(PORTB_BASE_PTR,4)#define PORTB_PCR5 PORT_PCR_REG(PORTB_BASE_PTR,5)#define PORTB_PCR6 PORT_PCR_REG(PORTB_BASE_PTR,6)#define PORTB_PCR7 PORT_PCR_REG(PORTB_BASE_PTR,7)#define PORTB_PCR8 PORT_PCR_REG(PORTB_BASE_PTR,8)#define PORTB_PCR9 PORT_PCR_REG(PORTB_BASE_PTR,9)#define PORTB_PCR10 PORT_PCR_REG(PORTB_BASE_PTR,10)#define PORTB_PCR11 PORT_PCR_REG(PORTB_BASE_PTR,11)#define PORTB_PCR12 PORT_PCR_REG(PORTB_BASE_PTR,12)#define PORTB_PCR13 PORT_PCR_REG(PORTB_BASE_PTR,13)#define PORTB_PCR14 PORT_PCR_REG(PORTB_BASE_PTR,14)#define PORTB_PCR15 PORT_PCR_REG(PORTB_BASE_PTR,15)#define PORTB_PCR16 PORT_PCR_REG(PORTB_BASE_PTR,16)#define PORTB_PCR17 PORT_PCR_REG(PORTB_BASE_PTR,17)#define PORTB_PCR18 PORT_PCR_REG(PORTB_BASE_PTR,18)#define PORTB_PCR19 PORT_PCR_REG(PORTB_BASE_PTR,19)#define PORTB_PCR20 PORT_PCR_REG(PORTB_BASE_PTR,20)#define PORTB_PCR21 PORT_PCR_REG(PORTB_BASE_PTR,21)#define PORTB_PCR22 PORT_PCR_REG(PORTB_BASE_PTR,22)#define PORTB_PCR23 PORT_PCR_REG(PORTB_BASE_PTR,23)#define PORTB_PCR24 PORT_PCR_REG(PORTB_BASE_PTR,24)#define PORTB_PCR25 PORT_PCR_REG(PORTB_BASE_PTR,25)#define PORTB_PCR26 PORT_PCR_REG(PORTB_BASE_PTR,26)#define PORTB_PCR27 PORT_PCR_REG(PORTB_BASE_PTR,27)#define PORTB_PCR28 PORT_PCR_REG(PORTB_BASE_PTR,28)#define PORTB_PCR29 PORT_PCR_REG(PORTB_BASE_PTR,29)#define PORTB_PCR30 PORT_PCR_REG(PORTB_BASE_PTR,30)#define PORTB_PCR31 PORT_PCR_REG(PORTB_BASE_PTR,31)#define PORTB_GPCLR PORT_GPCLR_REG(PORTB_BASE_PTR)#define PORTB_GPCHR PORT_GPCHR_REG(PORTB_BASE_PTR)#define PORTB_ISFR PORT_ISFR_REG(PORTB_BASE_PTR)#define PORTB_DFER PORT_DFER_REG(PORTB_BASE_PTR)#define PORTB_DFCR PORT_DFCR_REG(PORTB_BASE_PTR)#define PORTB_DFWR PORT_DFWR_REG(PORTB_BASE_PTR)/* PORTC */#define PORTC_PCR0 PORT_PCR_REG(PORTC_BASE_PTR,0)#define PORTC_PCR1 PORT_PCR_REG(PORTC_BASE_PTR,1)#define PORTC_PCR2 PORT_PCR_REG(PORTC_BASE_PTR,2)#define PORTC_PCR3 PORT_PCR_REG(PORTC_BASE_PTR,3)#define PORTC_PCR4 PORT_PCR_REG(PORTC_BASE_PTR,4)#define PORTC_PCR5 PORT_PCR_REG(PORTC_BASE_PTR,5)#define PORTC_PCR6 PORT_PCR_REG(PORTC_BASE_PTR,6)#define PORTC_PCR7 PORT_PCR_REG(PORTC_BASE_PTR,7)#define PORTC_PCR8 PORT_PCR_REG(PORTC_BASE_PTR,8)#define PORTC_PCR9 PORT_PCR_REG(PORTC_BASE_PTR,9)#define PORTC_PCR10 PORT_PCR_REG(PORTC_BASE_PTR,10)#define PORTC_PCR11 PORT_PCR_REG(PORTC_BASE_PTR,11)#define PORTC_PCR12 PORT_PCR_REG(PORTC_BASE_PTR,12)#define PORTC_PCR13 PORT_PCR_REG(PORTC_BASE_PTR,13)#define PORTC_PCR14 PORT_PCR_REG(PORTC_BASE_PTR,14)#define PORTC_PCR15 PORT_PCR_REG(PORTC_BASE_PTR,15)#define PORTC_PCR16 PORT_PCR_REG(PORTC_BASE_PTR,16)#define PORTC_PCR17 PORT_PCR_REG(PORTC_BASE_PTR,17)#define PORTC_PCR18 PORT_PCR_REG(PORTC_BASE_PTR,18)#define PORTC_PCR19 PORT_PCR_REG(PORTC_BASE_PTR,19)#define PORTC_PCR20 PORT_PCR_REG(PORTC_BASE_PTR,20)#define PORTC_PCR21 PORT_PCR_REG(PORTC_BASE_PTR,21)#define PORTC_PCR22 PORT_PCR_REG(PORTC_BASE_PTR,22)#define PORTC_PCR23 PORT_PCR_REG(PORTC_BASE_PTR,23)#define PORTC_PCR24 PORT_PCR_REG(PORTC_BASE_PTR,24)#define PORTC_PCR25 PORT_PCR_REG(PORTC_BASE_PTR,25)#define PORTC_PCR26 PORT_PCR_REG(PORTC_BASE_PTR,26)#define PORTC_PCR27 PORT_PCR_REG(PORTC_BASE_PTR,27)#define PORTC_PCR28 PORT_PCR_REG(PORTC_BASE_PTR,28)#define PORTC_PCR29 PORT_PCR_REG(PORTC_BASE_PTR,29)#define PORTC_PCR30 PORT_PCR_REG(PORTC_BASE_PTR,30)#define PORTC_PCR31 PORT_PCR_REG(PORTC_BASE_PTR,31)#define PORTC_GPCLR PORT_GPCLR_REG(PORTC_BASE_PTR)#define PORTC_GPCHR PORT_GPCHR_REG(PORTC_BASE_PTR)#define PORTC_ISFR PORT_ISFR_REG(PORTC_BASE_PTR)#define PORTC_DFER PORT_DFER_REG(PORTC_BASE_PTR)#define PORTC_DFCR PORT_DFCR_REG(PORTC_BASE_PTR)#define PORTC_DFWR PORT_DFWR_REG(PORTC_BASE_PTR)/* PORTD */#define PORTD_PCR0 PORT_PCR_REG(PORTD_BASE_PTR,0)#define PORTD_PCR1 PORT_PCR_REG(PORTD_BASE_PTR,1)#define PORTD_PCR2 PORT_PCR_REG(PORTD_BASE_PTR,2)#define PORTD_PCR3 PORT_PCR_REG(PORTD_BASE_PTR,3)#define PORTD_PCR4 PORT_PCR_REG(PORTD_BASE_PTR,4)#define PORTD_PCR5 PORT_PCR_REG(PORTD_BASE_PTR,5)#define PORTD_PCR6 PORT_PCR_REG(PORTD_BASE_PTR,6)#define PORTD_PCR7 PORT_PCR_REG(PORTD_BASE_PTR,7)#define PORTD_PCR8 PORT_PCR_REG(PORTD_BASE_PTR,8)#define PORTD_PCR9 PORT_PCR_REG(PORTD_BASE_PTR,9)#define PORTD_PCR10 PORT_PCR_REG(PORTD_BASE_PTR,10)#define PORTD_PCR11 PORT_PCR_REG(PORTD_BASE_PTR,11)#define PORTD_PCR12 PORT_PCR_REG(PORTD_BASE_PTR,12)#define PORTD_PCR13 PORT_PCR_REG(PORTD_BASE_PTR,13)#define PORTD_PCR14 PORT_PCR_REG(PORTD_BASE_PTR,14)#define PORTD_PCR15 PORT_PCR_REG(PORTD_BASE_PTR,15)#define PORTD_PCR16 PORT_PCR_REG(PORTD_BASE_PTR,16)#define PORTD_PCR17 PORT_PCR_REG(PORTD_BASE_PTR,17)#define PORTD_PCR18 PORT_PCR_REG(PORTD_BASE_PTR,18)#define PORTD_PCR19 PORT_PCR_REG(PORTD_BASE_PTR,19)#define PORTD_PCR20 PORT_PCR_REG(PORTD_BASE_PTR,20)#define PORTD_PCR21 PORT_PCR_REG(PORTD_BASE_PTR,21)#define PORTD_PCR22 PORT_PCR_REG(PORTD_BASE_PTR,22)#define PORTD_PCR23 PORT_PCR_REG(PORTD_BASE_PTR,23)#define PORTD_PCR24 PORT_PCR_REG(PORTD_BASE_PTR,24)#define PORTD_PCR25 PORT_PCR_REG(PORTD_BASE_PTR,25)#define PORTD_PCR26 PORT_PCR_REG(PORTD_BASE_PTR,26)#define PORTD_PCR27 PORT_PCR_REG(PORTD_BASE_PTR,27)#define PORTD_PCR28 PORT_PCR_REG(PORTD_BASE_PTR,28)#define PORTD_PCR29 PORT_PCR_REG(PORTD_BASE_PTR,29)#define PORTD_PCR30 PORT_PCR_REG(PORTD_BASE_PTR,30)#define PORTD_PCR31 PORT_PCR_REG(PORTD_BASE_PTR,31)#define PORTD_GPCLR PORT_GPCLR_REG(PORTD_BASE_PTR)#define PORTD_GPCHR PORT_GPCHR_REG(PORTD_BASE_PTR)#define PORTD_ISFR PORT_ISFR_REG(PORTD_BASE_PTR)#define PORTD_DFER PORT_DFER_REG(PORTD_BASE_PTR)#define PORTD_DFCR PORT_DFCR_REG(PORTD_BASE_PTR)#define PORTD_DFWR PORT_DFWR_REG(PORTD_BASE_PTR)/* PORTE */#define PORTE_PCR0 PORT_PCR_REG(PORTE_BASE_PTR,0)#define PORTE_PCR1 PORT_PCR_REG(PORTE_BASE_PTR,1)#define PORTE_PCR2 PORT_PCR_REG(PORTE_BASE_PTR,2)#define PORTE_PCR3 PORT_PCR_REG(PORTE_BASE_PTR,3)#define PORTE_PCR4 PORT_PCR_REG(PORTE_BASE_PTR,4)#define PORTE_PCR5 PORT_PCR_REG(PORTE_BASE_PTR,5)#define PORTE_PCR6 PORT_PCR_REG(PORTE_BASE_PTR,6)#define PORTE_PCR7 PORT_PCR_REG(PORTE_BASE_PTR,7)#define PORTE_PCR8 PORT_PCR_REG(PORTE_BASE_PTR,8)#define PORTE_PCR9 PORT_PCR_REG(PORTE_BASE_PTR,9)#define PORTE_PCR10 PORT_PCR_REG(PORTE_BASE_PTR,10)#define PORTE_PCR11 PORT_PCR_REG(PORTE_BASE_PTR,11)#define PORTE_PCR12 PORT_PCR_REG(PORTE_BASE_PTR,12)#define PORTE_PCR13 PORT_PCR_REG(PORTE_BASE_PTR,13)#define PORTE_PCR14 PORT_PCR_REG(PORTE_BASE_PTR,14)#define PORTE_PCR15 PORT_PCR_REG(PORTE_BASE_PTR,15)#define PORTE_PCR16 PORT_PCR_REG(PORTE_BASE_PTR,16)#define PORTE_PCR17 PORT_PCR_REG(PORTE_BASE_PTR,17)#define PORTE_PCR18 PORT_PCR_REG(PORTE_BASE_PTR,18)#define PORTE_PCR19 PORT_PCR_REG(PORTE_BASE_PTR,19)#define PORTE_PCR20 PORT_PCR_REG(PORTE_BASE_PTR,20)#define PORTE_PCR21 PORT_PCR_REG(PORTE_BASE_PTR,21)#define PORTE_PCR22 PORT_PCR_REG(PORTE_BASE_PTR,22)#define PORTE_PCR23 PORT_PCR_REG(PORTE_BASE_PTR,23)#define PORTE_PCR24 PORT_PCR_REG(PORTE_BASE_PTR,24)#define PORTE_PCR25 PORT_PCR_REG(PORTE_BASE_PTR,25)#define PORTE_PCR26 PORT_PCR_REG(PORTE_BASE_PTR,26)#define PORTE_PCR27 PORT_PCR_REG(PORTE_BASE_PTR,27)#define PORTE_PCR28 PORT_PCR_REG(PORTE_BASE_PTR,28)#define PORTE_PCR29 PORT_PCR_REG(PORTE_BASE_PTR,29)#define PORTE_PCR30 PORT_PCR_REG(PORTE_BASE_PTR,30)#define PORTE_PCR31 PORT_PCR_REG(PORTE_BASE_PTR,31)#define PORTE_GPCLR PORT_GPCLR_REG(PORTE_BASE_PTR)#define PORTE_GPCHR PORT_GPCHR_REG(PORTE_BASE_PTR)#define PORTE_ISFR PORT_ISFR_REG(PORTE_BASE_PTR)#define PORTE_DFER PORT_DFER_REG(PORTE_BASE_PTR)#define PORTE_DFCR PORT_DFCR_REG(PORTE_BASE_PTR)#define PORTE_DFWR PORT_DFWR_REG(PORTE_BASE_PTR)/* PORT - Register array accessors */#define PORTA_PCR(index) PORT_PCR_REG(PORTA_BASE_PTR,index)#define PORTB_PCR(index) PORT_PCR_REG(PORTB_BASE_PTR,index)#define PORTC_PCR(index) PORT_PCR_REG(PORTC_BASE_PTR,index)#define PORTD_PCR(index) PORT_PCR_REG(PORTD_BASE_PTR,index)#define PORTE_PCR(index) PORT_PCR_REG(PORTE_BASE_PTR,index)/** * @} */ /* end of group PORT_Register_Accessor_Macros *//** * @} */ /* end of group PORT_Peripheral */
上述代码是K60芯片的PORT模块相关头文件定义,这里结合硬件手册 K60P100M100SF2RM 对该部分代码进行简要分析。
软件结构分析:
1、“struct PORT_MemMap{ }”:端口内存映射结构体,该结构体定义了一系列“端口控制寄存器”的名称,利用结构体本身的“平坦特性”与CPU中实际的寄存器的相对地址一一对应,实现结构体变量操作对物理地址操作的映射(这里只实现了相对映射,完全映射需要有绝对地址,下面会看到)。该结构体区域中有多块保留空间,与硬件文档地址分配一致不可删除,详见K60P100M100SF2RM 文件11.4 Memory map and register definition章节。如下图所示:
3、“#define PORT_PCR_PS_MASK 0x1u”:端口寄存器中的位域屏蔽码,根据硬件手册对端口中各个寄存器的各个位域进行定义,根据缩写大概能猜想出个大概,便于后期使用,详见K60P100M100SF2RM 文件11.4.1 Pin Control Register n(PORTx_PCRn),其他定义类似。如下图所示:
4、“#define PORTA_BASE_PTR ((PORT_MemMapPtr)0x40049000u)”:定义端口A寄存器组的基地址0x40049000,该CPU中对各个寄存器的配置本质上是对内存映射地址的配置。上面讲到逻辑操作对物理地址的映射问题时,指出只能实现相对映射,这里的绝对地址定义就是为实现地址绝对映射。PORT_MemMapPtr是端口寄存器组的强制类型转换,与结构体“struct PORT_MemMap{ }”共同作用,表示基地址和偏移地址,这样就能通过结构体变量来操控该寄存器组中的任意硬件寄存器,对于其他端口定义也是类似。5、“#define PORTA_PCR0 PORT_PCR_REG(PORTA_BASE_PTR,0)”:各个端口的内部寄存器变量定义,也是为了方便后期使用,每个端口的寄存器数量可能不一致,但都与硬件寄存器配置一致。
硬件特性分析:
1、PORT模块主要是对IO端口(不仅仅限于GPIO)的功能性能进行配置,达到一些复杂的功能实现。包括:引脚中断(中断类型配置、中断打开关闭、DMA设置)、数字输入滤波(滤波开关、滤波时钟源、分辨率)、端口控制(各个引脚功能复用、上拉/下拉,电平转换斜率,驱动强度)。例如:如果引脚想实现 GPIO模块 的功能,就需要对PORT模块进行相关配置,设置引脚复用为GPIO,设置上拉\下拉等等。
2、
- MQX4.0:MK60DZ10.h头文件PORT模块代码分析
- MQX4.0:MK60DZ10.h头文件GPIO模块代码分析
- MQX4.0:MK60DZ10.h头文件PORT模块…
- MQX4.0:MK60DZ10.h头文件GPIO模块…
- list.h头文件分析
- list.h头文件分析
- linux内核中链表代码分析---list.h头文件分析(一)
- linux内核中链表代码分析---list.h头文件分析(二)
- linux内核list.h头文件分析
- HAL层,.sensors.h 头文件分析
- 4.4 ipu_param_mem.h头文件分析
- stdarg.h头文件源代码分析
- linux内核模块头文件之---kernel.h
- libsvm代码阅读:基础准备与svm.h头文件
- linux内核list.h头文件分析(一)
- linux内核list.h头文件分析(二)
- linux内核list.h头文件分析(三)
- linux内核list.h头文件分析(四)
- android一些有用属性
- 最近抽了点时间做了个Android电子书一键生成器
- 是时候清除你的僵尸代码了
- [STL基础]STL概述+总结
- 程序员如何做出“不难看”的设计
- MQX4.0:MK60DZ10.h头文件PORT模块代码分析
- 红黑树和平衡二叉树 区别
- 人生路长,何从选择?
- WebKit模块化分析
- 2.1.2 硬件环境
- jquery form API浅层阅读
- 2.1.3 软件环境
- 朝鲜叛逃高官揭秘:金正日真实的一生
- typedef和typename关键字