From 28c3af682d304d0636b199c6d7de05a9fbbf3fed Mon Sep 17 00:00:00 2001 From: Andrey Date: Tue, 28 Feb 2023 22:10:19 -0500 Subject: [PATCH] Native SENT TPS input #5079 a bit of progress --- firmware/controllers/sensors/tps.cpp | 3 +++ firmware/controllers/sensors/tps.h | 2 ++ firmware/hw_layer/drivers/sent/sent.cpp | 1 + firmware/init/sensor/init_tps.cpp | 13 +++++++++---- 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/firmware/controllers/sensors/tps.cpp b/firmware/controllers/sensors/tps.cpp index 4764ff2c840..0c92485d81f 100644 --- a/firmware/controllers/sensors/tps.cpp +++ b/firmware/controllers/sensors/tps.cpp @@ -45,3 +45,6 @@ bool isTps2Error() { bool isPedalError() { return !Sensor::get(SensorType::AcceleratorPedal).Valid && Sensor::hasSensor(SensorType::AcceleratorPedalPrimary); } + +void sentTpsDecode() { +} \ No newline at end of file diff --git a/firmware/controllers/sensors/tps.h b/firmware/controllers/sensors/tps.h index 74ec13785f0..da9f589d74a 100644 --- a/firmware/controllers/sensors/tps.h +++ b/firmware/controllers/sensors/tps.h @@ -29,6 +29,8 @@ void grabTPSIsWideOpen(); void grabPedalIsUp(); void grabPedalIsWideOpen(); +void sentTpsDecode(); + bool isTps1Error(); bool isTps2Error(); bool isPedalError(); diff --git a/firmware/hw_layer/drivers/sent/sent.cpp b/firmware/hw_layer/drivers/sent/sent.cpp index 23a7dbb652a..9c78b8356b9 100644 --- a/firmware/hw_layer/drivers/sent/sent.cpp +++ b/firmware/hw_layer/drivers/sent/sent.cpp @@ -580,6 +580,7 @@ static void SentDecoderThread(void*) { /* Call high level decoder from here */ + sentTpsDecode(); } } } diff --git a/firmware/init/sensor/init_tps.cpp b/firmware/init/sensor/init_tps.cpp index 77c4d9951ce..f412bd5a4ba 100644 --- a/firmware/init/sensor/init_tps.cpp +++ b/firmware/init/sensor/init_tps.cpp @@ -203,10 +203,15 @@ void initTps() { tpsSecondaryMaximum = 20; } - analogTps1.init(isFordTps, &fordTps1, tpsSecondaryMaximum, - { engineConfiguration->tps1_1AdcChannel, (float)engineConfiguration->tpsMin, (float)engineConfiguration->tpsMax, min, max }, - { engineConfiguration->tps1_2AdcChannel, (float)engineConfiguration->tps1SecondaryMin, (float)engineConfiguration->tps1SecondaryMax, min, max } - ); + + if (isDigitalTps1()) { + sentTps.Register(); + } else { + analogTps1.init(isFordTps, &fordTps1, tpsSecondaryMaximum, + { engineConfiguration->tps1_1AdcChannel, (float)engineConfiguration->tpsMin, (float)engineConfiguration->tpsMax, min, max }, + { engineConfiguration->tps1_2AdcChannel, (float)engineConfiguration->tps1SecondaryMin, (float)engineConfiguration->tps1SecondaryMax, min, max } + ); + } tps2.init(isFordTps, &fordTps2, tpsSecondaryMaximum, { engineConfiguration->tps2_1AdcChannel, (float)engineConfiguration->tps2Min, (float)engineConfiguration->tps2Max, min, max },