2020-09-19 02:49:20 -07:00
|
|
|
#include "ch.h"
|
|
|
|
#include "hal.h"
|
2020-10-29 02:55:55 -07:00
|
|
|
#include "chprintf.h"
|
2020-09-19 02:49:20 -07:00
|
|
|
|
2020-09-19 16:51:02 -07:00
|
|
|
#include "can.h"
|
2020-10-30 01:53:54 -07:00
|
|
|
#include "heater_control.h"
|
2020-10-31 16:59:35 -07:00
|
|
|
#include "pump_control.h"
|
2020-10-27 16:33:32 -07:00
|
|
|
#include "pump_dac.h"
|
2020-10-29 02:55:55 -07:00
|
|
|
#include "sampling.h"
|
2020-11-01 01:17:13 -08:00
|
|
|
#include "lambda_conversion.h"
|
2020-09-19 15:44:10 -07:00
|
|
|
|
2020-10-26 17:25:05 -07:00
|
|
|
static const UARTConfig uartCfg =
|
|
|
|
{
|
|
|
|
.txend1_cb = nullptr,
|
|
|
|
.txend2_cb = nullptr,
|
|
|
|
.rxend_cb = nullptr,
|
|
|
|
.rxchar_cb = nullptr,
|
|
|
|
.rxerr_cb = nullptr,
|
|
|
|
.timeout_cb = nullptr,
|
|
|
|
|
|
|
|
.timeout = 0,
|
2020-10-29 02:55:55 -07:00
|
|
|
.speed = 500000,
|
2020-10-26 17:25:05 -07:00
|
|
|
.cr1 = 0,
|
|
|
|
.cr2 = 0,
|
|
|
|
.cr3 = 0,
|
|
|
|
};
|
|
|
|
|
2020-10-29 02:55:55 -07:00
|
|
|
char strBuffer[200];
|
|
|
|
|
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-10-31 16:59:35 -07:00
|
|
|
// Fire up all of our threads
|
2020-10-29 02:55:55 -07:00
|
|
|
StartSampling();
|
2020-10-27 16:33:32 -07:00
|
|
|
InitPumpDac();
|
2020-10-31 16:59:35 -07:00
|
|
|
StartHeaterControl();
|
|
|
|
StartPumpControl();
|
2020-09-19 15:44:10 -07:00
|
|
|
|
2020-10-26 17:25:05 -07:00
|
|
|
uartStart(&UARTD1, &uartCfg);
|
2020-10-26 12:45:50 -07:00
|
|
|
|
2020-10-31 16:59:35 -07:00
|
|
|
InitCan();
|
2020-09-19 21:39:29 -07:00
|
|
|
|
2020-10-29 02:55:55 -07:00
|
|
|
while(1) {
|
2020-11-28 02:56:46 -08:00
|
|
|
float esr = GetSensorInternalResistance();
|
|
|
|
float lambda = GetLambda();
|
2020-10-27 20:07:16 -07:00
|
|
|
|
2020-11-28 02:56:46 -08:00
|
|
|
SendCanData(lambda, esr);
|
2020-09-19 16:51:02 -07:00
|
|
|
}
|
2020-09-19 02:49:20 -07:00
|
|
|
}
|