Subversion Repositories EDIS_Ignition

Rev

Rev 10 | 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.  
  23. #pragma pack(push, 1)
  24.  
  25.     ///\brief State of item
  26.     /// this is expected to be packed into 16 bits
  27.     typedef union
  28.     {
  29.         struct
  30.         {
  31.             unsigned tag : 8;
  32.             unsigned filler;
  33.             int val : 16;
  34.         } data;
  35.         uint32_t word;
  36.     } nvram_info_t;
  37. #pragma pack(pop)
  38.     typedef nvram_info_t CF_DATA;
  39.  
  40.     // Save data according to its tag field
  41.     extern void write_nvram_data(nvram_info_t data);
  42.  
  43.     // find data according to the tag field or return null if no info
  44.     extern nvram_info_t *find_nvram_data(uint8_t tag);
  45.  
  46. #if defined __cplusplus
  47. }
  48. #endif
  49.