RCC_APB2PeriphClockCmd, GPIO_InitStructure.GPIO_Pin, GPIO_InitStructure.GPIO_Mode etc. what is it used for?
Hi. I'm trying to translate the SHT30 library for stm32l0. But I could not understand and translate the "IIC_Init" part of the code. I didn't understand the init part, I couldn't translate it and it only gives a line there What do you think are the operations it does in this function? I think it doesn't work with i2c because there are parts called SDA_IN() and SDA_OUT(). It sets it as GPIO input and GPIO output. Can you explain what it does in the init part? source code-> https://github.com/thejbte/Example_OS_QuartKTS__STM32
void IIC_Init(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
RCC_APB2PeriphClockCmd( RCC_APB2Periph_GPIOB, ENABLE );
GPIO_InitStructure.GPIO_Pin = IIC_SDA_Pin|IIC_SCL_Pin;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP ; //�������
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOC, &GPIO_InitStructure);
GPIO_SetBits(GPIOB,IIC_SDA_Pin|IIC_SCL_Pin); //PB6,PB7�����
}
void SDA_IN()
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/*Configure GPIO pin : IIC_SDA_Pin */
GPIO_InitStruct.Pin = IIC_SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(IIC_SDA_GPIO_Port, &GPIO_InitStruct);
}
void SDA_OUT()
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
/* GPIO Ports Clock Enable */
__HAL_RCC_GPIOC_CLK_ENABLE();
__HAL_RCC_GPIOH_CLK_ENABLE();
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOA_CLK_ENABLE();
/*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(IIC_SDA_GPIO_Port, IIC_SDA_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin : IIC_SDA_Pin */
GPIO_InitStruct.Pin = IIC_SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(IIC_SDA_GPIO_Port, &GPIO_InitStruct);
}
