eeprom.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. /*
  2. * Copyright Jordy Sipkema, 2016.
  3. *
  4. * Project : 20152016-TI2.3a6-Internet Radio
  5. * Module : Eeprom
  6. * File name : Eeprom.h
  7. * Revision : 2.0
  8. * Creation Date : 2016/03/04
  9. *
  10. * Description : This module stores the non-volatile settings
  11. * for the radio in the atmega128's internal eeprom
  12. */
  13. #ifndef MUTLI_OS_BUILD_EEPROM_H
  14. #define MUTLI_OS_BUILD_EEPROM_H
  15. #include <stdio.h>
  16. #include <string.h>
  17. #include <time.h>
  18. #include "typedefs.h"
  19. #define EEPROM_BASE 0x0100 //The address where we'll start writing values.
  20. #define SETTINGS_POINTER ((TSettings *)EEPROM_USER_BASE)
  21. /*!\brief System settings */
  22. typedef struct _TSettingsSystem
  23. {
  24. u_long lSerialnumber; // size = 4
  25. } TSettingsSystem; // totalsize = 4
  26. /*!\brief System Cache */
  27. typedef struct _TCache
  28. {
  29. tm last_sync; // TODO: figure out the size
  30. } TCache;
  31. typedef struct _TAlarm // Max 5
  32. {
  33. tm alarm_time;
  34. char name[16];
  35. char snooze_time; // size = ?, desc: snooze_time in minutes.
  36. } TAlarm;
  37. /*!\brief Settings to write on Eeprom */
  38. typedef struct _TSettings
  39. {
  40. size_t Checksum; // Checksum for validation TSettings-struct
  41. TSettingsSystem System; // System settings
  42. TAlarm Alarm_general; // Alarms settings
  43. TCache Cache; // Cache
  44. } TSettings;
  45. extern void EepromRead(int, void*, size_t);
  46. extern void EepromWrite(int, void*, size_t);
  47. extern bool EepromGetAll(TSettings*);
  48. extern void EepromSetAll(TSettings *settings);
  49. extern bool EepromGetSystemSettings(TSettingsSystem*);
  50. extern bool EepromGetCache(TCache*);
  51. extern void EepromSetCache(TCache*);
  52. #endif //MUTLI_OS_BUILD_EEPROM_H