Prusa MINI Firmware overview
new_eeprom.h
Go to the documentation of this file.
1 /*
2  * Marlin_I2cEeprom.h
3  *
4  * Created on: 7. 8. 2019
5  * Author: mcbig
6  */
7 
8 #ifndef NEW_EEPROM_H_
9 #define NEW_EEPROM_H_
10 
11 #include <stdint.h>
12 
13 //Filament
14 #define FILAMENT_ADDRESS 0x400
15 #define FILAMENT_COLOR_R 0x401
16 #define FILAMENT_COLOR_G 0x402
17 #define FILAMENT_COLOR_B 0x403
18 
19 //firmware update flag
20 #define FW_UPDATE_FLAG_ADDRESS 0x40B
21 
22 #define MENU_TIMEOUT_FLAG_ADDRESS 0x40C // is it ok?
23 
24 //====================EEPROM_REWORK======================
25 
26 #define EEPROM_START_ADDR 0x400
27 #define EEPROM_VER 0x01 //increment if you add any variable
28 #define EEPROM_VER_OFFSET 2323 //is added to EEPROM_VER for security
29 //#define EEPROM_MEMORY_RESERVED 0
30 
31 typedef struct {
32 
33  uint16_t eeprom_version;
34  uint32_t check_sum;
37  uint8_t filament_g; //If you added a variable/s to the EEPROM make sure you increment EEPROM_VER macro
38  uint8_t filament_b; //and add it/them to eeprom_initialize() and eeprom_factory_reset() accordingly
39 } EEPROM_t;
40 
41 //extern EEPROM_t * const EEPROM;
42 
43 #ifdef __cplusplus //Not included in sys.c (should be .cpp)
44 
45 void eeprom_initialize(EEPROM_t *ptr); //set default values, makes eeprom compatible with it's older versions
46 extern void eeprom_factory_reset(EEPROM_t *ptr); //set all eerpom variables to default
47 int8_t eeprom_check_sum(EEPROM_t *ptr); //checks if data is not corrupted (optimalization at compilation will probably cause eeprom factory reset)
48 
49 template <typename _T>
50 void eeprom_get(const _T &eeprom_source, _T &destination) {
52  const uint8_t *source_addr = reinterpret_cast<const uint8_t *>(&eeprom_source);
53  uint8_t *ptr = reinterpret_cast<uint8_t *>(&destination);
54  for (int count = sizeof(_T); count; --count, ++source_addr)
55  *ptr++ = *source_addr;
56 }
57 
58 template <typename _U>
59 void eeprom_put(_U &eeprom_destination, const _U &source) {
61  if (eeprom_destination != source) {
62  uint8_t *dest_addr = reinterpret_cast<uint8_t *>(&eeprom_destination);
63  const uint8_t *ptr = reinterpret_cast<const uint8_t *>(&source);
64  for (int count = sizeof(_U); count; --count, ++dest_addr)
65  *dest_addr = *ptr++;
67  }
68 }
69 #endif //__cplusplus
70 //====================================================
71 
72 #endif /* NEW_EEPROM_H_ */
eeprom_check_sum
int8_t eeprom_check_sum(EEPROM_t *ptr)
Definition: new_eeprom.cpp:59
menu_pll_on
void menu_pll_on()
Definition: menu_service.cpp:22
EEPROM_t::filament_type
uint8_t filament_type
Definition: new_eeprom.h:35
sscg_freq_kHz
int16_t sscg_freq_kHz
Definition: menu_service.cpp:11
sys_spi_set_prescaler
void sys_spi_set_prescaler(int prescaler_num)
Definition: sys.cpp:230
sys_reset
void sys_reset(void)
Definition: sys.cpp:20
EEPROM_t::check_sum
uint32_t check_sum
Definition: new_eeprom.h:34
sys.h
EEPROM_t::eeprom_version
uint16_t eeprom_version
Definition: new_eeprom.h:33
EEPROM_t::filament_b
uint8_t filament_b
Definition: new_eeprom.h:38
_menu_endless_loop
void _menu_endless_loop()
Definition: menu_service.cpp:48
destination
xyze_pos_t destination
Definition: motion.cpp:110
menu_go_dfu
void menu_go_dfu()
Definition: menu_service.cpp:67
FW_BUILDSX
#define FW_BUILDSX
Definition: config.h:12
sys_pll_is_enabled
int sys_pll_is_enabled(void)
Definition: sys.cpp:48
osDelay
osStatus osDelay(uint32_t millisec)
Wait for Timeout (Time Delay)
Definition: cmsis_os.c:365
new_eeprom.h
sys_dfu_boot
void sys_dfu_boot(void)
Definition: sys.cpp:31
sys_sscg_enable
void sys_sscg_enable(void)
Definition: sys.cpp:140
HAL_IWDG_Refresh
HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg)
sys_pll_enable
void sys_pll_enable(void)
Definition: sys.cpp:78
version_build_nr
const int version_build_nr
build number
Definition: version.c:44
EEPROM_t
Definition: new_eeprom.h:31
menu_spi_test1
void menu_spi_test1()
Definition: menu_service.cpp:57
guimain_spi_test
int guimain_spi_test
Definition: guimain.c:74
EEPROM_START_ADDR
#define EEPROM_START_ADDR
Definition: new_eeprom.h:26
menu_sscg_off
void menu_sscg_off()
Definition: menu_service.cpp:38
EEPROM_t::filament_r
uint8_t filament_r
Definition: new_eeprom.h:36
EEPROM_VER_OFFSET
#define EEPROM_VER_OFFSET
Definition: new_eeprom.h:28
spi_prescaler
int16_t spi_prescaler
Definition: menu_service.cpp:13
eeprom_initialize
void eeprom_initialize(EEPROM_t *ptr)
Definition: new_eeprom.cpp:11
eeprom_factory_reset
void eeprom_factory_reset(EEPROM_t *ptr)
Definition: new_eeprom.cpp:48
menu_system_reset
void menu_system_reset()
Definition: menu_service.cpp:18
menu_set_spi_prescaler
void menu_set_spi_prescaler()
Definition: menu_service.cpp:43
menu_support
void menu_support()
Definition: menu_support.cpp:8
sys_sscg_set_config
void sys_sscg_set_config(int freq, int depth)
Definition: sys.cpp:159
uint8_t
const uint8_t[]
Definition: 404_html.c:3
sys_sscg_disable
void sys_sscg_disable(void)
Definition: sys.cpp:125
ui
MarlinUI ui
sys_pll_disable
void sys_pll_disable(void)
Definition: sys.cpp:57
sscg_depth
int16_t sscg_depth
Definition: menu_service.cpp:12
_T
#define _T(x)
Definition: ff.h:63
menu_service
void menu_service()
Definition: menu_service.cpp:71
EEPROM_t::filament_g
uint8_t filament_g
Definition: new_eeprom.h:37
menu_pll_off
void menu_pll_off()
Definition: menu_service.cpp:27
hiwdg
IWDG_HandleTypeDef hiwdg
Definition: watchdog.h:24
EEPROM_VER
#define EEPROM_VER
Definition: new_eeprom.h:27
menu_sscg_on
void menu_sscg_on()
Definition: menu_service.cpp:32
sys_sscg_is_enabled
int sys_sscg_is_enabled(void)
Definition: sys.cpp:121
cmsis_os.h
Header of cmsis_os.c A new set of APIs are added in addition to existing ones, these APIs are specifi...
menu_spi_test2
void menu_spi_test2()
Definition: menu_service.cpp:62