wideband/firmware/main.cpp

38 lines
644 B
C++
Raw Normal View History

2020-09-19 02:49:20 -07:00
#include "ch.h"
#include "hal.h"
2020-09-19 21:39:29 -07:00
#include "analog_input.h"
2020-09-19 16:51:02 -07:00
#include "can.h"
2020-09-19 15:44:10 -07:00
#include "pwm.h"
// 400khz / 1024 = 390hz PWM
2020-09-19 15:45:44 -07:00
// TODO: this is wired to an inverted output, what do?
2020-09-19 15:44:10 -07:00
Pwm heaterPwm(PWMD1, 1, 400000, 1024);
// 48MHz / 1024 = 46.8khz PWM
Pwm pumpDac(PWMD3, 1, 48000000, 1024);
2020-09-19 02:49:20 -07:00
/*
* Application entry point.
*/
2020-09-19 21:39:29 -07:00
int main() {
2020-09-19 16:51:02 -07:00
halInit();
chSysInit();
2020-09-19 02:49:20 -07:00
2020-09-19 16:51:02 -07:00
InitCan();
2020-09-19 15:44:10 -07:00
2020-09-19 16:51:02 -07:00
heaterPwm.Start();
pumpDac.Start();
2020-09-19 02:49:20 -07:00
2020-09-19 20:44:13 -07:00
heaterPwm.SetDuty(0.2f);
pumpDac.SetDuty(0.4f);
2020-09-19 16:51:02 -07:00
while (true) {
2020-09-19 21:39:29 -07:00
auto result = AnalogSample();
2020-09-19 16:51:02 -07:00
// dummy data
SendCanData(0.5f, 300);
chThdSleepMilliseconds(10);
}
2020-09-19 02:49:20 -07:00
}