Subversion Repositories DashDisplay

Rev

Rev 70 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /*
  2.  * nvram.h
  3.  *
  4.  *  Created on: 4 Jun 2017
  5.  *      Author: Mike
  6.  */
  7. #include "libPLX/plx.h"
  8.  
  9. #pragma once
  10.  
  11.  
  12. #if defined __cplusplus
  13. extern "C"
  14. {
  15. #endif
  16. #pragma pack(push, 1)
  17.  
  18.     ///\brief State of currently displayed item
  19.     /// this is expected to be packed into 32 bits
  20.     typedef union
  21.     {
  22.         struct
  23.         {
  24.             unsigned tag : 8; // dial tag
  25.             unsigned : 16;  // filler
  26.             int pos:  8;   // dial position code
  27.         } data;
  28.         uint32_t u32;
  29.     } nvram_info_t;
  30. #pragma pack(pop)
  31.  
  32. // Allocation of NVRAM words : there are 4k bytes
  33. #define NVRAM_WORDS (4096 / sizeof(nvram_info_t))
  34.  
  35.     /// @brief Erase every NVRAM entry
  36.     extern void erase_nvram();
  37.    
  38.     /// @brief Save data, replacing any with a matching tag field.
  39.     /// @param data data item to write
  40.     extern void write_nvram_data(nvram_info_t data);
  41.  
  42.     //
  43.     /// @brief Find data according to the tag field/
  44.     /// @param tag tag code to find
  45.     /// @return a pointer to the nvram data with matching tag or NULL if not found
  46.     extern nvram_info_t *find_nvram_data(uint8_t tag);
  47.  
  48. #if defined __cplusplus
  49. }
  50. #endif
  51.