10 #include "../includes/config.h"
17 #include <HardwareSerial.h>
18 #include <IWatchdog.h>
19 #include <LiquidCrystal.h>
22 #include "../includes/battery.h"
23 #include "../includes/blower.h"
24 #include "../includes/buzzer.h"
25 #include "../includes/buzzer_control.h"
26 #include "../includes/calibration.h"
27 #include "../includes/cpu_load.h"
28 #include "../includes/debug.h"
29 #include "../includes/end_of_line_test.h"
30 #include "../includes/keyboard.h"
31 #include "../includes/main_controller.h"
32 #include "../includes/main_state_machine.h"
33 #include "../includes/mass_flow_meter.h"
34 #include "../includes/parameters.h"
35 #include "../includes/pressure.h"
36 #include "../includes/pressure_valve.h"
37 #include "../includes/rpi_watchdog.h"
38 #include "../includes/screen.h"
39 #include "../includes/serial_control.h"
40 #include "../includes/telemetry.h"
53 DBG_DO(Serial.println(
"Booting the system...");)
97 #ifdef MASS_FLOW_METER_ENABLED
109 pinMode(PB12, INPUT);
120 if (HIGH == digitalRead(PB12)) {
123 while (HIGH == digitalRead(PB12)) {
130 if (IWatchdog.isReset(
true)) {
AlarmController alarmController
Instance of the alarm controller.
uint32_t getBatteryLevelX100()
Returns battery level x100 for better accuracy.
bool isBatteryDeepDischarged()
Check if battery is deeply discharged.
void initBattery()
Initialize battery abstraction.
void Buzzer_High_Prio_Start(void)
Activate the buzzer pattern for high priority alarms.
void Buzzer_Init()
Initialization of HardwareTimer for buzzer.
#define WATCHDOG_TIMEOUT
Watchdog timeout in microseconds.
void BuzzerControl_Init(void)
Initialization of HardwareTimer for buzzer.
void Calibration_Init()
Initialization of calibration process.
void setup()
Initialize the hardware timer used to control the blower.
void setupAndStart()
Run test mode.
void activate()
Enable test mode.
bool isRunning()
Check if test mode is enabled.
Controls breathing cycle.
void setupAndStart()
Run the state machine.
Offset aware reading class for the pressure sensor.
Controls a pressure valve.
void setup()
Initialize this valve.
void disable()
Disable countdown mode (used for debug)
#define COUNT_IDLE_CYCLE
Increment the idle cycles counter.
#define DBG_DO(statement)
Expand arbitrary code only when in debug mode.
void initKeyboard()
Initialize keyboard abstraction.
MainController mainController
MainStateMachine mainStateMachine
bool MFM_init(void)
Initialize Mass Flow Meter.
#define PIN_TELEMETRY_SERIAL_TX
#define PIN_PRESSURE_SENSOR
#define TIM_CHANNEL_ESC_BLOWER
#define PIN_TELEMETRY_SERIAL_RX
#define PIN_ENABLE_PWR_RASP
#define VALVE_CLOSED_STATE
Angle when closed.
#define VALVE_OPEN_STATE
Angle when opened.
#define TIM_CHANNEL_EXPIRATORY_VALVE
#define TIM_CHANNEL_INSPIRATORY_VALVE
#define PIN_INSPIRATORY_VALVE
#define PIN_EXPIRATORY_VALVE
PressureSensor inspiratoryPressureSensor
PressureValve inspiratoryValve
PressureValve expiratoryValve
HardwareTimer * hardwareTimer3
HardwareSerial Serial6(PIN_TELEMETRY_SERIAL_RX, PIN_TELEMETRY_SERIAL_TX)
HardwareTimer * hardwareTimer1
void displayBatteryDeepDischarge()
Display error when battery level is too discharged.
void displayWatchdogError()
Display error when machine was restarted by watchdog.
void displayEndOfLineTestMode()
Show that EOL mode was triggered.
void startScreen()
Start the screen.
void sendWatchdogRestartFatalError(void)
Send a "watchdog restart" fatal error.
void sendBootMessage()
Send a "boot" message.
void sendBatteryDeeplyDischargedFatalError(uint16_t batteryLevelValue)
Send a "battery deeply discharged" fatal error.
void initTelemetry(void)
Prepare Serial6 to send telemetry data.