Files
wideband/firmware/main.cpp
Andrey G cddcd0d88c Multichannel (#134)
* Multichannel AFR

* heater: fixes for multi channel mode

* f1_dual: fix configuration names

* pump_dac: fixes for multi-channel mode

* pwm: fixes for multichannel mode

* pump_control: reference instead of pointer

* sampling: reference instead of pointer

* heater_control: reference instead of pointer

* sampling: comment about heater/battery voltage

* f0_module: fixes for multi-channel update

* f1_rev2: fix for multichannel AFR

* hello rev 3

Co-authored-by: rusefillc <sdfsdfqsf2334234234>
2022-08-29 17:19:30 -07:00

79 lines
1.6 KiB
C++

#include "ch.h"
#include "hal.h"
#include "can.h"
#include "fault.h"
#include "heater_control.h"
#include "pump_control.h"
#include "pump_dac.h"
#include "sampling.h"
#include "uart.h"
#include "io_pins.h"
#include "auxout.h"
#include "max31855.h"
#include "wideband_config.h"
using namespace wbo;
/*
* Application entry point.
*/
int main() {
halInit();
chSysInit();
// Fire up all of our threads
StartSampling();
InitPumpDac();
StartHeaterControl();
StartPumpControl();
#ifdef AUXOUT_DAC_PWM_DEVICE
InitAuxDac();
#endif
InitCan();
InitUart();
#if (EGT_CHANNELS > 0)
StartEgt();
#endif
while(true)
{
/* TODO: show error for all AFR channels */
/* TODO: show EGT errors */
auto fault = GetCurrentFault(0);
if (fault == Fault::None)
{
// blue is off
palClearPad(LED_BLUE_PORT, LED_BLUE_PIN);
// Green is blinking
palTogglePad(LED_GREEN_PORT, LED_GREEN_PIN);
// Slow blink if closed loop, fast if not
chThdSleepMilliseconds(IsRunningClosedLoop(0) ? 700 : 50);
}
else
{
// green is off
palClearPad(LED_GREEN_PORT, LED_GREEN_PIN);
// Blink out the error code
for (int i = 0; i < 2 * static_cast<int>(fault); i++)
{
// Blue is blinking
palTogglePad(LED_BLUE_PORT, LED_BLUE_PIN);
// fast blink
chThdSleepMilliseconds(300);
}
chThdSleepMilliseconds(2000);
}
}
}