rusEFI
The most advanced open source ECU
Loading...
Searching...
No Matches
hw_layer
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
14
enum class
backup_ram_e
{
15
/**
16
* IAC Stepper motor position, 16-bit (stored in BKP0R 0..15)
17
* Used in stepper.cpp
18
*/
19
StepperPosition
,
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
*/
27
IgnCounter
,
28
29
/* The number of stored backup variables */
30
BACKUP_RAM_NUM
,
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)
37
uint32_t
backupRamLoad
(
backup_ram_e
idx);
38
// use backup-power RTC registers (non-volatile memory) to store the data
39
void
backupRamSave
(
backup_ram_e
idx, uint32_t value);
40
// make sure that all changes are saved before we shutdown the MCU
41
void
backupRamFlush
(
void
);
42
43
#if EFI_PROD_CODE
44
struct
BackupSramData
{
45
uint32_t
BootCount
;
46
uint32_t
BootCountCookie
;
47
48
backupErrorState
err
;
49
};
50
51
BackupSramData
*
getBackupSram
();
52
#endif
// EFI_PROD_CODE
getBackupSram
BackupSramData * getBackupSram()
Definition
backup_ram.cpp:52
backup_ram_e
backup_ram_e
Definition
backup_ram.h:14
backup_ram_e::StepperPosition
@ StepperPosition
backup_ram_e::IgnCounter
@ IgnCounter
backup_ram_e::BACKUP_RAM_NUM
@ BACKUP_RAM_NUM
backupRamLoad
uint32_t backupRamLoad(backup_ram_e idx)
Definition
backup_ram.cpp:43
backupRamSave
void backupRamSave(backup_ram_e idx, uint32_t value)
Definition
backup_ram.cpp:52
backupRamFlush
void backupRamFlush(void)
Definition
backup_ram.cpp:61
efi_gpio.h
EFI-related GPIO code.
error_handling.h
BackupSramData
Definition
backup_ram.h:44
BackupSramData::BootCountCookie
uint32_t BootCountCookie
Definition
backup_ram.h:46
BackupSramData::BootCount
uint32_t BootCount
Definition
backup_ram.h:45
BackupSramData::err
backupErrorState err
Definition
backup_ram.h:48
backupErrorState
Definition
error_handling.h:101
Generated on Sat Sep 27 2025 00:10:06 for rusEFI by
1.9.8