/**********************GPIO别名储存器映射表*************************/
//GPIOC_ODR[15..0]映射到别名区
//GPIOC_ODR ADDRESS=0x4001 100C
//别名区 ADDRESS=0x4200 0000 + (0x0001 100C*0x20) + (bitx*4) ;bitx:第x位
#define PC_Bit0 ((volatile unsigned long *) (0x42220180))
#define PC_Bit1 ((volatile unsigned long *) (0x42220184))
#define PC_Bit2 ((volatile unsigned long *) (0x42220188))
#define PC_Bit3 ((volatile unsigned long *) (0x4222018C))
#define PC_Bit4 ((volatile unsigned long *) (0x42220190))
#define PC_Bit5 ((volatile unsigned long *) (0x42220194))
#define PC_Bit6 ((volatile unsigned long *) (0x42220198))
#define PC_Bit7 ((volatile unsigned long *) (0x4222019C))
#define PC_Bit8 ((volatile unsigned long *) (0x422201A0))
#define PC_Bit9 ((volatile unsigned long *) (0x422201A4))
#define PC_Bit10 ((volatile unsigned long *) (0x422201A8))
#define PC_Bit11 ((volatile unsigned long *) (0x422201AC))
#define PC_Bit12 ((volatile unsigned long *) (0x422201B0))
#define PC_Bit13 ((volatile unsigned long *) (0x422201B4))
#define PC_Bit14 ((volatile unsigned long *) (0x422201B8))
#define PC_Bit15 ((volatile unsigned long *) (0x422201BC))
/
//对GPIO做为输出的操作可以有几种方法:
//1:直接对GPIOx_ODR写入,
// 如:GPIOC_ODR=0x00FF;//Bit[15..8]=0;Bit[7..0]=1;
// 注意:这种方法必须是以字(16位)的形式写入数据。
// 除了写之外该寄存器还可以读。
//2: 通过对GPIOx_BSRR写入,
// 如:GPIOC_BSRR=0x0000 0010;//高16位写入0不影响IO口,写入1表示清除GPIOx_ODR对应位为0;
// //低16位写入0不影响IO口,写如1表示设置GPIOx_ODR对应位为1;
// 因此通过GPIOx_BSRR可以实现单独位的操作,如上面的式子表示Bit[4]=1;
//3: 通过别名区的映射地址写入,
// 如:#define PC_Bit0 ((volatile unsigned long *) (0x42220180))
// #define PC_Bit4 ((volatile unsigned long *) (0x42220190))
// *PC_Bit0=1;
// *PC_Bit4=0;//
// 因为别名区对应着位带区中GPIOx_ODR的每1位,所以对别名区的操作就相当于对位带区中GPIOx_ODR的单独位操作;
// 除了写之外该寄存器还可以读。
//另外,对GPIOx_BSRR的高16位写入1与对GPIOx_BRR的低16位写入1作用相同:都表示清除GPIOx_ODR对应位为0;
STM32别名区
最新推荐文章于 2024-03-12 18:14:55 发布