rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
backup_ram.h
Go to the documentation of this file.
1/**
2 * @file backup_ram.h
3 * @brief Non-volatile backup-RAM registers support
4 *
5 * @date Dec 19, 2017
6 */
7
8#pragma once
9
10#include "efi_gpio.h"
11
12#include "error_handling.h"
13
14enum class backup_ram_e {
15 /**
16 * IAC Stepper motor position, 16-bit (stored in BKP0R 0..15)
17 * Used in stepper.cpp
18 */
20 /**
21 * Ignition switch counter, 8-bit (stored in BKP0R 16..23)
22 * The counter stores the number of times the ignition switch is turned on. Used for prime injection pulse.
23 * We need a protection against 'fake' ignition switch on and off (i.e. no engine started), to avoid repeated prime pulses.
24 * So we check and update the ignition switch counter in non-volatile backup-RAM.
25 * See startPrimeInjectionPulse() in controllers/trigger/main_trigger_callback.cpp
26 */
28
29 /* The number of stored backup variables */
31};
32
33#define LAST_BACKUP_RAM_ENUM backup_ram_e::BACKUP_RAM_NUM
34
35
36// load data from backup-power RTC registers (non-volatile memory)
37uint32_t backupRamLoad(backup_ram_e idx);
38// use backup-power RTC registers (non-volatile memory) to store the data
39void backupRamSave(backup_ram_e idx, uint32_t value);
40// make sure that all changes are saved before we shutdown the MCU
41void backupRamFlush(void);
42
43#if EFI_PROD_CODE
50
52#endif // EFI_PROD_CODE
BackupSramData * getBackupSram()
backup_ram_e
Definition backup_ram.h:14
uint32_t backupRamLoad(backup_ram_e idx)
void backupRamSave(backup_ram_e idx, uint32_t value)
void backupRamFlush(void)
EFI-related GPIO code.
uint32_t BootCountCookie
Definition backup_ram.h:46
uint32_t BootCount
Definition backup_ram.h:45
backupErrorState err
Definition backup_ram.h:48