From cd1ea0a6552e957c8f2207fe88631d9d742bbec6 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 9 Jul 2019 13:38:58 +0200 Subject: [PATCH 1/2] Move function declaration and structs declarations to top of eeprom.h file. --- Firmware/eeprom.h | 47 +++++++++++++++++++++++++---------------------- 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index f4e20e5d..16bb6729 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -3,7 +3,32 @@ #include +#ifdef __cplusplus void eeprom_init(); +extern bool is_sheet_initialized(); +#endif + + +typedef struct +{ + char name[7]; //!< Can be null terminated, doesn't need to be null terminated + int16_t z_offset; //!< Z_BABYSTEP_MIN .. Z_BABYSTEP_MAX = Z_BABYSTEP_MIN*2/1000 [mm] .. Z_BABYSTEP_MAX*2/1000 [mm] + uint8_t bed_temp; //!< 0 .. 254 [°C] + uint8_t pinda_temp; //!< 0 .. 254 [°C] +} Sheet; + +typedef struct +{ + Sheet s[3]; + uint8_t active_sheet; +} Sheets; +// sizeof(Sheets). Do not change it unless EEPROM_Sheets_base is last item in EEPROM. +// Otherwise it would move following items. +#define EEPROM_SHEETS_SIZEOF 34 + +#ifdef __cplusplus +static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEPROM_SHEETS_SIZEOF."); +#endif // The total size of the EEPROM is // 4096 for the Atmega2560 @@ -171,30 +196,8 @@ void eeprom_init(); #define EEPROM_NOZZLE_DIAMETER (EEPROM_CHECK_MODE-1) // uint8 #define EEPROM_NOZZLE_DIAMETER_uM (EEPROM_NOZZLE_DIAMETER-2) // uint16 -typedef struct -{ - char name[7]; //!< Can be null terminated, doesn't need to be null terminated - int16_t z_offset; //!< Z_BABYSTEP_MIN .. Z_BABYSTEP_MAX = Z_BABYSTEP_MIN*2/1000 [mm] .. Z_BABYSTEP_MAX*2/1000 [mm] - uint8_t bed_temp; //!< 0 .. 254 [°C] - uint8_t pinda_temp; //!< 0 .. 254 [°C] -} Sheet; - -typedef struct -{ - Sheet s[3]; - uint8_t active_sheet; -} Sheets; -// sizeof(Sheets). Do not change it unless EEPROM_Sheets_base is last item in EEPROM. -// Otherwise it would move following items. -#define EEPROM_SHEETS_SIZEOF 34 - static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_NOZZLE_DIAMETER - EEPROM_SHEETS_SIZEOF); -#ifdef __cplusplus -extern bool is_sheet_initialized(); -static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEPROM_SHEETS_SIZEOF."); -#endif - //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. #define EEPROM_LAST_ITEM ((uint16_t)EEPROM_Sheets_base) From 898f6d9d8b6565e65723aa4bba77e838ee1462f8 Mon Sep 17 00:00:00 2001 From: Marek Bel Date: Tue, 9 Jul 2019 13:41:18 +0200 Subject: [PATCH 2/2] Fix EEPROM_Sheets_base overlay of EEPROM_NOZZLE_DIAMETER_uM. --- Firmware/eeprom.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Firmware/eeprom.h b/Firmware/eeprom.h index 16bb6729..7cc07fb2 100644 --- a/Firmware/eeprom.h +++ b/Firmware/eeprom.h @@ -196,7 +196,7 @@ static_assert(sizeof(Sheets) == EEPROM_SHEETS_SIZEOF, "Sizeof(Sheets) is not EEP #define EEPROM_NOZZLE_DIAMETER (EEPROM_CHECK_MODE-1) // uint8 #define EEPROM_NOZZLE_DIAMETER_uM (EEPROM_NOZZLE_DIAMETER-2) // uint16 -static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_NOZZLE_DIAMETER - EEPROM_SHEETS_SIZEOF); +static Sheets * const EEPROM_Sheets_base = (Sheets*)(EEPROM_NOZZLE_DIAMETER_uM - EEPROM_SHEETS_SIZEOF); //This is supposed to point to last item to allow EEPROM overrun check. Please update when adding new items. #define EEPROM_LAST_ITEM ((uint16_t)EEPROM_Sheets_base)