STM3232 GPIO的配置寄存器(为了移植IIC)

参考
https://blog.csdn.net/qq_45539458/article/details/129481019
https://blog.csdn.net/weixin_43314829/article/details/125573448?spm=1001.2014.3001.5502
https://blog.csdn.net/m0_71548440/article/details/125894236?spm=1001.2014.3001.5502

正点原子mini板 stm32f103rct6 普通口模拟iic通信设置
CRH:15 14 13 12_11 10 9 8—FFFF_0FFF (11-8)*4=12 CRH

//IO方向      
#define SDA_IN()  {GPIOC->CRH&=0XFFFF0FFF;GPIOC->CRH|=8<<12;}
#define SDA_OUT() {GPIOC->CRH&=0XFFFF0FFF;GPIOC->CRH|=3<<12;}

//IO操作	 
#define IIC_SCL    PCout(12) //SCL
#define IIC_SDA    PCout(11) //SDA	 
#define READ_SDA   PCin(11)  //输入SDA 

更改io口如下 FF0F FFFF (13-8)*4=20 CRH

#define SDA_IN()  {GPIOC->CRH&=0XFF0FFFFF;GPIOC->CRH|=(u32)8<<20;}	//CRH:15 14 13 12 11 10 9 8 
#define SDA_OUT() {GPIOC->CRH&=0XFF0FFFFF;GPIOC->CRH|=(u32)3<<20;} 	//PC13
#define IIC_SCL   PCout(0) //SCL
#define IIC_SDA   PCout(13) //SDA
#define READ_SDA  PCin(13)  //ÊäÈëSDA

ds18b20代码 0 *4=0 CRL

//IO·½ÏòÉèÖÃ
#define DS18B20_IO_IN()  {GPIOA->CRL&=0XFFFFFFF0;GPIOA->CRL|=8<<0;}
#define DS18B20_IO_OUT() {GPIOA->CRL&=0XFFFFFFF0;GPIOA->CRL|=3<<0;}
IO²Ù×÷º¯Êý											   
#define	DS18B20_DQ_OUT PAout(0) //Êý¾Ý¶Ë¿Ú	PA0
#define	DS18B20_DQ_IN  PAin(0)  //Êý¾Ý¶Ë¿Ú	PA0 

战舰板 iic 7*4=28 CRL

#define SDA_IN()  {GPIOB->CRL&=0X0FFFFFFF;GPIOB->CRL|=(u32)8<<28;}
#define SDA_OUT() {GPIOB->CRL&=0X0FFFFFFF;GPIOB->CRL|=(u32)3<<28;}
#define IIC_SCL    PBout(6) //SCL
#define IIC_SDA    PBout(7) //SDA	 
#define READ_SDA   PBin(7)  //ÊäÈëSDA 

战舰板 ds18b20 (11-8)*4=12 CRH

//IO·½ÏòÉèÖÃ
#define DS18B20_IO_IN()  {GPIOG->CRH&=0XFFFF0FFF;GPIOG->CRH|=8<<12;}
#define DS18B20_IO_OUT() {GPIOG->CRH&=0XFFFF0FFF;GPIOG->CRH|=3<<12;}
IO²Ù×÷º¯Êý											   
#define	DS18B20_DQ_OUT PGout(11) //Êý¾Ý¶Ë¿Ú	PA0 
#define	DS18B20_DQ_IN  PGin(11)  //Êý¾Ý¶Ë¿Ú	PA0 

你可能感兴趣的:(stm32,嵌入式硬件,单片机)