STMicroelectronics / stm32l4xx_hal_driver

Provides the STM32Cube MCU Component "hal_driver" of the STM32L4 series.
BSD 3-Clause "New" or "Revised" License
30 stars 14 forks source link

FLASH_SIZE macro definition is not defined. #5

Closed Mculover666 closed 1 year ago

Mculover666 commented 2 years ago

Hi,i am a st mcu developer from china , and i have meet some trouble in stm32l4xx_hal_driver lib, lib version is the code on the master branch of this repo.

The FLASH_SIZE macro definition is not defined but it is used in stm32l4xx_hal_flash.h(842 line) file:

#if defined (STM32L471xx) || defined (STM32L475xx) || defined (STM32L476xx) || defined (STM32L485xx) || defined (STM32L486xx) || \
    defined (STM32L496xx) || defined (STM32L4A6xx) || defined (STM32L4P5xx) || defined (STM32L4Q5xx) || defined (STM32L4R5xx) || \
    defined (STM32L4R7xx) || defined (STM32L4R9xx) || defined (STM32L4S5xx) || defined (STM32L4S7xx) || defined (STM32L4S9xx)
#define FLASH_BANK_SIZE                    (FLASH_SIZE >> 1U)
#else
#define FLASH_BANK_SIZE                    (FLASH_SIZE)
#endif

In addition,i have found this defintion code in the v0.3.0(14-Jan-2015) version:

#define FLASH_SIZE_DATA_REGISTER           ((uint32_t)0x1FFF75E0)

#define FLASH_SIZE                         ((((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) == 0xFFFF)) ? (0x400 << 10) : \
                                            (((*((uint16_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0FFF)) << 10))

so, i want to know why these code is removed in the latest version, and how can i solve this problem?

Thanks!

TOUNSTM commented 1 year ago

Hello @Mculover666,

Let me inform you that these macros has been moved to cmsis_device_l4. For example @lines 1425 & 1427 in stm32l4q5xx.h file you'll find these definitions:

#define FLASH_SIZE_DATA_REGISTER ((uint32_t)0x1FFF75E0)

#define FLASH_SIZE               (((((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU))== 0x0000FFFFU)) ? (0x400U << 10U) : \
                                  (((*((uint32_t *)FLASH_SIZE_DATA_REGISTER)) & (0x0000FFFFU)) << 10U)) 

Best Regards