第一步:配置IIC外设,代替IIC_Init() 第二步:控制外设电路,实现指定地址写时序,替换Write_Reg() 第三步:控制外设电路,实现指定地址读时序,替换Read_Reg() RCC_APB1PeriphClockCmd(RCC_APB1Periph_I2C2,ENABLE);//时钟 RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOB,ENABLE); GPIO_InitTypeDef GPIO_InitStruct...
GPIO_InitTypeDef GPIO_Initure; __HAL_RCC_GPIOF_CLK_ENABLE(); //使能GPIOF时钟 //PF15,13初始化设置 GPIO_Initure.Pin=GPIO_PIN_15|GPIO_PIN_13; GPIO_Initure.Mode=GPIO_MODE_OUTPUT_PP; //推挽输出 GPIO_Initure.Pull=GPIO_PULLUP; //上拉 GPIO_Initure.Speed=GPIO_SPEED_FAST; //快速 HAL_...
void IIC_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOC, ENABLE); GPIO_InitStructure.GPIO_Pin = GPIO_Pin_8 | GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_S...
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; HAL_GPIO_Init(IIC_SCL_PORT, &GPIO_InitStruct); GPIO_InitStruct.Pin = IIC_SDA_PIN; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; GPIO_InitStruct.Pull = GPIO_...
GPIO_Init(EPROM_I2C_SDA_GPIO_PORT, &GPIO_InitStruct); // 配置I2C参数(时钟速度、模式、占空比、自身地址、应答使能、7位设备地址) I2C_InitStruct.I2C_ClockSpeed = EEPROM_I2C_BAUDRATE; I2C_InitStruct.I2C_Mode = I2C_Mode_I2C; I2C_InitStruct.I2C_DutyCycle = I2C_DutyCycle_2; ...
DL_GPIO_initDigitalOutput(MPU6050_SDA_IOMUX); DL_GPIO_setPins(MPU6050_PORT, MPU6050_SDA_PIN); DL_GPIO_enableOutput(MPU6050_PORT, MPU6050_SDA_PIN); } //�ر�SDA���ţ����룩 void SDA_IN(void) { DL_GPIO_initDigitalInputFeatures(MPU6050_SDA_IOMUX, ...
(SDA_PORT , SDA_PIN , GPIO_Mode_In_PU_No_IT);//输入44}45//设置SDA为输出模式46voidSDA_OUT_Mode(){47GPIO_Init(SDA_PORT , SDA_PIN , GPIO_Mode_Out_PP_Low_Fast);//输出48}4950//IIC初始化51voidIIC_Init()52{53GPIO_Init(SCL_PORT , SCL_PIN , GPIO_Mode_Out_PP_Low_Fast);//...
//初始化 IICvoidIIC_Init(void){GPIO_InitTypeDef GPIO_InitStructure;RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOB,ENABLE);//使能 GPIOB 时钟//GPIOB8,B9 初始化设置GPIO_InitStructure.GPIO_Pin=GPIO_Pin_8|GPIO_Pin_9;GPIO_InitStructure.GPIO_Mode=GPIO_Mode_OUT;//普通输出模式GPIO_InitStructure.GPIO_...
void IIC_Init(void) { GPIO_InitTypeDef GPIO_InitStructure; RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE );//使能GPIOB时钟 GPIO_InitStructure.GPIO_Pin = GPIO_Pin_6|GPIO_Pin_7; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP ;//推挽输出 ...
void IIC_INIT(void){ /*** 初始化引脚 ***/ RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOB, ENABLE); GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitStructure.GPIO_Pin= GPIO_Pin_8 | GPIO_Pin_9; GPIO_InitStructure.GPIO_Mode= GPIO_Mode_AF; GPIO_InitStructure.GPIO_Speed= GPIO_Speed_50MHz...