Skip to content

Commit

Permalink
change eeprom to a struct
Browse files Browse the repository at this point in the history
  • Loading branch information
freasy committed Mar 28, 2024
1 parent e9fc66b commit 973ba57
Show file tree
Hide file tree
Showing 5 changed files with 162 additions and 117 deletions.
4 changes: 3 additions & 1 deletion Inc/common.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#include "eeprom.h"

#pragma once

extern uint8_t eepromBuffer[176];
extern EEprom_t eepromBuffer;
extern uint16_t TIMER1_MAX_ARR;
extern uint16_t dshot_frametime_high;
extern uint16_t dshot_frametime_low;
Expand Down
52 changes: 52 additions & 0 deletions Mcu/f421/Inc/eeprom.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,57 @@
#include "main.h"

#pragma once

typedef union EEprom_u {
struct {
uint8_t reserved_0; //0
uint8_t eeprom_version; //1
uint8_t reserved_1; //2
struct {
uint8_t major; //3
uint8_t minor; //4
} version;
char firmware_name[12]; //5-16
uint8_t dir_reversed; // 17
uint8_t bi_direction; // 18
uint8_t use_sine_start; // 19
uint8_t comp_pwm; // 20
uint8_t variable_pwm; // 21
uint8_t stuck_rotor_protection; // 22
uint8_t advance_level; // 23
uint8_t pwm_frequency; // 24
uint8_t startup_power; // 25
uint8_t motor_kv; // 26
uint8_t motor_poles; // 27
uint8_t brake_on_stop; // 28
uint8_t stall_protection; // 29
uint8_t beep_volume; // 30
uint8_t telementry_on_interval; // 31
struct {
uint8_t low_threshold; // 32
uint8_t high_threshold; // 33
uint8_t neutral; // 34
uint8_t dead_band; // 35
} servo;
uint8_t low_voltage_cut_off; // 36
uint8_t low_cell_volt_cutoff; // 37
uint8_t rc_car_reverse; // 38
uint8_t use_hall_sensors; // 39
uint8_t sine_mode_changeover_thottle_level; // 40
uint8_t drag_brake_strength; // 41
uint8_t driving_brake_strength; // 42
struct {
uint8_t temperature; // 43
uint8_t current; // 44
} limits;
uint8_t sine_mode_power; // 45
uint8_t input_type; // 46
uint8_t reserved_2[5]; //47-51
uint8_t tune[124];
};
uint8_t buffer[176];
} EEprom_t;

// void save_to_flash(uint8_t *data);
// void read_flash(uint8_t* data, uint32_t address);
// void save_to_flash_bin(uint8_t *data, int length, uint32_t add);
Expand Down
Loading

0 comments on commit 973ba57

Please sign in to comment.