Feature request: odometer for engine break #3857
This commit is contained in:
parent
627923558c
commit
2ab8a3df4e
|
@ -17,6 +17,7 @@
|
|||
#include "mre_meta.h"
|
||||
#include "proteus_meta.h"
|
||||
#include "hellen_meta.h"
|
||||
#include "odometer.h"
|
||||
|
||||
#if EFI_ELECTRONIC_THROTTLE_BODY
|
||||
#include "electronic_throttle.h"
|
||||
|
@ -304,15 +305,12 @@ void setIssue898() {
|
|||
|
||||
#if HW_FRANKENSO && EFI_PROD_CODE
|
||||
|
||||
#define EE_PAGE_SIZE 32
|
||||
|
||||
// todo: page_size + 2
|
||||
// todo: CC_SECTION(".nocache")
|
||||
static uint8_t write_buf[EE_PAGE_SIZE + 10];
|
||||
|
||||
|
||||
#define EE_SIZE 4096
|
||||
#define EE_U2CD I2CD3
|
||||
#define EEPROM_WRITE_TIME_MS 10 /* time to write one page in ms. Consult datasheet! */
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,3 +1,24 @@
|
|||
#include "pch.h"
|
||||
|
||||
#include "odometer.h"
|
||||
|
||||
|
||||
static odometer_state odometerCopies[2];
|
||||
|
||||
void setCrc(odometer_state *state) {
|
||||
state->crc = crc32(state, 4);
|
||||
}
|
||||
|
||||
void validate(odometer_state *state) {
|
||||
int crc = crc32(state, 4);
|
||||
if (state->crc != crc)
|
||||
state->totalMeters = 0;
|
||||
|
||||
}
|
||||
|
||||
|
||||
void initOdometer() {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1 +1,19 @@
|
|||
#pragma once
|
||||
|
||||
|
||||
#ifndef EE_PAGE_SIZE
|
||||
#define EE_PAGE_SIZE 32
|
||||
#endif
|
||||
|
||||
#ifndef EE_SIZE
|
||||
#define EE_SIZE 4096
|
||||
#endif
|
||||
|
||||
#ifndef EE_U2CD
|
||||
#define EE_U2CD I2CD3
|
||||
#endif
|
||||
|
||||
struct odometer_state {
|
||||
int totalMeters;
|
||||
int crc;
|
||||
};
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include "sensor_chart.h"
|
||||
#include "serial_hw.h"
|
||||
#include "idle_thread.h"
|
||||
#include "odometer.h"
|
||||
|
||||
#if EFI_PROD_CODE
|
||||
#include "mpu_util.h"
|
||||
|
@ -503,7 +504,7 @@ void initHardware() {
|
|||
|
||||
#if STM32_I2C_USE_I2C3
|
||||
if (engineConfiguration->useEeprom) {
|
||||
i2cStart(&I2CD3, &i2cfg);
|
||||
i2cStart(&EE_U2CD, &i2cfg);
|
||||
}
|
||||
#endif // STM32_I2C_USE_I2C3
|
||||
|
||||
|
|
Loading…
Reference in New Issue