29#ifdef _CHIBIOS_RT_CONF_VER_6_1_
44 SPI_CR1_BR_0 | SPI_CR1_BR_1 | SPI_CR1_BR_2 |
50class Pt2001 :
public Pt2001Base {
56 void acquireBus()
override {
57 criticalAssertVoid(driver !=
nullptr,
"mc33816");
58 spiAcquireBus(driver);
61 void releaseBus()
override {
62 spiReleaseBus(driver);
65 void select()
override {
66 criticalAssertVoid(driver !=
nullptr,
"mc33816");
72 chipSelect.setValue(0);
75 void deselect()
override {
78 chipSelect.setValue(1);
81 uint16_t sendRecv(uint16_t tx)
override {
82 return spiPolledExchange(driver, tx);
86 void sendLarge(
const uint16_t* data,
size_t count)
override {
87 spiSend(driver,
count, data);
91 void setResetB(
bool state)
override {
92 resetB.setValue(
state);
95 void setDriveEN(
bool state)
override {
96 driven.setValue(
state);
100 bool readFlag0()
const override {
105 float getVbatt()
const override {
111 float getBoostVoltage()
const override {
116 float getBoostCurrent()
const override {
120 float getPeakCurrent()
const override {
124 float getHoldCurrent()
const override {
128 float getPumpPeakCurrent()
const override {
132 float getPumpHoldCurrent()
const override {
137 uint16_t getTpeakOff()
const override {
141 uint16_t getTpeakTot()
const override {
145 uint16_t getTbypass()
const override {
149 uint16_t getTholdOff()
const override {
153 uint16_t getTHoldTot()
const override {
157 uint16_t getTBoostMin()
const override {
161 uint16_t getTBoostMax()
const override {
165 uint16_t getPumpTholdOff()
const override {
169 uint16_t getPumpTholdTot()
const override {
174 void onError(
const char* why)
override {
175 efiPrintf(
"PT2001 error: %s", why);
178 bool errorOnUnexpectedFlag()
override {
179 efiPrintf(
"****** unexpected mc33 flag state ******");
183 void sleepMs(
size_t ms)
override {
184 chThdSleepMilliseconds(ms);
214 chipSelect.setValue(1);
230 criticalError(
"mc33816 needs SPI selection");
234 if (driver ==
nullptr) {
239 spiStart(driver, &
spiCfg);
240 efiPrintf(
"mc33 started SPI");
254void Pt2001::initIfNeeded() {
262 efiPrintf(
"happy mc33/PT2001!");
264 efiPrintf(
"unhappy mc33 fault=%d %s", (
int)fault, mcFaultToString(fault));
276 chThdSleepMilliseconds(100);
281 bool isConfigured =
pt.init();
283 chThdCreateStatic(mc33_thread_wa,
sizeof(mc33_thread_wa), PRIO_GPIOCHIP, mc33_driver_thread,
nullptr);
void efiSetPadMode(const char *msg, brain_pin_e brainPin, iomode_t mode)
Single output pin reference and state.
virtual SensorResult get() const =0
void addConsoleAction(const char *token, Void callback)
Register console action without parameters.
ioportid_t getHwPort(const char *msg, brain_pin_e brainPin)
ioportmask_t getHwPin(const char *msg, brain_pin_e brainPin)
static constexpr engine_configuration_s * engineConfiguration
SPIDriver * getSpiDevice(spi_device_e spiDevice)
iomode_t getInputMode(pin_input_mode_e mode)
bool efiReadPin(brain_pin_e pin)
static THD_FUNCTION(mc33_driver_thread, p)
static THD_WORKING_AREA(mc33_thread_wa, 256)
static IgnVoltageGatekeeper gatekeeper
bool isBrainPinValid(brain_pin_e brainPin)
state("state", SensorCategory.SENSOR_INPUTS, FieldType.INT8, 1871, 1.0, -1.0, -1.0, "")
uint16_t mc33_t_min_boost
scaled_channel< uint8_t, 10, 1 > mc33_hpfp_i_hold
uint8_t mc33_hpfp_max_hold
uint8_t mc33_hpfp_i_hold_off
uint16_t mc33_t_max_boost
spi_device_e mc33816spiDevice
scaled_channel< uint8_t, 10, 1 > mc33_hpfp_i_peak