- http://www.github.com/NimaLTD
- https://www.instagram.com/github.nimaltd/
- https://www.youtube.com/@nimaltd
solve F1 i2c problem
void HAL_I2C_MspInit(I2C_HandleTypeDef* i2cHandle)
{
GPIO_InitTypeDef GPIO_InitStruct = {0};
if(i2cHandle->Instance==I2C2)
{
/* USER CODE BEGIN I2C2_MspInit 0 */
__HAL_RCC_I2C2_CLK_ENABLE(); // <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< add manualy
/* USER CODE END I2C2_MspInit 0 */
__HAL_RCC_GPIOB_CLK_ENABLE();
/**I2C2 GPIO Configuration
PB10 ------> I2C2_SCL
PB11 ------> I2C2_SDA
*/
GPIO_InitStruct.Pin = GPIO_PIN_10|GPIO_PIN_11;
GPIO_InitStruct.Mode = GPIO_MODE_AF_OD;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
/* I2C2 clock enable */
__HAL_RCC_I2C2_CLK_ENABLE();
/* USER CODE BEGIN I2C2_MspInit 1 */
/* USER CODE END I2C2_MspInit 1 */
}
}
example:
#include "ee24.h"
uint8_t data[1024];
int main(void)
{
if (ee24_isConnected())
{
ee24_read(0, data, 1024, 1000);
}
while(1)
{
}
}