V1.7
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
#include "eeprom.h"
|
||||
#include "errors.h"
|
||||
#include "stm32f3xx_hal.h"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
|
||||
#define EEPROM_I2C_ADDR 0xA0
|
||||
@ -10,11 +10,13 @@
|
||||
#define EEPROM_CONFIG_ECC_OFFSET 0x20
|
||||
|
||||
EEPROMConfig eeprom_config;
|
||||
uint32_t current_address;
|
||||
|
||||
static I2C_HandleTypeDef* hi2c;
|
||||
|
||||
void eeprom_init(I2C_HandleTypeDef* handle) {
|
||||
hi2c = handle;
|
||||
current_address = 0;
|
||||
uint8_t buf[sizeof(EEPROMConfig) * 3];
|
||||
// Read 3 EEPROM config buffers at 32 byte offsets
|
||||
for (size_t ecc_i = 0; ecc_i < 3; ecc_i++) {
|
||||
@ -58,3 +60,23 @@ void eeprom_config_save() {
|
||||
HAL_Delay(100);
|
||||
}
|
||||
}
|
||||
|
||||
void eeprom_write_status(){
|
||||
uint8_t data_length = 16;
|
||||
uint8_t data[data_length] = {};
|
||||
|
||||
|
||||
eeprom_write(data, data_length);
|
||||
}
|
||||
|
||||
void eeprom_read(int8_t* data){}
|
||||
|
||||
void eeprom_write(uint8_t* data, uint8_t data_length){
|
||||
HAL_StatusTypeDef status = HAL_I2C_Mem_Write(
|
||||
hi2c, EEPROM_I2C_ADDR,
|
||||
current_address, 2,
|
||||
(uint8_t*)&eeprom_config, sizeof(eeprom_config), 100);
|
||||
if (status != HAL_OK) {
|
||||
set_error_source(ERROR_SOURCE_EEPROM);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user