Rev 10 | 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 |
||
| 23 | mjames | 22 | |
| 9 | mjames | 23 | #pragma pack(push, 1) |
| 24 | |||
| 25 | ///\brief State of item |
||
| 10 | mjames | 26 | /// this is expected to be packed into 16 bits |
| 9 | mjames | 27 | typedef union |
| 28 | { |
||
| 29 | struct |
||
| 30 | { |
||
| 31 | unsigned tag : 8; |
||
| 23 | mjames | 32 | unsigned filler; |
| 33 | int val : 16; |
||
| 9 | mjames | 34 | } data; |
| 23 | mjames | 35 | uint32_t word; |
| 9 | mjames | 36 | } nvram_info_t; |
| 37 | #pragma pack(pop) |
||
| 23 | mjames | 38 | typedef nvram_info_t CF_DATA; |
| 9 | mjames | 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 |