Skip to content

Commit

Permalink
Fix output sensor not being initialized
Browse files Browse the repository at this point in the history
  • Loading branch information
rnd-ash committed Aug 24, 2024
1 parent 06ed407 commit 34eea17
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ SPEAKER_POST_CODE setup_tcm()
if (ret == SPEAKER_POST_CODE::INIT_OK)
{
spkr = new Speaker(pcb_gpio_matrix->spkr_pin);
if (ESP_OK == Sensors::init_sensors())
if (ESP_OK == EEPROM::init_eeprom())
{
if (ESP_OK == Solenoids::init_all_solenoids())
if (ESP_OK == Sensors::init_sensors())
{
if (ESP_OK == EEPROM::init_eeprom())
if (ESP_OK == Solenoids::init_all_solenoids())
{
// Read device mode!
CURRENT_DEVICE_MODE = EEPROM::read_device_mode();
Expand Down
10 changes: 7 additions & 3 deletions src/sensors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,9 +266,13 @@ esp_err_t Sensors::init_sensors(void){
ESP_RETURN_ON_ERROR(configure_pcnt("N3", pcb_gpio_matrix->n3_pin, &PCNT_HANDLE_N3, &PCNT_C_HANDLE_N3, &n3_avg_buffer), "SENSORS", "N3 PCNT Setup failed");

// Enable output RPM reading if needed
if (VEHICLE_CONFIG.io_0_usage == 1 && VEHICLE_CONFIG.input_sensor_pulses_per_rev != 0) {
ESP_LOGI("SENSORS", "Will init OUTPUT RPM sensor");
if (ESP_OK == configure_output_pcnt(pcb_gpio_matrix->io_pin, &PCNT_HANDLE_OUTPUT, &PCNT_C_HANDLE_OUTPUT)) {
if (VEHICLE_CONFIG.io_0_usage == 1) {
if (VEHICLE_CONFIG.input_sensor_pulses_per_rev == 0) {
ESP_LOGE("SENSORS", "Cannot init output sensor with 0 pulses/rev specified");
return ESP_ERR_INVALID_ARG;
} else {
ESP_LOGI("SENSORS", "Will init OUTPUT RPM sensor");
ESP_RETURN_ON_ERROR(configure_output_pcnt(pcb_gpio_matrix->io_pin, &PCNT_HANDLE_OUTPUT, &PCNT_C_HANDLE_OUTPUT), "SENSORS", "Output PCNT Setup failed");
output_rpm_ok = true;
}
}
Expand Down

0 comments on commit 34eea17

Please sign in to comment.