stm32存储空间定义及其结构体定义

//第一级
#define PERIPH_BB_BASE        ((uint32_t)0x42000000) ///*!< Peripheral base address in the 
                                                     //  bit-band region  0x42 000 000 
//第二级
#define APB1PERIPH_BASE       PERIPH_BASE
#define APB2PERIPH_BASE       (PERIPH_BASE + 0x00010000)  
#define AHB1PERIPH_BASE       (PERIPH_BASE + 0x00020000)
#define AHB2PERIPH_BASE       (PERIPH_BASE + 0x10000000)

//第三级  -----1
#define TIM2_BASE             (APB1PERIPH_BASE + 0x0000)
#define TIM3_BASE             (APB1PERIPH_BASE + 0x0400)
#define GPIOA_BASE            (AHB1PERIPH_BASE + 0x0000)
#define GPIOB_BASE            (AHB1PERIPH_BASE + 0x0400)
#define GPIOC_BASE            (AHB1PERIPH_BASE + 0x0800)

//第三级   ---- 2
#define TIM2                ((TIM_TypeDef *) TIM2_BASE)
#define TIM3                ((TIM_TypeDef *) TIM3_BASE)
#define GPIOA               ((GPIO_TypeDef *) GPIOA_BASE)
#define GPIOB               ((GPIO_TypeDef *) GPIOB_BASE)
#define GPIOC               ((GPIO_TypeDef *) GPIOC_BASE)

typedef struct
{
  __IO uint32_t MODER;    /*!< GPIO port mode register, Address offset: 0x00      */

  __IO uint32_t OTYPER;   /*!< GPIO port output type register,  

  __IO uint32_t OSPEEDR;  /*!< GPIO port output speed register,     

  __IO uint32_t PUPDR;    /*!< GPIO port pull-up/pull-down register, 

  __IO uint32_t IDR;      /*!< GPIO port input data register,         

  __IO uint32_t ODR;      /*!< GPIO port output data register,       

  __IO uint16_t BSRRL;    /*!< GPIO port bit set/reset low register,

  __IO uint16_t BSRRH;    /*!< GPIO port bit set/reset high register, 

  __IO uint32_t LCKR;     /*!< GPIO port configuration lock register,

  __IO uint32_t AFR[2];   /*!< GPIO alternate function registers,     

} GPIO_TypeDef;



typedef struct
{
  uint32_t GPIO_Pin;              /*!< Specifies the GPIO pins to be configured.
                                   
  GPIOMode_TypeDef GPIO_Mode;    /*!< Specifies the operating mode for the selected pins.
                                    

  GPIOSpeed_TypeDef GPIO_Speed;   /*!< Specifies the speed for the selected pins.
                                      

  GPIOOType_TypeDef GPIO_OType;   /*!< Specifies the operating output type for the 
                                     

  GPIOPuPd_TypeDef GPIO_PuPd;     /*!< Specifies the operating Pull-up/Pull down for the 
                                    
}GPIO_InitTypeDef;


 GPIO_InitTypeDef -------------->>>>>>>>>>   GPIO_TypeDef

void GPIO_Init(GPIO_TypeDef* GPIOx, GPIO_InitTypeDef* GPIO_InitStruct)

从功能参数   到  寄存器参数

   

猜你喜欢

转载自blog.csdn.net/h490516509/article/details/88030450