/*
 *  PWM_control.h
 *
 *  Created on: 10.07.2024
 *      Author: Hamza
 */

#ifndef INC_EEPROM_H_
#define INC_EEPROM_H_

#include <stm32f3xx_hal.h>
#include "ADBMS_LL_Driver.h"
#include "soc_estimation.h"
#include <state_machine.h>
#include "stm32f3xx_hal_def.h"
#include "stm32f3xx_hal_i2c.h"
#include "TMP1075.h"

// see Datasheet for these values
#define EEPROM_I2C_ADDR             0xA4    // 0xA4 for the the first 2⁸ addresses and 0xA6 for the the last 2⁸ addresses
#define EERROM_MEMORY_ADDR_SIZE     2       // it is controlled by A17 in the address Byte, see datasheet
#define EEPROM_MEMORY_SIZE          131072  // in bytes
#define EEPROM_PAGE_SIZE            32      // in bytes

extern uint32_t write_address, read_address;

void eeprom_init(I2C_HandleTypeDef* hi2c);
void eeprom_write_status();

HAL_StatusTypeDef eeprom_read(uint8_t* data, uint16_t data_length);
HAL_StatusTypeDef eeprom_write(uint8_t* data, uint16_t data_length);

#endif // INC_EEPROM_H_