博士
最后登录1970-1-1
在线时间 小时
注册时间2015-11-21
|
看到core_cm3.h头文件内定义了下面几个宏。发现__IO,__I,__O都是定义为volatile这个关键字。而后面注释的都是要么是只读许可,要么是读写许可,可是后面其他地方使用这个宏进行定义变量的时候,都是被替换成一样的volatile?怎么会有不同的读写限制呢? 看后面的 NVIC_Type 结构体定义便知:
#ifdef __cplusplus
#define __I volatile /*!< defines 'read only' permissions */ 只读许可
#else
#define __I volatile const /*!< defines 'read only' permissions */
#endif
#define __O volatile /*!< defines 'write only' permissions */ 只写许可
#define __IO volatile /*!< defines 'read / write' permissions */读写许可
-----------------------------------------注意下面的红色的宏定义,被替换后,都是清一色的volatile关键字,从哪里看出有读写访问限制了?
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;
typedef struct
{
__I uint32_t CPUID; /*!< Offset: 0x00 CPU ID Base Register CPUIDoÅ */ 这个地方是只读访问许可,写也是可以的吧?
__IO uint32_t ICSR; /*!< Offset: 0x04 Interrupt Control State Register ÖD¶Ï¿ØÖÆÆ÷×′ì¬ */
__IO uint32_t VTOR; /*!< Offset: 0x08 Vector Table Offset Register Ïò῱íÆ«òÆ */
__IO uint32_t AIRCR; /*!< Offset: 0x0C Application Interrupt / Reset Control Register ó|óÃÖD¶Ï¸′λ¿ØÖÆÆ÷ */
__IO uint32_t SCR; /*!< Offset: 0x10 System Control Register Ïμí3¿ØÖƼÄ′æÆ÷ */
__IO uint32_t CCR; /*!< Offset: 0x14 Configuration Control Register ÅäÖÿØÖƼÄ′æÆ÷ */
__IO uint8_t SHP[12]; /*!< Offset: 0x18 System Handlers Priority Registers (4-7, 8-11, 12-15) */
__IO uint32_t SHCSR; /*!< Offset: 0x24 System Handler Control and State Register Ïμí3′|àí¿ØÖÆ×′ì¬ */
__IO uint32_t CFSR; /*!< Offset: 0x28 Configurable Fault Status Register 1êÕÏ×′쬼Ä′æÆ÷ */
__IO uint32_t HFSR; /*!< Offset: 0x2C Hard Fault Status Register ó2¼t1êÕÏ×′쬼Ä′æÆ÷ */
__IO uint32_t DFSR; /*!< Offset: 0x30 Debug Fault Status Register μ÷êÔ1êÕÏ×′쬼Ä′æÆ÷ */
__IO uint32_t MMFAR; /*!< Offset: 0x34 Mem Manage Address Register Äú′æ1üàíμØÖ·¼Ä′æÆ÷*/
__IO uint32_t BFAR; /*!< Offset: 0x38 Bus Fault Address Register ×üÏß1êÕÏμØÖ·¼Ä′æÆ÷*/
__IO uint32_t AFSR; /*!< Offset: 0x3C Auxiliary Fault Status Register ¸¨Öú1êÕϼÄ′æÆ÷ */
__I uint32_t PFR[2]; /*!< Offset: 0x40 Processor Feature Register ′|àíÆ÷ìØDÔ¼Ä′æÆ÷ */
__I uint32_t DFR; /*!< Offset: 0x48 Debug Feature Register μ÷êÔìØDÔ¼Ä′æÆ÷ */
__I uint32_t ADR; /*!< Offset: 0x4C Auxiliary Feature Register ¸¨ÖúìØDÔ¼Ä′æÆ÷ */
__I uint32_t MMFR[4]; /*!< Offset: 0x50 Memory Model Feature Register Äú′æÄ£DíìØDÔ¼Ä′æÆ÷ */
__I uint32_t ISAR[5]; /*!< Offset: 0x60 ISA Feature Register ISAìØDÔ¼Ä′æÆ÷*/
} SCB_Type;
----------------------------------
恳求指导!!
多谢
|
|