You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

40 lines
1.0 KiB

  1. #ifndef _eeprom_h__
  2. #define _eeprom_h__
  3. #include <stdint.h>
  4. #define EEPROM_MAGIC 0xfeed
  5. #define EEPROM_BASE_PTR ((void*)0x0000)
  6. #define EEPROM_USED_SIZE (sizeof(struct eeprom_data_struct))
  7. #define EEPROM_USED_SIZE_NOCRC (EEPROM_USED_SIZE-2)
  8. #include "config.h" // config.h to struct eeprom_cfg
  9. struct eeprom_data_struct {
  10. uint16_t magic;
  11. struct eeprom_cfg cfg;
  12. uint16_t crc16;
  13. };
  14. extern struct eeprom_data_struct g_eeprom_data;
  15. /* Application specific function to implement. When
  16. * called, write application defaults to g_eeprom_data.
  17. *
  18. * Only called when eeprom is new or corrupted. */
  19. extern void eeprom_app_write_defaults(void);
  20. /* Application specific function to implement. Called
  21. * after the eeprom content has been loaded or initialized.
  22. * A good place to copy values elsewhere or otherwise
  23. * act on configuration content. */
  24. extern void eeprom_app_ready(void);
  25. /* Load, Validate and init eeprom if needed. */
  26. void eeprom_init(void);
  27. /* Commit changes made to g_eeprom_data */
  28. void eeprom_commit(void);
  29. #endif // _eeprom_h__