论坛元老 
   
	- 积分
 - 3038
 
        - 金钱
 - 3038 
 
       - 注册时间
 - 2017-9-8
 
      - 在线时间
 - 494 小时
 
 
 
 | 
 
 
 楼主 |
发表于 2024-11-25 13:46:48
|
显示全部楼层
 
 
 
- void  ROM_IIC_init(void)
 
 - {                                             
 
 -         GPIO_InitTypeDef GPIO_InitStructure;
 
 -         //RCC->APB2ENR|=1<<4;//先使能外设IO PORTC时钟 
 
 -         RCC_APB2PeriphClockCmd(        RCC_APB2Periph_GPIOC, ENABLE );        
 
 -            
 
 -         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_1|GPIO_Pin_2;
 
 -         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP ;   //推挽输出
 
 -         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
 
 -         GPIO_Init(GPIOC, &GPIO_InitStructure);
 
 -         
 
 -         ROM_IIC_SCL=1;
 
 -         ROM_IIC_SDA=1;
 
 - }
 
  
- void  ROM_SDA_OUT()
 
 - {
 
 -         GPIO_InitTypeDef  GPIO_InitStructure;        
 
 -         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);        
 
 -         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;        
 
 -         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; 
 
 -         GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;        
 
 -         GPIO_Init(GPIOB, &GPIO_InitStructure);                        
 
 - }
 
  
- void  ROM_SDA_IN()
 
 - {
 
 -         GPIO_InitTypeDef  GPIO_InitStructure;        
 
 -         RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOC, ENABLE);        
 
 -         GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;        
 
 -         GPIO_InitStructure.GPIO_Mode = GPIO_Mode_IN_FLOATING; 
 
 -         GPIO_Init(GPIOB, &GPIO_InitStructure);        
 
 - }
 
  复制代码 |   
 
 
 
 |