move CAN loop

This commit is contained in:
Matthew Kennedy 2020-12-10 18:08:06 -08:00
parent 2d483cc586
commit ea1f528aea
2 changed files with 23 additions and 9 deletions

View File

@ -3,6 +3,8 @@
#include "can_helper.h"
#include "heater_control.h"
#include "lambda_conversion.h"
#include "sampling.h"
static const CANConfig canConfig500 =
{
@ -10,9 +12,25 @@ static const CANConfig canConfig500 =
CAN_BTR_SJW(0) | CAN_BTR_BRP(5) | CAN_BTR_TS1(12) | CAN_BTR_TS2(1) | CAN_BTR_LBKM,
};
static THD_WORKING_AREA(waCanTxThread, 256);
void CanTxThread(void*)
{
while(1)
{
float esr = GetSensorInternalResistance();
float lambda = GetLambda();
SendCanData(lambda, esr);
SendEmulatedAemXseries(lambda, 0);
chThdSleepMilliseconds(10);
}
}
void InitCan()
{
canStart(&CAND1, &canConfig500);
chThdCreateStatic(waCanTxThread, sizeof(waCanTxThread), NORMALPRIO, CanTxThread, nullptr);
}
struct StandardDataFrame

View File

@ -7,7 +7,6 @@
#include "pump_control.h"
#include "pump_dac.h"
#include "sampling.h"
#include "lambda_conversion.h"
static const UARTConfig uartCfg =
{
@ -44,13 +43,10 @@ int main() {
InitCan();
while(1) {
float esr = GetSensorInternalResistance();
float lambda = GetLambda();
SendCanData(lambda, esr);
SendEmulatedAemXseries(lambda, 0);
chThdSleepMilliseconds(10);
while(true)
{
palTogglePad(GPIOB, 6);
chThdSleepMilliseconds(400);
}
}