2020-09-19 21:39:29 -07:00
|
|
|
#pragma once
|
|
|
|
|
2021-02-25 22:57:44 -08:00
|
|
|
#include "hal.h"
|
2021-12-27 20:39:02 -08:00
|
|
|
#include "port_shared.h"
|
2022-06-24 14:51:22 -07:00
|
|
|
#include "wideband_config.h"
|
2021-02-25 22:57:44 -08:00
|
|
|
|
2020-09-19 21:39:29 -07:00
|
|
|
struct AnalogResult
|
|
|
|
{
|
2022-06-24 14:51:22 -07:00
|
|
|
struct {
|
|
|
|
float NernstVoltage;
|
|
|
|
float PumpCurrentVoltage;
|
|
|
|
/* for dual version - this is voltage on Heater-, switches between zero and Vbatt with heater PWM,
|
|
|
|
* used for both Vbatt measurement and Heater diagnostic */
|
|
|
|
float BatteryVoltage;
|
|
|
|
} ch[AFR_CHANNELS];
|
2020-12-11 00:25:50 -08:00
|
|
|
float VirtualGroundVoltageInt;
|
2020-09-19 21:39:29 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
AnalogResult AnalogSample();
|
2021-02-25 22:57:44 -08:00
|
|
|
|
2021-03-14 00:22:58 -08:00
|
|
|
class Configuration {
|
|
|
|
private:
|
|
|
|
// Increment this any time the configuration format changes
|
|
|
|
// It is stored along with the data to ensure that it has been written before
|
|
|
|
static constexpr uint32_t ExpectedTag = 0xDEADBE01;
|
|
|
|
uint32_t Tag = ExpectedTag;
|
|
|
|
|
|
|
|
public:
|
|
|
|
bool IsValid() const
|
|
|
|
{
|
|
|
|
return this->Tag == ExpectedTag;
|
|
|
|
}
|
2022-09-19 16:31:30 -07:00
|
|
|
void LoadDefaults();
|
2021-03-14 00:22:58 -08:00
|
|
|
|
|
|
|
// Actual configuration data
|
2022-12-01 15:40:36 -08:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
uint8_t CanIndexOffset = 0;
|
|
|
|
// AUX0 and AUX1 curves
|
|
|
|
float auxOutBins[2][8];
|
|
|
|
float auxOutValues[2][8];
|
|
|
|
uint8_t auxInput[2];
|
|
|
|
} __attribute__((packed));
|
|
|
|
|
|
|
|
// pad to 256 bytes including tag
|
|
|
|
uint8_t pad[256 - 4];
|
|
|
|
};
|
2021-03-14 00:22:58 -08:00
|
|
|
};
|
|
|
|
|
2022-09-19 16:31:30 -07:00
|
|
|
int InitConfiguration();
|
2022-12-02 01:46:23 -08:00
|
|
|
Configuration* GetConfiguration();
|
|
|
|
void SetConfiguration();
|
2021-03-14 00:22:58 -08:00
|
|
|
|
2022-07-18 12:31:09 -07:00
|
|
|
/* TS stuff */
|
|
|
|
uint8_t *GetConfiguratiuonPtr();
|
2022-09-15 11:56:17 -07:00
|
|
|
size_t GetConfiguratiuonSize();
|
|
|
|
void SaveConfiguration();
|
2022-07-15 11:10:15 -07:00
|
|
|
const char *getTsSignature();
|