Skip to content

Commit 246367b

Browse files
committed
better management of debugging #499
1 parent 2d78e7e commit 246367b

File tree

12 files changed

+29
-14
lines changed

12 files changed

+29
-14
lines changed

src/current_sense/hardware_specific/esp32/esp32_mcu.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,11 @@ typedef struct ESP32CurrentSenseParams {
2121

2222
// macros for debugging wuing the simplefoc debug system
2323
#define SIMPLEFOC_ESP32_CS_DEBUG(str)\
24-
SimpleFOCDebug::println( "ESP32-CS: "+ String(str));\
25-
24+
#ifndef SIMPLEFOC_DISABLE_DEBUG
25+
SimpleFOCDebug::println( "ESP32-CS: "+ String(str));\
26+
#endif
27+
28+
2629
#define CHECK_CS_ERR(func_call, message) \
2730
if ((func_call) != ESP_OK) { \
2831
SIMPLEFOC_ESP32_CS_DEBUG("ERROR - " + String(message)); \

src/current_sense/hardware_specific/stm32/stm32_adc_utils.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,13 +145,15 @@ ADC_TypeDef* _findBestADCForPins(int numPins, int pins[]) {
145145
}
146146
}
147147

148+
#ifndef SIMPLEFOC_DISABLE_DEBUG
148149
for (int i = 0; i < ADC_COUNT; i++) {
149150
if(!pins_at_adc[i]) continue;
150151
SimpleFOCDebug::print("STM32-CS: ADC");
151152
SimpleFOCDebug::print(i+1);
152153
SimpleFOCDebug::print(" pins: ");
153154
SimpleFOCDebug::println(pins_at_adc[i]);
154155
}
156+
#endif
155157

156158
// now take the first ADC that has all pins connected
157159
for (int i = 0; i < ADC_COUNT; i++) {

src/current_sense/hardware_specific/stm32/stm32f1/stm32f1_hal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ int _adc_gpio_init(Stm32CurrentSenseParams* cs_params, const int pinA, const int
131131
if(_isset(pins[i])){
132132
// check if pin is an analog pin
133133
if(pinmap_peripheral(analogInputToPinName(pins[i]), PinMap_ADC) == NP){
134-
#ifdef SIMPLEFOC_STM32_DEBUG
134+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
135135
SimpleFOCDebug::print("STM32-CS: ERR: Pin ");
136136
SimpleFOCDebug::print(port_names[i]);
137137
SimpleFOCDebug::println(" does not belong to any ADC!");

src/current_sense/hardware_specific/stm32/stm32f4/stm32f4_hal.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ int _adc_gpio_init(Stm32CurrentSenseParams* cs_params, const int pinA, const int
143143
if(_isset(pins[i])){
144144
// check if pin is an analog pin
145145
if(pinmap_peripheral(analogInputToPinName(pins[i]), PinMap_ADC) == NP){
146-
#ifdef SIMPLEFOC_STM32_DEBUG
146+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
147147
SimpleFOCDebug::print("STM32-CS: ERR: Pin ");
148148
SimpleFOCDebug::print(i == 0 ? "A" : i == 1 ? "B" : "C");
149149
SimpleFOCDebug::println(" does not belong to any ADC!");

src/current_sense/hardware_specific/stm32/stm32f7/stm32f7_hal.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,8 @@ int _adc_gpio_init(Stm32CurrentSenseParams* cs_params, const int pinA, const int
154154
if(_isset(pins[i])){
155155
// check if pin is an analog pin
156156
if(pinmap_peripheral(analogInputToPinName(pins[i]), PinMap_ADC) == NP){
157-
#ifdef SIMPLEFOC_STM32_DEBUG
157+
158+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
158159
SimpleFOCDebug::print("STM32-CS: ERR: Pin ");
159160
SimpleFOCDebug::print(port_names[i]);
160161
SimpleFOCDebug::println(" does not belong to any ADC!");

src/current_sense/hardware_specific/stm32/stm32g4/stm32g4_hal.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,8 @@ int _adc_gpio_init(Stm32CurrentSenseParams* cs_params, const int pinA, const int
195195
if(_isset(pins[i])){
196196
// check if pin is an analog pin
197197
if(pinmap_peripheral(analogInputToPinName(pins[i]), PinMap_ADC) == NP){
198-
#ifdef SIMPLEFOC_STM32_DEBUG
198+
199+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
199200
SimpleFOCDebug::print("STM32-CS: ERR: Pin ");
200201
SimpleFOCDebug::print(port_names[i]);
201202
SimpleFOCDebug::println(" does not belong to any ADC!");

src/current_sense/hardware_specific/stm32/stm32h7/stm32h7_hal.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ int _adc_gpio_init(Stm32CurrentSenseParams* cs_params, const int pinA, const int
175175
if(_isset(pins[i])){
176176
// check if pin is an analog pin
177177
if(pinmap_peripheral(analogInputToPinName(pins[i]), PinMap_ADC) == NP){
178-
#ifdef SIMPLEFOC_STM32_DEBUG
178+
179+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
179180
SimpleFOCDebug::print("STM32-CS: ERR: Pin ");
180181
SimpleFOCDebug::print(port_names[i]);
181182
SimpleFOCDebug::println(" does not belong to any ADC!");

src/current_sense/hardware_specific/stm32/stm32l4/stm32l4_hal.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ int _adc_gpio_init(Stm32CurrentSenseParams* cs_params, const int pinA, const int
189189
if(_isset(pins[i])){
190190
// check if pin is an analog pin
191191
if(pinmap_peripheral(analogInputToPinName(pins[i]), PinMap_ADC) == NP){
192-
#ifdef SIMPLEFOC_STM32_DEBUG
192+
193+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
193194
SimpleFOCDebug::print("STM32-CS: ERR: Pin ");
194195
SimpleFOCDebug::print(port_names[i]);
195196
SimpleFOCDebug::println(" does not belong to any ADC!");

src/drivers/hardware_specific/esp32/esp32_driver_mcpwm.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ typedef struct ESP32MCPWMDriverParams {
3333

3434

3535
#define SIMPLEFOC_ESP32_DEBUG(tag, str)\
36+
#ifndef SIMPLEFOC_DISABLE_DEBUG
3637
SimpleFOCDebug::println( "ESP32-"+String(tag)+ ": "+ String(str));
38+
#endif
3739

3840
#define SIMPLEFOC_ESP32_DRV_DEBUG(str)\
3941
SIMPLEFOC_ESP32_DEBUG("DRV", str);\

src/drivers/hardware_specific/renesas/renesas.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,9 @@ ClockDivAndRange getClockDivAndRange(uint32_t pwm_frequency, uint8_t timer_chann
121121
result.clk_div = TIMER_SOURCE_DIV_1024;
122122
}
123123
else {
124+
#if !defined(SIMPLEFOC_DISABLE_DEBUG)
124125
SimpleFOCDebug::println("DRV: PWM frequency too low");
126+
#endif
125127
}
126128
return result;
127129
};
@@ -181,7 +183,7 @@ bool configureTimerPin(RenesasHardwareDriverParams* params, uint8_t index, bool
181183

182184
// configure timer channel - frequency / top value
183185
ClockDivAndRange timings = getClockDivAndRange(params->pwm_frequency, timer_channel);
184-
#if defined(SIMPLEFOC_RENESAS_DEBUG)
186+
#if defined(SIMPLEFOC_RENESAS_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
185187
SimpleFOCDebug::println("---PWM Config---");
186188
SimpleFOCDebug::println("DRV: pwm pin: ", pin);
187189
if (complementary)
@@ -269,7 +271,9 @@ bool configureTimerPin(RenesasHardwareDriverParams* params, uint8_t index, bool
269271
return false;
270272
}
271273
if (err == FSP_ERR_ALREADY_OPEN) {
274+
#if !defined(SIMPLEFOC_DISABLE_DEBUG)
272275
SimpleFOCDebug::println("DRV: timer already open");
276+
#endif
273277
return false;
274278
}
275279

@@ -306,12 +310,12 @@ bool startTimerChannels(RenesasHardwareDriverParams* params, int num_channels) {
306310
// return false;
307311
// }
308312
mask |= (1 << params->channels[i]);
309-
#if defined(SIMPLEFOC_RENESAS_DEBUG)
313+
#if defined(SIMPLEFOC_RENESAS_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
310314
SimpleFOCDebug::println("DRV: starting timer: ", params->channels[i]);
311315
#endif
312316
}
313317
params->timer_config[0]->ctrl.p_reg->GTSTR |= mask;
314-
#if defined(SIMPLEFOC_RENESAS_DEBUG)
318+
#if defined(SIMPLEFOC_RENESAS_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
315319
SimpleFOCDebug::println("DRV: timers started");
316320
#endif
317321
return true;

0 commit comments

Comments
 (0)