打印

typedef struct不太会,有没有大佬细心指导指导?

[复制链接]
295|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
无幻|  楼主 | 2020-4-25 16:42 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
//用来存放寄存器映射的代码

//外设 Perirhral
#define PERIRPH_BASE            ((unsigned int)0x40000000)//这里要别加*号就都别加不然出问题
#define APB1PERIRPH_BASE        PERIRPH_BASE
#define APB2PERIRPH_BASE        (PERIRPH_BASE+0x10000)
#define AHBPERIRPH_BASE         (PERIRPH_BASE+0x20000)

#define RCC_BASE                (AHBPERIRPH_BASE+0x1000)   
#define GPIOB_BASE              (APB2PERIRPH_BASE+0x0c00)

#define RCC_APB2ENR             *(unsigned int*)(RCC_BASE+0x18)
        
//#define GPIOB_CRL               *(unsigned int*)(GPIOB_BASE+0x00)
//#define GPIOB_CRH               *(unsigned int*)(GPIOB_BASE+0x04)
//#define GPIOB_IDR               *(unsigned int*)(GPIOB_BASE+0x08)
//#define GPIOB_ODR               *(unsigned int*)(GPIOB_BASE+0x0C)
//#define GPIOB_BSRR              *(unsigned int*)(GPIOB_BASE+0x10)
//#define GPIOB_BRR               *(unsigned int*)(GPIOB_BASE+0x14)
//#define GPIOB_LCKR              *(unsigned int*)(GPIOB_BASE+0x18)
        

typedef unsigned int   uint32_t;
typedef unsigned short uint16_t;
typedef struct
{
  uint32_t CRL;
        uint32_t CRH;
        uint32_t IDR;
        uint32_t ODR;
        uint32_t BSRR;
        uint32_t BRR;
        uint32_t LCKR;
}GPIO_TypeDef;


typedef struct
{
  uint32_t CR;
        uint32_t CFGR;
        uint32_t CIR;
        uint32_t APB2RSTR;
        uint32_t APB1RSTR;
        uint32_t AHBENR;
        uint32_t APB2ENR;
        uint32_t APB1ENR;
        uint32_t BDCR;
        uint32_t CSR;
}RCC_TypeDef;

#define GPIOB ((GPIO_TypeDef*)GPIOB_BASE)

使用特权

评论回复

相关帖子

发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

431

主题

436

帖子

0

粉丝