Cortex-M3使用CMSIS编程的问题
以下是一个嵌入式平台上的代码
有如下这些定义:
#define SCS_BASE (0xE000E000) /*!< System Control Space Base Address */
#define NVIC_BASE (SCS_BASE + 0x0100) /*!< NVIC Base Address */
typedef struct
{
__IO uint32_t ISER[8]; /*!< Offset: 0x000 Interrupt Set Enable Register */
uint32_t RESERVED0[24];
__IO uint32_t ICER[8]; /*!< Offset: 0x080 Interrupt Clear Enable Register */
uint32_t RSERVED1[24];
__IO uint32_t ISPR[8]; /*!< Offset: 0x100 Interrupt Set Pending Register */
uint32_t RESERVED2[24];
__IO uint32_t ICPR[8]; /*!< Offset: 0x180 Interrupt Clear Pending Register */
uint32_t RESERVED3[24];
__IO uint32_t IABR[8]; /*!< Offset: 0x200 Interrupt Active bit Register */
uint32_t RESERVED4[56];
__IO uint8_t IP[240]; /*!< Offset: 0x300 Interrupt Priority Register (8Bit wide) */
uint32_t RESERVED5[644];
__O uint32_t STIR; /*!< Offset: 0xE00 Software Trigger Interrupt Register */
} NVIC_Type;
#define NVIC ((NVIC_Type *) NVIC_BASE) /*!< NVIC configuration struct */
在使用的时候它就这么用:比方说是要给ISER附值,NVIC->ISER=0x85c0;我主要 是不能理解这句:
#define NVIC ((NVIC_Type *) NVIC_BASE)其中这个(NVIC_Type *) 是什么意思?起什么作用的?还有就是这个ISER的地址是0xe000e100
我们写程序的时候为什么不直接写成:
#define ISER (0xE000E100) 然后来一句:ISER=0x85c0;为什么就要这么费劲?定义了那么多东西?它这么做有什么好处?