Skip to content

Commit

Permalink
we have main relay sensing!
Browse files Browse the repository at this point in the history
  • Loading branch information
mck1117 committed Jan 3, 2025
1 parent 0baff3d commit 9f4b660
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 2 deletions.
17 changes: 17 additions & 0 deletions firmware/config/boards/atlas/board_configuration.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
#include "pch.h"

#include "adc_subscription.h"
#include "functional_sensor.h"
#include "linear_func.h"

static const brain_pin_e injPins[] = {
Gpio::G5,
Gpio::G6,
Expand Down Expand Up @@ -149,3 +153,16 @@ void preHalInit() {
efiSetPadMode("SDMMC", Gpio::C12, PAL_MODE_ALTERNATE(0xc));
efiSetPadMode("SDMMC", Gpio::D2, PAL_MODE_ALTERNATE(0xc));
}

void initBoardSensors() {
static LinearFunc mrSenseFunc;
static FunctionalSensor mrSenseSensor(SensorType::MainRelayVoltage, MS2NT(100));

// 82k high side/10k low side = 9.2
const float mrSenseRatio = (92.0f / 10.0f);

mrSenseFunc.configure(0, 0, 1, mrSenseRatio, 0, 50);
mrSenseSensor.setFunction(mrSenseFunc);
AdcSubscription::SubscribeSensor(mrSenseSensor, EFI_ADC_16, /*bandwidth*/ 20, /*ratio*/ 1);
mrSenseSensor.Register();
}
2 changes: 2 additions & 0 deletions firmware/controllers/algo/engine_configuration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -937,3 +937,5 @@ __attribute__((weak)) void setBoardConfigOverrides() { }

__attribute__((weak)) int getBoardMetaOutputsCount() { return 0; }
__attribute__((weak)) Gpio* getBoardMetaOutputs() { return nullptr; }

__attribute__((weak)) void initBoardSensors() { }
6 changes: 4 additions & 2 deletions firmware/controllers/algo/engine_configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@ void resetConfigurationExt(engine_type_e engineType);
void rememberCurrentConfiguration();
#endif /* __cplusplus */

void setBoardDefaultConfiguration(void);
void setBoardConfigOverrides(void);
void setBoardDefaultConfiguration();
void setBoardConfigOverrides();
// Init any sensors built in to the board that don't need config
void initBoardSensors();
void boardOnConfigurationChange(engine_configuration_s *previousConfiguration);
Gpio getCommsLedPin();
Gpio getWarningLedPin();
Expand Down
3 changes: 3 additions & 0 deletions firmware/init/sensor/init_sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ static void deInitAuxDigital() {
}

void initNewSensors() {
// First (optionally) init any sensors built in to the board that don't need config
initBoardSensors();

reconfigureSensors();

initBaro();
Expand Down

0 comments on commit 9f4b660

Please sign in to comment.