From b5e28baf453d978c438332e19fa1b63b6f30eaa0 Mon Sep 17 00:00:00 2001 From: Jerome Coutant Date: Fri, 10 Dec 2021 14:28:46 +0100 Subject: [PATCH 1/6] STM32 CAN : remove warning [-Wsign-compare] Detected with NUCLEO_G474RE build: [Warning] stm32g4xx_hal_fdcan.h@1325,84: comparison is always true due to limited range of data type [-Wtype-limits] [Warning] stm32g4xx_hal_fdcan.h@1331,46: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] [Warning] stm32g4xx_hal_fdcan.h@1331,65: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] [Warning] stm32g4xx_hal_fdcan.h@1325,61: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] [Warning] stm32g4xx_hal_fdcan.h@1325,84: comparison of integer expressions of different signedness: 'int' and 'unsigned int' [-Wsign-compare] --- targets/TARGET_STM/can_api.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/targets/TARGET_STM/can_api.c b/targets/TARGET_STM/can_api.c index ad00e39a2b..a2f34a96df 100644 --- a/targets/TARGET_STM/can_api.c +++ b/targets/TARGET_STM/can_api.c @@ -142,16 +142,16 @@ static void _can_init_freq_direct(can_t *obj, const can_pinmap_t *pinmap, int hz // We use PLL1.Q clock right now so get its frequency PLL1_ClocksTypeDef pll1_clocks; HAL_RCCEx_GetPLL1ClockFreq(&pll1_clocks); - int ntq = pll1_clocks.PLL1_Q_Frequency / hz; + uint32_t ntq = pll1_clocks.PLL1_Q_Frequency / (uint32_t)hz; #else #if (defined RCC_PERIPHCLK_FDCAN1) - int ntq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_FDCAN1) / hz; + uint32_t ntq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_FDCAN1) / (uint32_t)hz; #else - int ntq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_FDCAN) / hz; + uint32_t ntq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_FDCAN) / (uint32_t)hz; #endif #endif - int nominalPrescaler = 1; + uint32_t nominalPrescaler = 1; // !When the sample point should be lower than 50%, this must be changed to // !IS_FDCAN_NOMINAL_TSEG2(ntq/nominalPrescaler), since // NTSEG2 and SJW max values are lower. For now the sample point is fix @75% @@ -322,16 +322,16 @@ int can_frequency(can_t *obj, int f) // STM32H7 doesn't support yet HAL_RCCEx_GetPeriphCLKFreq for FDCAN PLL1_ClocksTypeDef pll1_clocks; HAL_RCCEx_GetPLL1ClockFreq(&pll1_clocks); - int ntq = pll1_clocks.PLL1_Q_Frequency / f; + uint32_t ntq = pll1_clocks.PLL1_Q_Frequency / (uint32_t)f; #else #if (defined RCC_PERIPHCLK_FDCAN1) - int ntq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_FDCAN1) / f; + uint32_t ntq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_FDCAN1) / (uint32_t)f; #else - int ntq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_FDCAN) / f; + uint32_t ntq = HAL_RCCEx_GetPeriphCLKFreq(RCC_PERIPHCLK_FDCAN) / (uint32_t)f; #endif #endif - int nominalPrescaler = 1; + uint32_t nominalPrescaler = 1; // !When the sample point should be lower than 50%, this must be changed to // !IS_FDCAN_DATA_TSEG2(ntq/nominalPrescaler), since // NTSEG2 and SJW max values are lower. For now the sample point is fix @75% From 999d98a3d78b81ba2a4c78984cdcaf05a53321a9 Mon Sep 17 00:00:00 2001 From: Jerome Coutant Date: Fri, 10 Dec 2021 14:30:01 +0100 Subject: [PATCH 2/6] STM32L4 : remove warning This is the MBED current implementation, no need to warn --- .../STM32L4xx_HAL_Driver/Legacy/stm32l4xx_hal_can_legacy.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/targets/TARGET_STM/TARGET_STM32L4/STM32Cube_FW/STM32L4xx_HAL_Driver/Legacy/stm32l4xx_hal_can_legacy.c b/targets/TARGET_STM/TARGET_STM32L4/STM32Cube_FW/STM32L4xx_HAL_Driver/Legacy/stm32l4xx_hal_can_legacy.c index 8797ec0c54..9dfe829be3 100644 --- a/targets/TARGET_STM/TARGET_STM32L4/STM32Cube_FW/STM32L4xx_HAL_Driver/Legacy/stm32l4xx_hal_can_legacy.c +++ b/targets/TARGET_STM/TARGET_STM32L4/STM32Cube_FW/STM32L4xx_HAL_Driver/Legacy/stm32l4xx_hal_can_legacy.c @@ -104,7 +104,8 @@ #error 'The HAL CAN driver cannot be used with its legacy, Please ensure to enable only one HAL CAN module at once in stm32l4xx_hal_conf.h file' #endif /* HAL_CAN_MODULE_ENABLED */ -#warning 'Legacy HAL CAN driver is enabled! It can be used with known limitations, refer to the release notes. However it is recommended to use rather the new HAL CAN driver' +// MBED current implementation +// #warning 'Legacy HAL CAN driver is enabled! It can be used with known limitations, refer to the release notes. However it is recommended to use rather the new HAL CAN driver' #if defined(CAN1) From 1bf801a4f76ea13852e47496c11a95a5b9aaa70c Mon Sep 17 00:00:00 2001 From: Jerome Coutant Date: Fri, 10 Dec 2021 14:36:34 +0100 Subject: [PATCH 3/6] STM32G4 : remove warning [Warning] serial_device.c@644,41: comparison of integer expressions of different signedness: 'PinName' and 'enum ' [-Wsign-compare] [Warning] serial_device.c@644,41: comparison between 'PinName' and 'enum ' [-Wenum-compare] [Warning] serial_device.c@653,41: comparison of integer expressions of different signedness: 'PinName' and 'enum ' [-Wsign-compare] [Warning] serial_device.c@653,41: comparison between 'PinName' and 'enum ' [-Wenum-compare] [Warning] serial_device.c@662,41: comparison of integer expressions of different signedness: 'PinName' and 'enum ' [-Wsign-compare] [Warning] serial_device.c@662,41: comparison between 'PinName' and 'enum ' [-Wenum-compare] [Warning] serial_device.c@663,41: comparison of integer expressions of different signedness: 'PinName' and 'enum ' [-Wsign-compare] [Warning] serial_device.c@663,41: comparison between 'PinName' and 'enum ' [-Wenum-compare] [Warning] stm32g4xx_hal_hrtim.c@1817,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32g4xx_hal_hrtim.c@1821,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32g4xx_hal_hrtim.c@2461,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32g4xx_hal_hrtim.c@2465,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32g4xx_hal_hrtim.c@6600,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32g4xx_hal_hrtim.c@7162,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32g4xx_hal_hrtim.c@7166,21: equality comparison with extraneous parentheses [-Wparentheses-equality] --- .../stm32g4xx_hal_hrtim.c | 20 +++++++++---------- .../TARGET_STM/TARGET_STM32G4/serial_device.c | 8 ++++---- 2 files changed, 14 insertions(+), 14 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32G4/STM32Cube_FW/STM32G4xx_HAL_Driver/stm32g4xx_hal_hrtim.c b/targets/TARGET_STM/TARGET_STM32G4/STM32Cube_FW/STM32G4xx_HAL_Driver/stm32g4xx_hal_hrtim.c index 19a03051f1..30782b7d5d 100644 --- a/targets/TARGET_STM/TARGET_STM32G4/STM32Cube_FW/STM32G4xx_HAL_Driver/stm32g4xx_hal_hrtim.c +++ b/targets/TARGET_STM/TARGET_STM32G4/STM32Cube_FW/STM32G4xx_HAL_Driver/stm32g4xx_hal_hrtim.c @@ -1814,13 +1814,13 @@ HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart_DMA(HRTIM_HandleTypeDef * hhrtim, /* Check the parameters */ assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel)); - if((hhrtim->State == HAL_HRTIM_STATE_BUSY)) + if (hhrtim->State == HAL_HRTIM_STATE_BUSY) { return HAL_BUSY; } - if((hhrtim->State == HAL_HRTIM_STATE_READY)) + if (hhrtim->State == HAL_HRTIM_STATE_READY) { - if((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U)) + if ((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U)) { return HAL_ERROR; } @@ -2458,13 +2458,13 @@ HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart_DMA(HRTIM_HandleTypeDef * hhrtim, /* Check the parameters */ assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel)); - if((hhrtim->State == HAL_HRTIM_STATE_BUSY)) + if (hhrtim->State == HAL_HRTIM_STATE_BUSY) { return HAL_BUSY; } - if((hhrtim->State == HAL_HRTIM_STATE_READY)) + if (hhrtim->State == HAL_HRTIM_STATE_READY) { - if((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U)) + if ((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U)) { return HAL_ERROR; } @@ -6597,7 +6597,7 @@ HAL_StatusTypeDef HAL_HRTIM_WaveformCountStart_DMA(HRTIM_HandleTypeDef * hhrtim, /* Check the parameters */ assert_param(IS_HRTIM_TIMERID(Timers)); - if((hhrtim->State == HAL_HRTIM_STATE_BUSY)) + if (hhrtim->State == HAL_HRTIM_STATE_BUSY) { return HAL_BUSY; } @@ -7159,13 +7159,13 @@ HAL_StatusTypeDef HAL_HRTIM_BurstDMATransfer(HRTIM_HandleTypeDef *hhrtim, /* Check the parameters */ assert_param(IS_HRTIM_TIMERINDEX(TimerIdx)); - if((hhrtim->State == HAL_HRTIM_STATE_BUSY)) + if (hhrtim->State == HAL_HRTIM_STATE_BUSY) { return HAL_BUSY; } - if((hhrtim->State == HAL_HRTIM_STATE_READY)) + if (hhrtim->State == HAL_HRTIM_STATE_READY) { - if((BurstBufferAddress == 0U ) || (BurstBufferLength == 0U)) + if ((BurstBufferAddress == 0U ) || (BurstBufferLength == 0U)) { return HAL_ERROR; } diff --git a/targets/TARGET_STM/TARGET_STM32G4/serial_device.c b/targets/TARGET_STM/TARGET_STM32G4/serial_device.c index 131812e184..b452c64b13 100644 --- a/targets/TARGET_STM/TARGET_STM32G4/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32G4/serial_device.c @@ -641,7 +641,7 @@ static void _serial_set_flow_control_direct(serial_t *obj, FlowControl type, con } if (type == FlowControlRTS) { // Enable RTS - MBED_ASSERT(pinmap->rx_flow_pin != (UARTName)NC); + MBED_ASSERT(pinmap->rx_flow_pin != NC); obj_s->hw_flow_ctl = UART_HWCONTROL_RTS; obj_s->pin_rts = pinmap->rx_flow_pin; // Enable the pin for RTS function @@ -650,7 +650,7 @@ static void _serial_set_flow_control_direct(serial_t *obj, FlowControl type, con } if (type == FlowControlCTS) { // Enable CTS - MBED_ASSERT(pinmap->tx_flow_pin != (UARTName)NC); + MBED_ASSERT(pinmap->tx_flow_pin != NC); obj_s->hw_flow_ctl = UART_HWCONTROL_CTS; obj_s->pin_cts = pinmap->tx_flow_pin; // Enable the pin for CTS function @@ -659,8 +659,8 @@ static void _serial_set_flow_control_direct(serial_t *obj, FlowControl type, con } if (type == FlowControlRTSCTS) { // Enable CTS & RTS - MBED_ASSERT(pinmap->rx_flow_pin != (UARTName)NC); - MBED_ASSERT(pinmap->tx_flow_pin != (UARTName)NC); + MBED_ASSERT(pinmap->rx_flow_pin != NC); + MBED_ASSERT(pinmap->tx_flow_pin != NC); obj_s->hw_flow_ctl = UART_HWCONTROL_RTS_CTS; obj_s->pin_rts = pinmap->rx_flow_pin;; obj_s->pin_cts = pinmap->tx_flow_pin;; From 4d63929898de6088c770aa278951ad0e4f2baedd Mon Sep 17 00:00:00 2001 From: Jerome Coutant Date: Fri, 10 Dec 2021 14:45:48 +0100 Subject: [PATCH 4/6] STM32L5 : remove warning [Warning] serial_device.c@657,41: comparison of different enumeration types ('PinName' and 'UARTName') [-Wenum-compare] [Warning] serial_device.c@666,41: comparison of different enumeration types ('PinName' and 'UARTName') [-Wenum-compare] [Warning] serial_device.c@675,41: comparison of different enumeration types ('PinName' and 'UARTName') [-Wenum-compare] [Warning] serial_device.c@676,41: comparison of different enumeration types ('PinName' and 'UARTName') [-Wenum-compare] --- targets/TARGET_STM/TARGET_STM32L5/serial_device.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32L5/serial_device.c b/targets/TARGET_STM/TARGET_STM32L5/serial_device.c index 3f8ed5413b..6a321f4822 100644 --- a/targets/TARGET_STM/TARGET_STM32L5/serial_device.c +++ b/targets/TARGET_STM/TARGET_STM32L5/serial_device.c @@ -654,7 +654,7 @@ static void _serial_set_flow_control_direct(serial_t *obj, FlowControl type, con } if (type == FlowControlRTS) { // Enable RTS - MBED_ASSERT(pinmap->rx_flow_pin != (UARTName)NC); + MBED_ASSERT(pinmap->rx_flow_pin != NC); obj_s->hw_flow_ctl = UART_HWCONTROL_RTS; obj_s->pin_rts = pinmap->rx_flow_pin; // Enable the pin for RTS function @@ -663,7 +663,7 @@ static void _serial_set_flow_control_direct(serial_t *obj, FlowControl type, con } if (type == FlowControlCTS) { // Enable CTS - MBED_ASSERT(pinmap->tx_flow_pin != (UARTName)NC); + MBED_ASSERT(pinmap->tx_flow_pin != NC); obj_s->hw_flow_ctl = UART_HWCONTROL_CTS; obj_s->pin_cts = pinmap->tx_flow_pin; // Enable the pin for CTS function @@ -672,8 +672,8 @@ static void _serial_set_flow_control_direct(serial_t *obj, FlowControl type, con } if (type == FlowControlRTSCTS) { // Enable CTS & RTS - MBED_ASSERT(pinmap->rx_flow_pin != (UARTName)NC); - MBED_ASSERT(pinmap->tx_flow_pin != (UARTName)NC); + MBED_ASSERT(pinmap->rx_flow_pin != NC); + MBED_ASSERT(pinmap->tx_flow_pin != NC); obj_s->hw_flow_ctl = UART_HWCONTROL_RTS_CTS; obj_s->pin_rts = pinmap->rx_flow_pin;; obj_s->pin_cts = pinmap->tx_flow_pin;; From 3237bff990167862b2ecf5f9a0a8b4277ac9d933 Mon Sep 17 00:00:00 2001 From: Jerome Coutant Date: Fri, 10 Dec 2021 16:35:23 +0100 Subject: [PATCH 5/6] STM32F7 : remove warning [Warning] flash_api.c@191,14: unused variable 'tmp' [-Wunused-variable] --- targets/TARGET_STM/TARGET_STM32F7/flash_api.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/targets/TARGET_STM/TARGET_STM32F7/flash_api.c b/targets/TARGET_STM/TARGET_STM32F7/flash_api.c index 94034fdd86..e7da2142f4 100644 --- a/targets/TARGET_STM/TARGET_STM32F7/flash_api.c +++ b/targets/TARGET_STM/TARGET_STM32F7/flash_api.c @@ -188,8 +188,9 @@ uint32_t flash_get_size(const flash_t *obj) static uint32_t GetSector(uint32_t address) { uint32_t sector = 0; - uint32_t tmp = address - ADDR_FLASH_SECTOR_0; + #if (MBED_CONF_TARGET_FLASH_DUAL_BANK) && defined(FLASH_OPTCR_nDBANK) + uint32_t tmp = address - ADDR_FLASH_SECTOR_0; if (address < ADDR_FLASH_SECTOR_4) { // Sectors 0 to 3 sector += tmp >> 14; } else if (address < ADDR_FLASH_SECTOR_5) { // Sector 4 From de3f9efb67b7d1bef5adb5f5159fd335acf607e0 Mon Sep 17 00:00:00 2001 From: Jerome Coutant Date: Fri, 10 Dec 2021 16:47:57 +0100 Subject: [PATCH 6/6] STM32H7 : remove warning [Warning] stm32h7xx_hal_hrtim.c@1621,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32h7xx_hal_hrtim.c@1625,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32h7xx_hal_hrtim.c@2238,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32h7xx_hal_hrtim.c@2242,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32h7xx_hal_hrtim.c@5332,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32h7xx_hal_hrtim.c@5767,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] stm32h7xx_hal_hrtim.c@5771,21: equality comparison with extraneous parentheses [-Wparentheses-equality] [Warning] analogin_device.c@63,30: comparison between 'PinName' and 'enum ' [-Wenum-compare] --- .../stm32h7xx_hal_hrtim.c | 20 +++++++++---------- .../TARGET_STM32H7/analogin_device.c | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_hrtim.c b/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_hrtim.c index 1d7efa1377..582ebbd405 100644 --- a/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_hrtim.c +++ b/targets/TARGET_STM/TARGET_STM32H7/STM32Cube_FW/STM32H7xx_HAL_Driver/stm32h7xx_hal_hrtim.c @@ -1618,13 +1618,13 @@ HAL_StatusTypeDef HAL_HRTIM_SimpleOCStart_DMA(HRTIM_HandleTypeDef * hhrtim, /* Check the parameters */ assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, OCChannel)); - if((hhrtim->State == HAL_HRTIM_STATE_BUSY)) + if (hhrtim->State == HAL_HRTIM_STATE_BUSY) { return HAL_BUSY; } - if((hhrtim->State == HAL_HRTIM_STATE_READY)) + if (hhrtim->State == HAL_HRTIM_STATE_READY) { - if((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U)) + if ((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U)) { return HAL_ERROR; } @@ -2235,13 +2235,13 @@ HAL_StatusTypeDef HAL_HRTIM_SimplePWMStart_DMA(HRTIM_HandleTypeDef * hhrtim, /* Check the parameters */ assert_param(IS_HRTIM_TIMER_OUTPUT(TimerIdx, PWMChannel)); - if((hhrtim->State == HAL_HRTIM_STATE_BUSY)) + if (hhrtim->State == HAL_HRTIM_STATE_BUSY) { return HAL_BUSY; } - if((hhrtim->State == HAL_HRTIM_STATE_READY)) + if (hhrtim->State == HAL_HRTIM_STATE_READY) { - if((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U)) + if ((SrcAddr == 0U ) || (DestAddr == 0U ) || (Length == 0U)) { return HAL_ERROR; } @@ -5329,7 +5329,7 @@ HAL_StatusTypeDef HAL_HRTIM_WaveformCountStart_DMA(HRTIM_HandleTypeDef * hhrtim, /* Check the parameters */ assert_param(IS_HRTIM_TIMERID(Timers)); - if((hhrtim->State == HAL_HRTIM_STATE_BUSY)) + if (hhrtim->State == HAL_HRTIM_STATE_BUSY) { return HAL_BUSY; } @@ -5764,13 +5764,13 @@ HAL_StatusTypeDef HAL_HRTIM_BurstDMATransfer(HRTIM_HandleTypeDef *hhrtim, /* Check the parameters */ assert_param(IS_HRTIM_TIMERINDEX(TimerIdx)); - if((hhrtim->State == HAL_HRTIM_STATE_BUSY)) + if (hhrtim->State == HAL_HRTIM_STATE_BUSY) { return HAL_BUSY; } - if((hhrtim->State == HAL_HRTIM_STATE_READY)) + if (hhrtim->State == HAL_HRTIM_STATE_READY) { - if((BurstBufferAddress == 0U ) || (BurstBufferLength == 0U)) + if ((BurstBufferAddress == 0U ) || (BurstBufferLength == 0U)) { return HAL_ERROR; } diff --git a/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c b/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c index 3fb41a7997..449b3a3e01 100644 --- a/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c +++ b/targets/TARGET_STM/TARGET_STM32H7/analogin_device.c @@ -60,7 +60,7 @@ void analogin_init(analogin_t *obj, PinName pin) // ADC Internal Channels "pins" (Temperature, Vref, Vbat, ...) // are described in PinNames.h and PeripheralPins.c // Pin value must be between 0xF0 and 0xFF - if ((pin < 0xF0) || (pin >= ALT0)) { + if ((pin < 0xF0) || (pin >= (PinName)ALT0)) { // Normal channels // Get the peripheral name from the pin and assign it to the object obj->handle.Instance = (ADC_TypeDef *)pinmap_peripheral(pin, PinMap_ADC);