2020-03-19 05:43:37 -07:00
|
|
|
/**
|
|
|
|
* @file can.h
|
|
|
|
*
|
|
|
|
* @date Mar 19, 2020
|
|
|
|
* @author Matthew Kennedy, (c) 2020
|
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "hal.h"
|
|
|
|
|
2020-03-19 11:01:07 -07:00
|
|
|
#include "periodic_thread_controller.h"
|
|
|
|
|
2020-03-29 18:15:06 -07:00
|
|
|
#define CAN_PEDAL_TPS_OFFSET 2
|
|
|
|
#define CAN_SENSOR_1_OFFSET 3
|
|
|
|
|
2020-09-06 20:39:25 -07:00
|
|
|
#define CAN_TIMEOUT MS2NT(100)
|
|
|
|
|
2020-03-19 05:43:37 -07:00
|
|
|
class Logging;
|
2020-03-31 20:21:05 -07:00
|
|
|
class CanSensorBase;
|
|
|
|
|
2021-02-05 20:57:28 -08:00
|
|
|
#if EFI_CAN_SUPPORT
|
2020-03-31 20:21:05 -07:00
|
|
|
void processCanRxMessage(const CANRxFrame& msg, Logging* logger, efitick_t nowNt);
|
2021-02-05 20:57:28 -08:00
|
|
|
#endif // EFI_CAN_SUPPORT
|
|
|
|
|
2020-03-31 20:21:05 -07:00
|
|
|
void registerCanSensor(CanSensorBase& sensor);
|
2020-03-19 11:01:07 -07:00
|
|
|
|
2020-12-16 05:28:53 -08:00
|
|
|
// Indicate that an ack response was received from the wideband bootloader
|
|
|
|
void handleWidebandBootloaderAck();
|
|
|
|
// Update the firmware on any connected wideband controller
|
|
|
|
void updateWidebandFirmware(Logging*);
|
|
|
|
|
2020-03-19 16:29:56 -07:00
|
|
|
class CanWrite final : public PeriodicController<512> {
|
2020-03-19 11:01:07 -07:00
|
|
|
public:
|
|
|
|
CanWrite();
|
|
|
|
void PeriodicTask(efitime_t nowNt) override;
|
|
|
|
};
|
2021-03-09 15:54:01 -08:00
|
|
|
|
|
|
|
// We need these helpers because the frame layout is different on STM32H7
|
|
|
|
#ifdef STM32H7XX
|
|
|
|
#define CAN_SID(f) ((f).std.SID)
|
|
|
|
#define CAN_EID(f) ((f).ext.EID)
|
|
|
|
#else
|
|
|
|
#define CAN_SID(f) ((f).SID)
|
|
|
|
#define CAN_EID(f) ((f).EID)
|
|
|
|
#endif
|