nimaltd / ee24

24xx EEPROM library for stm32 HAL
GNU General Public License v3.0
149 stars 41 forks source link
24c01 24c02 24c04 24c08 24c16 24c32 24c64 24cxx 24xx eeprom hal stm32 stm32f0 stm32f1 stm32f2 stm32f4

24xx EEPROM library for stm32 HAL


Please Do not Forget to get STAR, DONATE and support me on social networks. Thank you. :sparkling_heart:


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"

EE24_HandleTypeDef ee24; uint8_t data[1024]; int main(void) { ... ... ... if (EE24_Init(&ee24, &hi2c1, EE24_ADDRESS_DEFAULT)) { EE24_Read(&ee24, 0, data, 1024, 1000); } while(1) {

} }