extract heater control

This commit is contained in:
Matthew Kennedy 2020-10-30 01:53:54 -07:00
parent 7ec17c0e3a
commit 0a96a10734
4 changed files with 21 additions and 9 deletions

View File

@ -127,6 +127,7 @@ CPPSRC = $(ALLCPPSRC) \
pwm.cpp \
pump_dac.cpp \
sampling.cpp \
heater_control.cpp \
main.cpp
# List ASM source files here.

View File

@ -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);
}

View File

@ -0,0 +1,3 @@
#pragma once
void StartHeaterControl();

View File

@ -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);