Subversion Repositories EDIS_Ignition

Rev

Rev 9 | 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, modified for STM32F1 series using 2 pages of Flash rather than NVRAM
  5.  *      Author: Mike
  6.  *
  7.  * The design stores 8 bit data with an 8 bit tag value : this allows up to 253 different tags to be used (0x00 and 0xFF are reserved)
  8.  *
  9.  * In the application here, each element in a 10x10 ignition timing map is given its own tag, along with the rpm and vacuum axis values,
  10.  * and an overall timing correction tag.
  11.  *
  12.  */
  13.  
  14.  
  15. #pragma once
  16. #include "stdint.h"
  17.  
  18. #if defined __cplusplus
  19. extern "C"
  20. {
  21. #endif
  22. #pragma pack(push, 1)
  23.  
  24.     ///\brief State of item
  25.     /// this is expected to be packed into 16 bits
  26.     typedef union
  27.     {
  28.         struct
  29.         {
  30.             unsigned tag : 8;
  31.             int val : 8;
  32.         } data;
  33.         uint16_t u16;
  34.     } nvram_info_t;
  35. #pragma pack(pop)
  36.  
  37.  
  38.     // Save data according to its tag field
  39.     extern void write_nvram_data(nvram_info_t data);
  40.  
  41.     // find data according to the tag field or return null if no info
  42.     extern nvram_info_t *find_nvram_data(uint8_t tag);
  43.  
  44. #if defined __cplusplus
  45. }
  46. #endif
  47.