From 4765c0a8612a9170a66c9651b14813da3f320b1f Mon Sep 17 00:00:00 2001 From: andreika-git Date: Tue, 23 Jan 2018 00:47:10 +0200 Subject: [PATCH] CJ125: prepare backup (#543) --- firmware/hw_layer/backup_ram.cpp | 10 ++++++++++ firmware/hw_layer/backup_ram.h | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/firmware/hw_layer/backup_ram.cpp b/firmware/hw_layer/backup_ram.cpp index ea98e5c91d..434da3e832 100644 --- a/firmware/hw_layer/backup_ram.cpp +++ b/firmware/hw_layer/backup_ram.cpp @@ -12,6 +12,10 @@ uint32_t backupRamLoad(backup_ram_e idx) { return RTCD1.rtc->BKP0R & 0xffff; case BACKUP_IGNITION_SWITCH_COUNTER: return (RTCD1.rtc->BKP0R >> 16) & 0xff; + case BACKUP_CJ125_CALIBRATION_LAMBDA: + return RTCD1.rtc->BKP1R & 0xffff; + case BACKUP_CJ125_CALIBRATION_HEATER: + return (RTCD1.rtc->BKP1R >> 16) & 0xffff; default: //scheduleMsg(logger, "Invalid backup ram idx %d", idx); return 0; @@ -26,6 +30,12 @@ void backupRamSave(backup_ram_e idx, uint32_t value) { case BACKUP_IGNITION_SWITCH_COUNTER: RTCD1.rtc->BKP0R = (RTCD1.rtc->BKP0R & ~0x00ff0000) | ((value & 0xff) << 16); break; + case BACKUP_CJ125_CALIBRATION_LAMBDA: + RTCD1.rtc->BKP1R = (RTCD1.rtc->BKP1R & ~0x0000ffff) | (value & 0xffff); + break; + case BACKUP_CJ125_CALIBRATION_HEATER: + RTCD1.rtc->BKP1R = (RTCD1.rtc->BKP1R & ~0xffff0000) | ((value & 0xffff) << 16); + break; default: //scheduleMsg(logger, "Invalid backup ram idx %d, value 0x08x", idx, value); break; diff --git a/firmware/hw_layer/backup_ram.h b/firmware/hw_layer/backup_ram.h index 1ce331d1e8..de37d6b13b 100644 --- a/firmware/hw_layer/backup_ram.h +++ b/firmware/hw_layer/backup_ram.h @@ -25,6 +25,14 @@ typedef enum { * See startPrimeInjectionPulse() in controllers/trigger/main_trigger_callback.cpp */ BACKUP_IGNITION_SWITCH_COUNTER, + /** + * CJ125 Calibration data (16bit) + */ + BACKUP_CJ125_CALIBRATION_LAMBDA, + /** + * CJ125 Calibration data (16bit) + */ + BACKUP_CJ125_CALIBRATION_HEATER, } backup_ram_e;