Skip to content

Commit 72262ca

Browse files
committed
MTS targets: Don't use any printf() calls when NDEBUG is defined, prevents linking out printf() and friends in release build
1 parent 4978a08 commit 72262ca

File tree

4 files changed

+16
-4
lines changed

4 files changed

+16
-4
lines changed

targets/TARGET_STM/TARGET_STM32F4/TARGET_MTS_DRAGONFLY_F411RE/device/system_clock.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,8 @@ uint8_t SetSysClock_PLL_HSI(void)
240240
/******************************************************************************/
241241
void HardFault_Handler(void)
242242
{
243+
#if !defined(NDEBUG) || NDEBUG == 0
243244
printf("Hard Fault\n");
245+
#endif
244246
NVIC_SystemReset();
245247
}

targets/TARGET_STM/TARGET_STM32F4/TARGET_MTS_MDOT_F411RE/device/system_clock.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,8 @@ uint8_t SetSysClock_PLL_HSI(void)
243243
/******************************************************************************/
244244
void HardFault_Handler(void)
245245
{
246+
#if !defined(NDEBUG) || NDEBUG == 0
246247
printf("Hard Fault\n");
248+
#endif
247249
NVIC_SystemReset();
248250
}

targets/TARGET_STM/TARGET_STM32L1/TARGET_XDOT_L151CC/device/system_clock.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
/*!< Uncomment the following line if you need to relocate your vector Table in
4242
Internal SRAM. */
4343
/* #define VECT_TAB_SRAM */
44-
#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field.
44+
#define VECT_TAB_OFFSET 0x0 /*!< Vector Table base offset field.
4545
This value must be a multiple of 0x200. */
4646

4747
/* Select the clock sources (other than HSI) to start with (0=OFF, 1=ON) */
@@ -253,7 +253,9 @@ uint8_t SetSysClock_PLL_HSI(void)
253253
/******************************************************************************/
254254
void HardFault_Handler(void)
255255
{
256+
#if !defined(NDEBUG) || NDEBUG == 0
256257
printf("Hard Fault\n");
258+
#endif
257259
NVIC_SystemReset();
258260
}
259261

targets/TARGET_STM/TARGET_STM32L1/TARGET_XDOT_L151CC/xdot_low_power.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
#include "xdot_low_power.h"
3232
#include "stdio.h"
3333

34+
#if defined(NDEBUG) && NDEBUG == 1
35+
#define xdot_lp_debug(...) do {} while(0)
36+
#else
37+
#define xdot_lp_debug(...) printf(__VA_ARGS__)
38+
#endif
39+
3440
static uint32_t portA[6];
3541
static uint32_t portB[6];
3642
static uint32_t portC[6];
@@ -230,7 +236,7 @@ void xdot_enter_stop_mode() {
230236
HSERCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL4;
231237
HSERCC_OscInitStruct.PLL.PLLDIV = RCC_PLL_DIV3;
232238
if (HAL_RCC_OscConfig(&HSERCC_OscInitStruct) != HAL_OK) {
233-
printf("OSC initialization failed - initiating soft reset\r\n");
239+
xdot_lp_debug("OSC initialization failed - initiating soft reset\r\n");
234240
NVIC_SystemReset();
235241
}
236242

@@ -241,7 +247,7 @@ void xdot_enter_stop_mode() {
241247
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1; // 32 MHz
242248
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1; // 32 MHz
243249
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_1) != HAL_OK) {
244-
printf("PLL initialization failed - initiating soft reset\r\n");
250+
xdot_lp_debug("PLL initialization failed - initiating soft reset\r\n");
245251
NVIC_SystemReset();
246252
}
247253

@@ -254,7 +260,7 @@ void xdot_enter_stop_mode() {
254260
HSIRCC_OscInitStruct.PLL.PLLState = RCC_PLL_NONE;
255261
HAL_StatusTypeDef ret = HAL_RCC_OscConfig(&HSIRCC_OscInitStruct);
256262
if ( ret != HAL_OK ) {
257-
printf("HSI initialization failed - ADC will not function properly\r\n");
263+
xdot_lp_debug("HSI initialization failed - ADC will not function properly\r\n");
258264
}
259265
}
260266

0 commit comments

Comments
 (0)