max3185x: restart driver thread on settings change
This commit is contained in:
parent
5efe1171f4
commit
247bf24a20
|
@ -16,7 +16,6 @@
|
||||||
#include "bench_test.h"
|
#include "bench_test.h"
|
||||||
#include "yaw_rate_sensor.h"
|
#include "yaw_rate_sensor.h"
|
||||||
#include "pin_repository.h"
|
#include "pin_repository.h"
|
||||||
#include "max3185x.h"
|
|
||||||
#include "logic_analyzer.h"
|
#include "logic_analyzer.h"
|
||||||
#include "smart_gpio.h"
|
#include "smart_gpio.h"
|
||||||
#include "accelerometer.h"
|
#include "accelerometer.h"
|
||||||
|
@ -620,10 +619,6 @@ void initHardware() {
|
||||||
initMc33816();
|
initMc33816();
|
||||||
#endif /* EFI_MC33816 */
|
#endif /* EFI_MC33816 */
|
||||||
|
|
||||||
#if EFI_MAX_31855
|
|
||||||
initMax3185x(engineConfiguration->max31855spiDevice, engineConfiguration->max31855_cs);
|
|
||||||
#endif /* EFI_MAX_31855 */
|
|
||||||
|
|
||||||
#if EFI_CAN_SUPPORT
|
#if EFI_CAN_SUPPORT
|
||||||
#if EFI_SIMULATOR
|
#if EFI_SIMULATOR
|
||||||
// Set CAN device name
|
// Set CAN device name
|
||||||
|
|
|
@ -84,11 +84,28 @@ public:
|
||||||
ThreadController::start();
|
ThreadController::start();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
efiPrintf("EGT not configured");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stop(void) {
|
||||||
|
ThreadController::stop();
|
||||||
|
|
||||||
|
for (size_t i = 0; i < EGT_CHANNEL_COUNT; i++) {
|
||||||
|
if (!isBrainPinValid(m_cs[i])) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto& sensor = egtSensors[i];
|
||||||
|
|
||||||
|
brain_pin_markUnused(m_cs[i]);
|
||||||
|
sensor.unregister();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ThreadTask() override {
|
void ThreadTask() override {
|
||||||
while (true) {
|
while (!chThdShouldTerminateX()) {
|
||||||
for (int i = 0; i < EGT_CHANNEL_COUNT; i++) {
|
for (int i = 0; i < EGT_CHANNEL_COUNT; i++) {
|
||||||
float value;
|
float value;
|
||||||
|
|
||||||
|
@ -104,6 +121,8 @@ public:
|
||||||
|
|
||||||
chThdSleepMilliseconds(MAX3185X_REFRESH_TIME);
|
chThdSleepMilliseconds(MAX3185X_REFRESH_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
chThdExit((msg_t)0x0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Debug stuff */
|
/* Debug stuff */
|
||||||
|
@ -435,12 +454,20 @@ static void egtRead() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void initMax3185x(spi_device_e device, egt_cs_array_t max31855_cs) {
|
void initMax3185x(spi_device_e device, egt_cs_array_t max31855_cs) {
|
||||||
if (instance.start(device, max31855_cs) == 0) {
|
addConsoleAction("egtinfo", (Void) showEgtInfo);
|
||||||
addConsoleAction("egtinfo", showEgtInfo);
|
addConsoleAction("egtread", (Void) egtRead);
|
||||||
addConsoleAction("egtread", egtRead);
|
|
||||||
} else {
|
startMax3185x(device, max31855_cs);
|
||||||
efiPrintf("EGT not configured");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stopMax3185x(void)
|
||||||
|
{
|
||||||
|
instance.stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
void startMax3185x(spi_device_e device, egt_cs_array_t max31855_cs)
|
||||||
|
{
|
||||||
|
instance.start(device, max31855_cs);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* EFI_MAX_31855 */
|
#endif /* EFI_MAX_31855 */
|
||||||
|
|
|
@ -12,4 +12,6 @@
|
||||||
|
|
||||||
#if HAL_USE_SPI
|
#if HAL_USE_SPI
|
||||||
void initMax3185x(spi_device_e device, egt_cs_array_t max31855_cs);
|
void initMax3185x(spi_device_e device, egt_cs_array_t max31855_cs);
|
||||||
|
void stopMax3185x(void);
|
||||||
|
void startMax3185x(spi_device_e device, egt_cs_array_t max31855_cs);
|
||||||
#endif /* HAL_USE_SPI */
|
#endif /* HAL_USE_SPI */
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include "cli_registry.h"
|
#include "cli_registry.h"
|
||||||
#include "io_pins.h"
|
#include "io_pins.h"
|
||||||
#include "lua_hooks.h"
|
#include "lua_hooks.h"
|
||||||
|
#include "max3185x.h"
|
||||||
|
|
||||||
static void initSensorCli();
|
static void initSensorCli();
|
||||||
|
|
||||||
|
@ -105,6 +106,10 @@ void initNewSensors() {
|
||||||
initOldAnalogInputs();
|
initOldAnalogInputs();
|
||||||
initAuxDigital();
|
initAuxDigital();
|
||||||
|
|
||||||
|
#if EFI_MAX_31855
|
||||||
|
initMax3185x(engineConfiguration->max31855spiDevice, engineConfiguration->max31855_cs);
|
||||||
|
#endif /* EFI_MAX_31855 */
|
||||||
|
|
||||||
// Init CLI functionality for sensors (mocking)
|
// Init CLI functionality for sensors (mocking)
|
||||||
initSensorCli();
|
initSensorCli();
|
||||||
|
|
||||||
|
@ -137,6 +142,9 @@ void stopSensors() {
|
||||||
deinitAuxSpeedSensors();
|
deinitAuxSpeedSensors();
|
||||||
deinitMap();
|
deinitMap();
|
||||||
deinitInputShaftSpeedSensor();
|
deinitInputShaftSpeedSensor();
|
||||||
|
#if EFI_MAX_31855
|
||||||
|
stopMax3185x();
|
||||||
|
#endif /* EFI_MAX_31855 */
|
||||||
}
|
}
|
||||||
|
|
||||||
void reconfigureSensors() {
|
void reconfigureSensors() {
|
||||||
|
@ -152,6 +160,9 @@ void reconfigureSensors() {
|
||||||
initInputShaftSpeedSensor();
|
initInputShaftSpeedSensor();
|
||||||
|
|
||||||
initOldAnalogInputs();
|
initOldAnalogInputs();
|
||||||
|
#if EFI_MAX_31855
|
||||||
|
startMax3185x(engineConfiguration->max31855spiDevice, engineConfiguration->max31855_cs);
|
||||||
|
#endif /* EFI_MAX_31855 */
|
||||||
}
|
}
|
||||||
|
|
||||||
// Mocking/testing helpers
|
// Mocking/testing helpers
|
||||||
|
|
Loading…
Reference in New Issue