Rev 9 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
9 | mjames | 1 | /* |
2 | * nvram.h |
||
3 | * |
||
10 | mjames | 4 | * Created on: 4 Jun 2017, modified for STM32F1 series using 2 pages of Flash rather than NVRAM |
9 | mjames | 5 | * Author: Mike |
10 | mjames | 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 | * |
||
9 | mjames | 12 | */ |
13 | |||
10 | mjames | 14 | |
9 | mjames | 15 | #pragma once |
10 | mjames | 16 | #include "stdint.h" |
9 | mjames | 17 | |
18 | #if defined __cplusplus |
||
19 | extern "C" |
||
20 | { |
||
21 | #endif |
||
22 | #pragma pack(push, 1) |
||
23 | |||
24 | ///\brief State of item |
||
10 | mjames | 25 | /// this is expected to be packed into 16 bits |
9 | mjames | 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 |