diff --git a/firmware/Makefile b/firmware/Makefile index 6f8675f..c3821f9 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -127,6 +127,7 @@ CPPSRC = $(ALLCPPSRC) \ pwm.cpp \ pump_dac.cpp \ sampling.cpp \ + heater_control.cpp \ main.cpp # List ASM source files here. diff --git a/firmware/heater_control.cpp b/firmware/heater_control.cpp new file mode 100644 index 0000000..125f0e2 --- /dev/null +++ b/firmware/heater_control.cpp @@ -0,0 +1,15 @@ +#include "heater_control.h" + +#include "hal.h" +#include "pwm.h" +#include "sampling.h" + +// 400khz / 1024 = 390hz PWM +// TODO: this is wired to an inverted output, what do? +Pwm heaterPwm(PWMD1, 0, 400'000, 1024); + +void StartHeaterControl() +{ + heaterPwm.Start(); + heaterPwm.SetDuty(0); +} diff --git a/firmware/heater_control.h b/firmware/heater_control.h new file mode 100644 index 0000000..2bfdca7 --- /dev/null +++ b/firmware/heater_control.h @@ -0,0 +1,3 @@ +#pragma once + +void StartHeaterControl(); diff --git a/firmware/main.cpp b/firmware/main.cpp index f4b9c72..866bff1 100644 --- a/firmware/main.cpp +++ b/firmware/main.cpp @@ -3,14 +3,10 @@ #include "chprintf.h" #include "can.h" -#include "pwm.h" +#include "heater_control.h" #include "pump_dac.h" #include "sampling.h" -// 400khz / 1024 = 390hz PWM -// TODO: this is wired to an inverted output, what do? -Pwm heaterPwm(PWMD1, 0, 400'000, 1024); - static const UARTConfig uartCfg = { .txend1_cb = nullptr, @@ -44,10 +40,7 @@ int main() { uartStart(&UARTD1, &uartCfg); - heaterPwm.Start(); - - heaterPwm.SetDuty(0.2f); - + StartHeaterControl(); /*for (int i = 0; i < 500; i++) { SetPumpCurrentTarget(current);