CJ125: prepare backup (#543)

This commit is contained in:
andreika-git 2018-01-23 00:47:10 +02:00 committed by rusefi
parent ba44ffcc6a
commit 4765c0a861
2 changed files with 18 additions and 0 deletions

View File

@ -12,6 +12,10 @@ uint32_t backupRamLoad(backup_ram_e idx) {
return RTCD1.rtc->BKP0R & 0xffff; return RTCD1.rtc->BKP0R & 0xffff;
case BACKUP_IGNITION_SWITCH_COUNTER: case BACKUP_IGNITION_SWITCH_COUNTER:
return (RTCD1.rtc->BKP0R >> 16) & 0xff; 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: default:
//scheduleMsg(logger, "Invalid backup ram idx %d", idx); //scheduleMsg(logger, "Invalid backup ram idx %d", idx);
return 0; return 0;
@ -26,6 +30,12 @@ void backupRamSave(backup_ram_e idx, uint32_t value) {
case BACKUP_IGNITION_SWITCH_COUNTER: case BACKUP_IGNITION_SWITCH_COUNTER:
RTCD1.rtc->BKP0R = (RTCD1.rtc->BKP0R & ~0x00ff0000) | ((value & 0xff) << 16); RTCD1.rtc->BKP0R = (RTCD1.rtc->BKP0R & ~0x00ff0000) | ((value & 0xff) << 16);
break; 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: default:
//scheduleMsg(logger, "Invalid backup ram idx %d, value 0x08x", idx, value); //scheduleMsg(logger, "Invalid backup ram idx %d, value 0x08x", idx, value);
break; break;

View File

@ -25,6 +25,14 @@ typedef enum {
* See startPrimeInjectionPulse() in controllers/trigger/main_trigger_callback.cpp * See startPrimeInjectionPulse() in controllers/trigger/main_trigger_callback.cpp
*/ */
BACKUP_IGNITION_SWITCH_COUNTER, BACKUP_IGNITION_SWITCH_COUNTER,
/**
* CJ125 Calibration data (16bit)
*/
BACKUP_CJ125_CALIBRATION_LAMBDA,
/**
* CJ125 Calibration data (16bit)
*/
BACKUP_CJ125_CALIBRATION_HEATER,
} backup_ram_e; } backup_ram_e;