新手上路
- 积分
- 40
- 金钱
- 40
- 注册时间
- 2014-1-24
- 在线时间
- 6 小时
|
发表于 2020-6-23 14:44:33
|
显示全部楼层
问题多是复杂化了,精力很充沛!用结构体加联合体去描述寄存器不是很好麻,为什么要这么麻烦。
typedef struct stc_gpio_inen_field
{
__IO uint32_t INEN0 : 1;
__IO uint32_t INEN1 : 1;
__IO uint32_t INEN2 : 1;
__IO uint32_t INEN3 : 1;
__IO uint32_t INEN4 : 1;
__IO uint32_t INEN5 : 1;
__IO uint32_t INEN6 : 1;
__IO uint32_t INEN7 : 1;
__IO uint32_t INEN8 : 1;
__IO uint32_t INEN9 : 1;
__IO uint32_t INEN10 : 1;
__IO uint32_t INEN11 : 1;
__IO uint32_t INEN12 : 1;
__IO uint32_t INEN13 : 1;
__IO uint32_t INEN14 : 1;
__IO uint32_t INEN15 : 1;
} stc_gpio_inen_field_t;
typedef struct
{
union {
__IO uint32_t INEN;
stc_gpio_inen_field_t INEN_f;
};
''''''''''''
}FM3_GPIO_TypeDef;
#define GPIO_PA ((FM3_GPIO_TypeDef *)0x40000C00UL)
//整体操作:
GPIO_PA->INEN=0xxxxxxxx;
//位操作
GPIO_PA->INEN_f.INEN4=x;
不服的加QQ:253344458交流
|
|