Skip to content

Commit 283f20b

Browse files
committed
debug stm32 flag issue
1 parent f1d9200 commit 283f20b

File tree

4 files changed

+12
-15
lines changed

4 files changed

+12
-15
lines changed

src/communication/SimpleFOCDebug.h

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,11 @@ class SimpleFOCDebug {
6666
#define SIMPLEFOC_DEBUG(msg, ...) \
6767
SimpleFOCDebug::println(F(msg), ##__VA_ARGS__)
6868

69-
#else //ifndef SIMPLEFOC_DISABLE_DEBUG
70-
71-
72-
69+
#else //ifndef SIMPLEFOC_DISABLE_DEBUG
70+
7371
#define SIMPLEFOC_DEBUG(msg, ...)
7472

7573

76-
7774
#endif //ifndef SIMPLEFOC_DISABLE_DEBUG
7875
#endif
7976

src/drivers/hardware_specific/stm32/stm32_mcu.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -177,15 +177,15 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m
177177
uint32_t channel = STM_PIN_CHANNEL(timer->function);
178178
if (handle==NULL) {
179179
handle = stm32_useTimer(timer);
180-
#ifdef SIMPLEFOC_STM32_DEBUG
180+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
181181
SIMPLEFOC_DEBUG("STM32-DRV: Initializing TIM", (int)stm32_getTimerNumber(handle->Instance));
182182
#endif
183183
uint32_t arr = stm32_setClockAndARR(handle, PWM_freq);
184184
if (arr<SIMPLEFOC_STM32_MIN_RESOLUTION) {
185185
SIMPLEFOC_DEBUG("STM32-DRV: WARN timer resolution too low (<8bit): ", (int)arr+1);
186186
}
187187
else {
188-
#ifdef SIMPLEFOC_STM32_DEBUG
188+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
189189
SIMPLEFOC_DEBUG("STM32-DRV: Timer resolution set to: ", (int)arr+1);
190190
#endif
191191
}
@@ -210,7 +210,7 @@ TIM_HandleTypeDef* stm32_initPinPWM(uint32_t PWM_freq, PinMap* timer, uint32_t m
210210
if (IS_TIM_BREAK_INSTANCE(handle->Instance)) {
211211
__HAL_TIM_MOE_ENABLE(handle);
212212
}
213-
#ifdef SIMPLEFOC_STM32_DEBUG
213+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
214214
SimpleFOCDebug::print("STM32-DRV: Configured TIM");
215215
SimpleFOCDebug::print((int)stm32_getTimerNumber(handle->Instance));
216216
SIMPLEFOC_DEBUG("_CH", (int)channel);
@@ -289,7 +289,7 @@ int stm32_checkTimerFrequency(long pwm_frequency, TIM_HandleTypeDef *timers[], u
289289
common_pwm_freq = pwm_freq;
290290
} else {
291291
if (pwm_freq != common_pwm_freq) {
292-
#ifdef SIMPLEFOC_STM32_DEBUG
292+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
293293
SimpleFOCDebug::print("STM32-DRV: ERR: Timer frequency different: TIM");
294294
SimpleFOCDebug::print(stm32_getTimerNumber(timers_distinct[0]->Instance));
295295
SimpleFOCDebug::print(" freq: ");
@@ -303,7 +303,7 @@ int stm32_checkTimerFrequency(long pwm_frequency, TIM_HandleTypeDef *timers[], u
303303
}
304304
}
305305
if ( (common_pwm_freq - (float)pwm_frequency) > 1.0f) {
306-
#ifdef SIMPLEFOC_STM32_DEBUG
306+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
307307
SIMPLEFOC_DEBUG("STM32-DRV: ERR: Common timer frequency unexpected: ", common_pwm_freq);
308308
#endif
309309
return -1;

src/drivers/hardware_specific/stm32/stm32_searchtimers.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ int _stm32_findBestTimerCombination(int numPins, int index, int pins[], PinMap*
149149
score = _stm32_findBestTimerCombination(numPins, index+1, pins, searchArray);
150150
else {
151151
score = _stm32_scoreCombination(numPins, searchArray);
152-
#ifdef SIMPLEFOC_STM32_DEBUG
152+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
153153
stm32_printTimerCombination(numPins, searchArray, score);
154154
#endif
155155
}
@@ -171,13 +171,13 @@ int _stm32_findBestTimerCombination(int numPins, int index, int pins[], PinMap*
171171
int stm32_findBestTimerCombination(int numPins, int pins[], PinMap* pinTimers[]) {
172172
int bestScore = _stm32_findBestTimerCombination(numPins, 0, pins, pinTimers);
173173
if (bestScore == NOT_FOUND) {
174-
#ifdef SIMPLEFOC_STM32_DEBUG
174+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
175175
SimpleFOCDebug::println("STM32-DRV: no workable combination found on these pins");
176176
#endif
177177
return -10; // no workable combination found
178178
}
179179
else if (bestScore >= 0) {
180-
#ifdef SIMPLEFOC_STM32_DEBUG
180+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
181181
SimpleFOCDebug::print("STM32-DRV: best: ");
182182
stm32_printTimerCombination(numPins, pinTimers, bestScore);
183183
#endif

src/drivers/hardware_specific/stm32/stm32_timerutils.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ TIM_HandleTypeDef* stm32_alignTimers(TIM_HandleTypeDef *timers_in[], uint8_t num
510510
}
511511

512512

513-
#ifdef SIMPLEFOC_STM32_DEBUG
513+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
514514
SimpleFOCDebug::print("STM32-DRV: Synchronising ");
515515
SimpleFOCDebug::print(numTimers);
516516
SimpleFOCDebug::println(" timers");
@@ -946,7 +946,7 @@ uint8_t getTimerClkSrc(TIM_TypeDef *tim) {
946946

947947

948948

949-
#ifdef SIMPLEFOC_STM32_DEBUG
949+
#if defined(SIMPLEFOC_STM32_DEBUG) && !defined(SIMPLEFOC_DISABLE_DEBUG)
950950

951951
/*
952952
some utility functions to print out the timer combinations

0 commit comments

Comments
 (0)