From 1aa7c661f6cfb67e5e75a66cb00c9e220a9630ba Mon Sep 17 00:00:00 2001 From: Andrey G Date: Tue, 13 Dec 2022 06:29:32 +0300 Subject: [PATCH] f1_rev and threads (#173) * f1_rev3: high speed (strenght) for heater PWM output * threads: set name for all thread * f1_dual: enalbe CH_CFG_USE_REGISTRY so GDB can see thread * f1_rev3: enalbe CH_CFG_USE_REGISTRY so GDB can see thread --- firmware/auxout.cpp | 2 ++ firmware/boards/f1_dual/chconf.h | 2 +- firmware/boards/f1_rev3/board.h | 2 +- firmware/boards/f1_rev3/chconf.h | 2 +- firmware/can.cpp | 4 ++++ firmware/heater_control.cpp | 2 ++ firmware/pump_control.cpp | 2 ++ firmware/sampling.cpp | 2 ++ firmware/uart.cpp | 2 ++ 9 files changed, 17 insertions(+), 3 deletions(-) diff --git a/firmware/auxout.cpp b/firmware/auxout.cpp index 9290b91..ea07211 100644 --- a/firmware/auxout.cpp +++ b/firmware/auxout.cpp @@ -151,6 +151,8 @@ void AuxOutThread(void*) { const auto cfg = GetConfiguration(); + chRegSetThreadName("Aux out"); + while(1) { for (int ch = 0; ch < AFR_CHANNELS; ch++) diff --git a/firmware/boards/f1_dual/chconf.h b/firmware/boards/f1_dual/chconf.h index 17e39d8..9229796 100644 --- a/firmware/boards/f1_dual/chconf.h +++ b/firmware/boards/f1_dual/chconf.h @@ -183,7 +183,7 @@ typedef int pid_t; * @note The default is @p TRUE. */ #if !defined(CH_CFG_USE_REGISTRY) -#define CH_CFG_USE_REGISTRY FALSE +#define CH_CFG_USE_REGISTRY TRUE #endif /** diff --git a/firmware/boards/f1_rev3/board.h b/firmware/boards/f1_rev3/board.h index 5fdf718..ace74c5 100644 --- a/firmware/boards/f1_rev3/board.h +++ b/firmware/boards/f1_rev3/board.h @@ -109,7 +109,7 @@ * PB12 - Nernsr_4.2_esr_drive (digital input, no pull) - keep high-Z after power on * PB13..PB15 - unused */ -#define VAL_GPIOBCRL 0x8A888200 /* PB7...PB0 */ +#define VAL_GPIOBCRL 0x8B888200 /* PB7...PB0 */ #define VAL_GPIOBCRH 0x88843488 /* PB15...PB8 */ #define VAL_GPIOBODR 0x0000FFFF diff --git a/firmware/boards/f1_rev3/chconf.h b/firmware/boards/f1_rev3/chconf.h index 458b179..abea810 100644 --- a/firmware/boards/f1_rev3/chconf.h +++ b/firmware/boards/f1_rev3/chconf.h @@ -183,7 +183,7 @@ typedef int pid_t; * @note The default is @p TRUE. */ #if !defined(CH_CFG_USE_REGISTRY) -#define CH_CFG_USE_REGISTRY FALSE +#define CH_CFG_USE_REGISTRY TRUE #endif /** diff --git a/firmware/can.cpp b/firmware/can.cpp index 027286b..818262d 100644 --- a/firmware/can.cpp +++ b/firmware/can.cpp @@ -17,6 +17,8 @@ static Configuration* configuration; static THD_WORKING_AREA(waCanTxThread, 256); void CanTxThread(void*) { + chRegSetThreadName("CAN Tx"); + while(1) { SendRusefiFormat(configuration->CanIndexOffset); @@ -45,6 +47,8 @@ static float remoteBatteryVoltage = 0; static THD_WORKING_AREA(waCanRxThread, 512); void CanRxThread(void*) { + chRegSetThreadName("CAN Rx"); + while(1) { CANRxFrame frame; diff --git a/firmware/heater_control.cpp b/firmware/heater_control.cpp index b97d923..b2dd3b0 100644 --- a/firmware/heater_control.cpp +++ b/firmware/heater_control.cpp @@ -196,6 +196,8 @@ static void HeaterThread(void*) { int ch; + chRegSetThreadName("Heater"); + // Wait for temperature sensing to stabilize so we don't // immediately think we overshot the target temperature chThdSleepMilliseconds(1000); diff --git a/firmware/pump_control.cpp b/firmware/pump_control.cpp index b78b3bc..9c0f443 100644 --- a/firmware/pump_control.cpp +++ b/firmware/pump_control.cpp @@ -26,6 +26,8 @@ static struct pump_control_state state[AFR_CHANNELS] = static THD_WORKING_AREA(waPumpThread, 256); static void PumpThread(void*) { + chRegSetThreadName("Pump"); + while(true) { for (int ch = 0; ch < AFR_CHANNELS; ch++) diff --git a/firmware/sampling.cpp b/firmware/sampling.cpp index 081d67b..994147b 100644 --- a/firmware/sampling.cpp +++ b/firmware/sampling.cpp @@ -37,6 +37,8 @@ static void SamplingThread(void*) float r_2[AFR_CHANNELS] = {0}; float r_3[AFR_CHANNELS] = {0}; + chRegSetThreadName("Sampling"); + /* GD32: Insert 20us delay after ADC enable */ chThdSleepMilliseconds(1); diff --git a/firmware/uart.cpp b/firmware/uart.cpp index 499b23b..fbbb8f4 100644 --- a/firmware/uart.cpp +++ b/firmware/uart.cpp @@ -28,6 +28,8 @@ static char printBuffer[200]; static THD_WORKING_AREA(waUartThread, 512); static void UartThread(void*) { + chRegSetThreadName("UART debug"); + // in UART_DEBUG mode we only support Serial - this file name here has a bit of a confusing naming sdStart(&SD1, &cfg);