Browse Source

stm32: Update L4 code to build with latest stm32lib and L4 HAL 1.17.0.

Signed-off-by: Damien George <damien@micropython.org>
pull/8082/head
Damien George 3 years ago
parent
commit
88ac5a3116
  1. 7
      ports/stm32/Makefile
  2. 4
      ports/stm32/adc.h
  3. 9
      ports/stm32/boards/stm32l4xx_hal_conf_base.h
  4. 4
      ports/stm32/machine_adc.c
  5. 8
      ports/stm32/mphalport.h
  6. 4
      ports/stm32/stm32_it.c

7
ports/stm32/Makefile

@ -432,8 +432,13 @@ endif
ifeq ($(CMSIS_MCU),$(filter $(CMSIS_MCU),STM32H743xx STM32H750xx STM32H7A3xx STM32H7A3xxQ STM32H7B3xx STM32H7B3xxQ))
HAL_SRC_C += $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES)xx_, hal_fdcan.c)
else
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),f0 f4 f7 h7 l4))
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),f0 f4 f7 h7))
HAL_SRC_C += $(addprefix $(HAL_DIR)/Src/stm32$(MCU_SERIES)xx_, hal_can.c)
else
ifeq ($(MCU_SERIES),$(filter $(MCU_SERIES),l4))
HAL_SRC_C += $(addprefix $(HAL_DIR)/Src/Legacy/stm32$(MCU_SERIES)xx_, hal_can.c)
$(BUILD)/$(HAL_DIR)/Src/Legacy/stm32$(MCU_SERIES)xx_hal_can.o: CFLAGS += -Wno-error=cpp
endif
endif
endif

4
ports/stm32/adc.h

@ -44,7 +44,7 @@ static inline void adc_deselect_vbat(ADC_TypeDef *adc, uint32_t channel) {
#if defined(STM32F0) || defined(STM32WB)
adc_common = ADC1_COMMON;
#elif defined(STM32F4) || defined(STM32L4)
#elif defined(STM32F4)
adc_common = ADC_COMMON_REGISTER(0);
#elif defined(STM32F7)
adc_common = ADC123_COMMON;
@ -52,6 +52,8 @@ static inline void adc_deselect_vbat(ADC_TypeDef *adc, uint32_t channel) {
adc_common = ADC12_COMMON;
#elif defined(STM32H7)
adc_common = adc == ADC3 ? ADC3_COMMON : ADC12_COMMON;
#elif defined(STM32L4)
adc_common = __LL_ADC_COMMON_INSTANCE(0);
#endif
adc_common->CCR &= ~LL_ADC_PATH_INTERNAL_VBAT;

9
ports/stm32/boards/stm32l4xx_hal_conf_base.h

@ -26,10 +26,13 @@
#ifndef MICROPY_INCLUDED_STM32L4XX_HAL_CONF_BASE_H
#define MICROPY_INCLUDED_STM32L4XX_HAL_CONF_BASE_H
// Needs to be defined before ll_usb.h is included
#define HAL_PCD_MODULE_ENABLED
// Include various HAL modules for convenience
#include "stm32l4xx_hal_dma.h"
#include "stm32l4xx_hal_adc.h"
#include "stm32l4xx_hal_can.h"
#include "Legacy/stm32l4xx_hal_can_legacy.h"
#include "stm32l4xx_hal_cortex.h"
#include "stm32l4xx_hal_crc.h"
#include "stm32l4xx_hal_dac.h"
@ -54,11 +57,12 @@
#include "stm32l4xx_ll_lpuart.h"
#include "stm32l4xx_ll_rtc.h"
#include "stm32l4xx_ll_usart.h"
#include "stm32l4xx_ll_usb.h"
// Enable various HAL modules
#define HAL_MODULE_ENABLED
#define HAL_ADC_MODULE_ENABLED
#define HAL_CAN_MODULE_ENABLED
#define HAL_CAN_LEGACY_MODULE_ENABLED
#define HAL_CORTEX_MODULE_ENABLED
#define HAL_CRC_MODULE_ENABLED
#define HAL_DAC_MODULE_ENABLED
@ -70,7 +74,6 @@
#define HAL_HCD_MODULE_ENABLED
#define HAL_I2C_MODULE_ENABLED
#define HAL_IWDG_MODULE_ENABLED
#define HAL_PCD_MODULE_ENABLED
#define HAL_PWR_MODULE_ENABLED
#define HAL_RCC_MODULE_ENABLED
#define HAL_RTC_MODULE_ENABLED

4
ports/stm32/machine_adc.c

@ -34,10 +34,12 @@
#define ADC_V2 (0)
#endif
#if defined(STM32F4) || defined(STM32L4)
#if defined(STM32F4)
#define ADCx_COMMON ADC_COMMON_REGISTER(0)
#elif defined(STM32F7)
#define ADCx_COMMON ADC123_COMMON
#elif defined(STM32L4)
#define ADCx_COMMON __LL_ADC_COMMON_INSTANCE(0)
#endif
#if defined(STM32F0) || defined(STM32L0)

8
ports/stm32/mphalport.h

@ -2,21 +2,25 @@
#include STM32_HAL_H
#include "pin.h"
// F0-1.9.0+F4-1.16.0+F7-1.7.0+H7-1.6.0+L0-1.11.2+L4-1.8.1+WB-1.10.0
// F0-1.9.0+F4-1.16.0+F7-1.7.0+G4-1.3.0+H7-1.6.0+L0-1.11.2+L4-1.17.0+WB-1.10.0+WL-1.1.0
#if defined(STM32F0)
#define MICROPY_PLATFORM_VERSION "HAL1.9.0"
#elif defined(STM32F4)
#define MICROPY_PLATFORM_VERSION "HAL1.16.0"
#elif defined(STM32F7)
#define MICROPY_PLATFORM_VERSION "HAL1.7.0"
#elif defined(STM32G4)
#define MICROPY_PLATFORM_VERSION "HAL1.3.0"
#elif defined(STM32H7)
#define MICROPY_PLATFORM_VERSION "HAL1.6.0"
#elif defined(STM32L0)
#define MICROPY_PLATFORM_VERSION "HAL1.11.2"
#elif defined(STM32L4)
#define MICROPY_PLATFORM_VERSION "HAL1.8.1"
#define MICROPY_PLATFORM_VERSION "HAL1.17.0"
#elif defined(STM32WB)
#define MICROPY_PLATFORM_VERSION "HAL1.10.0"
#elif defined(STM32WL)
#define MICROPY_PLATFORM_VERSION "HAL1.1.0"
#endif
extern const unsigned char mp_hal_status_to_errno_table[4];

4
ports/stm32/stm32_it.c

@ -395,7 +395,9 @@ void OTG_FS_WKUP_IRQHandler(void) {
OTG_CMD_WKUP_Handler(&pcd_fs_handle);
#if !defined(STM32H7)
#if defined(STM32L4)
EXTI->PR1 = USB_OTG_FS_WAKEUP_EXTI_LINE;
#elif !defined(STM32H7)
/* Clear EXTI pending Bit*/
__HAL_USB_FS_EXTI_CLEAR_FLAG();
#endif

Loading…
Cancel
Save