断言的配置
在 LL 库中,默认使用了断言(assert),断言的定义位于文件 stm32_assert.h 中。如果要使用默认的断言,则该文件要求,在自己的编译工具链中定义宏值 USE_FULL_ASSERT。注意,如果与 HAL 库混合使用,可能会导致重定义(HAL 库中也存在默认断言的定义)。使用时自己注意一下!
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef STM32_ASSERT_H
#define STM32_ASSERT_H
#ifdef __cplusplus
extern "C" {
#endif
/* Exported types ------------------------------------------------------------*/
/* Exported constants --------------------------------------------------------*/
/* Includes ------------------------------------------------------------------*/
/* Exported macro ------------------------------------------------------------*/
#ifdef USE_FULL_ASSERT
/**
* @brief The assert_param macro is used for function's parameters check.
* @param expr: If expr is false, it calls assert_failed function
* which reports the name of the source file and the source
* line number of the call that failed.
* If expr is true, it returns no value.
* @retval None
*/
#define assert_param(expr) ((expr) ? (void)0U : assert_failed((char *)__FILE__, __LINE__))
/* Exported functions ------------------------------------------------------- */
void assert_failed(char *file, uint32_t line);
#else
#define assert_param(expr) ((void)0U)
#endif /* USE_FULL_ASSERT */
#ifdef __cplusplus
}
#endif
#endif /* STM32_ASSERT_H */
配置使用的芯片类型 LL 库本身支持多个系列的 MCU,我们必须要配置使用的芯片型号。这是 CMSIS 中的 stm32l4xx.h 文件中要求的。如下是未配置之前的原文件部分内容: /** @addtogroup Library_configuration_section * @{ */
/** * @brief STM32 Family */ #if !defined (STM32L4) #define STM32L4 #endif /* STM32L4 */
/* Uncomment the line below according to the target STM32L4 device used in your application */
#if !defined (STM32L412xx) && !defined (STM32L422xx) && \ !defined (STM32L431xx) && !defined (STM32L432xx) && !defined (STM32L433xx) && !defined (STM32L442xx) && !defined (STM32L443xx) && \ !defined (STM32L451xx) && !defined (STM32L452xx) && !defined (STM32L462xx) && \ !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 STM32L412xx */ /*!< STM32L412xx Devices */ /* #define STM32L422xx */ /*!< STM32L422xx Devices */ /* #define STM32L431xx */ /*!< STM32L431xx Devices */ /* #define STM32L432xx */ /*!< STM32L432xx Devices */ /* #define STM32L433xx */ /*!< STM32L433xx Devices */ /* #define STM32L442xx */ /*!< STM32L442xx Devices */ /* #define STM32L443xx */ /*!< STM32L443xx Devices */ /* #define STM32L451xx */ /*!< STM32L451xx Devices */ /* #define STM32L452xx */ /*!< STM32L452xx Devices */ /* #define STM32L462xx */ /*!< STM32L462xx Devices */ /* #define STM32L471xx */ /*!< STM32L471xx Devices */ /* #define STM32L475xx */ /*!< STM32L475xx Devices */ /* #define STM32L476xx */ /*!< STM32L476xx Devices */ /* #define STM32L485xx */ /*!< STM32L485xx Devices */ /* #define STM32L486xx */ /*!< STM32L486xx Devices */ /* #define STM32L496xx */ /*!< STM32L496xx Devices */ /* #define STM32L4A6xx */ /*!< STM32L4A6xx Devices */ /* #define STM32L4P5xx */ /*!< STM32L4Q5xx Devices */ /* #define STM32L4R5xx */ /*!< STM32L4R5xx Devices */ /* #define STM32L4R7xx */ /*!< STM32L4R7xx Devices */ /* #define STM32L4R9xx */ /*!< STM32L4R9xx Devices */ /* #define STM32L4S5xx */ /*!< STM32L4S5xx Devices */ /* #define STM32L4S7xx */ /*!< STM32L4S7xx Devices */ /* #define STM32L4S9xx */ /*!< STM32L4S9xx Devices */ #endif
/* Tip: To avoid modifying this file each time you need to switch between these devices, you can define the device in your toolchain compiler preprocessor. */
通常,我们是把需要的芯片类型定义到自己的编译工具链中,而不是去修改该文件!
|