- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* 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((uint8_t *)__FILE__, __LINE__))
-/* Exported functions ------------------------------------------------------- */
- void assert_failed(uint8_t* file, uint32_t line);
-#else
- #define assert_param(expr) ((void)0U)
-#endif /* USE_FULL_ASSERT */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __STM32_ASSERT_H */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal.h b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal.h
deleted file mode 100644
index e3d4967d057..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal.h
+++ /dev/null
@@ -1,996 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal.h
- * @author MCD Application Team
- * @brief This file contains all the functions prototypes for the HAL
- * module driver.
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STM32L1xx_HAL_DEF
-#define __STM32L1xx_HAL_DEF
-
-#ifdef __cplusplus
- extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx.h"
-#include "Legacy/stm32_hal_legacy.h"
-#include
-
-/* Exported types ------------------------------------------------------------*/
-
-/**
- * @brief HAL Status structures definition
- */
-typedef enum
-{
- HAL_OK = 0x00U,
- HAL_ERROR = 0x01U,
- HAL_BUSY = 0x02U,
- HAL_TIMEOUT = 0x03U
-} HAL_StatusTypeDef;
-
-/**
- * @brief HAL Lock structures definition
- */
-typedef enum
-{
- HAL_UNLOCKED = 0x00U,
- HAL_LOCKED = 0x01U
-} HAL_LockTypeDef;
-
-/* Exported macro ------------------------------------------------------------*/
-
-#define UNUSED(X) (void)X /* To avoid gcc/g++ warnings */
-
-#define HAL_MAX_DELAY 0xFFFFFFFFU
-
-#define HAL_IS_BIT_SET(REG, BIT) (((REG) & (BIT)) == (BIT))
-#define HAL_IS_BIT_CLR(REG, BIT) (((REG) & (BIT)) == 0U)
-
-#define __HAL_LINKDMA(__HANDLE__, __PPP_DMA_FIELD_, __DMA_HANDLE_) \
- do{ \
- (__HANDLE__)->__PPP_DMA_FIELD_ = &(__DMA_HANDLE_); \
- (__DMA_HANDLE_).Parent = (__HANDLE__); \
- } while(0)
-
-/** @brief Reset the Handle's State field.
- * @param __HANDLE__: specifies the Peripheral Handle.
- * @note This macro can be used for the following purpose:
- * - When the Handle is declared as local variable; before passing it as parameter
- * to HAL_PPP_Init() for the first time, it is mandatory to use this macro
- * to set to 0 the Handle's "State" field.
- * Otherwise, "State" field may have any random value and the first time the function
- * HAL_PPP_Init() is called, the low level hardware initialization will be missed
- * (i.e. HAL_PPP_MspInit() will not be executed).
- * - When there is a need to reconfigure the low level hardware: instead of calling
- * HAL_PPP_DeInit() then HAL_PPP_Init(), user can make a call to this macro then HAL_PPP_Init().
- * In this later function, when the Handle's "State" field is set to 0, it will execute the function
- * HAL_PPP_MspInit() which will reconfigure the low level hardware.
- * @retval None
- */
-#define __HAL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = 0U)
-
-#if (USE_RTOS == 1)
-
- /* Reserved for future use */
- #error "USE_RTOS should be 0 in the current HAL release"
-
-#else
- #define __HAL_LOCK(__HANDLE__) \
- do{ \
- if((__HANDLE__)->Lock == HAL_LOCKED) \
- { \
- return HAL_BUSY; \
- } \
- else \
- { \
- (__HANDLE__)->Lock = HAL_LOCKED; \
- } \
- }while (0)
-
- #define __HAL_UNLOCK(__HANDLE__) \
- do{ \
- (__HANDLE__)->Lock = HAL_UNLOCKED; \
- }while (0)
-#endif /* USE_RTOS */
-
-#if defined ( __GNUC__ ) && !defined (__CC_ARM) /* GNU Compiler */
- #ifndef __weak
- #define __weak __attribute__((weak))
- #endif /* __weak */
- #ifndef __packed
- #define __packed __attribute__((__packed__))
- #endif /* __packed */
-#endif /* __GNUC__ */
-
-
-/* Macro to get variable aligned on 4-bytes, for __ICCARM__ the directive "#pragma data_alignment=4" must be used instead */
-#if defined (__GNUC__) && !defined (__CC_ARM) /* GNU Compiler */
- #ifndef __ALIGN_END
- #define __ALIGN_END __attribute__ ((aligned (4)))
- #endif /* __ALIGN_END */
- #ifndef __ALIGN_BEGIN
- #define __ALIGN_BEGIN
- #endif /* __ALIGN_BEGIN */
-#else
- #ifndef __ALIGN_END
- #define __ALIGN_END
- #endif /* __ALIGN_END */
- #ifndef __ALIGN_BEGIN
- #if defined (__CC_ARM) /* ARM Compiler */
- #define __ALIGN_BEGIN __align(4)
- #elif defined (__ICCARM__) /* IAR Compiler */
- #define __ALIGN_BEGIN
- #endif /* __CC_ARM */
- #endif /* __ALIGN_BEGIN */
-#endif /* __GNUC__ */
-
-/**
- * @brief __RAM_FUNC definition
- */
-#if defined ( __CC_ARM )
-/* ARM Compiler
- ------------
- RAM functions are defined using the toolchain options.
- Functions that are executed in RAM should reside in a separate source module.
- Using the 'Options for File' dialog you can simply change the 'Code / Const'
- area of a module to a memory space in physical RAM.
- Available memory areas are declared in the 'Target' tab of the 'Options for Target'
- dialog.
-*/
-#define __RAM_FUNC
-
-#elif defined ( __ICCARM__ )
-/* ICCARM Compiler
- ---------------
- RAM functions are defined using a specific toolchain keyword "__ramfunc".
-*/
-#define __RAM_FUNC __ramfunc
-
-#elif defined ( __GNUC__ )
-/* GNU Compiler
- ------------
- RAM functions are defined using a specific toolchain attribute
- "__attribute__((section(".RamFunc")))".
-*/
-#define __RAM_FUNC __attribute__((section(".RamFunc")))
-
-#endif
-
-/**
- * @brief __NOINLINE definition
- */
-#if defined ( __CC_ARM ) || defined ( __GNUC__ )
-/* ARM & GNUCompiler
- ----------------
-*/
-#define __NOINLINE __attribute__ ( (noinline) )
-
-#elif defined ( __ICCARM__ )
-/* ICCARM Compiler
- ---------------
-*/
-#define __NOINLINE _Pragma("optimize = no_inline")
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* ___STM32L1xx_HAL_DEF */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_dma.h b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_dma.h
deleted file mode 100644
index 2baafbcea0b..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Inc/stm32l1xx_hal_dma.h
+++ /dev/null
@@ -1,652 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_dma.h
- * @author MCD Application Team
- * @brief Header file of DMA HAL module.
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Define to prevent recursive inclusion -------------------------------------*/
-#ifndef __STM32L1xx_LL_ADC_H
-#define __STM32L1xx_LL_ADC_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx.h"
-
-/** @addtogroup STM32L1xx_LL_Driver
- * @{
- */
-
-#if defined (ADC1)
-
-/** @defgroup ADC_LL ADC
- * @{
- */
-
-/* Private types -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-
-/* Private constants ---------------------------------------------------------*/
-/** @defgroup ADC_LL_Private_Constants ADC Private Constants
- * @{
- */
-
-/* Internal mask for ADC group regular sequencer: */
-/* To select into literal LL_ADC_REG_RANK_x the relevant bits for: */
-/* - sequencer register offset */
-/* - sequencer rank bits position into the selected register */
-
-/* Internal register offset for ADC group regular sequencer configuration */
-/* (offset placed into a spare area of literal definition) */
-#define ADC_SQR1_REGOFFSET 0x00000000U
-#define ADC_SQR2_REGOFFSET 0x00000100U
-#define ADC_SQR3_REGOFFSET 0x00000200U
-#define ADC_SQR4_REGOFFSET 0x00000300U
-#define ADC_SQR5_REGOFFSET 0x00000400U
-
-#define ADC_REG_SQRX_REGOFFSET_MASK (ADC_SQR1_REGOFFSET | ADC_SQR2_REGOFFSET | ADC_SQR3_REGOFFSET | ADC_SQR4_REGOFFSET | ADC_SQR5_REGOFFSET)
-#define ADC_REG_RANK_ID_SQRX_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
-
-/* Definition of ADC group regular sequencer bits information to be inserted */
-/* into ADC group regular sequencer ranks literals definition. */
-#define ADC_REG_RANK_1_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ1) */
-#define ADC_REG_RANK_2_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ2) */
-#define ADC_REG_RANK_3_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ3) */
-#define ADC_REG_RANK_4_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ4) */
-#define ADC_REG_RANK_5_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ5) */
-#define ADC_REG_RANK_6_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR5_SQ6) */
-#define ADC_REG_RANK_7_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ7) */
-#define ADC_REG_RANK_8_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ8) */
-#define ADC_REG_RANK_9_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ9) */
-#define ADC_REG_RANK_10_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ10) */
-#define ADC_REG_RANK_11_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ11) */
-#define ADC_REG_RANK_12_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR4_SQ12) */
-#define ADC_REG_RANK_13_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ13) */
-#define ADC_REG_RANK_14_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ14) */
-#define ADC_REG_RANK_15_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ15) */
-#define ADC_REG_RANK_16_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ16) */
-#define ADC_REG_RANK_17_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ17) */
-#define ADC_REG_RANK_18_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR3_SQ18) */
-#define ADC_REG_RANK_19_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ29) */
-#define ADC_REG_RANK_20_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ20) */
-#define ADC_REG_RANK_21_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ21) */
-#define ADC_REG_RANK_22_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ22) */
-#define ADC_REG_RANK_23_SQRX_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ23) */
-#define ADC_REG_RANK_24_SQRX_BITOFFSET_POS (25U) /* Value equivalent to POSITION_VAL(ADC_SQR2_SQ24) */
-#define ADC_REG_RANK_25_SQRX_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ25) */
-#define ADC_REG_RANK_26_SQRX_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ26) */
-#define ADC_REG_RANK_27_SQRX_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ27) */
-#if defined(ADC_SQR1_SQ28)
-#define ADC_REG_RANK_28_SQRX_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_SQR1_SQ28) */
-#endif
-
-
-
-/* Internal mask for ADC group injected sequencer: */
-/* To select into literal LL_ADC_INJ_RANK_x the relevant bits for: */
-/* - data register offset */
-/* - offset register offset */
-/* - sequencer rank bits position into the selected register */
-
-/* Internal register offset for ADC group injected data register */
-/* (offset placed into a spare area of literal definition) */
-#define ADC_JDR1_REGOFFSET 0x00000000U
-#define ADC_JDR2_REGOFFSET 0x00000100U
-#define ADC_JDR3_REGOFFSET 0x00000200U
-#define ADC_JDR4_REGOFFSET 0x00000300U
-
-/* Internal register offset for ADC group injected offset configuration */
-/* (offset placed into a spare area of literal definition) */
-#define ADC_JOFR1_REGOFFSET 0x00000000U
-#define ADC_JOFR2_REGOFFSET 0x00001000U
-#define ADC_JOFR3_REGOFFSET 0x00002000U
-#define ADC_JOFR4_REGOFFSET 0x00003000U
-
-#define ADC_INJ_JDRX_REGOFFSET_MASK (ADC_JDR1_REGOFFSET | ADC_JDR2_REGOFFSET | ADC_JDR3_REGOFFSET | ADC_JDR4_REGOFFSET)
-#define ADC_INJ_JOFRX_REGOFFSET_MASK (ADC_JOFR1_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_JOFR4_REGOFFSET)
-#define ADC_INJ_RANK_ID_JSQR_MASK (ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0)
-
-/* Definition of ADC group injected sequencer bits information to be inserted */
-/* into ADC group injected sequencer ranks literals definition. */
-#define ADC_INJ_RANK_1_JSQR_BITOFFSET_POS ( 0U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ1) */
-#define ADC_INJ_RANK_2_JSQR_BITOFFSET_POS ( 5U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ2) */
-#define ADC_INJ_RANK_3_JSQR_BITOFFSET_POS (10U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ3) */
-#define ADC_INJ_RANK_4_JSQR_BITOFFSET_POS (15U) /* Value equivalent to POSITION_VAL(ADC_JSQR_JSQ4) */
-
-
-
-/* Internal mask for ADC group regular trigger: */
-/* To select into literal LL_ADC_REG_TRIG_x the relevant bits for: */
-/* - regular trigger source */
-/* - regular trigger edge */
-#define ADC_REG_TRIG_EXT_EDGE_DEFAULT (ADC_CR2_EXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value) */
-
-/* Mask containing trigger source masks for each of possible */
-/* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
-/* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
-#define ADC_REG_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTSEL) >> (4U * 0U)) | \
- ((ADC_CR2_EXTSEL) >> (4U * 1U)) | \
- ((ADC_CR2_EXTSEL) >> (4U * 2U)) | \
- ((ADC_CR2_EXTSEL) >> (4U * 3U)))
-
-/* Mask containing trigger edge masks for each of possible */
-/* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
-/* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
-#define ADC_REG_TRIG_EDGE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTEN) >> (4U * 0U)) | \
- ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 1U)) | \
- ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 2U)) | \
- ((ADC_REG_TRIG_EXT_EDGE_DEFAULT) >> (4U * 3U)))
-
-/* Definition of ADC group regular trigger bits information. */
-#define ADC_REG_TRIG_EXTSEL_BITOFFSET_POS (24U) /* Value equivalent to POSITION_VAL(ADC_CR2_EXTSEL) */
-#define ADC_REG_TRIG_EXTEN_BITOFFSET_POS (28U) /* Value equivalent to POSITION_VAL(ADC_CR2_EXTEN) */
-
-
-
-/* Internal mask for ADC group injected trigger: */
-/* To select into literal LL_ADC_INJ_TRIG_x the relevant bits for: */
-/* - injected trigger source */
-/* - injected trigger edge */
-#define ADC_INJ_TRIG_EXT_EDGE_DEFAULT (ADC_CR2_JEXTEN_0) /* Trigger edge set to rising edge (default setting for compatibility with some ADC on other STM32 families having this setting set by HW default value) */
-
-/* Mask containing trigger source masks for each of possible */
-/* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
-/* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
-#define ADC_INJ_TRIG_SOURCE_MASK (((LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_JEXTSEL) >> (4U * 0U)) | \
- ((ADC_CR2_JEXTSEL) >> (4U * 1U)) | \
- ((ADC_CR2_JEXTSEL) >> (4U * 2U)) | \
- ((ADC_CR2_JEXTSEL) >> (4U * 3U)))
-
-/* Mask containing trigger edge masks for each of possible */
-/* trigger edge selection duplicated with shifts [0; 4; 8; 12] */
-/* corresponding to {SW start; ext trigger; ext trigger; ext trigger}. */
-#define ADC_INJ_TRIG_EDGE_MASK (((LL_ADC_INJ_TRIG_SOFTWARE & ADC_CR2_JEXTEN) >> (4U * 0U)) | \
- ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 1U)) | \
- ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 2U)) | \
- ((ADC_INJ_TRIG_EXT_EDGE_DEFAULT) >> (4U * 3U)))
-
-/* Definition of ADC group injected trigger bits information. */
-#define ADC_INJ_TRIG_EXTSEL_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_CR2_JEXTSEL) */
-#define ADC_INJ_TRIG_EXTEN_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_CR2_JEXTEN) */
-
-
-
-
-
-
-/* Internal mask for ADC channel: */
-/* To select into literal LL_ADC_CHANNEL_x the relevant bits for: */
-/* - channel identifier defined by number */
-/* - channel differentiation between external channels (connected to */
-/* GPIO pins) and internal channels (connected to internal paths) */
-/* - channel sampling time defined by SMPRx register offset */
-/* and SMPx bits positions into SMPRx register */
-#define ADC_CHANNEL_ID_NUMBER_MASK (ADC_CR1_AWDCH)
-#define ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS ( 0U)/* Value equivalent to POSITION_VAL(ADC_CHANNEL_ID_NUMBER_MASK) */
-#define ADC_CHANNEL_ID_MASK (ADC_CHANNEL_ID_NUMBER_MASK | ADC_CHANNEL_ID_INTERNAL_CH_MASK)
-/* Equivalent mask of ADC_CHANNEL_NUMBER_MASK aligned on register LSB (bit 0) */
-#define ADC_CHANNEL_ID_NUMBER_MASK_POSBIT0 0x0000001FU /* Equivalent to shift: (ADC_CHANNEL_NUMBER_MASK >> POSITION_VAL(ADC_CHANNEL_NUMBER_MASK)) */
-
-/* Channel differentiation between external and internal channels */
-#define ADC_CHANNEL_ID_INTERNAL_CH 0x80000000U /* Marker of internal channel */
-#define ADC_CHANNEL_ID_INTERNAL_CH_MASK (ADC_CHANNEL_ID_INTERNAL_CH)
-
-/* Internal register offset for ADC channel sampling time configuration */
-/* (offset placed into a spare area of literal definition) */
-#define ADC_SMPR1_REGOFFSET 0x00000000U
-#define ADC_SMPR2_REGOFFSET 0x02000000U
-#define ADC_SMPR3_REGOFFSET 0x04000000U
-#if defined(ADC_SMPR0_SMP31)
-#define ADC_SMPR0_REGOFFSET 0x28000000U /* SMPR0 register offset from SMPR1 is 20 registers. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET | ADC_SMPR3_REGOFFSET | ADC_SMPR0_REGOFFSET)
-#else
-#define ADC_CHANNEL_SMPRX_REGOFFSET_MASK (ADC_SMPR1_REGOFFSET | ADC_SMPR2_REGOFFSET | ADC_SMPR3_REGOFFSET)
-#endif /* ADC_SMPR0_SMP31 */
-
-#define ADC_CHANNEL_SMPx_BITOFFSET_MASK 0x01F00000U
-#define ADC_CHANNEL_SMPx_BITOFFSET_POS (20U) /* Value equivalent to POSITION_VAL(ADC_CHANNEL_SMPx_BITOFFSET_MASK) */
-
-/* Definition of channels ID number information to be inserted into */
-/* channels literals definition. */
-#define ADC_CHANNEL_0_NUMBER 0x00000000U
-#define ADC_CHANNEL_1_NUMBER ( ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_2_NUMBER ( ADC_CR1_AWDCH_1 )
-#define ADC_CHANNEL_3_NUMBER ( ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_4_NUMBER ( ADC_CR1_AWDCH_2 )
-#define ADC_CHANNEL_5_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_6_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
-#define ADC_CHANNEL_7_NUMBER ( ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_8_NUMBER ( ADC_CR1_AWDCH_3 )
-#define ADC_CHANNEL_9_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_10_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 )
-#define ADC_CHANNEL_11_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_12_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 )
-#define ADC_CHANNEL_13_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_14_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
-#define ADC_CHANNEL_15_NUMBER ( ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_16_NUMBER (ADC_CR1_AWDCH_4 )
-#define ADC_CHANNEL_17_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_18_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1 )
-#define ADC_CHANNEL_19_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_20_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 )
-#define ADC_CHANNEL_21_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_22_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
-#define ADC_CHANNEL_23_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_24_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 )
-#define ADC_CHANNEL_25_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_26_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 )
-#if defined(ADC_SMPR0_SMP31)
-#define ADC_CHANNEL_27_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_28_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 )
-#define ADC_CHANNEL_29_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_0)
-#define ADC_CHANNEL_30_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 )
-#define ADC_CHANNEL_31_NUMBER (ADC_CR1_AWDCH_4 | ADC_CR1_AWDCH_3 | ADC_CR1_AWDCH_2 | ADC_CR1_AWDCH_1 | ADC_CR1_AWDCH_0)
-#endif /* ADC_SMPR0_SMP31 */
-
-/* Definition of channels sampling time information to be inserted into */
-/* channels literals definition. */
-#define ADC_CHANNEL_0_SMP (ADC_SMPR3_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP0) */
-#define ADC_CHANNEL_1_SMP (ADC_SMPR3_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP1) */
-#define ADC_CHANNEL_2_SMP (ADC_SMPR3_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP2) */
-#define ADC_CHANNEL_3_SMP (ADC_SMPR3_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP3) */
-#define ADC_CHANNEL_4_SMP (ADC_SMPR3_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP4) */
-#define ADC_CHANNEL_5_SMP (ADC_SMPR3_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP5) */
-#define ADC_CHANNEL_6_SMP (ADC_SMPR3_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP6) */
-#define ADC_CHANNEL_7_SMP (ADC_SMPR3_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP7) */
-#define ADC_CHANNEL_8_SMP (ADC_SMPR3_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP8) */
-#define ADC_CHANNEL_9_SMP (ADC_SMPR3_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR3_SMP9) */
-#define ADC_CHANNEL_10_SMP (ADC_SMPR2_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP10) */
-#define ADC_CHANNEL_11_SMP (ADC_SMPR2_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP11) */
-#define ADC_CHANNEL_12_SMP (ADC_SMPR2_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP12) */
-#define ADC_CHANNEL_13_SMP (ADC_SMPR2_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP13) */
-#define ADC_CHANNEL_14_SMP (ADC_SMPR2_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP14) */
-#define ADC_CHANNEL_15_SMP (ADC_SMPR2_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP15) */
-#define ADC_CHANNEL_16_SMP (ADC_SMPR2_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP16) */
-#define ADC_CHANNEL_17_SMP (ADC_SMPR2_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP17) */
-#define ADC_CHANNEL_18_SMP (ADC_SMPR2_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP18) */
-#define ADC_CHANNEL_19_SMP (ADC_SMPR2_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR2_SMP19) */
-#define ADC_CHANNEL_20_SMP (ADC_SMPR1_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP20) */
-#define ADC_CHANNEL_21_SMP (ADC_SMPR1_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP21) */
-#define ADC_CHANNEL_22_SMP (ADC_SMPR1_REGOFFSET | (( 6U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP22) */
-#define ADC_CHANNEL_23_SMP (ADC_SMPR1_REGOFFSET | (( 9U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP23) */
-#define ADC_CHANNEL_24_SMP (ADC_SMPR1_REGOFFSET | ((12U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP24) */
-#define ADC_CHANNEL_25_SMP (ADC_SMPR1_REGOFFSET | ((15U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP25) */
-#define ADC_CHANNEL_26_SMP (ADC_SMPR1_REGOFFSET | ((18U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP26) */
-#if defined(ADC_SMPR0_SMP31)
-#define ADC_CHANNEL_27_SMP (ADC_SMPR1_REGOFFSET | ((21U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP27) */
-#define ADC_CHANNEL_28_SMP (ADC_SMPR1_REGOFFSET | ((24U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP28) */
-#define ADC_CHANNEL_29_SMP (ADC_SMPR1_REGOFFSET | ((27U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR1_SMP19) */
-#define ADC_CHANNEL_30_SMP (ADC_SMPR0_REGOFFSET | (( 0U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR0_SMP30) */
-#define ADC_CHANNEL_31_SMP (ADC_SMPR0_REGOFFSET | (( 3U) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) /* Value shifted is equivalent to POSITION_VAL(ADC_SMPR0_SMP31) */
-#endif /* ADC_SMPR0_SMP31 */
-
-
-/* Internal mask for ADC analog watchdog: */
-/* To select into literals LL_ADC_AWD_CHANNELx_xxx the relevant bits for: */
-/* (concatenation of multiple bits used in different analog watchdogs, */
-/* (feature of several watchdogs not available on all STM32 families)). */
-/* - analog watchdog 1: monitored channel defined by number, */
-/* selection of ADC group (ADC groups regular and-or injected). */
-
-/* Internal register offset for ADC analog watchdog channel configuration */
-#define ADC_AWD_CR1_REGOFFSET 0x00000000U
-
-#define ADC_AWD_CRX_REGOFFSET_MASK (ADC_AWD_CR1_REGOFFSET)
-
-#define ADC_AWD_CR1_CHANNEL_MASK (ADC_CR1_AWDCH | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL)
-#define ADC_AWD_CR_ALL_CHANNEL_MASK (ADC_AWD_CR1_CHANNEL_MASK)
-
-/* Internal register offset for ADC analog watchdog threshold configuration */
-#define ADC_AWD_TR1_HIGH_REGOFFSET 0x00000000U
-#define ADC_AWD_TR1_LOW_REGOFFSET 0x00000001U
-#define ADC_AWD_TRX_REGOFFSET_MASK (ADC_AWD_TR1_HIGH_REGOFFSET | ADC_AWD_TR1_LOW_REGOFFSET)
-
-
-/* ADC registers bits positions */
-#define ADC_CR1_RES_BITOFFSET_POS (24U) /* Value equivalent to POSITION_VAL(ADC_CR1_RES) */
-#define ADC_TR_HT_BITOFFSET_POS (16U) /* Value equivalent to POSITION_VAL(ADC_TR_HT) */
-
-
-/* ADC internal channels related definitions */
-/* Internal voltage reference VrefInt */
-#define VREFINT_CAL_ADDR ((uint16_t*) VREFINT_CAL_ADDR_CMSIS) /* Internal voltage reference, address of parameter VREFINT_CAL: VrefInt ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
-#define VREFINT_CAL_VREF ( 3000U) /* Analog voltage reference (Vref+) value with which temperature sensor has been calibrated in production (tolerance: +-10 mV) (unit: mV). */
-/* Temperature sensor */
-#if defined (TEMPSENSOR_CAL1_ADDR_CMSIS)
-#define TEMPSENSOR_CAL1_ADDR ((uint16_t*) TEMPSENSOR_CAL1_ADDR_CMSIS) /* Internal temperature sensor, address of parameter TS_CAL1: On STM32L1, temperature sensor ADC raw data acquired at temperature 30 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
-#define TEMPSENSOR_CAL2_ADDR ((uint16_t*) TEMPSENSOR_CAL2_ADDR_CMSIS) /* Internal temperature sensor, address of parameter TS_CAL2: On STM32L1, temperature sensor ADC raw data acquired at temperature 110 DegC (tolerance: +-5 DegC), Vref+ = 3.0 V (tolerance: +-10 mV). */
-#endif /* TEMPSENSOR_CAL1_ADDR_CMSIS */
-#define TEMPSENSOR_CAL1_TEMP (( int32_t) 30) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL1_ADDR (tolerance: +-5 DegC) (unit: DegC). */
-#define TEMPSENSOR_CAL2_TEMP (( int32_t) 110) /* Internal temperature sensor, temperature at which temperature sensor has been calibrated in production for data into TEMPSENSOR_CAL2_ADDR (tolerance: +-5 DegC) (unit: DegC). */
-#define TEMPSENSOR_CAL_VREFANALOG ( 3000U) /* Analog voltage reference (Vref+) voltage with which temperature sensor has been calibrated in production (+-10 mV) (unit: mV). */
-
-
-/**
- * @}
- */
-
-
-/* Private macros ------------------------------------------------------------*/
-/** @defgroup ADC_LL_Private_Macros ADC Private Macros
- * @{
- */
-
-/**
- * @brief Driver macro reserved for internal use: isolate bits with the
- * selected mask and shift them to the register LSB
- * (shift mask on register position bit 0).
- * @param __BITS__ Bits in register 32 bits
- * @param __MASK__ Mask in register 32 bits
- * @retval Bits in register 32 bits
- */
-#define __ADC_MASK_SHIFT(__BITS__, __MASK__) \
- (((__BITS__) & (__MASK__)) >> POSITION_VAL((__MASK__)))
-
-/**
- * @brief Driver macro reserved for internal use: set a pointer to
- * a register from a register basis from which an offset
- * is applied.
- * @param __REG__ Register basis from which the offset is applied.
- * @param __REG_OFFFSET__ Offset to be applied (unit: number of registers).
- * @retval Pointer to register address
- */
-#define __ADC_PTR_REG_OFFSET(__REG__, __REG_OFFFSET__) \
- ((uint32_t *)((uint32_t) ((uint32_t)(&(__REG__)) + ((__REG_OFFFSET__) << 2U))))
-
-/**
- * @}
- */
-
-
-/* Exported types ------------------------------------------------------------*/
-#if defined(USE_FULL_LL_DRIVER)
-/** @defgroup ADC_LL_ES_INIT ADC Exported Init structure
- * @{
- */
-
-/**
- * @brief Structure definition of some features of ADC common parameters
- * and multimode
- * (all ADC instances belonging to the same ADC common instance).
- * @note The setting of these parameters by function @ref LL_ADC_CommonInit()
- * is conditioned to ADC instances state (all ADC instances
- * sharing the same ADC common instance):
- * All ADC instances sharing the same ADC common instance must be
- * disabled.
- */
-typedef struct
-{
- uint32_t CommonClock; /*!< Set parameter common to several ADC: Clock source and prescaler.
- This parameter can be a value of @ref ADC_LL_EC_COMMON_CLOCK_SOURCE
- @note On this STM32 serie, HSI RC oscillator is the only clock source for ADC.
- Therefore, HSI RC oscillator must be preliminarily enabled at RCC top level.
- @note On this STM32 serie, some clock ratio constraints between ADC clock and APB clock
- must be respected:
- - In all cases: if APB clock frequency is too low compared ADC clock frequency, a delay between conversions must be inserted.
- - If ADC group injected is used: ADC clock frequency should be lower than APB clock frequency /4 for resolution 12 or 10 bits, APB clock frequency /3 for resolution 8 bits, APB clock frequency /2 for resolution 6 bits.
- Refer to reference manual.
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_SetCommonClock(). */
-
-} LL_ADC_CommonInitTypeDef;
-
-/**
- * @brief Structure definition of some features of ADC instance.
- * @note These parameters have an impact on ADC scope: ADC instance.
- * Affects both group regular and group injected (availability
- * of ADC group injected depends on STM32 families).
- * Refer to corresponding unitary functions into
- * @ref ADC_LL_EF_Configuration_ADC_Instance .
- * @note The setting of these parameters by function @ref LL_ADC_Init()
- * is conditioned to ADC state:
- * ADC instance must be disabled.
- * This condition is applied to all ADC features, for efficiency
- * and compatibility over all STM32 families. However, the different
- * features can be set under different ADC state conditions
- * (setting possible with ADC enabled without conversion on going,
- * ADC enabled with conversion on going, ...)
- * Each feature can be updated afterwards with a unitary function
- * and potentially with ADC in a different state than disabled,
- * refer to description of each function for setting
- * conditioned to ADC state.
- */
-typedef struct
-{
- uint32_t Resolution; /*!< Set ADC resolution.
- This parameter can be a value of @ref ADC_LL_EC_RESOLUTION
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_SetResolution(). */
-
- uint32_t DataAlignment; /*!< Set ADC conversion data alignment.
- This parameter can be a value of @ref ADC_LL_EC_DATA_ALIGN
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_SetDataAlignment(). */
-
- uint32_t LowPowerMode; /*!< Set ADC low power mode.
- This parameter can be a concatenation of a value of @ref ADC_LL_EC_LP_MODE_AUTOWAIT and a value of @ref ADC_LL_EC_LP_MODE_AUTOPOWEROFF
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_SetLowPowerModeAutoWait() and @ref LL_ADC_SetLowPowerModeAutoPowerOff(). */
-
- uint32_t SequencersScanMode; /*!< Set ADC scan selection.
- This parameter can be a value of @ref ADC_LL_EC_SCAN_SELECTION
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_SetSequencersScanMode(). */
-
-} LL_ADC_InitTypeDef;
-
-/**
- * @brief Structure definition of some features of ADC group regular.
- * @note These parameters have an impact on ADC scope: ADC group regular.
- * Refer to corresponding unitary functions into
- * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
- * (functions with prefix "REG").
- * @note The setting of these parameters by function @ref LL_ADC_REG_Init()
- * is conditioned to ADC state:
- * ADC instance must be disabled.
- * This condition is applied to all ADC features, for efficiency
- * and compatibility over all STM32 families. However, the different
- * features can be set under different ADC state conditions
- * (setting possible with ADC enabled without conversion on going,
- * ADC enabled with conversion on going, ...)
- * Each feature can be updated afterwards with a unitary function
- * and potentially with ADC in a different state than disabled,
- * refer to description of each function for setting
- * conditioned to ADC state.
- */
-typedef struct
-{
- uint32_t TriggerSource; /*!< Set ADC group regular conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
- This parameter can be a value of @ref ADC_LL_EC_REG_TRIGGER_SOURCE
- @note On this STM32 serie, setting of external trigger edge is performed
- using function @ref LL_ADC_REG_StartConversionExtTrig().
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetTriggerSource(). */
-
- uint32_t SequencerLength; /*!< Set ADC group regular sequencer length.
- This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_SCAN_LENGTH
- @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerLength(). */
-
- uint32_t SequencerDiscont; /*!< Set ADC group regular sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
- This parameter can be a value of @ref ADC_LL_EC_REG_SEQ_DISCONT_MODE
- @note This parameter has an effect only if group regular sequencer is enabled
- (scan length of 2 ranks or more).
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetSequencerDiscont(). */
-
- uint32_t ContinuousMode; /*!< Set ADC continuous conversion mode on ADC group regular, whether ADC conversions are performed in single mode (one conversion per trigger) or in continuous mode (after the first trigger, following conversions launched successively automatically).
- This parameter can be a value of @ref ADC_LL_EC_REG_CONTINUOUS_MODE
- Note: It is not possible to enable both ADC group regular continuous mode and discontinuous mode.
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetContinuousMode(). */
-
- uint32_t DMATransfer; /*!< Set ADC group regular conversion data transfer: no transfer or transfer by DMA, and DMA requests mode.
- This parameter can be a value of @ref ADC_LL_EC_REG_DMA_TRANSFER
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_REG_SetDMATransfer(). */
-
-} LL_ADC_REG_InitTypeDef;
-
-/**
- * @brief Structure definition of some features of ADC group injected.
- * @note These parameters have an impact on ADC scope: ADC group injected.
- * Refer to corresponding unitary functions into
- * @ref ADC_LL_EF_Configuration_ADC_Group_Regular
- * (functions with prefix "INJ").
- * @note The setting of these parameters by function @ref LL_ADC_INJ_Init()
- * is conditioned to ADC state:
- * ADC instance must be disabled.
- * This condition is applied to all ADC features, for efficiency
- * and compatibility over all STM32 families. However, the different
- * features can be set under different ADC state conditions
- * (setting possible with ADC enabled without conversion on going,
- * ADC enabled with conversion on going, ...)
- * Each feature can be updated afterwards with a unitary function
- * and potentially with ADC in a different state than disabled,
- * refer to description of each function for setting
- * conditioned to ADC state.
- */
-typedef struct
-{
- uint32_t TriggerSource; /*!< Set ADC group injected conversion trigger source: internal (SW start) or from external IP (timer event, external interrupt line).
- This parameter can be a value of @ref ADC_LL_EC_INJ_TRIGGER_SOURCE
- @note On this STM32 serie, setting of external trigger edge is performed
- using function @ref LL_ADC_INJ_StartConversionExtTrig().
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTriggerSource(). */
-
- uint32_t SequencerLength; /*!< Set ADC group injected sequencer length.
- This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_SCAN_LENGTH
- @note This parameter is discarded if scan mode is disabled (refer to parameter 'ADC_SequencersScanMode').
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerLength(). */
-
- uint32_t SequencerDiscont; /*!< Set ADC group injected sequencer discontinuous mode: sequence subdivided and scan conversions interrupted every selected number of ranks.
- This parameter can be a value of @ref ADC_LL_EC_INJ_SEQ_DISCONT_MODE
- @note This parameter has an effect only if group injected sequencer is enabled
- (scan length of 2 ranks or more).
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetSequencerDiscont(). */
-
- uint32_t TrigAuto; /*!< Set ADC group injected conversion trigger: independent or from ADC group regular.
- This parameter can be a value of @ref ADC_LL_EC_INJ_TRIG_AUTO
- Note: This parameter must be set to set to independent trigger if injected trigger source is set to an external trigger.
-
- This feature can be modified afterwards using unitary function @ref LL_ADC_INJ_SetTrigAuto(). */
-
-} LL_ADC_INJ_InitTypeDef;
-
-/**
- * @}
- */
-#endif /* USE_FULL_LL_DRIVER */
-
-/* Exported constants --------------------------------------------------------*/
-/** @defgroup ADC_LL_Exported_Constants ADC Exported Constants
- * @{
- */
-
-/** @defgroup ADC_LL_EC_FLAG ADC flags
- * @brief Flags defines which can be used with LL_ADC_ReadReg function
- * @{
- */
-#define LL_ADC_FLAG_ADRDY ADC_SR_ADONS /*!< ADC flag ADC instance ready */
-#define LL_ADC_FLAG_STRT ADC_SR_STRT /*!< ADC flag ADC group regular conversion start */
-#define LL_ADC_FLAG_EOCS ADC_SR_EOC /*!< ADC flag ADC group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
-#define LL_ADC_FLAG_OVR ADC_SR_OVR /*!< ADC flag ADC group regular overrun */
-#define LL_ADC_FLAG_JSTRT ADC_SR_JSTRT /*!< ADC flag ADC group injected conversion start */
-#define LL_ADC_FLAG_JEOS ADC_SR_JEOC /*!< ADC flag ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
-#define LL_ADC_FLAG_AWD1 ADC_SR_AWD /*!< ADC flag ADC analog watchdog 1 */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_IT ADC interruptions for configuration (interruption enable or disable)
- * @brief IT defines which can be used with LL_ADC_ReadReg and LL_ADC_WriteReg functions
- * @{
- */
-#define LL_ADC_IT_EOCS ADC_CR1_EOCIE /*!< ADC interruption ADC group regular end of unitary conversion or sequence conversions (to configure flag of end of conversion, use function @ref LL_ADC_REG_SetFlagEndOfConversion() ) */
-#define LL_ADC_IT_OVR ADC_CR1_OVRIE /*!< ADC interruption ADC group regular overrun */
-#define LL_ADC_IT_JEOS ADC_CR1_JEOCIE /*!< ADC interruption ADC group injected end of sequence conversions (Note: on this STM32 serie, there is no flag ADC group injected end of unitary conversion. Flag noted as "JEOC" is corresponding to flag "JEOS" in other STM32 families) */
-#define LL_ADC_IT_AWD1 ADC_CR1_AWDIE /*!< ADC interruption ADC analog watchdog 1 */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_REGISTERS ADC registers compliant with specific purpose
- * @{
- */
-/* List of ADC registers intended to be used (most commonly) with */
-/* DMA transfer. */
-/* Refer to function @ref LL_ADC_DMA_GetRegAddr(). */
-#define LL_ADC_DMA_REG_REGULAR_DATA 0x00000000U /* ADC group regular conversion data register (corresponding to register DR) to be used with ADC configured in independent mode. Without DMA transfer, register accessed by LL function @ref LL_ADC_REG_ReadConversionData32() and other functions @ref LL_ADC_REG_ReadConversionDatax() */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_COMMON_CLOCK_SOURCE ADC common - Clock source
- * @{
- */
-#define LL_ADC_CLOCK_ASYNC_DIV1 0x00000000U /*!< ADC asynchronous clock without prescaler */
-#define LL_ADC_CLOCK_ASYNC_DIV2 (ADC_CCR_ADCPRE_0) /*!< ADC asynchronous clock with prescaler division by 2 */
-#define LL_ADC_CLOCK_ASYNC_DIV4 (ADC_CCR_ADCPRE_1) /*!< ADC asynchronous clock with prescaler division by 4 */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_COMMON_PATH_INTERNAL ADC common - Measurement path to internal channels
- * @{
- */
-/* Note: Other measurement paths to internal channels may be available */
-/* (connections to other peripherals). */
-/* If they are not listed below, they do not require any specific */
-/* path enable. In this case, Access to measurement path is done */
-/* only by selecting the corresponding ADC internal channel. */
-#define LL_ADC_PATH_INTERNAL_NONE 0x00000000U /*!< ADC measurement pathes all disabled */
-#define LL_ADC_PATH_INTERNAL_VREFINT (ADC_CCR_TSVREFE) /*!< ADC measurement path to internal channel VrefInt */
-#define LL_ADC_PATH_INTERNAL_TEMPSENSOR (ADC_CCR_TSVREFE) /*!< ADC measurement path to internal channel temperature sensor */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_RESOLUTION ADC instance - Resolution
- * @{
- */
-#define LL_ADC_RESOLUTION_12B 0x00000000U /*!< ADC resolution 12 bits */
-#define LL_ADC_RESOLUTION_10B ( ADC_CR1_RES_0) /*!< ADC resolution 10 bits */
-#define LL_ADC_RESOLUTION_8B (ADC_CR1_RES_1 ) /*!< ADC resolution 8 bits */
-#define LL_ADC_RESOLUTION_6B (ADC_CR1_RES_1 | ADC_CR1_RES_0) /*!< ADC resolution 6 bits */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_DATA_ALIGN ADC instance - Data alignment
- * @{
- */
-#define LL_ADC_DATA_ALIGN_RIGHT 0x00000000U /*!< ADC conversion data alignment: right aligned (alignment on data register LSB bit 0)*/
-#define LL_ADC_DATA_ALIGN_LEFT (ADC_CR2_ALIGN) /*!< ADC conversion data alignment: left aligned (aligment on data register MSB bit 15)*/
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_LP_MODE_AUTOWAIT ADC instance - Low power mode auto wait (auto delay)
- * @{
- */
-#define LL_ADC_LP_AUTOWAIT_NONE 0x00000000U /*!< ADC low power mode auto wait not activated */
-#define LL_ADC_LP_AUTOWAIT ( ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Dynamic low power mode, ADC conversions are performed only when necessary (when previous ADC conversion data is read). See description with function @ref LL_ADC_SetLowPowerModeAutoWait(). */
-#define LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES ( ADC_CR2_DELS_1 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 7 APB clock cycles */
-#define LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES ( ADC_CR2_DELS_1 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 15 APB clock cycles */
-#define LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES (ADC_CR2_DELS_2 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 31 APB clock cycles */
-#define LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 63 APB clock cycles */
-#define LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_1 ) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 127 APB clock cycles */
-#define LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES (ADC_CR2_DELS_2 | ADC_CR2_DELS_1 | ADC_CR2_DELS_0) /*!< ADC low power mode auto wait: Insert a delay between ADC conversions: 255 APB clock cycles */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_LP_MODE_AUTOPOWEROFF ADC instance - Low power mode auto power-off
- * @{
- */
-#define LL_ADC_LP_AUTOPOWEROFF_NONE 0x00000000U /*!< ADC low power mode auto power-off not activated */
-#define LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE (ADC_CR1_PDI) /*!< ADC low power mode auto power-off: ADC power off when ADC is not converting (idle phase) */
-#define LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE (ADC_CR1_PDD) /*!< ADC low power mode auto power-off: ADC power off when a delay is inserted between conversions (refer to function @ref LL_ADC_SetLowPowerModeAutoWait() ) */
-#define LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES (ADC_CR1_PDI | ADC_CR1_PDD) /*!< ADC low power mode auto power-off: ADC power off when ADC is not converting (idle phase) and when a delay is inserted between conversions (refer to function @ref LL_ADC_SetLowPowerModeAutoWait() ) */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_SCAN_SELECTION ADC instance - Scan selection
- * @{
- */
-#define LL_ADC_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC conversion is performed in unitary conversion mode (one channel converted, that defined in rank 1). Configuration of both groups regular and injected sequencers (sequence length, ...) is discarded: equivalent to length of 1 rank.*/
-#define LL_ADC_SEQ_SCAN_ENABLE (ADC_CR1_SCAN) /*!< ADC conversions are performed in sequence conversions mode, according to configuration of both groups regular and injected sequencers (sequence length, ...). */
-/**
- * @}
- */
-
-#if defined(ADC_CR2_CFG)
-/** @defgroup ADC_LL_EC_CHANNELS_BANK ADC instance - Channels bank
- * @{
- */
-#define LL_ADC_CHANNELS_BANK_A 0x00000000U /*!< ADC channels bank A */
-#define LL_ADC_CHANNELS_BANK_B (ADC_CR2_CFG) /*!< ADC channels bank B, available in devices categories 3, 4, 5. */
-/**
- * @}
- */
-#endif
-
-/** @defgroup ADC_LL_EC_GROUPS ADC instance - Groups
- * @{
- */
-#define LL_ADC_GROUP_REGULAR 0x00000001U /*!< ADC group regular (available on all STM32 devices) */
-#define LL_ADC_GROUP_INJECTED 0x00000002U /*!< ADC group injected (not available on all STM32 devices)*/
-#define LL_ADC_GROUP_REGULAR_INJECTED 0x00000003U /*!< ADC both groups regular and injected */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_CHANNEL ADC instance - Channel number
- * @{
- */
-#define LL_ADC_CHANNEL_0 (ADC_CHANNEL_0_NUMBER | ADC_CHANNEL_0_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN0 . Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_1 (ADC_CHANNEL_1_NUMBER | ADC_CHANNEL_1_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN1 . Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_2 (ADC_CHANNEL_2_NUMBER | ADC_CHANNEL_2_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN2 . Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_3 (ADC_CHANNEL_3_NUMBER | ADC_CHANNEL_3_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN3 . Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_4 (ADC_CHANNEL_4_NUMBER | ADC_CHANNEL_4_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN4 . Direct (fast) channel. */
-#define LL_ADC_CHANNEL_5 (ADC_CHANNEL_5_NUMBER | ADC_CHANNEL_5_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN5 . Direct (fast) channel. */
-#define LL_ADC_CHANNEL_6 (ADC_CHANNEL_6_NUMBER | ADC_CHANNEL_6_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN6 . Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_7 (ADC_CHANNEL_7_NUMBER | ADC_CHANNEL_7_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN7 . Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_8 (ADC_CHANNEL_8_NUMBER | ADC_CHANNEL_8_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN8 . Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_9 (ADC_CHANNEL_9_NUMBER | ADC_CHANNEL_9_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN9 . Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_10 (ADC_CHANNEL_10_NUMBER | ADC_CHANNEL_10_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN10. Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_11 (ADC_CHANNEL_11_NUMBER | ADC_CHANNEL_11_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN11. Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_12 (ADC_CHANNEL_12_NUMBER | ADC_CHANNEL_12_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN12. Channel different in bank A and bank B. */
-#define LL_ADC_CHANNEL_13 (ADC_CHANNEL_13_NUMBER | ADC_CHANNEL_13_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN13. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_14 (ADC_CHANNEL_14_NUMBER | ADC_CHANNEL_14_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN14. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_15 (ADC_CHANNEL_15_NUMBER | ADC_CHANNEL_15_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN15. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_16 (ADC_CHANNEL_16_NUMBER | ADC_CHANNEL_16_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN16. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_17 (ADC_CHANNEL_17_NUMBER | ADC_CHANNEL_17_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN17. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_18 (ADC_CHANNEL_18_NUMBER | ADC_CHANNEL_18_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN18. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_19 (ADC_CHANNEL_19_NUMBER | ADC_CHANNEL_19_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN19. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_20 (ADC_CHANNEL_20_NUMBER | ADC_CHANNEL_20_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN20. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_21 (ADC_CHANNEL_21_NUMBER | ADC_CHANNEL_21_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN21. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_22 (ADC_CHANNEL_22_NUMBER | ADC_CHANNEL_22_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN22. Direct (fast) channel. */
-#define LL_ADC_CHANNEL_23 (ADC_CHANNEL_23_NUMBER | ADC_CHANNEL_23_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN23. Direct (fast) channel. */
-#define LL_ADC_CHANNEL_24 (ADC_CHANNEL_24_NUMBER | ADC_CHANNEL_24_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN24. Direct (fast) channel. */
-#define LL_ADC_CHANNEL_25 (ADC_CHANNEL_25_NUMBER | ADC_CHANNEL_25_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN25. Direct (fast) channel. */
-#define LL_ADC_CHANNEL_26 (ADC_CHANNEL_26_NUMBER | ADC_CHANNEL_26_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN26. Direct (fast) channel. */
-#if defined(ADC_SMPR0_SMP31)
-#define LL_ADC_CHANNEL_27 (ADC_CHANNEL_27_NUMBER | ADC_CHANNEL_27_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN27. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_CHANNEL_28 (ADC_CHANNEL_28_NUMBER | ADC_CHANNEL_28_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN28. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_CHANNEL_29 (ADC_CHANNEL_29_NUMBER | ADC_CHANNEL_29_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN29. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_CHANNEL_30 (ADC_CHANNEL_30_NUMBER | ADC_CHANNEL_30_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN30. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_CHANNEL_31 (ADC_CHANNEL_31_NUMBER | ADC_CHANNEL_31_SMP) /*!< ADC external channel (channel connected to GPIO pin) ADCx_IN31. Channel common to both bank A and bank B. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#endif /* ADC_SMPR0_SMP31 */
-#define LL_ADC_CHANNEL_VREFINT (LL_ADC_CHANNEL_17 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to VrefInt: Internal voltage reference. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_TEMPSENSOR (LL_ADC_CHANNEL_16 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to Temperature sensor. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_VCOMP (LL_ADC_CHANNEL_26 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
-#if defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD) || defined (OPAMP_CSR_OPA3PD)
-#define LL_ADC_CHANNEL_VOPAMP1 (LL_ADC_CHANNEL_3 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#define LL_ADC_CHANNEL_VOPAMP2 (LL_ADC_CHANNEL_8 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#if defined(OPAMP_CSR_OPA3PD)
-#define LL_ADC_CHANNEL_VOPAMP3 (LL_ADC_CHANNEL_13 | ADC_CHANNEL_ID_INTERNAL_CH) /*!< ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#endif /* OPAMP_CSR_OPA3PD */
-#endif /* OPAMP_CSR_OPA1PD || OPAMP_CSR_OPA2PD || OPAMP_CSR_OPA3PD */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_REG_TRIGGER_SOURCE ADC group regular - Trigger source
- * @{
- */
-#define LL_ADC_REG_TRIG_SOFTWARE 0x00000000U /*!< ADC group regular conversion trigger internal: SW start. */
-#define LL_ADC_REG_TRIG_EXT_TIM2_TRGO (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_TIM2_CH3 (ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_TIM3_TRGO (ADC_CR2_EXTSEL_2 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 TRGO. Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_TIM2_CH2 (ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM2 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_TIM3_CH1 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_TIM3_CH3 (ADC_CR2_EXTSEL_3 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM3 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_TIM4_TRGO (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_TIM4_CH4 (ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM4 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_TIM6_TRGO (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_1 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM6 TRGO. Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_TIM9_CH2 (ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM9 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_TIM9_TRGO (ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: TIM9 TRGO. Trigger edge set to rising edge (default setting). */
-#define LL_ADC_REG_TRIG_EXT_EXTI_LINE11 (ADC_CR2_EXTSEL_3 | ADC_CR2_EXTSEL_2 | ADC_CR2_EXTSEL_1 | ADC_CR2_EXTSEL_0 | ADC_REG_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group regular conversion trigger from external IP: external interrupt line 11. Trigger edge set to rising edge (default setting). */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_REG_TRIGGER_EDGE ADC group regular - Trigger edge
- * @{
- */
-#define LL_ADC_REG_TRIG_EXT_RISING ( ADC_CR2_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to rising edge */
-#define LL_ADC_REG_TRIG_EXT_FALLING (ADC_CR2_EXTEN_1 ) /*!< ADC group regular conversion trigger polarity set to falling edge */
-#define LL_ADC_REG_TRIG_EXT_RISINGFALLING (ADC_CR2_EXTEN_1 | ADC_CR2_EXTEN_0) /*!< ADC group regular conversion trigger polarity set to both rising and falling edges */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_REG_CONTINUOUS_MODE ADC group regular - Continuous mode
-* @{
-*/
-#define LL_ADC_REG_CONV_SINGLE 0x00000000U /*!< ADC conversions are performed in single mode: one conversion per trigger */
-#define LL_ADC_REG_CONV_CONTINUOUS (ADC_CR2_CONT) /*!< ADC conversions are performed in continuous mode: after the first trigger, following conversions launched successively automatically */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_REG_DMA_TRANSFER ADC group regular - DMA transfer of ADC conversion data
- * @{
- */
-#define LL_ADC_REG_DMA_TRANSFER_NONE 0x00000000U /*!< ADC conversions are not transferred by DMA */
-#define LL_ADC_REG_DMA_TRANSFER_LIMITED ( ADC_CR2_DMA) /*!< ADC conversion data are transferred by DMA, in limited mode (one shot mode): DMA transfer requests are stopped when number of DMA data transfers (number of ADC conversions) is reached. This ADC mode is intended to be used with DMA mode non-circular. */
-#define LL_ADC_REG_DMA_TRANSFER_UNLIMITED (ADC_CR2_DDS | ADC_CR2_DMA) /*!< ADC conversion data are transferred by DMA, in unlimited mode: DMA transfer requests are unlimited, whatever number of DMA data transferred (number of ADC conversions). This ADC mode is intended to be used with DMA mode circular. */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_REG_FLAG_EOC_SELECTION ADC group regular - Flag EOC selection (unitary or sequence conversions)
- * @{
- */
-#define LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV 0x00000000U /*!< ADC flag EOC (end of unitary conversion) selected */
-#define LL_ADC_REG_FLAG_EOC_UNITARY_CONV (ADC_CR2_EOCS) /*!< ADC flag EOS (end of sequence conversions) selected */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_REG_SEQ_SCAN_LENGTH ADC group regular - Sequencer scan length
- * @{
- */
-#define LL_ADC_REG_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC group regular sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS ( ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 2 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS ( ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 3 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS ( ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 4 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS ( ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 5 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 6 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 7 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS ( ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 8 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS (ADC_SQR1_L_3 ) /*!< ADC group regular sequencer enable with 9 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 10 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 11 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 12 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 ) /*!< ADC group regular sequencer enable with 13 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 14 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 ) /*!< ADC group regular sequencer enable with 15 ranks in the sequence */
-#define LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS (ADC_SQR1_L_3 | ADC_SQR1_L_2 | ADC_SQR1_L_1 | ADC_SQR1_L_0) /*!< ADC group regular sequencer enable with 16 ranks in the sequence */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_REG_SEQ_DISCONT_MODE ADC group regular - Sequencer discontinuous mode
- * @{
- */
-#define LL_ADC_REG_SEQ_DISCONT_DISABLE 0x00000000U /*!< ADC group regular sequencer discontinuous mode disable */
-#define LL_ADC_REG_SEQ_DISCONT_1RANK ( ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every rank */
-#define LL_ADC_REG_SEQ_DISCONT_2RANKS ( ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enabled with sequence interruption every 2 ranks */
-#define LL_ADC_REG_SEQ_DISCONT_3RANKS ( ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 3 ranks */
-#define LL_ADC_REG_SEQ_DISCONT_4RANKS ( ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 4 ranks */
-#define LL_ADC_REG_SEQ_DISCONT_5RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 5 ranks */
-#define LL_ADC_REG_SEQ_DISCONT_6RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 6 ranks */
-#define LL_ADC_REG_SEQ_DISCONT_7RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 7 ranks */
-#define LL_ADC_REG_SEQ_DISCONT_8RANKS (ADC_CR1_DISCNUM_2 | ADC_CR1_DISCNUM_1 | ADC_CR1_DISCNUM_0 | ADC_CR1_DISCEN) /*!< ADC group regular sequencer discontinuous mode enable with sequence interruption every 8 ranks */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_REG_SEQ_RANKS ADC group regular - Sequencer ranks
- * @{
- */
-#define LL_ADC_REG_RANK_1 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_1_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 1 */
-#define LL_ADC_REG_RANK_2 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_2_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 2 */
-#define LL_ADC_REG_RANK_3 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_3_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 3 */
-#define LL_ADC_REG_RANK_4 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_4_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 4 */
-#define LL_ADC_REG_RANK_5 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_5_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 5 */
-#define LL_ADC_REG_RANK_6 (ADC_SQR5_REGOFFSET | ADC_REG_RANK_6_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 6 */
-#define LL_ADC_REG_RANK_7 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_7_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 7 */
-#define LL_ADC_REG_RANK_8 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_8_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 8 */
-#define LL_ADC_REG_RANK_9 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_9_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 9 */
-#define LL_ADC_REG_RANK_10 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_10_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 10 */
-#define LL_ADC_REG_RANK_11 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_11_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 11 */
-#define LL_ADC_REG_RANK_12 (ADC_SQR4_REGOFFSET | ADC_REG_RANK_12_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 12 */
-#define LL_ADC_REG_RANK_13 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_13_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 13 */
-#define LL_ADC_REG_RANK_14 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_14_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 14 */
-#define LL_ADC_REG_RANK_15 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_15_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 15 */
-#define LL_ADC_REG_RANK_16 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_16_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 16 */
-#define LL_ADC_REG_RANK_17 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_17_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 17 */
-#define LL_ADC_REG_RANK_18 (ADC_SQR3_REGOFFSET | ADC_REG_RANK_18_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 18 */
-#define LL_ADC_REG_RANK_19 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_19_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 19 */
-#define LL_ADC_REG_RANK_20 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_20_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 20 */
-#define LL_ADC_REG_RANK_21 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_21_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 21 */
-#define LL_ADC_REG_RANK_22 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_22_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 22 */
-#define LL_ADC_REG_RANK_23 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_23_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 23 */
-#define LL_ADC_REG_RANK_24 (ADC_SQR2_REGOFFSET | ADC_REG_RANK_24_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 24 */
-#define LL_ADC_REG_RANK_25 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_25_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 25 */
-#define LL_ADC_REG_RANK_26 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_26_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 26 */
-#define LL_ADC_REG_RANK_27 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_27_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 27 */
-#if defined(ADC_SQR1_SQ28)
-#define LL_ADC_REG_RANK_28 (ADC_SQR1_REGOFFSET | ADC_REG_RANK_28_SQRX_BITOFFSET_POS) /*!< ADC group regular sequencer rank 28 */
-#endif
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_INJ_TRIGGER_SOURCE ADC group injected - Trigger source
- * @{
- */
-#define LL_ADC_INJ_TRIG_SOFTWARE 0x00000000U /*!< ADC group injected conversion trigger internal: SW start. */
-#define LL_ADC_INJ_TRIG_EXT_TIM9_CH1 (ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM9 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_TIM9_TRGO (ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM9 TRGO. Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_TIM2_TRGO (ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 TRGO. Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_TIM2_CH1 (ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM2 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_TIM3_CH4 (ADC_CR2_JEXTSEL_2 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM3 channel 4 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_TIM4_TRGO (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 TRGO. Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_TIM4_CH1 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_TIM4_CH2 (ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 2 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_TIM4_CH3 (ADC_CR2_JEXTSEL_3 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM4 channel 3 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_TIM10_CH1 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM10 channel 1 event (capture compare: input capture or output capture). Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_TIM7_TRGO (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_1 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: TIM7 TRGO. Trigger edge set to rising edge (default setting). */
-#define LL_ADC_INJ_TRIG_EXT_EXTI_LINE15 (ADC_CR2_JEXTSEL_3 | ADC_CR2_JEXTSEL_2 | ADC_CR2_JEXTSEL_1 | ADC_CR2_JEXTSEL_0 | ADC_INJ_TRIG_EXT_EDGE_DEFAULT) /*!< ADC group injected conversion trigger from external IP: external interrupt line 15. Trigger edge set to rising edge (default setting). */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_INJ_TRIGGER_EDGE ADC group injected - Trigger edge
- * @{
- */
-#define LL_ADC_INJ_TRIG_EXT_RISING ( ADC_CR2_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to rising edge */
-#define LL_ADC_INJ_TRIG_EXT_FALLING (ADC_CR2_JEXTEN_1 ) /*!< ADC group injected conversion trigger polarity set to falling edge */
-#define LL_ADC_INJ_TRIG_EXT_RISINGFALLING (ADC_CR2_JEXTEN_1 | ADC_CR2_JEXTEN_0) /*!< ADC group injected conversion trigger polarity set to both rising and falling edges */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_INJ_TRIG_AUTO ADC group injected - Automatic trigger mode
-* @{
-*/
-#define LL_ADC_INJ_TRIG_INDEPENDENT 0x00000000U /*!< ADC group injected conversion trigger independent. Setting mandatory if ADC group injected injected trigger source is set to an external trigger. */
-#define LL_ADC_INJ_TRIG_FROM_GRP_REGULAR (ADC_CR1_JAUTO) /*!< ADC group injected conversion trigger from ADC group regular. Setting compliant only with group injected trigger source set to SW start, without any further action on ADC group injected conversion start or stop: in this case, ADC group injected is controlled only from ADC group regular. */
-/**
- * @}
- */
-
-
-/** @defgroup ADC_LL_EC_INJ_SEQ_SCAN_LENGTH ADC group injected - Sequencer scan length
- * @{
- */
-#define LL_ADC_INJ_SEQ_SCAN_DISABLE 0x00000000U /*!< ADC group injected sequencer disable (equivalent to sequencer of 1 rank: ADC conversion on only 1 channel) */
-#define LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS ( ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 2 ranks in the sequence */
-#define LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS (ADC_JSQR_JL_1 ) /*!< ADC group injected sequencer enable with 3 ranks in the sequence */
-#define LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS (ADC_JSQR_JL_1 | ADC_JSQR_JL_0) /*!< ADC group injected sequencer enable with 4 ranks in the sequence */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_INJ_SEQ_DISCONT_MODE ADC group injected - Sequencer discontinuous mode
- * @{
- */
-#define LL_ADC_INJ_SEQ_DISCONT_DISABLE 0x00000000U /*!< ADC group injected sequencer discontinuous mode disable */
-#define LL_ADC_INJ_SEQ_DISCONT_1RANK (ADC_CR1_JDISCEN) /*!< ADC group injected sequencer discontinuous mode enable with sequence interruption every rank */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_INJ_SEQ_RANKS ADC group injected - Sequencer ranks
- * @{
- */
-#define LL_ADC_INJ_RANK_1 (ADC_JDR1_REGOFFSET | ADC_JOFR1_REGOFFSET | ADC_INJ_RANK_1_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 1 */
-#define LL_ADC_INJ_RANK_2 (ADC_JDR2_REGOFFSET | ADC_JOFR2_REGOFFSET | ADC_INJ_RANK_2_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 2 */
-#define LL_ADC_INJ_RANK_3 (ADC_JDR3_REGOFFSET | ADC_JOFR3_REGOFFSET | ADC_INJ_RANK_3_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 3 */
-#define LL_ADC_INJ_RANK_4 (ADC_JDR4_REGOFFSET | ADC_JOFR4_REGOFFSET | ADC_INJ_RANK_4_JSQR_BITOFFSET_POS) /*!< ADC group injected sequencer rank 4 */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_CHANNEL_SAMPLINGTIME Channel - Sampling time
- * @{
- */
-#define LL_ADC_SAMPLINGTIME_4CYCLES 0x00000000U /*!< Sampling time 4 ADC clock cycles */
-#define LL_ADC_SAMPLINGTIME_9CYCLES (ADC_SMPR3_SMP0_0) /*!< Sampling time 9 ADC clock cycles */
-#define LL_ADC_SAMPLINGTIME_16CYCLES (ADC_SMPR3_SMP0_1) /*!< Sampling time 16 ADC clock cycles */
-#define LL_ADC_SAMPLINGTIME_24CYCLES (ADC_SMPR3_SMP0_1 | ADC_SMPR3_SMP0_0) /*!< Sampling time 24 ADC clock cycles */
-#define LL_ADC_SAMPLINGTIME_48CYCLES (ADC_SMPR3_SMP0_2) /*!< Sampling time 48 ADC clock cycles */
-#define LL_ADC_SAMPLINGTIME_96CYCLES (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_0) /*!< Sampling time 96 ADC clock cycles */
-#define LL_ADC_SAMPLINGTIME_192CYCLES (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_1) /*!< Sampling time 192 ADC clock cycles */
-#define LL_ADC_SAMPLINGTIME_384CYCLES (ADC_SMPR3_SMP0_2 | ADC_SMPR3_SMP0_1 | ADC_SMPR3_SMP0_0) /*!< Sampling time 384 ADC clock cycles */
-/**
- * @}
- */
-
-#if defined(COMP_CSR_FCH3)
-/** @defgroup ADC_LL_EC_CHANNEL_ROUTING_LIST Channel - Routing channels list
- * @{
- */
-#define LL_ADC_CHANNEL_3_ROUTING (COMP_CSR_FCH3) /*!< ADC channel 3 routing. Used as ADC direct channel (fast channel) if OPAMP1 is in power down mode. */
-#define LL_ADC_CHANNEL_8_ROUTING (COMP_CSR_FCH8) /*!< ADC channel 8 routing. Used as ADC direct channel (fast channel) if OPAMP2 is in power down mode. */
-#define LL_ADC_CHANNEL_13_ROUTING (COMP_CSR_RCH13) /*!< ADC channel 13 routing. Used as ADC re-routed channel if OPAMP3 is in power down mode. Otherwise, channel 13 is connected to OPAMP3 output and routed through switches COMP1_SW1 and VCOMP to ADC switch matrix. (Note: OPAMP3 is available on STM32L1 Cat.4 only). */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_CHANNEL_ROUTING_SELECTION Channel - Routing selection
- * @{
- */
-#define LL_ADC_CHANNEL_ROUTING_DEFAULT 0x00000000U /*!< ADC channel routing default: slow channel */
-#define LL_ADC_CHANNEL_ROUTING_DIRECT 0x00000001U /*!< ADC channel routing direct: fast channel. */
-/**
- * @}
- */
-#endif
-
-/** @defgroup ADC_LL_EC_AWD_NUMBER Analog watchdog - Analog watchdog number
- * @{
- */
-#define LL_ADC_AWD1 (ADC_AWD_CR1_CHANNEL_MASK | ADC_AWD_CR1_REGOFFSET) /*!< ADC analog watchdog number 1 */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_AWD_CHANNELS Analog watchdog - Monitored channels
- * @{
- */
-#define LL_ADC_AWD_DISABLE 0x00000000U /*!< ADC analog watchdog monitoring disabled */
-#define LL_ADC_AWD_ALL_CHANNELS_REG ( ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group regular only */
-#define LL_ADC_AWD_ALL_CHANNELS_INJ ( ADC_CR1_JAWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by group injected only */
-#define LL_ADC_AWD_ALL_CHANNELS_REG_INJ ( ADC_CR1_JAWDEN | ADC_CR1_AWDEN ) /*!< ADC analog watchdog monitoring of all channels, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_0_REG ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_0_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_0_REG_INJ ((LL_ADC_CHANNEL_0 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN0, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_1_REG ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_1_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_1_REG_INJ ((LL_ADC_CHANNEL_1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN1, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_2_REG ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_2_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_2_REG_INJ ((LL_ADC_CHANNEL_2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN2, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_3_REG ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_3_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_3_REG_INJ ((LL_ADC_CHANNEL_3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN3, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_4_REG ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_4_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_4_REG_INJ ((LL_ADC_CHANNEL_4 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN4, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_5_REG ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_5_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_5_REG_INJ ((LL_ADC_CHANNEL_5 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN5, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_6_REG ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_6_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_6_REG_INJ ((LL_ADC_CHANNEL_6 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN6, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_7_REG ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_7_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_7_REG_INJ ((LL_ADC_CHANNEL_7 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN7, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_8_REG ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_8_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_8_REG_INJ ((LL_ADC_CHANNEL_8 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN8, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_9_REG ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_9_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_9_REG_INJ ((LL_ADC_CHANNEL_9 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN9, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_10_REG ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_10_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_10_REG_INJ ((LL_ADC_CHANNEL_10 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN10, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_11_REG ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_11_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_11_REG_INJ ((LL_ADC_CHANNEL_11 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN11, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_12_REG ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_12_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_12_REG_INJ ((LL_ADC_CHANNEL_12 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN12, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_13_REG ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_13_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_13_REG_INJ ((LL_ADC_CHANNEL_13 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN13, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_14_REG ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_14_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_14_REG_INJ ((LL_ADC_CHANNEL_14 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN14, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_15_REG ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_15_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_15_REG_INJ ((LL_ADC_CHANNEL_15 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN15, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_16_REG ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_16_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_16_REG_INJ ((LL_ADC_CHANNEL_16 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN16, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_17_REG ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_17_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_17_REG_INJ ((LL_ADC_CHANNEL_17 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN17, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_18_REG ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_18_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_18_REG_INJ ((LL_ADC_CHANNEL_18 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN18, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_19_REG ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_19_INJ ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_19_REG_INJ ((LL_ADC_CHANNEL_19 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN19, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_20_REG ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_20_INJ ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_20_REG_INJ ((LL_ADC_CHANNEL_20 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN20, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_21_REG ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_21_INJ ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_21_REG_INJ ((LL_ADC_CHANNEL_21 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN21, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_22_REG ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_22_INJ ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_22_REG_INJ ((LL_ADC_CHANNEL_22 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN22, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_23_REG ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_23_INJ ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_23_REG_INJ ((LL_ADC_CHANNEL_23 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN23, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_24_REG ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_24_INJ ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_24_REG_INJ ((LL_ADC_CHANNEL_24 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN24, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_25_REG ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_25_INJ ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_25_REG_INJ ((LL_ADC_CHANNEL_25 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN25, converted by either group regular or injected */
-#define LL_ADC_AWD_CHANNEL_26_REG ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by group regular only */
-#define LL_ADC_AWD_CHANNEL_26_INJ ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by group injected only */
-#define LL_ADC_AWD_CHANNEL_26_REG_INJ ((LL_ADC_CHANNEL_26 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN26, converted by either group regular or injected */
-#if defined(ADC_SMPR0_SMP31)
-#define LL_ADC_AWD_CHANNEL_27_REG ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_27_INJ ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_27_REG_INJ ((LL_ADC_CHANNEL_27 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN27, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_28_REG ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_28_INJ ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_28_REG_INJ ((LL_ADC_CHANNEL_28 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN28, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_29_REG ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_29_INJ ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_29_REG_INJ ((LL_ADC_CHANNEL_29 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN29, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_30_REG ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_30_INJ ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_30_REG_INJ ((LL_ADC_CHANNEL_30 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN30, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_31_REG ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by group regular only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_31_INJ ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by group injected only. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#define LL_ADC_AWD_CHANNEL_31_REG_INJ ((LL_ADC_CHANNEL_31 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC external channel (channel connected to GPIO pin) ADCx_IN31, converted by either group regular or injected. On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5. */
-#endif /* ADC_SMPR0_SMP31 */
-#define LL_ADC_AWD_CH_VREFINT_REG ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group regular only. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VREFINT_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by group injected only. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VREFINT_REG_INJ ((LL_ADC_CHANNEL_VREFINT & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to VrefInt: Internal voltage reference, converted by either group regular or injected. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_TEMPSENSOR_REG ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group regular only. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_TEMPSENSOR_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by group injected only. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ ((LL_ADC_CHANNEL_TEMPSENSOR & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to Temperature sensor, converted by either group regular or injected. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VCOMP_REG ((LL_ADC_CHANNEL_VCOMP & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VCOMP_INJ ((LL_ADC_CHANNEL_VCOMP & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VCOMP_REG_INJ ((LL_ADC_CHANNEL_VCOMP & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to comparator COMP1 positive input via ADC switch matrix. Channel common to both bank A and bank B. */
-#if defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD) || defined (OPAMP_CSR_OPA3PD)
-#define LL_ADC_AWD_CH_VOPAMP1_REG ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VOPAMP1_INJ ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VOPAMP1_REG_INJ ((LL_ADC_CHANNEL_VOPAMP1 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP1 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VOPAMP2_REG ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VOPAMP2_INJ ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VOPAMP2_REG_INJ ((LL_ADC_CHANNEL_VOPAMP2 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP2 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#if defined(OPAMP_CSR_OPA3PD)
-#define LL_ADC_AWD_CH_VOPAMP3_REG ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VOPAMP3_INJ ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#define LL_ADC_AWD_CH_VOPAMP3_REG_INJ ((LL_ADC_CHANNEL_VOPAMP3 & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) /*!< ADC analog watchdog monitoring of ADC internal channel connected to OPAMP3 output via ADC switch matrix. Channel common to both bank A and bank B. */
-#endif /* OPAMP_CSR_OPA3PD */
-#endif /* OPAMP_CSR_OPA1PD || OPAMP_CSR_OPA2PD || OPAMP_CSR_OPA3PD */
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EC_AWD_THRESHOLDS Analog watchdog - Thresholds
- * @{
- */
-#define LL_ADC_AWD_THRESHOLD_HIGH (ADC_AWD_TR1_HIGH_REGOFFSET) /*!< ADC analog watchdog threshold high */
-#define LL_ADC_AWD_THRESHOLD_LOW (ADC_AWD_TR1_LOW_REGOFFSET) /*!< ADC analog watchdog threshold low */
-/**
- * @}
- */
-
-
-/** @defgroup ADC_LL_EC_HW_DELAYS Definitions of ADC hardware constraints delays
- * @note Only ADC IP HW delays are defined in ADC LL driver driver,
- * not timeout values.
- * For details on delays values, refer to descriptions in source code
- * above each literal definition.
- * @{
- */
-
-/* Note: Only ADC IP HW delays are defined in ADC LL driver driver, */
-/* not timeout values. */
-/* Timeout values for ADC operations are dependent to device clock */
-/* configuration (system clock versus ADC clock), */
-/* and therefore must be defined in user application. */
-/* Indications for estimation of ADC timeout delays, for this */
-/* STM32 serie: */
-/* - ADC enable time: maximum delay is 3.5us */
-/* (refer to device datasheet, parameter "tSTAB") */
-/* - ADC conversion time: duration depending on ADC clock and ADC */
-/* configuration. */
-/* (refer to device reference manual, section "Timing") */
-
-/* Delay for internal voltage reference stabilization time. */
-/* Delay set to maximum value (refer to device datasheet, */
-/* parameter "TADC_BUF"). */
-/* Unit: us */
-#define LL_ADC_DELAY_VREFINT_STAB_US ( 10U) /*!< Delay for internal voltage reference stabilization time */
-
-/* Delay for temperature sensor stabilization time. */
-/* Literal set to maximum value (refer to device datasheet, */
-/* parameter "tSTART"). */
-/* Unit: us */
-#define LL_ADC_DELAY_TEMPSENSOR_STAB_US ( 10U) /*!< Delay for internal voltage reference stabilization time */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-
-/* Exported macro ------------------------------------------------------------*/
-/** @defgroup ADC_LL_Exported_Macros ADC Exported Macros
- * @{
- */
-
-/** @defgroup ADC_LL_EM_WRITE_READ Common write and read registers Macros
- * @{
- */
-
-/**
- * @brief Write a value in ADC register
- * @param __INSTANCE__ ADC Instance
- * @param __REG__ Register to be written
- * @param __VALUE__ Value to be written in the register
- * @retval None
- */
-#define LL_ADC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
-
-/**
- * @brief Read a value in ADC register
- * @param __INSTANCE__ ADC Instance
- * @param __REG__ Register to be read
- * @retval Register value
- */
-#define LL_ADC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EM_HELPER_MACRO ADC helper macro
- * @{
- */
-
-/**
- * @brief Helper macro to get ADC channel number in decimal format
- * from literals LL_ADC_CHANNEL_x.
- * @note Example:
- * __LL_ADC_CHANNEL_TO_DECIMAL_NB(LL_ADC_CHANNEL_4)
- * will return decimal number "4".
- * @note The input can be a value from functions where a channel
- * number is returned, either defined with number
- * or with bitfield (only one bit must be set).
- * @param __CHANNEL__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
- * @retval Value between Min_Data=0 and Max_Data=18
- */
-#define __LL_ADC_CHANNEL_TO_DECIMAL_NB(__CHANNEL__) \
- (((__CHANNEL__) & ADC_CHANNEL_ID_NUMBER_MASK) >> ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS)
-
-/**
- * @brief Helper macro to get ADC channel in literal format LL_ADC_CHANNEL_x
- * from number in decimal format.
- * @note Example:
- * __LL_ADC_DECIMAL_NB_TO_CHANNEL(4)
- * will return a data equivalent to "LL_ADC_CHANNEL_4".
- * @param __DECIMAL_NB__ Value between Min_Data=0 and Max_Data=18
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
- * (6) For ADC channel read back from ADC register,
- * comparison with internal channel parameter to be done
- * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
- */
-#if defined(ADC_SMPR0_SMP31)
-#define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
- (((__DECIMAL_NB__) <= 9U) \
- ? ( \
- ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
- (ADC_SMPR3_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
- ) \
- : \
- (((__DECIMAL_NB__) <= 19U) \
- ? ( \
- ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
- (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
- ) \
- : \
- (((__DECIMAL_NB__) <= 28U) \
- ? ( \
- ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
- (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -20U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
- ) \
- : \
- ( \
- ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
- (ADC_SMPR0_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) - 30U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
- ) \
- ) \
- ) \
- )
-#else
-#define __LL_ADC_DECIMAL_NB_TO_CHANNEL(__DECIMAL_NB__) \
- (((__DECIMAL_NB__) <= 9U) \
- ? ( \
- ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
- (ADC_SMPR3_REGOFFSET | (((uint32_t) (3U * (__DECIMAL_NB__))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
- ) \
- : \
- (((__DECIMAL_NB__) <= 19U) \
- ? ( \
- ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
- (ADC_SMPR2_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -10U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
- ) \
- : \
- ( \
- ((__DECIMAL_NB__) << ADC_CHANNEL_ID_NUMBER_BITOFFSET_POS) | \
- (ADC_SMPR1_REGOFFSET | (((uint32_t) (3U * ((__DECIMAL_NB__) -20U))) << ADC_CHANNEL_SMPx_BITOFFSET_POS)) \
- ) \
- ) \
- )
-#endif /* ADC_SMPR0_SMP31 */
-
-/**
- * @brief Helper macro to determine whether the selected channel
- * corresponds to literal definitions of driver.
- * @note The different literal definitions of ADC channels are:
- * - ADC internal channel:
- * LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...
- * - ADC external channel (channel connected to a GPIO pin):
- * LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...
- * @note The channel parameter must be a value defined from literal
- * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
- * LL_ADC_CHANNEL_TEMPSENSOR, ...),
- * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...),
- * must not be a value from functions where a channel number is
- * returned from ADC registers,
- * because internal and external channels share the same channel
- * number in ADC registers. The differentiation is made only with
- * parameters definitions of driver.
- * @param __CHANNEL__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
- * @retval Value "0" if the channel corresponds to a parameter definition of a ADC external channel (channel connected to a GPIO pin).
- * Value "1" if the channel corresponds to a parameter definition of a ADC internal channel.
- */
-#define __LL_ADC_IS_CHANNEL_INTERNAL(__CHANNEL__) \
- (((__CHANNEL__) & ADC_CHANNEL_ID_INTERNAL_CH_MASK) != 0U)
-
-/**
- * @brief Helper macro to convert a channel defined from parameter
- * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
- * LL_ADC_CHANNEL_TEMPSENSOR, ...),
- * to its equivalent parameter definition of a ADC external channel
- * (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...).
- * @note The channel parameter can be, additionally to a value
- * defined from parameter definition of a ADC internal channel
- * (LL_ADC_CHANNEL_VREFINT, LL_ADC_CHANNEL_TEMPSENSOR, ...),
- * a value defined from parameter definition of
- * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
- * or a value from functions where a channel number is returned
- * from ADC registers.
- * @param __CHANNEL__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0
- * @arg @ref LL_ADC_CHANNEL_1
- * @arg @ref LL_ADC_CHANNEL_2
- * @arg @ref LL_ADC_CHANNEL_3
- * @arg @ref LL_ADC_CHANNEL_4
- * @arg @ref LL_ADC_CHANNEL_5
- * @arg @ref LL_ADC_CHANNEL_6
- * @arg @ref LL_ADC_CHANNEL_7
- * @arg @ref LL_ADC_CHANNEL_8
- * @arg @ref LL_ADC_CHANNEL_9
- * @arg @ref LL_ADC_CHANNEL_10
- * @arg @ref LL_ADC_CHANNEL_11
- * @arg @ref LL_ADC_CHANNEL_12
- * @arg @ref LL_ADC_CHANNEL_13
- * @arg @ref LL_ADC_CHANNEL_14
- * @arg @ref LL_ADC_CHANNEL_15
- * @arg @ref LL_ADC_CHANNEL_16
- * @arg @ref LL_ADC_CHANNEL_17
- * @arg @ref LL_ADC_CHANNEL_18
- */
-#define __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL(__CHANNEL__) \
- ((__CHANNEL__) & ~ADC_CHANNEL_ID_INTERNAL_CH_MASK)
-
-/**
- * @brief Helper macro to determine whether the internal channel
- * selected is available on the ADC instance selected.
- * @note The channel parameter must be a value defined from parameter
- * definition of a ADC internal channel (LL_ADC_CHANNEL_VREFINT,
- * LL_ADC_CHANNEL_TEMPSENSOR, ...),
- * must not be a value defined from parameter definition of
- * ADC external channel (LL_ADC_CHANNEL_1, LL_ADC_CHANNEL_2, ...)
- * or a value from functions where a channel number is
- * returned from ADC registers,
- * because internal and external channels share the same channel
- * number in ADC registers. The differentiation is made only with
- * parameters definitions of driver.
- * @param __ADC_INSTANCE__ ADC instance
- * @param __CHANNEL__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
- * @retval Value "0" if the internal channel selected is not available on the ADC instance selected.
- * Value "1" if the internal channel selected is available on the ADC instance selected.
- */
-#if defined (OPAMP_CSR_OPA3PD)
-#define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
- ( \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP3) \
- )
-#elif defined(OPAMP_CSR_OPA1PD) || defined (OPAMP_CSR_OPA2PD)
-#define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
- ( \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP1) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VOPAMP2) \
- )
-#else
-#define __LL_ADC_IS_CHANNEL_INTERNAL_AVAILABLE(__ADC_INSTANCE__, __CHANNEL__) \
- ( \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VREFINT) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_TEMPSENSOR) || \
- ((__CHANNEL__) == LL_ADC_CHANNEL_VCOMP) \
- )
-#endif
-
-/**
- * @brief Helper macro to define ADC analog watchdog parameter:
- * define a single channel to monitor with analog watchdog
- * from sequencer channel and groups definition.
- * @note To be used with function @ref LL_ADC_SetAnalogWDMonitChannels().
- * Example:
- * LL_ADC_SetAnalogWDMonitChannels(
- * ADC1, LL_ADC_AWD1,
- * __LL_ADC_ANALOGWD_CHANNEL_GROUP(LL_ADC_CHANNEL4, LL_ADC_GROUP_REGULAR))
- * @param __CHANNEL__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
- * (6) For ADC channel read back from ADC register,
- * comparison with internal channel parameter to be done
- * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
- * @param __GROUP__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_GROUP_REGULAR
- * @arg @ref LL_ADC_GROUP_INJECTED
- * @arg @ref LL_ADC_GROUP_REGULAR_INJECTED
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_AWD_DISABLE
- * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
- * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
- * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
- * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_20_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_20_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_21_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_21_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_22_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_22_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_23_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_23_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_24_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_24_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_25_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_25_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_26_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_26_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_27_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_27_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_28_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_28_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_29_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_29_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_30_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_30_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_31_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_31_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (3)
- * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (3)
- * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_VCOMP_REG (3)
- * @arg @ref LL_ADC_AWD_CH_VCOMP_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_VCOMP_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
- */
-#define __LL_ADC_ANALOGWD_CHANNEL_GROUP(__CHANNEL__, __GROUP__) \
- (((__GROUP__) == LL_ADC_GROUP_REGULAR) \
- ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
- : \
- ((__GROUP__) == LL_ADC_GROUP_INJECTED) \
- ? (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL) \
- : \
- (((__CHANNEL__) & ADC_CHANNEL_ID_MASK) | ADC_CR1_JAWDEN | ADC_CR1_AWDEN | ADC_CR1_AWDSGL) \
- )
-
-/**
- * @brief Helper macro to set the value of ADC analog watchdog threshold high
- * or low in function of ADC resolution, when ADC resolution is
- * different of 12 bits.
- * @note To be used with function @ref LL_ADC_SetAnalogWDThresholds().
- * Example, with a ADC resolution of 8 bits, to set the value of
- * analog watchdog threshold high (on 8 bits):
- * LL_ADC_SetAnalogWDThresholds
- * (< ADCx param >,
- * __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(LL_ADC_RESOLUTION_8B, )
- * );
- * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @param __AWD_THRESHOLD__ Value between Min_Data=0x000 and Max_Data=0xFFF
- * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
- */
-#define __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD__) \
- ((__AWD_THRESHOLD__) << ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U )))
-
-/**
- * @brief Helper macro to get the value of ADC analog watchdog threshold high
- * or low in function of ADC resolution, when ADC resolution is
- * different of 12 bits.
- * @note To be used with function @ref LL_ADC_GetAnalogWDThresholds().
- * Example, with a ADC resolution of 8 bits, to get the value of
- * analog watchdog threshold high (on 8 bits):
- * < threshold_value_6_bits > = __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION
- * (LL_ADC_RESOLUTION_8B,
- * LL_ADC_GetAnalogWDThresholds(, LL_ADC_AWD_THRESHOLD_HIGH)
- * );
- * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @param __AWD_THRESHOLD_12_BITS__ Value between Min_Data=0x000 and Max_Data=0xFFF
- * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
- */
-#define __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION(__ADC_RESOLUTION__, __AWD_THRESHOLD_12_BITS__) \
- ((__AWD_THRESHOLD_12_BITS__) >> ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U )))
-
-/**
- * @brief Helper macro to select the ADC common instance
- * to which is belonging the selected ADC instance.
- * @note ADC common register instance can be used for:
- * - Set parameters common to several ADC instances
- * - Multimode (for devices with several ADC instances)
- * Refer to functions having argument "ADCxy_COMMON" as parameter.
- * @param __ADCx__ ADC instance
- * @retval ADC common register instance
- */
-#define __LL_ADC_COMMON_INSTANCE(__ADCx__) \
- (ADC1_COMMON)
-
-/**
- * @brief Helper macro to check if all ADC instances sharing the same
- * ADC common instance are disabled.
- * @note This check is required by functions with setting conditioned to
- * ADC state:
- * All ADC instances of the ADC common group must be disabled.
- * Refer to functions having argument "ADCxy_COMMON" as parameter.
- * @note On devices with only 1 ADC common instance, parameter of this macro
- * is useless and can be ignored (parameter kept for compatibility
- * with devices featuring several ADC common instances).
- * @param __ADCXY_COMMON__ ADC common instance
- * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
- * @retval Value "0" if all ADC instances sharing the same ADC common instance
- * are disabled.
- * Value "1" if at least one ADC instance sharing the same ADC common instance
- * is enabled.
- */
-#define __LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(__ADCXY_COMMON__) \
- LL_ADC_IsEnabled(ADC1)
-
-/**
- * @brief Helper macro to define the ADC conversion data full-scale digital
- * value corresponding to the selected ADC resolution.
- * @note ADC conversion data full-scale corresponds to voltage range
- * determined by analog voltage references Vref+ and Vref-
- * (refer to reference manual).
- * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @retval ADC conversion data equivalent voltage value (unit: mVolt)
- */
-#define __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
- (0xFFFU >> ((__ADC_RESOLUTION__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U)))
-
-/**
- * @brief Helper macro to convert the ADC conversion data from
- * a resolution to another resolution.
- * @param __DATA__ ADC conversion data to be converted
- * @param __ADC_RESOLUTION_CURRENT__ Resolution of to the data to be converted
- * This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @param __ADC_RESOLUTION_TARGET__ Resolution of the data after conversion
- * This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @retval ADC conversion data to the requested resolution
- */
-#define __LL_ADC_CONVERT_DATA_RESOLUTION(__DATA__, __ADC_RESOLUTION_CURRENT__, __ADC_RESOLUTION_TARGET__) \
- (((__DATA__) \
- << ((__ADC_RESOLUTION_CURRENT__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U))) \
- >> ((__ADC_RESOLUTION_TARGET__) >> (ADC_CR1_RES_BITOFFSET_POS - 1U)) \
- )
-
-/**
- * @brief Helper macro to calculate the voltage (unit: mVolt)
- * corresponding to a ADC conversion data (unit: digital value).
- * @note Analog reference voltage (Vref+) must be either known from
- * user board environment or can be calculated using ADC measurement
- * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
- * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
- * @param __ADC_DATA__ ADC conversion data (resolution 12 bits)
- * (unit: digital value).
- * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @retval ADC conversion data equivalent voltage value (unit: mVolt)
- */
-#define __LL_ADC_CALC_DATA_TO_VOLTAGE(__VREFANALOG_VOLTAGE__,\
- __ADC_DATA__,\
- __ADC_RESOLUTION__) \
- ((__ADC_DATA__) * (__VREFANALOG_VOLTAGE__) \
- / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__) \
- )
-
-/**
- * @brief Helper macro to calculate analog reference voltage (Vref+)
- * (unit: mVolt) from ADC conversion data of internal voltage
- * reference VrefInt.
- * @note Computation is using VrefInt calibration value
- * stored in system memory for each device during production.
- * @note This voltage depends on user board environment: voltage level
- * connected to pin Vref+.
- * On devices with small package, the pin Vref+ is not present
- * and internally bonded to pin Vdda.
- * @note On this STM32 serie, calibration data of internal voltage reference
- * VrefInt corresponds to a resolution of 12 bits,
- * this is the recommended ADC resolution to convert voltage of
- * internal voltage reference VrefInt.
- * Otherwise, this macro performs the processing to scale
- * ADC conversion data to 12 bits.
- * @param __VREFINT_ADC_DATA__ ADC conversion data (resolution 12 bits)
- * of internal voltage reference VrefInt (unit: digital value).
- * @param __ADC_RESOLUTION__ This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @retval Analog reference voltage (unit: mV)
- */
-#define __LL_ADC_CALC_VREFANALOG_VOLTAGE(__VREFINT_ADC_DATA__,\
- __ADC_RESOLUTION__) \
- (((uint32_t)(*VREFINT_CAL_ADDR) * VREFINT_CAL_VREF) \
- / __LL_ADC_CONVERT_DATA_RESOLUTION((__VREFINT_ADC_DATA__), \
- (__ADC_RESOLUTION__), \
- LL_ADC_RESOLUTION_12B) \
- )
-
-/* Note: On device STM32L100, calibration parameters TS_CAL1 and TS_CAL2 are not available. */
-/* Therefore, helper macro __LL_ADC_CALC_TEMPERATURE() is not available.*/
-/* Use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(). */
-#if defined(TEMPSENSOR_CAL1_ADDR_CMSIS)
-/**
- * @brief Helper macro to calculate the temperature (unit: degree Celsius)
- * from ADC conversion data of internal temperature sensor.
- * @note Computation is using temperature sensor calibration values
- * stored in system memory for each device during production.
- * @note Calculation formula:
- * Temperature = ((TS_ADC_DATA - TS_CAL1)
- * * (TS_CAL2_TEMP - TS_CAL1_TEMP))
- * / (TS_CAL2 - TS_CAL1) + TS_CAL1_TEMP
- * with TS_ADC_DATA = temperature sensor raw data measured by ADC
- * Avg_Slope = (TS_CAL2 - TS_CAL1)
- * / (TS_CAL2_TEMP - TS_CAL1_TEMP)
- * TS_CAL1 = equivalent TS_ADC_DATA at temperature
- * TEMP_DEGC_CAL1 (calibrated in factory)
- * TS_CAL2 = equivalent TS_ADC_DATA at temperature
- * TEMP_DEGC_CAL2 (calibrated in factory)
- * Caution: Calculation relevancy under reserve that calibration
- * parameters are correct (address and data).
- * To calculate temperature using temperature sensor
- * datasheet typical values (generic values less, therefore
- * less accurate than calibrated values),
- * use helper macro @ref __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS().
- * @note As calculation input, the analog reference voltage (Vref+) must be
- * defined as it impacts the ADC LSB equivalent voltage.
- * @note Analog reference voltage (Vref+) must be either known from
- * user board environment or can be calculated using ADC measurement
- * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
- * @note On this STM32 serie, calibration data of temperature sensor
- * corresponds to a resolution of 12 bits,
- * this is the recommended ADC resolution to convert voltage of
- * temperature sensor.
- * Otherwise, this macro performs the processing to scale
- * ADC conversion data to 12 bits.
- * @param __VREFANALOG_VOLTAGE__ Analog reference voltage (unit: mV)
- * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal
- * temperature sensor (unit: digital value).
- * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature
- * sensor voltage has been measured.
- * This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @retval Temperature (unit: degree Celsius)
- */
-#define __LL_ADC_CALC_TEMPERATURE(__VREFANALOG_VOLTAGE__,\
- __TEMPSENSOR_ADC_DATA__,\
- __ADC_RESOLUTION__) \
- (((( ((int32_t)((__LL_ADC_CONVERT_DATA_RESOLUTION((__TEMPSENSOR_ADC_DATA__), \
- (__ADC_RESOLUTION__), \
- LL_ADC_RESOLUTION_12B) \
- * (__VREFANALOG_VOLTAGE__)) \
- / TEMPSENSOR_CAL_VREFANALOG) \
- - (int32_t) *TEMPSENSOR_CAL1_ADDR) \
- ) * (int32_t)(TEMPSENSOR_CAL2_TEMP - TEMPSENSOR_CAL1_TEMP) \
- ) / (int32_t)((int32_t)*TEMPSENSOR_CAL2_ADDR - (int32_t)*TEMPSENSOR_CAL1_ADDR) \
- ) + TEMPSENSOR_CAL1_TEMP \
- )
-#endif /* TEMPSENSOR_CAL1_ADDR_CMSIS */
-
-/**
- * @brief Helper macro to calculate the temperature (unit: degree Celsius)
- * from ADC conversion data of internal temperature sensor.
- * @note Computation is using temperature sensor typical values
- * (refer to device datasheet).
- * @note Calculation formula:
- * Temperature = (TS_TYP_CALx_VOLT(uV) - TS_ADC_DATA * Conversion_uV)
- * / Avg_Slope + CALx_TEMP
- * with TS_ADC_DATA = temperature sensor raw data measured by ADC
- * (unit: digital value)
- * Avg_Slope = temperature sensor slope
- * (unit: uV/Degree Celsius)
- * TS_TYP_CALx_VOLT = temperature sensor digital value at
- * temperature CALx_TEMP (unit: mV)
- * Caution: Calculation relevancy under reserve the temperature sensor
- * of the current device has characteristics in line with
- * datasheet typical values.
- * If temperature sensor calibration values are available on
- * on this device (presence of macro __LL_ADC_CALC_TEMPERATURE()),
- * temperature calculation will be more accurate using
- * helper macro @ref __LL_ADC_CALC_TEMPERATURE().
- * @note As calculation input, the analog reference voltage (Vref+) must be
- * defined as it impacts the ADC LSB equivalent voltage.
- * @note Analog reference voltage (Vref+) must be either known from
- * user board environment or can be calculated using ADC measurement
- * and ADC helper macro @ref __LL_ADC_CALC_VREFANALOG_VOLTAGE().
- * @note ADC measurement data must correspond to a resolution of 12bits
- * (full scale digital value 4095). If not the case, the data must be
- * preliminarily rescaled to an equivalent resolution of 12 bits.
- * @param __TEMPSENSOR_TYP_AVGSLOPE__ Device datasheet data: Temperature sensor slope typical value (unit: uV/DegCelsius).
- * On STM32L1, refer to device datasheet parameter "Avg_Slope".
- * @param __TEMPSENSOR_TYP_CALX_V__ Device datasheet data: Temperature sensor voltage typical value (at temperature and Vref+ defined in parameters below) (unit: mV).
- * On STM32L1, refer to device datasheet parameter "V110" (corresponding to TS_CAL2).
- * @param __TEMPSENSOR_CALX_TEMP__ Device datasheet data: Temperature at which temperature sensor voltage (see parameter above) is corresponding (unit: mV)
- * @param __VREFANALOG_VOLTAGE__ Analog voltage reference (Vref+) voltage (unit: mV)
- * @param __TEMPSENSOR_ADC_DATA__ ADC conversion data of internal temperature sensor (unit: digital value).
- * @param __ADC_RESOLUTION__ ADC resolution at which internal temperature sensor voltage has been measured.
- * This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @retval Temperature (unit: degree Celsius)
- */
-#define __LL_ADC_CALC_TEMPERATURE_TYP_PARAMS(__TEMPSENSOR_TYP_AVGSLOPE__,\
- __TEMPSENSOR_TYP_CALX_V__,\
- __TEMPSENSOR_CALX_TEMP__,\
- __VREFANALOG_VOLTAGE__,\
- __TEMPSENSOR_ADC_DATA__,\
- __ADC_RESOLUTION__) \
- ((( ( \
- (int32_t)((((__TEMPSENSOR_ADC_DATA__) * (__VREFANALOG_VOLTAGE__)) \
- / __LL_ADC_DIGITAL_SCALE(__ADC_RESOLUTION__)) \
- * 1000) \
- - \
- (int32_t)(((__TEMPSENSOR_TYP_CALX_V__)) \
- * 1000) \
- ) \
- ) / (__TEMPSENSOR_TYP_AVGSLOPE__) \
- ) + (__TEMPSENSOR_CALX_TEMP__) \
- )
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-
-/* Exported functions --------------------------------------------------------*/
-/** @defgroup ADC_LL_Exported_Functions ADC Exported Functions
- * @{
- */
-
-/** @defgroup ADC_LL_EF_DMA_Management ADC DMA management
- * @{
- */
-/* Note: LL ADC functions to set DMA transfer are located into sections of */
-/* configuration of ADC instance, groups and multimode (if available): */
-/* @ref LL_ADC_REG_SetDMATransfer(), ... */
-
-/**
- * @brief Function to help to configure DMA transfer from ADC: retrieve the
- * ADC register address from ADC instance and a list of ADC registers
- * intended to be used (most commonly) with DMA transfer.
- * @note These ADC registers are data registers:
- * when ADC conversion data is available in ADC data registers,
- * ADC generates a DMA transfer request.
- * @note This macro is intended to be used with LL DMA driver, refer to
- * function "LL_DMA_ConfigAddresses()".
- * Example:
- * LL_DMA_ConfigAddresses(DMA1,
- * LL_DMA_CHANNEL_1,
- * LL_ADC_DMA_GetRegAddr(ADC1, LL_ADC_DMA_REG_REGULAR_DATA),
- * (uint32_t)&< array or variable >,
- * LL_DMA_DIRECTION_PERIPH_TO_MEMORY);
- * @note For devices with several ADC: in multimode, some devices
- * use a different data register outside of ADC instance scope
- * (common data register). This macro manages this register difference,
- * only ADC instance has to be set as parameter.
- * @rmtoll DR DATA LL_ADC_DMA_GetRegAddr
- * @param ADCx ADC instance
- * @param Register This parameter can be one of the following values:
- * @arg @ref LL_ADC_DMA_REG_REGULAR_DATA
- * @retval ADC register address
- */
-__STATIC_INLINE uint32_t LL_ADC_DMA_GetRegAddr(ADC_TypeDef *ADCx, uint32_t Register)
-{
- /* Retrieve address of register DR */
- return (uint32_t)&(ADCx->DR);
-}
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_Configuration_ADC_Common Configuration of ADC hierarchical scope: common to several ADC instances
- * @{
- */
-
-/**
- * @brief Set parameter common to several ADC: Clock source and prescaler.
- * @note On this STM32 serie, HSI RC oscillator is the only clock source for ADC.
- * Therefore, HSI RC oscillator must be preliminarily enabled at RCC top level.
- * @note On this STM32 serie, some clock ratio constraints between ADC clock and APB clock
- * must be respected:
- * - In all cases: if APB clock frequency is too low compared ADC clock frequency, a delay between conversions must be inserted.
- * - If ADC group injected is used: ADC clock frequency should be lower than APB clock frequency /4 for resolution 12 or 10 bits, APB clock frequency /3 for resolution 8 bits, APB clock frequency /2 for resolution 6 bits.
- * Refer to reference manual.
- * @rmtoll CCR ADCPRE LL_ADC_SetCommonClock
- * @param ADCxy_COMMON ADC common instance
- * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
- * @param CommonClock This parameter can be one of the following values:
- * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
- * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
- * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t CommonClock)
-{
- MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_ADCPRE, CommonClock);
-}
-
-/**
- * @brief Get parameter common to several ADC: Clock source and prescaler.
- * @rmtoll CCR ADCPRE LL_ADC_GetCommonClock
- * @param ADCxy_COMMON ADC common instance
- * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_CLOCK_ASYNC_DIV1
- * @arg @ref LL_ADC_CLOCK_ASYNC_DIV2
- * @arg @ref LL_ADC_CLOCK_ASYNC_DIV4
- */
-__STATIC_INLINE uint32_t LL_ADC_GetCommonClock(ADC_Common_TypeDef *ADCxy_COMMON)
-{
- return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_ADCPRE));
-}
-
-/**
- * @brief Set parameter common to several ADC: measurement path to internal
- * channels (VrefInt, temperature sensor, ...).
- * @note One or several values can be selected.
- * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
- * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
- * @note Stabilization time of measurement path to internal channel:
- * After enabling internal paths, before starting ADC conversion,
- * a delay is required for internal voltage reference and
- * temperature sensor stabilization time.
- * Refer to device datasheet.
- * Refer to literal @ref LL_ADC_DELAY_VREFINT_STAB_US.
- * Refer to literal @ref LL_ADC_DELAY_TEMPSENSOR_STAB_US.
- * @note ADC internal channel sampling time constraint:
- * For ADC conversion of internal channels,
- * a sampling time minimum value is required.
- * Refer to device datasheet.
- * @rmtoll CCR TSVREFE LL_ADC_SetCommonPathInternalCh
- * @param ADCxy_COMMON ADC common instance
- * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
- * @param PathInternal This parameter can be a combination of the following values:
- * @arg @ref LL_ADC_PATH_INTERNAL_NONE
- * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
- * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON, uint32_t PathInternal)
-{
- MODIFY_REG(ADCxy_COMMON->CCR, ADC_CCR_TSVREFE, PathInternal);
-}
-
-/**
- * @brief Get parameter common to several ADC: measurement path to internal
- * channels (VrefInt, temperature sensor, ...).
- * @note One or several values can be selected.
- * Example: (LL_ADC_PATH_INTERNAL_VREFINT |
- * LL_ADC_PATH_INTERNAL_TEMPSENSOR)
- * @rmtoll CCR TSVREFE LL_ADC_GetCommonPathInternalCh
- * @param ADCxy_COMMON ADC common instance
- * (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
- * @retval Returned value can be a combination of the following values:
- * @arg @ref LL_ADC_PATH_INTERNAL_NONE
- * @arg @ref LL_ADC_PATH_INTERNAL_VREFINT
- * @arg @ref LL_ADC_PATH_INTERNAL_TEMPSENSOR
- */
-__STATIC_INLINE uint32_t LL_ADC_GetCommonPathInternalCh(ADC_Common_TypeDef *ADCxy_COMMON)
-{
- return (uint32_t)(READ_BIT(ADCxy_COMMON->CCR, ADC_CCR_TSVREFE));
-}
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_Configuration_ADC_Instance Configuration of ADC hierarchical scope: ADC instance
- * @{
- */
-
-/**
- * @brief Set ADC resolution.
- * Refer to reference manual for alignments formats
- * dependencies to ADC resolutions.
- * @rmtoll CR1 RES LL_ADC_SetResolution
- * @param ADCx ADC instance
- * @param Resolution This parameter can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetResolution(ADC_TypeDef *ADCx, uint32_t Resolution)
-{
- MODIFY_REG(ADCx->CR1, ADC_CR1_RES, Resolution);
-}
-
-/**
- * @brief Get ADC resolution.
- * Refer to reference manual for alignments formats
- * dependencies to ADC resolutions.
- * @rmtoll CR1 RES LL_ADC_GetResolution
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_RESOLUTION_12B
- * @arg @ref LL_ADC_RESOLUTION_10B
- * @arg @ref LL_ADC_RESOLUTION_8B
- * @arg @ref LL_ADC_RESOLUTION_6B
- */
-__STATIC_INLINE uint32_t LL_ADC_GetResolution(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_RES));
-}
-
-/**
- * @brief Set ADC conversion data alignment.
- * @note Refer to reference manual for alignments formats
- * dependencies to ADC resolutions.
- * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
- * @param ADCx ADC instance
- * @param DataAlignment This parameter can be one of the following values:
- * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
- * @arg @ref LL_ADC_DATA_ALIGN_LEFT
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetDataAlignment(ADC_TypeDef *ADCx, uint32_t DataAlignment)
-{
- MODIFY_REG(ADCx->CR2, ADC_CR2_ALIGN, DataAlignment);
-}
-
-/**
- * @brief Get ADC conversion data alignment.
- * @note Refer to reference manual for alignments formats
- * dependencies to ADC resolutions.
- * @rmtoll CR2 ALIGN LL_ADC_SetDataAlignment
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_DATA_ALIGN_RIGHT
- * @arg @ref LL_ADC_DATA_ALIGN_LEFT
- */
-__STATIC_INLINE uint32_t LL_ADC_GetDataAlignment(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_ALIGN));
-}
-
-/**
- * @brief Set ADC low power mode auto wait.
- * @note Description of ADC low power modes:
- * - ADC low power mode "auto wait": Dynamic low power mode,
- * ADC conversions occurrences are limited to the minimum necessary
- * in order to reduce power consumption.
- * New ADC conversion starts only when the previous
- * unitary conversion data (for ADC group regular)
- * or previous sequence conversions data (for ADC group injected)
- * has been retrieved by user software.
- * In the meantime, ADC remains idle: does not performs any
- * other conversion.
- * This mode allows to automatically adapt the ADC conversions
- * triggers to the speed of the software that reads the data.
- * Moreover, this avoids risk of overrun for low frequency
- * applications.
- * How to use this low power mode:
- * - Do not use with interruption or DMA since these modes
- * have to clear immediately the EOC flag to free the
- * IRQ vector sequencer.
- * - Do use with polling: 1. Start conversion,
- * 2. Later on, when conversion data is needed: poll for end of
- * conversion to ensure that conversion is completed and
- * retrieve ADC conversion data. This will trig another
- * ADC conversion start.
- * - ADC low power mode "auto power-off":
- * refer to function @ref LL_ADC_SetLowPowerModeAutoPowerOff().
- * @note With ADC low power mode "auto wait", the ADC conversion data read
- * is corresponding to previous ADC conversion start, independently
- * of delay during which ADC was idle.
- * Therefore, the ADC conversion data may be outdated: does not
- * correspond to the current voltage level on the selected
- * ADC channel.
- * @rmtoll CR2 DELS LL_ADC_SetLowPowerModeAutoWait
- * @param ADCx ADC instance
- * @param LowPowerModeAutoWait This parameter can be one of the following values:
- * @arg @ref LL_ADC_LP_AUTOWAIT_NONE
- * @arg @ref LL_ADC_LP_AUTOWAIT
- * @arg @ref LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES
- * @arg @ref LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES
- * @arg @ref LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES
- * @arg @ref LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES
- * @arg @ref LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES
- * @arg @ref LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetLowPowerModeAutoWait(ADC_TypeDef *ADCx, uint32_t LowPowerModeAutoWait)
-{
- MODIFY_REG(ADCx->CR2, ADC_CR2_DELS, LowPowerModeAutoWait);
-}
-
-/**
- * @brief Get ADC low power mode auto wait.
- * @note Description of ADC low power modes:
- * - ADC low power mode "auto wait": Dynamic low power mode,
- * ADC conversions occurrences are limited to the minimum necessary
- * in order to reduce power consumption.
- * New ADC conversion starts only when the previous
- * unitary conversion data (for ADC group regular)
- * or previous sequence conversions data (for ADC group injected)
- * has been retrieved by user software.
- * In the meantime, ADC remains idle: does not performs any
- * other conversion.
- * This mode allows to automatically adapt the ADC conversions
- * triggers to the speed of the software that reads the data.
- * Moreover, this avoids risk of overrun for low frequency
- * applications.
- * How to use this low power mode:
- * - Do not use with interruption or DMA since these modes
- * have to clear immediately the EOC flag to free the
- * IRQ vector sequencer.
- * - Do use with polling: 1. Start conversion,
- * 2. Later on, when conversion data is needed: poll for end of
- * conversion to ensure that conversion is completed and
- * retrieve ADC conversion data. This will trig another
- * ADC conversion start.
- * - ADC low power mode "auto power-off":
- * refer to function @ref LL_ADC_SetLowPowerModeAutoPowerOff().
- * @note With ADC low power mode "auto wait", the ADC conversion data read
- * is corresponding to previous ADC conversion start, independently
- * of delay during which ADC was idle.
- * Therefore, the ADC conversion data may be outdated: does not
- * correspond to the current voltage level on the selected
- * ADC channel.
- * @rmtoll CR2 DELS LL_ADC_GetLowPowerModeAutoWait
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_LP_AUTOWAIT_NONE
- * @arg @ref LL_ADC_LP_AUTOWAIT
- * @arg @ref LL_ADC_LP_AUTOWAIT_7_APBCLOCKCYCLES
- * @arg @ref LL_ADC_LP_AUTOWAIT_15_APBCLOCKCYCLES
- * @arg @ref LL_ADC_LP_AUTOWAIT_31_APBCLOCKCYCLES
- * @arg @ref LL_ADC_LP_AUTOWAIT_63_APBCLOCKCYCLES
- * @arg @ref LL_ADC_LP_AUTOWAIT_127_APBCLOCKCYCLES
- * @arg @ref LL_ADC_LP_AUTOWAIT_255_APBCLOCKCYCLES
- */
-__STATIC_INLINE uint32_t LL_ADC_GetLowPowerModeAutoWait(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DELS));
-}
-
-/**
- * @brief Set ADC low power mode auto power-off.
- * @note Description of ADC low power modes:
- * - ADC low power mode "auto wait":
- * refer to function @ref LL_ADC_SetLowPowerModeAutoWait().
- * - ADC low power mode "auto power-off":
- * the ADC automatically powers-off after a conversion and
- * automatically wakes up when a new conversion is triggered
- * (with startup time between trigger and start of sampling).
- * This feature can be combined with low power mode "auto wait".
- * @rmtoll CR1 PDI LL_ADC_GetLowPowerModeAutoPowerOff\n
- * CR1 PDD LL_ADC_GetLowPowerModeAutoPowerOff
- * @param ADCx ADC instance
- * @param LowPowerModeAutoPowerOff This parameter can be one of the following values:
- * @arg @ref LL_ADC_LP_AUTOPOWEROFF_NONE
- * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE
- * @arg @ref LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE
- * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetLowPowerModeAutoPowerOff(ADC_TypeDef *ADCx, uint32_t LowPowerModeAutoPowerOff)
-{
- MODIFY_REG(ADCx->CR1, (ADC_CR1_PDI | ADC_CR1_PDD), LowPowerModeAutoPowerOff);
-}
-
-/**
- * @brief Get ADC low power mode auto power-off.
- * @note Description of ADC low power modes:
- * - ADC low power mode "auto wait":
- * refer to function @ref LL_ADC_SetLowPowerModeAutoWait().
- * - ADC low power mode "auto power-off":
- * the ADC automatically powers-off after a conversion and
- * automatically wakes up when a new conversion is triggered
- * (with startup time between trigger and start of sampling).
- * This feature can be combined with low power mode "auto wait".
- * @rmtoll CR1 PDI LL_ADC_GetLowPowerModeAutoPowerOff\n
- * CR1 PDD LL_ADC_GetLowPowerModeAutoPowerOff
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_LP_AUTOPOWEROFF_NONE
- * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_PHASE
- * @arg @ref LL_ADC_LP_AUTOPOWEROFF_AUTOWAIT_PHASE
- * @arg @ref LL_ADC_LP_AUTOPOWEROFF_IDLE_AUTOWAIT_PHASES
- */
-__STATIC_INLINE uint32_t LL_ADC_GetLowPowerModeAutoPowerOff(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_PDI | ADC_CR1_PDD)));
-}
-
-/**
- * @brief Set ADC sequencers scan mode, for all ADC groups
- * (group regular, group injected).
- * @note According to sequencers scan mode :
- * - If disabled: ADC conversion is performed in unitary conversion
- * mode (one channel converted, that defined in rank 1).
- * Configuration of sequencers of all ADC groups
- * (sequencer scan length, ...) is discarded: equivalent to
- * scan length of 1 rank.
- * - If enabled: ADC conversions are performed in sequence conversions
- * mode, according to configuration of sequencers of
- * each ADC group (sequencer scan length, ...).
- * Refer to function @ref LL_ADC_REG_SetSequencerLength()
- * and to function @ref LL_ADC_INJ_SetSequencerLength().
- * @note On this STM32 serie, setting of this feature is conditioned to
- * ADC state:
- * ADC must be disabled or enabled without conversion on going
- * on either groups regular or injected.
- * @rmtoll CR1 SCAN LL_ADC_SetSequencersScanMode
- * @param ADCx ADC instance
- * @param ScanMode This parameter can be one of the following values:
- * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
- * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetSequencersScanMode(ADC_TypeDef *ADCx, uint32_t ScanMode)
-{
- MODIFY_REG(ADCx->CR1, ADC_CR1_SCAN, ScanMode);
-}
-
-/**
- * @brief Get ADC sequencers scan mode, for all ADC groups
- * (group regular, group injected).
- * @note According to sequencers scan mode :
- * - If disabled: ADC conversion is performed in unitary conversion
- * mode (one channel converted, that defined in rank 1).
- * Configuration of sequencers of all ADC groups
- * (sequencer scan length, ...) is discarded: equivalent to
- * scan length of 1 rank.
- * - If enabled: ADC conversions are performed in sequence conversions
- * mode, according to configuration of sequencers of
- * each ADC group (sequencer scan length, ...).
- * Refer to function @ref LL_ADC_REG_SetSequencerLength()
- * and to function @ref LL_ADC_INJ_SetSequencerLength().
- * @rmtoll CR1 SCAN LL_ADC_GetSequencersScanMode
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_SEQ_SCAN_DISABLE
- * @arg @ref LL_ADC_SEQ_SCAN_ENABLE
- */
-__STATIC_INLINE uint32_t LL_ADC_GetSequencersScanMode(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_SCAN));
-}
-
-#if defined(ADC_CR2_CFG)
-/**
- * @brief Set ADC channels bank.
- * @note Bank selected applies to ADC scope, on all channels
- * (independently of channel mapped on ADC group regular
- * or group injected).
- * @note Banks availability depends on devices categories.
- * @note On this STM32 serie, setting of this feature is conditioned to
- * ADC state:
- * ADC must be disabled or enabled without conversion on going
- * on either groups regular or injected.
- * @rmtoll CR2 ADC_CFG LL_ADC_SetChannelsBank
- * @param ADCx ADC instance
- * @param ChannelsBank This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNELS_BANK_A
- * @arg @ref LL_ADC_CHANNELS_BANK_B
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetChannelsBank(ADC_TypeDef *ADCx, uint32_t ChannelsBank)
-{
- MODIFY_REG(ADCx->CR2, ADC_CR2_CFG, ChannelsBank);
-}
-
-/**
- * @brief Get ADC channels bank.
- * @note Bank selected applies to ADC scope, on all channels
- * (independently of channel mapped on ADC group regular
- * or group injected).
- * @note Banks availability depends on devices categories.
- * @rmtoll CR2 ADC_CFG LL_ADC_GetChannelsBank
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_CHANNELS_BANK_A
- * @arg @ref LL_ADC_CHANNELS_BANK_B
- */
-__STATIC_INLINE uint32_t LL_ADC_GetChannelsBank(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CFG));
-}
-#endif
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_Configuration_ADC_Group_Regular Configuration of ADC hierarchical scope: group regular
- * @{
- */
-
-/**
- * @brief Set ADC group regular conversion trigger source:
- * internal (SW start) or from external IP (timer event,
- * external interrupt line).
- * @note On this STM32 serie, setting of external trigger edge is performed
- * using function @ref LL_ADC_REG_StartConversionExtTrig().
- * @note Availability of parameters of trigger sources from timer
- * depends on timers availability on the selected device.
- * @rmtoll CR2 EXTSEL LL_ADC_REG_SetTriggerSource\n
- * CR2 EXTEN LL_ADC_REG_SetTriggerSource
- * @param ADCx ADC instance
- * @param TriggerSource This parameter can be one of the following values:
- * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH3
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_CH2
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_TRGO
- * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_REG_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
-{
-/* Note: On this STM32 serie, ADC group regular external trigger edge */
-/* is used to perform a ADC conversion start. */
-/* This function does not set external trigger edge. */
-/* This feature is set using function */
-/* @ref LL_ADC_REG_StartConversionExtTrig(). */
- MODIFY_REG(ADCx->CR2, ADC_CR2_EXTSEL, (TriggerSource & ADC_CR2_EXTSEL));
-}
-
-/**
- * @brief Get ADC group regular conversion trigger source:
- * internal (SW start) or from external IP (timer event,
- * external interrupt line).
- * @note To determine whether group regular trigger source is
- * internal (SW start) or external, without detail
- * of which peripheral is selected as external trigger,
- * (equivalent to
- * "if(LL_ADC_REG_GetTriggerSource(ADC1) == LL_ADC_REG_TRIG_SOFTWARE)")
- * use function @ref LL_ADC_REG_IsTriggerSourceSWStart.
- * @note Availability of parameters of trigger sources from timer
- * depends on timers availability on the selected device.
- * @rmtoll CR2 EXTSEL LL_ADC_REG_GetTriggerSource\n
- * CR2 EXTEN LL_ADC_REG_GetTriggerSource
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_REG_TRIG_SOFTWARE
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_TRGO
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH3
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_TRGO
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM2_CH2
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH1
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM3_CH3
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_TRGO
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM4_CH4
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM6_TRGO
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_CH2
- * @arg @ref LL_ADC_REG_TRIG_EXT_TIM9_TRGO
- * @arg @ref LL_ADC_REG_TRIG_EXT_EXTI_LINE11
- */
-__STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerSource(ADC_TypeDef *ADCx)
-{
- uint32_t TriggerSource = READ_BIT(ADCx->CR2, ADC_CR2_EXTSEL | ADC_CR2_EXTEN);
-
- /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
- /* corresponding to ADC_CR2_EXTEN {0; 1; 2; 3}. */
- uint32_t ShiftExten = ((TriggerSource & ADC_CR2_EXTEN) >> (ADC_REG_TRIG_EXTEN_BITOFFSET_POS - 2U));
-
- /* Set bitfield corresponding to ADC_CR2_EXTEN and ADC_CR2_EXTSEL */
- /* to match with triggers literals definition. */
- return ((TriggerSource
- & (ADC_REG_TRIG_SOURCE_MASK << ShiftExten) & ADC_CR2_EXTSEL)
- | ((ADC_REG_TRIG_EDGE_MASK << ShiftExten) & ADC_CR2_EXTEN)
- );
-}
-
-/**
- * @brief Get ADC group regular conversion trigger source internal (SW start)
- or external.
- * @note In case of group regular trigger source set to external trigger,
- * to determine which peripheral is selected as external trigger,
- * use function @ref LL_ADC_REG_GetTriggerSource().
- * @rmtoll CR2 EXTEN LL_ADC_REG_IsTriggerSourceSWStart
- * @param ADCx ADC instance
- * @retval Value "0" if trigger source external trigger
- * Value "1" if trigger source SW start.
- */
-__STATIC_INLINE uint32_t LL_ADC_REG_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
-{
- return (READ_BIT(ADCx->CR2, ADC_CR2_EXTEN) == (LL_ADC_REG_TRIG_SOFTWARE & ADC_CR2_EXTEN));
-}
-
-/**
- * @brief Get ADC group regular conversion trigger polarity.
- * @note Applicable only for trigger source set to external trigger.
- * @note On this STM32 serie, setting of external trigger edge is performed
- * using function @ref LL_ADC_REG_StartConversionExtTrig().
- * @rmtoll CR2 EXTEN LL_ADC_REG_GetTriggerEdge
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
- * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
- * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
- */
-__STATIC_INLINE uint32_t LL_ADC_REG_GetTriggerEdge(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EXTEN));
-}
-
-
-/**
- * @brief Set ADC group regular sequencer length and scan direction.
- * @note Description of ADC group regular sequencer features:
- * - For devices with sequencer fully configurable
- * (function "LL_ADC_REG_SetSequencerRanks()" available):
- * sequencer length and each rank affectation to a channel
- * are configurable.
- * This function performs configuration of:
- * - Sequence length: Number of ranks in the scan sequence.
- * - Sequence direction: Unless specified in parameters, sequencer
- * scan direction is forward (from rank 1 to rank n).
- * Sequencer ranks are selected using
- * function "LL_ADC_REG_SetSequencerRanks()".
- * - For devices with sequencer not fully configurable
- * (function "LL_ADC_REG_SetSequencerChannels()" available):
- * sequencer length and each rank affectation to a channel
- * are defined by channel number.
- * This function performs configuration of:
- * - Sequence length: Number of ranks in the scan sequence is
- * defined by number of channels set in the sequence,
- * rank of each channel is fixed by channel HW number.
- * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
- * - Sequence direction: Unless specified in parameters, sequencer
- * scan direction is forward (from lowest channel number to
- * highest channel number).
- * Sequencer ranks are selected using
- * function "LL_ADC_REG_SetSequencerChannels()".
- * @note On this STM32 serie, group regular sequencer configuration
- * is conditioned to ADC instance sequencer mode.
- * If ADC instance sequencer mode is disabled, sequencers of
- * all groups (group regular, group injected) can be configured
- * but their execution is disabled (limited to rank 1).
- * Refer to function @ref LL_ADC_SetSequencersScanMode().
- * @note Sequencer disabled is equivalent to sequencer of 1 rank:
- * ADC conversion on only 1 channel.
- * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
- * @param ADCx ADC instance
- * @param SequencerNbRanks This parameter can be one of the following values:
- * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_REG_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
-{
- MODIFY_REG(ADCx->SQR1, ADC_SQR1_L, SequencerNbRanks);
-}
-
-/**
- * @brief Get ADC group regular sequencer length and scan direction.
- * @note Description of ADC group regular sequencer features:
- * - For devices with sequencer fully configurable
- * (function "LL_ADC_REG_SetSequencerRanks()" available):
- * sequencer length and each rank affectation to a channel
- * are configurable.
- * This function retrieves:
- * - Sequence length: Number of ranks in the scan sequence.
- * - Sequence direction: Unless specified in parameters, sequencer
- * scan direction is forward (from rank 1 to rank n).
- * Sequencer ranks are selected using
- * function "LL_ADC_REG_SetSequencerRanks()".
- * - For devices with sequencer not fully configurable
- * (function "LL_ADC_REG_SetSequencerChannels()" available):
- * sequencer length and each rank affectation to a channel
- * are defined by channel number.
- * This function retrieves:
- * - Sequence length: Number of ranks in the scan sequence is
- * defined by number of channels set in the sequence,
- * rank of each channel is fixed by channel HW number.
- * (channel 0 fixed on rank 0, channel 1 fixed on rank1, ...).
- * - Sequence direction: Unless specified in parameters, sequencer
- * scan direction is forward (from lowest channel number to
- * highest channel number).
- * Sequencer ranks are selected using
- * function "LL_ADC_REG_SetSequencerChannels()".
- * @note On this STM32 serie, group regular sequencer configuration
- * is conditioned to ADC instance sequencer mode.
- * If ADC instance sequencer mode is disabled, sequencers of
- * all groups (group regular, group injected) can be configured
- * but their execution is disabled (limited to rank 1).
- * Refer to function @ref LL_ADC_SetSequencersScanMode().
- * @note Sequencer disabled is equivalent to sequencer of 1 rank:
- * ADC conversion on only 1 channel.
- * @rmtoll SQR1 L LL_ADC_REG_SetSequencerLength
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_REG_SEQ_SCAN_DISABLE
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_2RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_3RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_4RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_5RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_6RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_7RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_8RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_9RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_10RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_11RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_12RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_13RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_14RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_15RANKS
- * @arg @ref LL_ADC_REG_SEQ_SCAN_ENABLE_16RANKS
- */
-__STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerLength(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->SQR1, ADC_SQR1_L));
-}
-
-/**
- * @brief Set ADC group regular sequencer discontinuous mode:
- * sequence subdivided and scan conversions interrupted every selected
- * number of ranks.
- * @note It is not possible to enable both ADC group regular
- * continuous mode and sequencer discontinuous mode.
- * @note It is not possible to enable both ADC auto-injected mode
- * and ADC group regular sequencer discontinuous mode.
- * @rmtoll CR1 DISCEN LL_ADC_REG_SetSequencerDiscont\n
- * CR1 DISCNUM LL_ADC_REG_SetSequencerDiscont
- * @param ADCx ADC instance
- * @param SeqDiscont This parameter can be one of the following values:
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_REG_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
-{
- MODIFY_REG(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM, SeqDiscont);
-}
-
-/**
- * @brief Get ADC group regular sequencer discontinuous mode:
- * sequence subdivided and scan conversions interrupted every selected
- * number of ranks.
- * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont\n
- * CR1 DISCNUM LL_ADC_REG_GetSequencerDiscont
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_DISABLE
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_1RANK
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_2RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_3RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_4RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_5RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_6RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_7RANKS
- * @arg @ref LL_ADC_REG_SEQ_DISCONT_8RANKS
- */
-__STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerDiscont(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_DISCEN | ADC_CR1_DISCNUM));
-}
-
-/**
- * @brief Set ADC group regular sequence: channel on the selected
- * scan sequence rank.
- * @note This function performs configuration of:
- * - Channels ordering into each rank of scan sequence:
- * whatever channel can be placed into whatever rank.
- * @note On this STM32 serie, ADC group regular sequencer is
- * fully configurable: sequencer length and each rank
- * affectation to a channel are configurable.
- * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
- * @note Depending on devices and packages, some channels may not be available.
- * Refer to device datasheet for channels availability.
- * @note On this STM32 serie, to measure internal channels (VrefInt,
- * TempSensor, ...), measurement paths to internal channels must be
- * enabled separately.
- * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
- * @rmtoll SQR5 SQ1 LL_ADC_REG_SetSequencerRanks\n
- * SQR5 SQ2 LL_ADC_REG_SetSequencerRanks\n
- * SQR5 SQ3 LL_ADC_REG_SetSequencerRanks\n
- * SQR5 SQ4 LL_ADC_REG_SetSequencerRanks\n
- * SQR5 SQ5 LL_ADC_REG_SetSequencerRanks\n
- * SQR5 SQ6 LL_ADC_REG_SetSequencerRanks\n
- * SQR4 SQ7 LL_ADC_REG_SetSequencerRanks\n
- * SQR4 SQ8 LL_ADC_REG_SetSequencerRanks\n
- * SQR4 SQ9 LL_ADC_REG_SetSequencerRanks\n
- * SQR4 SQ10 LL_ADC_REG_SetSequencerRanks\n
- * SQR4 SQ11 LL_ADC_REG_SetSequencerRanks\n
- * SQR4 SQ12 LL_ADC_REG_SetSequencerRanks\n
- * SQR3 SQ13 LL_ADC_REG_SetSequencerRanks\n
- * SQR3 SQ14 LL_ADC_REG_SetSequencerRanks\n
- * SQR3 SQ15 LL_ADC_REG_SetSequencerRanks\n
- * SQR3 SQ16 LL_ADC_REG_SetSequencerRanks\n
- * SQR3 SQ17 LL_ADC_REG_SetSequencerRanks\n
- * SQR3 SQ18 LL_ADC_REG_SetSequencerRanks\n
- * SQR2 SQ19 LL_ADC_REG_SetSequencerRanks\n
- * SQR2 SQ20 LL_ADC_REG_SetSequencerRanks\n
- * SQR2 SQ21 LL_ADC_REG_SetSequencerRanks\n
- * SQR2 SQ22 LL_ADC_REG_SetSequencerRanks\n
- * SQR2 SQ23 LL_ADC_REG_SetSequencerRanks\n
- * SQR2 SQ24 LL_ADC_REG_SetSequencerRanks\n
- * SQR1 SQ25 LL_ADC_REG_SetSequencerRanks\n
- * SQR1 SQ26 LL_ADC_REG_SetSequencerRanks\n
- * SQR1 SQ27 LL_ADC_REG_SetSequencerRanks\n
- * SQR1 SQ28 LL_ADC_REG_SetSequencerRanks
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_REG_RANK_1
- * @arg @ref LL_ADC_REG_RANK_2
- * @arg @ref LL_ADC_REG_RANK_3
- * @arg @ref LL_ADC_REG_RANK_4
- * @arg @ref LL_ADC_REG_RANK_5
- * @arg @ref LL_ADC_REG_RANK_6
- * @arg @ref LL_ADC_REG_RANK_7
- * @arg @ref LL_ADC_REG_RANK_8
- * @arg @ref LL_ADC_REG_RANK_9
- * @arg @ref LL_ADC_REG_RANK_10
- * @arg @ref LL_ADC_REG_RANK_11
- * @arg @ref LL_ADC_REG_RANK_12
- * @arg @ref LL_ADC_REG_RANK_13
- * @arg @ref LL_ADC_REG_RANK_14
- * @arg @ref LL_ADC_REG_RANK_15
- * @arg @ref LL_ADC_REG_RANK_16
- * @arg @ref LL_ADC_REG_RANK_17
- * @arg @ref LL_ADC_REG_RANK_18
- * @arg @ref LL_ADC_REG_RANK_19
- * @arg @ref LL_ADC_REG_RANK_20
- * @arg @ref LL_ADC_REG_RANK_21
- * @arg @ref LL_ADC_REG_RANK_22
- * @arg @ref LL_ADC_REG_RANK_23
- * @arg @ref LL_ADC_REG_RANK_24
- * @arg @ref LL_ADC_REG_RANK_25
- * @arg @ref LL_ADC_REG_RANK_26
- * @arg @ref LL_ADC_REG_RANK_27
- * @arg @ref LL_ADC_REG_RANK_28 (1)
- *
- * (1) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.3, Cat.4 and Cat.5.
- * @param Channel This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_REG_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
-{
- /* Set bits with content of parameter "Channel" with bits position */
- /* in register and register position depending on parameter "Rank". */
- /* Parameters "Rank" and "Channel" are used with masks because containing */
- /* other bits reserved for other purpose. */
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
-
- MODIFY_REG(*preg,
- ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK),
- (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_REG_RANK_ID_SQRX_MASK));
-}
-
-/**
- * @brief Get ADC group regular sequence: channel on the selected
- * scan sequence rank.
- * @note On this STM32 serie, ADC group regular sequencer is
- * fully configurable: sequencer length and each rank
- * affectation to a channel are configurable.
- * Refer to description of function @ref LL_ADC_REG_SetSequencerLength().
- * @note Depending on devices and packages, some channels may not be available.
- * Refer to device datasheet for channels availability.
- * @note Usage of the returned channel number:
- * - To reinject this channel into another function LL_ADC_xxx:
- * the returned channel number is only partly formatted on definition
- * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
- * with parts of literals LL_ADC_CHANNEL_x or using
- * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
- * Then the selected literal LL_ADC_CHANNEL_x can be used
- * as parameter for another function.
- * - To get the channel number in decimal format:
- * process the returned value with the helper macro
- * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
- * @rmtoll SQR5 SQ1 LL_ADC_REG_GetSequencerRanks\n
- * SQR5 SQ2 LL_ADC_REG_GetSequencerRanks\n
- * SQR5 SQ3 LL_ADC_REG_GetSequencerRanks\n
- * SQR5 SQ4 LL_ADC_REG_GetSequencerRanks\n
- * SQR5 SQ5 LL_ADC_REG_GetSequencerRanks\n
- * SQR5 SQ6 LL_ADC_REG_GetSequencerRanks\n
- * SQR4 SQ7 LL_ADC_REG_GetSequencerRanks\n
- * SQR4 SQ8 LL_ADC_REG_GetSequencerRanks\n
- * SQR4 SQ9 LL_ADC_REG_GetSequencerRanks\n
- * SQR4 SQ10 LL_ADC_REG_GetSequencerRanks\n
- * SQR4 SQ11 LL_ADC_REG_GetSequencerRanks\n
- * SQR4 SQ12 LL_ADC_REG_GetSequencerRanks\n
- * SQR3 SQ13 LL_ADC_REG_GetSequencerRanks\n
- * SQR3 SQ14 LL_ADC_REG_GetSequencerRanks\n
- * SQR3 SQ15 LL_ADC_REG_GetSequencerRanks\n
- * SQR3 SQ16 LL_ADC_REG_GetSequencerRanks\n
- * SQR3 SQ17 LL_ADC_REG_GetSequencerRanks\n
- * SQR3 SQ18 LL_ADC_REG_GetSequencerRanks\n
- * SQR2 SQ19 LL_ADC_REG_GetSequencerRanks\n
- * SQR2 SQ20 LL_ADC_REG_GetSequencerRanks\n
- * SQR2 SQ21 LL_ADC_REG_GetSequencerRanks\n
- * SQR2 SQ22 LL_ADC_REG_GetSequencerRanks\n
- * SQR2 SQ23 LL_ADC_REG_GetSequencerRanks\n
- * SQR2 SQ24 LL_ADC_REG_GetSequencerRanks\n
- * SQR1 SQ25 LL_ADC_REG_GetSequencerRanks\n
- * SQR1 SQ26 LL_ADC_REG_GetSequencerRanks\n
- * SQR1 SQ27 LL_ADC_REG_GetSequencerRanks\n
- * SQR1 SQ28 LL_ADC_REG_GetSequencerRanks
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_REG_RANK_1
- * @arg @ref LL_ADC_REG_RANK_2
- * @arg @ref LL_ADC_REG_RANK_3
- * @arg @ref LL_ADC_REG_RANK_4
- * @arg @ref LL_ADC_REG_RANK_5
- * @arg @ref LL_ADC_REG_RANK_6
- * @arg @ref LL_ADC_REG_RANK_7
- * @arg @ref LL_ADC_REG_RANK_8
- * @arg @ref LL_ADC_REG_RANK_9
- * @arg @ref LL_ADC_REG_RANK_10
- * @arg @ref LL_ADC_REG_RANK_11
- * @arg @ref LL_ADC_REG_RANK_12
- * @arg @ref LL_ADC_REG_RANK_13
- * @arg @ref LL_ADC_REG_RANK_14
- * @arg @ref LL_ADC_REG_RANK_15
- * @arg @ref LL_ADC_REG_RANK_16
- * @arg @ref LL_ADC_REG_RANK_17
- * @arg @ref LL_ADC_REG_RANK_18
- * @arg @ref LL_ADC_REG_RANK_19
- * @arg @ref LL_ADC_REG_RANK_20
- * @arg @ref LL_ADC_REG_RANK_21
- * @arg @ref LL_ADC_REG_RANK_22
- * @arg @ref LL_ADC_REG_RANK_23
- * @arg @ref LL_ADC_REG_RANK_24
- * @arg @ref LL_ADC_REG_RANK_25
- * @arg @ref LL_ADC_REG_RANK_26
- * @arg @ref LL_ADC_REG_RANK_27
- * @arg @ref LL_ADC_REG_RANK_28 (1)
- *
- * (1) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.3, Cat.4 and Cat.5.
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
- * (6) For ADC channel read back from ADC register,
- * comparison with internal channel parameter to be done
- * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
- */
-__STATIC_INLINE uint32_t LL_ADC_REG_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SQR1, __ADC_MASK_SHIFT(Rank, ADC_REG_SQRX_REGOFFSET_MASK));
-
- return (uint32_t) (READ_BIT(*preg,
- ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_REG_RANK_ID_SQRX_MASK))
- >> (Rank & ADC_REG_RANK_ID_SQRX_MASK)
- );
-}
-
-/**
- * @brief Set ADC continuous conversion mode on ADC group regular.
- * @note Description of ADC continuous conversion mode:
- * - single mode: one conversion per trigger
- * - continuous mode: after the first trigger, following
- * conversions launched successively automatically.
- * @note It is not possible to enable both ADC group regular
- * continuous mode and sequencer discontinuous mode.
- * @rmtoll CR2 CONT LL_ADC_REG_SetContinuousMode
- * @param ADCx ADC instance
- * @param Continuous This parameter can be one of the following values:
- * @arg @ref LL_ADC_REG_CONV_SINGLE
- * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_REG_SetContinuousMode(ADC_TypeDef *ADCx, uint32_t Continuous)
-{
- MODIFY_REG(ADCx->CR2, ADC_CR2_CONT, Continuous);
-}
-
-/**
- * @brief Get ADC continuous conversion mode on ADC group regular.
- * @note Description of ADC continuous conversion mode:
- * - single mode: one conversion per trigger
- * - continuous mode: after the first trigger, following
- * conversions launched successively automatically.
- * @rmtoll CR2 CONT LL_ADC_REG_GetContinuousMode
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_REG_CONV_SINGLE
- * @arg @ref LL_ADC_REG_CONV_CONTINUOUS
- */
-__STATIC_INLINE uint32_t LL_ADC_REG_GetContinuousMode(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_CONT));
-}
-
-/**
- * @brief Set ADC group regular conversion data transfer: no transfer or
- * transfer by DMA, and DMA requests mode.
- * @note If transfer by DMA selected, specifies the DMA requests
- * mode:
- * - Limited mode (One shot mode): DMA transfer requests are stopped
- * when number of DMA data transfers (number of
- * ADC conversions) is reached.
- * This ADC mode is intended to be used with DMA mode non-circular.
- * - Unlimited mode: DMA transfer requests are unlimited,
- * whatever number of DMA data transfers (number of
- * ADC conversions).
- * This ADC mode is intended to be used with DMA mode circular.
- * @note If ADC DMA requests mode is set to unlimited and DMA is set to
- * mode non-circular:
- * when DMA transfers size will be reached, DMA will stop transfers of
- * ADC conversions data ADC will raise an overrun error
- * (overrun flag and interruption if enabled).
- * @note To configure DMA source address (peripheral address),
- * use function @ref LL_ADC_DMA_GetRegAddr().
- * @rmtoll CR2 DMA LL_ADC_REG_SetDMATransfer\n
- * CR2 DDS LL_ADC_REG_SetDMATransfer
- * @param ADCx ADC instance
- * @param DMATransfer This parameter can be one of the following values:
- * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
- * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
- * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_REG_SetDMATransfer(ADC_TypeDef *ADCx, uint32_t DMATransfer)
-{
- MODIFY_REG(ADCx->CR2, ADC_CR2_DMA | ADC_CR2_DDS, DMATransfer);
-}
-
-/**
- * @brief Get ADC group regular conversion data transfer: no transfer or
- * transfer by DMA, and DMA requests mode.
- * @note If transfer by DMA selected, specifies the DMA requests
- * mode:
- * - Limited mode (One shot mode): DMA transfer requests are stopped
- * when number of DMA data transfers (number of
- * ADC conversions) is reached.
- * This ADC mode is intended to be used with DMA mode non-circular.
- * - Unlimited mode: DMA transfer requests are unlimited,
- * whatever number of DMA data transfers (number of
- * ADC conversions).
- * This ADC mode is intended to be used with DMA mode circular.
- * @note If ADC DMA requests mode is set to unlimited and DMA is set to
- * mode non-circular:
- * when DMA transfers size will be reached, DMA will stop transfers of
- * ADC conversions data ADC will raise an overrun error
- * (overrun flag and interruption if enabled).
- * @note To configure DMA source address (peripheral address),
- * use function @ref LL_ADC_DMA_GetRegAddr().
- * @rmtoll CR2 DMA LL_ADC_REG_GetDMATransfer\n
- * CR2 DDS LL_ADC_REG_GetDMATransfer
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_REG_DMA_TRANSFER_NONE
- * @arg @ref LL_ADC_REG_DMA_TRANSFER_LIMITED
- * @arg @ref LL_ADC_REG_DMA_TRANSFER_UNLIMITED
- */
-__STATIC_INLINE uint32_t LL_ADC_REG_GetDMATransfer(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_DMA | ADC_CR2_DDS));
-}
-
-/**
- * @brief Specify which ADC flag between EOC (end of unitary conversion)
- * or EOS (end of sequence conversions) is used to indicate
- * the end of conversion.
- * @note This feature is aimed to be set when using ADC with
- * programming model by polling or interruption
- * (programming model by DMA usually uses DMA interruptions
- * to indicate end of conversion and data transfer).
- * @note For ADC group injected, end of conversion (flag&IT) is raised
- * only at the end of the sequence.
- * @rmtoll CR2 EOCS LL_ADC_REG_SetFlagEndOfConversion
- * @param ADCx ADC instance
- * @param EocSelection This parameter can be one of the following values:
- * @arg @ref LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV
- * @arg @ref LL_ADC_REG_FLAG_EOC_UNITARY_CONV
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_REG_SetFlagEndOfConversion(ADC_TypeDef *ADCx, uint32_t EocSelection)
-{
- MODIFY_REG(ADCx->CR2, ADC_CR2_EOCS, EocSelection);
-}
-
-/**
- * @brief Get which ADC flag between EOC (end of unitary conversion)
- * or EOS (end of sequence conversions) is used to indicate
- * the end of conversion.
- * @rmtoll CR2 EOCS LL_ADC_REG_GetFlagEndOfConversion
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_REG_FLAG_EOC_SEQUENCE_CONV
- * @arg @ref LL_ADC_REG_FLAG_EOC_UNITARY_CONV
- */
-__STATIC_INLINE uint32_t LL_ADC_REG_GetFlagEndOfConversion(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_EOCS));
-}
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_Configuration_ADC_Group_Injected Configuration of ADC hierarchical scope: group injected
- * @{
- */
-
-/**
- * @brief Set ADC group injected conversion trigger source:
- * internal (SW start) or from external IP (timer event,
- * external interrupt line).
- * @note On this STM32 serie, setting of external trigger edge is performed
- * using function @ref LL_ADC_INJ_StartConversionExtTrig().
- * @note Availability of parameters of trigger sources from timer
- * depends on timers availability on the selected device.
- * @rmtoll CR2 JEXTSEL LL_ADC_INJ_SetTriggerSource\n
- * CR2 JEXTEN LL_ADC_INJ_SetTriggerSource
- * @param ADCx ADC instance
- * @param TriggerSource This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_CH1
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_TRGO
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH1
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH2
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM10_CH1
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO
- * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_INJ_SetTriggerSource(ADC_TypeDef *ADCx, uint32_t TriggerSource)
-{
-/* Note: On this STM32 serie, ADC group injected external trigger edge */
-/* is used to perform a ADC conversion start. */
-/* This function does not set external trigger edge. */
-/* This feature is set using function */
-/* @ref LL_ADC_INJ_StartConversionExtTrig(). */
- MODIFY_REG(ADCx->CR2, ADC_CR2_JEXTSEL, (TriggerSource & ADC_CR2_JEXTSEL));
-}
-
-/**
- * @brief Get ADC group injected conversion trigger source:
- * internal (SW start) or from external IP (timer event,
- * external interrupt line).
- * @note To determine whether group injected trigger source is
- * internal (SW start) or external, without detail
- * of which peripheral is selected as external trigger,
- * (equivalent to
- * "if(LL_ADC_INJ_GetTriggerSource(ADC1) == LL_ADC_INJ_TRIG_SOFTWARE)")
- * use function @ref LL_ADC_INJ_IsTriggerSourceSWStart.
- * @note Availability of parameters of trigger sources from timer
- * depends on timers availability on the selected device.
- * @rmtoll CR2 JEXTSEL LL_ADC_INJ_GetTriggerSource\n
- * CR2 JEXTEN LL_ADC_INJ_GetTriggerSource
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_INJ_TRIG_SOFTWARE
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_CH1
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM9_TRGO
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_TRGO
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM2_CH1
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM3_CH4
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_TRGO
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH1
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH2
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM4_CH3
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM10_CH1
- * @arg @ref LL_ADC_INJ_TRIG_EXT_TIM7_TRGO
- * @arg @ref LL_ADC_INJ_TRIG_EXT_EXTI_LINE15
- */
-__STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerSource(ADC_TypeDef *ADCx)
-{
- uint32_t TriggerSource = READ_BIT(ADCx->CR2, ADC_CR2_JEXTSEL | ADC_CR2_JEXTEN);
-
- /* Value for shift of {0; 4; 8; 12} depending on value of bitfield */
- /* corresponding to ADC_CR2_JEXTEN {0; 1; 2; 3}. */
- uint32_t ShiftExten = ((TriggerSource & ADC_CR2_JEXTEN) >> (ADC_INJ_TRIG_EXTEN_BITOFFSET_POS - 2U));
-
- /* Set bitfield corresponding to ADC_CR2_JEXTEN and ADC_CR2_JEXTSEL */
- /* to match with triggers literals definition. */
- return ((TriggerSource
- & (ADC_INJ_TRIG_SOURCE_MASK << ShiftExten) & ADC_CR2_JEXTSEL)
- | ((ADC_INJ_TRIG_EDGE_MASK << ShiftExten) & ADC_CR2_JEXTEN)
- );
-}
-
-/**
- * @brief Get ADC group injected conversion trigger source internal (SW start)
- or external
- * @note In case of group injected trigger source set to external trigger,
- * to determine which peripheral is selected as external trigger,
- * use function @ref LL_ADC_INJ_GetTriggerSource.
- * @rmtoll CR2 JEXTEN LL_ADC_INJ_IsTriggerSourceSWStart
- * @param ADCx ADC instance
- * @retval Value "0" if trigger source external trigger
- * Value "1" if trigger source SW start.
- */
-__STATIC_INLINE uint32_t LL_ADC_INJ_IsTriggerSourceSWStart(ADC_TypeDef *ADCx)
-{
- return (READ_BIT(ADCx->CR2, ADC_CR2_JEXTEN) == (LL_ADC_INJ_TRIG_SOFTWARE & ADC_CR2_JEXTEN));
-}
-
-/**
- * @brief Get ADC group injected conversion trigger polarity.
- * Applicable only for trigger source set to external trigger.
- * @rmtoll CR2 JEXTEN LL_ADC_INJ_GetTriggerEdge
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
- * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
- * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
- */
-__STATIC_INLINE uint32_t LL_ADC_INJ_GetTriggerEdge(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR2, ADC_CR2_JEXTEN));
-}
-
-/**
- * @brief Set ADC group injected sequencer length and scan direction.
- * @note This function performs configuration of:
- * - Sequence length: Number of ranks in the scan sequence.
- * - Sequence direction: Unless specified in parameters, sequencer
- * scan direction is forward (from rank 1 to rank n).
- * @note On this STM32 serie, group injected sequencer configuration
- * is conditioned to ADC instance sequencer mode.
- * If ADC instance sequencer mode is disabled, sequencers of
- * all groups (group regular, group injected) can be configured
- * but their execution is disabled (limited to rank 1).
- * Refer to function @ref LL_ADC_SetSequencersScanMode().
- * @note Sequencer disabled is equivalent to sequencer of 1 rank:
- * ADC conversion on only 1 channel.
- * @rmtoll JSQR JL LL_ADC_INJ_SetSequencerLength
- * @param ADCx ADC instance
- * @param SequencerNbRanks This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
- * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
- * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
- * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_INJ_SetSequencerLength(ADC_TypeDef *ADCx, uint32_t SequencerNbRanks)
-{
- MODIFY_REG(ADCx->JSQR, ADC_JSQR_JL, SequencerNbRanks);
-}
-
-/**
- * @brief Get ADC group injected sequencer length and scan direction.
- * @note This function retrieves:
- * - Sequence length: Number of ranks in the scan sequence.
- * - Sequence direction: Unless specified in parameters, sequencer
- * scan direction is forward (from rank 1 to rank n).
- * @note On this STM32 serie, group injected sequencer configuration
- * is conditioned to ADC instance sequencer mode.
- * If ADC instance sequencer mode is disabled, sequencers of
- * all groups (group regular, group injected) can be configured
- * but their execution is disabled (limited to rank 1).
- * Refer to function @ref LL_ADC_SetSequencersScanMode().
- * @note Sequencer disabled is equivalent to sequencer of 1 rank:
- * ADC conversion on only 1 channel.
- * @rmtoll JSQR JL LL_ADC_INJ_GetSequencerLength
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_INJ_SEQ_SCAN_DISABLE
- * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_2RANKS
- * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_3RANKS
- * @arg @ref LL_ADC_INJ_SEQ_SCAN_ENABLE_4RANKS
- */
-__STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerLength(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->JSQR, ADC_JSQR_JL));
-}
-
-/**
- * @brief Set ADC group injected sequencer discontinuous mode:
- * sequence subdivided and scan conversions interrupted every selected
- * number of ranks.
- * @note It is not possible to enable both ADC group injected
- * auto-injected mode and sequencer discontinuous mode.
- * @rmtoll CR1 DISCEN LL_ADC_INJ_SetSequencerDiscont
- * @param ADCx ADC instance
- * @param SeqDiscont This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
- * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_INJ_SetSequencerDiscont(ADC_TypeDef *ADCx, uint32_t SeqDiscont)
-{
- MODIFY_REG(ADCx->CR1, ADC_CR1_JDISCEN, SeqDiscont);
-}
-
-/**
- * @brief Get ADC group injected sequencer discontinuous mode:
- * sequence subdivided and scan conversions interrupted every selected
- * number of ranks.
- * @rmtoll CR1 DISCEN LL_ADC_REG_GetSequencerDiscont
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_INJ_SEQ_DISCONT_DISABLE
- * @arg @ref LL_ADC_INJ_SEQ_DISCONT_1RANK
- */
-__STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerDiscont(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JDISCEN));
-}
-
-/**
- * @brief Set ADC group injected sequence: channel on the selected
- * sequence rank.
- * @note Depending on devices and packages, some channels may not be available.
- * Refer to device datasheet for channels availability.
- * @note On this STM32 serie, to measure internal channels (VrefInt,
- * TempSensor, ...), measurement paths to internal channels must be
- * enabled separately.
- * This can be done using function @ref LL_ADC_SetCommonPathInternalCh().
- * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
- * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
- * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
- * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_RANK_1
- * @arg @ref LL_ADC_INJ_RANK_2
- * @arg @ref LL_ADC_INJ_RANK_3
- * @arg @ref LL_ADC_INJ_RANK_4
- * @param Channel This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_INJ_SetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t Channel)
-{
- /* Set bits with content of parameter "Channel" with bits position */
- /* in register depending on parameter "Rank". */
- /* Parameters "Rank" and "Channel" are used with masks because containing */
- /* other bits reserved for other purpose. */
- MODIFY_REG(ADCx->JSQR,
- ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK),
- (Channel & ADC_CHANNEL_ID_NUMBER_MASK) << (Rank & ADC_INJ_RANK_ID_JSQR_MASK));
-}
-
-/**
- * @brief Get ADC group injected sequence: channel on the selected
- * sequence rank.
- * @note Depending on devices and packages, some channels may not be available.
- * Refer to device datasheet for channels availability.
- * @note Usage of the returned channel number:
- * - To reinject this channel into another function LL_ADC_xxx:
- * the returned channel number is only partly formatted on definition
- * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
- * with parts of literals LL_ADC_CHANNEL_x or using
- * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
- * Then the selected literal LL_ADC_CHANNEL_x can be used
- * as parameter for another function.
- * - To get the channel number in decimal format:
- * process the returned value with the helper macro
- * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
- * @rmtoll JSQR JSQ1 LL_ADC_INJ_SetSequencerRanks\n
- * JSQR JSQ2 LL_ADC_INJ_SetSequencerRanks\n
- * JSQR JSQ3 LL_ADC_INJ_SetSequencerRanks\n
- * JSQR JSQ4 LL_ADC_INJ_SetSequencerRanks
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_RANK_1
- * @arg @ref LL_ADC_INJ_RANK_2
- * @arg @ref LL_ADC_INJ_RANK_3
- * @arg @ref LL_ADC_INJ_RANK_4
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)(6)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)(6)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)(6)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5.\n
- * (6) For ADC channel read back from ADC register,
- * comparison with internal channel parameter to be done
- * using helper macro @ref __LL_ADC_CHANNEL_INTERNAL_TO_EXTERNAL().
- */
-__STATIC_INLINE uint32_t LL_ADC_INJ_GetSequencerRanks(ADC_TypeDef *ADCx, uint32_t Rank)
-{
- return (uint32_t)(READ_BIT(ADCx->JSQR,
- ADC_CHANNEL_ID_NUMBER_MASK << (Rank & ADC_INJ_RANK_ID_JSQR_MASK))
- >> (Rank & ADC_INJ_RANK_ID_JSQR_MASK)
- );
-}
-
-/**
- * @brief Set ADC group injected conversion trigger:
- * independent or from ADC group regular.
- * @note This mode can be used to extend number of data registers
- * updated after one ADC conversion trigger and with data
- * permanently kept (not erased by successive conversions of scan of
- * ADC sequencer ranks), up to 5 data registers:
- * 1 data register on ADC group regular, 4 data registers
- * on ADC group injected.
- * @note If ADC group injected injected trigger source is set to an
- * external trigger, this feature must be must be set to
- * independent trigger.
- * ADC group injected automatic trigger is compliant only with
- * group injected trigger source set to SW start, without any
- * further action on ADC group injected conversion start or stop:
- * in this case, ADC group injected is controlled only
- * from ADC group regular.
- * @note It is not possible to enable both ADC group injected
- * auto-injected mode and sequencer discontinuous mode.
- * @rmtoll CR1 JAUTO LL_ADC_INJ_SetTrigAuto
- * @param ADCx ADC instance
- * @param TrigAuto This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
- * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_INJ_SetTrigAuto(ADC_TypeDef *ADCx, uint32_t TrigAuto)
-{
- MODIFY_REG(ADCx->CR1, ADC_CR1_JAUTO, TrigAuto);
-}
-
-/**
- * @brief Get ADC group injected conversion trigger:
- * independent or from ADC group regular.
- * @rmtoll CR1 JAUTO LL_ADC_INJ_GetTrigAuto
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_INJ_TRIG_INDEPENDENT
- * @arg @ref LL_ADC_INJ_TRIG_FROM_GRP_REGULAR
- */
-__STATIC_INLINE uint32_t LL_ADC_INJ_GetTrigAuto(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR1, ADC_CR1_JAUTO));
-}
-
-/**
- * @brief Set ADC group injected offset.
- * @note It sets:
- * - ADC group injected rank to which the offset programmed
- * will be applied
- * - Offset level (offset to be subtracted from the raw
- * converted data).
- * Caution: Offset format is dependent to ADC resolution:
- * offset has to be left-aligned on bit 11, the LSB (right bits)
- * are set to 0.
- * @note Offset cannot be enabled or disabled.
- * To emulate offset disabled, set an offset value equal to 0.
- * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_SetOffset\n
- * JOFR2 JOFFSET2 LL_ADC_INJ_SetOffset\n
- * JOFR3 JOFFSET3 LL_ADC_INJ_SetOffset\n
- * JOFR4 JOFFSET4 LL_ADC_INJ_SetOffset
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_RANK_1
- * @arg @ref LL_ADC_INJ_RANK_2
- * @arg @ref LL_ADC_INJ_RANK_3
- * @arg @ref LL_ADC_INJ_RANK_4
- * @param OffsetLevel Value between Min_Data=0x000 and Max_Data=0xFFF
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_INJ_SetOffset(ADC_TypeDef *ADCx, uint32_t Rank, uint32_t OffsetLevel)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
-
- MODIFY_REG(*preg,
- ADC_JOFR1_JOFFSET1,
- OffsetLevel);
-}
-
-/**
- * @brief Get ADC group injected offset.
- * @note It gives offset level (offset to be subtracted from the raw converted data).
- * Caution: Offset format is dependent to ADC resolution:
- * offset has to be left-aligned on bit 11, the LSB (right bits)
- * are set to 0.
- * @rmtoll JOFR1 JOFFSET1 LL_ADC_INJ_GetOffset\n
- * JOFR2 JOFFSET2 LL_ADC_INJ_GetOffset\n
- * JOFR3 JOFFSET3 LL_ADC_INJ_GetOffset\n
- * JOFR4 JOFFSET4 LL_ADC_INJ_GetOffset
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_RANK_1
- * @arg @ref LL_ADC_INJ_RANK_2
- * @arg @ref LL_ADC_INJ_RANK_3
- * @arg @ref LL_ADC_INJ_RANK_4
- * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
- */
-__STATIC_INLINE uint32_t LL_ADC_INJ_GetOffset(ADC_TypeDef *ADCx, uint32_t Rank)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JOFR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JOFRX_REGOFFSET_MASK));
-
- return (uint32_t)(READ_BIT(*preg,
- ADC_JOFR1_JOFFSET1)
- );
-}
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_Configuration_Channels Configuration of ADC hierarchical scope: channels
- * @{
- */
-
-/**
- * @brief Set sampling time of the selected ADC channel
- * Unit: ADC clock cycles.
- * @note On this device, sampling time is on channel scope: independently
- * of channel mapped on ADC group regular or injected.
- * @note In case of internal channel (VrefInt, TempSensor, ...) to be
- * converted:
- * sampling time constraints must be respected (sampling time can be
- * adjusted in function of ADC clock frequency and sampling time
- * setting).
- * Refer to device datasheet for timings values (parameters TS_vrefint,
- * TS_temp, ...).
- * @note Conversion time is the addition of sampling time and processing time.
- * Refer to reference manual for ADC processing time of
- * this STM32 serie.
- * @note In case of ADC conversion of internal channel (VrefInt,
- * temperature sensor, ...), a sampling time minimum value
- * is required.
- * Refer to device datasheet.
- * @rmtoll SMPR0 SMP31 LL_ADC_SetChannelSamplingTime\n
- * SMPR0 SMP30 LL_ADC_SetChannelSamplingTime\n
- * SMPR1 SMP29 LL_ADC_SetChannelSamplingTime\n
- * SMPR1 SMP28 LL_ADC_SetChannelSamplingTime\n
- * SMPR1 SMP27 LL_ADC_SetChannelSamplingTime\n
- * SMPR1 SMP26 LL_ADC_SetChannelSamplingTime\n
- * SMPR1 SMP25 LL_ADC_SetChannelSamplingTime\n
- * SMPR1 SMP24 LL_ADC_SetChannelSamplingTime\n
- * SMPR1 SMP23 LL_ADC_SetChannelSamplingTime\n
- * SMPR1 SMP22 LL_ADC_SetChannelSamplingTime\n
- * SMPR1 SMP21 LL_ADC_SetChannelSamplingTime\n
- * SMPR1 SMP20 LL_ADC_SetChannelSamplingTime\n
- * SMPR2 SMP19 LL_ADC_SetChannelSamplingTime\n
- * SMPR2 SMP18 LL_ADC_SetChannelSamplingTime\n
- * SMPR2 SMP17 LL_ADC_SetChannelSamplingTime\n
- * SMPR2 SMP16 LL_ADC_SetChannelSamplingTime\n
- * SMPR2 SMP15 LL_ADC_SetChannelSamplingTime\n
- * SMPR2 SMP14 LL_ADC_SetChannelSamplingTime\n
- * SMPR2 SMP13 LL_ADC_SetChannelSamplingTime\n
- * SMPR2 SMP12 LL_ADC_SetChannelSamplingTime\n
- * SMPR2 SMP11 LL_ADC_SetChannelSamplingTime\n
- * SMPR2 SMP10 LL_ADC_SetChannelSamplingTime\n
- * SMPR3 SMP9 LL_ADC_SetChannelSamplingTime\n
- * SMPR3 SMP8 LL_ADC_SetChannelSamplingTime\n
- * SMPR3 SMP7 LL_ADC_SetChannelSamplingTime\n
- * SMPR3 SMP6 LL_ADC_SetChannelSamplingTime\n
- * SMPR3 SMP5 LL_ADC_SetChannelSamplingTime\n
- * SMPR3 SMP4 LL_ADC_SetChannelSamplingTime\n
- * SMPR3 SMP3 LL_ADC_SetChannelSamplingTime\n
- * SMPR3 SMP2 LL_ADC_SetChannelSamplingTime\n
- * SMPR3 SMP1 LL_ADC_SetChannelSamplingTime\n
- * SMPR3 SMP0 LL_ADC_SetChannelSamplingTime
- * @param ADCx ADC instance
- * @param Channel This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
- * @param SamplingTime This parameter can be one of the following values:
- * @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_9CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_16CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_48CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_96CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_192CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_384CYCLES
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t SamplingTime)
-{
- /* Set bits with content of parameter "SamplingTime" with bits position */
- /* in register and register position depending on parameter "Channel". */
- /* Parameter "Channel" is used with masks because containing */
- /* other bits reserved for other purpose. */
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
-
- MODIFY_REG(*preg,
- ADC_SMPR3_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK),
- SamplingTime << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK));
-}
-
-/**
- * @brief Get sampling time of the selected ADC channel
- * Unit: ADC clock cycles.
- * @note On this device, sampling time is on channel scope: independently
- * of channel mapped on ADC group regular or injected.
- * @note Conversion time is the addition of sampling time and processing time.
- * Refer to reference manual for ADC processing time of
- * this STM32 serie.
- * @rmtoll SMPR0 SMP31 LL_ADC_GetChannelSamplingTime\n
- * SMPR0 SMP30 LL_ADC_GetChannelSamplingTime\n
- * SMPR1 SMP29 LL_ADC_GetChannelSamplingTime\n
- * SMPR1 SMP28 LL_ADC_GetChannelSamplingTime\n
- * SMPR1 SMP27 LL_ADC_GetChannelSamplingTime\n
- * SMPR1 SMP26 LL_ADC_GetChannelSamplingTime\n
- * SMPR1 SMP25 LL_ADC_GetChannelSamplingTime\n
- * SMPR1 SMP24 LL_ADC_GetChannelSamplingTime\n
- * SMPR1 SMP23 LL_ADC_GetChannelSamplingTime\n
- * SMPR1 SMP22 LL_ADC_GetChannelSamplingTime\n
- * SMPR1 SMP21 LL_ADC_GetChannelSamplingTime\n
- * SMPR1 SMP20 LL_ADC_GetChannelSamplingTime\n
- * SMPR2 SMP19 LL_ADC_GetChannelSamplingTime\n
- * SMPR2 SMP18 LL_ADC_GetChannelSamplingTime\n
- * SMPR2 SMP17 LL_ADC_GetChannelSamplingTime\n
- * SMPR2 SMP16 LL_ADC_GetChannelSamplingTime\n
- * SMPR2 SMP15 LL_ADC_GetChannelSamplingTime\n
- * SMPR2 SMP14 LL_ADC_GetChannelSamplingTime\n
- * SMPR2 SMP13 LL_ADC_GetChannelSamplingTime\n
- * SMPR2 SMP12 LL_ADC_GetChannelSamplingTime\n
- * SMPR2 SMP11 LL_ADC_GetChannelSamplingTime\n
- * SMPR2 SMP10 LL_ADC_GetChannelSamplingTime\n
- * SMPR3 SMP9 LL_ADC_GetChannelSamplingTime\n
- * SMPR3 SMP8 LL_ADC_GetChannelSamplingTime\n
- * SMPR3 SMP7 LL_ADC_GetChannelSamplingTime\n
- * SMPR3 SMP6 LL_ADC_GetChannelSamplingTime\n
- * SMPR3 SMP5 LL_ADC_GetChannelSamplingTime\n
- * SMPR3 SMP4 LL_ADC_GetChannelSamplingTime\n
- * SMPR3 SMP3 LL_ADC_GetChannelSamplingTime\n
- * SMPR3 SMP2 LL_ADC_GetChannelSamplingTime\n
- * SMPR3 SMP1 LL_ADC_GetChannelSamplingTime\n
- * SMPR3 SMP0 LL_ADC_GetChannelSamplingTime
- * @param ADCx ADC instance
- * @param Channel This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_0 (2)
- * @arg @ref LL_ADC_CHANNEL_1 (2)
- * @arg @ref LL_ADC_CHANNEL_2 (2)
- * @arg @ref LL_ADC_CHANNEL_3 (2)
- * @arg @ref LL_ADC_CHANNEL_4 (1)
- * @arg @ref LL_ADC_CHANNEL_5 (1)
- * @arg @ref LL_ADC_CHANNEL_6 (2)
- * @arg @ref LL_ADC_CHANNEL_7 (2)
- * @arg @ref LL_ADC_CHANNEL_8 (2)
- * @arg @ref LL_ADC_CHANNEL_9 (2)
- * @arg @ref LL_ADC_CHANNEL_10 (2)
- * @arg @ref LL_ADC_CHANNEL_11 (2)
- * @arg @ref LL_ADC_CHANNEL_12 (2)
- * @arg @ref LL_ADC_CHANNEL_13 (3)
- * @arg @ref LL_ADC_CHANNEL_14 (3)
- * @arg @ref LL_ADC_CHANNEL_15 (3)
- * @arg @ref LL_ADC_CHANNEL_16 (3)
- * @arg @ref LL_ADC_CHANNEL_17 (3)
- * @arg @ref LL_ADC_CHANNEL_18 (3)
- * @arg @ref LL_ADC_CHANNEL_19 (3)
- * @arg @ref LL_ADC_CHANNEL_20 (3)
- * @arg @ref LL_ADC_CHANNEL_21 (3)
- * @arg @ref LL_ADC_CHANNEL_22 (1)
- * @arg @ref LL_ADC_CHANNEL_23 (1)
- * @arg @ref LL_ADC_CHANNEL_24 (1)
- * @arg @ref LL_ADC_CHANNEL_25 (1)
- * @arg @ref LL_ADC_CHANNEL_26 (3)
- * @arg @ref LL_ADC_CHANNEL_27 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_28 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_29 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_30 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_31 (3)(4)
- * @arg @ref LL_ADC_CHANNEL_VREFINT (3)
- * @arg @ref LL_ADC_CHANNEL_TEMPSENSOR (3)
- * @arg @ref LL_ADC_CHANNEL_VCOMP (3)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP1 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP2 (3)(5)
- * @arg @ref LL_ADC_CHANNEL_VOPAMP3 (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_SAMPLINGTIME_4CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_9CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_16CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_24CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_48CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_96CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_192CYCLES
- * @arg @ref LL_ADC_SAMPLINGTIME_384CYCLES
- */
-__STATIC_INLINE uint32_t LL_ADC_GetChannelSamplingTime(ADC_TypeDef *ADCx, uint32_t Channel)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->SMPR1, __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPRX_REGOFFSET_MASK));
-
- return (uint32_t)(READ_BIT(*preg,
- ADC_SMPR3_SMP0 << __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK))
- >> __ADC_MASK_SHIFT(Channel, ADC_CHANNEL_SMPx_BITOFFSET_MASK)
- );
-}
-
-#if defined(COMP_CSR_FCH3)
-/**
- * @brief Set ADC channels routing.
- * @note Channel routing set configuration between ADC IP and GPIO pads,
- * it is used to increase ADC channels speed (setting of
- * direct channel).
- * @note This feature is specific to STM32L1, on devices
- * category Cat.3, Cat.4, Cat.5.
- * To use this function, COMP RCC clock domain must be enabled.
- * Refer to @ref LL_APB1_GRP1_PERIPH_COMP.
- * @rmtoll CSR FCH3 LL_ADC_SetChannelRouting
- * @rmtoll CSR FCH8 LL_ADC_SetChannelRouting
- * @rmtoll CSR RCH13 LL_ADC_SetChannelRouting
- * @param ADCx ADC instance
- * @param Channel This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_3_ROUTING (1)
- * @arg @ref LL_ADC_CHANNEL_8_ROUTING (2)
- * @arg @ref LL_ADC_CHANNEL_13_ROUTING (3)
- *
- * (1) Used as ADC direct channel (fast channel) if OPAMP1 is
- * in power down mode.\n
- * (2) Used as ADC direct channel (fast channel) if OPAMP2 is
- * in power down mode.\n
- * (3) Used as ADC re-routed channel if OPAMP3 is
- * in power down mode.
- * Otherwise, channel 13 is connected to OPAMP3 output and routed
- * through switches COMP1_SW1 and VCOMP to ADC switch matrix.
- * (Note: OPAMP3 is available on STM32L1 Cat.4 only).
- * @param Routing This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_ROUTING_DEFAULT
- * @arg @ref LL_ADC_CHANNEL_ROUTING_DIRECT
- */
-__STATIC_INLINE void LL_ADC_SetChannelRouting(ADC_TypeDef *ADCx, uint32_t Channel, uint32_t Routing)
-{
- /* Note: Bit is located in comparator IP, but dedicated to ADC */
- MODIFY_REG(COMP->CSR, Channel, (Routing << POSITION_VAL(Channel)));
-}
-
-/**
- * @brief Get ADC channels speed.
- * @note Channel routing set configuration between ADC IP and GPIO pads,
- * it is used to increase ADC channels speed (setting of
- * direct channel).
- * @note This feature is specific to STM32L1, on devices
- * category Cat.3, Cat.4, Cat.5.
- * To use this function, COMP RCC clock domain must be enabled.
- * Refer to @ref LL_APB1_GRP1_PERIPH_COMP.
- * @rmtoll CSR FCH3 LL_ADC_GetChannelRouting
- * @rmtoll CSR FCH8 LL_ADC_GetChannelRouting
- * @rmtoll CSR RCH13 LL_ADC_GetChannelRouting
- * @param ADCx ADC instance
- * @param Channel This parameter can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_3_ROUTING (1)
- * @arg @ref LL_ADC_CHANNEL_8_ROUTING (2)
- * @arg @ref LL_ADC_CHANNEL_13_ROUTING (3)
- *
- * (1) Used as ADC direct channel (fast channel) if OPAMP1 is
- * in power down mode.\n
- * (2) Used as ADC direct channel (fast channel) if OPAMP2 is
- * in power down mode.\n
- * (3) Used as ADC re-routed channel if OPAMP3 is
- * in power down mode.
- * Otherwise, channel 13 is connected to OPAMP3 output and routed
- * through switches COMP1_SW1 and VCOMP to ADC switch matrix.
- * (Note: OPAMP3 is available on STM32L1 Cat.4 only).
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_CHANNEL_ROUTING_DEFAULT
- * @arg @ref LL_ADC_CHANNEL_ROUTING_DIRECT
- */
-__STATIC_INLINE uint32_t LL_ADC_GetChannelRouting(ADC_TypeDef *ADCx, uint32_t Channel)
-{
- /* Note: Bit is located in comparator IP, but dedicated to ADC */
- return (uint32_t)(READ_BIT(COMP->CSR, Channel) >> POSITION_VAL(Channel));
-}
-#endif
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_Configuration_ADC_AnalogWatchdog Configuration of ADC transversal scope: analog watchdog
- * @{
- */
-
-/**
- * @brief Set ADC analog watchdog monitored channels:
- * a single channel or all channels,
- * on ADC groups regular and-or injected.
- * @note Once monitored channels are selected, analog watchdog
- * is enabled.
- * @note In case of need to define a single channel to monitor
- * with analog watchdog from sequencer channel definition,
- * use helper macro @ref __LL_ADC_ANALOGWD_CHANNEL_GROUP().
- * @note On this STM32 serie, there is only 1 kind of analog watchdog
- * instance:
- * - AWD standard (instance AWD1):
- * - channels monitored: can monitor 1 channel or all channels.
- * - groups monitored: ADC groups regular and-or injected.
- * - resolution: resolution is not limited (corresponds to
- * ADC resolution configured).
- * @rmtoll CR1 AWD1CH LL_ADC_SetAnalogWDMonitChannels\n
- * CR1 AWD1SGL LL_ADC_SetAnalogWDMonitChannels\n
- * CR1 AWD1EN LL_ADC_SetAnalogWDMonitChannels
- * @param ADCx ADC instance
- * @param AWDChannelGroup This parameter can be one of the following values:
- * @arg @ref LL_ADC_AWD_DISABLE
- * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
- * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
- * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
- * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_20_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_20_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_21_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_21_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_22_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_22_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_23_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_23_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_24_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_24_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_25_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_25_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_26_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_26_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_27_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_27_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_28_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_28_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_29_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_29_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_30_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_30_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_31_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_31_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CH_VREFINT_REG (3)
- * @arg @ref LL_ADC_AWD_CH_VREFINT_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_VREFINT_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG (3)
- * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_TEMPSENSOR_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_VCOMP_REG (3)
- * @arg @ref LL_ADC_AWD_CH_VCOMP_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_VCOMP_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP1_INJ (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP1_REG_INJ (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP2_INJ (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP2_REG_INJ (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP3_INJ (3)(5)
- * @arg @ref LL_ADC_AWD_CH_VOPAMP3_REG_INJ (3)(5)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.\n
- * (5) On STM32L1, parameter not available on all devices: OPAMP1 and OPAMP2 available only on STM32L1 Cat.3, Cat.4 and Cat.5, OPAMP3 available only on STM32L1 Cat.4 and Cat.5
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetAnalogWDMonitChannels(ADC_TypeDef *ADCx, uint32_t AWDChannelGroup)
-{
- MODIFY_REG(ADCx->CR1,
- (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH),
- AWDChannelGroup);
-}
-
-/**
- * @brief Get ADC analog watchdog monitored channel.
- * @note Usage of the returned channel number:
- * - To reinject this channel into another function LL_ADC_xxx:
- * the returned channel number is only partly formatted on definition
- * of literals LL_ADC_CHANNEL_x. Therefore, it has to be compared
- * with parts of literals LL_ADC_CHANNEL_x or using
- * helper macro @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
- * Then the selected literal LL_ADC_CHANNEL_x can be used
- * as parameter for another function.
- * - To get the channel number in decimal format:
- * process the returned value with the helper macro
- * @ref __LL_ADC_CHANNEL_TO_DECIMAL_NB().
- * Applicable only when the analog watchdog is set to monitor
- * one channel.
- * @note On this STM32 serie, there is only 1 kind of analog watchdog
- * instance:
- * - AWD standard (instance AWD1):
- * - channels monitored: can monitor 1 channel or all channels.
- * - groups monitored: ADC groups regular and-or injected.
- * - resolution: resolution is not limited (corresponds to
- * ADC resolution configured).
- * @rmtoll CR1 AWD1CH LL_ADC_GetAnalogWDMonitChannels\n
- * CR1 AWD1SGL LL_ADC_GetAnalogWDMonitChannels\n
- * CR1 AWD1EN LL_ADC_GetAnalogWDMonitChannels
- * @param ADCx ADC instance
- * @retval Returned value can be one of the following values:
- * @arg @ref LL_ADC_AWD_DISABLE
- * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG
- * @arg @ref LL_ADC_AWD_ALL_CHANNELS_INJ
- * @arg @ref LL_ADC_AWD_ALL_CHANNELS_REG_INJ
- * @arg @ref LL_ADC_AWD_CHANNEL_0_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_0_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_0_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_1_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_1_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_1_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_2_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_2_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_2_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_3_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_3_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_3_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_4_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_4_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_4_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_5_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_5_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_5_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_6_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_6_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_6_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_7_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_7_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_7_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_8_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_8_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_8_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_9_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_9_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_9_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_10_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_10_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_10_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_11_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_11_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_11_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_12_REG (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_12_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_12_REG_INJ (2)
- * @arg @ref LL_ADC_AWD_CHANNEL_13_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_13_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_13_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_14_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_14_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_14_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_15_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_15_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_15_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_16_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_16_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_16_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_17_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_17_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_17_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_18_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_18_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_18_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_19_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_19_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_19_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_20_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_20_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_20_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_21_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_21_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_21_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_22_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_22_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_22_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_23_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_23_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_23_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_24_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_24_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_24_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_25_REG (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_25_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_25_REG_INJ (1)
- * @arg @ref LL_ADC_AWD_CHANNEL_26_REG (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_26_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_26_REG_INJ (3)
- * @arg @ref LL_ADC_AWD_CHANNEL_27_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_27_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_27_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_28_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_28_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_28_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_29_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_29_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_29_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_30_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_30_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_30_REG_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_31_REG (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_31_INJ (3)(4)
- * @arg @ref LL_ADC_AWD_CHANNEL_31_REG_INJ (3)(4)
- *
- * (1) On STM32L1, connection via routing interface (RI) specificity: fast channel (channel routed directly to ADC switch matrix).\n
- * (2) On STM32L1, for devices with feature 'channels banks' available: Channel different in bank A and bank B.\n
- * (3) On STM32L1, for devices with feature 'channels banks' available: Channel common to both bank A and bank B.\n
- * (4) On STM32L1, parameter not available on all devices: only on STM32L1 Cat.4 and Cat.5.
- */
-__STATIC_INLINE uint32_t LL_ADC_GetAnalogWDMonitChannels(ADC_TypeDef *ADCx)
-{
- return (uint32_t)(READ_BIT(ADCx->CR1, (ADC_CR1_AWDEN | ADC_CR1_JAWDEN | ADC_CR1_AWDSGL | ADC_CR1_AWDCH)));
-}
-
-/**
- * @brief Set ADC analog watchdog threshold value of threshold
- * high or low.
- * @note In case of ADC resolution different of 12 bits,
- * analog watchdog thresholds data require a specific shift.
- * Use helper macro @ref __LL_ADC_ANALOGWD_SET_THRESHOLD_RESOLUTION().
- * @note On this STM32 serie, there is only 1 kind of analog watchdog
- * instance:
- * - AWD standard (instance AWD1):
- * - channels monitored: can monitor 1 channel or all channels.
- * - groups monitored: ADC groups regular and-or injected.
- * - resolution: resolution is not limited (corresponds to
- * ADC resolution configured).
- * @rmtoll HTR HT LL_ADC_SetAnalogWDThresholds\n
- * LTR LT LL_ADC_SetAnalogWDThresholds
- * @param ADCx ADC instance
- * @param AWDThresholdsHighLow This parameter can be one of the following values:
- * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
- * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
- * @param AWDThresholdValue Value between Min_Data=0x000 and Max_Data=0xFFF
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_SetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow, uint32_t AWDThresholdValue)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
-
- MODIFY_REG(*preg,
- ADC_HTR_HT,
- AWDThresholdValue);
-}
-
-/**
- * @brief Get ADC analog watchdog threshold value of threshold high or
- * threshold low.
- * @note In case of ADC resolution different of 12 bits,
- * analog watchdog thresholds data require a specific shift.
- * Use helper macro @ref __LL_ADC_ANALOGWD_GET_THRESHOLD_RESOLUTION().
- * @rmtoll HTR HT LL_ADC_GetAnalogWDThresholds\n
- * LTR LT LL_ADC_GetAnalogWDThresholds
- * @param ADCx ADC instance
- * @param AWDThresholdsHighLow This parameter can be one of the following values:
- * @arg @ref LL_ADC_AWD_THRESHOLD_HIGH
- * @arg @ref LL_ADC_AWD_THRESHOLD_LOW
- * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
-*/
-__STATIC_INLINE uint32_t LL_ADC_GetAnalogWDThresholds(ADC_TypeDef *ADCx, uint32_t AWDThresholdsHighLow)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->HTR, AWDThresholdsHighLow);
-
- return (uint32_t)(READ_BIT(*preg, ADC_HTR_HT));
-}
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_Operation_ADC_Instance Operation on ADC hierarchical scope: ADC instance
- * @{
- */
-
-/**
- * @brief Enable the selected ADC instance.
- * @note On this STM32 serie, after ADC enable, a delay for
- * ADC internal analog stabilization is required before performing a
- * ADC conversion start.
- * Refer to device datasheet, parameter tSTAB.
- * @note Due to the latency introduced by the synchronization between
- * two clock domains (ADC clock source asynchronous),
- * some hardware constraints must be respected:
- * - ADC must be enabled (@ref LL_ADC_Enable() ) only
- * when ADC is not ready to convert.
- * - ADC must be disabled (@ref LL_ADC_Disable() ) only
- * when ADC is ready to convert.
- * Status of ADC ready to convert can be checked using function
- * @ref LL_ADC_IsActiveFlag_ADRDY().
- * @rmtoll CR2 ADON LL_ADC_Enable
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_Enable(ADC_TypeDef *ADCx)
-{
- SET_BIT(ADCx->CR2, ADC_CR2_ADON);
-}
-
-/**
- * @brief Disable the selected ADC instance.
- * @note Due to the latency introduced by the synchronization between
- * two clock domains (ADC clock source asynchronous),
- * some hardware constraints must be respected:
- * - ADC must be enabled (@ref LL_ADC_Enable() ) only
- * when ADC is not ready to convert.
- * - ADC must be disabled (@ref LL_ADC_Disable() ) only
- * when ADC is ready to convert.
- * Status of ADC ready to convert can be checked using function
- * @ref LL_ADC_IsActiveFlag_ADRDY().
- * @rmtoll CR2 ADON LL_ADC_Disable
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_Disable(ADC_TypeDef *ADCx)
-{
- CLEAR_BIT(ADCx->CR2, ADC_CR2_ADON);
-}
-
-/**
- * @brief Get the selected ADC instance enable state.
- * @rmtoll CR2 ADON LL_ADC_IsEnabled
- * @param ADCx ADC instance
- * @retval 0: ADC is disabled, 1: ADC is enabled.
- */
-__STATIC_INLINE uint32_t LL_ADC_IsEnabled(ADC_TypeDef *ADCx)
-{
- return (READ_BIT(ADCx->CR2, ADC_CR2_ADON) == (ADC_CR2_ADON));
-}
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_Operation_ADC_Group_Regular Operation on ADC hierarchical scope: group regular
- * @{
- */
-
-/**
- * @brief Start ADC group regular conversion.
- * @note On this STM32 serie, this function is relevant only for
- * internal trigger (SW start), not for external trigger:
- * - If ADC trigger has been set to software start, ADC conversion
- * starts immediately.
- * - If ADC trigger has been set to external trigger, ADC conversion
- * start must be performed using function
- * @ref LL_ADC_REG_StartConversionExtTrig().
- * (if external trigger edge would have been set during ADC other
- * settings, ADC conversion would start at trigger event
- * as soon as ADC is enabled).
- * @rmtoll CR2 SWSTART LL_ADC_REG_StartConversionSWStart
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_REG_StartConversionSWStart(ADC_TypeDef *ADCx)
-{
- SET_BIT(ADCx->CR2, ADC_CR2_SWSTART);
-}
-
-/**
- * @brief Start ADC group regular conversion from external trigger.
- * @note ADC conversion will start at next trigger event (on the selected
- * trigger edge) following the ADC start conversion command.
- * @note On this STM32 serie, this function is relevant for
- * ADC conversion start from external trigger.
- * If internal trigger (SW start) is needed, perform ADC conversion
- * start using function @ref LL_ADC_REG_StartConversionSWStart().
- * @rmtoll CR2 EXTEN LL_ADC_REG_StartConversionExtTrig
- * @param ExternalTriggerEdge This parameter can be one of the following values:
- * @arg @ref LL_ADC_REG_TRIG_EXT_RISING
- * @arg @ref LL_ADC_REG_TRIG_EXT_FALLING
- * @arg @ref LL_ADC_REG_TRIG_EXT_RISINGFALLING
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_REG_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
-{
- SET_BIT(ADCx->CR2, ExternalTriggerEdge);
-}
-
-/**
- * @brief Stop ADC group regular conversion from external trigger.
- * @note No more ADC conversion will start at next trigger event
- * following the ADC stop conversion command.
- * If a conversion is on-going, it will be completed.
- * @note On this STM32 serie, there is no specific command
- * to stop a conversion on-going or to stop ADC converting
- * in continuous mode. These actions can be performed
- * using function @ref LL_ADC_Disable().
- * @rmtoll CR2 EXTEN LL_ADC_REG_StopConversionExtTrig
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_REG_StopConversionExtTrig(ADC_TypeDef *ADCx)
-{
- CLEAR_BIT(ADCx->CR2, ADC_CR2_EXTEN);
-}
-
-/**
- * @brief Get ADC group regular conversion data, range fit for
- * all ADC configurations: all ADC resolutions and
- * all oversampling increased data width (for devices
- * with feature oversampling).
- * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData32
- * @param ADCx ADC instance
- * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
- */
-__STATIC_INLINE uint32_t LL_ADC_REG_ReadConversionData32(ADC_TypeDef *ADCx)
-{
- return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
-}
-
-/**
- * @brief Get ADC group regular conversion data, range fit for
- * ADC resolution 12 bits.
- * @note For devices with feature oversampling: Oversampling
- * can increase data width, function for extended range
- * may be needed: @ref LL_ADC_REG_ReadConversionData32.
- * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData12
- * @param ADCx ADC instance
- * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
- */
-__STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData12(ADC_TypeDef *ADCx)
-{
- return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
-}
-
-/**
- * @brief Get ADC group regular conversion data, range fit for
- * ADC resolution 10 bits.
- * @note For devices with feature oversampling: Oversampling
- * can increase data width, function for extended range
- * may be needed: @ref LL_ADC_REG_ReadConversionData32.
- * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData10
- * @param ADCx ADC instance
- * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
- */
-__STATIC_INLINE uint16_t LL_ADC_REG_ReadConversionData10(ADC_TypeDef *ADCx)
-{
- return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
-}
-
-/**
- * @brief Get ADC group regular conversion data, range fit for
- * ADC resolution 8 bits.
- * @note For devices with feature oversampling: Oversampling
- * can increase data width, function for extended range
- * may be needed: @ref LL_ADC_REG_ReadConversionData32.
- * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData8
- * @param ADCx ADC instance
- * @retval Value between Min_Data=0x00 and Max_Data=0xFF
- */
-__STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData8(ADC_TypeDef *ADCx)
-{
- return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
-}
-
-/**
- * @brief Get ADC group regular conversion data, range fit for
- * ADC resolution 6 bits.
- * @note For devices with feature oversampling: Oversampling
- * can increase data width, function for extended range
- * may be needed: @ref LL_ADC_REG_ReadConversionData32.
- * @rmtoll DR RDATA LL_ADC_REG_ReadConversionData6
- * @param ADCx ADC instance
- * @retval Value between Min_Data=0x00 and Max_Data=0x3F
- */
-__STATIC_INLINE uint8_t LL_ADC_REG_ReadConversionData6(ADC_TypeDef *ADCx)
-{
- return (uint16_t)(READ_BIT(ADCx->DR, ADC_DR_DATA));
-}
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_Operation_ADC_Group_Injected Operation on ADC hierarchical scope: group injected
- * @{
- */
-
-/**
- * @brief Start ADC group injected conversion.
- * @note On this STM32 serie, this function is relevant only for
- * internal trigger (SW start), not for external trigger:
- * - If ADC trigger has been set to software start, ADC conversion
- * starts immediately.
- * - If ADC trigger has been set to external trigger, ADC conversion
- * start must be performed using function
- * @ref LL_ADC_INJ_StartConversionExtTrig().
- * (if external trigger edge would have been set during ADC other
- * settings, ADC conversion would start at trigger event
- * as soon as ADC is enabled).
- * @rmtoll CR2 JSWSTART LL_ADC_INJ_StartConversionSWStart
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_INJ_StartConversionSWStart(ADC_TypeDef *ADCx)
-{
- SET_BIT(ADCx->CR2, ADC_CR2_JSWSTART);
-}
-
-/**
- * @brief Start ADC group injected conversion from external trigger.
- * @note ADC conversion will start at next trigger event (on the selected
- * trigger edge) following the ADC start conversion command.
- * @note On this STM32 serie, this function is relevant for
- * ADC conversion start from external trigger.
- * If internal trigger (SW start) is needed, perform ADC conversion
- * start using function @ref LL_ADC_INJ_StartConversionSWStart().
- * @rmtoll CR2 JEXTEN LL_ADC_INJ_StartConversionExtTrig
- * @param ExternalTriggerEdge This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_TRIG_EXT_RISING
- * @arg @ref LL_ADC_INJ_TRIG_EXT_FALLING
- * @arg @ref LL_ADC_INJ_TRIG_EXT_RISINGFALLING
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_INJ_StartConversionExtTrig(ADC_TypeDef *ADCx, uint32_t ExternalTriggerEdge)
-{
- SET_BIT(ADCx->CR2, ExternalTriggerEdge);
-}
-
-/**
- * @brief Stop ADC group injected conversion from external trigger.
- * @note No more ADC conversion will start at next trigger event
- * following the ADC stop conversion command.
- * If a conversion is on-going, it will be completed.
- * @note On this STM32 serie, there is no specific command
- * to stop a conversion on-going or to stop ADC converting
- * in continuous mode. These actions can be performed
- * using function @ref LL_ADC_Disable().
- * @rmtoll CR2 JEXTEN LL_ADC_INJ_StopConversionExtTrig
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_INJ_StopConversionExtTrig(ADC_TypeDef *ADCx)
-{
- CLEAR_BIT(ADCx->CR2, ADC_CR2_JEXTEN);
-}
-
-/**
- * @brief Get ADC group regular conversion data, range fit for
- * all ADC configurations: all ADC resolutions and
- * all oversampling increased data width (for devices
- * with feature oversampling).
- * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData32\n
- * JDR2 JDATA LL_ADC_INJ_ReadConversionData32\n
- * JDR3 JDATA LL_ADC_INJ_ReadConversionData32\n
- * JDR4 JDATA LL_ADC_INJ_ReadConversionData32
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_RANK_1
- * @arg @ref LL_ADC_INJ_RANK_2
- * @arg @ref LL_ADC_INJ_RANK_3
- * @arg @ref LL_ADC_INJ_RANK_4
- * @retval Value between Min_Data=0x00000000 and Max_Data=0xFFFFFFFF
- */
-__STATIC_INLINE uint32_t LL_ADC_INJ_ReadConversionData32(ADC_TypeDef *ADCx, uint32_t Rank)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
-
- return (uint32_t)(READ_BIT(*preg,
- ADC_JDR1_JDATA)
- );
-}
-
-/**
- * @brief Get ADC group injected conversion data, range fit for
- * ADC resolution 12 bits.
- * @note For devices with feature oversampling: Oversampling
- * can increase data width, function for extended range
- * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
- * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData12\n
- * JDR2 JDATA LL_ADC_INJ_ReadConversionData12\n
- * JDR3 JDATA LL_ADC_INJ_ReadConversionData12\n
- * JDR4 JDATA LL_ADC_INJ_ReadConversionData12
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_RANK_1
- * @arg @ref LL_ADC_INJ_RANK_2
- * @arg @ref LL_ADC_INJ_RANK_3
- * @arg @ref LL_ADC_INJ_RANK_4
- * @retval Value between Min_Data=0x000 and Max_Data=0xFFF
- */
-__STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData12(ADC_TypeDef *ADCx, uint32_t Rank)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
-
- return (uint16_t)(READ_BIT(*preg,
- ADC_JDR1_JDATA)
- );
-}
-
-/**
- * @brief Get ADC group injected conversion data, range fit for
- * ADC resolution 10 bits.
- * @note For devices with feature oversampling: Oversampling
- * can increase data width, function for extended range
- * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
- * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData10\n
- * JDR2 JDATA LL_ADC_INJ_ReadConversionData10\n
- * JDR3 JDATA LL_ADC_INJ_ReadConversionData10\n
- * JDR4 JDATA LL_ADC_INJ_ReadConversionData10
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_RANK_1
- * @arg @ref LL_ADC_INJ_RANK_2
- * @arg @ref LL_ADC_INJ_RANK_3
- * @arg @ref LL_ADC_INJ_RANK_4
- * @retval Value between Min_Data=0x000 and Max_Data=0x3FF
- */
-__STATIC_INLINE uint16_t LL_ADC_INJ_ReadConversionData10(ADC_TypeDef *ADCx, uint32_t Rank)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
-
- return (uint16_t)(READ_BIT(*preg,
- ADC_JDR1_JDATA)
- );
-}
-
-/**
- * @brief Get ADC group injected conversion data, range fit for
- * ADC resolution 8 bits.
- * @note For devices with feature oversampling: Oversampling
- * can increase data width, function for extended range
- * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
- * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData8\n
- * JDR2 JDATA LL_ADC_INJ_ReadConversionData8\n
- * JDR3 JDATA LL_ADC_INJ_ReadConversionData8\n
- * JDR4 JDATA LL_ADC_INJ_ReadConversionData8
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_RANK_1
- * @arg @ref LL_ADC_INJ_RANK_2
- * @arg @ref LL_ADC_INJ_RANK_3
- * @arg @ref LL_ADC_INJ_RANK_4
- * @retval Value between Min_Data=0x00 and Max_Data=0xFF
- */
-__STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData8(ADC_TypeDef *ADCx, uint32_t Rank)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
-
- return (uint8_t)(READ_BIT(*preg,
- ADC_JDR1_JDATA)
- );
-}
-
-/**
- * @brief Get ADC group injected conversion data, range fit for
- * ADC resolution 6 bits.
- * @note For devices with feature oversampling: Oversampling
- * can increase data width, function for extended range
- * may be needed: @ref LL_ADC_INJ_ReadConversionData32.
- * @rmtoll JDR1 JDATA LL_ADC_INJ_ReadConversionData6\n
- * JDR2 JDATA LL_ADC_INJ_ReadConversionData6\n
- * JDR3 JDATA LL_ADC_INJ_ReadConversionData6\n
- * JDR4 JDATA LL_ADC_INJ_ReadConversionData6
- * @param ADCx ADC instance
- * @param Rank This parameter can be one of the following values:
- * @arg @ref LL_ADC_INJ_RANK_1
- * @arg @ref LL_ADC_INJ_RANK_2
- * @arg @ref LL_ADC_INJ_RANK_3
- * @arg @ref LL_ADC_INJ_RANK_4
- * @retval Value between Min_Data=0x00 and Max_Data=0x3F
- */
-__STATIC_INLINE uint8_t LL_ADC_INJ_ReadConversionData6(ADC_TypeDef *ADCx, uint32_t Rank)
-{
- uint32_t *preg = __ADC_PTR_REG_OFFSET(ADCx->JDR1, __ADC_MASK_SHIFT(Rank, ADC_INJ_JDRX_REGOFFSET_MASK));
-
- return (uint8_t)(READ_BIT(*preg,
- ADC_JDR1_JDATA)
- );
-}
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_FLAG_Management ADC flag management
- * @{
- */
-
-/**
- * @brief Get flag ADC ready.
- * @rmtoll SR ADONS LL_ADC_IsActiveFlag_ADRDY
- * @param ADCx ADC instance
- * @retval State of bit (1 or 0).
- */
-__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_ADRDY(ADC_TypeDef *ADCx)
-{
- return (READ_BIT(ADCx->SR, LL_ADC_FLAG_ADRDY) == (LL_ADC_FLAG_ADRDY));
-}
-
-/**
- * @brief Get flag ADC group regular end of unitary conversion
- * or end of sequence conversions, depending on
- * ADC configuration.
- * @note To configure flag of end of conversion,
- * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
- * @rmtoll SR EOC LL_ADC_IsActiveFlag_EOCS
- * @param ADCx ADC instance
- * @retval State of bit (1 or 0).
- */
-__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_EOCS(ADC_TypeDef *ADCx)
-{
- return (READ_BIT(ADCx->SR, LL_ADC_FLAG_EOCS) == (LL_ADC_FLAG_EOCS));
-}
-
-/**
- * @brief Get flag ADC group regular overrun.
- * @rmtoll SR OVR LL_ADC_IsActiveFlag_OVR
- * @param ADCx ADC instance
- * @retval State of bit (1 or 0).
- */
-__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_OVR(ADC_TypeDef *ADCx)
-{
- return (READ_BIT(ADCx->SR, LL_ADC_FLAG_OVR) == (LL_ADC_FLAG_OVR));
-}
-
-
-/**
- * @brief Get flag ADC group injected end of sequence conversions.
- * @rmtoll SR JEOC LL_ADC_IsActiveFlag_JEOS
- * @param ADCx ADC instance
- * @retval State of bit (1 or 0).
- */
-__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_JEOS(ADC_TypeDef *ADCx)
-{
- /* Note: on this STM32 serie, there is no flag ADC group injected */
- /* end of unitary conversion. */
- /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
- /* in other STM32 families). */
- return (READ_BIT(ADCx->SR, LL_ADC_FLAG_JEOS) == (LL_ADC_FLAG_JEOS));
-}
-
-/**
- * @brief Get flag ADC analog watchdog 1 flag
- * @rmtoll SR AWD LL_ADC_IsActiveFlag_AWD1
- * @param ADCx ADC instance
- * @retval State of bit (1 or 0).
- */
-__STATIC_INLINE uint32_t LL_ADC_IsActiveFlag_AWD1(ADC_TypeDef *ADCx)
-{
- return (READ_BIT(ADCx->SR, LL_ADC_FLAG_AWD1) == (LL_ADC_FLAG_AWD1));
-}
-
-/**
- * @brief Clear flag ADC group regular end of unitary conversion
- * or end of sequence conversions, depending on
- * ADC configuration.
- * @note To configure flag of end of conversion,
- * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
- * @rmtoll SR EOC LL_ADC_ClearFlag_EOCS
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_ClearFlag_EOCS(ADC_TypeDef *ADCx)
-{
- WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_EOCS);
-}
-
-/**
- * @brief Clear flag ADC group regular overrun.
- * @rmtoll SR OVR LL_ADC_ClearFlag_OVR
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_ClearFlag_OVR(ADC_TypeDef *ADCx)
-{
- WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_OVR);
-}
-
-
-/**
- * @brief Clear flag ADC group injected end of sequence conversions.
- * @rmtoll SR JEOC LL_ADC_ClearFlag_JEOS
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_ClearFlag_JEOS(ADC_TypeDef *ADCx)
-{
- /* Note: on this STM32 serie, there is no flag ADC group injected */
- /* end of unitary conversion. */
- /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
- /* in other STM32 families). */
- WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_JEOS);
-}
-
-/**
- * @brief Clear flag ADC analog watchdog 1.
- * @rmtoll SR AWD LL_ADC_ClearFlag_AWD1
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_ClearFlag_AWD1(ADC_TypeDef *ADCx)
-{
- WRITE_REG(ADCx->SR, ~LL_ADC_FLAG_AWD1);
-}
-
-/**
- * @}
- */
-
-/** @defgroup ADC_LL_EF_IT_Management ADC IT management
- * @{
- */
-
-/**
- * @brief Enable interruption ADC group regular end of unitary conversion
- * or end of sequence conversions, depending on
- * ADC configuration.
- * @note To configure flag of end of conversion,
- * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
- * @rmtoll CR1 EOCIE LL_ADC_EnableIT_EOCS
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_EnableIT_EOCS(ADC_TypeDef *ADCx)
-{
- SET_BIT(ADCx->CR1, LL_ADC_IT_EOCS);
-}
-
-/**
- * @brief Enable ADC group regular interruption overrun.
- * @rmtoll CR1 OVRIE LL_ADC_EnableIT_OVR
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_EnableIT_OVR(ADC_TypeDef *ADCx)
-{
- SET_BIT(ADCx->CR1, LL_ADC_IT_OVR);
-}
-
-
-/**
- * @brief Enable interruption ADC group injected end of sequence conversions.
- * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_EnableIT_JEOS(ADC_TypeDef *ADCx)
-{
- /* Note: on this STM32 serie, there is no flag ADC group injected */
- /* end of unitary conversion. */
- /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
- /* in other STM32 families). */
- SET_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
-}
-
-/**
- * @brief Enable interruption ADC analog watchdog 1.
- * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_EnableIT_AWD1(ADC_TypeDef *ADCx)
-{
- SET_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
-}
-
-/**
- * @brief Disable interruption ADC group regular end of unitary conversion
- * or end of sequence conversions, depending on
- * ADC configuration.
- * @note To configure flag of end of conversion,
- * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
- * @rmtoll CR1 EOCIE LL_ADC_DisableIT_EOCS
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_DisableIT_EOCS(ADC_TypeDef *ADCx)
-{
- CLEAR_BIT(ADCx->CR1, LL_ADC_IT_EOCS);
-}
-
-/**
- * @brief Disable interruption ADC group regular overrun.
- * @rmtoll CR1 OVRIE LL_ADC_DisableIT_OVR
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_DisableIT_OVR(ADC_TypeDef *ADCx)
-{
- CLEAR_BIT(ADCx->CR1, LL_ADC_IT_OVR);
-}
-
-
-/**
- * @brief Disable interruption ADC group injected end of sequence conversions.
- * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_DisableIT_JEOS(ADC_TypeDef *ADCx)
-{
- /* Note: on this STM32 serie, there is no flag ADC group injected */
- /* end of unitary conversion. */
- /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
- /* in other STM32 families). */
- CLEAR_BIT(ADCx->CR1, LL_ADC_IT_JEOS);
-}
-
-/**
- * @brief Disable interruption ADC analog watchdog 1.
- * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
- * @param ADCx ADC instance
- * @retval None
- */
-__STATIC_INLINE void LL_ADC_DisableIT_AWD1(ADC_TypeDef *ADCx)
-{
- CLEAR_BIT(ADCx->CR1, LL_ADC_IT_AWD1);
-}
-
-/**
- * @brief Get state of interruption ADC group regular end of unitary conversion
- * or end of sequence conversions, depending on
- * ADC configuration.
- * @note To configure flag of end of conversion,
- * use function @ref LL_ADC_REG_SetFlagEndOfConversion().
- * (0: interrupt disabled, 1: interrupt enabled)
- * @rmtoll CR1 EOCIE LL_ADC_IsEnabledIT_EOCS
- * @param ADCx ADC instance
- * @retval State of bit (1 or 0).
- */
-__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_EOCS(ADC_TypeDef *ADCx)
-{
- return (READ_BIT(ADCx->CR1, LL_ADC_IT_EOCS) == (LL_ADC_IT_EOCS));
-}
-
-/**
- * @brief Get state of interruption ADC group regular overrun
- * (0: interrupt disabled, 1: interrupt enabled).
- * @rmtoll CR1 OVRIE LL_ADC_IsEnabledIT_OVR
- * @param ADCx ADC instance
- * @retval State of bit (1 or 0).
- */
-__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_OVR(ADC_TypeDef *ADCx)
-{
- return (READ_BIT(ADCx->CR1, LL_ADC_IT_OVR) == (LL_ADC_IT_OVR));
-}
-
-
-/**
- * @brief Get state of interruption ADC group injected end of sequence conversions
- * (0: interrupt disabled, 1: interrupt enabled).
- * @rmtoll CR1 JEOCIE LL_ADC_EnableIT_JEOS
- * @param ADCx ADC instance
- * @retval State of bit (1 or 0).
- */
-__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_JEOS(ADC_TypeDef *ADCx)
-{
- /* Note: on this STM32 serie, there is no flag ADC group injected */
- /* end of unitary conversion. */
- /* Flag noted as "JEOC" is corresponding to flag "JEOS" */
- /* in other STM32 families). */
- return (READ_BIT(ADCx->CR1, LL_ADC_IT_JEOS) == (LL_ADC_IT_JEOS));
-}
-
-/**
- * @brief Get state of interruption ADC analog watchdog 1
- * (0: interrupt disabled, 1: interrupt enabled).
- * @rmtoll CR1 AWDIE LL_ADC_EnableIT_AWD1
- * @param ADCx ADC instance
- * @retval State of bit (1 or 0).
- */
-__STATIC_INLINE uint32_t LL_ADC_IsEnabledIT_AWD1(ADC_TypeDef *ADCx)
-{
- return (READ_BIT(ADCx->CR1, LL_ADC_IT_AWD1) == (LL_ADC_IT_AWD1));
-}
-
-/**
- * @}
- */
-
-#if defined(USE_FULL_LL_DRIVER)
-/** @defgroup ADC_LL_EF_Init Initialization and de-initialization functions
- * @{
- */
-
-/* Initialization of some features of ADC common parameters and multimode */
-ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON);
-ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
-void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct);
-
-/* De-initialization of ADC instance, ADC group regular and ADC group injected */
-/* (availability of ADC group injected depends on STM32 families) */
-ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx);
-
-/* Initialization of some features of ADC instance */
-ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct);
-void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct);
-
-/* Initialization of some features of ADC instance and ADC group regular */
-ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
-void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct);
-
-/* Initialization of some features of ADC instance and ADC group injected */
-ErrorStatus LL_ADC_INJ_Init(ADC_TypeDef *ADCx, LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
-void LL_ADC_INJ_StructInit(LL_ADC_INJ_InitTypeDef *ADC_INJ_InitStruct);
-
-/**
- * @}
- */
-#endif /* USE_FULL_LL_DRIVER */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* ADC1 */
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __STM32L1xx_LL_ADC_H */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Inc/stm32l1xx_ll_bus.h b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Inc/stm32l1xx_ll_bus.h
deleted file mode 100644
index c4c1e0a6a6b..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Inc/stm32l1xx_ll_bus.h
+++ /dev/null
@@ -1,1103 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_ll_bus.h
- * @author MCD Application Team
- * @brief Header file of BUS LL module.
-
- @verbatim
- ##### RCC Limitations #####
- ==============================================================================
- [..]
- A delay between an RCC peripheral clock enable and the effective peripheral
- enabling should be taken into account in order to manage the peripheral read/write
- from/to registers.
- (+) This delay depends on the peripheral mapping.
- (++) AHB & APB peripherals, 1 dummy read is necessary
-
- [..]
- Workarounds:
- (#) For AHB & APB peripherals, a dummy read to the peripheral register has been
- inserted in each LL_{BUS}_GRP{x}_EnableClock() function.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
Licensed by ST under BSD 3-Clause license (the "License"). You may not use this package except in compliance with the License. You may obtain a copy of the License at:
The STM32Cube HAL and LL, an STM32 abstraction layer embedded software, ensure maximized portability across STM32 portfolio.
-
The portable APIs layer provides a generic, multi instanced and simple set of APIs to interact with the upper layer (application, libraries and stacks). It is composed of native and extended APIs set. It is directly built around a generic architecture and allows the build-upon layers, like the middleware layer, to implement its functions without knowing in-depth the used STM32 device. This improves the library code reusability and guarantees an easy portability on other devices and STM32 families.
-
The Low Layer (LL) drivers are part of the STM32Cube firmware HAL that provides a basic set of optimized and one shot services. The Low layer drivers, contrary to the HAL ones are not fully portable across the STM32 families; the availability of some functions depends on the physical availability of the relative features on the product. The Low Layer (LL) drivers are designed to offer the following features:
-
-
New set of inline functions for direct and atomic register access
-
One-shot operations that can be used by the HAL drivers or from application level
-
Full independence from HAL and standalone usage (without HAL drivers)
-
Full features coverage of all the supported peripherals
-
-
-
-
Update History
-
-
-
-
Main Changes
-
Maintenance release
-
-
Patch release to to fix known defects and enhancements implementation.
-
-
Contents
-
-
HAL Generic update
-
-
Update HAL TimeBase TIM template for more robustness
-
-
Update Hal_Init_Tick() API to propoerty store the priority when using the non-default time base.
-
-
-
HAL/LL TIM update
-
-
Previous release note corrected by removing reference to ChannelNState.
-
Made TIM_DMADelayPulseCplt callback as a private function.
-
Update HAL_TIMEx_OnePulseN_Start and HAL_TIMEx_OnePulseN_Stop (pooling and IT mode) to take into consideration all OutputChannel parameters.
-
Update input capture measurement in DMA mode to avoid zero return values at high frequencies.
-
Update LL_TIM_GetCounterMode() API to return the correct counter mode.
-
Correct reversed description of TIM_LL_EC_ONEPULSEMODE One Pulse Mode.
-
-
HAL/LL SPI update
-
-
Update LL_SPI_TransmitData8() API to avoid casting the result to 8 bits.
-
Update to fix MISRA-C 2012 Rule-13.2.
-
-
HAL/LL USART update
-
-
Remove useless check on maximum BRR value by removing IS_LL_USART_BRR_MAX() macro.
-
-
HAL UART update
-
-
Correction on UART ReceptionType management in case of ReceptionToIdle API are called from RxEvent callback. Update UART polling and interruption processes to fix issues related to access out of user’s specified buffer. Fix wrong comment related to RX pin configuration within the description section. Enhance reception for idle services (ReceptionToIdle):
-
-
Add a new field (HAL_UART_RxTypeTypeDef) to the UART_HandleTypeDef structure to identify the type of ongoing reception.
-
Add UART Reception Event Callback registration.
-
Add reception specific APIs specific to reception for Idle transfer in different modes:
-
HAL_UARTEx_ReceiveToIdle(): Receive an amount of data in blocking mode until either the expected number of data is received or an IDLE event occurs.
-
HAL_UARTEx_ReceiveToIdle_IT(): Receive an amount of data in interrupt mode until either the expected number of data is received or an IDLE event occurs.
-
HAL_UARTEx_ReceiveToIdle_DMA(): Receive an amount of data in DMA mode until either the expected number of data is received or an IDLE event occurs.
-
Update HAL_UART_Receive(), HAL_UART_Receive_IT() and HAL_UART_Receive_DMA() APIs to support the new enhancement of ReceptionToIdle.
-
-
-
HAL SMARTCARD update
-
-
Fix typos in the SMARTCARD State definition description.
-
-
HAL IRDA update
-
-
Fix typos in the IRDA State definition description.
-
-
HAL RTC update
-
-
New APIs to subtract or add one hour to the calendar in one single operation without going through the initialization procedure (Daylight Saving):
-
-
HAL_RTC_DST_Add1Hour()
-
HAL_RTC_DST_Sub1Hour()
-
HAL_RTC_DST_SetStoreOperation()
-
HAL_RTC_DST_ClearStoreOperation()
-
HAL_RTC_DST_ReadStoreOperation()
-
DayLightSaving and StoreOperation interfaces from RTC_TimeTypeDef type and HAL_RTC_DAYLIGHT_SAVING_TIME_ADD1H() and HAL_RTC_DAYLIGHT_SAVING_TIME_SUB1H() macros are now deprecated.
-
-
Fix the wait for the RSF bit to be cleared in the LL_RTC_WaitForSynchro function.
-
Correct month management in IS_LL_RTC_MONTH() macro.
-
Update __HAL_RTC_…(__HANDLE__, …) macros to access registers through (__HANDLE__)->Instance pointer and avoid “unused variable” warnings.
-
-
LL FMC_LL update
-
-
Fix compilation warning with gcc -Wpedantic compiler option
-
-
HAL SDMMC update
-
-
Update the definition of SDMMC_DATATIMEOUT constant in order to allow the user to redefine it in his proper application.
-
SD_FindSCR() updated to resolve an issue with FIFO blocking when reading.
-
Update the definition of SDMMC_DATATIMEOUT constant in order to allow the user to redefine it in his proper application.
-
Add the block size settings in the initialization functions and remove it from read/write transactions to avoid repeated and inefficient reconfiguration.
-
Update read/write functions in DMA mode in order to force the DMA direction.
-
Deploy new functions MMC_ReadExtCSD() and SDMMC_CmdSendEXTCSD () that read and check the sectors number of the device in order to resolve the issue of wrongly reading big memory size.
-
-
HAL FLASH update
-
-
Update FLASH_SetErrorCode() to correctly handle the SIZERR flag.
-
-
HAL USB_FS update
-
-
HAL PCD: add fix transfer complete for IN Interrupt transaction in single buffer mode.
-
-
HAL OPAMP update
-
-
Fix CodeSonar error.
-
Update HAL_OPAMP_SelfCalibrate() API to avoid wrong configuration of trimming value “n” and “p”.
-
-
HAL I2C update
-
-
Update to avoid I2C interrupt in endless loop:
-
-
Update HAL_I2C_Master_Transmit_IT(), HAL_I2C_Master_Receive_IT(), HAL_I2C_Master_Transmit_DMA() and HAL_I2C_Master_Receive_DMA() APIs to unlock the I2C peripheral before generating the start.
-
-
Update the management of (hi2c->hdmatx!=NULL) & (hi2c->hdmarx!=NULL) check.
-
Update to prevent several calls of Start bit:
-
-
Update I2C_MemoryTransmit_TXE_BTF() API to increment EventCount.
-
-
Update to use the right macro to clear I2C ADDR flag inside I2C_Slave_ADDR() API as it’s indicated in the reference manual.
-
Update HAL_I2C_EV_IRQHandler() and I2C_MasterTransmit_BTF() APIs to fix an issue where the transfer of the first few bytes to an I2C memory fails.
-
-
HAL/LL ADC update
-
-
Update HAL_ADC_Stop_DMA() API to check if DMA state is Busy before calling HAL_DMA_Abort() API to avoid DMA internal error.
-
Update HAL ADC driver to add include of the LL ADC driver.
-
Update timeout mechanism to avoid false timeout detection in case of preemption.
-
Update LL_ADC_REG_Init() API to avoid enabling continuous mode and discontinuous mode simultaneously.
-
-
HAL WWDG update
-
-
Update HAL driver description.
-
-
HAL IWDG update
-
-
Update HAL_IWDG_Init() API in order to fix HAL_GetTick() timeout vulnerability issue.
-
Add LSI startup time in default IWDG timeout calculation (HAL_IWDG_DEFAULT_TIMEOUT).
-
-
HAL EXTI update
-
-
Update macros using LINE as a macro parameter to use EXTI_LINE instead to resolve parameter conflicts with standard C usage.
-
Update HAL_EXTI_GetConfigLine() API to set default configuration value of Trigger and GPIOSel before checking each corresponding registers.
-
-
-
-
-
-
-
-
Main Changes
-
Maintenance release
-
-
General updates to fix known defect.
-
-
Contents
-
-
HAL/LL I2C driver
-
-
Update to fix hardfault issue with HAL_I2C_Mem_Write_DMA() API:
-
-
Abort the right ongoing DMA transfer when memory write access request operation failed: fix typo “hdmarx” replaced by “hdmatx”
-
-
-
-
-
-
-
-
-
Main Changes
-
Maintenance release
-
-
Patch release to fix issue in I2C HAL driver
-
-
Contents
-
-
HAL I2C driver
-
-
Update I2C_MasterReceiveRXNE() static API to avoid set the STOP bit again after the bit clearing by Hardware during the masking operation.
-
-
Add new API I2C_WaitOnSTOPRequestThroughIT() to wait for stop bit.
-
-
-
-
-
-
-
-
-
Main Changes
-
Maintenance release
-
-
Add new HAL EXTI driver
-
General updates to fix known defects and enhancements implementation
-
-
Contents
-
-
HAL driver
-
-
Enhance HAL_SetTickFreq() API robustness
-
-
Restore previous tick frequency when a wrong tick initialization occurs.
-
-
-
LL ADC driver
-
-
Fix ADC TEMPSENSOR/VREFINT calibration addresses
-
-
HAL/LL GPIO driver
-
-
Update HAL_GPIO_TogglePin() API to allow the toggling of many pins
-
Update GPIO initialization sequence to avoid unwanted pulse on GPIO Pin’s
-
-
HAL EXTI driver
-
-
Add new HAL_EXTI driver.
-
-
HAL FLASH driver
-
-
Fix assert compilation error with HAL_FLASHEx_DATAEEPROM_Erase() API.
-
-
HAL/LL I2C driver
-
-
Update HAL_I2C_ER_IRQHandler() API to fix acknowledge failure issue with I2C memory IT processes
-
-
Add stop condition generation when NACK occurs.
-
-
Update I2C_DMAXferCplt(), I2C_DMAError() and I2C_DMAAbort() APIs to fix hardfault issue when hdmatx and hdmarx parameters in i2c handle aren’t initialized (NULL pointer).
-
Update HAL_I2C_Init() API to force software reset before setting new I2C configuration
-
Update HAL I2C processes to report ErrorCode when wrong I2C start condition occurs
-
-
Add new ErrorCode define: HAL_I2C_WRONG_START
-
Set ErrorCode parameter in I2C handle to HAL_I2C_WRONG_START
-
-
Update sequential APIs to avoid requesting a START when a STOP condition is not fully treated
-
-
Wait the end of STOP treatment by polling (with a timeout) the STOP bit on Control register CR1
-
-
-
HAL/LL I2S driver
-
-
Update HAL_I2S_DMAStop() API to be more safe
-
-
Add a check on BSY, TXE and RXNE flags before disabling the I2S
-
-
Update HAL_I2S_DMAStop() API to fix multi-call transfer issue(to avoid re-initializing the I2S for the next transfer).
-
-
Add __HAL_I2SEXT_FLUSH_RX_DR() and __HAL_I2S_FLUSH_RX_DR() macros to flush the remaining data inside DR registers.
-
Add new ErrorCode define: HAL_I2S_ERROR_BUSY_LINE_RX
-
-
-
HAL IRDA driver
-
-
Update IRDA interruption handler to manage correctly the overrun interrupt
-
-
Add in the HAL_IRDA_IRQHandler() API a check on USART_CR1_RXNEIE bit when an overrun interrupt occurs.
-
-
-
HAL SMARTCARD driver
-
-
Update SMARTCARD interruption handler to manage correctly the overrun interrupt
-
-
Add in the HAL_SMARTCARD_IRQHandler() API a check on USART_CR1_RXNEIE bit when an overrun interrupt occurs.
-
-
Update SMARTCARD transmission and reception API to handle memory corruption
-
-
HAL_SMARTCARD_Transmit(), HAL_SMARTCARD_Receive()
-
SMARTCARD_Transmit_IT(), SMARTCARD_Receive_IT()
-
-
-
HAL/LL SPI driver
-
-
Update to implement Erratasheet: BSY bit may stay high at the end of a data transfer in Slave mode.
-
Update SPI_DMAReceiveCplt() API to handle efficiently the repeated transfers.
-
-
To avoid setting the BaudRatePrescaler in case of Slave Motorola Mode
-
Use the bit-mask for SPI configuration
-
-
Update Transmit/Receive processes in half-duplex mode
-
-
Disable the SPI instance before setting BDIOE bit
-
-
Fix wrong timeout management
-
-
Calculate Timeout based on a software loop to avoid blocking issue if Systick is disabled
-
-
-
HAL/LL TIM driver
-
-
Align HAL/LL TIM driver with latest updates and enhancements
-
Add new macros to enable and disable the fast mode when using the one pulse mode to output a waveform with a minimum delay
-
-
__HAL_TIM_ENABLE_OCxFAST() and __HAL_TIM_DISABLE_OCxFAST().
-
-
Update Encoder interface mode to keep TIM_CCER_CCxNP bits low
-
-
Add TIM_ENCODERINPUTPOLARITY_RISING and TIM_ENCODERINPUTPOLARITY_FALLING definitions to determine encoder input polarity.
-
Add IS_TIM_ENCODERINPUT_POLARITY() macro to check the encoder input polarity.
-
Update HAL_TIM_Encoder_Init() API
-
Replace IS_TIM_IC_POLARITY() macro by IS_TIM_ENCODERINPUT_POLARITY() macro.
-
-
Fix bug when using multiple DMA request to different channels of same timer
-
-
Introduce DMA burst state management mechanism
-
-
Add a new structure for DMA Burst States definition : HAL_TIM_DMABurstStateTypeDef
-
Update __HAL_TIM_RESET_HANDLE_STATE to support DMABurstState
-
Add a new API HAL_TIM_DMABurstState() to get the actual state of a DMA burst operation
-
Add DMABurstState, the DMA burst operation state, in the TIM_HandleTypeDef structure
-
Add new API TIM_DMAErrorCCxN() for TIM DMA error callback (complementary channel)
-
Add new API TIM_DMADelayPulseNCplt() for TIM DMA Delay Pulse complete callback (complementary channel)
-
-
-
Implement TIM channel state management mechanism
-
-
Add new macro
-
-
TIM_CHANNEL_STATE_SET_ALL
-
TIM_CHANNEL_STATE_SET
-
TIM_CHANNEL_STATE_GET
-
-
Add new API HAL_TIM_GetActiveChannel()
-
Add new API HAL_TIM_GetChannelState() to get actual state of the TIM channel
-
Add a new structure for TIM channel States definition : HAL_TIM_ChannelStateTypeDef
-
Update __HAL_TIM_RESET_HANDLE_STATE to support ChannelState
-
Add a new element in the TIM_HandleTypeDef structure : ChannelState to manage TIM channel operation state
-
-
Update HAL_TIMEx_MasterConfigSynchronization() API to avoid functional errors and assert fails when using some TIM instances as input trigger.
-
-
Replace IS_TIM_SYNCHRO_INSTANCE() macro by IS_TIM_MASTER_INSTANCE() macro.
-
Add IS_TIM_SLAVE_INSTANCE() macro to check on TIM_SMCR_MSM bit.
-
-
Remove ‘register’ storage class specifier from LL TIM driver.
-
Add new API HAL_TIM_DMABurst_MultiWriteStart() allowing to configure the DMA Burst to transfer multiple Data from the memory to the TIM peripheral
-
Add new API HAL_TIM_DMABurst_MultiReadStart() allowing to configure the DMA Burst to transfer Data from the TIM peripheral to the memory
-
-
HAL RCC driver
-
-
Fix extra parentheses compilation warnings with clang compiler
-
Update HAL_RCC_GetSysClockFreq() API to avoid the risk of rounding overflow.
-
-
HAL/LL UART driver
-
-
Update UART polling processes to handle efficiently the Lock mechanism
-
-
Move the process unlock at the top of the HAL_UART_Receive() and HAL_UART_Transmit() API.
-
-
Update UART interruption handler to manage correctly the overrun interrupt
-
-
Add in the HAL_UART_IRQHandler() API a check on USART_CR1_RXNEIE bit when an overrun interrupt occurs.
The feature may be enabled individually per HAL PPP driver by setting the corresponding definition USE_HAL_PPP_REGISTER_CALLBACKS to 1U in stm32l1xx_hal_conf.h project configuration file (template file stm32l1xx_hal_conf_template.h available from Drivers/STM32L1xx_HAL_Driver/Inc)
-
Once enabled, the user application may resort to HAL_PPP_RegisterCallback() to register specific callback function(s) and unregister it(them) with HAL_PPP_UnRegisterCallback().
-
Update HAL/LL Driver compliancy with MISRA C 2012 rules
-
stm32l1xx_hal_def.h
-
-
Update file to avoid compiler warnings from __packed definitions
-
Update UNUSED() macro to fix compilation warning with g++ compiler
-
Replace include stdio.h by stddef.h
-
Update __RAM_FUNC define to not impose function type
-
-
-
HAL driver
-
-
Add HAL_GetUIDw0(), HAL_GetUIDw1() and HAL_GetUIDw2() for 96-bit UID
-
Modify default HAL_Delay implementation to guarantee minimum delay
-
Update Doxygen tags in macros description to have generate correct CHM format
-
Update implementation of HAL_SetTickFreq() function
-
-
HAL ADC driver
-
-
Add callback registration feature
-
-
Add HAL_ADC_RegisterCallback() and HAL_ADC_UnRegisterCallback() APIs
-
Add callback identifiers in HAL_ADC_CallbackIDTypeDef enumerated typedef
-
-
Remove unused code in HAL_ADC_Stop_DMA() function.
-
-
HAL/LL COMP driver
-
-
Add callback registration feature
-
-
Add HAL_COMP_RegisterCallback() and HAL_COMP_UnRegisterCallback() APIs
-
Add callback identifiers in HAL_COMP_CallbackIDTypeDef enumerated typedef
-
-
Update define for COMP_NONINVERTINGINPUT_PA6
-
Update define for LL_COMP_INPUT_PLUS_IO11
-
Correct issue with input plus COMP1 in windowmode
-
Add missing LL function for COMP_CSR->VREFOUTEN bit
-
-
HAL CRC driver
-
-
Align HAL/LL CRC driver with latest updates and enhancements
-
Update CRC driver to remove not applicable InputDataFormat
-
-
HAL DAC driver
-
-
Align HAL/LL DAC driver with latest updates and enhancements
-
Add callback registration feature
-
-
Add HAL_DAC_RegisterCallback() and HAL_DAC_UnRegisterCallback() APIs
-
Add callback identifiers in HAL_DAC_CallbackIDTypeDef enumerated typedef
-
-
-
HAL/LL DMA driver
-
-
Align HAL/LL DMA drivers with latest updates and enhancements
-
Add missing APIs to register/unregister DMA callbacks
-
-
HAL FLASH driver
-
-
Update HAL_FLASH_Unlock() and HAL_FLASH_OB_Unlock() in order the functions do not return an error when already unlocked
-
Update HAL_FLASHEx_ProgramParallelHalfPage(), HAL_FLASHEx_HalfPageProgram(), HAL_FLASHEx_DATAEEPROM_EraseDoubleWord(), HAL_FLASHEx_DATAEEPROM_ProgramDoubleWord() so that the functions should not be restricted to privilege mode
-
Update FLASH_OB_GetRDP() function to return the correct RDP level
-
Update FLASH_OB_GetUser() and FLASH_OB_UserConfig() to use the combination of specific masks FLASH_OBR_IWDG_SW, FLASH_OBR_nRST_STOP and FLASH_OBR_nRST_STDBY
-
-
HAL GPIO driver
-
-
Update HAL_GPIO_DeInit() function to perform EXTI configuration reset before GPIO configuration
-
Improve robustness of HAL_GPIO_TogglePin() function
-
Update definition of IS_GPIO_PIN to remove compilation warning with IAR tool chain
-
Update usage description for HAL_GPIO_LockPin() to justify an unused read of a register
-
-
HAL/LL I2C driver
-
-
Align HAL/LL I2C driver with latest updates and enhancements
-
Add callback registration feature
-
-
Add HAL_I2C_RegisterCallback(), HAL_I2C_UnRegisterCallback(), HAL_I2C_RegisterAddrCallback() and HAL_I2C_UnRegisterAddrCallback() APIs
-
Add callback identifiers in HAL_I2C_CallbackIDTypeDef enumerated typedef
-
-
Add I2C_FIRST_AND_NEXT_FRAME for I2C Sequential transfer options: allow to manage a sequence with start condition, address and data to transfer without a final stop condition, an then permit a call to the same master sequential interface several times.
-
Add reset on slave LISTEN_TX state in case of direction change
-
Remove unused variable in HAL_I2C_Slave_Transmit_IT/DMA() and HAL_I2C_Slave_Receive_IT/DMA() functions to avoid warning compilation with linux tool chain
-
Add I2C slave enhancement with the functions: HAL_I2C_Master_Sequential_Transmit_DMA(), HAL_I2C_Master_Sequential_Receive_DMA(), HAL_I2C_Slave_Sequential_Transmit_DMA(), HAL_I2C_Slave_Sequential_Receive_DMA() functions
Optimize WaitOnFlag management in IRDA_Transmit() function
-
Optimize all HAL IRQ Handler routines
-
Optimize HAL IRDA to avoid using macros as argument of function calls
-
-
HAL OPAMP driver
-
-
Align HAL OPAMP driver with latest updates and enhancements
-
Add callback registration feature
-
-
Add HAL_OPAMP_RegisterCallback() and HAL_OPAMP_UnRegisterCallback() APIs
-
Add callback identifiers in HAL_OPAMP_CallbackIDTypeDef enumerated typedef
-
-
-
HAL/LL RCC driver
-
-
Replace __HAL_RCC_CRYP_CLK_ENABLE by __HAL_RCC_AES_CLK_ENABLE
-
Change HAL_RCC_DeInit() to HAL_StatusTypeDef
-
Update HAL_RCC_DeInit() and LL_RCC_DeInit() to also clear interrupts and reset flags
-
Update HAL_RCC_DeInit() and LL_RCC_DeInit() to add check on PLLRDY before clearing PLLCFGR register
-
Update HAL_RCC_DeInit() to insure that default MSI range is set prior to enable MSI and use it as SYSCLK source
-
Update LL_RCC_DeInit() to add the key word volatile and avoid compilation issue with gcc -O3
-
Remove LSI_VALUE definition from stm32l1xx_hal_rcc_ex.h to have it declared in HAL Generic stm32l1xx_hal_conf_template.h/stm32l1xx_hal_conf.h as other families STM32 HAL drivers
-
Correct LSI_VALUE LL definition in stm32l1xx_ll_rcc.h
-
Update HAL_RCC_OscConfig() to avoid MCU hangs after some stop/wakeup cycles
-
Replace all calls to HAL_InitTick(TICK_INT_PRIORITY) with HAL_InitTick(uwTickPrio) to avoid Tick priority overwrite
-
Add new LL_RCC_PLL_SetMainSource macro to set the PLL source without enabling any PLL
-
-
HAL/LL RTC driver
-
-
Align HAL/LL RTC driver with latest updates and enhancements
-
Remove unused value in HAL_RTC_SetTime() function
-
Update implementation of LL_RTC_DATE_Get() function
-
Correct issue in the argument of LL_RTC_ALMB_SetDay() function
-
Add callback registration feature
-
-
Add HAL_RTC_RegisterCallback() and HAL_RTC_UnRegisterCallback() APIs
-
Add callback identifiers in HAL_RTC_CallbackIDTypeDef enumerated typedef
-
-
-
HAL SDMMC driver
-
-
Align HAL SDMMC driver with latest updates and enhancements
-
Due to limitation SDIO hardware flow control indicated in Errata Sheet :
-
-
In 4-bits bus wide mode, do not use the HAL_SD_WriteBlocks_IT() or HAL_SD_WriteBlocks() APIs otherwise underrun will occur and there is not possibility to activate the flow control
-
Use DMA mode when using 4-bits bus wide mode or decrease the frequency
-
-
Add callback registration feature
-
-
Add HAL_SD_RegisterCallback(),HAL_SD_UnRegisterCallback(), HAL_SD_RegisterTransceiverCallback() and HAL_SD_UnRegisterTransceiverCallback APIs
-
Add callback identifiers in HAL_SD_CallbackIDTypeDef enumerated typedef
-
-
-
HAL SMARTCARD driver
-
-
Align HAL SMARTCARD driver with latest updates and enhancements
-
Add callback registration feature
-
-
Add HAL_SMARTCARD_RegisterCallback() and HAL_SMARTCARD_UnRegisterCallback() APIs
-
Add callback identifiers in HAL_SMARTCARD_CallbackIDTypeDef enumerated typedef
-
-
Review SMARTCARD state machine to avoid cases where SMARTCARD state is overwritten by SMARTCARD IRQ
-
Implement new APIs for HAL SMARTCARD Abort management:
-
Add callback identifiers in HAL_PCD_CallbackIDTypeDef enumerated typedef
-
-
-
LL UTILS driver
-
-
Correct LL_GetUID_Word2 function to fix error in UID flash location
-
Fix mismatch return type in LL_GetPackageType(void)
-
-
HAL WWDG driver
-
-
Align HAL WWDG driver with latest updates and enhancements
-
Add callback registration feature
-
-
Add HAL_WWDG_RegisterCallback() and HAL_WWDG_UnRegisterCallback() APIs
-
Add callback identifiers in HAL_WWDG_CallbackIDTypeDef enumerated typedef
-
-
-
-
-
-
-
-
-
Main Changes
-
Patch release
-
Contents
-
-
HAL/LL generic
-
-
Remove DATE and VERSION fields from header files
-
Update CHM User Manual for Drivers/STM32L1xx_HAL_Driver
-
-
-
-
-
-
-
-
Main Changes
-
Maintenance release
-
Contents
-
-
HAL/LL generic
-
-
Enhanced HAL delay and time base implementation:
-
-
Added new templates stm32l1xx_hal_timebase_tim_template.c which can be used to override the native HAL time base functions (defined as weak) and to use Timer as time base tick source.
-
For more details about the usage of these drivers, please refer to HAL_TimeBase_TIM examples and FreeRTOS-based applications.
-
-
Updated HAL Driver compliancy with MISRA C 2004 rules:
-
-
MISRA C 2004 rule 10.3 (illegal explicit conversion from type “unsigned int” to "uint16_t *)
-
MISRA C 2004 rule 10.5 (if the bitwise operators ~ and << are applied to an operand of underlying type ‘unsigned char’ or ‘unsigned short’, the result shall be immediately cast to the underlying type of the operand)
-
MISRA C 2004 rule 11.4 (cast should not be performed between a pointer to object type and a different pointer to object type)
-
MISRA C 2004 rule 12.6 (logical operators should not be confused with bitwise operators)
-
MISRA C 2004 rule 12.7 (bitwise operations not performed on signed integer types)
-
MISRA C 2004 rule 14.3 (a null statement shall only occur on a line by itself)
-
-
Removed (uint32_t) cast when “U” is used in order to avoid double definitions.
-
Replaced hard coded POSITION definition in HAL/LL drivers by the associated PPP_xxx_pos CMSIS define.
-
-
HAL CORTEX
-
-
Updated HAL_MPU_Disable function to clear whole CR register.
-
-
LL DMA
-
-
Improved CPAR and CMAR registers access in LL_DMA_ConfigAddresses function.
-
-
HAL FLASH
-
-
Updated HAL_FLASHEx_Erase_IT() function to check the FLASH is ready before starting Erase by IT.
-
-
HAL/LL GPIO
-
-
Renamed GPIO_AFRL_AFRLx and GPIO_AFRL_AFRHx bit to GPIO_AFRL_AFSELx.
-
-
HAL/LL I2C
-
-
Added LL_I2C_DisableReset() function to allow the disable of SWRST.
-
-
HAL PCD
-
-
Corrected double buffer implementation in PCD_SET_EP_DBUF1_CNT() macro.
-
Added missing USB_CNTR_SOFM in the setting of wInterrupt_Mask global variable used in HAL_PCD_Init.
-
Removed lock/unlock from receive and transmit endpoints.
-
-
HAL/LL PWR
-
-
Replaced HAL_PWREx_GetVoltageRange() function by direct register access to remove dependency with HAL PWR.
-
Renamed the LL_PWR_IsActiveFlag_VOSF() API to LL_PWR_IsActiveFlag_VOS() in order to remove reference to PWR flag name and to refer to the Power feature.
-
-
HAL/LL RTC
-
-
Renamed RTC_CR_BCK bits in RTC_CR register to RTC_CR_BKP, to be aligned with others series.
-
-
HAL/LL SPI
-
-
Removed LL_SPI_SR_UDR define which is available only for I2S feature.
-
Updated LL_SPI_TransmitData16() et LL_SPI_TransmitData8 functions.
-
-
HAL/LL TIM
-
-
Corrected error in LL_TIM_EnableUpdateEvent() and LL_TIM_DisableUpdateEvent() functions.
-
-
-
-
-
-
-
-
Main Changes
-
Maintenance release
-
-
First official release supporting the Low Level drivers for the STM32L1xx family:
-
-
Low Layer drivers APIs provide register level programming: they require deep knowledge of peripherals described in STM32L1xx Reference Manual.
-
Low Layer drivers are available for: ADC, COMP, CORTEX, CRC, DAC, DMA, EXTI, GPIO, I2C, IWDG, OPAMP, PWR, RCC, RTC, SPI, TIM, USART, WWDG peripherals and additional Low Level Bus, System and Utilities APIs.
-
Low Layer drivers APIs are implemented as static inline function in new Inc/stm32l1xx_ll_ppp.h files for PPP peripherals, there is no configuration file and each stm32l1xx_ll_ppp.h file must be included in user code.
-
-
-
Contents
-
-
Generic updates
-
-
Update HAL drivers to apply MISRA C 2004 rule 10.6.
-
uwTick must be global and not static to allow overwrite of HAL_IncTick()
-
-
ADC
-
-
Clear the bit OVR (overrun) in addition to EOC (end of conversion) inside HAL_ADC_Start, HAL_ADC_Start_IT and HAL_ADC_Start_DMA.
-
-
CRC
-
-
HAL_CRC_DeInit() resets CRC_IDR register to reset value.
-
-
DMA
-
-
Add function HAL_StatusTypeDef HAL_DMA_Abort_IT(DMA_HandleTypeDef *hdma).
-
This function aborts the DMA Transfer in Interrupt mode.
-
Add macro __HAL_DMA_GET_COUNTER
-
This macro permits to get the number of remaining data units in the current DMAy Channelx transfer.
-
Global driver code optimization to reduce memory footprint
-
-
FLASH
-
-
Correct MISRA 10.3 Error[Pm069]: if identifiers are given for any of the parameters, then the identifiers used in the declaration and definition shall be identical (MISRA C 2004 rule 16.4).
-
-
GPIO
-
-
IS_GPIO_PIN is more robust.
-
-
I2C
-
-
WaitOnFlag is optimized to effectively last until the expected timeout of a transfer.
-
Optimisation of the IRQHandler.
-
Rework DMA end process and I2C error management during DMA transfer.
-
HAL_I2C_Master_Transmit_DMA now returns an error in case of communication error.
-
Add support for repeated start feature.
-
-
IWDG
-
-
New simplified HAL IWDG driver: remove HAL_IWDG_Start(), HAL_IWDG_MspInit() and HAL_IWDG_GetState() APIs
-
API functions are:
-
HAL_IWDG_Init(): this function insures the configuration and the start of the IWDG counter
-
HAL_IWDG_Refresh(): this function insures the reload of the IWDG counter
-
Refer to the following example to identify the changes: IWDG_Example
-
-
PWR
-
-
Add new interface HAL_FLASHEx_GetError.
-
Add constant FLASH_SIZE.
-
Use suffix U for all the defines.
-
HAL_PWREx_DisableLowPowerRunMode now returns HAL_StatusTypeDef instead of void.
-
SB and ADDR are now managed in interrupt mode, not in polling.
-
Add DMA abort treatment
-
-
RCC
-
-
Rework the correction from V1.1.3:
-
-
Backup domain are no more reseted when RTC clock source is changed from reset value.
-
-
-
RTC
-
-
Updated HAL_RTCEx_SetWakeUpTimer_IT() function by adding clear of Wake-Up flag before enabling the interrupt.
-
-
SPI
-
-
Correct MISRA 5.2 “tmpreg” variable shall not be used inside MACRO.
-
In the SPI_HandleTypeDef structure, RxXferCount and TxXferCount are now __IO.
-
Clear the OVR flag before a new transfer.
-
-
TIMER
-
-
Correct the description of the function HAL_TIM_PWM_Start_IT.
-
-
The parameter Channel mentions the channel to be enabled and not the one to be disabled.
-
-
-
WWDG
-
-
New simplified HAL WWDG driver: remove HAL_WWDG_Start(), HAL_WWDG_Start_IT(), HAL_WWDG_MspDeInit() and HAL_WWDG_GetState() APIs
-
-
Update HAL_WWDG_Refresh() API to remove counter parameter
-
New field EWIMode in WWDG_InitTypeDef to specify need for Early Wakeup Interrupt
-
API functions are: HAL_WWDG_Init(), HAL_WWDG_MspInit(), HAL_WWDG_Refresh(), HAL_WWDG_IRQHandler() and HAL_WWDG_EarlyWakeupCallback()
-
-
-
-
-
-
-
-
-
Main Changes
-
Maintenance release
-
Contents
-
-
Generic update
-
-
Update HAL weak empty callbacks to prevent unused argument compilation warnings with some compilers.
-
Improve the update of the SystemCoreClock variable within the HAL Driver.
-
Split aAPBAHBPrescTable into aAHBPrescTable and aAPBPrescTable.
-
Reduce HSE_STARTUP_TIMEOUT from 5s to 100ms.
-
Reduce MSI_TIMEOUT_VALUE from 100ms to 2ms.
-
Reduce HSI_TIMEOUT_VALUE from 100ms to 2ms.
-
Reduce LSI_TIMEOUT_VALUE from 100ms to 2ms.
-
Reduce PLL_TIMEOUT_VALUE from 100ms to 2ms.
-
-
CORTEX
-
-
__HAL_CORTEX_SYSTICKCLK_CONFIG is now deprecated. Prefer using HAL_SYSTICK_CLKSourceConfig function.
-
-
FLASH
-
-
Correct issue preventing Cat.1 devices to write data in EEPROM.
-
-
I2C
-
-
Add NACK management during wait on flag treatment.
-
Update the state machine.
-
It is now possible to use the I2C transmission with a data size of 0.
-
-
RCC
-
-
Optimize HAL_RCC_ClockConfig.
-
LSEON is reset only if required inside HAL_RCC_OscConfig.
-
RCC HSE pre-scaler reconfiguration for LCD/RTC peripherical is now possible.
-
Backup domain are no more reseted when RTC clock source is changed from reset value.
-
-
SMARTCARD
-
-
Update description of GuardTime and Prescaler fields in SMARTCARD_InitTypeDef structure.
-
-
UART
-
-
HAL_LIN_SendBreak() now use IS_UART_LIN_INSTANCE instead of IS_UART_INSTANCE.
-
Correct the UART_BRR_SAMPLING8 macro in the case of cary handling.
-
-
-
-
-
-
-
-
Main Changes
-
Maintenance release
-
Contents
-
-
ADC
-
-
The ADC internal macro “IS_ADC_RANGE” is modified to take into account the ADC resolution.
-
The function HAL_ADC_PollForEvent, in case of timeout, returns HAL_TIMEOUT instead of HAL_ERROR.
-
HAL_ADC_Init set the ADC handle in state HAL_ADC_ERROR_INTERNAL if the user try to initialize the ADC in DiscontinuousConvMode and ContinuousConvMode simultaneously, which is not possible.
-
Enhance the check for ScanConvMode in HAL_ADC_Init.
-
-
Cortex
-
-
Corrected Misra error (MISRA C 2004 rule 10.5).
-
-
CRC
-
-
Corrected the macro __HAL_CRC_SET_IDR.
-
-
GPIO
-
-
Corrected the macro GPIO_GET_INDEX.
-
To insure the same naming accross all STM32 families (F4, F2, F0, F1, L1 etc):
-
-
Replacing GPIO_SPEED_VERY_LOW by GPIO_SPEED_FREQ_LOW.
-
Replacing GPIO_SPEED_LOW by GPIO_SPEED_FREQ_MEDIUM.
-
Replacing GPIO_SPEED_MEDIUM by GPIO_SPEED_FREQ_HIGH.
-
Replacing GPIO_SPEED_HIGH by GPIO_SPEED_FREQ_VERY_HIGH.
-
-
-
IRDA
-
-
Corrected the HAL_IRDA_IRQHandler which was preventing to handle 2 simultaneous errors.
-
-
I2C
-
-
Corrected an issue where the STOP bit was not cleared after reading data depending on APB/I2C frequency.
-
-
I2S
-
-
HAL_I2S_Transmit() is updated to keep the check on busy flag only for the slave.
-
-
PCD
-
-
Corrected issue when using USB Device double-buffering mode for IN endpoints.
-
do{ … } while(0) is used for multi statement macros.
-
-
PWR
-
-
Corrected Misra error (MISRA C 2004 rule 14.3).
-
-
RCC
-
-
In HAL_RCCEx_PeriphCLKConfig, the reset of the backup domain occurs only if the RTC clock source has been changed.
-
__HAL_RCC_HSE_CONFIG is updated to remove the transition from RCC_HSE_ON to RCC_HSE_BYPASS.
-
Adding the macro __HAL_RCC_MCO1_CONFIG to configure the MCO clock.
-
Adding the macros and function to handle LSE CSS interrupt.
-
Corrected an error in HAL_RCC_GetSysClockFreq when the PLL is used as system clock. An incorrect sysclockfreq was returned.
-
-
RTC
-
-
RTC_TimeTypeDef.SecondFraction field is added to specifies the range or granularity of Sub Second register content.This field will be used only by HAL_RTC_GetTime function.
-
HAL_RTC_GetTime is updated to take into account the new field RTC_TimeTypeDef.SecondFraction.
-
Corrected error in __HAL_RTC_TAMPER_TIMESTAMP_EXTI_GET_FLAG macro.
-
Add additionnal checks on WUTWF flag in HAL_RTCEx_SetWakeUpTimer_IT.
-
do{ … } while(0) is used for multi statement macros.
-
-
USART
-
-
Corrected the HAL_USART_IRQHandler which was preventing to handle 2 simultaneous errors.
-
-
UART
-
-
Removed the activation of ERR IT from HAL_UART_Transmit_IT() which was leading to HAL_UART_IRQ_Handler wrong behavior.
-
Corrected the HAL_UART_IRQHandler which was preventing to handle 2 simultaneous errors.
-
-
SMARTCARD
-
-
Corrected the HAL_SMARTCARD_IRQHandler which was preventing to handle 2 simultaneous errors.
-
-
-
-
-
-
-
-
Main Changes
-
Maintenance release
-
-
Include path changes for compilation under Unix environment
-
Update drivers to be C++ compliant
-
-
Contents
-
-
CORTEX
-
-
Added interface to access MPU features (refer to stm32l1xx_hal_cortex.h)
-
-
CRYP
-
-
Added Instance field in CRYP_HandleTypeDef.
-
-
HAL CRYP driver updated to support multi instance, so user must ensure that the new parameter Instance is initialized in his application (CRYPHandle.Instance = CRYP)
-
-
-
FLASH
-
-
Changing field name of NOR_CFITypeDef (CFI1X changed to CFI1_X)
The field ErrorCode of UART_HandleTypeDef is changed from HAL_UART_ErrorTypeDef to uint32_t.
-
-
USART
-
-
The field ErrorCode of UART_HandleTypeDef is changed from HAL_UART_ErrorTypeDef to uint32_t.
-
-
-
-
-
-
-
-
Main Changes
-
Maintenance release
-
-
Add support of new STM32L1 eXtended devices - STM32l151xDX, STM32l152xDX & STM32l62xDX
-
-
Contents
-
-
HAL generic
-
-
Add eXtended Devices switchs when needed
-
-
STM32L151xDX has same features than STM32L151xE
-
STM32L152xDX has same features than STM32L152xE
-
STM32L162xDX has same features than STM32L162xE
-
-
-
HAL FLASH
-
-
Add support of new STM32L1 Devices (same as other HAL)
-
stm32l1xx_hal_flash_ex.c : Specific treatment done in HAL_FLASHEx_Erase and HAL_FLASHEx_Erase_IT as memory is not continuous between 2 banks, user should perform pages erase by bank only
-
-
-
-
-
-
-
Main Changes
-
First official release
-
-
-
-
-
-
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c
deleted file mode 100644
index 9d0f706e0b8..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal.c
+++ /dev/null
@@ -1,569 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal.c
- * @author MCD Application Team
- * @brief HAL module driver.
- * This is the common part of the HAL initialization
- *
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- The common HAL driver contains a set of generic and common APIs that can be
- used by the PPP peripheral drivers and the user to start using the HAL.
- [..]
- The HAL contains two APIs categories:
- (+) Common HAL APIs
- (+) Services HAL APIs
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup HAL HAL
- * @brief HAL module driver.
- * @{
- */
-
-#ifdef HAL_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-
-/** @defgroup HAL_Private_Defines HAL Private Defines
- * @{
- */
-
-/**
- * @brief STM32L1xx HAL Driver version number V1.4.4
- */
-#define __STM32L1xx_HAL_VERSION_MAIN (0x01) /*!< [31:24] main version */
-#define __STM32L1xx_HAL_VERSION_SUB1 (0x04) /*!< [23:16] sub1 version */
-#define __STM32L1xx_HAL_VERSION_SUB2 (0x04) /*!< [15:8] sub2 version */
-#define __STM32L1xx_HAL_VERSION_RC (0x00) /*!< [7:0] release candidate */
-#define __STM32L1xx_HAL_VERSION ((__STM32L1xx_HAL_VERSION_MAIN << 24)\
- |(__STM32L1xx_HAL_VERSION_SUB1 << 16)\
- |(__STM32L1xx_HAL_VERSION_SUB2 << 8 )\
- |(__STM32L1xx_HAL_VERSION_RC))
-
-#define IDCODE_DEVID_MASK (0x00000FFFU)
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/* Exported variables --------------------------------------------------------*/
-/** @addtogroup HAL_Exported_Variables
- * @{
- */
-__IO uint32_t uwTick;
-uint32_t uwTickPrio = (1UL << __NVIC_PRIO_BITS); /* Invalid priority */
-uint32_t uwTickFreq = HAL_TICK_FREQ_DEFAULT; /* 1KHz */
-/**
- * @}
- */
-
-/* Exported functions --------------------------------------------------------*/
-/** @defgroup HAL_Exported_Functions HAL Exported Functions
- * @{
- */
-
-/** @defgroup HAL_Exported_Functions_Group1 Initialization and de-initialization Functions
- * @brief Initialization and de-initialization functions
- *
-@verbatim
- ===============================================================================
- ##### Initialization and de-initialization functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Initialize the Flash interface, the NVIC allocation and initial clock
- configuration. It initializes the source of time base also when timeout
- is needed and the backup domain when enabled.
- (+) De-initialize common part of the HAL.
- (+) Configure the time base source to have 1ms time base with a dedicated
- Tick interrupt priority.
- (++) SysTick timer is used by default as source of time base, but user
- can eventually implement his proper time base source (a general purpose
- timer for example or other time source), keeping in mind that Time base
- duration should be kept 1ms since PPP_TIMEOUT_VALUEs are defined and
- handled in milliseconds basis.
- (++) Time base configuration function (HAL_InitTick ()) is called automatically
- at the beginning of the program after reset by HAL_Init() or at any time
- when clock is configured, by HAL_RCC_ClockConfig().
- (++) Source of time base is configured to generate interrupts at regular
- time intervals. Care must be taken if HAL_Delay() is called from a
- peripheral ISR process, the Tick interrupt line must have higher priority
- (numerically lower) than the peripheral interrupt. Otherwise the caller
- ISR process will be blocked.
- (++) functions affecting time base configurations are declared as __weak
- to make override possible in case of other implementations in user file.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief This function configures the Flash prefetch,
- * configures time base source, NVIC and Low level hardware
- * @note This function is called at the beginning of program after reset and before
- * the clock configuration
- * @note The time base configuration is based on MSI clock when exiting from Reset.
- * Once done, time base tick start incrementing.
- * In the default implementation,Systick is used as source of time base.
- * the tick variable is incremented each 1ms in its ISR.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_Init(void)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Configure Flash prefetch */
-#if (PREFETCH_ENABLE != 0)
- __HAL_FLASH_PREFETCH_BUFFER_ENABLE();
-#endif /* PREFETCH_ENABLE */
-
- /* Set Interrupt Group Priority */
- HAL_NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4);
-
- /* Use systick as time base source and configure 1ms tick (default clock after Reset is MSI) */
- if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK)
- {
- status = HAL_ERROR;
- }
- else
- {
- /* Init the low level hardware */
- HAL_MspInit();
- }
-
- /* Return function status */
- return status;
-}
-
-/**
- * @brief This function de-initializes common part of the HAL and stops the source
- * of time base.
- * @note This function is optional.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_DeInit(void)
-{
- /* Reset of all peripherals */
- __HAL_RCC_APB1_FORCE_RESET();
- __HAL_RCC_APB1_RELEASE_RESET();
-
- __HAL_RCC_APB2_FORCE_RESET();
- __HAL_RCC_APB2_RELEASE_RESET();
-
- __HAL_RCC_AHB_FORCE_RESET();
- __HAL_RCC_AHB_RELEASE_RESET();
-
- /* De-Init the low level hardware */
- HAL_MspDeInit();
-
- /* Return function status */
- return HAL_OK;
-}
-
-/**
- * @brief Initialize the MSP.
- * @retval None
- */
-__weak void HAL_MspInit(void)
-{
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_MspInit could be implemented in the user file
- */
-}
-
-/**
- * @brief DeInitialize the MSP.
- * @retval None
- */
-__weak void HAL_MspDeInit(void)
-{
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_MspDeInit could be implemented in the user file
- */
-}
-
-/**
- * @brief This function configures the source of the time base:
- * The time source is configured to have 1ms time base with a dedicated
- * Tick interrupt priority.
- * @note This function is called automatically at the beginning of program after
- * reset by HAL_Init() or at any time when clock is reconfigured by HAL_RCC_ClockConfig().
- * @note In the default implementation, SysTick timer is the source of time base.
- * It is used to generate interrupts at regular time intervals.
- * Care must be taken if HAL_Delay() is called from a peripheral ISR process,
- * The SysTick interrupt must have higher priority (numerically lower)
- * than the peripheral interrupt. Otherwise the caller ISR process will be blocked.
- * The function is declared as __weak to be overwritten in case of other
- * implementation in user file.
- * @param TickPriority Tick interrupt priority.
- * @retval HAL status
- */
-__weak HAL_StatusTypeDef HAL_InitTick(uint32_t TickPriority)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (uwTickFreq != 0U)
- {
- /*Configure the SysTick to have interrupt in 1ms time basis*/
- if (HAL_SYSTICK_Config(SystemCoreClock / (1000U / uwTickFreq)) == 0U)
- {
- /* Configure the SysTick IRQ priority */
- if (TickPriority < (1UL << __NVIC_PRIO_BITS))
- {
- HAL_NVIC_SetPriority(SysTick_IRQn, TickPriority, 0U);
- uwTickPrio = TickPriority;
- }
- else
- {
- status = HAL_ERROR;
- }
- }
- else
- {
- status = HAL_ERROR;
- }
- }
- else
- {
- status = HAL_ERROR;
- }
-
- /* Return function status */
- return status;
-}
-
-/**
- * @}
- */
-
-/** @defgroup HAL_Exported_Functions_Group2 HAL Control functions
- * @brief HAL Control functions
- *
-@verbatim
- ===============================================================================
- ##### HAL Control functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Provide a tick value in millisecond
- (+) Provide a blocking delay in millisecond
- (+) Suspend the time base source interrupt
- (+) Resume the time base source interrupt
- (+) Get the HAL API driver version
- (+) Get the device identifier
- (+) Get the device revision identifier
- (+) Get the unique device identifier
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief This function is called to increment a global variable "uwTick"
- * used as application time base.
- * @note In the default implementation, this variable is incremented each 1ms
- * in SysTick ISR.
- * @note This function is declared as __weak to be overwritten in case of other
- * implementations in user file.
- * @retval None
- */
-__weak void HAL_IncTick(void)
-{
- uwTick += uwTickFreq;
-}
-
-/**
- * @brief Provide a tick value in millisecond.
- * @note This function is declared as __weak to be overwritten in case of other
- * implementations in user file.
- * @retval tick value
- */
-__weak uint32_t HAL_GetTick(void)
-{
- return uwTick;
-}
-
-/**
- * @brief This function returns a tick priority.
- * @retval tick priority
- */
-uint32_t HAL_GetTickPrio(void)
-{
- return uwTickPrio;
-}
-
-/**
- * @brief Set new tick Freq.
- * @param Freq tick frequency
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_SetTickFreq(uint32_t Freq)
-{
- HAL_StatusTypeDef status = HAL_OK;
- uint32_t prevTickFreq;
-
- assert_param(IS_TICKFREQ(Freq));
-
- if (uwTickFreq != Freq)
- {
- /* Back up uwTickFreq frequency */
- prevTickFreq = uwTickFreq;
-
- /* Update uwTickFreq global variable used by HAL_InitTick() */
- uwTickFreq = Freq;
-
- /* Apply the new tick Freq */
- status = HAL_InitTick(uwTickPrio);
-
- if (status != HAL_OK)
- {
- /* Restore previous tick frequency */
- uwTickFreq = prevTickFreq;
- }
- }
-
- return status;
-}
-
-/**
- * @brief Return tick frequency.
- * @retval tick period in Hz
- */
-uint32_t HAL_GetTickFreq(void)
-{
- return uwTickFreq;
-}
-
-/**
- * @brief This function provides minimum delay (in milliseconds) based
- * on variable incremented.
- * @note In the default implementation , SysTick timer is the source of time base.
- * It is used to generate interrupts at regular time intervals where uwTick
- * is incremented.
- * @note This function is declared as __weak to be overwritten in case of other
- * implementations in user file.
- * @param Delay specifies the delay time length, in milliseconds.
- * @retval None
- */
-__weak void HAL_Delay(uint32_t Delay)
-{
- uint32_t tickstart = HAL_GetTick();
- uint32_t wait = Delay;
-
- /* Add a period to guaranty minimum wait */
- if (wait < HAL_MAX_DELAY)
- {
- wait += (uint32_t)(uwTickFreq);
- }
-
- while((HAL_GetTick() - tickstart) < wait)
- {
- }
-}
-
-/**
- * @brief Suspend the Tick increment.
- * @note In the default implementation , SysTick timer is the source of time base. It is
- * used to generate interrupts at regular time intervals. Once HAL_SuspendTick()
- * is called, the SysTick interrupt will be disabled and so Tick increment
- * is suspended.
- * @note This function is declared as __weak to be overwritten in case of other
- * implementations in user file.
- * @retval None
- */
-__weak void HAL_SuspendTick(void)
-{
- /* Disable SysTick Interrupt */
- CLEAR_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
-}
-
-/**
- * @brief Resume the Tick increment.
- * @note In the default implementation , SysTick timer is the source of time base. It is
- * used to generate interrupts at regular time intervals. Once HAL_ResumeTick()
- * is called, the SysTick interrupt will be enabled and so Tick increment
- * is resumed.
- * @note This function is declared as __weak to be overwritten in case of other
- * implementations in user file.
- * @retval None
- */
-__weak void HAL_ResumeTick(void)
-{
- /* Enable SysTick Interrupt */
- SET_BIT(SysTick->CTRL,SysTick_CTRL_TICKINT_Msk);
-}
-
-/**
- * @brief Return the HAL revision
- * @retval version: 0xXYZR (8bits for each decimal, R for RC)
- */
-uint32_t HAL_GetHalVersion(void)
-{
- return __STM32L1xx_HAL_VERSION;
-}
-
-/**
- * @brief Return the device revision identifier.
- * @retval Device revision identifier
- */
-uint32_t HAL_GetREVID(void)
-{
- return((DBGMCU->IDCODE) >> 16U);
-}
-
-/**
- * @brief Return the device identifier.
- * @retval Device identifier
- */
-uint32_t HAL_GetDEVID(void)
-{
- return((DBGMCU->IDCODE) & IDCODE_DEVID_MASK);
-}
-
-/**
- * @brief Return the first word of the unique device identifier (UID based on 96 bits)
- * @retval Device identifier 31:0 bits
- */
-uint32_t HAL_GetUIDw0(void)
-{
- return(READ_REG(*((uint32_t *)UID_BASE)));
-}
-
-/**
- * @brief Return the second word of the unique device identifier (UID based on 96 bits)
- * @retval Device identifier 63:32 bits
- */
-uint32_t HAL_GetUIDw1(void)
-{
- return(READ_REG(*((uint32_t *)(UID_BASE + 0x4U))));
-}
-
-/**
- * @brief Return the third word of the unique device identifier (UID based on 96 bits)
- * @retval Device identifier 95:64 bits
- */
-uint32_t HAL_GetUIDw2(void)
-{
- return(READ_REG(*((uint32_t *)(UID_BASE + 0x14U))));
-}
-
-/**
- * @}
- */
-
-/** @defgroup HAL_Exported_Functions_Group3 DBGMCU Peripheral Control functions
- * @brief DBGMCU Peripheral Control functions
- *
-@verbatim
- ===============================================================================
- ##### DBGMCU Peripheral Control functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Enable/Disable Debug module during SLEEP mode
- (+) Enable/Disable Debug module during STOP mode
- (+) Enable/Disable Debug module during STANDBY mode
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Enable the Debug Module during SLEEP mode
- * @retval None
- */
-void HAL_DBGMCU_EnableDBGSleepMode(void)
-{
- SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
-}
-
-/**
- * @brief Disable the Debug Module during SLEEP mode
- * @retval None
- */
-void HAL_DBGMCU_DisableDBGSleepMode(void)
-{
- CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_SLEEP);
-}
-
-/**
- * @brief Enable the Debug Module during STOP mode
- * @retval None
- */
-void HAL_DBGMCU_EnableDBGStopMode(void)
-{
- SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
-}
-
-/**
- * @brief Disable the Debug Module during STOP mode
- * @retval None
- */
-void HAL_DBGMCU_DisableDBGStopMode(void)
-{
- CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STOP);
-}
-
-/**
- * @brief Enable the Debug Module during STANDBY mode
- * @retval None
- */
-void HAL_DBGMCU_EnableDBGStandbyMode(void)
-{
- SET_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
-}
-
-/**
- * @brief Disable the Debug Module during STANDBY mode
- * @retval None
- */
-void HAL_DBGMCU_DisableDBGStandbyMode(void)
-{
- CLEAR_BIT(DBGMCU->CR, DBGMCU_CR_DBG_STANDBY);
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* HAL_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_adc.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_adc.c
deleted file mode 100644
index a1d8ff05455..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_adc.c
+++ /dev/null
@@ -1,2409 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_adc.c
- * @author MCD Application Team
- * @brief This file provides firmware functions to manage the following
- * functionalities of the Analog to Digital Convertor (ADC)
- * peripheral:
- * + Initialization and de-initialization functions
- * ++ Initialization and Configuration of ADC
- * + Operation functions
- * ++ Start, stop, get result of conversions of regular
- * group, using 3 possible modes: polling, interruption or DMA.
- * + Control functions
- * ++ Channels configuration on regular group
- * ++ Channels configuration on injected group
- * ++ Analog Watchdog configuration
- * + State functions
- * ++ ADC state machine management
- * ++ Interrupts and flags management
- * Other functions (extended functions) are available in file
- * "stm32l1xx_hal_adc_ex.c".
- *
- @verbatim
- ==============================================================================
- ##### ADC peripheral features #####
- ==============================================================================
- [..]
- (+) 12-bit, 10-bit, 8-bit or 6-bit configurable resolution
-
- (+) Interrupt generation at the end of regular conversion, end of injected
- conversion, and in case of analog watchdog or overrun events.
-
- (+) Single and continuous conversion modes.
-
- (+) Scan mode for conversion of several channels sequentially.
-
- (+) Data alignment with in-built data coherency.
-
- (+) Programmable sampling time (channel wise)
-
- (+) ADC conversion of regular group and injected group.
-
- (+) External trigger (timer or EXTI) with configurable polarity
- for both regular and injected groups.
-
- (+) DMA request generation for transfer of conversions data of regular group.
-
- (+) ADC offset on injected channels
-
- (+) ADC supply requirements: 2.4 V to 3.6 V at full speed and down to 1.8 V at
- slower speed.
-
- (+) ADC input range: from Vref- (connected to Vssa) to Vref+ (connected to
- Vdda or to an external voltage reference).
-
-
- ##### How to use this driver #####
- ==============================================================================
- [..]
-
- *** Configuration of top level parameters related to ADC ***
- ============================================================
- [..]
-
- (#) Enable the ADC interface
- (++) As prerequisite, ADC clock must be configured at RCC top level.
- Caution: On STM32L1, ADC clock frequency max is 16MHz (refer
- to device datasheet).
- Therefore, ADC clock prescaler must be configured in
- function of ADC clock source frequency to remain below
- this maximum frequency.
-
- (++) Two clock settings are mandatory:
- (+++) ADC clock (core clock).
- (+++) ADC clock (conversions clock).
- Only one possible clock source: derived from HSI RC 16MHz oscillator
- (HSI).
- ADC is connected directly to HSI RC 16MHz oscillator.
- Therefore, RCC PLL setting has no impact on ADC.
- PLL can be disabled (".PLL.PLLState = RCC_PLL_NONE") or
- enabled with HSI16 as clock source
- (".PLL.PLLSource = RCC_PLLSOURCE_HSI") to be used as device
- main clock source SYSCLK.
- The only mandatory setting is ".HSIState = RCC_HSI_ON"
-
- (+++) Example:
- Into HAL_ADC_MspInit() (recommended code location) or with
- other device clock parameters configuration:
- (+++) __HAL_RCC_ADC1_CLK_ENABLE();
-
- (+++) HAL_RCC_GetOscConfig(&RCC_OscInitStructure);
- (+++) RCC_OscInitStructure.OscillatorType = (... | RCC_OSCILLATORTYPE_HSI);
- (+++) RCC_OscInitStructure.HSIState = RCC_HSI_ON;
- (+++) RCC_OscInitStructure.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
- (+++) RCC_OscInitStructure.PLL.PLLState = RCC_PLL_NONE;
- (+++) RCC_OscInitStructure.PLL.PLLSource = ...
- (+++) RCC_OscInitStructure.PLL...
- (+++) HAL_RCC_OscConfig(&RCC_OscInitStructure);
-
- (++) ADC clock prescaler is configured at ADC level with
- parameter "ClockPrescaler" using function HAL_ADC_Init().
-
- (#) ADC pins configuration
- (++) Enable the clock for the ADC GPIOs
- using macro __HAL_RCC_GPIOx_CLK_ENABLE()
- (++) Configure these ADC pins in analog mode
- using function HAL_GPIO_Init()
-
- (#) Optionally, in case of usage of ADC with interruptions:
- (++) Configure the NVIC for ADC
- using function HAL_NVIC_EnableIRQ(ADCx_IRQn)
- (++) Insert the ADC interruption handler function HAL_ADC_IRQHandler()
- into the function of corresponding ADC interruption vector
- ADCx_IRQHandler().
-
- (#) Optionally, in case of usage of DMA:
- (++) Configure the DMA (DMA channel, mode normal or circular, ...)
- using function HAL_DMA_Init().
- (++) Configure the NVIC for DMA
- using function HAL_NVIC_EnableIRQ(DMAx_Channelx_IRQn)
- (++) Insert the ADC interruption handler function HAL_ADC_IRQHandler()
- into the function of corresponding DMA interruption vector
- DMAx_Channelx_IRQHandler().
-
- *** Configuration of ADC, groups regular/injected, channels parameters ***
- ==========================================================================
- [..]
-
- (#) Configure the ADC parameters (resolution, data alignment, ...)
- and regular group parameters (conversion trigger, sequencer, ...)
- using function HAL_ADC_Init().
-
- (#) Configure the channels for regular group parameters (channel number,
- channel rank into sequencer, ..., into regular group)
- using function HAL_ADC_ConfigChannel().
-
- (#) Optionally, configure the injected group parameters (conversion trigger,
- sequencer, ..., of injected group)
- and the channels for injected group parameters (channel number,
- channel rank into sequencer, ..., into injected group)
- using function HAL_ADCEx_InjectedConfigChannel().
-
- (#) Optionally, configure the analog watchdog parameters (channels
- monitored, thresholds, ...)
- using function HAL_ADC_AnalogWDGConfig().
-
- (#) Optionally, for devices with several ADC instances: configure the
- multimode parameters
- using function HAL_ADCEx_MultiModeConfigChannel().
-
- *** Execution of ADC conversions ***
- ====================================
- [..]
-
- (#) ADC driver can be used among three modes: polling, interruption,
- transfer by DMA.
-
- (++) ADC conversion by polling:
- (+++) Activate the ADC peripheral and start conversions
- using function HAL_ADC_Start()
- (+++) Wait for ADC conversion completion
- using function HAL_ADC_PollForConversion()
- (or for injected group: HAL_ADCEx_InjectedPollForConversion() )
- (+++) Retrieve conversion results
- using function HAL_ADC_GetValue()
- (or for injected group: HAL_ADCEx_InjectedGetValue() )
- (+++) Stop conversion and disable the ADC peripheral
- using function HAL_ADC_Stop()
-
- (++) ADC conversion by interruption:
- (+++) Activate the ADC peripheral and start conversions
- using function HAL_ADC_Start_IT()
- (+++) Wait for ADC conversion completion by call of function
- HAL_ADC_ConvCpltCallback()
- (this function must be implemented in user program)
- (or for injected group: HAL_ADCEx_InjectedConvCpltCallback() )
- (+++) Retrieve conversion results
- using function HAL_ADC_GetValue()
- (or for injected group: HAL_ADCEx_InjectedGetValue() )
- (+++) Stop conversion and disable the ADC peripheral
- using function HAL_ADC_Stop_IT()
-
- (++) ADC conversion with transfer by DMA:
- (+++) Activate the ADC peripheral and start conversions
- using function HAL_ADC_Start_DMA()
- (+++) Wait for ADC conversion completion by call of function
- HAL_ADC_ConvCpltCallback() or HAL_ADC_ConvHalfCpltCallback()
- (these functions must be implemented in user program)
- (+++) Conversion results are automatically transferred by DMA into
- destination variable address.
- (+++) Stop conversion and disable the ADC peripheral
- using function HAL_ADC_Stop_DMA()
-
- (++) For devices with several ADCs: ADC multimode conversion
- with transfer by DMA:
- (+++) Activate the ADC peripheral (slave) and start conversions
- using function HAL_ADC_Start()
- (+++) Activate the ADC peripheral (master) and start conversions
- using function HAL_ADCEx_MultiModeStart_DMA()
- (+++) Wait for ADC conversion completion by call of function
- HAL_ADC_ConvCpltCallback() or HAL_ADC_ConvHalfCpltCallback()
- (these functions must be implemented in user program)
- (+++) Conversion results are automatically transferred by DMA into
- destination variable address.
- (+++) Stop conversion and disable the ADC peripheral (master)
- using function HAL_ADCEx_MultiModeStop_DMA()
- (+++) Stop conversion and disable the ADC peripheral (slave)
- using function HAL_ADC_Stop_IT()
-
- [..]
-
- (@) Callback functions must be implemented in user program:
- (+@) HAL_ADC_ErrorCallback()
- (+@) HAL_ADC_LevelOutOfWindowCallback() (callback of analog watchdog)
- (+@) HAL_ADC_ConvCpltCallback()
- (+@) HAL_ADC_ConvHalfCpltCallback
- (+@) HAL_ADCEx_InjectedConvCpltCallback()
-
- *** Deinitialization of ADC ***
- ============================================================
- [..]
-
- (#) Disable the ADC interface
- (++) ADC clock can be hard reset and disabled at RCC top level.
- (++) Hard reset of ADC peripherals
- using macro __ADCx_FORCE_RESET(), __ADCx_RELEASE_RESET().
- (++) ADC clock disable
- using the equivalent macro/functions as configuration step.
- (+++) Example:
- Into HAL_ADC_MspDeInit() (recommended code location) or with
- other device clock parameters configuration:
- (+++) HAL_RCC_GetOscConfig(&RCC_OscInitStructure);
- (+++) RCC_OscInitStructure.OscillatorType = RCC_OSCILLATORTYPE_HSI;
- (+++) RCC_OscInitStructure.HSIState = RCC_HSI_OFF; (if not used for system clock)
- (+++) HAL_RCC_OscConfig(&RCC_OscInitStructure);
-
- (#) ADC pins configuration
- (++) Disable the clock for the ADC GPIOs
- using macro __HAL_RCC_GPIOx_CLK_DISABLE()
-
- (#) Optionally, in case of usage of ADC with interruptions:
- (++) Disable the NVIC for ADC
- using function HAL_NVIC_EnableIRQ(ADCx_IRQn)
-
- (#) Optionally, in case of usage of DMA:
- (++) Deinitialize the DMA
- using function HAL_DMA_Init().
- (++) Disable the NVIC for DMA
- using function HAL_NVIC_EnableIRQ(DMAx_Channelx_IRQn)
-
- [..]
-
- *** Callback registration ***
- =============================================
- [..]
-
- The compilation flag USE_HAL_ADC_REGISTER_CALLBACKS, when set to 1,
- allows the user to configure dynamically the driver callbacks.
- Use Functions @ref HAL_ADC_RegisterCallback()
- to register an interrupt callback.
- [..]
-
- Function @ref HAL_ADC_RegisterCallback() allows to register following callbacks:
- (+) ConvCpltCallback : ADC conversion complete callback
- (+) ConvHalfCpltCallback : ADC conversion DMA half-transfer callback
- (+) LevelOutOfWindowCallback : ADC analog watchdog 1 callback
- (+) ErrorCallback : ADC error callback
- (+) InjectedConvCpltCallback : ADC group injected conversion complete callback
- (+) MspInitCallback : ADC Msp Init callback
- (+) MspDeInitCallback : ADC Msp DeInit callback
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
- [..]
-
- Use function @ref HAL_ADC_UnRegisterCallback to reset a callback to the default
- weak function.
- [..]
-
- @ref HAL_ADC_UnRegisterCallback takes as parameters the HAL peripheral handle,
- and the Callback ID.
- This function allows to reset following callbacks:
- (+) ConvCpltCallback : ADC conversion complete callback
- (+) ConvHalfCpltCallback : ADC conversion DMA half-transfer callback
- (+) LevelOutOfWindowCallback : ADC analog watchdog 1 callback
- (+) ErrorCallback : ADC error callback
- (+) InjectedConvCpltCallback : ADC group injected conversion complete callback
- (+) MspInitCallback : ADC Msp Init callback
- (+) MspDeInitCallback : ADC Msp DeInit callback
- [..]
-
- By default, after the @ref HAL_ADC_Init() and when the state is @ref HAL_ADC_STATE_RESET
- all callbacks are set to the corresponding weak functions:
- examples @ref HAL_ADC_ConvCpltCallback(), @ref HAL_ADC_ErrorCallback().
- Exception done for MspInit and MspDeInit functions that are
- reset to the legacy weak functions in the @ref HAL_ADC_Init()/ @ref HAL_ADC_DeInit() only when
- these callbacks are null (not registered beforehand).
- [..]
-
- If MspInit or MspDeInit are not null, the @ref HAL_ADC_Init()/ @ref HAL_ADC_DeInit()
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state.
- [..]
-
- Callbacks can be registered/unregistered in @ref HAL_ADC_STATE_READY state only.
- Exception done MspInit/MspDeInit functions that can be registered/unregistered
- in @ref HAL_ADC_STATE_READY or @ref HAL_ADC_STATE_RESET state,
- thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
- [..]
-
- Then, the user first registers the MspInit/MspDeInit user callbacks
- using @ref HAL_ADC_RegisterCallback() before calling @ref HAL_ADC_DeInit()
- or @ref HAL_ADC_Init() function.
- [..]
-
- When the compilation flag USE_HAL_ADC_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registration feature is not available and all callbacks
- are set to the corresponding weak functions.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup ADCEx ADCEx
- * @brief ADC Extension HAL module driver
- * @{
- */
-
-#ifdef HAL_ADC_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/** @defgroup ADCEx_Private_Constants ADCEx Private Constants
- * @{
- */
-
- /* ADC conversion cycles (unit: ADC clock cycles) */
- /* (selected sampling time + conversion time of 12 ADC clock cycles, with */
- /* resolution 12 bits) */
- #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_4CYCLE5 ( 16U)
- #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_9CYCLES ( 21U)
- #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_16CYCLES ( 28U)
- #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_24CYCLES ( 36U)
- #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_48CYCLES ( 60U)
- #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_96CYCLES (108U)
- #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_192CYCLES (204U)
- #define ADC_CONVERSIONCLOCKCYCLES_SAMPLETIME_384CYCLES (396U)
-
- /* Delay for temperature sensor stabilization time. */
- /* Maximum delay is 10us (refer to device datasheet, parameter tSTART). */
- /* Unit: us */
- #define ADC_TEMPSENSOR_DELAY_US (10U)
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup ADCEx_Exported_Functions ADCEx Exported Functions
- * @{
- */
-
-/** @defgroup ADCEx_Exported_Functions_Group1 ADC Extended IO operation functions
- * @brief ADC Extended Input and Output operation functions
- *
-@verbatim
- ===============================================================================
- ##### IO operation functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Start conversion of injected group.
- (+) Stop conversion of injected group.
- (+) Poll for conversion complete on injected group.
- (+) Get result of injected channel conversion.
- (+) Start conversion of injected group and enable interruptions.
- (+) Stop conversion of injected group and disable interruptions.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Enables ADC, starts conversion of injected group.
- * Interruptions enabled in this function: None.
- * @param hadc ADC handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ADCEx_InjectedStart(ADC_HandleTypeDef* hadc)
-{
- HAL_StatusTypeDef tmp_hal_status = HAL_OK;
-
- /* Check the parameters */
- assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
-
- /* Process locked */
- __HAL_LOCK(hadc);
-
- /* Enable the ADC peripheral */
- tmp_hal_status = ADC_Enable(hadc);
-
- /* Start conversion if ADC is effectively enabled */
- if (tmp_hal_status == HAL_OK)
- {
- /* Set ADC state */
- /* - Clear state bitfield related to injected group conversion results */
- /* - Set state bitfield related to injected operation */
- ADC_STATE_CLR_SET(hadc->State,
- HAL_ADC_STATE_READY | HAL_ADC_STATE_INJ_EOC,
- HAL_ADC_STATE_INJ_BUSY);
-
- /* Check if a regular conversion is ongoing */
- /* Note: On this device, there is no ADC error code fields related to */
- /* conversions on group injected only. In case of conversion on */
- /* going on group regular, no error code is reset. */
- if (HAL_IS_BIT_CLR(hadc->State, HAL_ADC_STATE_REG_BUSY))
- {
- /* Reset ADC all error code fields */
- ADC_CLEAR_ERRORCODE(hadc);
- }
-
- /* Process unlocked */
- /* Unlock before starting ADC conversions: in case of potential */
- /* interruption, to let the process to ADC IRQ Handler. */
- __HAL_UNLOCK(hadc);
-
- /* Clear injected group conversion flag */
- /* (To ensure of no unknown state from potential previous ADC operations) */
- __HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_JEOC);
-
- /* Enable conversion of injected group. */
- /* If software start has been selected, conversion starts immediately. */
- /* If external trigger has been selected, conversion will start at next */
- /* trigger event. */
- /* If automatic injected conversion is enabled, conversion will start */
- /* after next regular group conversion. */
- if (ADC_IS_SOFTWARE_START_INJECTED(hadc) &&
- HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO) )
- {
- /* Enable ADC software conversion for injected channels */
- SET_BIT(hadc->Instance->CR2, ADC_CR2_JSWSTART);
- }
- }
-
- /* Return function status */
- return tmp_hal_status;
-}
-
-/**
- * @brief Stop conversion of injected channels. Disable ADC peripheral if
- * no regular conversion is on going.
- * @note If ADC must be disabled and if conversion is on going on
- * regular group, function HAL_ADC_Stop must be used to stop both
- * injected and regular groups, and disable the ADC.
- * @note If injected group mode auto-injection is enabled,
- * function HAL_ADC_Stop must be used.
- * @note In case of auto-injection mode, HAL_ADC_Stop must be used.
- * @param hadc ADC handle
- * @retval None
- */
-HAL_StatusTypeDef HAL_ADCEx_InjectedStop(ADC_HandleTypeDef* hadc)
-{
- HAL_StatusTypeDef tmp_hal_status = HAL_OK;
-
- /* Check the parameters */
- assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
-
- /* Process locked */
- __HAL_LOCK(hadc);
-
- /* Stop potential conversion and disable ADC peripheral */
- /* Conditioned to: */
- /* - No conversion on the other group (regular group) is intended to */
- /* continue (injected and regular groups stop conversion and ADC disable */
- /* are common) */
- /* - In case of auto-injection mode, HAL_ADC_Stop must be used. */
- if(((hadc->State & HAL_ADC_STATE_REG_BUSY) == RESET) &&
- HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO) )
- {
- /* Stop potential conversion on going, on regular and injected groups */
- /* Disable ADC peripheral */
- tmp_hal_status = ADC_ConversionStop_Disable(hadc);
-
- /* Check if ADC is effectively disabled */
- if (tmp_hal_status == HAL_OK)
- {
- /* Set ADC state */
- ADC_STATE_CLR_SET(hadc->State,
- HAL_ADC_STATE_REG_BUSY | HAL_ADC_STATE_INJ_BUSY,
- HAL_ADC_STATE_READY);
- }
- }
- else
- {
- /* Update ADC state machine to error */
- SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
-
- tmp_hal_status = HAL_ERROR;
- }
-
- /* Process unlocked */
- __HAL_UNLOCK(hadc);
-
- /* Return function status */
- return tmp_hal_status;
-}
-
-/**
- * @brief Wait for injected group conversion to be completed.
- * @param hadc ADC handle
- * @param Timeout Timeout value in millisecond.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_ADCEx_InjectedPollForConversion(ADC_HandleTypeDef* hadc, uint32_t Timeout)
-{
- uint32_t tickstart;
-
- /* Variables for polling in case of scan mode enabled and polling for each */
- /* conversion. */
- /* Note: Variable "conversion_timeout_cpu_cycles" set to offset 28 CPU */
- /* cycles to compensate number of CPU cycles for processing of variable */
- /* "conversion_timeout_cpu_cycles_max" */
- uint32_t conversion_timeout_cpu_cycles = 28;
- uint32_t conversion_timeout_cpu_cycles_max = 0;
-
- /* Check the parameters */
- assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
-
- /* Get timeout */
- tickstart = HAL_GetTick();
-
- /* Polling for end of conversion: differentiation if single/sequence */
- /* conversion. */
- /* For injected group, flag JEOC is set only at the end of the sequence, */
- /* not for each conversion within the sequence. */
- /* If setting "EOCSelection" is set to poll for each single conversion, */
- /* management of polling depends on setting of injected group sequencer: */
- /* - If single conversion for injected group (scan mode disabled or */
- /* InjectedNbrOfConversion ==1), flag JEOC is used to determine the */
- /* conversion completion. */
- /* - If sequence conversion for injected group (scan mode enabled and */
- /* InjectedNbrOfConversion >=2), flag JEOC is set only at the end of the */
- /* sequence. */
- /* To poll for each conversion, the maximum conversion time is computed */
- /* from ADC conversion time (selected sampling time + conversion time of */
- /* 12 ADC clock cycles) and APB2/ADC clock prescalers (depending on */
- /* settings, conversion time range can vary from 8 to several thousands */
- /* of CPU cycles). */
-
- /* Note: On STM32L1, setting "EOCSelection" is related to regular group */
- /* only, by hardware. For compatibility with other STM32 devices, */
- /* this setting is related also to injected group by software. */
- if (((hadc->Instance->JSQR & ADC_JSQR_JL) == RESET) ||
- (hadc->Init.EOCSelection != ADC_EOC_SINGLE_CONV) )
- {
- /* Wait until End of Conversion flag is raised */
- while(HAL_IS_BIT_CLR(hadc->Instance->SR, ADC_FLAG_JEOC))
- {
- /* Check if timeout is disabled (set to infinite wait) */
- if(Timeout != HAL_MAX_DELAY)
- {
- if((Timeout == 0) || ((HAL_GetTick() - tickstart ) > Timeout))
- {
- /* New check to avoid false timeout detection in case of preemption */
- if(HAL_IS_BIT_CLR(hadc->Instance->SR, ADC_FLAG_JEOC))
- {
- /* Update ADC state machine to timeout */
- SET_BIT(hadc->State, HAL_ADC_STATE_TIMEOUT);
-
- /* Process unlocked */
- __HAL_UNLOCK(hadc);
-
- return HAL_TIMEOUT;
- }
- }
- }
- }
- }
- else
- {
- /* Computation of CPU cycles corresponding to ADC conversion cycles. */
- /* Retrieve ADC clock prescaler and ADC maximum conversion cycles on all */
- /* channels. */
- conversion_timeout_cpu_cycles_max = ADC_GET_CLOCK_PRESCALER_DECIMAL(hadc);
- conversion_timeout_cpu_cycles_max *= ADC_CONVCYCLES_MAX_RANGE(hadc);
-
- /* Poll with maximum conversion time */
- while(conversion_timeout_cpu_cycles < conversion_timeout_cpu_cycles_max)
- {
- /* Check if timeout is disabled (set to infinite wait) */
- if(Timeout != HAL_MAX_DELAY)
- {
- if((Timeout == 0) || ((HAL_GetTick() - tickstart ) > Timeout))
- {
- /* New check to avoid false timeout detection in case of preemption */
- if(conversion_timeout_cpu_cycles < conversion_timeout_cpu_cycles_max)
- {
- /* Update ADC state machine to timeout */
- SET_BIT(hadc->State, HAL_ADC_STATE_TIMEOUT);
-
- /* Process unlocked */
- __HAL_UNLOCK(hadc);
-
- return HAL_TIMEOUT;
- }
- }
- }
- conversion_timeout_cpu_cycles ++;
- }
- }
-
- /* Clear end of conversion flag of injected group if low power feature */
- /* "Auto Wait" is disabled, to not interfere with this feature until data */
- /* register is read using function HAL_ADCEx_InjectedGetValue(). */
- if (hadc->Init.LowPowerAutoWait == DISABLE)
- {
- /* Clear injected group conversion flag */
- __HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_JSTRT | ADC_FLAG_JEOC);
- }
-
- /* Update ADC state machine */
- SET_BIT(hadc->State, HAL_ADC_STATE_INJ_EOC);
-
- /* Determine whether any further conversion upcoming on group injected */
- /* by external trigger, continuous mode or scan sequence on going. */
- /* Note: On STM32L1, there is no independent flag of end of sequence. */
- /* The test of scan sequence on going is done either with scan */
- /* sequence disabled or with end of conversion flag set to */
- /* of end of sequence. */
- if(ADC_IS_SOFTWARE_START_INJECTED(hadc) &&
- (HAL_IS_BIT_CLR(hadc->Instance->JSQR, ADC_JSQR_JL) ||
- HAL_IS_BIT_CLR(hadc->Instance->CR2, ADC_CR2_EOCS) ) &&
- (HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO) &&
- (ADC_IS_SOFTWARE_START_REGULAR(hadc) &&
- (hadc->Init.ContinuousConvMode == DISABLE) ) ) )
- {
- /* Set ADC state */
- CLEAR_BIT(hadc->State, HAL_ADC_STATE_INJ_BUSY);
-
- if (HAL_IS_BIT_CLR(hadc->State, HAL_ADC_STATE_REG_BUSY))
- {
- SET_BIT(hadc->State, HAL_ADC_STATE_READY);
- }
- }
-
- /* Return ADC state */
- return HAL_OK;
-}
-
-/**
- * @brief Enables ADC, starts conversion of injected group with interruption.
- * - JEOC (end of conversion of injected group)
- * Each of these interruptions has its dedicated callback function.
- * @param hadc ADC handle
- * @retval HAL status.
- */
-HAL_StatusTypeDef HAL_ADCEx_InjectedStart_IT(ADC_HandleTypeDef* hadc)
-{
- HAL_StatusTypeDef tmp_hal_status = HAL_OK;
-
- /* Check the parameters */
- assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
-
- /* Process locked */
- __HAL_LOCK(hadc);
-
- /* Enable the ADC peripheral */
- tmp_hal_status = ADC_Enable(hadc);
-
- /* Start conversion if ADC is effectively enabled */
- if (tmp_hal_status == HAL_OK)
- {
- /* Set ADC state */
- /* - Clear state bitfield related to injected group conversion results */
- /* - Set state bitfield related to injected operation */
- ADC_STATE_CLR_SET(hadc->State,
- HAL_ADC_STATE_READY | HAL_ADC_STATE_INJ_EOC,
- HAL_ADC_STATE_INJ_BUSY);
-
- /* Check if a regular conversion is ongoing */
- /* Note: On this device, there is no ADC error code fields related to */
- /* conversions on group injected only. In case of conversion on */
- /* going on group regular, no error code is reset. */
- if (HAL_IS_BIT_CLR(hadc->State, HAL_ADC_STATE_REG_BUSY))
- {
- /* Reset ADC all error code fields */
- ADC_CLEAR_ERRORCODE(hadc);
- }
-
- /* Process unlocked */
- /* Unlock before starting ADC conversions: in case of potential */
- /* interruption, to let the process to ADC IRQ Handler. */
- __HAL_UNLOCK(hadc);
-
- /* Clear injected group conversion flag */
- /* (To ensure of no unknown state from potential previous ADC operations) */
- __HAL_ADC_CLEAR_FLAG(hadc, ADC_FLAG_JEOC);
-
- /* Enable end of conversion interrupt for injected channels */
- __HAL_ADC_ENABLE_IT(hadc, ADC_IT_JEOC);
-
- /* Enable conversion of injected group. */
- /* If software start has been selected, conversion starts immediately. */
- /* If external trigger has been selected, conversion will start at next */
- /* trigger event. */
- /* If automatic injected conversion is enabled, conversion will start */
- /* after next regular group conversion. */
- if (ADC_IS_SOFTWARE_START_INJECTED(hadc) &&
- HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO) )
- {
- /* Enable ADC software conversion for injected channels */
- SET_BIT(hadc->Instance->CR2, ADC_CR2_JSWSTART);
- }
- }
-
- /* Return function status */
- return tmp_hal_status;
-}
-
-/**
- * @brief Stop conversion of injected channels, disable interruption of
- * end-of-conversion. Disable ADC peripheral if no regular conversion
- * is on going.
- * @note If ADC must be disabled and if conversion is on going on
- * regular group, function HAL_ADC_Stop must be used to stop both
- * injected and regular groups, and disable the ADC.
- * @note If injected group mode auto-injection is enabled,
- * function HAL_ADC_Stop must be used.
- * @param hadc ADC handle
- * @retval None
- */
-HAL_StatusTypeDef HAL_ADCEx_InjectedStop_IT(ADC_HandleTypeDef* hadc)
-{
- HAL_StatusTypeDef tmp_hal_status = HAL_OK;
-
- /* Check the parameters */
- assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
-
- /* Process locked */
- __HAL_LOCK(hadc);
-
- /* Stop potential conversion and disable ADC peripheral */
- /* Conditioned to: */
- /* - No conversion on the other group (regular group) is intended to */
- /* continue (injected and regular groups stop conversion and ADC disable */
- /* are common) */
- /* - In case of auto-injection mode, HAL_ADC_Stop must be used. */
- if(((hadc->State & HAL_ADC_STATE_REG_BUSY) == RESET) &&
- HAL_IS_BIT_CLR(hadc->Instance->CR1, ADC_CR1_JAUTO) )
- {
- /* Stop potential conversion on going, on regular and injected groups */
- /* Disable ADC peripheral */
- tmp_hal_status = ADC_ConversionStop_Disable(hadc);
-
- /* Check if ADC is effectively disabled */
- if (tmp_hal_status == HAL_OK)
- {
- /* Disable ADC end of conversion interrupt for injected channels */
- __HAL_ADC_DISABLE_IT(hadc, ADC_IT_JEOC);
-
- /* Set ADC state */
- ADC_STATE_CLR_SET(hadc->State,
- HAL_ADC_STATE_REG_BUSY | HAL_ADC_STATE_INJ_BUSY,
- HAL_ADC_STATE_READY);
- }
- }
- else
- {
- /* Update ADC state machine to error */
- SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
-
- tmp_hal_status = HAL_ERROR;
- }
-
- /* Process unlocked */
- __HAL_UNLOCK(hadc);
-
- /* Return function status */
- return tmp_hal_status;
-}
-
-/**
- * @brief Get ADC injected group conversion result.
- * @note Reading register JDRx automatically clears ADC flag JEOC
- * (ADC group injected end of unitary conversion).
- * @note This function does not clear ADC flag JEOS
- * (ADC group injected end of sequence conversion)
- * Occurrence of flag JEOS rising:
- * - If sequencer is composed of 1 rank, flag JEOS is equivalent
- * to flag JEOC.
- * - If sequencer is composed of several ranks, during the scan
- * sequence flag JEOC only is raised, at the end of the scan sequence
- * both flags JEOC and EOS are raised.
- * Flag JEOS must not be cleared by this function because
- * it would not be compliant with low power features
- * (feature low power auto-wait, not available on all STM32 families).
- * To clear this flag, either use function:
- * in programming model IT: @ref HAL_ADC_IRQHandler(), in programming
- * model polling: @ref HAL_ADCEx_InjectedPollForConversion()
- * or @ref __HAL_ADC_CLEAR_FLAG(&hadc, ADC_FLAG_JEOS).
- * @param hadc ADC handle
- * @param InjectedRank the converted ADC injected rank.
- * This parameter can be one of the following values:
- * @arg ADC_INJECTED_RANK_1: Injected Channel1 selected
- * @arg ADC_INJECTED_RANK_2: Injected Channel2 selected
- * @arg ADC_INJECTED_RANK_3: Injected Channel3 selected
- * @arg ADC_INJECTED_RANK_4: Injected Channel4 selected
- * @retval ADC group injected conversion data
- */
-uint32_t HAL_ADCEx_InjectedGetValue(ADC_HandleTypeDef* hadc, uint32_t InjectedRank)
-{
- uint32_t tmp_jdr = 0;
-
- /* Check the parameters */
- assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
- assert_param(IS_ADC_INJECTED_RANK(InjectedRank));
-
- /* Get ADC converted value */
- switch(InjectedRank)
- {
- case ADC_INJECTED_RANK_4:
- tmp_jdr = hadc->Instance->JDR4;
- break;
- case ADC_INJECTED_RANK_3:
- tmp_jdr = hadc->Instance->JDR3;
- break;
- case ADC_INJECTED_RANK_2:
- tmp_jdr = hadc->Instance->JDR2;
- break;
- case ADC_INJECTED_RANK_1:
- default:
- tmp_jdr = hadc->Instance->JDR1;
- break;
- }
-
- /* Return ADC converted value */
- return tmp_jdr;
-}
-
-/**
- * @brief Injected conversion complete callback in non blocking mode
- * @param hadc ADC handle
- * @retval None
- */
-__weak void HAL_ADCEx_InjectedConvCpltCallback(ADC_HandleTypeDef* hadc)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hadc);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_ADCEx_InjectedConvCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @}
- */
-
-/** @defgroup ADCEx_Exported_Functions_Group2 ADC Extended Peripheral Control functions
- * @brief ADC Extended Peripheral Control functions
- *
-@verbatim
- ===============================================================================
- ##### Peripheral Control functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Configure channels on injected group
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Configures the ADC injected group and the selected channel to be
- * linked to the injected group.
- * @note Possibility to update parameters on the fly:
- * This function initializes injected group, following calls to this
- * function can be used to reconfigure some parameters of structure
- * "ADC_InjectionConfTypeDef" on the fly, without reseting the ADC.
- * The setting of these parameters is conditioned to ADC state:
- * this function must be called when ADC is not under conversion.
- * @param hadc ADC handle
- * @param sConfigInjected Structure of ADC injected group and ADC channel for
- * injected group.
- * @retval None
- */
-HAL_StatusTypeDef HAL_ADCEx_InjectedConfigChannel(ADC_HandleTypeDef* hadc, ADC_InjectionConfTypeDef* sConfigInjected)
-{
- HAL_StatusTypeDef tmp_hal_status = HAL_OK;
- __IO uint32_t wait_loop_index = 0;
-
- /* Check the parameters */
- assert_param(IS_ADC_ALL_INSTANCE(hadc->Instance));
- assert_param(IS_ADC_CHANNEL(sConfigInjected->InjectedChannel));
- assert_param(IS_ADC_SAMPLE_TIME(sConfigInjected->InjectedSamplingTime));
- assert_param(IS_FUNCTIONAL_STATE(sConfigInjected->AutoInjectedConv));
- assert_param(IS_ADC_EXTTRIGINJEC(sConfigInjected->ExternalTrigInjecConv));
- assert_param(IS_ADC_RANGE(ADC_RESOLUTION_12B, sConfigInjected->InjectedOffset));
-
- if(hadc->Init.ScanConvMode != ADC_SCAN_DISABLE)
- {
- assert_param(IS_ADC_INJECTED_RANK(sConfigInjected->InjectedRank));
- assert_param(IS_ADC_INJECTED_NB_CONV(sConfigInjected->InjectedNbrOfConversion));
- assert_param(IS_FUNCTIONAL_STATE(sConfigInjected->InjectedDiscontinuousConvMode));
- }
-
- if(sConfigInjected->ExternalTrigInjecConv != ADC_INJECTED_SOFTWARE_START)
- {
- assert_param(IS_ADC_EXTTRIGINJEC_EDGE(sConfigInjected->ExternalTrigInjecConvEdge));
- }
-
- /* Process locked */
- __HAL_LOCK(hadc);
-
- /* Configuration of injected group sequencer: */
- /* - if scan mode is disabled, injected channels sequence length is set to */
- /* 0x00: 1 channel converted (channel on regular rank 1) */
- /* Parameter "InjectedNbrOfConversion" is discarded. */
- /* Note: Scan mode is present by hardware on this device and, if */
- /* disabled, discards automatically nb of conversions. Anyway, nb of */
- /* conversions is forced to 0x00 for alignment over all STM32 devices. */
- /* - if scan mode is enabled, injected channels sequence length is set to */
- /* parameter ""InjectedNbrOfConversion". */
- if (hadc->Init.ScanConvMode == ADC_SCAN_DISABLE)
- {
- if (sConfigInjected->InjectedRank == ADC_INJECTED_RANK_1)
- {
- /* Clear the old SQx bits for all injected ranks */
- MODIFY_REG(hadc->Instance->JSQR ,
- ADC_JSQR_JL |
- ADC_JSQR_JSQ4 |
- ADC_JSQR_JSQ3 |
- ADC_JSQR_JSQ2 |
- ADC_JSQR_JSQ1 ,
- ADC_JSQR_RK_JL(sConfigInjected->InjectedChannel,
- ADC_INJECTED_RANK_1,
- 0x01) );
- }
- /* If another injected rank than rank1 was intended to be set, and could */
- /* not due to ScanConvMode disabled, error is reported. */
- else
- {
- /* Update ADC state machine to error */
- SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
-
- tmp_hal_status = HAL_ERROR;
- }
- }
- else
- {
- /* Since injected channels rank conv. order depends on total number of */
- /* injected conversions, selected rank must be below or equal to total */
- /* number of injected conversions to be updated. */
- if (sConfigInjected->InjectedRank <= sConfigInjected->InjectedNbrOfConversion)
- {
- /* Clear the old SQx bits for the selected rank */
- /* Set the SQx bits for the selected rank */
- MODIFY_REG(hadc->Instance->JSQR ,
-
- ADC_JSQR_JL |
- ADC_JSQR_RK_JL(ADC_JSQR_JSQ1,
- sConfigInjected->InjectedRank,
- sConfigInjected->InjectedNbrOfConversion) ,
-
- ADC_JSQR_JL_SHIFT(sConfigInjected->InjectedNbrOfConversion) |
- ADC_JSQR_RK_JL(sConfigInjected->InjectedChannel,
- sConfigInjected->InjectedRank,
- sConfigInjected->InjectedNbrOfConversion) );
- }
- else
- {
- /* Clear the old SQx bits for the selected rank */
- MODIFY_REG(hadc->Instance->JSQR ,
-
- ADC_JSQR_JL |
- ADC_JSQR_RK_JL(ADC_JSQR_JSQ1,
- sConfigInjected->InjectedRank,
- sConfigInjected->InjectedNbrOfConversion) ,
-
- 0x00000000 );
- }
- }
-
- /* Enable external trigger if trigger selection is different of software */
- /* start. */
- /* Note: This configuration keeps the hardware feature of parameter */
- /* ExternalTrigConvEdge "trigger edge none" equivalent to */
- /* software start. */
-
- if (sConfigInjected->ExternalTrigInjecConv != ADC_INJECTED_SOFTWARE_START)
- {
- MODIFY_REG(hadc->Instance->CR2 ,
- ADC_CR2_JEXTEN |
- ADC_CR2_JEXTSEL ,
- sConfigInjected->ExternalTrigInjecConv |
- sConfigInjected->ExternalTrigInjecConvEdge );
- }
- else
- {
- MODIFY_REG(hadc->Instance->CR2,
- ADC_CR2_JEXTEN |
- ADC_CR2_JEXTSEL ,
- 0x00000000 );
- }
-
- /* Configuration of injected group */
- /* Parameters update conditioned to ADC state: */
- /* Parameters that can be updated only when ADC is disabled: */
- /* - Automatic injected conversion */
- /* - Injected discontinuous mode */
- if ((ADC_IS_ENABLE(hadc) == RESET))
- {
- hadc->Instance->CR1 &= ~(ADC_CR1_JAUTO |
- ADC_CR1_JDISCEN );
-
- /* Automatic injected conversion can be enabled if injected group */
- /* external triggers are disabled. */
- if (sConfigInjected->AutoInjectedConv == ENABLE)
- {
- if (sConfigInjected->ExternalTrigInjecConv == ADC_INJECTED_SOFTWARE_START)
- {
- SET_BIT(hadc->Instance->CR1, ADC_CR1_JAUTO);
- }
- else
- {
- /* Update ADC state machine to error */
- SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
-
- tmp_hal_status = HAL_ERROR;
- }
- }
-
- /* Injected discontinuous can be enabled only if auto-injected mode is */
- /* disabled. */
- if (sConfigInjected->InjectedDiscontinuousConvMode == ENABLE)
- {
- if (sConfigInjected->AutoInjectedConv == DISABLE)
- {
- SET_BIT(hadc->Instance->CR1, ADC_CR1_JDISCEN);
- }
- else
- {
- /* Update ADC state machine to error */
- SET_BIT(hadc->State, HAL_ADC_STATE_ERROR_CONFIG);
-
- tmp_hal_status = HAL_ERROR;
- }
- }
- }
-
- /* Channel sampling time configuration */
- /* For InjectedChannels 0 to 9 */
- if (sConfigInjected->InjectedChannel < ADC_CHANNEL_10)
- {
- MODIFY_REG(hadc->Instance->SMPR3,
- ADC_SMPR3(ADC_SMPR3_SMP0, sConfigInjected->InjectedChannel),
- ADC_SMPR3(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel) );
- }
- /* For InjectedChannels 10 to 19 */
- else if (sConfigInjected->InjectedChannel < ADC_CHANNEL_20)
- {
- MODIFY_REG(hadc->Instance->SMPR2,
- ADC_SMPR2(ADC_SMPR2_SMP10, sConfigInjected->InjectedChannel),
- ADC_SMPR2(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel) );
- }
- /* For InjectedChannels 20 to 26 for devices Cat.1, Cat.2, Cat.3 */
- /* For InjectedChannels 20 to 29 for devices Cat4, Cat.5 */
- else if (sConfigInjected->InjectedChannel <= ADC_SMPR1_CHANNEL_MAX)
- {
- MODIFY_REG(hadc->Instance->SMPR1,
- ADC_SMPR1(ADC_SMPR1_SMP20, sConfigInjected->InjectedChannel),
- ADC_SMPR1(sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel) );
- }
- /* For InjectedChannels 30 to 31 for devices Cat4, Cat.5 */
- else
- {
- ADC_SMPR0_CHANNEL_SET(hadc, sConfigInjected->InjectedSamplingTime, sConfigInjected->InjectedChannel);
- }
-
-
- /* Configure the offset: offset enable/disable, InjectedChannel, offset value */
- switch(sConfigInjected->InjectedRank)
- {
- case 1:
- /* Set injected channel 1 offset */
- MODIFY_REG(hadc->Instance->JOFR1,
- ADC_JOFR1_JOFFSET1,
- sConfigInjected->InjectedOffset);
- break;
- case 2:
- /* Set injected channel 2 offset */
- MODIFY_REG(hadc->Instance->JOFR2,
- ADC_JOFR2_JOFFSET2,
- sConfigInjected->InjectedOffset);
- break;
- case 3:
- /* Set injected channel 3 offset */
- MODIFY_REG(hadc->Instance->JOFR3,
- ADC_JOFR3_JOFFSET3,
- sConfigInjected->InjectedOffset);
- break;
- case 4:
- default:
- MODIFY_REG(hadc->Instance->JOFR4,
- ADC_JOFR4_JOFFSET4,
- sConfigInjected->InjectedOffset);
- break;
- }
-
- /* If ADC1 Channel_16 or Channel_17 is selected, enable Temperature sensor */
- /* and VREFINT measurement path. */
- if ((sConfigInjected->InjectedChannel == ADC_CHANNEL_TEMPSENSOR) ||
- (sConfigInjected->InjectedChannel == ADC_CHANNEL_VREFINT) )
- {
- SET_BIT(ADC->CCR, ADC_CCR_TSVREFE);
-
- if ((sConfigInjected->InjectedChannel == ADC_CHANNEL_TEMPSENSOR))
- {
- /* Delay for temperature sensor stabilization time */
- /* Compute number of CPU cycles to wait for */
- wait_loop_index = (ADC_TEMPSENSOR_DELAY_US * (SystemCoreClock / 1000000));
- while(wait_loop_index != 0)
- {
- wait_loop_index--;
- }
- }
- }
-
- /* Process unlocked */
- __HAL_UNLOCK(hadc);
-
- /* Return function status */
- return tmp_hal_status;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* HAL_ADC_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_comp.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_comp.c
deleted file mode 100644
index d85ed54b8f7..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_comp.c
+++ /dev/null
@@ -1,1080 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_comp.c
- * @author MCD Application Team
- * @brief COMP HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the COMP peripheral:
- * + Initialization and de-initialization functions
- * + I/O operation functions
- * + Peripheral Control functions
- * + Peripheral State functions
- *
- @verbatim
-================================================================================
- ##### COMP Peripheral features #####
-================================================================================
- [..]
- The STM32L1xx device family integrates 2 analog comparators COMP1 and
- COMP2:
- (#) The non inverting input and inverting input can be set to GPIO pins.
- HAL COMP driver configures the Routing Interface (RI) to connect the
- selected I/O pins to comparator input.
- Caution: Comparator COMP1 and ADC cannot be used at the same time as
- ADC since they share the ADC switch matrix: COMP1 non-inverting
- input is routed through ADC switch matrix. Except if ADC is intended
- to measure voltage on COMP1 non-inverting input: it can be performed
- on ADC channel VCOMP.
-
- (#) The COMP output is available using HAL_COMP_GetOutputLevel().
-
- (#) The COMP output can be redirected to embedded timers (TIM2, TIM3,
- TIM4, TIM10).
- COMP output cannot be redirected to any I/O pin.
-
- (#) The comparators COMP1 and COMP2 can be combined in window mode.
- In this mode, COMP2 non inverting input is used as common
- non-inverting input.
-
- (#) The 2 comparators have interrupt capability with wake-up
- from Sleep and Stop modes (through the EXTI controller):
- (++) COMP1 is internally connected to EXTI Line 21
- (++) COMP2 is internally connected to EXTI Line 22
-
- From the corresponding IRQ handler, the right interrupt source can be retrieved with the
- macros __HAL_COMP_COMP1_EXTI_GET_FLAG() and __HAL_COMP_COMP2_EXTI_GET_FLAG().
-
- (#) The comparators also offer the possibility to output the voltage
- reference (VrefInt), used on inverting inputs, on I/O pin through
- a buffer. To use it, refer to macro "__HAL_SYSCFG_VREFINT_OUT_ENABLE()".
-
- ##### How to use this driver #####
-================================================================================
- [..]
- This driver provides functions to configure and program the Comparators of all STM32L1xx devices.
-
- To use the comparator, perform the following steps:
-
- (#) Initialize the COMP low level resources by implementing the HAL_COMP_MspInit().
- (++) Configure the comparator input I/O pin using HAL_GPIO_Init():
- - For all inputs: I/O pin in analog mode (Schmitt trigger disabled)
- - Possible alternate configuration, for non-inverting inputs of comparator 2: I/O pin in floating mode (Schmitt trigger enabled).
- It is recommended to use analog configuration to avoid any overconsumption around VDD/2.
- (++) Enable COMP Peripheral clock using macro __HAL_RCC_COMP_CLK_ENABLE()
- (++) If required enable the COMP interrupt (EXTI line Interrupt): enable
- the comparator interrupt vector using HAL_NVIC_EnableIRQ(COMP_IRQn)
- and HAL_NVIC_SetPriority(COMP_IRQn, xxx, xxx) functions.
-
- (#) Configure the comparator using HAL_COMP_Init() function:
- (++) Select the inverting input (COMP2 only)
- (++) Select the non-inverting input
- (++) Select the output redirection to timers (COMP2 only)
- (++) Select the speed mode (COMP2 only)
- (++) Select the window mode (related to COMP1 and COMP2, but selected
- by COMP2 only)
- (++) Select the pull-up/down resistors on non-inverting input (COMP1 only)
-
- (#) Enable the comparator using HAL_COMP_Start() or HAL_COMP_Start_IT()
- function
-
- (#) If needed, use HAL_COMP_GetOutputLevel() or HAL_COMP_TriggerCallback()
- functions to manage comparator actions (output level or events)
-
- (#) Disable the comparator using HAL_COMP_Stop() or HAL_COMP_Stop_IT()
- function
-
- (#) De-initialize the comparator using HAL_COMP_DeInit() function
-
- *** Callback registration ***
- =============================================
- [..]
-
- The compilation flag USE_HAL_COMP_REGISTER_CALLBACKS, when set to 1,
- allows the user to configure dynamically the driver callbacks.
- Use Functions @ref HAL_COMP_RegisterCallback()
- to register an interrupt callback.
- [..]
-
- Function @ref HAL_COMP_RegisterCallback() allows to register following callbacks:
- (+) TriggerCallback : callback for COMP trigger.
- (+) MspInitCallback : callback for Msp Init.
- (+) MspDeInitCallback : callback for Msp DeInit.
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
- [..]
-
- Use function @ref HAL_COMP_UnRegisterCallback to reset a callback to the default
- weak function.
- [..]
-
- @ref HAL_COMP_UnRegisterCallback takes as parameters the HAL peripheral handle,
- and the Callback ID.
- This function allows to reset following callbacks:
- (+) TriggerCallback : callback for COMP trigger.
- (+) MspInitCallback : callback for Msp Init.
- (+) MspDeInitCallback : callback for Msp DeInit.
- [..]
-
- By default, after the @ref HAL_COMP_Init() and when the state is @ref HAL_COMP_STATE_RESET
- all callbacks are set to the corresponding weak functions:
- example @ref HAL_COMP_TriggerCallback().
- Exception done for MspInit and MspDeInit functions that are
- reset to the legacy weak functions in the @ref HAL_COMP_Init()/ @ref HAL_COMP_DeInit() only when
- these callbacks are null (not registered beforehand).
- [..]
-
- If MspInit or MspDeInit are not null, the @ref HAL_COMP_Init()/ @ref HAL_COMP_DeInit()
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state.
- [..]
-
- Callbacks can be registered/unregistered in @ref HAL_COMP_STATE_READY state only.
- Exception done MspInit/MspDeInit functions that can be registered/unregistered
- in @ref HAL_COMP_STATE_READY or @ref HAL_COMP_STATE_RESET state,
- thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
- [..]
-
- Then, the user first registers the MspInit/MspDeInit user callbacks
- using @ref HAL_COMP_RegisterCallback() before calling @ref HAL_COMP_DeInit()
- or @ref HAL_COMP_Init() function.
- [..]
-
- When the compilation flag USE_HAL_COMP_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registration feature is not available and all callbacks
- are set to the corresponding weak functions.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup CRC CRC
- * @brief CRC HAL module driver.
- * @{
- */
-
-#ifdef HAL_CRC_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-
-/* Exported functions --------------------------------------------------------*/
-
-/** @defgroup CRC_Exported_Functions CRC Exported Functions
- * @{
- */
-
-/** @defgroup CRC_Exported_Functions_Group1 Initialization and de-initialization functions
- * @brief Initialization and Configuration functions.
- *
-@verbatim
- ===============================================================================
- ##### Initialization and de-initialization functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Initialize the CRC according to the specified parameters
- in the CRC_InitTypeDef and create the associated handle
- (+) DeInitialize the CRC peripheral
- (+) Initialize the CRC MSP (MCU Specific Package)
- (+) DeInitialize the CRC MSP
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initialize the CRC according to the specified
- * parameters in the CRC_InitTypeDef and create the associated handle.
- * @param hcrc CRC handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_CRC_Init(CRC_HandleTypeDef *hcrc)
-{
- /* Check the CRC handle allocation */
- if (hcrc == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
-
- if (hcrc->State == HAL_CRC_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- hcrc->Lock = HAL_UNLOCKED;
- /* Init the low level hardware */
- HAL_CRC_MspInit(hcrc);
- }
-
- /* Change CRC peripheral state */
- hcrc->State = HAL_CRC_STATE_READY;
-
- /* Return function status */
- return HAL_OK;
-}
-
-/**
- * @brief DeInitialize the CRC peripheral.
- * @param hcrc CRC handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_CRC_DeInit(CRC_HandleTypeDef *hcrc)
-{
- /* Check the CRC handle allocation */
- if (hcrc == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_CRC_ALL_INSTANCE(hcrc->Instance));
-
- /* Check the CRC peripheral state */
- if (hcrc->State == HAL_CRC_STATE_BUSY)
- {
- return HAL_BUSY;
- }
-
- /* Change CRC peripheral state */
- hcrc->State = HAL_CRC_STATE_BUSY;
-
- /* Reset CRC calculation unit */
- __HAL_CRC_DR_RESET(hcrc);
-
- /* Reset IDR register content */
- CLEAR_BIT(hcrc->Instance->IDR, CRC_IDR_IDR);
-
- /* DeInit the low level hardware */
- HAL_CRC_MspDeInit(hcrc);
-
- /* Change CRC peripheral state */
- hcrc->State = HAL_CRC_STATE_RESET;
-
- /* Process unlocked */
- __HAL_UNLOCK(hcrc);
-
- /* Return function status */
- return HAL_OK;
-}
-
-/**
- * @brief Initializes the CRC MSP.
- * @param hcrc CRC handle
- * @retval None
- */
-__weak void HAL_CRC_MspInit(CRC_HandleTypeDef *hcrc)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hcrc);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_CRC_MspInit can be implemented in the user file
- */
-}
-
-/**
- * @brief DeInitialize the CRC MSP.
- * @param hcrc CRC handle
- * @retval None
- */
-__weak void HAL_CRC_MspDeInit(CRC_HandleTypeDef *hcrc)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hcrc);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_CRC_MspDeInit can be implemented in the user file
- */
-}
-
-/**
- * @}
- */
-
-/** @defgroup CRC_Exported_Functions_Group2 Peripheral Control functions
- * @brief management functions.
- *
-@verbatim
- ===============================================================================
- ##### Peripheral Control functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) compute the 32-bit CRC value of a 32-bit data buffer
- using combination of the previous CRC value and the new one.
-
- [..] or
-
- (+) compute the 32-bit CRC value of a 32-bit data buffer
- independently of the previous CRC value.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Compute the 32-bit CRC value of a 32-bit data buffer
- * starting with the previously computed CRC as initialization value.
- * @param hcrc CRC handle
- * @param pBuffer pointer to the input data buffer.
- * @param BufferLength input data buffer length (number of uint32_t words).
- * @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits)
- */
-uint32_t HAL_CRC_Accumulate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
-{
- uint32_t index; /* CRC input data buffer index */
- uint32_t temp = 0U; /* CRC output (read from hcrc->Instance->DR register) */
-
- /* Change CRC peripheral state */
- hcrc->State = HAL_CRC_STATE_BUSY;
-
- /* Enter Data to the CRC calculator */
- for (index = 0U; index < BufferLength; index++)
- {
- hcrc->Instance->DR = pBuffer[index];
- }
- temp = hcrc->Instance->DR;
-
- /* Change CRC peripheral state */
- hcrc->State = HAL_CRC_STATE_READY;
-
- /* Return the CRC computed value */
- return temp;
-}
-
-/**
- * @brief Compute the 32-bit CRC value of a 32-bit data buffer
- * starting with hcrc->Instance->INIT as initialization value.
- * @param hcrc CRC handle
- * @param pBuffer pointer to the input data buffer.
- * @param BufferLength input data buffer length (number of uint32_t words).
- * @retval uint32_t CRC (returned value LSBs for CRC shorter than 32 bits)
- */
-uint32_t HAL_CRC_Calculate(CRC_HandleTypeDef *hcrc, uint32_t pBuffer[], uint32_t BufferLength)
-{
- uint32_t index; /* CRC input data buffer index */
- uint32_t temp = 0U; /* CRC output (read from hcrc->Instance->DR register) */
-
- /* Change CRC peripheral state */
- hcrc->State = HAL_CRC_STATE_BUSY;
-
- /* Reset CRC Calculation Unit (hcrc->Instance->INIT is
- * written in hcrc->Instance->DR) */
- __HAL_CRC_DR_RESET(hcrc);
-
- /* Enter 32-bit input data to the CRC calculator */
- for (index = 0U; index < BufferLength; index++)
- {
- hcrc->Instance->DR = pBuffer[index];
- }
- temp = hcrc->Instance->DR;
-
- /* Change CRC peripheral state */
- hcrc->State = HAL_CRC_STATE_READY;
-
- /* Return the CRC computed value */
- return temp;
-}
-
-/**
- * @}
- */
-
-/** @defgroup CRC_Exported_Functions_Group3 Peripheral State functions
- * @brief Peripheral State functions.
- *
-@verbatim
- ===============================================================================
- ##### Peripheral State functions #####
- ===============================================================================
- [..]
- This subsection permits to get in run-time the status of the peripheral.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Return the CRC handle state.
- * @param hcrc CRC handle
- * @retval HAL state
- */
-HAL_CRC_StateTypeDef HAL_CRC_GetState(CRC_HandleTypeDef *hcrc)
-{
- /* Return CRC handle state */
- return hcrc->State;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-
-#endif /* HAL_CRC_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_cryp.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_cryp.c
deleted file mode 100644
index 04f13d0f4e3..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_cryp.c
+++ /dev/null
@@ -1,2163 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_cryp.c
- * @author MCD Application Team
- * @brief CRYP HAL module driver.
- *
- * This file provides firmware functions to manage the following
- * functionalities of the Cryptography (CRYP) peripheral:
- * + Initialization and de-initialization functions
- * + Processing functions by algorithm using polling mode
- * + Processing functions by algorithm using interrupt mode
- * + Processing functions by algorithm using DMA mode
- * + Peripheral State functions
- *
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- The CRYP HAL driver can be used as follows:
-
- (#)Initialize the CRYP low level resources by implementing the HAL_CRYP_MspInit():
- (##) Enable the CRYP interface clock using __HAL_RCC_CRYP_CLK_ENABLE()
- (##) In case of using interrupts (e.g. HAL_CRYP_AESECB_Encrypt_IT())
- (+) Configure the CRYP interrupt priority using HAL_NVIC_SetPriority()
- (+) Enable the CRYP IRQ handler using HAL_NVIC_EnableIRQ()
- (+) In CRYP IRQ handler, call HAL_CRYP_IRQHandler()
- (##) In case of using DMA to control data transfer (e.g. HAL_CRYP_AESECB_Encrypt_DMA())
- (+) Enable the DMA2 interface clock using
- (++) __HAL_RCC_DMA2_CLK_ENABLE()
- (+) Configure and enable two DMA Channels one for managing data transfer from
- memory to peripheral (input channel) and another channel for managing data
- transfer from peripheral to memory (output channel)
- (+) Associate the initialized DMA handle to the CRYP DMA handle
- using __HAL_LINKDMA()
- (+) Configure the priority and enable the NVIC for the transfer complete
- interrupt on the two DMA Streams. The output stream should have higher
- priority than the input stream.
- (++) HAL_NVIC_SetPriority()
- (++) HAL_NVIC_EnableIRQ()
-
- (#)Initialize the CRYP HAL using HAL_CRYP_Init(). This function configures mainly:
- (##) The data type: 1-bit, 8-bit, 16-bit and 32-bit
- (##) The encryption/decryption key.
- (##) The initialization vector (counter). It is not used ECB mode.
-
- (#)Three processing (encryption/decryption) functions are available:
- (##) Polling mode: encryption and decryption APIs are blocking functions
- i.e. they process the data and wait till the processing is finished
- e.g. HAL_CRYP_AESCBC_Encrypt()
- (##) Interrupt mode: encryption and decryption APIs are not blocking functions
- i.e. they process the data under interrupt
- e.g. HAL_CRYP_AESCBC_Encrypt_IT()
- (##) DMA mode: encryption and decryption APIs are not blocking functions
- i.e. the data transfer is ensured by DMA
- e.g. HAL_CRYP_AESCBC_Encrypt_DMA()
-
- (#)When the processing function is called for the first time after HAL_CRYP_Init()
- the CRYP peripheral is initialized and processes the buffer in input.
- At second call, the processing function performs an append of the already
- processed buffer.
- When a new data block is to be processed, call HAL_CRYP_Init() then the
- processing function.
-
- (#)Call HAL_CRYP_DeInit() to deinitialize the CRYP peripheral.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-#ifdef HAL_CRYP_MODULE_ENABLED
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup CRYPEx CRYPEx
- * @brief CRYP HAL Extended module driver.
- * @{
- */
-
-#if defined(STM32L162xC) || defined(STM32L162xCA) || defined(STM32L162xD) || defined(STM32L162xE) || defined(STM32L162xDX)
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup CRYPEx_Exported_Functions CRYPEx Exported Functions
- * @{
- */
-
-
-/** @defgroup CRYPEx_Exported_Functions_Group1 Extended features functions
- * @brief Extended features functions.
- *
-@verbatim
- ===============================================================================
- ##### Extended features functions #####
- ===============================================================================
- [..] This section provides callback functions:
- (+) Computation completed.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Computation completed callbacks.
- * @param hcryp pointer to a CRYP_HandleTypeDef structure that contains
- * the configuration information for CRYP module
- * @retval None
- */
-__weak void HAL_CRYPEx_ComputationCpltCallback(CRYP_HandleTypeDef *hcryp)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hcryp);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_CRYPEx_ComputationCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @}
- */
-
-
-/**
- * @}
- */
-
-#endif /* STM32L162xC || STM32L162xCA || STM32L162xD || STM32L162xE || STM32L162xDX*/
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* HAL_CRYP_MODULE_ENABLED */
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dac.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dac.c
deleted file mode 100644
index 103793e6667..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dac.c
+++ /dev/null
@@ -1,1353 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_dac.c
- * @author MCD Application Team
- * @brief DAC HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Digital to Analog Converter (DAC) peripheral:
- * + Initialization and de-initialization functions
- * + IO operation functions
- * + Peripheral Control functions
- * + Peripheral State and Errors functions
- *
- *
- @verbatim
- ==============================================================================
- ##### DAC Peripheral features #####
- ==============================================================================
- [..]
- *** DAC Channels ***
- ====================
- [..]
- STM32L1 devices integrate two 12-bit Digital Analog Converters
-
- The 2 converters (i.e. channel1 & channel2)
- can be used independently or simultaneously (dual mode):
- (#) DAC channel1 with DAC_OUT1 (PA4) as output or connected to on-chip
- peripherals (ex. timers).
- (#) DAC channel2 with DAC_OUT2 (PA5) as output or connected to on-chip
- peripherals (ex. timers).
-
- *** DAC Triggers ***
- ====================
- [..]
- Digital to Analog conversion can be non-triggered using DAC_TRIGGER_NONE
- and DAC_OUT1/DAC_OUT2 is available once writing to DHRx register.
- [..]
- Digital to Analog conversion can be triggered by:
- (#) External event: EXTI Line 9 (any GPIOx_PIN_9) using DAC_TRIGGER_EXT_IT9.
- The used pin (GPIOx_PIN_9) must be configured in input mode.
-
- (#) Timers TRGO: TIM2, TIM4, TIM6, TIM7, TIM9
- (DAC_TRIGGER_T2_TRGO, DAC_TRIGGER_T4_TRGO...)
-
- (#) Software using DAC_TRIGGER_SOFTWARE
-
- *** DAC Buffer mode feature ***
- ===============================
- [..]
- Each DAC channel integrates an output buffer that can be used to
- reduce the output impedance, and to drive external loads directly
- without having to add an external operational amplifier.
- To enable, the output buffer use
- sConfig.DAC_OutputBuffer = DAC_OUTPUTBUFFER_ENABLE;
- [..]
- (@) Refer to the device datasheet for more details about output
- impedance value with and without output buffer.
-
- *** GPIO configurations guidelines ***
- =====================
- [..]
- When a DAC channel is used (ex channel1 on PA4) and the other is not
- (ex channel2 on PA5 is configured in Analog and disabled).
- Channel1 may disturb channel2 as coupling effect.
- Note that there is no coupling on channel2 as soon as channel2 is turned on.
- Coupling on adjacent channel could be avoided as follows:
- when unused PA5 is configured as INPUT PULL-UP or DOWN.
- PA5 is configured in ANALOG just before it is turned on.
-
- *** DAC wave generation feature ***
- ===================================
- [..]
- Both DAC channels can be used to generate
- (#) Noise wave
- (#) Triangle wave
-
- *** DAC data format ***
- =======================
- [..]
- The DAC data format can be:
- (#) 8-bit right alignment using DAC_ALIGN_8B_R
- (#) 12-bit left alignment using DAC_ALIGN_12B_L
- (#) 12-bit right alignment using DAC_ALIGN_12B_R
-
- *** DAC data value to voltage correspondence ***
- ================================================
- [..]
- The analog output voltage on each DAC channel pin is determined
- by the following equation:
- [..]
- DAC_OUTx = VREF+ * DOR / 4095
- (+) with DOR is the Data Output Register
- [..]
- VREF+ is the input voltage reference (refer to the device datasheet)
- [..]
- e.g. To set DAC_OUT1 to 0.7V, use
- (+) Assuming that VREF+ = 3.3V, DAC_OUT1 = (3.3 * 868) / 4095 = 0.7V
-
- *** DMA requests ***
- =====================
- [..]
- A DMA request can be generated when an external trigger (but not a software trigger)
- occurs if DMA1 requests are enabled using HAL_DAC_Start_DMA().
- DMA1 requests are mapped as following:
- (#) DAC channel1 mapped on (no request on STM32L1XX) / DMA1 channel2
- (#) DAC channel2 mapped on (no request on STM32L1XX) / DMA1 channel3
-
- [..]
- (@) For Dual mode and specific signal (Triangle and noise) generation please
- refer to Extended Features Driver description
-
- ##### How to use this driver #####
- ==============================================================================
- [..]
- (+) DAC APB clock must be enabled to get write access to DAC
- registers using HAL_DAC_Init()
- (+) Configure DAC_OUTx (DAC_OUT1: PA4, DAC_OUT2: PA5) in analog mode.
- (+) Configure the DAC channel using HAL_DAC_ConfigChannel() function.
- (+) Enable the DAC channel using HAL_DAC_Start() or HAL_DAC_Start_DMA() functions.
-
-
- *** Polling mode IO operation ***
- =================================
- [..]
- (+) Start the DAC peripheral using HAL_DAC_Start()
- (+) To read the DAC last data output value, use the HAL_DAC_GetValue() function.
- (+) Stop the DAC peripheral using HAL_DAC_Stop()
-
- *** DMA mode IO operation ***
- ==============================
- [..]
- (+) Start the DAC peripheral using HAL_DAC_Start_DMA(), at this stage the user specify the length
- of data to be transferred at each end of conversion
- First issued trigger will start the conversion of the value previously set by HAL_DAC_SetValue().
- (+) At the middle of data transfer HAL_DAC_ConvHalfCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
- function is executed and user can add his own code by customization of function pointer
- HAL_DAC_ConvHalfCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
- (+) At The end of data transfer HAL_DAC_ConvCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
- function is executed and user can add his own code by customization of function pointer
- HAL_DAC_ConvCpltCallbackCh1() or HAL_DACEx_ConvHalfCpltCallbackCh2()
- (+) In case of transfer Error, HAL_DAC_ErrorCallbackCh1() function is executed and user can
- add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1
- (+) In case of DMA underrun, DAC interruption triggers and execute internal function HAL_DAC_IRQHandler.
- HAL_DAC_DMAUnderrunCallbackCh1() or HAL_DACEx_DMAUnderrunCallbackCh2()
- function is executed and user can add his own code by customization of function pointer
- HAL_DAC_DMAUnderrunCallbackCh1() or HAL_DACEx_DMAUnderrunCallbackCh2() and
- add his own code by customization of function pointer HAL_DAC_ErrorCallbackCh1()
- (+) Stop the DAC peripheral using HAL_DAC_Stop_DMA()
-
- *** Callback registration ***
- =============================================
- [..]
- The compilation define USE_HAL_DAC_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
-
- Use Functions @ref HAL_DAC_RegisterCallback() to register a user callback,
- it allows to register following callbacks:
- (+) ConvCpltCallbackCh1 : callback when a half transfer is completed on Ch1.
- (+) ConvHalfCpltCallbackCh1 : callback when a transfer is completed on Ch1.
- (+) ErrorCallbackCh1 : callback when an error occurs on Ch1.
- (+) DMAUnderrunCallbackCh1 : callback when an underrun error occurs on Ch1.
- (+) ConvCpltCallbackCh2 : callback when a half transfer is completed on Ch2.
- (+) ConvHalfCpltCallbackCh2 : callback when a transfer is completed on Ch2.
- (+) ErrorCallbackCh2 : callback when an error occurs on Ch2.
- (+) DMAUnderrunCallbackCh2 : callback when an underrun error occurs on Ch2.
- (+) MspInitCallback : DAC MspInit.
- (+) MspDeInitCallback : DAC MspdeInit.
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
-
- Use function @ref HAL_DAC_UnRegisterCallback() to reset a callback to the default
- weak (surcharged) function. It allows to reset following callbacks:
- (+) ConvCpltCallbackCh1 : callback when a half transfer is completed on Ch1.
- (+) ConvHalfCpltCallbackCh1 : callback when a transfer is completed on Ch1.
- (+) ErrorCallbackCh1 : callback when an error occurs on Ch1.
- (+) DMAUnderrunCallbackCh1 : callback when an underrun error occurs on Ch1.
- (+) ConvCpltCallbackCh2 : callback when a half transfer is completed on Ch2.
- (+) ConvHalfCpltCallbackCh2 : callback when a transfer is completed on Ch2.
- (+) ErrorCallbackCh2 : callback when an error occurs on Ch2.
- (+) DMAUnderrunCallbackCh2 : callback when an underrun error occurs on Ch2.
- (+) MspInitCallback : DAC MspInit.
- (+) MspDeInitCallback : DAC MspdeInit.
- (+) All Callbacks
- This function) takes as parameters the HAL peripheral handle and the Callback ID.
-
- By default, after the @ref HAL_DAC_Init and if the state is HAL_DAC_STATE_RESET
- all callbacks are reset to the corresponding legacy weak (surcharged) functions.
- Exception done for MspInit and MspDeInit callbacks that are respectively
- reset to the legacy weak (surcharged) functions in the @ref HAL_DAC_Init
- and @ref HAL_DAC_DeInit only when these callbacks are null (not registered beforehand).
- If not, MspInit or MspDeInit are not null, the @ref HAL_DAC_Init and @ref HAL_DAC_DeInit
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
-
- Callbacks can be registered/unregistered in READY state only.
- Exception done for MspInit/MspDeInit callbacks that can be registered/unregistered
- in READY or RESET state, thus registered (user) MspInit/DeInit callbacks can be used
- during the Init/DeInit.
- In that case first register the MspInit/MspDeInit user callbacks
- using @ref HAL_DAC_RegisterCallback before calling @ref HAL_DAC_DeInit
- or @ref HAL_DAC_Init function.
-
- When The compilation define USE_HAL_DAC_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registering feature is not available
- and weak (surcharged) callbacks are used.
-
- *** DAC HAL driver macros list ***
- =============================================
- [..]
- Below the list of most used macros in DAC HAL driver.
-
- (+) __HAL_DAC_ENABLE : Enable the DAC peripheral
- (+) __HAL_DAC_DISABLE : Disable the DAC peripheral
- (+) __HAL_DAC_CLEAR_FLAG: Clear the DAC's pending flags
- (+) __HAL_DAC_GET_FLAG: Get the selected DAC's flag status
-
- [..]
- (@) You can refer to the DAC HAL driver header file for more useful macros
-
-@endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-#ifdef HAL_DAC_MODULE_ENABLED
-
-#if defined(DAC1)
-
-/** @defgroup DACEx DACEx
- * @brief DAC Extended HAL module driver
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Exported functions --------------------------------------------------------*/
-
-/** @defgroup DACEx_Exported_Functions DACEx Exported Functions
- * @{
- */
-
-/** @defgroup DACEx_Exported_Functions_Group2 IO operation functions
- * @brief Extended IO operation functions
- *
-@verbatim
- ==============================================================================
- ##### Extended features functions #####
- ==============================================================================
- [..] This section provides functions allowing to:
- (+) Start conversion.
- (+) Stop conversion.
- (+) Start conversion and enable DMA transfer.
- (+) Stop conversion and disable DMA transfer.
- (+) Get result of conversion.
- (+) Get result of dual mode conversion.
-
-@endverbatim
- * @{
- */
-
-
-/**
- * @brief Enables DAC and starts conversion of both channels.
- * @param hdac pointer to a DAC_HandleTypeDef structure that contains
- * the configuration information for the specified DAC.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_DACEx_DualStart(DAC_HandleTypeDef *hdac)
-{
- uint32_t tmp_swtrig = 0UL;
-
-
- /* Process locked */
- __HAL_LOCK(hdac);
-
- /* Change DAC state */
- hdac->State = HAL_DAC_STATE_BUSY;
-
- /* Enable the Peripheral */
- __HAL_DAC_ENABLE(hdac, DAC_CHANNEL_1);
- __HAL_DAC_ENABLE(hdac, DAC_CHANNEL_2);
-
- /* Check if software trigger enabled */
- if ((hdac->Instance->CR & (DAC_CR_TEN1 | DAC_CR_TSEL1)) == DAC_TRIGGER_SOFTWARE)
- {
- tmp_swtrig |= DAC_SWTRIGR_SWTRIG1;
- }
- if ((hdac->Instance->CR & (DAC_CR_TEN2 | DAC_CR_TSEL2)) == (DAC_TRIGGER_SOFTWARE << (DAC_CHANNEL_2 & 0x10UL)))
- {
- tmp_swtrig |= DAC_SWTRIGR_SWTRIG2;
- }
- /* Enable the selected DAC software conversion*/
- SET_BIT(hdac->Instance->SWTRIGR, tmp_swtrig);
-
- /* Change DAC state */
- hdac->State = HAL_DAC_STATE_READY;
-
- /* Process unlocked */
- __HAL_UNLOCK(hdac);
-
- /* Return function status */
- return HAL_OK;
-}
-
-/**
- * @brief Disables DAC and stop conversion of both channels.
- * @param hdac pointer to a DAC_HandleTypeDef structure that contains
- * the configuration information for the specified DAC.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_DACEx_DualStop(DAC_HandleTypeDef *hdac)
-{
-
- /* Disable the Peripheral */
- __HAL_DAC_DISABLE(hdac, DAC_CHANNEL_1);
- __HAL_DAC_DISABLE(hdac, DAC_CHANNEL_2);
-
- /* Change DAC state */
- hdac->State = HAL_DAC_STATE_READY;
-
- /* Return function status */
- return HAL_OK;
-}
-
-
-/**
- * @brief Enable or disable the selected DAC channel wave generation.
- * @param hdac pointer to a DAC_HandleTypeDef structure that contains
- * the configuration information for the specified DAC.
- * @param Channel The selected DAC channel.
- * This parameter can be one of the following values:
- * @arg DAC_CHANNEL_1: DAC Channel1 selected
- * @arg DAC_CHANNEL_2: DAC Channel2 selected
- * @param Amplitude Select max triangle amplitude.
- * This parameter can be one of the following values:
- * @arg DAC_TRIANGLEAMPLITUDE_1: Select max triangle amplitude of 1
- * @arg DAC_TRIANGLEAMPLITUDE_3: Select max triangle amplitude of 3
- * @arg DAC_TRIANGLEAMPLITUDE_7: Select max triangle amplitude of 7
- * @arg DAC_TRIANGLEAMPLITUDE_15: Select max triangle amplitude of 15
- * @arg DAC_TRIANGLEAMPLITUDE_31: Select max triangle amplitude of 31
- * @arg DAC_TRIANGLEAMPLITUDE_63: Select max triangle amplitude of 63
- * @arg DAC_TRIANGLEAMPLITUDE_127: Select max triangle amplitude of 127
- * @arg DAC_TRIANGLEAMPLITUDE_255: Select max triangle amplitude of 255
- * @arg DAC_TRIANGLEAMPLITUDE_511: Select max triangle amplitude of 511
- * @arg DAC_TRIANGLEAMPLITUDE_1023: Select max triangle amplitude of 1023
- * @arg DAC_TRIANGLEAMPLITUDE_2047: Select max triangle amplitude of 2047
- * @arg DAC_TRIANGLEAMPLITUDE_4095: Select max triangle amplitude of 4095
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_DACEx_TriangleWaveGenerate(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Amplitude)
-{
- /* Check the parameters */
- assert_param(IS_DAC_CHANNEL(Channel));
- assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
-
- /* Process locked */
- __HAL_LOCK(hdac);
-
- /* Change DAC state */
- hdac->State = HAL_DAC_STATE_BUSY;
-
- /* Enable the triangle wave generation for the selected DAC channel */
- MODIFY_REG(hdac->Instance->CR, ((DAC_CR_WAVE1) | (DAC_CR_MAMP1)) << (Channel & 0x10UL),
- (DAC_CR_WAVE1_1 | Amplitude) << (Channel & 0x10UL));
-
- /* Change DAC state */
- hdac->State = HAL_DAC_STATE_READY;
-
- /* Process unlocked */
- __HAL_UNLOCK(hdac);
-
- /* Return function status */
- return HAL_OK;
-}
-
-/**
- * @brief Enable or disable the selected DAC channel wave generation.
- * @param hdac pointer to a DAC_HandleTypeDef structure that contains
- * the configuration information for the specified DAC.
- * @param Channel The selected DAC channel.
- * This parameter can be one of the following values:
- * @arg DAC_CHANNEL_1: DAC Channel1 selected
- * @arg DAC_CHANNEL_2: DAC Channel2 selected
- * @param Amplitude Unmask DAC channel LFSR for noise wave generation.
- * This parameter can be one of the following values:
- * @arg DAC_LFSRUNMASK_BIT0: Unmask DAC channel LFSR bit0 for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS1_0: Unmask DAC channel LFSR bit[1:0] for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS2_0: Unmask DAC channel LFSR bit[2:0] for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS3_0: Unmask DAC channel LFSR bit[3:0] for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS4_0: Unmask DAC channel LFSR bit[4:0] for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS5_0: Unmask DAC channel LFSR bit[5:0] for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS6_0: Unmask DAC channel LFSR bit[6:0] for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS7_0: Unmask DAC channel LFSR bit[7:0] for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS8_0: Unmask DAC channel LFSR bit[8:0] for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS9_0: Unmask DAC channel LFSR bit[9:0] for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS10_0: Unmask DAC channel LFSR bit[10:0] for noise wave generation
- * @arg DAC_LFSRUNMASK_BITS11_0: Unmask DAC channel LFSR bit[11:0] for noise wave generation
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_DACEx_NoiseWaveGenerate(DAC_HandleTypeDef *hdac, uint32_t Channel, uint32_t Amplitude)
-{
- /* Check the parameters */
- assert_param(IS_DAC_CHANNEL(Channel));
- assert_param(IS_DAC_LFSR_UNMASK_TRIANGLE_AMPLITUDE(Amplitude));
-
- /* Process locked */
- __HAL_LOCK(hdac);
-
- /* Change DAC state */
- hdac->State = HAL_DAC_STATE_BUSY;
-
- /* Enable the noise wave generation for the selected DAC channel */
- MODIFY_REG(hdac->Instance->CR, ((DAC_CR_WAVE1) | (DAC_CR_MAMP1)) << (Channel & 0x10UL),
- (DAC_CR_WAVE1_0 | Amplitude) << (Channel & 0x10UL));
-
- /* Change DAC state */
- hdac->State = HAL_DAC_STATE_READY;
-
- /* Process unlocked */
- __HAL_UNLOCK(hdac);
-
- /* Return function status */
- return HAL_OK;
-}
-
-
-/**
- * @brief Set the specified data holding register value for dual DAC channel.
- * @param hdac pointer to a DAC_HandleTypeDef structure that contains
- * the configuration information for the specified DAC.
- * @param Alignment Specifies the data alignment for dual channel DAC.
- * This parameter can be one of the following values:
- * DAC_ALIGN_8B_R: 8bit right data alignment selected
- * DAC_ALIGN_12B_L: 12bit left data alignment selected
- * DAC_ALIGN_12B_R: 12bit right data alignment selected
- * @param Data1 Data for DAC Channel1 to be loaded in the selected data holding register.
- * @param Data2 Data for DAC Channel2 to be loaded in the selected data holding register.
- * @note In dual mode, a unique register access is required to write in both
- * DAC channels at the same time.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_DACEx_DualSetValue(DAC_HandleTypeDef *hdac, uint32_t Alignment, uint32_t Data1, uint32_t Data2)
-{
- uint32_t data;
- uint32_t tmp;
-
- /* Check the parameters */
- assert_param(IS_DAC_ALIGN(Alignment));
- assert_param(IS_DAC_DATA(Data1));
- assert_param(IS_DAC_DATA(Data2));
-
- /* Calculate and set dual DAC data holding register value */
- if (Alignment == DAC_ALIGN_8B_R)
- {
- data = ((uint32_t)Data2 << 8U) | Data1;
- }
- else
- {
- data = ((uint32_t)Data2 << 16U) | Data1;
- }
-
- tmp = (uint32_t)hdac->Instance;
- tmp += DAC_DHR12RD_ALIGNMENT(Alignment);
-
- /* Set the dual DAC selected data holding register */
- *(__IO uint32_t *)tmp = data;
-
- /* Return function status */
- return HAL_OK;
-}
-
-/**
- * @brief Conversion complete callback in non-blocking mode for Channel2.
- * @param hdac pointer to a DAC_HandleTypeDef structure that contains
- * the configuration information for the specified DAC.
- * @retval None
- */
-__weak void HAL_DACEx_ConvCpltCallbackCh2(DAC_HandleTypeDef *hdac)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hdac);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_DACEx_ConvCpltCallbackCh2 could be implemented in the user file
- */
-}
-
-/**
- * @brief Conversion half DMA transfer callback in non-blocking mode for Channel2.
- * @param hdac pointer to a DAC_HandleTypeDef structure that contains
- * the configuration information for the specified DAC.
- * @retval None
- */
-__weak void HAL_DACEx_ConvHalfCpltCallbackCh2(DAC_HandleTypeDef *hdac)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hdac);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_DACEx_ConvHalfCpltCallbackCh2 could be implemented in the user file
- */
-}
-
-/**
- * @brief Error DAC callback for Channel2.
- * @param hdac pointer to a DAC_HandleTypeDef structure that contains
- * the configuration information for the specified DAC.
- * @retval None
- */
-__weak void HAL_DACEx_ErrorCallbackCh2(DAC_HandleTypeDef *hdac)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hdac);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_DACEx_ErrorCallbackCh2 could be implemented in the user file
- */
-}
-
-/**
- * @brief DMA underrun DAC callback for Channel2.
- * @param hdac pointer to a DAC_HandleTypeDef structure that contains
- * the configuration information for the specified DAC.
- * @retval None
- */
-__weak void HAL_DACEx_DMAUnderrunCallbackCh2(DAC_HandleTypeDef *hdac)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hdac);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_DACEx_DMAUnderrunCallbackCh2 could be implemented in the user file
- */
-}
-
-
-
-/**
- * @}
- */
-
-/** @defgroup DACEx_Exported_Functions_Group3 Peripheral Control functions
- * @brief Extended Peripheral Control functions
- *
-@verbatim
- ==============================================================================
- ##### Peripheral Control functions #####
- ==============================================================================
- [..] This section provides functions allowing to:
- (+) Set the specified data holding register value for DAC channel.
-
-@endverbatim
- * @{
- */
-
-
-/**
- * @brief Return the last data output value of the selected DAC channel.
- * @param hdac pointer to a DAC_HandleTypeDef structure that contains
- * the configuration information for the specified DAC.
- * @retval The selected DAC channel data output value.
- */
-uint32_t HAL_DACEx_DualGetValue(DAC_HandleTypeDef *hdac)
-{
- uint32_t tmp = 0UL;
-
- tmp |= hdac->Instance->DOR1;
-
- tmp |= hdac->Instance->DOR2 << 16UL;
-
- /* Returns the DAC channel data output register value */
- return tmp;
-}
-
-
-/**
- * @}
- */
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-/** @defgroup DACEx_Private_Functions DACEx private functions
- * @brief Extended private functions
- * @{
- */
-
-
-/**
- * @brief DMA conversion complete callback.
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-void DAC_DMAConvCpltCh2(DMA_HandleTypeDef *hdma)
-{
- DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
-
-#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
- hdac->ConvCpltCallbackCh2(hdac);
-#else
- HAL_DACEx_ConvCpltCallbackCh2(hdac);
-#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
-
- hdac->State = HAL_DAC_STATE_READY;
-}
-
-/**
- * @brief DMA half transfer complete callback.
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-void DAC_DMAHalfConvCpltCh2(DMA_HandleTypeDef *hdma)
-{
- DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
- /* Conversion complete callback */
-#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
- hdac->ConvHalfCpltCallbackCh2(hdac);
-#else
- HAL_DACEx_ConvHalfCpltCallbackCh2(hdac);
-#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA error callback.
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-void DAC_DMAErrorCh2(DMA_HandleTypeDef *hdma)
-{
- DAC_HandleTypeDef *hdac = (DAC_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
-
- /* Set DAC error code to DMA error */
- hdac->ErrorCode |= HAL_DAC_ERROR_DMA;
-
-#if (USE_HAL_DAC_REGISTER_CALLBACKS == 1)
- hdac->ErrorCallbackCh2(hdac);
-#else
- HAL_DACEx_ErrorCallbackCh2(hdac);
-#endif /* USE_HAL_DAC_REGISTER_CALLBACKS */
-
- hdac->State = HAL_DAC_STATE_READY;
-}
-
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* DAC1 */
-
-#endif /* HAL_DAC_MODULE_ENABLED */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dma.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dma.c
deleted file mode 100644
index bedf33b7260..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_dma.c
+++ /dev/null
@@ -1,908 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_dma.c
- * @author MCD Application Team
- * @brief DMA HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Direct Memory Access (DMA) peripheral:
- * + Initialization and de-initialization functions
- * + IO operation functions
- * + Peripheral State and errors functions
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- (#) Enable and configure the peripheral to be connected to the DMA Channel
- (except for internal SRAM / FLASH memories: no initialization is
- necessary). Please refer to the Reference manual for connection between peripherals
- and DMA requests.
-
- (#) For a given Channel, program the required configuration through the following parameters:
- Channel request, Transfer Direction, Source and Destination data formats,
- Circular or Normal mode, Channel Priority level, Source and Destination Increment mode
- using HAL_DMA_Init() function.
-
- (#) Use HAL_DMA_GetState() function to return the DMA state and HAL_DMA_GetError() in case of error
- detection.
-
- (#) Use HAL_DMA_Abort() function to abort the current transfer
-
- -@- In Memory-to-Memory transfer mode, Circular mode is not allowed.
- *** Polling mode IO operation ***
- =================================
- [..]
- (+) Use HAL_DMA_Start() to start DMA transfer after the configuration of Source
- address and destination address and the Length of data to be transferred
- (+) Use HAL_DMA_PollForTransfer() to poll for the end of current transfer, in this
- case a fixed Timeout can be configured by User depending from his application.
-
- *** Interrupt mode IO operation ***
- ===================================
- [..]
- (+) Configure the DMA interrupt priority using HAL_NVIC_SetPriority()
- (+) Enable the DMA IRQ handler using HAL_NVIC_EnableIRQ()
- (+) Use HAL_DMA_Start_IT() to start DMA transfer after the configuration of
- Source address and destination address and the Length of data to be transferred.
- In this case the DMA interrupt is configured
- (+) Use HAL_DMA_IRQHandler() called under DMA_IRQHandler() Interrupt subroutine
- (+) At the end of data transfer HAL_DMA_IRQHandler() function is executed and user can
- add his own function to register callbacks with HAL_DMA_RegisterCallback().
-
- *** DMA HAL driver macros list ***
- =============================================
- [..]
- Below the list of macros in DMA HAL driver.
-
- (+) __HAL_DMA_ENABLE: Enable the specified DMA Channel.
- (+) __HAL_DMA_DISABLE: Disable the specified DMA Channel.
- (+) __HAL_DMA_GET_FLAG: Get the DMA Channel pending flags.
- (+) __HAL_DMA_CLEAR_FLAG: Clear the DMA Channel pending flags.
- (+) __HAL_DMA_ENABLE_IT: Enable the specified DMA Channel interrupts.
- (+) __HAL_DMA_DISABLE_IT: Disable the specified DMA Channel interrupts.
- (+) __HAL_DMA_GET_IT_SOURCE: Check whether the specified DMA Channel interrupt is enabled or not.
-
- [..]
- (@) You can refer to the DMA HAL driver header file for more useful macros
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-#ifdef HAL_FLASH_MODULE_ENABLED
-
-/** @addtogroup FLASH
- * @{
- */
-/** @addtogroup FLASH_Private_Variables
- * @{
- */
-extern FLASH_ProcessTypeDef pFlash;
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/** @defgroup FLASH_RAMFUNC FLASH_RAMFUNC
- * @brief FLASH functions executed from RAM
- * @{
- */
-
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/** @defgroup FLASH_RAMFUNC_Private_Functions FLASH RAM Private Functions
- * @{
- */
-
-static __RAM_FUNC HAL_StatusTypeDef FLASHRAM_WaitForLastOperation(uint32_t Timeout);
-static __RAM_FUNC HAL_StatusTypeDef FLASHRAM_SetErrorCode(void);
-
-/**
- * @}
- */
-
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup FLASH_RAMFUNC_Exported_Functions FLASH RAM Exported Functions
- *
-@verbatim
- ===============================================================================
- ##### ramfunc functions #####
- ===============================================================================
- [..]
- This subsection provides a set of functions that should be executed from RAM
- transfers.
-
-@endverbatim
- * @{
- */
-
-/** @defgroup FLASH_RAMFUNC_Exported_Functions_Group1 Peripheral features functions
- * @{
- */
-
-/**
- * @brief Enable the power down mode during RUN mode.
- * @note This function can be used only when the user code is running from Internal SRAM.
- * @retval HAL status
- */
-__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EnableRunPowerDown(void)
-{
- /* Enable the Power Down in Run mode*/
- __HAL_FLASH_POWER_DOWN_ENABLE();
-
- return HAL_OK;
-}
-
-/**
- * @brief Disable the power down mode during RUN mode.
- * @note This function can be used only when the user code is running from Internal SRAM.
- * @retval HAL status
- */
-__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DisableRunPowerDown(void)
-{
- /* Disable the Power Down in Run mode*/
- __HAL_FLASH_POWER_DOWN_DISABLE();
-
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/** @defgroup FLASH_RAMFUNC_Exported_Functions_Group2 Programming and erasing operation functions
- *
-@verbatim
-@endverbatim
- * @{
- */
-
-#if defined(FLASH_PECR_PARALLBANK)
-/**
- * @brief Erases a specified 2 pages in program memory in parallel.
- * @note This function can be used only for STM32L151xD, STM32L152xD), STM32L162xD and Cat5 devices.
- * To correctly run this function, the @ref HAL_FLASH_Unlock() function
- * must be called before.
- * Call the @ref HAL_FLASH_Lock() to disable the flash memory access
- * (recommended to protect the FLASH memory against possible unwanted operation).
- * @param Page_Address1: The page address in program memory to be erased in
- * the first Bank (BANK1). This parameter should be between FLASH_BASE
- * and FLASH_BANK1_END.
- * @param Page_Address2: The page address in program memory to be erased in
- * the second Bank (BANK2). This parameter should be between FLASH_BANK2_BASE
- * and FLASH_BANK2_END.
- * @note A Page is erased in the Program memory only if the address to load
- * is the start address of a page (multiple of @ref FLASH_PAGE_SIZE bytes).
- * @retval HAL status
- */
-__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_EraseParallelPage(uint32_t Page_Address1, uint32_t Page_Address2)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Wait for last operation to be completed */
- status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
-
- if(status == HAL_OK)
- {
- /* Proceed to erase the page */
- SET_BIT(FLASH->PECR, FLASH_PECR_PARALLBANK);
- SET_BIT(FLASH->PECR, FLASH_PECR_ERASE);
- SET_BIT(FLASH->PECR, FLASH_PECR_PROG);
-
- /* Write 00000000h to the first word of the first program page to erase */
- *(__IO uint32_t *)Page_Address1 = 0x00000000U;
- /* Write 00000000h to the first word of the second program page to erase */
- *(__IO uint32_t *)Page_Address2 = 0x00000000U;
-
- /* Wait for last operation to be completed */
- status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
-
- /* If the erase operation is completed, disable the ERASE, PROG and PARALLBANK bits */
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_PROG);
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_ERASE);
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_PARALLBANK);
- }
- /* Return the Erase Status */
- return status;
-}
-
-/**
- * @brief Program 2 half pages in program memory in parallel (half page size is 32 Words).
- * @note This function can be used only for STM32L151xD, STM32L152xD), STM32L162xD and Cat5 devices.
- * @param Address1: specifies the first address to be written in the first bank
- * (BANK1). This parameter should be between FLASH_BASE and (FLASH_BANK1_END - FLASH_PAGE_SIZE).
- * @param pBuffer1: pointer to the buffer containing the data to be written
- * to the first half page in the first bank.
- * @param Address2: specifies the second address to be written in the second bank
- * (BANK2). This parameter should be between FLASH_BANK2_BASE and (FLASH_BANK2_END - FLASH_PAGE_SIZE).
- * @param pBuffer2: pointer to the buffer containing the data to be written
- * to the second half page in the second bank.
- * @note To correctly run this function, the @ref HAL_FLASH_Unlock() function
- * must be called before.
- * Call the @ref HAL_FLASH_Lock() to disable the flash memory access
- * (recommended to protect the FLASH memory against possible unwanted operation).
- * @note Half page write is possible only from SRAM.
- * @note If there are more than 32 words to write, after 32 words another
- * Half Page programming operation starts and has to be finished.
- * @note A half page is written to the program memory only if the first
- * address to load is the start address of a half page (multiple of 128
- * bytes) and the 31 remaining words to load are in the same half page.
- * @note During the Program memory half page write all read operations are
- * forbidden (this includes DMA read operations and debugger read
- * operations such as breakpoints, periodic updates, etc.).
- * @note If a PGAERR is set during a Program memory half page write, the
- * complete write operation is aborted. Software should then reset the
- * FPRG and PROG/DATA bits and restart the write operation from the
- * beginning.
- * @retval HAL status
- */
-__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_ProgramParallelHalfPage(uint32_t Address1, uint32_t* pBuffer1, uint32_t Address2, uint32_t* pBuffer2)
-{
- uint32_t primask_bit;
- uint32_t count = 0U;
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Wait for last operation to be completed */
- status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
-
- if(status == HAL_OK)
- {
- /* Disable all IRQs */
- primask_bit = __get_PRIMASK();
- __disable_irq();
-
- /* Proceed to program the new half page */
- SET_BIT(FLASH->PECR, FLASH_PECR_PARALLBANK);
- SET_BIT(FLASH->PECR, FLASH_PECR_FPRG);
- SET_BIT(FLASH->PECR, FLASH_PECR_PROG);
-
- /* Write the first half page directly with 32 different words */
- while(count < 32U)
- {
- *(__IO uint32_t*) ((uint32_t)(Address1 + (4 * count))) = *pBuffer1;
- pBuffer1++;
- count ++;
- }
-
- /* Write the second half page directly with 32 different words */
- count = 0U;
- while(count < 32U)
- {
- *(__IO uint32_t*) ((uint32_t)(Address2 + (4 * count))) = *pBuffer2;
- pBuffer2++;
- count ++;
- }
-
- /* Wait for last operation to be completed */
- status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
-
- /* if the write operation is completed, disable the PROG, FPRG and PARALLBANK bits */
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_PROG);
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_FPRG);
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_PARALLBANK);
-
- /* Enable IRQs */
- __set_PRIMASK(primask_bit);
- }
-
- /* Return the Write Status */
- return status;
-}
-#endif /* FLASH_PECR_PARALLBANK */
-
-/**
- * @brief Program a half page in program memory.
- * @param Address specifies the address to be written.
- * @param pBuffer pointer to the buffer containing the data to be written to
- * the half page.
- * @note To correctly run this function, the @ref HAL_FLASH_Unlock() function
- * must be called before.
- * Call the @ref HAL_FLASH_Lock() to disable the flash memory access
- * (recommended to protect the FLASH memory against possible unwanted operation)
- * @note Half page write is possible only from SRAM.
- * @note If there are more than 32 words to write, after 32 words another
- * Half Page programming operation starts and has to be finished.
- * @note A half page is written to the program memory only if the first
- * address to load is the start address of a half page (multiple of 128
- * bytes) and the 31 remaining words to load are in the same half page.
- * @note During the Program memory half page write all read operations are
- * forbidden (this includes DMA read operations and debugger read
- * operations such as breakpoints, periodic updates, etc.).
- * @note If a PGAERR is set during a Program memory half page write, the
- * complete write operation is aborted. Software should then reset the
- * FPRG and PROG/DATA bits and restart the write operation from the
- * beginning.
- * @retval HAL status
- */
-__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_HalfPageProgram(uint32_t Address, uint32_t* pBuffer)
-{
- uint32_t primask_bit;
- uint32_t count = 0U;
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Wait for last operation to be completed */
- status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
-
- if(status == HAL_OK)
- {
- /* Disable all IRQs */
- primask_bit = __get_PRIMASK();
- __disable_irq();
-
- /* Proceed to program the new half page */
- SET_BIT(FLASH->PECR, FLASH_PECR_FPRG);
- SET_BIT(FLASH->PECR, FLASH_PECR_PROG);
-
- /* Write one half page directly with 32 different words */
- while(count < 32U)
- {
- *(__IO uint32_t*) ((uint32_t)(Address + (4 * count))) = *pBuffer;
- pBuffer++;
- count ++;
- }
-
- /* Wait for last operation to be completed */
- status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
-
- /* If the write operation is completed, disable the PROG and FPRG bits */
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_PROG);
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_FPRG);
-
- /* Enable IRQs */
- __set_PRIMASK(primask_bit);
- }
-
- /* Return the Write Status */
- return status;
-}
-
-/**
- * @}
- */
-
-/** @defgroup FLASH_RAMFUNC_Exported_Functions_Group3 Peripheral errors functions
- * @brief Peripheral errors functions
- *
-@verbatim
- ===============================================================================
- ##### Peripheral errors functions #####
- ===============================================================================
- [..]
- This subsection permit to get in run-time errors of the FLASH peripheral.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Get the specific FLASH errors flag.
- * @param Error pointer is the error value. It can be a mixed of:
-@if STM32L100xB
-@elif STM32L100xBA
- * @arg @ref HAL_FLASH_ERROR_RD FLASH Read Protection error flag (PCROP)
-@elif STM32L151xB
-@elif STM32L151xBA
- * @arg @ref HAL_FLASH_ERROR_RD FLASH Read Protection error flag (PCROP)
-@elif STM32L152xB
-@elif STM32L152xBA
- * @arg @ref HAL_FLASH_ERROR_RD FLASH Read Protection error flag (PCROP)
-@elif STM32L100xC
- * @arg @ref HAL_FLASH_ERROR_RD FLASH Read Protection error flag (PCROP)
- * @arg @ref HAL_FLASH_ERROR_OPTVUSR FLASH Option User validity error
-@elif STM32L151xC
- * @arg @ref HAL_FLASH_ERROR_RD FLASH Read Protection error flag (PCROP)
- * @arg @ref HAL_FLASH_ERROR_OPTVUSR FLASH Option User validity error
-@elif STM32L152xC
- * @arg @ref HAL_FLASH_ERROR_RD FLASH Read Protection error flag (PCROP)
- * @arg @ref HAL_FLASH_ERROR_OPTVUSR FLASH Option User validity error
-@elif STM32L162xC
- * @arg @ref HAL_FLASH_ERROR_RD FLASH Read Protection error flag (PCROP)
- * @arg @ref HAL_FLASH_ERROR_OPTVUSR FLASH Option User validity error
-@else
- * @arg @ref HAL_FLASH_ERROR_OPTVUSR FLASH Option User validity error
-@endif
- * @arg @ref HAL_FLASH_ERROR_PGA FLASH Programming Alignment error flag
- * @arg @ref HAL_FLASH_ERROR_WRP FLASH Write protected error flag
- * @arg @ref HAL_FLASH_ERROR_OPTV FLASH Option valid error flag
- * @retval HAL Status
- */
-__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_GetError(uint32_t * Error)
-{
- *Error = pFlash.ErrorCode;
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/** @defgroup FLASH_RAMFUNC_Exported_Functions_Group4 DATA EEPROM functions
- *
- * @{
- */
-
-/**
- * @brief Erase a double word in data memory.
- * @param Address specifies the address to be erased.
- * @note To correctly run this function, the HAL_FLASH_EEPROM_Unlock() function
- * must be called before.
- * Call the HAL_FLASH_EEPROM_Lock() to he data EEPROM access
- * and Flash program erase control register access(recommended to protect
- * the DATA_EEPROM against possible unwanted operation).
- * @note Data memory double word erase is possible only from SRAM.
- * @note A double word is erased to the data memory only if the first address
- * to load is the start address of a double word (multiple of 8 bytes).
- * @note During the Data memory double word erase, all read operations are
- * forbidden (this includes DMA read operations and debugger read
- * operations such as breakpoints, periodic updates, etc.).
- * @retval HAL status
- */
-
-__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_EraseDoubleWord(uint32_t Address)
-{
- uint32_t primask_bit;
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Wait for last operation to be completed */
- status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
-
- if(status == HAL_OK)
- {
- /* Disable all IRQs */
- primask_bit = __get_PRIMASK();
- __disable_irq();
-
- /* If the previous operation is completed, proceed to erase the next double word */
- /* Set the ERASE bit */
- SET_BIT(FLASH->PECR, FLASH_PECR_ERASE);
-
- /* Set DATA bit */
- SET_BIT(FLASH->PECR, FLASH_PECR_DATA);
-
- /* Write 00000000h to the 2 words to erase */
- *(__IO uint32_t *)Address = 0x00000000U;
- Address += 4U;
- *(__IO uint32_t *)Address = 0x00000000U;
-
- /* Wait for last operation to be completed */
- status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
-
- /* If the erase operation is completed, disable the ERASE and DATA bits */
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_ERASE);
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_DATA);
-
- /* Enable IRQs */
- __set_PRIMASK(primask_bit);
-
- }
-
- /* Return the erase status */
- return status;
-}
-
-/**
- * @brief Write a double word in data memory without erase.
- * @param Address specifies the address to be written.
- * @param Data specifies the data to be written.
- * @note To correctly run this function, the HAL_FLASH_EEPROM_Unlock() function
- * must be called before.
- * Call the HAL_FLASH_EEPROM_Lock() to he data EEPROM access
- * and Flash program erase control register access(recommended to protect
- * the DATA_EEPROM against possible unwanted operation).
- * @note Data memory double word write is possible only from SRAM.
- * @note A data memory double word is written to the data memory only if the
- * first address to load is the start address of a double word (multiple
- * of double word).
- * @note During the Data memory double word write, all read operations are
- * forbidden (this includes DMA read operations and debugger read
- * operations such as breakpoints, periodic updates, etc.).
- * @retval HAL status
- */
-__RAM_FUNC HAL_StatusTypeDef HAL_FLASHEx_DATAEEPROM_ProgramDoubleWord(uint32_t Address, uint64_t Data)
-{
- uint32_t primask_bit;
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Wait for last operation to be completed */
- status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
-
- if(status == HAL_OK)
- {
- /* Disable all IRQs */
- primask_bit = __get_PRIMASK();
- __disable_irq();
-
- /* If the previous operation is completed, proceed to program the new data*/
- SET_BIT(FLASH->PECR, FLASH_PECR_FPRG);
- SET_BIT(FLASH->PECR, FLASH_PECR_DATA);
-
- /* Write the 2 words */
- *(__IO uint32_t *)Address = (uint32_t) Data;
- Address += 4U;
- *(__IO uint32_t *)Address = (uint32_t) (Data >> 32);
-
- /* Wait for last operation to be completed */
- status = FLASHRAM_WaitForLastOperation(FLASH_TIMEOUT_VALUE);
-
- /* If the write operation is completed, disable the FPRG and DATA bits */
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_FPRG);
- CLEAR_BIT(FLASH->PECR, FLASH_PECR_DATA);
-
- /* Enable IRQs */
- __set_PRIMASK(primask_bit);
- }
-
- /* Return the Write Status */
- return status;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/** @addtogroup FLASH_RAMFUNC_Private_Functions
- * @{
- */
-
-/**
- * @brief Set the specific FLASH error flag.
- * @retval HAL Status
- */
-static __RAM_FUNC HAL_StatusTypeDef FLASHRAM_SetErrorCode(void)
-{
- uint32_t flags = 0U;
-
- if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR))
- {
- pFlash.ErrorCode |= HAL_FLASH_ERROR_WRP;
- flags |= FLASH_FLAG_WRPERR;
- }
- if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR))
- {
- pFlash.ErrorCode |= HAL_FLASH_ERROR_PGA;
- flags |= FLASH_FLAG_PGAERR;
- }
- if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERR))
- {
- pFlash.ErrorCode |= HAL_FLASH_ERROR_OPTV;
- flags |= FLASH_FLAG_OPTVERR;
- }
-
-#if defined(FLASH_SR_RDERR)
- if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR))
- {
- pFlash.ErrorCode |= HAL_FLASH_ERROR_RD;
- flags |= FLASH_FLAG_RDERR;
- }
-#endif /* FLASH_SR_RDERR */
-#if defined(FLASH_SR_OPTVERRUSR)
- if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERRUSR))
- {
- pFlash.ErrorCode |= HAL_FLASH_ERROR_OPTVUSR;
- flags |= FLASH_FLAG_OPTVERRUSR;
- }
-#endif /* FLASH_SR_OPTVERRUSR */
-
- /* Clear FLASH error pending bits */
- __HAL_FLASH_CLEAR_FLAG(flags);
-
- return HAL_OK;
-}
-
-/**
- * @brief Wait for a FLASH operation to complete.
- * @param Timeout maximum flash operationtimeout
- * @retval HAL status
- */
-static __RAM_FUNC HAL_StatusTypeDef FLASHRAM_WaitForLastOperation(uint32_t Timeout)
-{
- /* Wait for the FLASH operation to complete by polling on BUSY flag to be reset.
- Even if the FLASH operation fails, the BUSY flag will be reset and an error
- flag will be set */
-
- while(__HAL_FLASH_GET_FLAG(FLASH_FLAG_BSY) && (Timeout != 0x00U))
- {
- Timeout--;
- }
-
- if(Timeout == 0x00U)
- {
- return HAL_TIMEOUT;
- }
-
- /* Check FLASH End of Operation flag */
- if (__HAL_FLASH_GET_FLAG(FLASH_FLAG_EOP))
- {
- /* Clear FLASH End of Operation pending bit */
- __HAL_FLASH_CLEAR_FLAG(FLASH_FLAG_EOP);
- }
-
- if(__HAL_FLASH_GET_FLAG(FLASH_FLAG_WRPERR) ||
- __HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERR) ||
-#if defined(FLASH_SR_RDERR)
- __HAL_FLASH_GET_FLAG(FLASH_FLAG_RDERR) ||
-#endif /* FLASH_SR_RDERR */
-#if defined(FLASH_SR_OPTVERRUSR)
- __HAL_FLASH_GET_FLAG(FLASH_FLAG_OPTVERRUSR) ||
-#endif /* FLASH_SR_OPTVERRUSR */
- __HAL_FLASH_GET_FLAG(FLASH_FLAG_PGAERR))
- {
- /*Save the error code*/
- FLASHRAM_SetErrorCode();
- return HAL_ERROR;
- }
-
- /* There is no error flag set */
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* HAL_FLASH_MODULE_ENABLED */
-/**
- * @}
- */
-
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_gpio.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_gpio.c
deleted file mode 100644
index ae06f5f2356..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_gpio.c
+++ /dev/null
@@ -1,547 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_gpio.c
- * @author MCD Application Team
- * @brief GPIO HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the General Purpose Input/Output (GPIO) peripheral:
- * + Initialization and de-initialization functions
- * + IO operation functions
- *
- @verbatim
- ==============================================================================
- ##### GPIO Peripheral features #####
- ==============================================================================
- [..]
- Each port bit of the general-purpose I/O (GPIO) ports can be individually
- configured by software in several modes:
- (+) Input mode
- (+) Analog mode
- (+) Output mode
- (+) Alternate function mode
- (+) External interrupt/event lines
-
- [..]
- During and just after reset, the alternate functions and external interrupt
- lines are not active and the I/O ports are configured in input floating mode.
-
- [..]
- All GPIO pins have weak internal pull-up and pull-down resistors, which can be
- activated or not.
-
- [..]
- In Output or Alternate mode, each IO can be configured on open-drain or push-pull
- type and the IO speed can be selected depending on the VDD value.
-
- [..]
- The microcontroller IO pins are connected to onboard peripherals/modules through a
- multiplexer that allows only one peripheral s alternate function (AF) connected
- to an IO pin at a time. In this way, there can be no conflict between peripherals
- sharing the same IO pin.
-
- [..]
- All ports have external interrupt/event capability. To use external interrupt
- lines, the port must be configured in input mode. All available GPIO pins are
- connected to the 16 external interrupt/event lines from EXTI0 to EXTI15.
-
- [..]
- The external interrupt/event controller consists of up to 28 edge detectors
- (depending on products 16 lines are connected to GPIO) for generating event/interrupt
- requests (each input line can be independently configured to select the type
- (interrupt or event) and the corresponding trigger event (rising or falling or both).
- Each line can also be masked independently.
-
- ##### How to use this driver #####
- ==============================================================================
- [..]
- (#) Enable the GPIO AHB clock using the following function : __GPIOx_CLK_ENABLE().
-
- (#) Configure the GPIO pin(s) using HAL_GPIO_Init().
- (++) Configure the IO mode using "Mode" member from GPIO_InitTypeDef structure
- (++) Activate Pull-up, Pull-down resistor using "Pull" member from GPIO_InitTypeDef
- structure.
- (++) In case of Output or alternate function mode selection: the speed is
- configured through "Speed" member from GPIO_InitTypeDef structure,
- the speed is configurable: Low, Medium and High.
- (++) If alternate mode is selected, the alternate function connected to the IO
- is configured through "Alternate" member from GPIO_InitTypeDef structure
- (++) Analog mode is required when a pin is to be used as ADC channel
- or DAC output.
- (++) In case of external interrupt/event selection the "Mode" member from
- GPIO_InitTypeDef structure select the type (interrupt or event) and
- the corresponding trigger event (rising or falling or both).
-
- (#) In case of external interrupt/event mode selection, configure NVIC IRQ priority
- mapped to the EXTI line using HAL_NVIC_SetPriority() and enable it using
- HAL_NVIC_EnableIRQ().
-
- (#) HAL_GPIO_DeInit allows to set register values to their reset value. It's also
- recommended to use it to unconfigure pin which was used as an external interrupt
- or in event mode. That's the only way to reset corresponding bit in EXTI & SYSCFG
- registers.
-
- (#) To get the level of a pin configured in input mode use HAL_GPIO_ReadPin().
-
- (#) To set/reset the level of a pin configured in output mode use
- HAL_GPIO_WritePin()/HAL_GPIO_TogglePin().
-
- (#) To lock pin configuration until next reset use HAL_GPIO_LockPin().
-
- (#) During and just after reset, the alternate functions are not
- active and the GPIO pins are configured in input floating mode (except JTAG
- pins).
-
- (#) The LSE oscillator pins OSC32_IN and OSC32_OUT can be used as general purpose
- (PC14 and PC15, respectively) when the LSE oscillator is off. The LSE has
- priority over the GPIO function.
-
- (#) The HSE oscillator pins OSC_IN/OSC_OUT can be used as
- general purpose PH0 and PH1, respectively, when the HSE oscillator is off.
- The HSE has priority over the GPIO function.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @addtogroup GPIO
- * @brief GPIO HAL module driver
- * @{
- */
-
-#ifdef HAL_GPIO_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/** @addtogroup GPIO_Private_Constants
- * @{
- */
-#define GPIO_NUMBER (16U)
-
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Exported functions ---------------------------------------------------------*/
-
-/** @addtogroup GPIO_Exported_Functions
- * @{
- */
-
-/** @addtogroup GPIO_Exported_Functions_Group1
- * @brief Initialization and Configuration functions
- *
-@verbatim
- ===============================================================================
- ##### Initialization and Configuration functions #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initializes the GPIOx peripheral according to the specified parameters in the GPIO_Init.
- * @param GPIOx where x can be (A..G depending on device used) to select the GPIO peripheral for STM32L1XX family devices
- * @param GPIO_Init pointer to a GPIO_InitTypeDef structure that contains
- * the configuration information for the specified GPIO peripheral.
- * @retval None
- */
-void HAL_GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_Init)
-{
- uint32_t position = 0x00;
- uint32_t iocurrent = 0x00;
- uint32_t temp = 0x00;
-
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
- assert_param(IS_GPIO_PIN(GPIO_Init->Pin));
- assert_param(IS_GPIO_MODE(GPIO_Init->Mode));
-
- /* Configure the port pins */
- while (((GPIO_Init->Pin) >> position) != 0)
- {
- /* Get current io position */
- iocurrent = (GPIO_Init->Pin) & (1U << position);
-
- if (iocurrent)
- {
- /*--------------------- GPIO Mode Configuration ------------------------*/
- /* In case of Output or Alternate function mode selection */
- if (((GPIO_Init->Mode & GPIO_MODE) == MODE_OUTPUT) ||
- ((GPIO_Init->Mode & GPIO_MODE) == MODE_AF))
- {
- /* Check the Speed parameter */
- assert_param(IS_GPIO_SPEED(GPIO_Init->Speed));
- /* Configure the IO Speed */
- temp = GPIOx->OSPEEDR;
- CLEAR_BIT(temp, GPIO_OSPEEDER_OSPEEDR0 << (position * 2));
- SET_BIT(temp, GPIO_Init->Speed << (position * 2));
- GPIOx->OSPEEDR = temp;
-
- /* Configure the IO Output Type */
- temp = GPIOx->OTYPER;
- CLEAR_BIT(temp, GPIO_OTYPER_OT_0 << position) ;
- SET_BIT(temp, ((GPIO_Init->Mode & OUTPUT_TYPE) >> OUTPUT_TYPE_Pos) << position);
- GPIOx->OTYPER = temp;
- }
-
- if ((GPIO_Init->Mode & GPIO_MODE) != MODE_ANALOG)
- {
- /* Check the Pull parameter */
- assert_param(IS_GPIO_PULL(GPIO_Init->Pull));
-
- /* Activate the Pull-up or Pull down resistor for the current IO */
- temp = GPIOx->PUPDR;
- CLEAR_BIT(temp, GPIO_PUPDR_PUPDR0 << (position * 2));
- SET_BIT(temp, (GPIO_Init->Pull) << (position * 2));
- GPIOx->PUPDR = temp;
- }
-
- /* In case of Alternate function mode selection */
- if ((GPIO_Init->Mode & GPIO_MODE) == MODE_AF)
- {
- /* Check the Alternate function parameters */
- assert_param(IS_GPIO_AF_INSTANCE(GPIOx));
- assert_param(IS_GPIO_AF(GPIO_Init->Alternate));
-
- /* Configure Alternate function mapped with the current IO */
- /* Identify AFRL or AFRH register based on IO position*/
- temp = GPIOx->AFR[position >> 3];
- CLEAR_BIT(temp, 0xFU << ((uint32_t)(position & 0x07U) * 4));
- SET_BIT(temp, (uint32_t)(GPIO_Init->Alternate) << (((uint32_t)position & 0x07U) * 4));
- GPIOx->AFR[position >> 3] = temp;
- }
-
- /* Configure IO Direction mode (Input, Output, Alternate or Analog) */
- temp = GPIOx->MODER;
- CLEAR_BIT(temp, GPIO_MODER_MODER0 << (position * 2));
- SET_BIT(temp, (GPIO_Init->Mode & GPIO_MODE) << (position * 2));
- GPIOx->MODER = temp;
-
- /*--------------------- EXTI Mode Configuration ------------------------*/
- /* Configure the External Interrupt or event for the current IO */
- if ((GPIO_Init->Mode & EXTI_MODE) != 0x00U)
- {
- /* Enable SYSCFG Clock */
- __HAL_RCC_SYSCFG_CLK_ENABLE();
-
- temp = SYSCFG->EXTICR[position >> 2];
- CLEAR_BIT(temp, (0x0FU) << (4 * (position & 0x03)));
- SET_BIT(temp, (GPIO_GET_INDEX(GPIOx)) << (4 * (position & 0x03)));
- SYSCFG->EXTICR[position >> 2] = temp;
-
- /* Clear EXTI line configuration */
- temp = EXTI->IMR;
- CLEAR_BIT(temp, (uint32_t)iocurrent);
- if ((GPIO_Init->Mode & EXTI_IT) != 0x00U)
- {
- SET_BIT(temp, iocurrent);
- }
- EXTI->IMR = temp;
-
- temp = EXTI->EMR;
- CLEAR_BIT(temp, (uint32_t)iocurrent);
- if ((GPIO_Init->Mode & EXTI_EVT) != 0x00U)
- {
- SET_BIT(temp, iocurrent);
- }
- EXTI->EMR = temp;
-
- /* Clear Rising Falling edge configuration */
- temp = EXTI->RTSR;
- CLEAR_BIT(temp, (uint32_t)iocurrent);
- if ((GPIO_Init->Mode & TRIGGER_RISING) != 0x00U)
- {
- SET_BIT(temp, iocurrent);
- }
- EXTI->RTSR = temp;
-
- temp = EXTI->FTSR;
- CLEAR_BIT(temp, (uint32_t)iocurrent);
- if ((GPIO_Init->Mode & TRIGGER_FALLING) != 0x00U)
- {
- SET_BIT(temp, iocurrent);
- }
- EXTI->FTSR = temp;
- }
- }
-
- position++;
- }
-}
-
-/**
- * @brief De-initializes the GPIOx peripheral registers to their default reset values.
- * @param GPIOx where x can be (A..G depending on device used) to select the GPIO peripheral for STM32L1XX family devices
- * @param GPIO_Pin specifies the port bit to be written.
- * This parameter can be one of GPIO_PIN_x where x can be (0..15).
- * @retval None
- */
-void HAL_GPIO_DeInit(GPIO_TypeDef *GPIOx, uint32_t GPIO_Pin)
-{
- uint32_t position = 0x00;
- uint32_t iocurrent = 0x00;
- uint32_t tmp = 0x00;
-
- /* Check the parameters */
- assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
- assert_param(IS_GPIO_PIN(GPIO_Pin));
-
- /* Configure the port pins */
- while ((GPIO_Pin >> position) != 0)
- {
- /* Get current io position */
- iocurrent = (GPIO_Pin) & (1U << position);
-
- if (iocurrent)
- {
- /*------------------------- EXTI Mode Configuration --------------------*/
- /* Clear the External Interrupt or Event for the current IO */
-
- tmp = SYSCFG->EXTICR[position >> 2];
- tmp &= ((0x0FU) << (4 * (position & 0x03)));
- if (tmp == (GPIO_GET_INDEX(GPIOx) << (4 * (position & 0x03))))
- {
- /* Clear EXTI line configuration */
- CLEAR_BIT(EXTI->IMR, (uint32_t)iocurrent);
- CLEAR_BIT(EXTI->EMR, (uint32_t)iocurrent);
-
- /* Clear Rising Falling edge configuration */
- CLEAR_BIT(EXTI->RTSR, (uint32_t)iocurrent);
- CLEAR_BIT(EXTI->FTSR, (uint32_t)iocurrent);
-
- tmp = (0x0FU) << (4 * (position & 0x03));
- CLEAR_BIT(SYSCFG->EXTICR[position >> 2], tmp);
- }
-
- /*------------------------- GPIO Mode Configuration --------------------*/
- /* Configure IO Direction in Input Floting Mode */
- CLEAR_BIT(GPIOx->MODER, GPIO_MODER_MODER0 << (position * 2));
-
- /* Configure the default Alternate Function in current IO */
- CLEAR_BIT(GPIOx->AFR[position >> 3], 0xFU << ((uint32_t)(position & 0x07U) * 4)) ;
- /* Deactivate the Pull-up oand Pull-down resistor for the current IO */
- CLEAR_BIT(GPIOx->PUPDR, GPIO_PUPDR_PUPDR0 << (position * 2));
-
- /* Configure the default value IO Output Type */
- CLEAR_BIT(GPIOx->OTYPER, GPIO_OTYPER_OT_0 << position) ;
-
- /* Configure the default value for IO Speed */
- CLEAR_BIT(GPIOx->OSPEEDR, GPIO_OSPEEDER_OSPEEDR0 << (position * 2));
- }
-
- position++;
- }
-}
-
-/**
- * @}
- */
-
-/** @addtogroup GPIO_Exported_Functions_Group2
- * @brief GPIO Read, Write, Toggle, Lock and EXTI management functions.
- *
-@verbatim
- ===============================================================================
- ##### IO operation functions #####
- ===============================================================================
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Reads the specified input port pin.
- * @param GPIOx where x can be (A..G depending on device used) to select the GPIO peripheral for STM32L1XX family devices
- * @param GPIO_Pin specifies the port bit to read.
- * This parameter can be GPIO_PIN_x where x can be (0..15).
- * @retval The input port pin value.
- */
-GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
-{
- GPIO_PinState bitstatus;
-
- /* Check the parameters */
- assert_param(IS_GPIO_PIN(GPIO_Pin));
-
- if ((GPIOx->IDR & GPIO_Pin) != (uint32_t)GPIO_PIN_RESET)
- {
- bitstatus = GPIO_PIN_SET;
- }
- else
- {
- bitstatus = GPIO_PIN_RESET;
- }
- return bitstatus;
-}
-
-/**
- * @brief Sets or clears the selected data port bit.
- * @note This function uses GPIOx_BSRR register to allow atomic read/modify
- * accesses. In this way, there is no risk of an IRQ occurring between
- * the read and the modify access.
- * @param GPIOx where x can be (A..G depending on device used) to select the GPIO peripheral for STM32L1XX family devices
- * @param GPIO_Pin specifies the port bit to be written.
- * This parameter can be one of GPIO_PIN_x where x can be (0..15).
- * @param PinState specifies the value to be written to the selected bit.
- * This parameter can be one of the GPIO_PinState enum values:
- * @arg GPIO_PIN_RESET: to clear the port pin
- * @arg GPIO_PIN_SET: to set the port pin
- * @retval None
- */
-void HAL_GPIO_WritePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin, GPIO_PinState PinState)
-{
- /* Check the parameters */
- assert_param(IS_GPIO_PIN(GPIO_Pin));
- assert_param(IS_GPIO_PIN_ACTION(PinState));
-
- if (PinState != GPIO_PIN_RESET)
- {
- GPIOx->BSRR = (uint32_t)GPIO_Pin;
- }
- else
- {
- GPIOx->BSRR = (uint32_t)GPIO_Pin << 16 ;
- }
-}
-
-/**
- * @brief Toggles the specified GPIO pin
- * @param GPIOx where x can be (A..G depending on device used) to select the GPIO peripheral for STM32L1XX family devices
- * @param GPIO_Pin specifies the pins to be toggled.
- * @retval None
- */
-void HAL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
-{
- uint32_t odr;
-
- /* Check the parameters */
- assert_param(IS_GPIO_PIN(GPIO_Pin));
-
- /* get current Ouput Data Register value */
- odr = GPIOx->ODR;
-
- /* Set selected pins that were at low level, and reset ones that were high */
- GPIOx->BSRR = ((odr & GPIO_Pin) << GPIO_NUMBER) | (~odr & GPIO_Pin);
-}
-
-/**
-* @brief Locks GPIO Pins configuration registers.
-* @note The locked registers are GPIOx_MODER, GPIOx_OTYPER, GPIOx_OSPEEDR,
-* GPIOx_PUPDR, GPIOx_AFRL and GPIOx_AFRH.
-* @note The configuration of the locked GPIO pins can no longer be modified
-* until the next reset.
-* @note Limitation concerning GPIOx_OTYPER: Locking of GPIOx_OTYPER[i] with i = 15..8
-* depends from setting of GPIOx_LCKR[i-8] and not from GPIOx_LCKR[i].
-* GPIOx_LCKR[i-8] is locking GPIOx_OTYPER[i] together with GPIOx_OTYPER[i-8].
-* It is not possible to lock GPIOx_OTYPER[i] with i = 15..8, without locking also
-* GPIOx_OTYPER[i-8].
-* Workaround: When calling HAL_GPIO_LockPin with GPIO_Pin from GPIO_PIN_8 to GPIO_PIN_15,
-* you must call also HAL_GPIO_LockPin with GPIO_Pin - 8.
-* (When locking a pin from GPIO_PIN_8 to GPIO_PIN_15, you must lock also the corresponding
-* GPIO_PIN_0 to GPIO_PIN_7).
-* @param GPIOx where x can be (A..G depending on device used) to select the GPIO peripheral for STM32L1XX family devices
-* @param GPIO_Pin Specifies the port bit to be locked.
-* This parameter can be any combination of GPIO_Pin_x where x can be (0..15).
-* @retval None
-*/
-HAL_StatusTypeDef HAL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint16_t GPIO_Pin)
-{
- __IO uint32_t tmp = GPIO_LCKR_LCKK;
-
- /* Check the parameters */
- assert_param(IS_GPIO_LOCK_INSTANCE(GPIOx));
- assert_param(IS_GPIO_PIN(GPIO_Pin));
-
- /* Apply lock key write sequence */
- SET_BIT(tmp, GPIO_Pin);
- /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
- GPIOx->LCKR = tmp;
- /* Reset LCKx bit(s): LCKK='0' + LCK[15-0] */
- GPIOx->LCKR = GPIO_Pin;
- /* Set LCKx bit(s): LCKK='1' + LCK[15-0] */
- GPIOx->LCKR = tmp;
- /* Read LCKK register. This read is mandatory to complete key lock sequence */
- tmp = GPIOx->LCKR;
-
- /* Read again in order to confirm lock is active */
- if ((GPIOx->LCKR & GPIO_LCKR_LCKK) != RESET)
- {
- return HAL_OK;
- }
- else
- {
- return HAL_ERROR;
- }
-}
-
-/**
- * @brief This function handles EXTI interrupt request.
- * @param GPIO_Pin Specifies the port pin connected to corresponding EXTI line.
- * @retval None
- */
-void HAL_GPIO_EXTI_IRQHandler(uint16_t GPIO_Pin)
-{
- /* EXTI line interrupt detected */
- if (__HAL_GPIO_EXTI_GET_IT(GPIO_Pin) != RESET)
- {
- __HAL_GPIO_EXTI_CLEAR_IT(GPIO_Pin);
- HAL_GPIO_EXTI_Callback(GPIO_Pin);
- }
-}
-
-/**
- * @brief EXTI line detection callbacks.
- * @param GPIO_Pin Specifies the port pin connected to corresponding EXTI line.
- * @retval None
- */
-__weak void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(GPIO_Pin);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_GPIO_EXTI_Callback could be implemented in the user file
- */
-}
-
-/**
- * @}
- */
-
-
-/**
- * @}
- */
-
-#endif /* HAL_GPIO_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_i2c.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_i2c.c
deleted file mode 100644
index 5d25efd0bfd..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_i2c.c
+++ /dev/null
@@ -1,7498 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_i2c.c
- * @author MCD Application Team
- * @brief I2C HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Inter Integrated Circuit (I2C) peripheral:
- * + Initialization and de-initialization functions
- * + IO operation functions
- * + Peripheral State, Mode and Error functions
- *
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- The I2C HAL driver can be used as follows:
-
- (#) Declare a I2C_HandleTypeDef handle structure, for example:
- I2C_HandleTypeDef hi2c;
-
- (#)Initialize the I2C low level resources by implementing the @ref HAL_I2C_MspInit() API:
- (##) Enable the I2Cx interface clock
- (##) I2C pins configuration
- (+++) Enable the clock for the I2C GPIOs
- (+++) Configure I2C pins as alternate function open-drain
- (##) NVIC configuration if you need to use interrupt process
- (+++) Configure the I2Cx interrupt priority
- (+++) Enable the NVIC I2C IRQ Channel
- (##) DMA Configuration if you need to use DMA process
- (+++) Declare a DMA_HandleTypeDef handle structure for the transmit or receive channel
- (+++) Enable the DMAx interface clock using
- (+++) Configure the DMA handle parameters
- (+++) Configure the DMA Tx or Rx channel
- (+++) Associate the initialized DMA handle to the hi2c DMA Tx or Rx handle
- (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on
- the DMA Tx or Rx channel
-
- (#) Configure the Communication Speed, Duty cycle, Addressing mode, Own Address1,
- Dual Addressing mode, Own Address2, General call and Nostretch mode in the hi2c Init structure.
-
- (#) Initialize the I2C registers by calling the @ref HAL_I2C_Init(), configures also the low level Hardware
- (GPIO, CLOCK, NVIC...etc) by calling the customized @ref HAL_I2C_MspInit() API.
-
- (#) To check if target device is ready for communication, use the function @ref HAL_I2C_IsDeviceReady()
-
- (#) For I2C IO and IO MEM operations, three operation modes are available within this driver :
-
- *** Polling mode IO operation ***
- =================================
- [..]
- (+) Transmit in master mode an amount of data in blocking mode using @ref HAL_I2C_Master_Transmit()
- (+) Receive in master mode an amount of data in blocking mode using @ref HAL_I2C_Master_Receive()
- (+) Transmit in slave mode an amount of data in blocking mode using @ref HAL_I2C_Slave_Transmit()
- (+) Receive in slave mode an amount of data in blocking mode using @ref HAL_I2C_Slave_Receive()
-
- *** Polling mode IO MEM operation ***
- =====================================
- [..]
- (+) Write an amount of data in blocking mode to a specific memory address using @ref HAL_I2C_Mem_Write()
- (+) Read an amount of data in blocking mode from a specific memory address using @ref HAL_I2C_Mem_Read()
-
-
- *** Interrupt mode IO operation ***
- ===================================
- [..]
- (+) Transmit in master mode an amount of data in non-blocking mode using @ref HAL_I2C_Master_Transmit_IT()
- (+) At transmission end of transfer, @ref HAL_I2C_MasterTxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_MasterTxCpltCallback()
- (+) Receive in master mode an amount of data in non-blocking mode using @ref HAL_I2C_Master_Receive_IT()
- (+) At reception end of transfer, @ref HAL_I2C_MasterRxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_MasterRxCpltCallback()
- (+) Transmit in slave mode an amount of data in non-blocking mode using @ref HAL_I2C_Slave_Transmit_IT()
- (+) At transmission end of transfer, @ref HAL_I2C_SlaveTxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_SlaveTxCpltCallback()
- (+) Receive in slave mode an amount of data in non-blocking mode using @ref HAL_I2C_Slave_Receive_IT()
- (+) At reception end of transfer, @ref HAL_I2C_SlaveRxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_SlaveRxCpltCallback()
- (+) In case of transfer Error, @ref HAL_I2C_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_ErrorCallback()
- (+) Abort a master I2C process communication with Interrupt using @ref HAL_I2C_Master_Abort_IT()
- (+) End of abort process, @ref HAL_I2C_AbortCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_AbortCpltCallback()
-
- *** Interrupt mode or DMA mode IO sequential operation ***
- ==========================================================
- [..]
- (@) These interfaces allow to manage a sequential transfer with a repeated start condition
- when a direction change during transfer
- [..]
- (+) A specific option field manage the different steps of a sequential transfer
- (+) Option field values are defined through @ref I2C_XferOptions_definition and are listed below:
- (++) I2C_FIRST_AND_LAST_FRAME: No sequential usage, functional is same as associated interfaces in no sequential mode
- (++) I2C_FIRST_FRAME: Sequential usage, this option allow to manage a sequence with start condition, address
- and data to transfer without a final stop condition
- (++) I2C_FIRST_AND_NEXT_FRAME: Sequential usage (Master only), this option allow to manage a sequence with start condition, address
- and data to transfer without a final stop condition, an then permit a call the same master sequential interface
- several times (like @ref HAL_I2C_Master_Seq_Transmit_IT() then @ref HAL_I2C_Master_Seq_Transmit_IT()
- or @ref HAL_I2C_Master_Seq_Transmit_DMA() then @ref HAL_I2C_Master_Seq_Transmit_DMA())
- (++) I2C_NEXT_FRAME: Sequential usage, this option allow to manage a sequence with a restart condition, address
- and with new data to transfer if the direction change or manage only the new data to transfer
- if no direction change and without a final stop condition in both cases
- (++) I2C_LAST_FRAME: Sequential usage, this option allow to manage a sequance with a restart condition, address
- and with new data to transfer if the direction change or manage only the new data to transfer
- if no direction change and with a final stop condition in both cases
- (++) I2C_LAST_FRAME_NO_STOP: Sequential usage (Master only), this option allow to manage a restart condition after several call of the same master sequential
- interface several times (link with option I2C_FIRST_AND_NEXT_FRAME).
- Usage can, transfer several bytes one by one using HAL_I2C_Master_Seq_Transmit_IT(option I2C_FIRST_AND_NEXT_FRAME then I2C_NEXT_FRAME)
- or HAL_I2C_Master_Seq_Receive_IT(option I2C_FIRST_AND_NEXT_FRAME then I2C_NEXT_FRAME)
- or HAL_I2C_Master_Seq_Transmit_DMA(option I2C_FIRST_AND_NEXT_FRAME then I2C_NEXT_FRAME)
- or HAL_I2C_Master_Seq_Receive_DMA(option I2C_FIRST_AND_NEXT_FRAME then I2C_NEXT_FRAME).
- Then usage of this option I2C_LAST_FRAME_NO_STOP at the last Transmit or Receive sequence permit to call the opposite interface Receive or Transmit
- without stopping the communication and so generate a restart condition.
- (++) I2C_OTHER_FRAME: Sequential usage (Master only), this option allow to manage a restart condition after each call of the same master sequential
- interface.
- Usage can, transfer several bytes one by one with a restart with slave address between each bytes using HAL_I2C_Master_Seq_Transmit_IT(option I2C_FIRST_FRAME then I2C_OTHER_FRAME)
- or HAL_I2C_Master_Seq_Receive_IT(option I2C_FIRST_FRAME then I2C_OTHER_FRAME)
- or HAL_I2C_Master_Seq_Transmit_DMA(option I2C_FIRST_FRAME then I2C_OTHER_FRAME)
- or HAL_I2C_Master_Seq_Receive_DMA(option I2C_FIRST_FRAME then I2C_OTHER_FRAME).
- Then usage of this option I2C_OTHER_AND_LAST_FRAME at the last frame to help automatic generation of STOP condition.
-
- (+) Different sequential I2C interfaces are listed below:
- (++) Sequential transmit in master I2C mode an amount of data in non-blocking mode using @ref HAL_I2C_Master_Seq_Transmit_IT()
- or using @ref HAL_I2C_Master_Seq_Transmit_DMA()
- (+++) At transmission end of current frame transfer, @ref HAL_I2C_MasterTxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_MasterTxCpltCallback()
- (++) Sequential receive in master I2C mode an amount of data in non-blocking mode using @ref HAL_I2C_Master_Seq_Receive_IT()
- or using @ref HAL_I2C_Master_Seq_Receive_DMA()
- (+++) At reception end of current frame transfer, @ref HAL_I2C_MasterRxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_MasterRxCpltCallback()
- (++) Abort a master IT or DMA I2C process communication with Interrupt using @ref HAL_I2C_Master_Abort_IT()
- (+++) End of abort process, @ref HAL_I2C_AbortCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_AbortCpltCallback()
- (++) Enable/disable the Address listen mode in slave I2C mode using @ref HAL_I2C_EnableListen_IT() @ref HAL_I2C_DisableListen_IT()
- (+++) When address slave I2C match, @ref HAL_I2C_AddrCallback() is executed and user can
- add his own code to check the Address Match Code and the transmission direction request by master (Write/Read).
- (+++) At Listen mode end @ref HAL_I2C_ListenCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_ListenCpltCallback()
- (++) Sequential transmit in slave I2C mode an amount of data in non-blocking mode using @ref HAL_I2C_Slave_Seq_Transmit_IT()
- or using @ref HAL_I2C_Slave_Seq_Transmit_DMA()
- (+++) At transmission end of current frame transfer, @ref HAL_I2C_SlaveTxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_SlaveTxCpltCallback()
- (++) Sequential receive in slave I2C mode an amount of data in non-blocking mode using @ref HAL_I2C_Slave_Seq_Receive_IT()
- or using @ref HAL_I2C_Slave_Seq_Receive_DMA()
- (+++) At reception end of current frame transfer, @ref HAL_I2C_SlaveRxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_SlaveRxCpltCallback()
- (++) In case of transfer Error, @ref HAL_I2C_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_ErrorCallback()
-
- *** Interrupt mode IO MEM operation ***
- =======================================
- [..]
- (+) Write an amount of data in non-blocking mode with Interrupt to a specific memory address using
- @ref HAL_I2C_Mem_Write_IT()
- (+) At Memory end of write transfer, @ref HAL_I2C_MemTxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_MemTxCpltCallback()
- (+) Read an amount of data in non-blocking mode with Interrupt from a specific memory address using
- @ref HAL_I2C_Mem_Read_IT()
- (+) At Memory end of read transfer, @ref HAL_I2C_MemRxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_MemRxCpltCallback()
- (+) In case of transfer Error, @ref HAL_I2C_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_ErrorCallback()
-
- *** DMA mode IO operation ***
- ==============================
- [..]
- (+) Transmit in master mode an amount of data in non-blocking mode (DMA) using
- @ref HAL_I2C_Master_Transmit_DMA()
- (+) At transmission end of transfer, @ref HAL_I2C_MasterTxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_MasterTxCpltCallback()
- (+) Receive in master mode an amount of data in non-blocking mode (DMA) using
- @ref HAL_I2C_Master_Receive_DMA()
- (+) At reception end of transfer, @ref HAL_I2C_MasterRxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_MasterRxCpltCallback()
- (+) Transmit in slave mode an amount of data in non-blocking mode (DMA) using
- @ref HAL_I2C_Slave_Transmit_DMA()
- (+) At transmission end of transfer, @ref HAL_I2C_SlaveTxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_SlaveTxCpltCallback()
- (+) Receive in slave mode an amount of data in non-blocking mode (DMA) using
- @ref HAL_I2C_Slave_Receive_DMA()
- (+) At reception end of transfer, @ref HAL_I2C_SlaveRxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_SlaveRxCpltCallback()
- (+) In case of transfer Error, @ref HAL_I2C_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_ErrorCallback()
- (+) Abort a master I2C process communication with Interrupt using @ref HAL_I2C_Master_Abort_IT()
- (+) End of abort process, @ref HAL_I2C_AbortCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_AbortCpltCallback()
-
- *** DMA mode IO MEM operation ***
- =================================
- [..]
- (+) Write an amount of data in non-blocking mode with DMA to a specific memory address using
- @ref HAL_I2C_Mem_Write_DMA()
- (+) At Memory end of write transfer, @ref HAL_I2C_MemTxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_MemTxCpltCallback()
- (+) Read an amount of data in non-blocking mode with DMA from a specific memory address using
- @ref HAL_I2C_Mem_Read_DMA()
- (+) At Memory end of read transfer, @ref HAL_I2C_MemRxCpltCallback() is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_MemRxCpltCallback()
- (+) In case of transfer Error, @ref HAL_I2C_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer @ref HAL_I2C_ErrorCallback()
-
-
- *** I2C HAL driver macros list ***
- ==================================
- [..]
- Below the list of most used macros in I2C HAL driver.
-
- (+) @ref __HAL_I2C_ENABLE: Enable the I2C peripheral
- (+) @ref __HAL_I2C_DISABLE: Disable the I2C peripheral
- (+) @ref __HAL_I2C_GET_FLAG: Checks whether the specified I2C flag is set or not
- (+) @ref __HAL_I2C_CLEAR_FLAG: Clear the specified I2C pending flag
- (+) @ref __HAL_I2C_ENABLE_IT: Enable the specified I2C interrupt
- (+) @ref __HAL_I2C_DISABLE_IT: Disable the specified I2C interrupt
-
- *** Callback registration ***
- =============================================
- [..]
- The compilation flag USE_HAL_I2C_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
- Use Functions @ref HAL_I2C_RegisterCallback() or @ref HAL_I2C_RegisterAddrCallback()
- to register an interrupt callback.
- [..]
- Function @ref HAL_I2C_RegisterCallback() allows to register following callbacks:
- (+) MasterTxCpltCallback : callback for Master transmission end of transfer.
- (+) MasterRxCpltCallback : callback for Master reception end of transfer.
- (+) SlaveTxCpltCallback : callback for Slave transmission end of transfer.
- (+) SlaveRxCpltCallback : callback for Slave reception end of transfer.
- (+) ListenCpltCallback : callback for end of listen mode.
- (+) MemTxCpltCallback : callback for Memory transmission end of transfer.
- (+) MemRxCpltCallback : callback for Memory reception end of transfer.
- (+) ErrorCallback : callback for error detection.
- (+) AbortCpltCallback : callback for abort completion process.
- (+) MspInitCallback : callback for Msp Init.
- (+) MspDeInitCallback : callback for Msp DeInit.
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
- [..]
- For specific callback AddrCallback use dedicated register callbacks : @ref HAL_I2C_RegisterAddrCallback().
- [..]
- Use function @ref HAL_I2C_UnRegisterCallback to reset a callback to the default
- weak function.
- @ref HAL_I2C_UnRegisterCallback takes as parameters the HAL peripheral handle,
- and the Callback ID.
- This function allows to reset following callbacks:
- (+) MasterTxCpltCallback : callback for Master transmission end of transfer.
- (+) MasterRxCpltCallback : callback for Master reception end of transfer.
- (+) SlaveTxCpltCallback : callback for Slave transmission end of transfer.
- (+) SlaveRxCpltCallback : callback for Slave reception end of transfer.
- (+) ListenCpltCallback : callback for end of listen mode.
- (+) MemTxCpltCallback : callback for Memory transmission end of transfer.
- (+) MemRxCpltCallback : callback for Memory reception end of transfer.
- (+) ErrorCallback : callback for error detection.
- (+) AbortCpltCallback : callback for abort completion process.
- (+) MspInitCallback : callback for Msp Init.
- (+) MspDeInitCallback : callback for Msp DeInit.
- [..]
- For callback AddrCallback use dedicated register callbacks : @ref HAL_I2C_UnRegisterAddrCallback().
- [..]
- By default, after the @ref HAL_I2C_Init() and when the state is @ref HAL_I2C_STATE_RESET
- all callbacks are set to the corresponding weak functions:
- examples @ref HAL_I2C_MasterTxCpltCallback(), @ref HAL_I2C_MasterRxCpltCallback().
- Exception done for MspInit and MspDeInit functions that are
- reset to the legacy weak functions in the @ref HAL_I2C_Init()/ @ref HAL_I2C_DeInit() only when
- these callbacks are null (not registered beforehand).
- If MspInit or MspDeInit are not null, the @ref HAL_I2C_Init()/ @ref HAL_I2C_DeInit()
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand) whatever the state.
- [..]
- Callbacks can be registered/unregistered in @ref HAL_I2C_STATE_READY state only.
- Exception done MspInit/MspDeInit functions that can be registered/unregistered
- in @ref HAL_I2C_STATE_READY or @ref HAL_I2C_STATE_RESET state,
- thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
- Then, the user first registers the MspInit/MspDeInit user callbacks
- using @ref HAL_I2C_RegisterCallback() before calling @ref HAL_I2C_DeInit()
- or @ref HAL_I2C_Init() function.
- [..]
- When the compilation flag USE_HAL_I2C_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registration feature is not available and all callbacks
- are set to the corresponding weak functions.
-
-
-
- [..]
- (@) You can refer to the I2C HAL driver header file for more useful macros
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-#ifdef HAL_I2S_MODULE_ENABLED
-
-#if defined(SPI_I2S_SUPPORT)
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup I2S I2S
- * @brief I2S HAL module driver
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-#define I2S_TIMEOUT_FLAG 100U /*!< Timeout 100 ms */
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/** @defgroup I2S_Private_Functions I2S Private Functions
- * @{
- */
-static void I2S_DMATxCplt(DMA_HandleTypeDef *hdma);
-static void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma);
-static void I2S_DMARxCplt(DMA_HandleTypeDef *hdma);
-static void I2S_DMARxHalfCplt(DMA_HandleTypeDef *hdma);
-static void I2S_DMAError(DMA_HandleTypeDef *hdma);
-static void I2S_Transmit_IT(I2S_HandleTypeDef *hi2s);
-static void I2S_Receive_IT(I2S_HandleTypeDef *hi2s);
-static HAL_StatusTypeDef I2S_WaitFlagStateUntilTimeout(I2S_HandleTypeDef *hi2s, uint32_t Flag, FlagStatus State,
- uint32_t Timeout);
-/**
- * @}
- */
-
-/* Exported functions ---------------------------------------------------------*/
-
-/** @defgroup I2S_Exported_Functions I2S Exported Functions
- * @{
- */
-
-/** @defgroup I2S_Exported_Functions_Group1 Initialization and de-initialization functions
- * @brief Initialization and Configuration functions
- *
-@verbatim
- ===============================================================================
- ##### Initialization and de-initialization functions #####
- ===============================================================================
- [..] This subsection provides a set of functions allowing to initialize and
- de-initialize the I2Sx peripheral in simplex mode:
-
- (+) User must Implement HAL_I2S_MspInit() function in which he configures
- all related peripherals resources (CLOCK, GPIO, DMA, IT and NVIC ).
-
- (+) Call the function HAL_I2S_Init() to configure the selected device with
- the selected configuration:
- (++) Mode
- (++) Standard
- (++) Data Format
- (++) MCLK Output
- (++) Audio frequency
- (++) Polarity
-
- (+) Call the function HAL_I2S_DeInit() to restore the default configuration
- of the selected I2Sx peripheral.
- @endverbatim
- * @{
- */
-
-/**
- * @brief Initializes the I2S according to the specified parameters
- * in the I2S_InitTypeDef and create the associated handle.
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_Init(I2S_HandleTypeDef *hi2s)
-{
- uint32_t i2sdiv;
- uint32_t i2sodd;
- uint32_t packetlength;
- uint32_t tmp;
- uint32_t i2sclk;
-
- /* Check the I2S handle allocation */
- if (hi2s == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the I2S parameters */
- assert_param(IS_I2S_ALL_INSTANCE(hi2s->Instance));
- assert_param(IS_I2S_MODE(hi2s->Init.Mode));
- assert_param(IS_I2S_STANDARD(hi2s->Init.Standard));
- assert_param(IS_I2S_DATA_FORMAT(hi2s->Init.DataFormat));
- assert_param(IS_I2S_MCLK_OUTPUT(hi2s->Init.MCLKOutput));
- assert_param(IS_I2S_AUDIO_FREQ(hi2s->Init.AudioFreq));
- assert_param(IS_I2S_CPOL(hi2s->Init.CPOL));
-
- if (hi2s->State == HAL_I2S_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- hi2s->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
- /* Init the I2S Callback settings */
- hi2s->TxCpltCallback = HAL_I2S_TxCpltCallback; /* Legacy weak TxCpltCallback */
- hi2s->RxCpltCallback = HAL_I2S_RxCpltCallback; /* Legacy weak RxCpltCallback */
- hi2s->TxHalfCpltCallback = HAL_I2S_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
- hi2s->RxHalfCpltCallback = HAL_I2S_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
- hi2s->ErrorCallback = HAL_I2S_ErrorCallback; /* Legacy weak ErrorCallback */
-
- if (hi2s->MspInitCallback == NULL)
- {
- hi2s->MspInitCallback = HAL_I2S_MspInit; /* Legacy weak MspInit */
- }
-
- /* Init the low level hardware : GPIO, CLOCK, NVIC... */
- hi2s->MspInitCallback(hi2s);
-#else
- /* Init the low level hardware : GPIO, CLOCK, CORTEX...etc */
- HAL_I2S_MspInit(hi2s);
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
- }
-
- hi2s->State = HAL_I2S_STATE_BUSY;
-
- /*----------------------- SPIx I2SCFGR & I2SPR Configuration ----------------*/
- /* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */
- CLEAR_BIT(hi2s->Instance->I2SCFGR, (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CKPOL | \
- SPI_I2SCFGR_I2SSTD | SPI_I2SCFGR_PCMSYNC | SPI_I2SCFGR_I2SCFG | \
- SPI_I2SCFGR_I2SE | SPI_I2SCFGR_I2SMOD));
- hi2s->Instance->I2SPR = 0x0002U;
-
- /*----------------------- I2SPR: I2SDIV and ODD Calculation -----------------*/
- /* If the requested audio frequency is not the default, compute the prescaler */
- if (hi2s->Init.AudioFreq != I2S_AUDIOFREQ_DEFAULT)
- {
- /* Check the frame length (For the Prescaler computing) ********************/
- if (hi2s->Init.DataFormat == I2S_DATAFORMAT_16B)
- {
- /* Packet length is 16 bits */
- packetlength = 16U;
- }
- else
- {
- /* Packet length is 32 bits */
- packetlength = 32U;
- }
-
- /* I2S standard */
- if (hi2s->Init.Standard <= I2S_STANDARD_LSB)
- {
- /* In I2S standard packet length is multiplied by 2 */
- packetlength = packetlength * 2U;
- }
-
- /* Get the source clock value: based on System Clock value */
- i2sclk = HAL_RCC_GetSysClockFreq();
-
- /* Compute the Real divider depending on the MCLK output state, with a floating point */
- if (hi2s->Init.MCLKOutput == I2S_MCLKOUTPUT_ENABLE)
- {
- /* MCLK output is enabled */
- if (hi2s->Init.DataFormat != I2S_DATAFORMAT_16B)
- {
- tmp = (uint32_t)(((((i2sclk / (packetlength * 4U)) * 10U) / hi2s->Init.AudioFreq)) + 5U);
- }
- else
- {
- tmp = (uint32_t)(((((i2sclk / (packetlength * 8U)) * 10U) / hi2s->Init.AudioFreq)) + 5U);
- }
- }
- else
- {
- /* MCLK output is disabled */
- tmp = (uint32_t)(((((i2sclk / packetlength) * 10U) / hi2s->Init.AudioFreq)) + 5U);
- }
-
- /* Remove the flatting point */
- tmp = tmp / 10U;
-
- /* Check the parity of the divider */
- i2sodd = (uint32_t)(tmp & (uint32_t)1U);
-
- /* Compute the i2sdiv prescaler */
- i2sdiv = (uint32_t)((tmp - i2sodd) / 2U);
-
- /* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */
- i2sodd = (uint32_t)(i2sodd << 8U);
- }
- else
- {
- /* Set the default values */
- i2sdiv = 2U;
- i2sodd = 0U;
- }
-
- /* Test if the divider is 1 or 0 or greater than 0xFF */
- if ((i2sdiv < 2U) || (i2sdiv > 0xFFU))
- {
- /* Set the error code and execute error callback*/
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_PRESCALER);
- return HAL_ERROR;
- }
-
- /*----------------------- SPIx I2SCFGR & I2SPR Configuration ----------------*/
-
- /* Write to SPIx I2SPR register the computed value */
- hi2s->Instance->I2SPR = (uint32_t)((uint32_t)i2sdiv | (uint32_t)(i2sodd | (uint32_t)hi2s->Init.MCLKOutput));
-
- /* Clear I2SMOD, I2SE, I2SCFG, PCMSYNC, I2SSTD, CKPOL, DATLEN and CHLEN bits */
- /* And configure the I2S with the I2S_InitStruct values */
- MODIFY_REG(hi2s->Instance->I2SCFGR, (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN | \
- SPI_I2SCFGR_CKPOL | SPI_I2SCFGR_I2SSTD | \
- SPI_I2SCFGR_PCMSYNC | SPI_I2SCFGR_I2SCFG | \
- SPI_I2SCFGR_I2SE | SPI_I2SCFGR_I2SMOD), \
- (SPI_I2SCFGR_I2SMOD | hi2s->Init.Mode | \
- hi2s->Init.Standard | hi2s->Init.DataFormat | \
- hi2s->Init.CPOL));
-
-#if defined(SPI_I2SCFGR_ASTRTEN)
- if ((hi2s->Init.Standard == I2S_STANDARD_PCM_SHORT) || ((hi2s->Init.Standard == I2S_STANDARD_PCM_LONG)))
- {
- /* Write to SPIx I2SCFGR */
- SET_BIT(hi2s->Instance->I2SCFGR, SPI_I2SCFGR_ASTRTEN);
- }
-#endif /* SPI_I2SCFGR_ASTRTEN */
-
- hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
- hi2s->State = HAL_I2S_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @brief DeInitializes the I2S peripheral
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_DeInit(I2S_HandleTypeDef *hi2s)
-{
- /* Check the I2S handle allocation */
- if (hi2s == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_I2S_ALL_INSTANCE(hi2s->Instance));
-
- hi2s->State = HAL_I2S_STATE_BUSY;
-
- /* Disable the I2S Peripheral Clock */
- __HAL_I2S_DISABLE(hi2s);
-
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
- if (hi2s->MspDeInitCallback == NULL)
- {
- hi2s->MspDeInitCallback = HAL_I2S_MspDeInit; /* Legacy weak MspDeInit */
- }
-
- /* DeInit the low level hardware: GPIO, CLOCK, NVIC... */
- hi2s->MspDeInitCallback(hi2s);
-#else
- /* DeInit the low level hardware: GPIO, CLOCK, NVIC... */
- HAL_I2S_MspDeInit(hi2s);
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
-
- hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
- hi2s->State = HAL_I2S_STATE_RESET;
-
- /* Release Lock */
- __HAL_UNLOCK(hi2s);
-
- return HAL_OK;
-}
-
-/**
- * @brief I2S MSP Init
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval None
- */
-__weak void HAL_I2S_MspInit(I2S_HandleTypeDef *hi2s)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hi2s);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_I2S_MspInit could be implemented in the user file
- */
-}
-
-/**
- * @brief I2S MSP DeInit
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval None
- */
-__weak void HAL_I2S_MspDeInit(I2S_HandleTypeDef *hi2s)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hi2s);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_I2S_MspDeInit could be implemented in the user file
- */
-}
-
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
-/**
- * @brief Register a User I2S Callback
- * To be used instead of the weak predefined callback
- * @param hi2s Pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for the specified I2S.
- * @param CallbackID ID of the callback to be registered
- * @param pCallback pointer to the Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_RegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef CallbackID,
- pI2S_CallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- /* Update the error code */
- hi2s->ErrorCode |= HAL_I2S_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
- /* Process locked */
- __HAL_LOCK(hi2s);
-
- if (HAL_I2S_STATE_READY == hi2s->State)
- {
- switch (CallbackID)
- {
- case HAL_I2S_TX_COMPLETE_CB_ID :
- hi2s->TxCpltCallback = pCallback;
- break;
-
- case HAL_I2S_RX_COMPLETE_CB_ID :
- hi2s->RxCpltCallback = pCallback;
- break;
-
- case HAL_I2S_TX_HALF_COMPLETE_CB_ID :
- hi2s->TxHalfCpltCallback = pCallback;
- break;
-
- case HAL_I2S_RX_HALF_COMPLETE_CB_ID :
- hi2s->RxHalfCpltCallback = pCallback;
- break;
-
- case HAL_I2S_ERROR_CB_ID :
- hi2s->ErrorCallback = pCallback;
- break;
-
- case HAL_I2S_MSPINIT_CB_ID :
- hi2s->MspInitCallback = pCallback;
- break;
-
- case HAL_I2S_MSPDEINIT_CB_ID :
- hi2s->MspDeInitCallback = pCallback;
- break;
-
- default :
- /* Update the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
-
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else if (HAL_I2S_STATE_RESET == hi2s->State)
- {
- switch (CallbackID)
- {
- case HAL_I2S_MSPINIT_CB_ID :
- hi2s->MspInitCallback = pCallback;
- break;
-
- case HAL_I2S_MSPDEINIT_CB_ID :
- hi2s->MspDeInitCallback = pCallback;
- break;
-
- default :
- /* Update the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
-
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hi2s);
- return status;
-}
-
-/**
- * @brief Unregister an I2S Callback
- * I2S callback is redirected to the weak predefined callback
- * @param hi2s Pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for the specified I2S.
- * @param CallbackID ID of the callback to be unregistered
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_UnRegisterCallback(I2S_HandleTypeDef *hi2s, HAL_I2S_CallbackIDTypeDef CallbackID)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Process locked */
- __HAL_LOCK(hi2s);
-
- if (HAL_I2S_STATE_READY == hi2s->State)
- {
- switch (CallbackID)
- {
- case HAL_I2S_TX_COMPLETE_CB_ID :
- hi2s->TxCpltCallback = HAL_I2S_TxCpltCallback; /* Legacy weak TxCpltCallback */
- break;
-
- case HAL_I2S_RX_COMPLETE_CB_ID :
- hi2s->RxCpltCallback = HAL_I2S_RxCpltCallback; /* Legacy weak RxCpltCallback */
- break;
-
- case HAL_I2S_TX_HALF_COMPLETE_CB_ID :
- hi2s->TxHalfCpltCallback = HAL_I2S_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
- break;
-
- case HAL_I2S_RX_HALF_COMPLETE_CB_ID :
- hi2s->RxHalfCpltCallback = HAL_I2S_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
- break;
-
- case HAL_I2S_ERROR_CB_ID :
- hi2s->ErrorCallback = HAL_I2S_ErrorCallback; /* Legacy weak ErrorCallback */
- break;
-
- case HAL_I2S_MSPINIT_CB_ID :
- hi2s->MspInitCallback = HAL_I2S_MspInit; /* Legacy weak MspInit */
- break;
-
- case HAL_I2S_MSPDEINIT_CB_ID :
- hi2s->MspDeInitCallback = HAL_I2S_MspDeInit; /* Legacy weak MspDeInit */
- break;
-
- default :
- /* Update the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
-
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else if (HAL_I2S_STATE_RESET == hi2s->State)
- {
- switch (CallbackID)
- {
- case HAL_I2S_MSPINIT_CB_ID :
- hi2s->MspInitCallback = HAL_I2S_MspInit; /* Legacy weak MspInit */
- break;
-
- case HAL_I2S_MSPDEINIT_CB_ID :
- hi2s->MspDeInitCallback = HAL_I2S_MspDeInit; /* Legacy weak MspDeInit */
- break;
-
- default :
- /* Update the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
-
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_INVALID_CALLBACK);
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(hi2s);
- return status;
-}
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
-/**
- * @}
- */
-
-/** @defgroup I2S_Exported_Functions_Group2 IO operation functions
- * @brief Data transfers functions
- *
-@verbatim
- ===============================================================================
- ##### IO operation functions #####
- ===============================================================================
- [..]
- This subsection provides a set of functions allowing to manage the I2S data
- transfers.
-
- (#) There are two modes of transfer:
- (++) Blocking mode : The communication is performed in the polling mode.
- The status of all data processing is returned by the same function
- after finishing transfer.
- (++) No-Blocking mode : The communication is performed using Interrupts
- or DMA. These functions return the status of the transfer startup.
- The end of the data processing will be indicated through the
- dedicated I2S IRQ when using Interrupt mode or the DMA IRQ when
- using DMA mode.
-
- (#) Blocking mode functions are :
- (++) HAL_I2S_Transmit()
- (++) HAL_I2S_Receive()
-
- (#) No-Blocking mode functions with Interrupt are :
- (++) HAL_I2S_Transmit_IT()
- (++) HAL_I2S_Receive_IT()
-
- (#) No-Blocking mode functions with DMA are :
- (++) HAL_I2S_Transmit_DMA()
- (++) HAL_I2S_Receive_DMA()
-
- (#) A set of Transfer Complete Callbacks are provided in non Blocking mode:
- (++) HAL_I2S_TxCpltCallback()
- (++) HAL_I2S_RxCpltCallback()
- (++) HAL_I2S_ErrorCallback()
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Transmit an amount of data in blocking mode
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @param pData a 16-bit pointer to data buffer.
- * @param Size number of data sample to be sent:
- * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S
- * configuration phase, the Size parameter means the number of 16-bit data length
- * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected
- * the Size parameter means the number of 24-bit or 32-bit data length.
- * @param Timeout Timeout duration
- * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization
- * between Master and Slave(example: audio streaming).
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_Transmit(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout)
-{
- uint32_t tmpreg_cfgr;
-
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(hi2s);
-
- if (hi2s->State != HAL_I2S_STATE_READY)
- {
- __HAL_UNLOCK(hi2s);
- return HAL_BUSY;
- }
-
- /* Set state and reset error code */
- hi2s->State = HAL_I2S_STATE_BUSY_TX;
- hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
- hi2s->pTxBuffPtr = pData;
-
- tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
-
- if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
- {
- hi2s->TxXferSize = (Size << 1U);
- hi2s->TxXferCount = (Size << 1U);
- }
- else
- {
- hi2s->TxXferSize = Size;
- hi2s->TxXferCount = Size;
- }
-
- tmpreg_cfgr = hi2s->Instance->I2SCFGR;
-
- /* Check if the I2S is already enabled */
- if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE)
- {
- /* Enable I2S peripheral */
- __HAL_I2S_ENABLE(hi2s);
- }
-
- /* Wait until TXE flag is set */
- if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXE, SET, Timeout) != HAL_OK)
- {
- /* Set the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT);
- hi2s->State = HAL_I2S_STATE_READY;
- __HAL_UNLOCK(hi2s);
- return HAL_ERROR;
- }
-
- while (hi2s->TxXferCount > 0U)
- {
- hi2s->Instance->DR = (*hi2s->pTxBuffPtr);
- hi2s->pTxBuffPtr++;
- hi2s->TxXferCount--;
-
- /* Wait until TXE flag is set */
- if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXE, SET, Timeout) != HAL_OK)
- {
- /* Set the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT);
- hi2s->State = HAL_I2S_STATE_READY;
- __HAL_UNLOCK(hi2s);
- return HAL_ERROR;
- }
-
- /* Check if an underrun occurs */
- if (__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_UDR) == SET)
- {
- /* Clear underrun flag */
- __HAL_I2S_CLEAR_UDRFLAG(hi2s);
-
- /* Set the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_UDR);
- }
- }
-
- /* Check if Slave mode is selected */
- if (((tmpreg_cfgr & SPI_I2SCFGR_I2SCFG) == I2S_MODE_SLAVE_TX)
- || ((tmpreg_cfgr & SPI_I2SCFGR_I2SCFG) == I2S_MODE_SLAVE_RX))
- {
- /* Wait until Busy flag is reset */
- if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_BSY, RESET, Timeout) != HAL_OK)
- {
- /* Set the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT);
- hi2s->State = HAL_I2S_STATE_READY;
- __HAL_UNLOCK(hi2s);
- return HAL_ERROR;
- }
- }
-
- hi2s->State = HAL_I2S_STATE_READY;
- __HAL_UNLOCK(hi2s);
- return HAL_OK;
-}
-
-/**
- * @brief Receive an amount of data in blocking mode
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @param pData a 16-bit pointer to data buffer.
- * @param Size number of data sample to be sent:
- * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S
- * configuration phase, the Size parameter means the number of 16-bit data length
- * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected
- * the Size parameter means the number of 24-bit or 32-bit data length.
- * @param Timeout Timeout duration
- * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization
- * between Master and Slave(example: audio streaming).
- * @note In I2S Master Receiver mode, just after enabling the peripheral the clock will be generate
- * in continuous way and as the I2S is not disabled at the end of the I2S transaction.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_Receive(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size, uint32_t Timeout)
-{
- uint32_t tmpreg_cfgr;
-
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(hi2s);
-
- if (hi2s->State != HAL_I2S_STATE_READY)
- {
- __HAL_UNLOCK(hi2s);
- return HAL_BUSY;
- }
-
- /* Set state and reset error code */
- hi2s->State = HAL_I2S_STATE_BUSY_RX;
- hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
- hi2s->pRxBuffPtr = pData;
-
- tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
-
- if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
- {
- hi2s->RxXferSize = (Size << 1U);
- hi2s->RxXferCount = (Size << 1U);
- }
- else
- {
- hi2s->RxXferSize = Size;
- hi2s->RxXferCount = Size;
- }
-
- /* Check if the I2S is already enabled */
- if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE)
- {
- /* Enable I2S peripheral */
- __HAL_I2S_ENABLE(hi2s);
- }
-
- /* Check if Master Receiver mode is selected */
- if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_MASTER_RX)
- {
- /* Clear the Overrun Flag by a read operation on the SPI_DR register followed by a read
- access to the SPI_SR register. */
- __HAL_I2S_CLEAR_OVRFLAG(hi2s);
- }
-
- /* Receive data */
- while (hi2s->RxXferCount > 0U)
- {
- /* Wait until RXNE flag is set */
- if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_RXNE, SET, Timeout) != HAL_OK)
- {
- /* Set the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT);
- hi2s->State = HAL_I2S_STATE_READY;
- __HAL_UNLOCK(hi2s);
- return HAL_ERROR;
- }
-
- (*hi2s->pRxBuffPtr) = (uint16_t)hi2s->Instance->DR;
- hi2s->pRxBuffPtr++;
- hi2s->RxXferCount--;
-
- /* Check if an overrun occurs */
- if (__HAL_I2S_GET_FLAG(hi2s, I2S_FLAG_OVR) == SET)
- {
- /* Clear overrun flag */
- __HAL_I2S_CLEAR_OVRFLAG(hi2s);
-
- /* Set the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_OVR);
- }
- }
-
- hi2s->State = HAL_I2S_STATE_READY;
- __HAL_UNLOCK(hi2s);
- return HAL_OK;
-}
-
-/**
- * @brief Transmit an amount of data in non-blocking mode with Interrupt
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @param pData a 16-bit pointer to data buffer.
- * @param Size number of data sample to be sent:
- * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S
- * configuration phase, the Size parameter means the number of 16-bit data length
- * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected
- * the Size parameter means the number of 24-bit or 32-bit data length.
- * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization
- * between Master and Slave(example: audio streaming).
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_Transmit_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
-{
- uint32_t tmpreg_cfgr;
-
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(hi2s);
-
- if (hi2s->State != HAL_I2S_STATE_READY)
- {
- __HAL_UNLOCK(hi2s);
- return HAL_BUSY;
- }
-
- /* Set state and reset error code */
- hi2s->State = HAL_I2S_STATE_BUSY_TX;
- hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
- hi2s->pTxBuffPtr = pData;
-
- tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
-
- if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
- {
- hi2s->TxXferSize = (Size << 1U);
- hi2s->TxXferCount = (Size << 1U);
- }
- else
- {
- hi2s->TxXferSize = Size;
- hi2s->TxXferCount = Size;
- }
-
- /* Enable TXE and ERR interrupt */
- __HAL_I2S_ENABLE_IT(hi2s, (I2S_IT_TXE | I2S_IT_ERR));
-
- /* Check if the I2S is already enabled */
- if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE)
- {
- /* Enable I2S peripheral */
- __HAL_I2S_ENABLE(hi2s);
- }
-
- __HAL_UNLOCK(hi2s);
- return HAL_OK;
-}
-
-/**
- * @brief Receive an amount of data in non-blocking mode with Interrupt
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @param pData a 16-bit pointer to the Receive data buffer.
- * @param Size number of data sample to be sent:
- * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S
- * configuration phase, the Size parameter means the number of 16-bit data length
- * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected
- * the Size parameter means the number of 24-bit or 32-bit data length.
- * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization
- * between Master and Slave(example: audio streaming).
- * @note It is recommended to use DMA for the I2S receiver to avoid de-synchronization
- * between Master and Slave otherwise the I2S interrupt should be optimized.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_Receive_IT(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
-{
- uint32_t tmpreg_cfgr;
-
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(hi2s);
-
- if (hi2s->State != HAL_I2S_STATE_READY)
- {
- __HAL_UNLOCK(hi2s);
- return HAL_BUSY;
- }
-
- /* Set state and reset error code */
- hi2s->State = HAL_I2S_STATE_BUSY_RX;
- hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
- hi2s->pRxBuffPtr = pData;
-
- tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
-
- if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
- {
- hi2s->RxXferSize = (Size << 1U);
- hi2s->RxXferCount = (Size << 1U);
- }
- else
- {
- hi2s->RxXferSize = Size;
- hi2s->RxXferCount = Size;
- }
-
- /* Enable RXNE and ERR interrupt */
- __HAL_I2S_ENABLE_IT(hi2s, (I2S_IT_RXNE | I2S_IT_ERR));
-
- /* Check if the I2S is already enabled */
- if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SE) != SPI_I2SCFGR_I2SE)
- {
- /* Enable I2S peripheral */
- __HAL_I2S_ENABLE(hi2s);
- }
-
- __HAL_UNLOCK(hi2s);
- return HAL_OK;
-}
-
-/**
- * @brief Transmit an amount of data in non-blocking mode with DMA
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @param pData a 16-bit pointer to the Transmit data buffer.
- * @param Size number of data sample to be sent:
- * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S
- * configuration phase, the Size parameter means the number of 16-bit data length
- * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected
- * the Size parameter means the number of 24-bit or 32-bit data length.
- * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization
- * between Master and Slave(example: audio streaming).
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_Transmit_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
-{
- uint32_t tmpreg_cfgr;
-
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(hi2s);
-
- if (hi2s->State != HAL_I2S_STATE_READY)
- {
- __HAL_UNLOCK(hi2s);
- return HAL_BUSY;
- }
-
- /* Set state and reset error code */
- hi2s->State = HAL_I2S_STATE_BUSY_TX;
- hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
- hi2s->pTxBuffPtr = pData;
-
- tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
-
- if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
- {
- hi2s->TxXferSize = (Size << 1U);
- hi2s->TxXferCount = (Size << 1U);
- }
- else
- {
- hi2s->TxXferSize = Size;
- hi2s->TxXferCount = Size;
- }
-
- /* Set the I2S Tx DMA Half transfer complete callback */
- hi2s->hdmatx->XferHalfCpltCallback = I2S_DMATxHalfCplt;
-
- /* Set the I2S Tx DMA transfer complete callback */
- hi2s->hdmatx->XferCpltCallback = I2S_DMATxCplt;
-
- /* Set the DMA error callback */
- hi2s->hdmatx->XferErrorCallback = I2S_DMAError;
-
- /* Enable the Tx DMA Stream/Channel */
- if (HAL_OK != HAL_DMA_Start_IT(hi2s->hdmatx,
- (uint32_t)hi2s->pTxBuffPtr,
- (uint32_t)&hi2s->Instance->DR,
- hi2s->TxXferSize))
- {
- /* Update SPI error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA);
- hi2s->State = HAL_I2S_STATE_READY;
-
- __HAL_UNLOCK(hi2s);
- return HAL_ERROR;
- }
-
- /* Check if the I2S is already enabled */
- if (HAL_IS_BIT_CLR(hi2s->Instance->I2SCFGR, SPI_I2SCFGR_I2SE))
- {
- /* Enable I2S peripheral */
- __HAL_I2S_ENABLE(hi2s);
- }
-
- /* Check if the I2S Tx request is already enabled */
- if (HAL_IS_BIT_CLR(hi2s->Instance->CR2, SPI_CR2_TXDMAEN))
- {
- /* Enable Tx DMA Request */
- SET_BIT(hi2s->Instance->CR2, SPI_CR2_TXDMAEN);
- }
-
- __HAL_UNLOCK(hi2s);
- return HAL_OK;
-}
-
-/**
- * @brief Receive an amount of data in non-blocking mode with DMA
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @param pData a 16-bit pointer to the Receive data buffer.
- * @param Size number of data sample to be sent:
- * @note When a 16-bit data frame or a 16-bit data frame extended is selected during the I2S
- * configuration phase, the Size parameter means the number of 16-bit data length
- * in the transaction and when a 24-bit data frame or a 32-bit data frame is selected
- * the Size parameter means the number of 24-bit or 32-bit data length.
- * @note The I2S is kept enabled at the end of transaction to avoid the clock de-synchronization
- * between Master and Slave(example: audio streaming).
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_Receive_DMA(I2S_HandleTypeDef *hi2s, uint16_t *pData, uint16_t Size)
-{
- uint32_t tmpreg_cfgr;
-
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(hi2s);
-
- if (hi2s->State != HAL_I2S_STATE_READY)
- {
- __HAL_UNLOCK(hi2s);
- return HAL_BUSY;
- }
-
- /* Set state and reset error code */
- hi2s->State = HAL_I2S_STATE_BUSY_RX;
- hi2s->ErrorCode = HAL_I2S_ERROR_NONE;
- hi2s->pRxBuffPtr = pData;
-
- tmpreg_cfgr = hi2s->Instance->I2SCFGR & (SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN);
-
- if ((tmpreg_cfgr == I2S_DATAFORMAT_24B) || (tmpreg_cfgr == I2S_DATAFORMAT_32B))
- {
- hi2s->RxXferSize = (Size << 1U);
- hi2s->RxXferCount = (Size << 1U);
- }
- else
- {
- hi2s->RxXferSize = Size;
- hi2s->RxXferCount = Size;
- }
-
- /* Set the I2S Rx DMA Half transfer complete callback */
- hi2s->hdmarx->XferHalfCpltCallback = I2S_DMARxHalfCplt;
-
- /* Set the I2S Rx DMA transfer complete callback */
- hi2s->hdmarx->XferCpltCallback = I2S_DMARxCplt;
-
- /* Set the DMA error callback */
- hi2s->hdmarx->XferErrorCallback = I2S_DMAError;
-
- /* Check if Master Receiver mode is selected */
- if ((hi2s->Instance->I2SCFGR & SPI_I2SCFGR_I2SCFG) == I2S_MODE_MASTER_RX)
- {
- /* Clear the Overrun Flag by a read operation to the SPI_DR register followed by a read
- access to the SPI_SR register. */
- __HAL_I2S_CLEAR_OVRFLAG(hi2s);
- }
-
- /* Enable the Rx DMA Stream/Channel */
- if (HAL_OK != HAL_DMA_Start_IT(hi2s->hdmarx, (uint32_t)&hi2s->Instance->DR, (uint32_t)hi2s->pRxBuffPtr,
- hi2s->RxXferSize))
- {
- /* Update SPI error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA);
- hi2s->State = HAL_I2S_STATE_READY;
-
- __HAL_UNLOCK(hi2s);
- return HAL_ERROR;
- }
-
- /* Check if the I2S is already enabled */
- if (HAL_IS_BIT_CLR(hi2s->Instance->I2SCFGR, SPI_I2SCFGR_I2SE))
- {
- /* Enable I2S peripheral */
- __HAL_I2S_ENABLE(hi2s);
- }
-
- /* Check if the I2S Rx request is already enabled */
- if (HAL_IS_BIT_CLR(hi2s->Instance->CR2, SPI_CR2_RXDMAEN))
- {
- /* Enable Rx DMA Request */
- SET_BIT(hi2s->Instance->CR2, SPI_CR2_RXDMAEN);
- }
-
- __HAL_UNLOCK(hi2s);
- return HAL_OK;
-}
-
-/**
- * @brief Pauses the audio DMA Stream/Channel playing from the Media.
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_DMAPause(I2S_HandleTypeDef *hi2s)
-{
- /* Process Locked */
- __HAL_LOCK(hi2s);
-
- if (hi2s->State == HAL_I2S_STATE_BUSY_TX)
- {
- /* Disable the I2S DMA Tx request */
- CLEAR_BIT(hi2s->Instance->CR2, SPI_CR2_TXDMAEN);
- }
- else if (hi2s->State == HAL_I2S_STATE_BUSY_RX)
- {
- /* Disable the I2S DMA Rx request */
- CLEAR_BIT(hi2s->Instance->CR2, SPI_CR2_RXDMAEN);
- }
- else
- {
- /* nothing to do */
- }
-
- /* Process Unlocked */
- __HAL_UNLOCK(hi2s);
-
- return HAL_OK;
-}
-
-/**
- * @brief Resumes the audio DMA Stream/Channel playing from the Media.
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_DMAResume(I2S_HandleTypeDef *hi2s)
-{
- /* Process Locked */
- __HAL_LOCK(hi2s);
-
- if (hi2s->State == HAL_I2S_STATE_BUSY_TX)
- {
- /* Enable the I2S DMA Tx request */
- SET_BIT(hi2s->Instance->CR2, SPI_CR2_TXDMAEN);
- }
- else if (hi2s->State == HAL_I2S_STATE_BUSY_RX)
- {
- /* Enable the I2S DMA Rx request */
- SET_BIT(hi2s->Instance->CR2, SPI_CR2_RXDMAEN);
- }
- else
- {
- /* nothing to do */
- }
-
- /* If the I2S peripheral is still not enabled, enable it */
- if (HAL_IS_BIT_CLR(hi2s->Instance->I2SCFGR, SPI_I2SCFGR_I2SE))
- {
- /* Enable I2S peripheral */
- __HAL_I2S_ENABLE(hi2s);
- }
-
- /* Process Unlocked */
- __HAL_UNLOCK(hi2s);
-
- return HAL_OK;
-}
-
-/**
- * @brief Stops the audio DMA Stream/Channel playing from the Media.
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_I2S_DMAStop(I2S_HandleTypeDef *hi2s)
-{
- HAL_StatusTypeDef errorcode = HAL_OK;
- /* The Lock is not implemented on this API to allow the user application
- to call the HAL SPI API under callbacks HAL_I2S_TxCpltCallback() or HAL_I2S_RxCpltCallback()
- when calling HAL_DMA_Abort() API the DMA TX or RX Transfer complete interrupt is generated
- and the correspond call back is executed HAL_I2S_TxCpltCallback() or HAL_I2S_RxCpltCallback()
- */
-
- if ((hi2s->Init.Mode == I2S_MODE_MASTER_TX) || (hi2s->Init.Mode == I2S_MODE_SLAVE_TX))
- {
- /* Abort the I2S DMA tx Stream/Channel */
- if (hi2s->hdmatx != NULL)
- {
- /* Disable the I2S DMA tx Stream/Channel */
- if (HAL_OK != HAL_DMA_Abort(hi2s->hdmatx))
- {
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA);
- errorcode = HAL_ERROR;
- }
- }
-
- /* Wait until TXE flag is set */
- if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_TXE, SET, I2S_TIMEOUT_FLAG) != HAL_OK)
- {
- /* Set the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT);
- hi2s->State = HAL_I2S_STATE_READY;
- errorcode = HAL_ERROR;
- }
-
- /* Wait until BSY flag is Reset */
- if (I2S_WaitFlagStateUntilTimeout(hi2s, I2S_FLAG_BSY, RESET, I2S_TIMEOUT_FLAG) != HAL_OK)
- {
- /* Set the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_TIMEOUT);
- hi2s->State = HAL_I2S_STATE_READY;
- errorcode = HAL_ERROR;
- }
-
- /* Disable I2S peripheral */
- __HAL_I2S_DISABLE(hi2s);
-
- /* Clear UDR flag */
- __HAL_I2S_CLEAR_UDRFLAG(hi2s);
-
- /* Disable the I2S Tx DMA requests */
- CLEAR_BIT(hi2s->Instance->CR2, SPI_CR2_TXDMAEN);
-
- }
-
- else if ((hi2s->Init.Mode == I2S_MODE_MASTER_RX) || (hi2s->Init.Mode == I2S_MODE_SLAVE_RX))
- {
- /* Abort the I2S DMA rx Stream/Channel */
- if (hi2s->hdmarx != NULL)
- {
- /* Disable the I2S DMA rx Stream/Channel */
- if (HAL_OK != HAL_DMA_Abort(hi2s->hdmarx))
- {
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA);
- errorcode = HAL_ERROR;
- }
- }
-
- /* Disable I2S peripheral */
- __HAL_I2S_DISABLE(hi2s);
-
- /* Clear OVR flag */
- __HAL_I2S_CLEAR_OVRFLAG(hi2s);
-
- /* Disable the I2S Rx DMA request */
- CLEAR_BIT(hi2s->Instance->CR2, SPI_CR2_RXDMAEN);
-
- if (hi2s->Init.Mode == I2S_MODE_SLAVE_RX)
- {
- /* Set the error code */
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_BUSY_LINE_RX);
-
- /* Set the I2S State ready */
- hi2s->State = HAL_I2S_STATE_READY;
- errorcode = HAL_ERROR;
- }
- else
- {
- /* Read DR to Flush RX Data */
- READ_REG((hi2s->Instance)->DR);
- }
- }
-
- hi2s->State = HAL_I2S_STATE_READY;
-
- return errorcode;
-}
-
-/**
- * @brief This function handles I2S interrupt request.
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval None
- */
-void HAL_I2S_IRQHandler(I2S_HandleTypeDef *hi2s)
-{
- uint32_t itsource = hi2s->Instance->CR2;
- uint32_t itflag = hi2s->Instance->SR;
-
- /* I2S in mode Receiver ------------------------------------------------*/
- if ((I2S_CHECK_FLAG(itflag, I2S_FLAG_OVR) == RESET) &&
- (I2S_CHECK_FLAG(itflag, I2S_FLAG_RXNE) != RESET) && (I2S_CHECK_IT_SOURCE(itsource, I2S_IT_RXNE) != RESET))
- {
- I2S_Receive_IT(hi2s);
- return;
- }
-
- /* I2S in mode Tramitter -----------------------------------------------*/
- if ((I2S_CHECK_FLAG(itflag, I2S_FLAG_TXE) != RESET) && (I2S_CHECK_IT_SOURCE(itsource, I2S_IT_TXE) != RESET))
- {
- I2S_Transmit_IT(hi2s);
- return;
- }
-
- /* I2S interrupt error -------------------------------------------------*/
- if (I2S_CHECK_IT_SOURCE(itsource, I2S_IT_ERR) != RESET)
- {
- /* I2S Overrun error interrupt occurred ---------------------------------*/
- if (I2S_CHECK_FLAG(itflag, I2S_FLAG_OVR) != RESET)
- {
- /* Disable RXNE and ERR interrupt */
- __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_RXNE | I2S_IT_ERR));
-
- /* Set the error code and execute error callback*/
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_OVR);
- }
-
- /* I2S Underrun error interrupt occurred --------------------------------*/
- if (I2S_CHECK_FLAG(itflag, I2S_FLAG_UDR) != RESET)
- {
- /* Disable TXE and ERR interrupt */
- __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXE | I2S_IT_ERR));
-
- /* Set the error code and execute error callback*/
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_UDR);
- }
-
- /* Set the I2S State ready */
- hi2s->State = HAL_I2S_STATE_READY;
-
- /* Call user error callback */
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
- hi2s->ErrorCallback(hi2s);
-#else
- HAL_I2S_ErrorCallback(hi2s);
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
- }
-}
-
-/**
- * @brief Tx Transfer Half completed callbacks
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval None
- */
-__weak void HAL_I2S_TxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hi2s);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_I2S_TxHalfCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Tx Transfer completed callbacks
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval None
- */
-__weak void HAL_I2S_TxCpltCallback(I2S_HandleTypeDef *hi2s)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hi2s);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_I2S_TxCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Rx Transfer half completed callbacks
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval None
- */
-__weak void HAL_I2S_RxHalfCpltCallback(I2S_HandleTypeDef *hi2s)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hi2s);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_I2S_RxHalfCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Rx Transfer completed callbacks
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval None
- */
-__weak void HAL_I2S_RxCpltCallback(I2S_HandleTypeDef *hi2s)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hi2s);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_I2S_RxCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief I2S error callbacks
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval None
- */
-__weak void HAL_I2S_ErrorCallback(I2S_HandleTypeDef *hi2s)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hi2s);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_I2S_ErrorCallback could be implemented in the user file
- */
-}
-
-/**
- * @}
- */
-
-/** @defgroup I2S_Exported_Functions_Group3 Peripheral State and Errors functions
- * @brief Peripheral State functions
- *
-@verbatim
- ===============================================================================
- ##### Peripheral State and Errors functions #####
- ===============================================================================
- [..]
- This subsection permits to get in run-time the status of the peripheral
- and the data flow.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Return the I2S state
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval HAL state
- */
-HAL_I2S_StateTypeDef HAL_I2S_GetState(I2S_HandleTypeDef *hi2s)
-{
- return hi2s->State;
-}
-
-/**
- * @brief Return the I2S error code
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval I2S Error Code
- */
-uint32_t HAL_I2S_GetError(I2S_HandleTypeDef *hi2s)
-{
- return hi2s->ErrorCode;
-}
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/** @addtogroup I2S_Private_Functions I2S Private Functions
- * @{
- */
-/**
- * @brief DMA I2S transmit process complete callback
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void I2S_DMATxCplt(DMA_HandleTypeDef *hdma)
-{
- I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; /* Derogation MISRAC2012-Rule-11.5 */
-
- /* if DMA is configured in DMA_NORMAL Mode */
- if (hdma->Init.Mode == DMA_NORMAL)
- {
- /* Disable Tx DMA Request */
- CLEAR_BIT(hi2s->Instance->CR2, SPI_CR2_TXDMAEN);
-
- hi2s->TxXferCount = 0U;
- hi2s->State = HAL_I2S_STATE_READY;
- }
- /* Call user Tx complete callback */
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
- hi2s->TxCpltCallback(hi2s);
-#else
- HAL_I2S_TxCpltCallback(hi2s);
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA I2S transmit process half complete callback
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void I2S_DMATxHalfCplt(DMA_HandleTypeDef *hdma)
-{
- I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; /* Derogation MISRAC2012-Rule-11.5 */
-
- /* Call user Tx half complete callback */
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
- hi2s->TxHalfCpltCallback(hi2s);
-#else
- HAL_I2S_TxHalfCpltCallback(hi2s);
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA I2S receive process complete callback
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void I2S_DMARxCplt(DMA_HandleTypeDef *hdma)
-{
- I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; /* Derogation MISRAC2012-Rule-11.5 */
-
- /* if DMA is configured in DMA_NORMAL Mode */
- if (hdma->Init.Mode == DMA_NORMAL)
- {
- /* Disable Rx DMA Request */
- CLEAR_BIT(hi2s->Instance->CR2, SPI_CR2_RXDMAEN);
- hi2s->RxXferCount = 0U;
- hi2s->State = HAL_I2S_STATE_READY;
- }
- /* Call user Rx complete callback */
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
- hi2s->RxCpltCallback(hi2s);
-#else
- HAL_I2S_RxCpltCallback(hi2s);
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA I2S receive process half complete callback
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void I2S_DMARxHalfCplt(DMA_HandleTypeDef *hdma)
-{
- I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; /* Derogation MISRAC2012-Rule-11.5 */
-
- /* Call user Rx half complete callback */
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
- hi2s->RxHalfCpltCallback(hi2s);
-#else
- HAL_I2S_RxHalfCpltCallback(hi2s);
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA I2S communication error callback
- * @param hdma pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void I2S_DMAError(DMA_HandleTypeDef *hdma)
-{
- I2S_HandleTypeDef *hi2s = (I2S_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent; /* Derogation MISRAC2012-Rule-11.5 */
-
- /* Disable Rx and Tx DMA Request */
- CLEAR_BIT(hi2s->Instance->CR2, (SPI_CR2_RXDMAEN | SPI_CR2_TXDMAEN));
- hi2s->TxXferCount = 0U;
- hi2s->RxXferCount = 0U;
-
- hi2s->State = HAL_I2S_STATE_READY;
-
- /* Set the error code and execute error callback*/
- SET_BIT(hi2s->ErrorCode, HAL_I2S_ERROR_DMA);
- /* Call user error callback */
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
- hi2s->ErrorCallback(hi2s);
-#else
- HAL_I2S_ErrorCallback(hi2s);
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief Transmit an amount of data in non-blocking mode with Interrupt
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval None
- */
-static void I2S_Transmit_IT(I2S_HandleTypeDef *hi2s)
-{
- /* Transmit data */
- hi2s->Instance->DR = (*hi2s->pTxBuffPtr);
- hi2s->pTxBuffPtr++;
- hi2s->TxXferCount--;
-
- if (hi2s->TxXferCount == 0U)
- {
- /* Disable TXE and ERR interrupt */
- __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_TXE | I2S_IT_ERR));
-
- hi2s->State = HAL_I2S_STATE_READY;
- /* Call user Tx complete callback */
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
- hi2s->TxCpltCallback(hi2s);
-#else
- HAL_I2S_TxCpltCallback(hi2s);
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
- }
-}
-
-/**
- * @brief Receive an amount of data in non-blocking mode with Interrupt
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @retval None
- */
-static void I2S_Receive_IT(I2S_HandleTypeDef *hi2s)
-{
- /* Receive data */
- (*hi2s->pRxBuffPtr) = (uint16_t)hi2s->Instance->DR;
- hi2s->pRxBuffPtr++;
- hi2s->RxXferCount--;
-
- if (hi2s->RxXferCount == 0U)
- {
- /* Disable RXNE and ERR interrupt */
- __HAL_I2S_DISABLE_IT(hi2s, (I2S_IT_RXNE | I2S_IT_ERR));
-
- hi2s->State = HAL_I2S_STATE_READY;
- /* Call user Rx complete callback */
-#if (USE_HAL_I2S_REGISTER_CALLBACKS == 1U)
- hi2s->RxCpltCallback(hi2s);
-#else
- HAL_I2S_RxCpltCallback(hi2s);
-#endif /* USE_HAL_I2S_REGISTER_CALLBACKS */
- }
-}
-
-/**
- * @brief This function handles I2S Communication Timeout.
- * @param hi2s pointer to a I2S_HandleTypeDef structure that contains
- * the configuration information for I2S module
- * @param Flag Flag checked
- * @param State Value of the flag expected
- * @param Timeout Duration of the timeout
- * @retval HAL status
- */
-static HAL_StatusTypeDef I2S_WaitFlagStateUntilTimeout(I2S_HandleTypeDef *hi2s, uint32_t Flag, FlagStatus State,
- uint32_t Timeout)
-{
- uint32_t tickstart;
-
- /* Get tick */
- tickstart = HAL_GetTick();
-
- /* Wait until flag is set to status*/
- while (((__HAL_I2S_GET_FLAG(hi2s, Flag)) ? SET : RESET) != State)
- {
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - tickstart) >= Timeout) || (Timeout == 0U))
- {
- /* Set the I2S State ready */
- hi2s->State = HAL_I2S_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hi2s);
-
- return HAL_TIMEOUT;
- }
- }
- }
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-#endif /* SPI_I2S_SUPPORT */
-
-#endif /* HAL_I2S_MODULE_ENABLED */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_irda.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_irda.c
deleted file mode 100644
index dc3048a70cd..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_irda.c
+++ /dev/null
@@ -1,2658 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_irda.c
- * @author MCD Application Team
- * @brief IRDA HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the IrDA SIR ENDEC block (IrDA):
- * + Initialization and de-initialization functions
- * + IO operation functions
- * + Peripheral Control functions
- * + Peripheral State and Errors functions
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- The IRDA HAL driver can be used as follows:
-
- (#) Declare a IRDA_HandleTypeDef handle structure (eg. IRDA_HandleTypeDef hirda).
- (#) Initialize the IRDA low level resources by implementing the HAL_IRDA_MspInit() API:
- (##) Enable the USARTx interface clock.
- (##) IRDA pins configuration:
- (+++) Enable the clock for the IRDA GPIOs.
- (+++) Configure IRDA pins as alternate function pull-up.
- (##) NVIC configuration if you need to use interrupt process (HAL_IRDA_Transmit_IT()
- and HAL_IRDA_Receive_IT() APIs):
- (+++) Configure the USARTx interrupt priority.
- (+++) Enable the NVIC USART IRQ handle.
- (##) DMA Configuration if you need to use DMA process (HAL_IRDA_Transmit_DMA()
- and HAL_IRDA_Receive_DMA() APIs):
- (+++) Declare a DMA handle structure for the Tx/Rx channel.
- (+++) Enable the DMAx interface clock.
- (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters.
- (+++) Configure the DMA Tx/Rx channel.
- (+++) Associate the initialized DMA handle to the IRDA DMA Tx/Rx handle.
- (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx channel.
- (+++) Configure the IRDAx interrupt priority and enable the NVIC USART IRQ handle
- (used for last byte sending completion detection in DMA non circular mode)
-
- (#) Program the Baud Rate, Word Length, Parity, IrDA Mode, Prescaler
- and Mode(Receiver/Transmitter) in the hirda Init structure.
-
- (#) Initialize the IRDA registers by calling the HAL_IRDA_Init() API:
- (++) This API configures also the low level Hardware GPIO, CLOCK, CORTEX...etc)
- by calling the customized HAL_IRDA_MspInit() API.
-
- -@@- The specific IRDA interrupts (Transmission complete interrupt,
- RXNE interrupt and Error Interrupts) will be managed using the macros
- __HAL_IRDA_ENABLE_IT() and __HAL_IRDA_DISABLE_IT() inside the transmit and receive process.
-
- (#) Three operation modes are available within this driver :
-
- *** Polling mode IO operation ***
- =================================
- [..]
- (+) Send an amount of data in blocking mode using HAL_IRDA_Transmit()
- (+) Receive an amount of data in blocking mode using HAL_IRDA_Receive()
-
- *** Interrupt mode IO operation ***
- ===================================
- [..]
- (+) Send an amount of data in non blocking mode using HAL_IRDA_Transmit_IT()
- (+) At transmission end of transfer HAL_IRDA_TxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_IRDA_TxCpltCallback
- (+) Receive an amount of data in non blocking mode using HAL_IRDA_Receive_IT()
- (+) At reception end of transfer HAL_IRDA_RxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_IRDA_RxCpltCallback
- (+) In case of transfer Error, HAL_IRDA_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer HAL_IRDA_ErrorCallback
-
- *** DMA mode IO operation ***
- =============================
- [..]
- (+) Send an amount of data in non blocking mode (DMA) using HAL_IRDA_Transmit_DMA()
- (+) At transmission end of half transfer HAL_IRDA_TxHalfCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_IRDA_TxHalfCpltCallback
- (+) At transmission end of transfer HAL_IRDA_TxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_IRDA_TxCpltCallback
- (+) Receive an amount of data in non blocking mode (DMA) using HAL_IRDA_Receive_DMA()
- (+) At reception end of half transfer HAL_IRDA_RxHalfCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_IRDA_RxHalfCpltCallback
- (+) At reception end of transfer HAL_IRDA_RxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_IRDA_RxCpltCallback
- (+) In case of transfer Error, HAL_IRDA_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer HAL_IRDA_ErrorCallback
- (+) Pause the DMA Transfer using HAL_IRDA_DMAPause()
- (+) Resume the DMA Transfer using HAL_IRDA_DMAResume()
- (+) Stop the DMA Transfer using HAL_IRDA_DMAStop()
-
- *** IRDA HAL driver macros list ***
- ===================================
- [..]
- Below the list of most used macros in IRDA HAL driver.
-
- (+) __HAL_IRDA_ENABLE: Enable the IRDA peripheral
- (+) __HAL_IRDA_DISABLE: Disable the IRDA peripheral
- (+) __HAL_IRDA_GET_FLAG : Check whether the specified IRDA flag is set or not
- (+) __HAL_IRDA_CLEAR_FLAG : Clear the specified IRDA pending flag
- (+) __HAL_IRDA_ENABLE_IT: Enable the specified IRDA interrupt
- (+) __HAL_IRDA_DISABLE_IT: Disable the specified IRDA interrupt
- (+) __HAL_IRDA_GET_IT_SOURCE: Check whether the specified IRDA interrupt has occurred or not
-
- [..]
- (@) You can refer to the IRDA HAL driver header file for more useful macros
-
- ##### Callback registration #####
- ==================================
-
- [..]
- The compilation define USE_HAL_IRDA_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
-
- [..]
- Use Function @ref HAL_IRDA_RegisterCallback() to register a user callback.
- Function @ref HAL_IRDA_RegisterCallback() allows to register following callbacks:
- (+) TxHalfCpltCallback : Tx Half Complete Callback.
- (+) TxCpltCallback : Tx Complete Callback.
- (+) RxHalfCpltCallback : Rx Half Complete Callback.
- (+) RxCpltCallback : Rx Complete Callback.
- (+) ErrorCallback : Error Callback.
- (+) AbortCpltCallback : Abort Complete Callback.
- (+) AbortTransmitCpltCallback : Abort Transmit Complete Callback.
- (+) AbortReceiveCpltCallback : Abort Receive Complete Callback.
- (+) MspInitCallback : IRDA MspInit.
- (+) MspDeInitCallback : IRDA MspDeInit.
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
-
- [..]
- Use function @ref HAL_IRDA_UnRegisterCallback() to reset a callback to the default
- weak (surcharged) function.
- @ref HAL_IRDA_UnRegisterCallback() takes as parameters the HAL peripheral handle,
- and the Callback ID.
- This function allows to reset following callbacks:
- (+) TxHalfCpltCallback : Tx Half Complete Callback.
- (+) TxCpltCallback : Tx Complete Callback.
- (+) RxHalfCpltCallback : Rx Half Complete Callback.
- (+) RxCpltCallback : Rx Complete Callback.
- (+) ErrorCallback : Error Callback.
- (+) AbortCpltCallback : Abort Complete Callback.
- (+) AbortTransmitCpltCallback : Abort Transmit Complete Callback.
- (+) AbortReceiveCpltCallback : Abort Receive Complete Callback.
- (+) MspInitCallback : IRDA MspInit.
- (+) MspDeInitCallback : IRDA MspDeInit.
-
- [..]
- By default, after the @ref HAL_IRDA_Init() and when the state is HAL_IRDA_STATE_RESET
- all callbacks are set to the corresponding weak (surcharged) functions:
- examples @ref HAL_IRDA_TxCpltCallback(), @ref HAL_IRDA_RxHalfCpltCallback().
- Exception done for MspInit and MspDeInit functions that are respectively
- reset to the legacy weak (surcharged) functions in the @ref HAL_IRDA_Init()
- and @ref HAL_IRDA_DeInit() only when these callbacks are null (not registered beforehand).
- If not, MspInit or MspDeInit are not null, the @ref HAL_IRDA_Init() and @ref HAL_IRDA_DeInit()
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
-
- [..]
- Callbacks can be registered/unregistered in HAL_IRDA_STATE_READY state only.
- Exception done MspInit/MspDeInit that can be registered/unregistered
- in HAL_IRDA_STATE_READY or HAL_IRDA_STATE_RESET state, thus registered (user)
- MspInit/DeInit callbacks can be used during the Init/DeInit.
- In that case first register the MspInit/MspDeInit user callbacks
- using @ref HAL_IRDA_RegisterCallback() before calling @ref HAL_IRDA_DeInit()
- or @ref HAL_IRDA_Init() function.
-
- [..]
- When The compilation define USE_HAL_IRDA_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registration feature is not available
- and weak (surcharged) callbacks are used.
-
- @endverbatim
- [..]
- (@) Additional remark: If the parity is enabled, then the MSB bit of the data written
- in the data register is transmitted but is changed by the parity bit.
- Depending on the frame length defined by the M bit (8-bits or 9-bits),
- the possible IRDA frame formats are as listed in the following table:
- +-------------------------------------------------------------+
- | M bit | PCE bit | IRDA frame |
- |---------------------|---------------------------------------|
- | 0 | 0 | | SB | 8 bit data | 1 STB | |
- |---------|-----------|---------------------------------------|
- | 0 | 1 | | SB | 7 bit data | PB | 1 STB | |
- |---------|-----------|---------------------------------------|
- | 1 | 0 | | SB | 9 bit data | 1 STB | |
- |---------|-----------|---------------------------------------|
- | 1 | 1 | | SB | 8 bit data | PB | 1 STB | |
- +-------------------------------------------------------------+
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-#ifdef HAL_IWDG_MODULE_ENABLED
-/** @addtogroup IWDG
- * @brief IWDG HAL module driver.
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/** @defgroup IWDG_Private_Defines IWDG Private Defines
- * @{
- */
-/* Status register needs up to 5 LSI clock periods divided by the clock
- prescaler to be updated. The number of LSI clock periods is upper-rounded to
- 6 for the timeout value calculation.
- The timeout value is calculated using the highest prescaler (256) and
- the LSI_VALUE constant. The value of this constant can be changed by the user
- to take into account possible LSI clock period variations.
- The timeout value is multiplied by 1000 to be converted in milliseconds.
- LSI startup time is also considered here by adding LSI_STARTUP_TIMEOUT
- converted in milliseconds. */
-#define HAL_IWDG_DEFAULT_TIMEOUT (((6UL * 256UL * 1000UL) / LSI_VALUE) + ((LSI_STARTUP_TIME / 1000UL) + 1UL))
-#define IWDG_KERNEL_UPDATE_FLAGS (IWDG_SR_RVU | IWDG_SR_PVU)
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Exported functions --------------------------------------------------------*/
-
-/** @addtogroup IWDG_Exported_Functions
- * @{
- */
-
-/** @addtogroup IWDG_Exported_Functions_Group1
- * @brief Initialization and Start functions.
- *
-@verbatim
- ===============================================================================
- ##### Initialization and Start functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Initialize the IWDG according to the specified parameters in the
- IWDG_InitTypeDef of associated handle.
- (+) Once initialization is performed in HAL_IWDG_Init function, Watchdog
- is reloaded in order to exit function with correct time base.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initialize the IWDG according to the specified parameters in the
- * IWDG_InitTypeDef and start watchdog. Before exiting function,
- * watchdog is refreshed in order to have correct time base.
- * @param hiwdg pointer to a IWDG_HandleTypeDef structure that contains
- * the configuration information for the specified IWDG module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_IWDG_Init(IWDG_HandleTypeDef *hiwdg)
-{
- uint32_t tickstart;
-
- /* Check the IWDG handle allocation */
- if (hiwdg == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_IWDG_ALL_INSTANCE(hiwdg->Instance));
- assert_param(IS_IWDG_PRESCALER(hiwdg->Init.Prescaler));
- assert_param(IS_IWDG_RELOAD(hiwdg->Init.Reload));
-
- /* Enable IWDG. LSI is turned on automatically */
- __HAL_IWDG_START(hiwdg);
-
- /* Enable write access to IWDG_PR and IWDG_RLR registers by writing
- 0x5555 in KR */
- IWDG_ENABLE_WRITE_ACCESS(hiwdg);
-
- /* Write to IWDG registers the Prescaler & Reload values to work with */
- hiwdg->Instance->PR = hiwdg->Init.Prescaler;
- hiwdg->Instance->RLR = hiwdg->Init.Reload;
-
- /* Check pending flag, if previous update not done, return timeout */
- tickstart = HAL_GetTick();
-
- /* Wait for register to be updated */
- while ((hiwdg->Instance->SR & IWDG_KERNEL_UPDATE_FLAGS) != 0x00u)
- {
- if ((HAL_GetTick() - tickstart) > HAL_IWDG_DEFAULT_TIMEOUT)
- {
- if ((hiwdg->Instance->SR & IWDG_KERNEL_UPDATE_FLAGS) != 0x00u)
- {
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Reload IWDG counter with value defined in the reload register */
- __HAL_IWDG_RELOAD_COUNTER(hiwdg);
-
- /* Return function status */
- return HAL_OK;
-}
-
-
-/**
- * @}
- */
-
-
-/** @addtogroup IWDG_Exported_Functions_Group2
- * @brief IO operation functions
- *
-@verbatim
- ===============================================================================
- ##### IO operation functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) Refresh the IWDG.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Refresh the IWDG.
- * @param hiwdg pointer to a IWDG_HandleTypeDef structure that contains
- * the configuration information for the specified IWDG module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_IWDG_Refresh(IWDG_HandleTypeDef *hiwdg)
-{
- /* Reload IWDG counter with value defined in the reload register */
- __HAL_IWDG_RELOAD_COUNTER(hiwdg);
-
- /* Return function status */
- return HAL_OK;
-}
-
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* HAL_IWDG_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_lcd.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_lcd.c
deleted file mode 100644
index 27b2b37d2c6..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_lcd.c
+++ /dev/null
@@ -1,615 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_lcd.c
- * @author MCD Application Team
- * @brief LCD Controller HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the LCD Controller (LCD) peripheral:
- * + Initialization/de-initialization methods
- * + I/O operation methods
- * + Peripheral State methods
- *
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..] The LCD HAL driver can be used as follows:
-
- (#) Declare a LCD_HandleTypeDef handle structure.
-
- (#) Initialize the LCD low level resources by implement the HAL_LCD_MspInit() API:
- (##) Enable the LCDCLK (same as RTCCLK): to configure the RTCCLK/LCDCLK, proceed as follows:
- (+++) Use RCC function HAL_RCCEx_PeriphCLKConfig in indicating RCC_PERIPHCLK_LCD and
- selected clock source (HSE, LSI or LSE)
- (+++) The frequency generator allows you to achieve various LCD frame rates
- starting from an LCD input clock frequency (LCDCLK) which can vary
- from 32 kHz up to 1 MHz.
- (##) LCD pins configuration:
- (+++) Enable the clock for the LCD GPIOs.
- (+++) Configure these LCD pins as alternate function no-pull.
- (##) Enable the LCD interface clock.
-
- (#) Program the Prescaler, Divider, Blink mode, Blink Frequency Duty, Bias,
- Voltage Source, Dead Time, Pulse On Duration and Contrast in the hlcd Init structure.
-
- (#) Initialize the LCD registers by calling the HAL_LCD_Init() API.
-
- -@- The HAL_LCD_Init() API configures also the low level Hardware GPIO, CLOCK, ...etc)
- by calling the custumed HAL_LCD_MspInit() API.
- -@- After calling the HAL_LCD_Init() the LCD RAM memory is cleared
-
- (#) Optionally you can update the LCD configuration using these macros:
- (++) LCD High Drive using the __HAL_LCD_HIGHDRIVER_ENABLE() and __HAL_LCD_HIGHDRIVER_DISABLE() macros
- (++) LCD Pulse ON Duration using the __HAL_LCD_PULSEONDURATION_CONFIG() macro
- (++) LCD Dead Time using the __HAL_LCD_DEADTIME_CONFIG() macro
- (++) The LCD Blink mode and frequency using the __HAL_LCD_BLINK_CONFIG() macro
- (++) The LCD Contrast using the __HAL_LCD_CONTRAST_CONFIG() macro
-
- (#) Write to the LCD RAM memory using the HAL_LCD_Write() API, this API can be called
- more time to update the different LCD RAM registers before calling
- HAL_LCD_UpdateDisplayRequest() API.
-
- (#) The HAL_LCD_Clear() API can be used to clear the LCD RAM memory.
-
- (#) When LCD RAM memory is updated enable the update display request using
- the HAL_LCD_UpdateDisplayRequest() API.
-
- [..] LCD and low power modes:
- (#) The LCD remain active during STOP mode.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup HAL_MSP HAL_MSP
- * @brief HAL MSP module.
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup HAL_MSP_Exported_Functions HAL MSP Exported Functions
- * @{
- */
-
-/**
- * @brief Initializes the Global MSP.
- * @retval None
- */
-void HAL_MspInit(void)
-{
- /* NOTE : This function is generated automatically by STM32CubeMX and eventually
- modified by the user
- */
-}
-
-/**
- * @brief DeInitializes the Global MSP.
- * @retval None
- */
-void HAL_MspDeInit(void)
-{
- /* NOTE : This function is generated automatically by STM32CubeMX and eventually
- modified by the user
- */
-}
-
-/**
- * @brief Initializes the PPP MSP.
- * @retval None
- */
-void HAL_PPP_MspInit(void)
-{
- /* NOTE : This function is generated automatically by STM32CubeMX and eventually
- modified by the user
- */
-}
-
-/**
- * @brief DeInitializes the PPP MSP.
- * @retval None
- */
-void HAL_PPP_MspDeInit(void)
-{
- /* NOTE : This function is generated automatically by STM32CubeMX and eventually
- modified by the user
- */
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_nor.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_nor.c
deleted file mode 100644
index 2cc0aed8032..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_nor.c
+++ /dev/null
@@ -1,1512 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_nor.c
- * @author MCD Application Team
- * @brief NOR HAL module driver.
- * This file provides a generic firmware to drive NOR memories mounted
- * as external device.
- *
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- This driver is a generic layered driver which contains a set of APIs used to
- control NOR flash memories. It uses the FSMC layer functions to interface
- with NOR devices. This driver is used as follows:
-
- (+) NOR flash memory configuration sequence using the function HAL_NOR_Init()
- with control and timing parameters for both normal and extended mode.
-
- (+) Read NOR flash memory manufacturer code and device IDs using the function
- HAL_NOR_Read_ID(). The read information is stored in the NOR_ID_TypeDef
- structure declared by the function caller.
-
- (+) Access NOR flash memory by read/write data unit operations using the functions
- HAL_NOR_Read(), HAL_NOR_Program().
-
- (+) Perform NOR flash erase block/chip operations using the functions
- HAL_NOR_Erase_Block() and HAL_NOR_Erase_Chip().
-
- (+) Read the NOR flash CFI (common flash interface) IDs using the function
- HAL_NOR_Read_CFI(). The read information is stored in the NOR_CFI_TypeDef
- structure declared by the function caller.
-
- (+) You can also control the NOR device by calling the control APIs HAL_NOR_WriteOperation_Enable()/
- HAL_NOR_WriteOperation_Disable() to respectively enable/disable the NOR write operation
-
- (+) You can monitor the NOR device HAL state by calling the function
- HAL_NOR_GetState()
- [..]
- (@) This driver is a set of generic APIs which handle standard NOR flash operations.
- If a NOR flash device contains different operations and/or implementations,
- it should be implemented separately.
-
- *** NOR HAL driver macros list ***
- =============================================
- [..]
- Below the list of most used macros in NOR HAL driver.
-
- (+) NOR_WRITE : NOR memory write data to specified address
-
- *** Callback registration ***
- =============================================
- [..]
- The compilation define USE_HAL_NOR_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
-
- Use Functions @ref HAL_NOR_RegisterCallback() to register a user callback,
- it allows to register following callbacks:
- (+) MspInitCallback : NOR MspInit.
- (+) MspDeInitCallback : NOR MspDeInit.
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
-
- Use function @ref HAL_NOR_UnRegisterCallback() to reset a callback to the default
- weak (surcharged) function. It allows to reset following callbacks:
- (+) MspInitCallback : NOR MspInit.
- (+) MspDeInitCallback : NOR MspDeInit.
- This function) takes as parameters the HAL peripheral handle and the Callback ID.
-
- By default, after the @ref HAL_NOR_Init and if the state is HAL_NOR_STATE_RESET
- all callbacks are reset to the corresponding legacy weak (surcharged) functions.
- Exception done for MspInit and MspDeInit callbacks that are respectively
- reset to the legacy weak (surcharged) functions in the @ref HAL_NOR_Init
- and @ref HAL_NOR_DeInit only when these callbacks are null (not registered beforehand).
- If not, MspInit or MspDeInit are not null, the @ref HAL_NOR_Init and @ref HAL_NOR_DeInit
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
-
- Callbacks can be registered/unregistered in READY state only.
- Exception done for MspInit/MspDeInit callbacks that can be registered/unregistered
- in READY or RESET state, thus registered (user) MspInit/DeInit callbacks can be used
- during the Init/DeInit.
- In that case first register the MspInit/MspDeInit user callbacks
- using @ref HAL_NOR_RegisterCallback before calling @ref HAL_NOR_DeInit
- or @ref HAL_NOR_Init function.
-
- When The compilation define USE_HAL_NOR_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registering feature is not available
- and weak (surcharged) callbacks are used.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup PWR PWR
- * @brief PWR HAL module driver
- * @{
- */
-
-#ifdef HAL_PWR_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-#define PVD_MODE_IT (0x00010000U)
-#define PVD_MODE_EVT (0x00020000U)
-#define PVD_RISING_EDGE (0x00000001U)
-#define PVD_FALLING_EDGE (0x00000002U)
-
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup PWR_Exported_Functions PWR Exported Functions
- * @{
- */
-
-/** @defgroup PWR_Exported_Functions_Group1 Initialization and de-initialization functions
- * @brief Initialization and de-initialization functions
- *
-@verbatim
- ===============================================================================
- ##### Initialization and de-initialization functions #####
- ===============================================================================
- [..]
- After reset, the backup domain (RTC registers, RTC backup data
- registers) is protected against possible unwanted
- write accesses.
- To enable access to the RTC Domain and RTC registers, proceed as follows:
- (+) Enable the Power Controller (PWR) APB1 interface clock using the
- __HAL_RCC_PWR_CLK_ENABLE() macro.
- (+) Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Deinitializes the PWR peripheral registers to their default reset values.
- * @note Before calling this function, the VOS[1:0] bits should be configured
- * to "10" and the system frequency has to be configured accordingly.
- * To configure the VOS[1:0] bits, use the PWR_VoltageScalingConfig()
- * function.
- * @note ULP and FWU bits are not reset by this function.
- * @retval None
- */
-void HAL_PWR_DeInit(void)
-{
- __HAL_RCC_PWR_FORCE_RESET();
- __HAL_RCC_PWR_RELEASE_RESET();
-}
-
-/**
- * @brief Enables access to the backup domain (RTC registers, RTC
- * backup data registers ).
- * @note If the HSE divided by 2, 4, 8 or 16 is used as the RTC clock, the
- * Backup Domain Access should be kept enabled.
- * @retval None
- */
-void HAL_PWR_EnableBkUpAccess(void)
-{
- /* Enable access to RTC and backup registers */
- *(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE;
-}
-
-/**
- * @brief Disables access to the backup domain (RTC registers, RTC
- * backup data registers).
- * @note If the HSE divided by 2, 4, 8 or 16 is used as the RTC clock, the
- * Backup Domain Access should be kept enabled.
- * @retval None
- */
-void HAL_PWR_DisableBkUpAccess(void)
-{
- /* Disable access to RTC and backup registers */
- *(__IO uint32_t *) CR_DBP_BB = (uint32_t)DISABLE;
-}
-
-/**
- * @}
- */
-
-/** @defgroup PWR_Exported_Functions_Group2 Peripheral Control functions
- * @brief Low Power modes configuration functions
- *
-@verbatim
-
- ===============================================================================
- ##### Peripheral Control functions #####
- ===============================================================================
-
- *** PVD configuration ***
- =========================
- [..]
- (+) The PVD is used to monitor the VDD power supply by comparing it to a
- threshold selected by the PVD Level (PLS[2:0] bits in the PWR_CR).
- (+) The PVD can use an external input analog voltage (PVD_IN) which is compared
- internally to VREFINT. The PVD_IN (PB7) has to be configured in Analog mode
- when PWR_PVDLevel_7 is selected (PLS[2:0] = 111).
-
- (+) A PVDO flag is available to indicate if VDD/VDDA is higher or lower
- than the PVD threshold. This event is internally connected to the EXTI
- line16 and can generate an interrupt if enabled. This is done through
- __HAL_PWR_PVD_EXTI_ENABLE_IT() macro.
- (+) The PVD is stopped in Standby mode.
-
- *** WakeUp pin configuration ***
- ================================
- [..]
- (+) WakeUp pin is used to wake up the system from Standby mode. This pin is
- forced in input pull-down configuration and is active on rising edges.
- (+) There are two or three WakeUp pins:
- WakeUp Pin 1 on PA.00.
- WakeUp Pin 2 on PC.13.
- WakeUp Pin 3 on PE.06. : Only on product with GPIOE available
-
- [..]
- *** Main and Backup Regulators configuration ***
- ================================================
-
- (+) The main internal regulator can be configured to have a tradeoff between
- performance and power consumption when the device does not operate at
- the maximum frequency. This is done through __HAL_PWR_VOLTAGESCALING_CONFIG()
- macro which configure VOS bit in PWR_CR register:
- (++) When this bit is set (Regulator voltage output Scale 1 mode selected)
- the System frequency can go up to 32 MHz.
- (++) When this bit is reset (Regulator voltage output Scale 2 mode selected)
- the System frequency can go up to 16 MHz.
- (++) When this bit is reset (Regulator voltage output Scale 3 mode selected)
- the System frequency can go up to 4.2 MHz.
-
- Refer to the datasheets for more details.
-
- *** Low Power modes configuration ***
- =====================================
- [..]
- The device features 5 low-power modes:
- (+) Low power run mode: regulator in low power mode, limited clock frequency,
- limited number of peripherals running.
- (+) Sleep mode: Cortex-M3 core stopped, peripherals kept running.
- (+) Low power sleep mode: Cortex-M3 core stopped, limited clock frequency,
- limited number of peripherals running, regulator in low power mode.
- (+) Stop mode: All clocks are stopped, regulator running, regulator in low power mode.
- (+) Standby mode: VCORE domain powered off
-
- *** Low power run mode ***
- =========================
- [..]
- To further reduce the consumption when the system is in Run mode, the regulator can be
- configured in low power mode. In this mode, the system frequency should not exceed
- MSI frequency range1.
- In Low power run mode, all I/O pins keep the same state as in Run mode.
-
- (+) Entry:
- (++) VCORE in range2
- (++) Decrease the system frequency tonot exceed the frequency of MSI frequency range1.
- (++) The regulator is forced in low power mode using the HAL_PWREx_EnableLowPowerRunMode()
- function.
- (+) Exit:
- (++) The regulator is forced in Main regulator mode using the HAL_PWREx_DisableLowPowerRunMode()
- function.
- (++) Increase the system frequency if needed.
-
- *** Sleep mode ***
- ==================
- [..]
- (+) Entry:
- The Sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFx)
- functions with
- (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
- (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
-
- (+) Exit:
- (++) Any peripheral interrupt acknowledged by the nested vectored interrupt
- controller (NVIC) can wake up the device from Sleep mode.
-
- *** Low power sleep mode ***
- ============================
- [..]
- (+) Entry:
- The Low power sleep mode is entered by using the HAL_PWR_EnterSLEEPMode(PWR_LOWPOWERREGULATOR_ON, PWR_SLEEPENTRY_WFx)
- functions with
- (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
- (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
- (+) The Flash memory can be switched off by using the control bits (SLEEP_PD in the FLASH_ACR register.
- This reduces power consumption but increases the wake-up time.
-
- (+) Exit:
- (++) If the WFI instruction was used to enter Low power sleep mode, any peripheral interrupt
- acknowledged by the nested vectored interrupt controller (NVIC) can wake up the device
- from Low power sleep mode. If the WFE instruction was used to enter Low power sleep mode,
- the MCU exits Sleep mode as soon as an event occurs.
-
- *** Stop mode ***
- =================
- [..]
- The Stop mode is based on the Cortex-M3 deepsleep mode combined with peripheral
- clock gating. The voltage regulator can be configured either in normal or low-power mode.
- In Stop mode, all clocks in the VCORE domain are stopped, the PLL, the MSI, the HSI and
- the HSE RC oscillators are disabled. Internal SRAM and register contents are preserved.
- To get the lowest consumption in Stop mode, the internal Flash memory also enters low
- power mode. When the Flash memory is in power-down mode, an additional startup delay is
- incurred when waking up from Stop mode.
- To minimize the consumption In Stop mode, VREFINT, the BOR, PVD, and temperature
- sensor can be switched off before entering Stop mode. They can be switched on again by
- software after exiting Stop mode using the ULP bit in the PWR_CR register.
- In Stop mode, all I/O pins keep the same state as in Run mode.
-
- (+) Entry:
- The Stop mode is entered using the HAL_PWR_EnterSTOPMode(PWR_MAINREGULATOR_ON, PWR_SLEEPENTRY_WFI )
- function with:
- (++) Main regulator ON.
- (++) Low Power regulator ON.
- (++) PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
- (++) PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
- (+) Exit:
- (++) By issuing an interrupt or a wakeup event, the MSI RC oscillator is selected as system clock.
-
- *** Standby mode ***
- ====================
- [..]
- The Standby mode allows to achieve the lowest power consumption. It is based on the
- Cortex-M3 deepsleep mode, with the voltage regulator disabled. The VCORE domain is
- consequently powered off. The PLL, the MSI, the HSI oscillator and the HSE oscillator are
- also switched off. SRAM and register contents are lost except for the RTC registers, RTC
- backup registers and Standby circuitry.
-
- To minimize the consumption In Standby mode, VREFINT, the BOR, PVD, and temperature
- sensor can be switched off before entering the Standby mode. They can be switched
- on again by software after exiting the Standby mode.
- function.
-
- (+) Entry:
- (++) The Standby mode is entered using the HAL_PWR_EnterSTANDBYMode() function.
- (+) Exit:
- (++) WKUP pin rising edge, RTC alarm (Alarm A and Alarm B), RTC wakeup,
- tamper event, time-stamp event, external reset in NRST pin, IWDG reset.
-
- *** Auto-wakeup (AWU) from low-power mode ***
- =============================================
- [..]
- The MCU can be woken up from low-power mode by an RTC Alarm event, an RTC
- Wakeup event, a tamper event, a time-stamp event, or a comparator event,
- without depending on an external interrupt (Auto-wakeup mode).
-
- (+) RTC auto-wakeup (AWU) from the Stop mode
- (++) To wake up from the Stop mode with an RTC alarm event, it is necessary to:
- (+++) Configure the EXTI Line 17 to be sensitive to rising edges (Interrupt
- or Event modes) and Enable the RTC Alarm Interrupt using the HAL_RTC_SetAlarm_IT()
- function
- (+++) Configure the RTC to generate the RTC alarm using the HAL_RTC_Init()
- and HAL_RTC_SetTime() functions.
- (++) To wake up from the Stop mode with an RTC Tamper or time stamp event, it
- is necessary to:
- (+++) Configure the EXTI Line 19 to be sensitive to rising edges (Interrupt or Event modes) and
- Enable the RTC Tamper or time stamp Interrupt using the HAL_RTCEx_SetTamper_IT()
- or HAL_RTCEx_SetTimeStamp_IT() functions.
- (++) To wake up from the Stop mode with an RTC WakeUp event, it is necessary to:
- (+++) Configure the EXTI Line 20 to be sensitive to rising edges (Interrupt or Event modes) and
- Enable the RTC WakeUp Interrupt using the HAL_RTCEx_SetWakeUpTimer_IT() function.
- (+++) Configure the RTC to generate the RTC WakeUp event using the HAL_RTCEx_SetWakeUpTimer()
- function.
-
- (+) RTC auto-wakeup (AWU) from the Standby mode
- (++) To wake up from the Standby mode with an RTC alarm event, it is necessary to:
- (+++) Enable the RTC Alarm Interrupt using the HAL_RTC_SetAlarm_IT() function.
- (+++) Configure the RTC to generate the RTC alarm using the HAL_RTC_Init()
- and HAL_RTC_SetTime() functions.
- (++) To wake up from the Standby mode with an RTC Tamper or time stamp event, it
- is necessary to:
- (+++) Enable the RTC Tamper or time stamp Interrupt and Configure the RTC to
- detect the tamper or time stamp event using the HAL_RTCEx_SetTimeStamp_IT()
- or HAL_RTCEx_SetTamper_IT()functions.
- (++) To wake up from the Standby mode with an RTC WakeUp event, it is necessary to:
- (+++) Enable the RTC WakeUp Interrupt and Configure the RTC to generate the RTC WakeUp event
- using the HAL_RTCEx_SetWakeUpTimer_IT() and HAL_RTCEx_SetWakeUpTimer() functions.
-
- (+) Comparator auto-wakeup (AWU) from the Stop mode
- (++) To wake up from the Stop mode with an comparator 1 or comparator 2 wakeup
- event, it is necessary to:
- (+++) Configure the EXTI Line 21 or EXTI Line 22 for comparator to be sensitive to to the
- selected edges (falling, rising or falling and rising) (Interrupt or Event modes) using
- the COMP functions.
- (+++) Configure the comparator to generate the event.
-
-
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Configures the voltage threshold detected by the Power Voltage Detector(PVD).
- * @param sConfigPVD pointer to an PWR_PVDTypeDef structure that contains the configuration
- * information for the PVD.
- * @note Refer to the electrical characteristics of your device datasheet for
- * more details about the voltage threshold corresponding to each
- * detection level.
- * @retval None
- */
-void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
-{
- /* Check the parameters */
- assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
- assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
-
- /* Set PLS[7:5] bits according to PVDLevel value */
- MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel);
-
- /* Clear any previous config. Keep it clear if no event or IT mode is selected */
- __HAL_PWR_PVD_EXTI_DISABLE_EVENT();
- __HAL_PWR_PVD_EXTI_DISABLE_IT();
- __HAL_PWR_PVD_EXTI_DISABLE_RISING_FALLING_EDGE();
-
- /* Configure interrupt mode */
- if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
- {
- __HAL_PWR_PVD_EXTI_ENABLE_IT();
- }
-
- /* Configure event mode */
- if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
- {
- __HAL_PWR_PVD_EXTI_ENABLE_EVENT();
- }
-
- /* Configure the edge */
- if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
- {
- __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE();
- }
-
- if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
- {
- __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE();
- }
-}
-
-/**
- * @brief Enables the Power Voltage Detector(PVD).
- * @retval None
- */
-void HAL_PWR_EnablePVD(void)
-{
- /* Enable the power voltage detector */
- *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)ENABLE;
-}
-
-/**
- * @brief Disables the Power Voltage Detector(PVD).
- * @retval None
- */
-void HAL_PWR_DisablePVD(void)
-{
- /* Disable the power voltage detector */
- *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)DISABLE;
-}
-
-/**
- * @brief Enables the WakeUp PINx functionality.
- * @param WakeUpPinx: Specifies the Power Wake-Up pin to enable.
- * This parameter can be one of the following values:
- * @arg PWR_WAKEUP_PIN1
- * @arg PWR_WAKEUP_PIN2
- * @arg PWR_WAKEUP_PIN3: Only on product with GPIOE available
- * @retval None
- */
-void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
-{
- /* Check the parameter */
- assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
- /* Enable the EWUPx pin */
- *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)ENABLE;
-}
-
-/**
- * @brief Disables the WakeUp PINx functionality.
- * @param WakeUpPinx: Specifies the Power Wake-Up pin to disable.
- * This parameter can be one of the following values:
- * @arg PWR_WAKEUP_PIN1
- * @arg PWR_WAKEUP_PIN2
- * @arg PWR_WAKEUP_PIN3: Only on product with GPIOE available
- * @retval None
- */
-void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
-{
- /* Check the parameter */
- assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
- /* Disable the EWUPx pin */
- *(__IO uint32_t *) CSR_EWUP_BB(WakeUpPinx) = (uint32_t)DISABLE;
-}
-
-/**
- * @brief Enters Sleep mode.
- * @note In Sleep mode, all I/O pins keep the same state as in Run mode.
- * @param Regulator: Specifies the regulator state in SLEEP mode.
- * This parameter can be one of the following values:
- * @arg PWR_MAINREGULATOR_ON: SLEEP mode with regulator ON
- * @arg PWR_LOWPOWERREGULATOR_ON: SLEEP mode with low power regulator ON
- * @param SLEEPEntry: Specifies if SLEEP mode is entered with WFI or WFE instruction.
- * When WFI entry is used, tick interrupt have to be disabled if not desired as
- * the interrupt wake up source.
- * This parameter can be one of the following values:
- * @arg PWR_SLEEPENTRY_WFI: enter SLEEP mode with WFI instruction
- * @arg PWR_SLEEPENTRY_WFE: enter SLEEP mode with WFE instruction
- * @retval None
- */
-void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
-{
- /* Check the parameters */
- assert_param(IS_PWR_REGULATOR(Regulator));
- assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
-
- /* Select the regulator state in Sleep mode: Set PDDS and LPSDSR bit according to PWR_Regulator value */
- MODIFY_REG(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPSDSR), Regulator);
-
- /* Clear SLEEPDEEP bit of Cortex System Control Register */
- CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
-
- /* Select SLEEP mode entry -------------------------------------------------*/
- if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
- {
- /* Request Wait For Interrupt */
- __WFI();
- }
- else
- {
- /* Request Wait For Event */
- __SEV();
- __WFE();
- __WFE();
- }
-}
-
-/**
- * @brief Enters Stop mode.
- * @note In Stop mode, all I/O pins keep the same state as in Run mode.
- * @note When exiting Stop mode by using an interrupt or a wakeup event,
- * MSI RC oscillator is selected as system clock.
- * @note When the voltage regulator operates in low power mode, an additional
- * startup delay is incurred when waking up from Stop mode.
- * By keeping the internal regulator ON during Stop mode, the consumption
- * is higher although the startup time is reduced.
- * @param Regulator: Specifies the regulator state in Stop mode.
- * This parameter can be one of the following values:
- * @arg PWR_MAINREGULATOR_ON: Stop mode with regulator ON
- * @arg PWR_LOWPOWERREGULATOR_ON: Stop mode with low power regulator ON
- * @param STOPEntry: Specifies if Stop mode in entered with WFI or WFE instruction.
- * This parameter can be one of the following values:
- * @arg PWR_STOPENTRY_WFI: Enter Stop mode with WFI instruction
- * @arg PWR_STOPENTRY_WFE: Enter Stop mode with WFE instruction
- * @retval None
- */
-void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
-{
- /* Check the parameters */
- assert_param(IS_PWR_REGULATOR(Regulator));
- assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
-
- /* Select the regulator state in Stop mode: Set PDDS and LPSDSR bit according to PWR_Regulator value */
- MODIFY_REG(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPSDSR), Regulator);
-
- /* Set SLEEPDEEP bit of Cortex System Control Register */
- SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
-
- /* Select Stop mode entry --------------------------------------------------*/
- if(STOPEntry == PWR_STOPENTRY_WFI)
- {
- /* Request Wait For Interrupt */
- __WFI();
- }
- else
- {
- /* Request Wait For Event */
- __SEV();
- __WFE();
- __WFE();
- }
- /* Reset SLEEPDEEP bit of Cortex System Control Register */
- CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
-}
-
-/**
- * @brief Enters Standby mode.
- * @note In Standby mode, all I/O pins are high impedance except for:
- * - Reset pad (still available)
- * - RTC_AF1 pin (PC13) if configured for tamper, time-stamp, RTC
- * Alarm out, or RTC clock calibration out.
- * - WKUP pin 1 (PA0) if enabled.
- * - WKUP pin 2 (PC13) if enabled.
- * - WKUP pin 3 (PE6) if enabled.
- * @retval None
- */
-void HAL_PWR_EnterSTANDBYMode(void)
-{
- /* Select Standby mode */
- SET_BIT(PWR->CR, PWR_CR_PDDS);
-
- /* Set SLEEPDEEP bit of Cortex System Control Register */
- SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
-
- /* This option is used to ensure that store operations are completed */
-#if defined ( __CC_ARM)
- __force_stores();
-#endif
- /* Request Wait For Interrupt */
- __WFI();
-}
-
-
-/**
- * @brief Indicates Sleep-On-Exit when returning from Handler mode to Thread mode.
- * @note Set SLEEPONEXIT bit of SCR register. When this bit is set, the processor
- * re-enters SLEEP mode when an interruption handling is over.
- * Setting this bit is useful when the processor is expected to run only on
- * interruptions handling.
- * @retval None
- */
-void HAL_PWR_EnableSleepOnExit(void)
-{
- /* Set SLEEPONEXIT bit of Cortex System Control Register */
- SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
-}
-
-
-/**
- * @brief Disables Sleep-On-Exit feature when returning from Handler mode to Thread mode.
- * @note Clears SLEEPONEXIT bit of SCR register. When this bit is set, the processor
- * re-enters SLEEP mode when an interruption handling is over.
- * @retval None
- */
-void HAL_PWR_DisableSleepOnExit(void)
-{
- /* Clear SLEEPONEXIT bit of Cortex System Control Register */
- CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
-}
-
-
-/**
- * @brief Enables CORTEX M3 SEVONPEND bit.
- * @note Sets SEVONPEND bit of SCR register. When this bit is set, this causes
- * WFE to wake up when an interrupt moves from inactive to pended.
- * @retval None
- */
-void HAL_PWR_EnableSEVOnPend(void)
-{
- /* Set SEVONPEND bit of Cortex System Control Register */
- SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
-}
-
-
-/**
- * @brief Disables CORTEX M3 SEVONPEND bit.
- * @note Clears SEVONPEND bit of SCR register. When this bit is set, this causes
- * WFE to wake up when an interrupt moves from inactive to pended.
- * @retval None
- */
-void HAL_PWR_DisableSEVOnPend(void)
-{
- /* Clear SEVONPEND bit of Cortex System Control Register */
- CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
-}
-
-
-
-/**
- * @brief This function handles the PWR PVD interrupt request.
- * @note This API should be called under the PVD_IRQHandler().
- * @retval None
- */
-void HAL_PWR_PVD_IRQHandler(void)
-{
- /* Check PWR exti flag */
- if(__HAL_PWR_PVD_EXTI_GET_FLAG() != RESET)
- {
- /* PWR PVD interrupt user callback */
- HAL_PWR_PVDCallback();
-
- /* Clear PWR Exti pending bit */
- __HAL_PWR_PVD_EXTI_CLEAR_FLAG();
- }
-}
-
-/**
- * @brief PWR PVD interrupt callback
- * @retval None
- */
-__weak void HAL_PWR_PVDCallback(void)
-{
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_PWR_PVDCallback could be implemented in the user file
- */
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* HAL_PWR_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_pwr_ex.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_pwr_ex.c
deleted file mode 100644
index e3580ec2899..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_pwr_ex.c
+++ /dev/null
@@ -1,161 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_pwr_ex.c
- * @author MCD Application Team
- * @brief Extended PWR HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Power Controller (PWR) peripheral:
- * + Extended Initialization and de-initialization functions
- * + Extended Peripheral Control functions
- *
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup PWREx PWREx
- * @brief PWR HAL module driver
- * @{
- */
-
-#ifdef HAL_PWR_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup PWREx_Exported_Functions PWREx Exported Functions
- * @{
- */
-
-/** @defgroup PWREx_Exported_Functions_Group1 Peripheral Extended Features Functions
- * @brief Low Power modes configuration functions
- *
-@verbatim
-
- ===============================================================================
- ##### Peripheral extended features functions #####
- ===============================================================================
-@endverbatim
- * @{
- */
-
-/**
- * @brief Return Voltage Scaling Range.
- * @retval VOS bit field (PWR_REGULATOR_VOLTAGE_SCALE1, PWR_REGULATOR_VOLTAGE_SCALE2 or PWR_REGULATOR_VOLTAGE_SCALE3)
- */
-uint32_t HAL_PWREx_GetVoltageRange(void)
-{
- return (PWR->CR & PWR_CR_VOS);
-}
-
-
-/**
- * @brief Enables the Fast WakeUp from Ultra Low Power mode.
- * @note This bit works in conjunction with ULP bit.
- * Means, when ULP = 1 and FWU = 1 :VREFINT startup time is ignored when
- * exiting from low power mode.
- * @retval None
- */
-void HAL_PWREx_EnableFastWakeUp(void)
-{
- /* Enable the fast wake up */
- *(__IO uint32_t *) CR_FWU_BB = (uint32_t)ENABLE;
-}
-
-/**
- * @brief Disables the Fast WakeUp from Ultra Low Power mode.
- * @retval None
- */
-void HAL_PWREx_DisableFastWakeUp(void)
-{
- /* Disable the fast wake up */
- *(__IO uint32_t *) CR_FWU_BB = (uint32_t)DISABLE;
-}
-
-/**
- * @brief Enables the Ultra Low Power mode
- * @retval None
- */
-void HAL_PWREx_EnableUltraLowPower(void)
-{
- /* Enable the Ultra Low Power mode */
- *(__IO uint32_t *) CR_ULP_BB = (uint32_t)ENABLE;
-}
-
-/**
- * @brief Disables the Ultra Low Power mode
- * @retval None
- */
-void HAL_PWREx_DisableUltraLowPower(void)
-{
- /* Disable the Ultra Low Power mode */
- *(__IO uint32_t *) CR_ULP_BB = (uint32_t)DISABLE;
-}
-
-/**
- * @brief Enters the Low Power Run mode.
- * @note Low power run mode can only be entered when VCORE is in range 2.
- * In addition, the dynamic voltage scaling must not be used when Low
- * power run mode is selected. Only Stop and Sleep modes with regulator
- * configured in Low power mode is allowed when Low power run mode is
- * selected.
- * @note In Low power run mode, all I/O pins keep the same state as in Run mode.
- * @retval None
- */
-void HAL_PWREx_EnableLowPowerRunMode(void)
-{
- /* Enters the Low Power Run mode */
- *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)ENABLE;
- *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)ENABLE;
-}
-
-/**
- * @brief Exits the Low Power Run mode.
- * @retval None
- */
-HAL_StatusTypeDef HAL_PWREx_DisableLowPowerRunMode(void)
-{
- /* Exits the Low Power Run mode */
- *(__IO uint32_t *) CR_LPRUN_BB = (uint32_t)DISABLE;
- *(__IO uint32_t *) CR_LPSDSR_BB = (uint32_t)DISABLE;
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* HAL_PWR_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rcc.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rcc.c
deleted file mode 100644
index 7be986e85b2..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rcc.c
+++ /dev/null
@@ -1,1394 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_rcc.c
- * @author MCD Application Team
- * @brief RCC HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Reset and Clock Control (RCC) peripheral:
- * + Initialization and de-initialization functions
- * + Peripheral Control functions
- *
- @verbatim
- ==============================================================================
- ##### RCC specific features #####
- ==============================================================================
- [..]
- After reset the device is running from multispeed internal oscillator clock
- (MSI 2.097MHz) with Flash 0 wait state and Flash prefetch buffer is disabled,
- and all peripherals are off except internal SRAM, Flash and JTAG.
- (+) There is no prescaler on High speed (AHB) and Low speed (APB) buses;
- all peripherals mapped on these buses are running at MSI speed.
- (+) The clock for all peripherals is switched off, except the SRAM and FLASH.
- (+) All GPIOs are in input floating state, except the JTAG pins which
- are assigned to be used for debug purpose.
- [..] Once the device started from reset, the user application has to:
- (+) Configure the clock source to be used to drive the System clock
- (if the application needs higher frequency/performance)
- (+) Configure the System clock frequency and Flash settings
- (+) Configure the AHB and APB buses prescalers
- (+) Enable the clock for the peripheral(s) to be used
- (+) Configure the clock source(s) for peripherals whose clocks are not
- derived from the System clock (I2S, RTC, ADC, USB OTG FS/SDIO/RNG)
- (*) SDIO only for STM32L1xxxD devices
-
- ##### RCC Limitations #####
- ==============================================================================
- [..]
- A delay between an RCC peripheral clock enable and the effective peripheral
- enabling should be taken into account in order to manage the peripheral read/write
- from/to registers.
- (+) This delay depends on the peripheral mapping.
- (++) AHB & APB peripherals, 1 dummy read is necessary
-
- [..]
- Workarounds:
- (#) For AHB & APB peripherals, a dummy read to the peripheral register has been
- inserted in each __HAL_RCC_PPP_CLK_ENABLE() macro.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup RCC RCC
-* @brief RCC HAL module driver
- * @{
- */
-
-#ifdef HAL_RCC_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/** @defgroup RCC_Private_Macros RCC Private Macros
- * @{
- */
-
-#define MCO1_CLK_ENABLE() __HAL_RCC_GPIOA_CLK_ENABLE()
-#define MCO1_GPIO_PORT GPIOA
-#define MCO1_PIN GPIO_PIN_8
-
-/**
- * @}
- */
-
-/* Private variables ---------------------------------------------------------*/
-/** @defgroup RCC_Private_Variables RCC Private Variables
- * @{
- */
-extern const uint8_t PLLMulTable[]; /* Defined in CMSIS (system_stm32l0xx.c)*/
-/**
- * @}
- */
-
-/* Private function prototypes -----------------------------------------------*/
-/** @defgroup RCC_Private_Functions RCC Private Functions
- * @{
- */
-static HAL_StatusTypeDef RCC_SetFlashLatencyFromMSIRange(uint32_t MSIrange);
-/**
- * @}
- */
-
-/* Exported functions ---------------------------------------------------------*/
-
-/** @defgroup RCC_Exported_Functions RCC Exported Functions
- * @{
- */
-
-/** @defgroup RCC_Exported_Functions_Group1 Initialization and de-initialization functions
- * @brief Initialization and Configuration functions
- *
- @verbatim
- ===============================================================================
- ##### Initialization and de-initialization functions #####
- ===============================================================================
- [..]
- This section provides functions allowing to configure the internal/external oscillators
- (MSI, HSE, HSI, LSE, LSI, PLL, CSS and MCO) and the System buses clocks (SYSCLK, AHB, APB1
- and APB2).
-
- [..] Internal/external clock and PLL configuration
- (#) MSI (Multispeed internal), Seven frequency ranges are available: 65.536 kHz,
- 131.072 kHz, 262.144 kHz, 524.288 kHz, 1.048 MHz, 2.097 MHz (default value) and 4.194 MHz.
-
- (#) HSI (high-speed internal), 16 MHz factory-trimmed RC used directly or through
- the PLL as System clock source.
- (#) LSI (low-speed internal), ~37 KHz low consumption RC used as IWDG and/or RTC
- clock source.
-
- (#) HSE (high-speed external), 1 to 24 MHz crystal oscillator used directly or
- through the PLL as System clock source. Can be used also as RTC clock source.
-
- (#) LSE (low-speed external), 32 KHz oscillator used as RTC clock source.
-
- (#) PLL (clocked by HSI or HSE), featuring different output clocks:
- (++) The first output is used to generate the high speed system clock (up to 32 MHz)
- (++) The second output is used to generate the clock for the USB OTG FS (48 MHz)
-
- (#) CSS (Clock security system), once enable using the macro __HAL_RCC_CSS_ENABLE()
- and if a HSE clock failure occurs(HSE used directly or through PLL as System
- clock source), the System clocks automatically switched to MSI and an interrupt
- is generated if enabled. The interrupt is linked to the Cortex-M3 NMI
- (Non-Maskable Interrupt) exception vector.
-
- (#) MCO1 (microcontroller clock output), used to output SYSCLK, HSI, LSI, MSI, LSE,
- HSE or PLL clock (through a configurable prescaler) on PA8 pin.
-
- [..] System, AHB and APB buses clocks configuration
- (#) Several clock sources can be used to drive the System clock (SYSCLK): MSI, HSI,
- HSE and PLL.
- The AHB clock (HCLK) is derived from System clock through configurable
- prescaler and used to clock the CPU, memory and peripherals mapped
- on AHB bus (DMA, GPIO...). APB1 (PCLK1) and APB2 (PCLK2) clocks are derived
- from AHB clock through configurable prescalers and used to clock
- the peripherals mapped on these buses. You can use
- "@ref HAL_RCC_GetSysClockFreq()" function to retrieve the frequencies of these clocks.
-
- -@- All the peripheral clocks are derived from the System clock (SYSCLK) except:
- (+@) RTC: RTC clock can be derived either from the LSI, LSE or HSE clock
- divided by 2 to 16. You have to use @ref __HAL_RCC_RTC_CONFIG() and @ref __HAL_RCC_RTC_ENABLE()
- macros to configure this clock.
- (+@) LCD: LCD clock can be derived either from the LSI, LSE or HSE clock
- divided by 2 to 16. You have to use @ref __HAL_RCC_LCD_CONFIG()
- macros to configure this clock.
- (+@) USB OTG FS: USB OTG FS require a frequency equal to 48 MHz
- to work correctly. This clock is derived of the main PLL through PLL Multiplier.
-
- (+@) IWDG clock which is always the LSI clock.
-
- (#) The maximum frequency of the SYSCLK and HCLK is 32 MHz, PCLK2 32 MHz
- and PCLK1 32 MHz. Depending on the device voltage range, the maximum
- frequency should be adapted accordingly.
- @endverbatim
- * @{
- */
-
-/*
- Additional consideration on the HCLK based on Latency settings:
- +----------------------------------------------------------------------+
- | Latency | HCLK clock frequency (MHz) |
- | |------------------------------------------------------|
- | | voltage range 1 | voltage range 2 | voltage range 3 |
- | | 1.8 V | 1.5 V | 1.2 V |
- |---------------|------------------|-----------------|-----------------|
- |0WS(1CPU cycle)| 0 < HCLK <= 16 | 0 < HCLK <= 8 | 0 < HCLK <= 2 |
- |---------------|------------------|-----------------|-----------------|
- |1WS(2CPU cycle)| 16 < HCLK <= 32 | 8 < HCLK <= 16 | 2 < HCLK <= 4 |
- +----------------------------------------------------------------------+
-
- The following table gives the different clock source frequencies depending on the product
- voltage range:
- +------------------------------------------------------------------------------------------+
- | Product voltage | Clock frequency |
- | |------------------|-----------------------------|-----------------------|
- | range | MSI | HSI | HSE | PLL |
- |-----------------|---------|--------|-----------------------------|-----------------------|
- | Range 1 (1.8 V) | 4.2 MHz | 16 MHz | HSE 32 MHz (external clock) | 32 MHz |
- | | | | or 24 MHz (crystal) | (PLLVCO max = 96 MHz) |
- |-----------------|---------|--------|-----------------------------|-----------------------|
- | Range 2 (1.5 V) | 4.2 MHz | 16 MHz | 16 MHz | 16 MHz |
- | | | | | (PLLVCO max = 48 MHz) |
- |-----------------|---------|--------|-----------------------------|-----------------------|
- | Range 3 (1.2 V) | 4.2 MHz | NA | 8 MHz | 4 MHz |
- | | | | | (PLLVCO max = 24 MHz) |
- +------------------------------------------------------------------------------------------+
- */
-
-/**
- * @brief Resets the RCC clock configuration to the default reset state.
- * @note The default reset state of the clock configuration is given below:
- * - MSI ON and used as system clock source
- * - HSI, HSE and PLL OFF
- * - AHB, APB1 and APB2 prescaler set to 1.
- * - CSS and MCO1 OFF
- * - All interrupts disabled
- * @note This function does not modify the configuration of the
- * - Peripheral clocks
- * - LSI, LSE and RTC clocks
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RCC_DeInit(void)
-{
- uint32_t tickstart;
- HAL_StatusTypeDef status;
-
- /* Set MSIClockRange, HSITRIM and MSITRIM bits to the reset values */
- MODIFY_REG(RCC->ICSCR, (RCC_ICSCR_MSITRIM | RCC_ICSCR_HSITRIM | RCC_ICSCR_MSIRANGE), \
- ((RCC_MSICALIBRATION_DEFAULT << RCC_ICSCR_MSITRIM_Pos) | (RCC_HSICALIBRATION_DEFAULT << RCC_ICSCR_HSITRIM_Pos) | RCC_ICSCR_MSIRANGE_5));
-
- /* Set MSION bit */
- SET_BIT(RCC->CR, RCC_CR_MSION);
-
- /* Get Start Tick*/
- tickstart = HAL_GetTick();
-
- /* Wait till MSI is ready */
- while (READ_BIT(RCC->CR, RCC_CR_MSIRDY) == 0U)
- {
- if ((HAL_GetTick() - tickstart) > MSI_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
-
- /* Switch SYSCLK to MSI*/
- CLEAR_BIT(RCC->CFGR, RCC_CFGR_SW);
-
- /* Wait till MSI as SYSCLK status is ready */
- while (READ_BIT(RCC->CFGR, RCC_CFGR_SWS) != 0U)
- {
- if ((HAL_GetTick() - tickstart) > CLOCKSWITCH_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
-
- /* Update the SystemCoreClock global variable */
- SystemCoreClock = MSI_VALUE;
-
- /* Configure the source of time base considering new system clock settings */
- status = HAL_InitTick(uwTickPrio);
- if(status != HAL_OK)
- {
- return status;
- }
-
- /* Reset HSION, HSEON, CSSON & PLLON bits */
- CLEAR_BIT(RCC->CR, RCC_CR_HSION | RCC_CR_HSEON | RCC_CR_CSSON | RCC_CR_PLLON);
- /* Reset HSEBYP bit */
- CLEAR_BIT(RCC->CR, RCC_CR_HSEBYP);
-
- /* Get Start Tick*/
- tickstart = HAL_GetTick();
-
- /* Wait till PLL is not ready */
- while (READ_BIT(RCC->CR, RCC_CR_PLLRDY) != 0U)
- {
- if ((HAL_GetTick() - tickstart) > PLL_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
-
- /* Reset CFGR register */
- CLEAR_REG(RCC->CFGR);
-
- /* Disable all interrupts */
- CLEAR_REG(RCC->CIR);
-
- /* Clear all flags */
-#if defined(RCC_LSECSS_SUPPORT)
- WRITE_REG(RCC->CIR, RCC_CIR_LSIRDYC | RCC_CIR_LSERDYC | RCC_CIR_HSIRDYC | RCC_CIR_HSERDYC | RCC_CIR_PLLRDYC | RCC_CIR_MSIRDYC | RCC_CIR_LSECSSC | RCC_CIR_CSSC);
-#else
- WRITE_REG(RCC->CIR, RCC_CIR_LSIRDYC | RCC_CIR_LSERDYC | RCC_CIR_HSIRDYC | RCC_CIR_HSERDYC | RCC_CIR_PLLRDYC | RCC_CIR_MSIRDYC | RCC_CIR_CSSC);
-#endif
-
- /* Clear all reset flags */
- SET_BIT(RCC->CSR, RCC_CSR_RMVF);
-
- return HAL_OK;
-}
-
-/**
- * @brief Initializes the RCC Oscillators according to the specified parameters in the
- * RCC_OscInitTypeDef.
- * @param RCC_OscInitStruct pointer to an RCC_OscInitTypeDef structure that
- * contains the configuration information for the RCC Oscillators.
- * @note The PLL is not disabled when used as system clock.
- * @note Transitions LSE Bypass to LSE On and LSE On to LSE Bypass are not
- * supported by this macro. User should request a transition to LSE Off
- * first and then LSE On or LSE Bypass.
- * @note Transition HSE Bypass to HSE On and HSE On to HSE Bypass are not
- * supported by this macro. User should request a transition to HSE Off
- * first and then HSE On or HSE Bypass.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RCC_OscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct)
-{
- uint32_t tickstart;
- HAL_StatusTypeDef status;
- uint32_t sysclk_source, pll_config;
-
- /* Check the parameters */
- if(RCC_OscInitStruct == NULL)
- {
- return HAL_ERROR;
- }
-
- assert_param(IS_RCC_OSCILLATORTYPE(RCC_OscInitStruct->OscillatorType));
-
- sysclk_source = __HAL_RCC_GET_SYSCLK_SOURCE();
- pll_config = __HAL_RCC_GET_PLL_OSCSOURCE();
-
- /*------------------------------- HSE Configuration ------------------------*/
- if(((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_HSE) == RCC_OSCILLATORTYPE_HSE)
- {
- /* Check the parameters */
- assert_param(IS_RCC_HSE(RCC_OscInitStruct->HSEState));
-
- /* When the HSE is used as system clock or clock source for PLL in these cases it is not allowed to be disabled */
- if((sysclk_source == RCC_SYSCLKSOURCE_STATUS_HSE)
- || ((sysclk_source == RCC_SYSCLKSOURCE_STATUS_PLLCLK) && (pll_config == RCC_PLLSOURCE_HSE)))
- {
- if((__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != 0U) && (RCC_OscInitStruct->HSEState == RCC_HSE_OFF))
- {
- return HAL_ERROR;
- }
- }
- else
- {
- /* Set the new HSE configuration ---------------------------------------*/
- __HAL_RCC_HSE_CONFIG(RCC_OscInitStruct->HSEState);
-
- /* Check the HSE State */
- if(RCC_OscInitStruct->HSEState != RCC_HSE_OFF)
- {
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till HSE is ready */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == 0U)
- {
- if((HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- else
- {
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till HSE is disabled */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) != 0U)
- {
- if((HAL_GetTick() - tickstart ) > HSE_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- }
- }
- /*----------------------------- HSI Configuration --------------------------*/
- if(((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_HSI) == RCC_OSCILLATORTYPE_HSI)
- {
- /* Check the parameters */
- assert_param(IS_RCC_HSI(RCC_OscInitStruct->HSIState));
- assert_param(IS_RCC_CALIBRATION_VALUE(RCC_OscInitStruct->HSICalibrationValue));
-
- /* Check if HSI is used as system clock or as PLL source when PLL is selected as system clock */
- if((sysclk_source == RCC_SYSCLKSOURCE_STATUS_HSI)
- || ((sysclk_source == RCC_SYSCLKSOURCE_STATUS_PLLCLK) && (pll_config == RCC_PLLSOURCE_HSI)))
- {
- /* When HSI is used as system clock it will not disabled */
- if((__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != 0U) && (RCC_OscInitStruct->HSIState != RCC_HSI_ON))
- {
- return HAL_ERROR;
- }
- /* Otherwise, just the calibration is allowed */
- else
- {
- /* Adjusts the Internal High Speed oscillator (HSI) calibration value.*/
- __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct->HSICalibrationValue);
- }
- }
- else
- {
- /* Check the HSI State */
- if(RCC_OscInitStruct->HSIState != RCC_HSI_OFF)
- {
- /* Enable the Internal High Speed oscillator (HSI). */
- __HAL_RCC_HSI_ENABLE();
-
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till HSI is ready */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == 0U)
- {
- if((HAL_GetTick() - tickstart ) > HSI_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
-
- /* Adjusts the Internal High Speed oscillator (HSI) calibration value.*/
- __HAL_RCC_HSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct->HSICalibrationValue);
- }
- else
- {
- /* Disable the Internal High Speed oscillator (HSI). */
- __HAL_RCC_HSI_DISABLE();
-
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till HSI is disabled */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) != 0U)
- {
- if((HAL_GetTick() - tickstart ) > HSI_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- }
- }
- /*----------------------------- MSI Configuration --------------------------*/
- if(((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_MSI) == RCC_OSCILLATORTYPE_MSI)
- {
- /* When the MSI is used as system clock it will not be disabled */
- if(sysclk_source == RCC_CFGR_SWS_MSI)
- {
- if((__HAL_RCC_GET_FLAG(RCC_FLAG_MSIRDY) != 0U) && (RCC_OscInitStruct->MSIState == RCC_MSI_OFF))
- {
- return HAL_ERROR;
- }
- /* Otherwise, just the calibration and MSI range change are allowed */
- else
- {
- /* Check MSICalibrationValue and MSIClockRange input parameters */
- assert_param(IS_RCC_MSICALIBRATION_VALUE(RCC_OscInitStruct->MSICalibrationValue));
- assert_param(IS_RCC_MSI_CLOCK_RANGE(RCC_OscInitStruct->MSIClockRange));
-
- /* To correctly read data from FLASH memory, the number of wait states (LATENCY)
- must be correctly programmed according to the frequency of the CPU clock
- (HCLK) and the supply voltage of the device. */
- if(RCC_OscInitStruct->MSIClockRange > __HAL_RCC_GET_MSI_RANGE())
- {
- /* First increase number of wait states update if necessary */
- if(RCC_SetFlashLatencyFromMSIRange(RCC_OscInitStruct->MSIClockRange) != HAL_OK)
- {
- return HAL_ERROR;
- }
-
- /* Selects the Multiple Speed oscillator (MSI) clock range .*/
- __HAL_RCC_MSI_RANGE_CONFIG(RCC_OscInitStruct->MSIClockRange);
- /* Adjusts the Multiple Speed oscillator (MSI) calibration value.*/
- __HAL_RCC_MSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct->MSICalibrationValue);
- }
- else
- {
- /* Else, keep current flash latency while decreasing applies */
- /* Selects the Multiple Speed oscillator (MSI) clock range .*/
- __HAL_RCC_MSI_RANGE_CONFIG(RCC_OscInitStruct->MSIClockRange);
- /* Adjusts the Multiple Speed oscillator (MSI) calibration value.*/
- __HAL_RCC_MSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct->MSICalibrationValue);
-
- /* Decrease number of wait states update if necessary */
- if(RCC_SetFlashLatencyFromMSIRange(RCC_OscInitStruct->MSIClockRange) != HAL_OK)
- {
- return HAL_ERROR;
- }
- }
-
- /* Update the SystemCoreClock global variable */
- SystemCoreClock = (32768U * (1UL << ((RCC_OscInitStruct->MSIClockRange >> RCC_ICSCR_MSIRANGE_Pos) + 1U)))
- >> AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> RCC_CFGR_HPRE_Pos)];
-
- /* Configure the source of time base considering new system clocks settings*/
- status = HAL_InitTick(uwTickPrio);
- if(status != HAL_OK)
- {
- return status;
- }
- }
- }
- else
- {
- /* Check MSI State */
- assert_param(IS_RCC_MSI(RCC_OscInitStruct->MSIState));
-
- /* Check the MSI State */
- if(RCC_OscInitStruct->MSIState != RCC_MSI_OFF)
- {
- /* Enable the Multi Speed oscillator (MSI). */
- __HAL_RCC_MSI_ENABLE();
-
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till MSI is ready */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_MSIRDY) == 0U)
- {
- if((HAL_GetTick() - tickstart) > MSI_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- /* Check MSICalibrationValue and MSIClockRange input parameters */
- assert_param(IS_RCC_MSICALIBRATION_VALUE(RCC_OscInitStruct->MSICalibrationValue));
- assert_param(IS_RCC_MSI_CLOCK_RANGE(RCC_OscInitStruct->MSIClockRange));
-
- /* Selects the Multiple Speed oscillator (MSI) clock range .*/
- __HAL_RCC_MSI_RANGE_CONFIG(RCC_OscInitStruct->MSIClockRange);
- /* Adjusts the Multiple Speed oscillator (MSI) calibration value.*/
- __HAL_RCC_MSI_CALIBRATIONVALUE_ADJUST(RCC_OscInitStruct->MSICalibrationValue);
-
- }
- else
- {
- /* Disable the Multi Speed oscillator (MSI). */
- __HAL_RCC_MSI_DISABLE();
-
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till MSI is ready */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_MSIRDY) != 0U)
- {
- if((HAL_GetTick() - tickstart) > MSI_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- }
- }
- /*------------------------------ LSI Configuration -------------------------*/
- if(((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_LSI) == RCC_OSCILLATORTYPE_LSI)
- {
- /* Check the parameters */
- assert_param(IS_RCC_LSI(RCC_OscInitStruct->LSIState));
-
- /* Check the LSI State */
- if(RCC_OscInitStruct->LSIState != RCC_LSI_OFF)
- {
- /* Enable the Internal Low Speed oscillator (LSI). */
- __HAL_RCC_LSI_ENABLE();
-
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till LSI is ready */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) == 0U)
- {
- if((HAL_GetTick() - tickstart ) > LSI_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- else
- {
- /* Disable the Internal Low Speed oscillator (LSI). */
- __HAL_RCC_LSI_DISABLE();
-
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till LSI is disabled */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSIRDY) != 0U)
- {
- if((HAL_GetTick() - tickstart ) > LSI_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- }
- /*------------------------------ LSE Configuration -------------------------*/
- if(((RCC_OscInitStruct->OscillatorType) & RCC_OSCILLATORTYPE_LSE) == RCC_OSCILLATORTYPE_LSE)
- {
- FlagStatus pwrclkchanged = RESET;
-
- /* Check the parameters */
- assert_param(IS_RCC_LSE(RCC_OscInitStruct->LSEState));
-
- /* Update LSE configuration in Backup Domain control register */
- /* Requires to enable write access to Backup Domain of necessary */
- if(__HAL_RCC_PWR_IS_CLK_DISABLED())
- {
- __HAL_RCC_PWR_CLK_ENABLE();
- pwrclkchanged = SET;
- }
-
- if(HAL_IS_BIT_CLR(PWR->CR, PWR_CR_DBP))
- {
- /* Enable write access to Backup domain */
- SET_BIT(PWR->CR, PWR_CR_DBP);
-
- /* Wait for Backup domain Write protection disable */
- tickstart = HAL_GetTick();
-
- while(HAL_IS_BIT_CLR(PWR->CR, PWR_CR_DBP))
- {
- if((HAL_GetTick() - tickstart) > RCC_DBP_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Set the new LSE configuration -----------------------------------------*/
- __HAL_RCC_LSE_CONFIG(RCC_OscInitStruct->LSEState);
- /* Check the LSE State */
- if(RCC_OscInitStruct->LSEState != RCC_LSE_OFF)
- {
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till LSE is ready */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == 0U)
- {
- if((HAL_GetTick() - tickstart ) > RCC_LSE_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- else
- {
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till LSE is disabled */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) != 0U)
- {
- if((HAL_GetTick() - tickstart ) > RCC_LSE_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Require to disable power clock if necessary */
- if(pwrclkchanged == SET)
- {
- __HAL_RCC_PWR_CLK_DISABLE();
- }
- }
-
- /*-------------------------------- PLL Configuration -----------------------*/
- /* Check the parameters */
- assert_param(IS_RCC_PLL(RCC_OscInitStruct->PLL.PLLState));
- if ((RCC_OscInitStruct->PLL.PLLState) != RCC_PLL_NONE)
- {
- /* Check if the PLL is used as system clock or not */
- if(sysclk_source != RCC_SYSCLKSOURCE_STATUS_PLLCLK)
- {
- if((RCC_OscInitStruct->PLL.PLLState) == RCC_PLL_ON)
- {
- /* Check the parameters */
- assert_param(IS_RCC_PLLSOURCE(RCC_OscInitStruct->PLL.PLLSource));
- assert_param(IS_RCC_PLL_MUL(RCC_OscInitStruct->PLL.PLLMUL));
- assert_param(IS_RCC_PLL_DIV(RCC_OscInitStruct->PLL.PLLDIV));
-
- /* Disable the main PLL. */
- __HAL_RCC_PLL_DISABLE();
-
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till PLL is disabled */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) != 0U)
- {
- if((HAL_GetTick() - tickstart ) > PLL_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
-
- /* Configure the main PLL clock source, multiplication and division factors. */
- __HAL_RCC_PLL_CONFIG(RCC_OscInitStruct->PLL.PLLSource,
- RCC_OscInitStruct->PLL.PLLMUL,
- RCC_OscInitStruct->PLL.PLLDIV);
- /* Enable the main PLL. */
- __HAL_RCC_PLL_ENABLE();
-
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till PLL is ready */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) == 0U)
- {
- if((HAL_GetTick() - tickstart ) > PLL_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- else
- {
- /* Disable the main PLL. */
- __HAL_RCC_PLL_DISABLE();
-
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till PLL is disabled */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) != 0U)
- {
- if((HAL_GetTick() - tickstart ) > PLL_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- }
- else
- {
- /* Check if there is a request to disable the PLL used as System clock source */
- if((RCC_OscInitStruct->PLL.PLLState) == RCC_PLL_OFF)
- {
- return HAL_ERROR;
- }
- else
- {
- /* Do not return HAL_ERROR if request repeats the current configuration */
- pll_config = RCC->CFGR;
- if((READ_BIT(pll_config, RCC_CFGR_PLLSRC) != RCC_OscInitStruct->PLL.PLLSource) ||
- (READ_BIT(pll_config, RCC_CFGR_PLLMUL) != RCC_OscInitStruct->PLL.PLLMUL) ||
- (READ_BIT(pll_config, RCC_CFGR_PLLDIV) != RCC_OscInitStruct->PLL.PLLDIV))
- {
- return HAL_ERROR;
- }
- }
- }
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Initializes the CPU, AHB and APB buses clocks according to the specified
- * parameters in the RCC_ClkInitStruct.
- * @param RCC_ClkInitStruct pointer to an RCC_OscInitTypeDef structure that
- * contains the configuration information for the RCC peripheral.
- * @param FLatency FLASH Latency
- * The value of this parameter depend on device used within the same series
- * @note The SystemCoreClock CMSIS variable is used to store System Clock Frequency
- * and updated by @ref HAL_RCC_GetHCLKFreq() function called within this function
- *
- * @note The MSI is used (enabled by hardware) as system clock source after
- * start-up from Reset, wake-up from STOP and STANDBY mode, or in case
- * of failure of the HSE used directly or indirectly as system clock
- * (if the Clock Security System CSS is enabled).
- *
- * @note A switch from one clock source to another occurs only if the target
- * clock source is ready (clock stable after start-up delay or PLL locked).
- * If a clock source which is not yet ready is selected, the switch will
- * occur when the clock source will be ready.
- * You can use @ref HAL_RCC_GetClockConfig() function to know which clock is
- * currently used as system clock source.
- * @note Depending on the device voltage range, the software has to set correctly
- * HPRE[3:0] bits to ensure that HCLK not exceed the maximum allowed frequency
- * (for more details refer to section above "Initialization/de-initialization functions")
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RCC_ClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t FLatency)
-{
- uint32_t tickstart;
- HAL_StatusTypeDef status;
-
- /* Check the parameters */
- if(RCC_ClkInitStruct == NULL)
- {
- return HAL_ERROR;
- }
-
- assert_param(IS_FLASH_LATENCY(FLatency));
-
- /* To correctly read data from FLASH memory, the number of wait states (LATENCY)
- must be correctly programmed according to the frequency of the CPU clock
- (HCLK) and the supply voltage of the device. */
-
- /* Increasing the number of wait states because of higher CPU frequency */
- if(FLatency > __HAL_FLASH_GET_LATENCY())
- {
- /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
- __HAL_FLASH_SET_LATENCY(FLatency);
-
- /* Check that the new number of wait states is taken into account to access the Flash
- memory by reading the FLASH_ACR register */
- if(__HAL_FLASH_GET_LATENCY() != FLatency)
- {
- return HAL_ERROR;
- }
- }
-
- /*-------------------------- HCLK Configuration --------------------------*/
- if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_HCLK) == RCC_CLOCKTYPE_HCLK)
- {
- assert_param(IS_RCC_HCLK(RCC_ClkInitStruct->AHBCLKDivider));
- MODIFY_REG(RCC->CFGR, RCC_CFGR_HPRE, RCC_ClkInitStruct->AHBCLKDivider);
- }
-
- /*------------------------- SYSCLK Configuration ---------------------------*/
- if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_SYSCLK) == RCC_CLOCKTYPE_SYSCLK)
- {
- assert_param(IS_RCC_SYSCLKSOURCE(RCC_ClkInitStruct->SYSCLKSource));
-
- /* HSE is selected as System Clock Source */
- if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE)
- {
- /* Check the HSE ready flag */
- if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSERDY) == 0U)
- {
- return HAL_ERROR;
- }
- }
- /* PLL is selected as System Clock Source */
- else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLCLK)
- {
- /* Check the PLL ready flag */
- if(__HAL_RCC_GET_FLAG(RCC_FLAG_PLLRDY) == 0U)
- {
- return HAL_ERROR;
- }
- }
- /* HSI is selected as System Clock Source */
- else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSI)
- {
- /* Check the HSI ready flag */
- if(__HAL_RCC_GET_FLAG(RCC_FLAG_HSIRDY) == 0U)
- {
- return HAL_ERROR;
- }
- }
- /* MSI is selected as System Clock Source */
- else
- {
- /* Check the MSI ready flag */
- if(__HAL_RCC_GET_FLAG(RCC_FLAG_MSIRDY) == 0U)
- {
- return HAL_ERROR;
- }
- }
- __HAL_RCC_SYSCLK_CONFIG(RCC_ClkInitStruct->SYSCLKSource);
-
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSE)
- {
- while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_HSE)
- {
- if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_PLLCLK)
- {
- while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_PLLCLK)
- {
- if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- else if(RCC_ClkInitStruct->SYSCLKSource == RCC_SYSCLKSOURCE_HSI)
- {
- while (__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_HSI)
- {
- if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- else
- {
- while(__HAL_RCC_GET_SYSCLK_SOURCE() != RCC_SYSCLKSOURCE_STATUS_MSI)
- {
- if((HAL_GetTick() - tickstart ) > CLOCKSWITCH_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- }
- /* Decreasing the number of wait states because of lower CPU frequency */
- if(FLatency < __HAL_FLASH_GET_LATENCY())
- {
- /* Program the new number of wait states to the LATENCY bits in the FLASH_ACR register */
- __HAL_FLASH_SET_LATENCY(FLatency);
-
- /* Check that the new number of wait states is taken into account to access the Flash
- memory by reading the FLASH_ACR register */
- if(__HAL_FLASH_GET_LATENCY() != FLatency)
- {
- return HAL_ERROR;
- }
- }
-
- /*-------------------------- PCLK1 Configuration ---------------------------*/
- if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_PCLK1) == RCC_CLOCKTYPE_PCLK1)
- {
- assert_param(IS_RCC_PCLK(RCC_ClkInitStruct->APB1CLKDivider));
- MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE1, RCC_ClkInitStruct->APB1CLKDivider);
- }
-
- /*-------------------------- PCLK2 Configuration ---------------------------*/
- if(((RCC_ClkInitStruct->ClockType) & RCC_CLOCKTYPE_PCLK2) == RCC_CLOCKTYPE_PCLK2)
- {
- assert_param(IS_RCC_PCLK(RCC_ClkInitStruct->APB2CLKDivider));
- MODIFY_REG(RCC->CFGR, RCC_CFGR_PPRE2, ((RCC_ClkInitStruct->APB2CLKDivider) << 3U));
- }
-
- /* Update the SystemCoreClock global variable */
- SystemCoreClock = HAL_RCC_GetSysClockFreq() >> AHBPrescTable[(RCC->CFGR & RCC_CFGR_HPRE)>> RCC_CFGR_HPRE_Pos];
-
- /* Configure the source of time base considering new system clocks settings*/
- status = HAL_InitTick(uwTickPrio);
-
- return status;
-}
-
-/**
- * @}
- */
-
-/** @defgroup RCC_Exported_Functions_Group2 Peripheral Control functions
- * @brief RCC clocks control functions
- *
- @verbatim
- ===============================================================================
- ##### Peripheral Control functions #####
- ===============================================================================
- [..]
- This subsection provides a set of functions allowing to control the RCC Clocks
- frequencies.
-
- @endverbatim
- * @{
- */
-
-/**
- * @brief Selects the clock source to output on MCO pin.
- * @note MCO pin should be configured in alternate function mode.
- * @param RCC_MCOx specifies the output direction for the clock source.
- * This parameter can be one of the following values:
- * @arg @ref RCC_MCO1 Clock source to output on MCO1 pin(PA8).
- * @param RCC_MCOSource specifies the clock source to output.
- * This parameter can be one of the following values:
- * @arg @ref RCC_MCO1SOURCE_NOCLOCK No clock selected as MCO clock
- * @arg @ref RCC_MCO1SOURCE_SYSCLK System clock selected as MCO clock
- * @arg @ref RCC_MCO1SOURCE_HSI HSI selected as MCO clock
- * @arg @ref RCC_MCO1SOURCE_HSE HSE selected as MCO clock
- * @arg @ref RCC_MCO1SOURCE_MSI MSI oscillator clock selected as MCO clock
- * @arg @ref RCC_MCO1SOURCE_PLLCLK PLL clock selected as MCO clock
- * @arg @ref RCC_MCO1SOURCE_LSI LSI clock selected as MCO clock
- * @arg @ref RCC_MCO1SOURCE_LSE LSE clock selected as MCO clock
- * @param RCC_MCODiv specifies the MCO DIV.
- * This parameter can be one of the following values:
- * @arg @ref RCC_MCODIV_1 no division applied to MCO clock
- * @arg @ref RCC_MCODIV_2 division by 2 applied to MCO clock
- * @arg @ref RCC_MCODIV_4 division by 4 applied to MCO clock
- * @arg @ref RCC_MCODIV_8 division by 8 applied to MCO clock
- * @arg @ref RCC_MCODIV_16 division by 16 applied to MCO clock
- * @retval None
- */
-void HAL_RCC_MCOConfig(uint32_t RCC_MCOx, uint32_t RCC_MCOSource, uint32_t RCC_MCODiv)
-{
- GPIO_InitTypeDef gpio;
-
- /* Check the parameters */
- assert_param(IS_RCC_MCO(RCC_MCOx));
- assert_param(IS_RCC_MCODIV(RCC_MCODiv));
- assert_param(IS_RCC_MCO1SOURCE(RCC_MCOSource));
-
- /* Configure the MCO1 pin in alternate function mode */
- gpio.Mode = GPIO_MODE_AF_PP;
- gpio.Speed = GPIO_SPEED_FREQ_HIGH;
- gpio.Pull = GPIO_NOPULL;
- gpio.Pin = MCO1_PIN;
- gpio.Alternate = GPIO_AF0_MCO;
-
- /* MCO1 Clock Enable */
- MCO1_CLK_ENABLE();
-
- HAL_GPIO_Init(MCO1_GPIO_PORT, &gpio);
-
- /* Configure the MCO clock source */
- __HAL_RCC_MCO1_CONFIG(RCC_MCOSource, RCC_MCODiv);
-}
-
-/**
- * @brief Enables the Clock Security System.
- * @note If a failure is detected on the HSE oscillator clock, this oscillator
- * is automatically disabled and an interrupt is generated to inform the
- * software about the failure (Clock Security System Interrupt, CSSI),
- * allowing the MCU to perform rescue operations. The CSSI is linked to
- * the Cortex-M3 NMI (Non-Maskable Interrupt) exception vector.
- * @retval None
- */
-void HAL_RCC_EnableCSS(void)
-{
- *(__IO uint32_t *) RCC_CR_CSSON_BB = (uint32_t)ENABLE;
-}
-
-/**
- * @brief Disables the Clock Security System.
- * @retval None
- */
-void HAL_RCC_DisableCSS(void)
-{
- *(__IO uint32_t *) RCC_CR_CSSON_BB = (uint32_t)DISABLE;
-}
-
-/**
- * @brief Returns the SYSCLK frequency
- * @note The system frequency computed by this function is not the real
- * frequency in the chip. It is calculated based on the predefined
- * constant and the selected clock source:
- * @note If SYSCLK source is MSI, function returns a value based on MSI
- * Value as defined by the MSI range.
- * @note If SYSCLK source is HSI, function returns values based on HSI_VALUE(*)
- * @note If SYSCLK source is HSE, function returns a value based on HSE_VALUE(**)
- * @note If SYSCLK source is PLL, function returns a value based on HSE_VALUE(**)
- * or HSI_VALUE(*) multiplied/divided by the PLL factors.
- * @note (*) HSI_VALUE is a constant defined in stm32l1xx_hal_conf.h file (default value
- * 16 MHz) but the real value may vary depending on the variations
- * in voltage and temperature.
- * @note (**) HSE_VALUE is a constant defined in stm32l1xx_hal_conf.h file (default value
- * 8 MHz), user has to ensure that HSE_VALUE is same as the real
- * frequency of the crystal used. Otherwise, this function may
- * have wrong result.
- *
- * @note The result of this function could be not correct when using fractional
- * value for HSE crystal.
- *
- * @note This function can be used by the user application to compute the
- * baud-rate for the communication peripherals or configure other parameters.
- *
- * @note Each time SYSCLK changes, this function must be called to update the
- * right SYSCLK value. Otherwise, any configuration based on this function will be incorrect.
- *
- * @retval SYSCLK frequency
- */
-uint32_t HAL_RCC_GetSysClockFreq(void)
-{
- uint32_t tmpreg, pllm, plld, pllvco, msiclkrange, sysclockfreq;
-
- tmpreg = RCC->CFGR;
-
- /* Get SYSCLK source -------------------------------------------------------*/
- switch (tmpreg & RCC_CFGR_SWS)
- {
- case RCC_SYSCLKSOURCE_STATUS_HSI: /* HSI used as system clock source */
- {
- sysclockfreq = HSI_VALUE;
- break;
- }
- case RCC_SYSCLKSOURCE_STATUS_HSE: /* HSE used as system clock */
- {
- sysclockfreq = HSE_VALUE;
- break;
- }
- case RCC_SYSCLKSOURCE_STATUS_PLLCLK: /* PLL used as system clock */
- {
- pllm = PLLMulTable[(uint32_t)(tmpreg & RCC_CFGR_PLLMUL) >> RCC_CFGR_PLLMUL_Pos];
- plld = ((uint32_t)(tmpreg & RCC_CFGR_PLLDIV) >> RCC_CFGR_PLLDIV_Pos) + 1U;
- if (__HAL_RCC_GET_PLL_OSCSOURCE() != RCC_PLLSOURCE_HSI)
- {
- /* HSE used as PLL clock source */
- pllvco = (uint32_t)(((uint64_t)HSE_VALUE * (uint64_t)pllm) / (uint64_t)plld);
- }
- else
- {
- /* HSI used as PLL clock source */
- pllvco = (uint32_t)(((uint64_t)HSI_VALUE * (uint64_t)pllm) / (uint64_t)plld);
- }
- sysclockfreq = pllvco;
- break;
- }
- case RCC_SYSCLKSOURCE_STATUS_MSI: /* MSI used as system clock source */
- default: /* MSI used as system clock */
- {
- msiclkrange = (RCC->ICSCR & RCC_ICSCR_MSIRANGE ) >> RCC_ICSCR_MSIRANGE_Pos;
- sysclockfreq = (32768U * (1UL << (msiclkrange + 1U)));
- break;
- }
- }
- return sysclockfreq;
-}
-
-/**
- * @brief Returns the HCLK frequency
- * @note Each time HCLK changes, this function must be called to update the
- * right HCLK value. Otherwise, any configuration based on this function will be incorrect.
- *
- * @note The SystemCoreClock CMSIS variable is used to store System Clock Frequency
- * and updated within this function
- * @retval HCLK frequency
- */
-uint32_t HAL_RCC_GetHCLKFreq(void)
-{
- return SystemCoreClock;
-}
-
-/**
- * @brief Returns the PCLK1 frequency
- * @note Each time PCLK1 changes, this function must be called to update the
- * right PCLK1 value. Otherwise, any configuration based on this function will be incorrect.
- * @retval PCLK1 frequency
- */
-uint32_t HAL_RCC_GetPCLK1Freq(void)
-{
- /* Get HCLK source and Compute PCLK1 frequency ---------------------------*/
- return (HAL_RCC_GetHCLKFreq() >> APBPrescTable[(RCC->CFGR & RCC_CFGR_PPRE1) >> RCC_CFGR_PPRE1_Pos]);
-}
-
-/**
- * @brief Returns the PCLK2 frequency
- * @note Each time PCLK2 changes, this function must be called to update the
- * right PCLK2 value. Otherwise, any configuration based on this function will be incorrect.
- * @retval PCLK2 frequency
- */
-uint32_t HAL_RCC_GetPCLK2Freq(void)
-{
- /* Get HCLK source and Compute PCLK2 frequency ---------------------------*/
- return (HAL_RCC_GetHCLKFreq()>> APBPrescTable[(RCC->CFGR & RCC_CFGR_PPRE2) >> RCC_CFGR_PPRE2_Pos]);
-}
-
-/**
- * @brief Configures the RCC_OscInitStruct according to the internal
- * RCC configuration registers.
- * @param RCC_OscInitStruct pointer to an RCC_OscInitTypeDef structure that
- * will be configured.
- * @retval None
- */
-void HAL_RCC_GetOscConfig(RCC_OscInitTypeDef *RCC_OscInitStruct)
-{
- /* Check the parameters */
- assert_param(RCC_OscInitStruct != (void *)NULL);
-
- /* Set all possible values for the Oscillator type parameter ---------------*/
- RCC_OscInitStruct->OscillatorType = RCC_OSCILLATORTYPE_HSE | RCC_OSCILLATORTYPE_HSI \
- | RCC_OSCILLATORTYPE_LSE | RCC_OSCILLATORTYPE_LSI | RCC_OSCILLATORTYPE_MSI;
-
-
- /* Get the HSE configuration -----------------------------------------------*/
- if((RCC->CR &RCC_CR_HSEBYP) == RCC_CR_HSEBYP)
- {
- RCC_OscInitStruct->HSEState = RCC_HSE_BYPASS;
- }
- else if((RCC->CR &RCC_CR_HSEON) == RCC_CR_HSEON)
- {
- RCC_OscInitStruct->HSEState = RCC_HSE_ON;
- }
- else
- {
- RCC_OscInitStruct->HSEState = RCC_HSE_OFF;
- }
-
- /* Get the HSI configuration -----------------------------------------------*/
- if((RCC->CR &RCC_CR_HSION) == RCC_CR_HSION)
- {
- RCC_OscInitStruct->HSIState = RCC_HSI_ON;
- }
- else
- {
- RCC_OscInitStruct->HSIState = RCC_HSI_OFF;
- }
-
- RCC_OscInitStruct->HSICalibrationValue = (uint32_t)((RCC->ICSCR & RCC_ICSCR_HSITRIM) >> RCC_ICSCR_HSITRIM_Pos);
-
- /* Get the MSI configuration -----------------------------------------------*/
- if((RCC->CR &RCC_CR_MSION) == RCC_CR_MSION)
- {
- RCC_OscInitStruct->MSIState = RCC_MSI_ON;
- }
- else
- {
- RCC_OscInitStruct->MSIState = RCC_MSI_OFF;
- }
-
- RCC_OscInitStruct->MSICalibrationValue = (uint32_t)((RCC->ICSCR & RCC_ICSCR_MSITRIM) >> RCC_ICSCR_MSITRIM_Pos);
- RCC_OscInitStruct->MSIClockRange = (uint32_t)((RCC->ICSCR & RCC_ICSCR_MSIRANGE));
-
- /* Get the LSE configuration -----------------------------------------------*/
- if((RCC->CSR &RCC_CSR_LSEBYP) == RCC_CSR_LSEBYP)
- {
- RCC_OscInitStruct->LSEState = RCC_LSE_BYPASS;
- }
- else if((RCC->CSR &RCC_CSR_LSEON) == RCC_CSR_LSEON)
- {
- RCC_OscInitStruct->LSEState = RCC_LSE_ON;
- }
- else
- {
- RCC_OscInitStruct->LSEState = RCC_LSE_OFF;
- }
-
- /* Get the LSI configuration -----------------------------------------------*/
- if((RCC->CSR &RCC_CSR_LSION) == RCC_CSR_LSION)
- {
- RCC_OscInitStruct->LSIState = RCC_LSI_ON;
- }
- else
- {
- RCC_OscInitStruct->LSIState = RCC_LSI_OFF;
- }
-
-
- /* Get the PLL configuration -----------------------------------------------*/
- if((RCC->CR &RCC_CR_PLLON) == RCC_CR_PLLON)
- {
- RCC_OscInitStruct->PLL.PLLState = RCC_PLL_ON;
- }
- else
- {
- RCC_OscInitStruct->PLL.PLLState = RCC_PLL_OFF;
- }
- RCC_OscInitStruct->PLL.PLLSource = (uint32_t)(RCC->CFGR & RCC_CFGR_PLLSRC);
- RCC_OscInitStruct->PLL.PLLMUL = (uint32_t)(RCC->CFGR & RCC_CFGR_PLLMUL);
- RCC_OscInitStruct->PLL.PLLDIV = (uint32_t)(RCC->CFGR & RCC_CFGR_PLLDIV);
-}
-
-/**
- * @brief Get the RCC_ClkInitStruct according to the internal
- * RCC configuration registers.
- * @param RCC_ClkInitStruct pointer to an RCC_ClkInitTypeDef structure that
- * contains the current clock configuration.
- * @param pFLatency Pointer on the Flash Latency.
- * @retval None
- */
-void HAL_RCC_GetClockConfig(RCC_ClkInitTypeDef *RCC_ClkInitStruct, uint32_t *pFLatency)
-{
- /* Check the parameters */
- assert_param(RCC_ClkInitStruct != (void *)NULL);
- assert_param(pFLatency != (void *)NULL);
-
- /* Set all possible values for the Clock type parameter --------------------*/
- RCC_ClkInitStruct->ClockType = RCC_CLOCKTYPE_SYSCLK | RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
-
- /* Get the SYSCLK configuration --------------------------------------------*/
- RCC_ClkInitStruct->SYSCLKSource = (uint32_t)(RCC->CFGR & RCC_CFGR_SW);
-
- /* Get the HCLK configuration ----------------------------------------------*/
- RCC_ClkInitStruct->AHBCLKDivider = (uint32_t)(RCC->CFGR & RCC_CFGR_HPRE);
-
- /* Get the APB1 configuration ----------------------------------------------*/
- RCC_ClkInitStruct->APB1CLKDivider = (uint32_t)(RCC->CFGR & RCC_CFGR_PPRE1);
-
- /* Get the APB2 configuration ----------------------------------------------*/
- RCC_ClkInitStruct->APB2CLKDivider = (uint32_t)((RCC->CFGR & RCC_CFGR_PPRE2) >> 3U);
-
- /* Get the Flash Wait State (Latency) configuration ------------------------*/
- *pFLatency = __HAL_FLASH_GET_LATENCY();
-}
-
-/**
- * @brief This function handles the RCC CSS interrupt request.
- * @note This API should be called under the NMI_Handler().
- * @retval None
- */
-void HAL_RCC_NMI_IRQHandler(void)
-{
- /* Check RCC CSSF flag */
- if(__HAL_RCC_GET_IT(RCC_IT_CSS))
- {
- /* RCC Clock Security System interrupt user callback */
- HAL_RCC_CSSCallback();
-
- /* Clear RCC CSS pending bit */
- __HAL_RCC_CLEAR_IT(RCC_IT_CSS);
- }
-}
-
-/**
- * @brief RCC Clock Security System interrupt callback
- * @retval none
- */
-__weak void HAL_RCC_CSSCallback(void)
-{
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_RCC_CSSCallback could be implemented in the user file
- */
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/* Private function prototypes -----------------------------------------------*/
-/** @addtogroup RCC_Private_Functions
- * @{
- */
-/**
- * @brief Update number of Flash wait states in line with MSI range and current
- voltage range
- * @param MSIrange MSI range value from RCC_MSIRANGE_0 to RCC_MSIRANGE_6
- * @retval HAL status
- */
-static HAL_StatusTypeDef RCC_SetFlashLatencyFromMSIRange(uint32_t MSIrange)
-{
- uint32_t vos;
- uint32_t latency = FLASH_LATENCY_0; /* default value 0WS */
-
- /* HCLK can reach 4 MHz only if AHB prescaler = 1 */
- if (READ_BIT(RCC->CFGR, RCC_CFGR_HPRE) == RCC_SYSCLK_DIV1)
- {
- if(__HAL_RCC_PWR_IS_CLK_ENABLED())
- {
- vos = READ_BIT(PWR->CR, PWR_CR_VOS);
- }
- else
- {
- __HAL_RCC_PWR_CLK_ENABLE();
- vos = READ_BIT(PWR->CR, PWR_CR_VOS);
- __HAL_RCC_PWR_CLK_DISABLE();
- }
-
- /* Check if need to set latency 1 only for Range 3 & HCLK = 4MHz */
- if((vos == PWR_REGULATOR_VOLTAGE_SCALE3) && (MSIrange == RCC_MSIRANGE_6))
- {
- latency = FLASH_LATENCY_1; /* 1WS */
- }
- }
-
- __HAL_FLASH_SET_LATENCY(latency);
-
- /* Check that the new number of wait states is taken into account to access the Flash
- memory by reading the FLASH_ACR register */
- if(__HAL_FLASH_GET_LATENCY() != latency)
- {
- return HAL_ERROR;
- }
-
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-#endif /* HAL_RCC_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rcc_ex.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rcc_ex.c
deleted file mode 100644
index 5b900414706..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rcc_ex.c
+++ /dev/null
@@ -1,450 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_rcc_ex.c
- * @author MCD Application Team
- * @brief Extended RCC HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities RCC extension peripheral:
- * + Extended Peripheral Control functions
- *
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-#ifdef HAL_RCC_MODULE_ENABLED
-
-/** @defgroup RCCEx RCCEx
- * @brief RCC Extension HAL module driver
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/** @defgroup RCCEx_Private_Constants RCCEx Private Constants
- * @{
- */
-/**
- * @}
- */
-
-/* Private macro -------------------------------------------------------------*/
-/** @defgroup RCCEx_Private_Macros RCCEx Private Macros
- * @{
- */
-/**
- * @}
- */
-
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Private functions ---------------------------------------------------------*/
-
-/** @defgroup RCCEx_Exported_Functions RCCEx Exported Functions
- * @{
- */
-
-/** @defgroup RCCEx_Exported_Functions_Group1 Extended Peripheral Control functions
- * @brief Extended Peripheral Control functions
- *
-@verbatim
- ===============================================================================
- ##### Extended Peripheral Control functions #####
- ===============================================================================
- [..]
- This subsection provides a set of functions allowing to control the RCC Clocks
- frequencies.
- [..]
- (@) Important note: Care must be taken when HAL_RCCEx_PeriphCLKConfig() is used to
- select the RTC clock source; in this case the Backup domain will be reset in
- order to modify the RTC Clock source, as consequence RTC registers (including
- the backup registers) are set to their reset values.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initializes the RCC extended peripherals clocks according to the specified
- * parameters in the RCC_PeriphCLKInitTypeDef.
- * @param PeriphClkInit pointer to an RCC_PeriphCLKInitTypeDef structure that
- * contains the configuration information for the Extended Peripherals clocks(RTC/LCD clock).
- * @retval HAL status
- * @note If HAL_ERROR returned, first switch-OFF HSE clock oscillator with @ref HAL_RCC_OscConfig()
- * to possibly update HSE divider.
- */
-HAL_StatusTypeDef HAL_RCCEx_PeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
-{
- uint32_t tickstart;
- uint32_t temp_reg;
-
- /* Check the parameters */
- assert_param(IS_RCC_PERIPHCLOCK(PeriphClkInit->PeriphClockSelection));
-
- /*------------------------------- RTC/LCD Configuration ------------------------*/
- if ((((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC)
-#if defined(LCD)
- || (((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LCD) == RCC_PERIPHCLK_LCD)
-#endif /* LCD */
- )
- {
- /* check for RTC Parameters used to output RTCCLK */
- if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC)
- {
- assert_param(IS_RCC_RTCCLKSOURCE(PeriphClkInit->RTCClockSelection));
- }
-
-#if defined(LCD)
- if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LCD) == RCC_PERIPHCLK_LCD)
- {
- assert_param(IS_RCC_RTCCLKSOURCE(PeriphClkInit->LCDClockSelection));
- }
-#endif /* LCD */
-
- FlagStatus pwrclkchanged = RESET;
-
- /* As soon as function is called to change RTC clock source, activation of the
- power domain is done. */
- /* Requires to enable write access to Backup Domain of necessary */
- if(__HAL_RCC_PWR_IS_CLK_DISABLED())
- {
- __HAL_RCC_PWR_CLK_ENABLE();
- pwrclkchanged = SET;
- }
-
- if(HAL_IS_BIT_CLR(PWR->CR, PWR_CR_DBP))
- {
- /* Enable write access to Backup domain */
- SET_BIT(PWR->CR, PWR_CR_DBP);
-
- /* Wait for Backup domain Write protection disable */
- tickstart = HAL_GetTick();
-
- while(HAL_IS_BIT_CLR(PWR->CR, PWR_CR_DBP))
- {
- if((HAL_GetTick() - tickstart) > RCC_DBP_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Check if user wants to change HSE RTC prescaler whereas HSE is enabled */
- temp_reg = (RCC->CR & RCC_CR_RTCPRE);
- if ((temp_reg != (PeriphClkInit->RTCClockSelection & RCC_CR_RTCPRE))
-#if defined (LCD)
- || (temp_reg != (PeriphClkInit->LCDClockSelection & RCC_CR_RTCPRE))
-#endif /* LCD */
- )
- { /* Check HSE State */
- if ((PeriphClkInit->RTCClockSelection & RCC_CSR_RTCSEL) == RCC_CSR_RTCSEL_HSE)
- {
- if (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSERDY))
- {
- /* To update HSE divider, first switch-OFF HSE clock oscillator*/
- return HAL_ERROR;
- }
- }
- }
-
- /* Reset the Backup domain only if the RTC Clock source selection is modified from reset value */
- temp_reg = (RCC->CSR & RCC_CSR_RTCSEL);
-
- if((temp_reg != 0x00000000U) && (((temp_reg != (PeriphClkInit->RTCClockSelection & RCC_CSR_RTCSEL)) \
- && (((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC))
-#if defined(LCD)
- || ((temp_reg != (PeriphClkInit->LCDClockSelection & RCC_CSR_RTCSEL)) \
- && (((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LCD) == RCC_PERIPHCLK_LCD))
-#endif /* LCD */
- ))
- {
- /* Store the content of CSR register before the reset of Backup Domain */
- temp_reg = (RCC->CSR & ~(RCC_CSR_RTCSEL));
-
- /* RTC Clock selection can be changed only if the Backup Domain is reset */
- __HAL_RCC_BACKUPRESET_FORCE();
- __HAL_RCC_BACKUPRESET_RELEASE();
-
- /* Restore the Content of CSR register */
- RCC->CSR = temp_reg;
-
- /* Wait for LSERDY if LSE was enabled */
- if (HAL_IS_BIT_SET(temp_reg, RCC_CSR_LSEON))
- {
- /* Get Start Tick */
- tickstart = HAL_GetTick();
-
- /* Wait till LSE is ready */
- while(__HAL_RCC_GET_FLAG(RCC_FLAG_LSERDY) == 0U)
- {
- if((HAL_GetTick() - tickstart ) > RCC_LSE_TIMEOUT_VALUE)
- {
- return HAL_TIMEOUT;
- }
- }
- }
- }
-#if defined(LCD)
- if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_LCD) == RCC_PERIPHCLK_LCD)
- {
- __HAL_RCC_LCD_CONFIG(PeriphClkInit->LCDClockSelection);
- }
-#endif /* LCD */
-
- if(((PeriphClkInit->PeriphClockSelection) & RCC_PERIPHCLK_RTC) == RCC_PERIPHCLK_RTC)
- {
- __HAL_RCC_RTC_CONFIG(PeriphClkInit->RTCClockSelection);
- }
-
- /* Require to disable power clock if necessary */
- if(pwrclkchanged == SET)
- {
- __HAL_RCC_PWR_CLK_DISABLE();
- }
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Get the PeriphClkInit according to the internal RCC configuration registers.
- * @param PeriphClkInit pointer to an RCC_PeriphCLKInitTypeDef structure that
- * returns the configuration information for the Extended Peripherals clocks(RTC/LCD clocks).
- * @retval None
- */
-void HAL_RCCEx_GetPeriphCLKConfig(RCC_PeriphCLKInitTypeDef *PeriphClkInit)
-{
- uint32_t srcclk;
-
- /* Set all possible values for the extended clock type parameter------------*/
- PeriphClkInit->PeriphClockSelection = RCC_PERIPHCLK_RTC;
-#if defined(LCD)
- PeriphClkInit->PeriphClockSelection |= RCC_PERIPHCLK_LCD;
-#endif /* LCD */
-
- /* Get the RTC/LCD configuration -----------------------------------------------*/
- srcclk = __HAL_RCC_GET_RTC_SOURCE();
- if (srcclk != RCC_RTCCLKSOURCE_HSE_DIV2)
- {
- /* Source clock is LSE or LSI*/
- PeriphClkInit->RTCClockSelection = srcclk;
- }
- else
- {
- /* Source clock is HSE. Need to get the prescaler value*/
- PeriphClkInit->RTCClockSelection = srcclk | (READ_BIT(RCC->CR, RCC_CR_RTCPRE));
- }
-#if defined(LCD)
- PeriphClkInit->LCDClockSelection = PeriphClkInit->RTCClockSelection;
-#endif /* LCD */
-}
-
-/**
- * @brief Return the peripheral clock frequency
- * @note Return 0 if peripheral clock is unknown
- * @param PeriphClk Peripheral clock identifier
- * This parameter can be one of the following values:
- * @arg @ref RCC_PERIPHCLK_RTC RTC peripheral clock
- * @arg @ref RCC_PERIPHCLK_LCD LCD peripheral clock (*)
- * @note (*) means that this peripheral is not present on all the devices
- * @retval Frequency in Hz (0: means that no available frequency for the peripheral)
- */
-uint32_t HAL_RCCEx_GetPeriphCLKFreq(uint32_t PeriphClk)
-{
- uint32_t frequency = 0;
- uint32_t srcclk;
-
- /* Check the parameters */
- assert_param(IS_RCC_PERIPHCLOCK(PeriphClk));
-
- switch (PeriphClk)
- {
- case RCC_PERIPHCLK_RTC:
-#if defined(LCD)
- case RCC_PERIPHCLK_LCD:
-#endif /* LCD */
- {
- /* Get the current RTC source */
- srcclk = __HAL_RCC_GET_RTC_SOURCE();
-
- /* Check if LSE is ready if RTC clock selection is LSE */
- if (srcclk == RCC_RTCCLKSOURCE_LSE)
- {
- if (HAL_IS_BIT_SET(RCC->CSR, RCC_CSR_LSERDY))
- {
- frequency = LSE_VALUE;
- }
- }
- /* Check if LSI is ready if RTC clock selection is LSI */
- else if (srcclk == RCC_RTCCLKSOURCE_LSI)
- {
- if (HAL_IS_BIT_SET(RCC->CSR, RCC_CSR_LSIRDY))
- {
- frequency = LSI_VALUE;
- }
- }
- /* Check if HSE is ready and if RTC clock selection is HSE */
- else if (srcclk == RCC_RTCCLKSOURCE_HSE_DIVX)
- {
- if (HAL_IS_BIT_SET(RCC->CR, RCC_CR_HSERDY))
- {
- /* Get the current HSE clock divider */
- switch (__HAL_RCC_GET_RTC_HSE_PRESCALER())
- {
- case RCC_RTC_HSE_DIV_16: /* HSE DIV16 has been selected */
- {
- frequency = HSE_VALUE / 16U;
- break;
- }
- case RCC_RTC_HSE_DIV_8: /* HSE DIV8 has been selected */
- {
- frequency = HSE_VALUE / 8U;
- break;
- }
- case RCC_RTC_HSE_DIV_4: /* HSE DIV4 has been selected */
- {
- frequency = HSE_VALUE / 4U;
- break;
- }
- default: /* HSE DIV2 has been selected */
- {
- frequency = HSE_VALUE / 2U;
- break;
- }
- }
- }
- }
- else
- {
- /* No clock source, frequency default init at 0 */
- }
- break;
- }
-
- default:
- break;
- }
-
- return(frequency);
-}
-
-#if defined(RCC_LSECSS_SUPPORT)
-/**
- * @brief Enables the LSE Clock Security System.
- * @note If a failure is detected on the external 32 kHz oscillator, the LSE clock is no longer supplied
- * to the RTC but no hardware action is made to the registers.
- * In Standby mode a wakeup is generated. In other modes an interrupt can be sent to wakeup
- * the software (see Section 5.3.4: Clock interrupt register (RCC_CIR) on page 104).
- * The software MUST then disable the LSECSSON bit, stop the defective 32 kHz oscillator
- * (disabling LSEON), and can change the RTC clock source (no clock or LSI or HSE, with
- * RTCSEL), or take any required action to secure the application.
- * @note LSE CSS available only for high density and medium+ devices
- * @retval None
- */
-void HAL_RCCEx_EnableLSECSS(void)
-{
- *(__IO uint32_t *) CSR_LSECSSON_BB = (uint32_t)ENABLE;
-}
-
-/**
- * @brief Disables the LSE Clock Security System.
- * @note Once enabled this bit cannot be disabled, except after an LSE failure detection
- * (LSECSSD=1). In that case the software MUST disable the LSECSSON bit.
- * Reset by power on reset and RTC software reset (RTCRST bit).
- * @note LSE CSS available only for high density and medium+ devices
- * @retval None
- */
-void HAL_RCCEx_DisableLSECSS(void)
-{
- /* Disable LSE CSS */
- *(__IO uint32_t *) CSR_LSECSSON_BB = (uint32_t)DISABLE;
-
- /* Disable LSE CSS IT */
- __HAL_RCC_DISABLE_IT(RCC_IT_LSECSS);
-}
-
-/**
- * @brief Enable the LSE Clock Security System IT & corresponding EXTI line.
- * @note LSE Clock Security System IT is mapped on RTC EXTI line 19
- * @retval None
- */
-void HAL_RCCEx_EnableLSECSS_IT(void)
-{
- /* Enable LSE CSS */
- *(__IO uint32_t *) CSR_LSECSSON_BB = (uint32_t)ENABLE;
-
- /* Enable LSE CSS IT */
- __HAL_RCC_ENABLE_IT(RCC_IT_LSECSS);
-
- /* Enable IT on EXTI Line 19 */
- __HAL_RCC_LSECSS_EXTI_ENABLE_IT();
- __HAL_RCC_LSECSS_EXTI_ENABLE_RISING_EDGE();
-}
-
-/**
- * @brief Handle the RCC LSE Clock Security System interrupt request.
- * @retval None
- */
-void HAL_RCCEx_LSECSS_IRQHandler(void)
-{
- /* Check RCC LSE CSSF flag */
- if(__HAL_RCC_GET_IT(RCC_IT_LSECSS))
- {
- /* RCC LSE Clock Security System interrupt user callback */
- HAL_RCCEx_LSECSS_Callback();
-
- /* Clear RCC LSE CSS pending bit */
- __HAL_RCC_CLEAR_IT(RCC_IT_LSECSS);
- }
-}
-
-/**
- * @brief RCCEx LSE Clock Security System interrupt callback.
- * @retval none
- */
-__weak void HAL_RCCEx_LSECSS_Callback(void)
-{
- /* NOTE : This function should not be modified, when the callback is needed,
- the @ref HAL_RCCEx_LSECSS_Callback should be implemented in the user file
- */
-}
-#endif /* RCC_LSECSS_SUPPORT */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* HAL_RCC_MODULE_ENABLED */
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rtc.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rtc.c
deleted file mode 100644
index 1cdb4ef32dd..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_rtc.c
+++ /dev/null
@@ -1,1944 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_rtc.c
- * @author MCD Application Team
- * @brief RTC HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Real Time Clock (RTC) peripheral:
- * + Initialization and de-initialization functions
- * + RTC Time and Date functions
- * + RTC Alarm functions
- * + Peripheral Control functions
- * + Peripheral State functions
- *
- @verbatim
- ===============================================================================
- ##### RTC Operating Condition #####
- ===============================================================================
- [..] The real-time clock (RTC) and the RTC backup registers can be powered
- from the VBAT voltage when the main VDD supply is powered off.
- To retain the content of the RTC backup registers and supply the RTC
- when VDD is turned off, VBAT pin can be connected to an optional
- standby voltage supplied by a battery or by another source.
-
- [..] To allow the RTC operating even when the main digital supply (VDD) is turned
- off, the VBAT pin powers the following blocks:
- (#) The RTC
- (#) The LSE oscillator
- (#) PC13 to PC15 I/Os (when available)
-
- [..] When the backup domain is supplied by VDD (analog switch connected to VDD),
- the following pins are available:
- (#) PC14 and PC15 can be used as either GPIO or LSE pins
- (#) PC13 can be used as a GPIO or as the RTC_AF1 pin
-
- [..] When the backup domain is supplied by VBAT (analog switch connected to VBAT
- because VDD is not present), the following pins are available:
- (#) PC14 and PC15 can be used as LSE pins only
- (#) PC13 can be used as the RTC_AF1 pin
-
- ##### Backup Domain Reset #####
- ===============================================================================
- [..] The backup domain reset sets all RTC registers and the RCC_BDCR register
- to their reset values.
- [..] A backup domain reset is generated when one of the following events occurs:
- (#) Software reset, triggered by setting the BDRST bit in the
- RCC Backup domain control register (RCC_BDCR).
- (#) VDD or VBAT power on, if both supplies have previously been powered off.
-
- ##### Backup Domain Access #####
- ===================================================================
- [..] After reset, the backup domain (RTC registers, RTC backup data
- registers and backup SRAM) is protected against possible unwanted write
- accesses.
- [..] To enable access to the RTC Domain and RTC registers, proceed as follows:
- (+) Enable the Power Controller (PWR) APB1 interface clock using the
- __HAL_RCC_PWR_CLK_ENABLE() function.
- (+) Enable access to RTC domain using the HAL_PWR_EnableBkUpAccess() function.
- (+) Select the RTC clock source using the __HAL_RCC_RTC_CONFIG() function.
- (+) Enable RTC Clock using the __HAL_RCC_RTC_ENABLE() function.
-
-
- ##### How to use RTC Driver #####
- ===================================================================
- [..]
- (+) Enable the RTC domain access (see description in the section above).
- (+) Configure the RTC Prescaler (Asynchronous and Synchronous) and RTC hour
- format using the HAL_RTC_Init() function.
-
- *** Time and Date configuration ***
- ===================================
- [..]
- (+) To configure the RTC Calendar (Time and Date) use the HAL_RTC_SetTime()
- and HAL_RTC_SetDate() functions.
- (+) To read the RTC Calendar, use the HAL_RTC_GetTime() and HAL_RTC_GetDate() functions.
-
- *** Alarm configuration ***
- ===========================
- [..]
- (+) To configure the RTC Alarm use the HAL_RTC_SetAlarm() function.
- You can also configure the RTC Alarm with interrupt mode using the
- HAL_RTC_SetAlarm_IT() function.
- (+) To read the RTC Alarm, use the HAL_RTC_GetAlarm() function.
-
- ##### RTC and low power modes #####
- ==================================================================
- [..] The MCU can be woken up from a low power mode by an RTC alternate
- function.
- [..] The RTC alternate functions are the RTC alarms (Alarm A and Alarm B),
- RTC wakeup, RTC tamper event detection and RTC time stamp event detection.
- These RTC alternate functions can wake up the system from the Stop and
- Standby low power modes.
- [..] The system can also wake up from low power modes without depending
- on an external interrupt (Auto-wakeup mode), by using the RTC alarm
- or the RTC wakeup events.
- [..] The RTC provides a programmable time base for waking up from the
- Stop or Standby mode at regular intervals.
- Wakeup from STOP and STANDBY modes is possible only when the RTC clock source
- is LSE or LSI.
-
- *** Callback registration ***
- =============================================
-
- [..]
- The compilation define USE_RTC_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
- Use Function @ref HAL_RTC_RegisterCallback() to register an interrupt callback.
-
- [..]
- Function @ref HAL_RTC_RegisterCallback() allows to register following callbacks:
- (+) AlarmAEventCallback : RTC Alarm A Event callback.
- (+) AlarmBEventCallback : RTC Alarm B Event callback.
- (+) TimeStampEventCallback : RTC TimeStamp Event callback.
- (+) WakeUpTimerEventCallback : RTC WakeUpTimer Event callback.
- (+) Tamper1EventCallback : RTC Tamper 1 Event callback.
- (+) Tamper2EventCallback : RTC Tamper 2 Event callback.
- (+) Tamper3EventCallback : RTC Tamper 3 Event callback.
- (+) MspInitCallback : RTC MspInit callback.
- (+) MspDeInitCallback : RTC MspDeInit callback.
- [..]
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
-
- [..]
- Use function @ref HAL_RTC_UnRegisterCallback() to reset a callback to the default
- weak function.
- @ref HAL_RTC_UnRegisterCallback() takes as parameters the HAL peripheral handle,
- and the Callback ID.
- This function allows to reset following callbacks:
- (+) AlarmAEventCallback : RTC Alarm A Event callback.
- (+) AlarmBEventCallback : RTC Alarm B Event callback.
- (+) TimeStampEventCallback : RTC TimeStamp Event callback.
- (+) WakeUpTimerEventCallback : RTC WakeUpTimer Event callback.
- (+) Tamper1EventCallback : RTC Tamper 1 Event callback.
- (+) Tamper2EventCallback : RTC Tamper 2 Event callback.
- (+) Tamper3EventCallback : RTC Tamper 3 Event callback.
- (+) MspInitCallback : RTC MspInit callback.
- (+) MspDeInitCallback : RTC MspDeInit callback.
-
- [..]
- By default, after the @ref HAL_RTC_Init() and when the state is HAL_RTC_STATE_RESET,
- all callbacks are set to the corresponding weak functions :
- examples @ref AlarmAEventCallback(), @ref WakeUpTimerEventCallback().
- Exception done for MspInit and MspDeInit callbacks that are reset to the legacy weak function
- in the @ref HAL_RTC_Init()/@ref HAL_RTC_DeInit() only when these callbacks are null
- (not registered beforehand).
- If not, MspInit or MspDeInit are not null, @ref HAL_RTC_Init()/@ref HAL_RTC_DeInit()
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
-
- [..]
- Callbacks can be registered/unregistered in HAL_RTC_STATE_READY state only.
- Exception done MspInit/MspDeInit that can be registered/unregistered
- in HAL_RTC_STATE_READY or HAL_RTC_STATE_RESET state,
- thus registered (user) MspInit/DeInit callbacks can be used during the Init/DeInit.
- In that case first register the MspInit/MspDeInit user callbacks
- using @ref HAL_RTC_RegisterCallback() before calling @ref HAL_RTC_DeInit()
- or @ref HAL_RTC_Init() function.
-
- [..]
- When The compilation define USE_HAL_RTC_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registration feature is not available and all callbacks
- are set to the corresponding weak functions.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @addtogroup RTCEx
- * @brief RTC Extended HAL module driver
- * @{
- */
-
-#ifdef HAL_RTC_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Exported functions --------------------------------------------------------*/
-
-/** @addtogroup RTCEx_Exported_Functions
- * @{
- */
-
-
-/** @addtogroup RTCEx_Exported_Functions_Group1
- * @brief RTC TimeStamp and Tamper functions
- *
-@verbatim
- ===============================================================================
- ##### RTC TimeStamp and Tamper functions #####
- ===============================================================================
-
- [..] This section provides functions allowing to configure TimeStamp feature
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Set TimeStamp.
- * @note This API must be called before enabling the TimeStamp feature.
- * @param hrtc RTC handle
- * @param TimeStampEdge Specifies the pin edge on which the TimeStamp is
- * activated.
- * This parameter can be one of the following values:
- * @arg RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the
- * rising edge of the related pin.
- * @arg RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the
- * falling edge of the related pin.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge)
-{
- uint32_t tmpreg;
-
- /* Check the parameters */
- assert_param(IS_TIMESTAMP_EDGE(TimeStampEdge));
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Get the RTC_CR register and clear the bits to be configured */
- tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
-
- tmpreg |= TimeStampEdge;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* Configure the Time Stamp TSEDGE and Enable bits */
- hrtc->Instance->CR = (uint32_t)tmpreg;
-
- __HAL_RTC_TIMESTAMP_ENABLE(hrtc);
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Set TimeStamp with Interrupt.
- * @param hrtc RTC handle
- * @note This API must be called before enabling the TimeStamp feature.
- * @param TimeStampEdge Specifies the pin edge on which the TimeStamp is
- * activated.
- * This parameter can be one of the following values:
- * @arg RTC_TIMESTAMPEDGE_RISING: the Time stamp event occurs on the
- * rising edge of the related pin.
- * @arg RTC_TIMESTAMPEDGE_FALLING: the Time stamp event occurs on the
- * falling edge of the related pin.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetTimeStamp_IT(RTC_HandleTypeDef *hrtc, uint32_t TimeStampEdge)
-{
- uint32_t tmpreg;
-
- /* Check the parameters */
- assert_param(IS_TIMESTAMP_EDGE(TimeStampEdge));
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Get the RTC_CR register and clear the bits to be configured */
- tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
-
- tmpreg |= TimeStampEdge;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* Configure the Time Stamp TSEDGE and Enable bits */
- hrtc->Instance->CR = (uint32_t)tmpreg;
-
- __HAL_RTC_TIMESTAMP_ENABLE(hrtc);
-
- /* Enable IT timestamp */
- __HAL_RTC_TIMESTAMP_ENABLE_IT(hrtc, RTC_IT_TS);
-
- /* RTC timestamp Interrupt Configuration: EXTI configuration */
- __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT();
-
- __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Deactivate TimeStamp.
- * @param hrtc RTC handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_DeactivateTimeStamp(RTC_HandleTypeDef *hrtc)
-{
- uint32_t tmpreg;
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* In case of interrupt mode is used, the interrupt source must disabled */
- __HAL_RTC_TIMESTAMP_DISABLE_IT(hrtc, RTC_IT_TS);
-
- /* Get the RTC_CR register and clear the bits to be configured */
- tmpreg = (uint32_t)(hrtc->Instance->CR & (uint32_t)~(RTC_CR_TSEDGE | RTC_CR_TSE));
-
- /* Configure the Time Stamp TSEDGE and Enable bits */
- hrtc->Instance->CR = (uint32_t)tmpreg;
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Get the RTC TimeStamp value.
- * @param hrtc RTC handle
- * @param sTimeStamp Pointer to Time structure
- * @param sTimeStampDate Pointer to Date structure
- * @param Format specifies the format of the entered parameters.
- * This parameter can be one of the following values:
- * @arg RTC_FORMAT_BIN: Binary data format
- * @arg RTC_FORMAT_BCD: BCD data format
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_GetTimeStamp(RTC_HandleTypeDef *hrtc, RTC_TimeTypeDef *sTimeStamp, RTC_DateTypeDef *sTimeStampDate, uint32_t Format)
-{
- uint32_t tmptime, tmpdate;
-
- /* Check the parameters */
- assert_param(IS_RTC_FORMAT(Format));
-
- /* Get the TimeStamp time and date registers values */
- tmptime = (uint32_t)(hrtc->Instance->TSTR & RTC_TR_RESERVED_MASK);
- tmpdate = (uint32_t)(hrtc->Instance->TSDR & RTC_DR_RESERVED_MASK);
-
- /* Fill the Time structure fields with the read parameters */
- sTimeStamp->Hours = (uint8_t)((tmptime & (RTC_TR_HT | RTC_TR_HU)) >> 16U);
- sTimeStamp->Minutes = (uint8_t)((tmptime & (RTC_TR_MNT | RTC_TR_MNU)) >> 8U);
- sTimeStamp->Seconds = (uint8_t)(tmptime & (RTC_TR_ST | RTC_TR_SU));
- sTimeStamp->TimeFormat = (uint8_t)((tmptime & (RTC_TR_PM)) >> 16);
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
- sTimeStamp->SubSeconds = (uint32_t)((hrtc->Instance->TSSSR) & RTC_TSSSR_SS);
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-
- /* Fill the Date structure fields with the read parameters */
- sTimeStampDate->Year = 0U;
- sTimeStampDate->Month = (uint8_t)((tmpdate & (RTC_DR_MT | RTC_DR_MU)) >> 8U);
- sTimeStampDate->Date = (uint8_t)(tmpdate & (RTC_DR_DT | RTC_DR_DU));
- sTimeStampDate->WeekDay = (uint8_t)((tmpdate & (RTC_DR_WDU)) >> 13U);
-
- /* Check the input parameters format */
- if (Format == RTC_FORMAT_BIN)
- {
- /* Convert the TimeStamp structure parameters to Binary format */
- sTimeStamp->Hours = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Hours);
- sTimeStamp->Minutes = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Minutes);
- sTimeStamp->Seconds = (uint8_t)RTC_Bcd2ToByte(sTimeStamp->Seconds);
-
- /* Convert the DateTimeStamp structure parameters to Binary format */
- sTimeStampDate->Month = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->Month);
- sTimeStampDate->Date = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->Date);
- sTimeStampDate->WeekDay = (uint8_t)RTC_Bcd2ToByte(sTimeStampDate->WeekDay);
- }
-
- /* Clear the TIMESTAMP Flag */
- __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSF);
-
- return HAL_OK;
-}
-
-/**
- * @brief Set Tamper
- * @note By calling this API we disable the tamper interrupt for all tampers.
- * @param hrtc RTC handle
- * @param sTamper Pointer to Tamper Structure.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetTamper(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper)
-{
- uint32_t tmpreg;
-
- /* Check the parameters */
- assert_param(IS_RTC_TAMPER(sTamper->Tamper));
- assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger));
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
- assert_param(IS_RTC_TAMPER_FILTER(sTamper->Filter));
- assert_param(IS_RTC_TAMPER_SAMPLING_FREQ(sTamper->SamplingFrequency));
- assert_param(IS_RTC_TAMPER_PRECHARGE_DURATION(sTamper->PrechargeDuration));
- assert_param(IS_RTC_TAMPER_PULLUP_STATE(sTamper->TamperPullUp));
- assert_param(IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(sTamper->TimeStampOnTamperDetection));
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
- if ((sTamper->Trigger == RTC_TAMPERTRIGGER_RISINGEDGE))
- {
- /* Configure the RTC_TAFCR register */
- sTamper->Trigger = RTC_TAMPERTRIGGER_RISINGEDGE;
- }
- else
- {
- sTamper->Trigger = (uint32_t)(sTamper->Tamper << 1);
- }
-
- tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)sTamper->Trigger | (uint32_t)sTamper->Filter | \
- (uint32_t)sTamper->SamplingFrequency | (uint32_t)sTamper->PrechargeDuration | \
- (uint32_t)sTamper->TamperPullUp | sTamper->TimeStampOnTamperDetection);
-
- hrtc->Instance->TAFCR &= (uint32_t)~((uint32_t)sTamper->Tamper | (uint32_t)(sTamper->Tamper << 1) | (uint32_t)RTC_TAFCR_TAMPTS | \
- (uint32_t)RTC_TAFCR_TAMPFREQ | (uint32_t)RTC_TAFCR_TAMPFLT | (uint32_t)RTC_TAFCR_TAMPPRCH | \
- (uint32_t)RTC_TAFCR_TAMPPUDIS | (uint32_t)RTC_TAFCR_TAMPIE);
-#else
- tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)(sTamper->Trigger));
-
- hrtc->Instance->TAFCR &= (uint32_t)~((uint32_t)RTC_TAFCR_TAMP1E | (uint32_t)RTC_TAFCR_TAMP1TRG);
-
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
- hrtc->Instance->TAFCR |= tmpreg;
-
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Set Tamper with interrupt.
- * @note By calling this API we force the tamper interrupt for all tampers.
- * @param hrtc RTC handle
- * @param sTamper Pointer to RTC Tamper.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetTamper_IT(RTC_HandleTypeDef *hrtc, RTC_TamperTypeDef *sTamper)
-{
- uint32_t tmpreg;
-
- /* Check the parameters */
- assert_param(IS_RTC_TAMPER(sTamper->Tamper));
- assert_param(IS_RTC_TAMPER_TRIGGER(sTamper->Trigger));
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
- assert_param(IS_RTC_TAMPER_FILTER(sTamper->Filter));
- assert_param(IS_RTC_TAMPER_SAMPLING_FREQ(sTamper->SamplingFrequency));
- assert_param(IS_RTC_TAMPER_PRECHARGE_DURATION(sTamper->PrechargeDuration));
- assert_param(IS_RTC_TAMPER_PULLUP_STATE(sTamper->TamperPullUp));
- assert_param(IS_RTC_TAMPER_TIMESTAMPONTAMPER_DETECTION(sTamper->TimeStampOnTamperDetection));
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
- /* Configure the tamper trigger */
- if ((sTamper->Trigger == RTC_TAMPERTRIGGER_RISINGEDGE))
- {
- sTamper->Trigger = RTC_TAMPERTRIGGER_RISINGEDGE;
- }
- else
- {
- sTamper->Trigger = (uint32_t)(sTamper->Tamper << 1);
- }
-
- tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)sTamper->Trigger | (uint32_t)sTamper->Filter | \
- (uint32_t)sTamper->SamplingFrequency | (uint32_t)sTamper->PrechargeDuration | \
- (uint32_t)sTamper->TamperPullUp | sTamper->TimeStampOnTamperDetection);
-
- hrtc->Instance->TAFCR &= (uint32_t)~((uint32_t)sTamper->Tamper | (uint32_t)(sTamper->Tamper << 1) | (uint32_t)RTC_TAFCR_TAMPTS | \
- (uint32_t)RTC_TAFCR_TAMPFREQ | (uint32_t)RTC_TAFCR_TAMPFLT | (uint32_t)RTC_TAFCR_TAMPPRCH | \
- (uint32_t)RTC_TAFCR_TAMPPUDIS);
-#else
- tmpreg = ((uint32_t)sTamper->Tamper | (uint32_t)sTamper->Trigger);
-
- hrtc->Instance->TAFCR &= (uint32_t)~((uint32_t)RTC_TAFCR_TAMP1E | (uint32_t)RTC_TAFCR_TAMP1TRG | (uint32_t)RTC_TAFCR_TAMPIE);
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
- hrtc->Instance->TAFCR |= tmpreg;
-
- /* Configure the Tamper Interrupt in the RTC_TAFCR */
- hrtc->Instance->TAFCR |= (uint32_t)RTC_TAFCR_TAMPIE;
-
- /* RTC Tamper Interrupt Configuration: EXTI configuration */
- __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_IT();
-
- __HAL_RTC_TAMPER_TIMESTAMP_EXTI_ENABLE_RISING_EDGE();
-
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Deactivate Tamper.
- * @param hrtc RTC handle
- * @param Tamper Selected tamper pin.
- * This parameter can be a value of @ref RTCEx_Tamper_Pins_Definitions
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_DeactivateTamper(RTC_HandleTypeDef *hrtc, uint32_t Tamper)
-{
- assert_param(IS_RTC_TAMPER(Tamper));
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the selected Tamper pin */
- hrtc->Instance->TAFCR &= (uint32_t)~Tamper;
-
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Handle TimeStamp interrupt request.
- * @param hrtc RTC handle
- * @retval None
- */
-void HAL_RTCEx_TamperTimeStampIRQHandler(RTC_HandleTypeDef *hrtc)
-{
- /* Get the TimeStamp interrupt source enable status */
- if (__HAL_RTC_TIMESTAMP_GET_IT_SOURCE(hrtc, RTC_IT_TS) != 0U)
- {
- /* Get the pending status of the TIMESTAMP Interrupt */
- if (__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSF) != 0U)
- {
- /* TIMESTAMP callback */
-#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
- hrtc->TimeStampEventCallback(hrtc);
-#else
- HAL_RTCEx_TimeStampEventCallback(hrtc);
-#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
-
- /* Clear the TIMESTAMP interrupt pending bit */
- __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSF);
- }
- }
-
- /* Get the Tamper1 interrupts source enable status */
- if (__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP | RTC_IT_TAMP1) != 0U)
- {
- /* Get the pending status of the Tamper1 Interrupt */
- if (__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F) != 0U)
- {
- /* Tamper1 callback */
-#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
- hrtc->Tamper1EventCallback(hrtc);
-#else
- HAL_RTCEx_Tamper1EventCallback(hrtc);
-#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
-
- /* Clear the Tamper1 interrupt pending bit */
- __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP1F);
- }
- }
-
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
- /* Get the Tamper2 interrupts source enable status */
- if (__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP | RTC_IT_TAMP2) != 0U)
- {
- /* Get the pending status of the Tamper2 Interrupt */
- if (__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP2F) != 0U)
- {
- /* Tamper2 callback */
-#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
- hrtc->Tamper2EventCallback(hrtc);
-#else
- HAL_RTCEx_Tamper2EventCallback(hrtc);
-#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
-
- /* Clear the Tamper2 interrupt pending bit */
- __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP2F);
- }
- }
-
- /* Get the Tamper3 interrupts source enable status */
- if (__HAL_RTC_TAMPER_GET_IT_SOURCE(hrtc, RTC_IT_TAMP | RTC_IT_TAMP3) != 0U)
- {
- /* Get the pending status of the Tamper3 Interrupt */
- if (__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP3F) != 0U)
- {
- /* Tamper3 callback */
-#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
- hrtc->Tamper3EventCallback(hrtc);
-#else
- HAL_RTCEx_Tamper3EventCallback(hrtc);
-#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
-
- /* Clear the Tamper3 interrupt pending bit */
- __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP3F);
- }
- }
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-
- /* Clear the EXTI's Flag for RTC TimeStamp and Tamper */
- __HAL_RTC_TAMPER_TIMESTAMP_EXTI_CLEAR_FLAG();
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-}
-
-/**
- * @brief TimeStamp callback.
- * @param hrtc RTC handle
- * @retval None
- */
-__weak void HAL_RTCEx_TimeStampEventCallback(RTC_HandleTypeDef *hrtc)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hrtc);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_RTCEx_TimeStampEventCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Tamper 1 callback.
- * @param hrtc RTC handle
- * @retval None
- */
-__weak void HAL_RTCEx_Tamper1EventCallback(RTC_HandleTypeDef *hrtc)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hrtc);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_RTCEx_Tamper1EventCallback could be implemented in the user file
- */
-}
-
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
-/**
- * @brief Tamper 2 callback.
- * @param hrtc RTC handle
- * @retval None
- */
-__weak void HAL_RTCEx_Tamper2EventCallback(RTC_HandleTypeDef *hrtc)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hrtc);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_RTCEx_Tamper2EventCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Tamper 3 callback.
- * @param hrtc RTC handle
- * @retval None
- */
-__weak void HAL_RTCEx_Tamper3EventCallback(RTC_HandleTypeDef *hrtc)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hrtc);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_RTCEx_Tamper3EventCallback could be implemented in the user file
- */
-}
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-
-/**
- * @brief Handle TimeStamp polling request.
- * @param hrtc RTC handle
- * @param Timeout Timeout duration
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_PollForTimeStampEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
-{
- uint32_t tickstart = HAL_GetTick();
-
- while (__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSF) == 0U)
- {
- if (__HAL_RTC_TIMESTAMP_GET_FLAG(hrtc, RTC_FLAG_TSOVF) != 0U)
- {
- /* Clear the TIMESTAMP OverRun Flag */
- __HAL_RTC_TIMESTAMP_CLEAR_FLAG(hrtc, RTC_FLAG_TSOVF);
-
- /* Change TIMESTAMP state */
- hrtc->State = HAL_RTC_STATE_ERROR;
-
- return HAL_ERROR;
- }
-
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
- {
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @brief Handle Tamper 1 Polling.
- * @param hrtc RTC handle
- * @param Timeout Timeout duration
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_PollForTamper1Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
-{
- uint32_t tickstart = HAL_GetTick();
-
- /* Get the status of the Interrupt */
- while (__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP1F) == 0U)
- {
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
- {
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Clear the Tamper Flag */
- __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP1F);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- return HAL_OK;
-}
-
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
-/**
- * @brief Handle Tamper 2 Polling.
- * @param hrtc RTC handle
- * @param Timeout Timeout duration
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_PollForTamper2Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
-{
- uint32_t tickstart = HAL_GetTick();
-
- /* Get the status of the Interrupt */
- while (__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP2F) == 0U)
- {
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
- {
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Clear the Tamper Flag */
- __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP2F);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @brief Handle Tamper 3 Polling.
- * @param hrtc RTC handle
- * @param Timeout Timeout duration
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_PollForTamper3Event(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
-{
- uint32_t tickstart = HAL_GetTick();
-
- /* Get the status of the Interrupt */
- while (__HAL_RTC_TAMPER_GET_FLAG(hrtc, RTC_FLAG_TAMP3F) == 0U)
- {
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
- {
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Clear the Tamper Flag */
- __HAL_RTC_TAMPER_CLEAR_FLAG(hrtc, RTC_FLAG_TAMP3F);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- return HAL_OK;
-}
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-
-/**
- * @}
- */
-
-/** @addtogroup RTCEx_Exported_Functions_Group2
- * @brief RTC Wake-up functions
- *
-@verbatim
- ===============================================================================
- ##### RTC Wake-up functions #####
- ===============================================================================
-
- [..] This section provides functions allowing to configure Wake-up feature
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Set wake up timer.
- * @param hrtc RTC handle
- * @param WakeUpCounter Wake up counter
- * @param WakeUpClock Wake up clock
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)
-{
- uint32_t tickstart;
-
- /* Check the parameters */
- assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock));
- assert_param(IS_RTC_WAKEUP_COUNTER(WakeUpCounter));
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /*Check RTC WUTWF flag is reset only when wake up timer enabled*/
- if ((hrtc->Instance->CR & RTC_CR_WUTE) != 0U)
- {
- tickstart = HAL_GetTick();
-
- /* Wait till RTC WUTWF flag is reset and if Time out is reached exit */
- while (__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == 1U)
- {
- if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_TIMEOUT;
- }
- }
- }
-
- __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
-
- tickstart = HAL_GetTick();
-
- /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
- while (__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == 0U)
- {
- if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_TIMEOUT;
- }
- }
-
- /* Clear the Wakeup Timer clock source bits in CR register */
- hrtc->Instance->CR &= (uint32_t)~RTC_CR_WUCKSEL;
-
- /* Configure the clock source */
- hrtc->Instance->CR |= (uint32_t)WakeUpClock;
-
- /* Configure the Wakeup Timer counter */
- hrtc->Instance->WUTR = (uint32_t)WakeUpCounter;
-
- /* Enable the Wakeup Timer */
- __HAL_RTC_WAKEUPTIMER_ENABLE(hrtc);
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Set wake up timer with interrupt.
- * @param hrtc RTC handle
- * @param WakeUpCounter Wake up counter
- * @param WakeUpClock Wake up clock
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetWakeUpTimer_IT(RTC_HandleTypeDef *hrtc, uint32_t WakeUpCounter, uint32_t WakeUpClock)
-{
- uint32_t tickstart;
-
- /* Check the parameters */
- assert_param(IS_RTC_WAKEUP_CLOCK(WakeUpClock));
- assert_param(IS_RTC_WAKEUP_COUNTER(WakeUpCounter));
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /*Check RTC WUTWF flag is reset only when wake up timer enabled*/
- if ((hrtc->Instance->CR & RTC_CR_WUTE) != 0U)
- {
- tickstart = HAL_GetTick();
-
- /* Wait till RTC WUTWF flag is reset and if Time out is reached exit */
- while (__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == 1U)
- {
- if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Disable the Wake-Up timer */
- __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
-
- /* Clear flag Wake-Up */
- __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
-
- tickstart = HAL_GetTick();
-
- /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
- while (__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == 0U)
- {
- if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_TIMEOUT;
- }
- }
-
- /* Configure the Wakeup Timer counter */
- hrtc->Instance->WUTR = (uint32_t)WakeUpCounter;
-
- /* Clear the Wakeup Timer clock source bits in CR register */
- hrtc->Instance->CR &= (uint32_t)~RTC_CR_WUCKSEL;
-
- /* Configure the clock source */
- hrtc->Instance->CR |= (uint32_t)WakeUpClock;
-
- /* RTC WakeUpTimer Interrupt Configuration: EXTI configuration */
- __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_IT();
-
- __HAL_RTC_WAKEUPTIMER_EXTI_ENABLE_RISING_EDGE();
-
- /* Configure the Interrupt in the RTC_CR register */
- __HAL_RTC_WAKEUPTIMER_ENABLE_IT(hrtc, RTC_IT_WUT);
-
- /* Enable the Wakeup Timer */
- __HAL_RTC_WAKEUPTIMER_ENABLE(hrtc);
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Deactivate wake up timer counter.
- * @param hrtc RTC handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_DeactivateWakeUpTimer(RTC_HandleTypeDef *hrtc)
-{
- uint32_t tickstart;
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* Disable the Wakeup Timer */
- __HAL_RTC_WAKEUPTIMER_DISABLE(hrtc);
-
- /* In case of interrupt mode is used, the interrupt source must disabled */
- __HAL_RTC_WAKEUPTIMER_DISABLE_IT(hrtc, RTC_IT_WUT);
-
- tickstart = HAL_GetTick();
- /* Wait till RTC WUTWF flag is set and if Time out is reached exit */
- while (__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTWF) == 0U)
- {
- if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_TIMEOUT;
- }
- }
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Get wake up timer counter.
- * @param hrtc RTC handle
- * @retval Counter value
- */
-uint32_t HAL_RTCEx_GetWakeUpTimer(RTC_HandleTypeDef *hrtc)
-{
- /* Get the counter value */
- return ((uint32_t)(hrtc->Instance->WUTR & RTC_WUTR_WUT));
-}
-
-/**
- * @brief Handle Wake Up Timer interrupt request.
- * @param hrtc RTC handle
- * @retval None
- */
-void HAL_RTCEx_WakeUpTimerIRQHandler(RTC_HandleTypeDef *hrtc)
-{
- /* Get the pending status of the WAKEUPTIMER Interrupt */
- if (__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) != 0U)
- {
- /* WAKEUPTIMER callback */
-#if (USE_HAL_RTC_REGISTER_CALLBACKS == 1)
- hrtc->WakeUpTimerEventCallback(hrtc);
-#else
- HAL_RTCEx_WakeUpTimerEventCallback(hrtc);
-#endif /* USE_HAL_RTC_REGISTER_CALLBACKS */
-
- /* Clear the WAKEUPTIMER interrupt pending bit */
- __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
- }
-
-
- /* Clear the EXTI's line Flag for RTC WakeUpTimer */
- __HAL_RTC_WAKEUPTIMER_EXTI_CLEAR_FLAG();
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-}
-
-/**
- * @brief Wake Up Timer callback.
- * @param hrtc RTC handle
- * @retval None
- */
-__weak void HAL_RTCEx_WakeUpTimerEventCallback(RTC_HandleTypeDef *hrtc)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hrtc);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_RTCEx_WakeUpTimerEventCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Handle Wake Up Timer Polling.
- * @param hrtc RTC handle
- * @param Timeout Timeout duration
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_PollForWakeUpTimerEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
-{
- uint32_t tickstart = HAL_GetTick();
-
- while (__HAL_RTC_WAKEUPTIMER_GET_FLAG(hrtc, RTC_FLAG_WUTF) == 0U)
- {
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
- {
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
-
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Clear the WAKEUPTIMER Flag */
- __HAL_RTC_WAKEUPTIMER_CLEAR_FLAG(hrtc, RTC_FLAG_WUTF);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-
-/** @addtogroup RTCEx_Exported_Functions_Group3
- * @brief Extended Peripheral Control functions
- *
-@verbatim
- ===============================================================================
- ##### Extended Peripheral Control functions #####
- ===============================================================================
- [..]
- This subsection provides functions allowing to
- (+) Write a data in a specified RTC Backup data register
- (+) Read a data in a specified RTC Backup data register
- (+) Set the Coarse calibration parameters.
- (+) Deactivate the Coarse calibration parameters
- (+) Set the Smooth calibration parameters.
- (+) Configure the Synchronization Shift Control Settings.
- (+) Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
- (+) Deactivate the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
- (+) Enable the RTC reference clock detection.
- (+) Disable the RTC reference clock detection.
- (+) Enable the Bypass Shadow feature.
- (+) Disable the Bypass Shadow feature.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Write a data in a specified RTC Backup data register.
- * @param hrtc RTC handle
- * @param BackupRegister RTC Backup data Register number.
- * This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to
- * specify the register.
- * @param Data Data to be written in the specified RTC Backup data register.
- * @retval None
- */
-void HAL_RTCEx_BKUPWrite(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister, uint32_t Data)
-{
- uint32_t tmp;
-
- /* Check the parameters */
- assert_param(IS_RTC_BKP(BackupRegister));
-
- tmp = (uint32_t) & (hrtc->Instance->BKP0R);
- tmp += (BackupRegister * 4U);
-
- /* Write the specified register */
- *(__IO uint32_t *)tmp = (uint32_t)Data;
-}
-
-/**
- * @brief Reads data from the specified RTC Backup data Register.
- * @param hrtc RTC handle
- * @param BackupRegister RTC Backup data Register number.
- * This parameter can be: RTC_BKP_DRx where x can be from 0 to 19 to
- * specify the register.
- * @retval Read value
- */
-uint32_t HAL_RTCEx_BKUPRead(RTC_HandleTypeDef *hrtc, uint32_t BackupRegister)
-{
- uint32_t tmp;
-
- /* Check the parameters */
- assert_param(IS_RTC_BKP(BackupRegister));
-
- tmp = (uint32_t) & (hrtc->Instance->BKP0R);
- tmp += (BackupRegister * 4U);
-
- /* Read the specified register */
- return (*(__IO uint32_t *)tmp);
-}
-
-/**
- * @brief Sets the Coarse calibration parameters.
- * @param hrtc pointer to a RTC_HandleTypeDef structure that contains
- * the configuration information for RTC.
- * @param CalibSign Specifies the sign of the coarse calibration value.
- * This parameter can be one of the following values :
- * @arg RTC_CALIBSIGN_POSITIVE: The value sign is positive
- * @arg RTC_CALIBSIGN_NEGATIVE: The value sign is negative
- * @param Value value of coarse calibration expressed in ppm (coded on 5 bits).
- *
- * @note This Calibration value should be between 0 and 63 when using negative
- * sign with a 2-ppm step.
- *
- * @note This Calibration value should be between 0 and 126 when using positive
- * sign with a 4-ppm step.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetCoarseCalib(RTC_HandleTypeDef *hrtc, uint32_t CalibSign, uint32_t Value)
-{
- /* Check the parameters */
- assert_param(IS_RTC_CALIB_SIGN(CalibSign));
- assert_param(IS_RTC_CALIB_VALUE(Value));
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* Set Initialization mode */
- if (RTC_EnterInitMode(hrtc) != HAL_OK)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Set RTC state*/
- hrtc->State = HAL_RTC_STATE_ERROR;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_ERROR;
- }
- else
- {
- /* Enable the Coarse Calibration */
- __HAL_RTC_COARSE_CALIB_ENABLE(hrtc);
-
- /* Set the coarse calibration value */
- hrtc->Instance->CALIBR = (uint32_t)(CalibSign | Value);
-
- /* Exit Initialization mode */
- hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
- }
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Deactivates the Coarse calibration parameters.
- * @param hrtc pointer to a RTC_HandleTypeDef structure that contains
- * the configuration information for RTC.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_DeactivateCoarseCalib(RTC_HandleTypeDef *hrtc)
-{
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* Set Initialization mode */
- if (RTC_EnterInitMode(hrtc) != HAL_OK)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Set RTC state*/
- hrtc->State = HAL_RTC_STATE_ERROR;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_ERROR;
- }
- else
- {
- /* Enable the Coarse Calibration */
- __HAL_RTC_COARSE_CALIB_DISABLE(hrtc);
-
- /* Exit Initialization mode */
- hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
- }
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
-/**
- * @brief Set the Smooth calibration parameters.
- * @param hrtc RTC handle
- * @param SmoothCalibPeriod Select the Smooth Calibration Period.
- * This parameter can be can be one of the following values :
- * @arg RTC_SMOOTHCALIB_PERIOD_32SEC: The smooth calibration period is 32s.
- * @arg RTC_SMOOTHCALIB_PERIOD_16SEC: The smooth calibration period is 16s.
- * @arg RTC_SMOOTHCALIB_PERIOD_8SEC: The smooth calibration period is 8s.
- * @param SmoothCalibPlusPulses Select to Set or reset the CALP bit.
- * This parameter can be one of the following values:
- * @arg RTC_SMOOTHCALIB_PLUSPULSES_SET: Add one RTCCLK pulse every 2*11 pulses.
- * @arg RTC_SMOOTHCALIB_PLUSPULSES_RESET: No RTCCLK pulses are added.
- * @param SmoothCalibMinusPulsesValue Select the value of CALM[8:0] bits.
- * This parameter can be one any value from 0 to 0x000001FF.
- * @note To deactivate the smooth calibration, the field SmoothCalibPlusPulses
- * must be equal to SMOOTHCALIB_PLUSPULSES_RESET and the field
- * SmoothCalibMinusPulsesValue mut be equal to 0.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetSmoothCalib(RTC_HandleTypeDef *hrtc, uint32_t SmoothCalibPeriod, uint32_t SmoothCalibPlusPulses, uint32_t SmoothCalibMinusPulsesValue)
-{
- uint32_t tickstart;
-
- /* Check the parameters */
- assert_param(IS_RTC_SMOOTH_CALIB_PERIOD(SmoothCalibPeriod));
- assert_param(IS_RTC_SMOOTH_CALIB_PLUS(SmoothCalibPlusPulses));
- assert_param(IS_RTC_SMOOTH_CALIB_MINUS(SmoothCalibMinusPulsesValue));
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* check if a calibration is pending*/
- if ((hrtc->Instance->ISR & RTC_ISR_RECALPF) != 0U)
- {
- tickstart = HAL_GetTick();
-
- /* check if a calibration is pending*/
- while ((hrtc->Instance->ISR & RTC_ISR_RECALPF) != 0U)
- {
- if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Configure the Smooth calibration settings */
- hrtc->Instance->CALR = (uint32_t)((uint32_t)SmoothCalibPeriod | (uint32_t)SmoothCalibPlusPulses | (uint32_t)SmoothCalibMinusPulsesValue);
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Configure the Synchronization Shift Control Settings.
- * @note When REFCKON is set, firmware must not write to Shift control register.
- * @param hrtc RTC handle
- * @param ShiftAdd1S Select to add or not 1 second to the time calendar.
- * This parameter can be one of the following values :
- * @arg RTC_SHIFTADD1S_SET: Add one second to the clock calendar.
- * @arg RTC_SHIFTADD1S_RESET: No effect.
- * @param ShiftSubFS Select the number of Second Fractions to substitute.
- * This parameter can be one any value from 0 to 0x7FFF.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetSynchroShift(RTC_HandleTypeDef *hrtc, uint32_t ShiftAdd1S, uint32_t ShiftSubFS)
-{
- uint32_t tickstart;
-
- /* Check the parameters */
- assert_param(IS_RTC_SHIFT_ADD1S(ShiftAdd1S));
- assert_param(IS_RTC_SHIFT_SUBFS(ShiftSubFS));
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- tickstart = HAL_GetTick();
-
- /* Wait until the shift is completed*/
- while ((hrtc->Instance->ISR & RTC_ISR_SHPF) != 0U)
- {
- if ((HAL_GetTick() - tickstart) > RTC_TIMEOUT_VALUE)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_TIMEOUT;
- }
- }
-
- /* Check if the reference clock detection is disabled */
- if ((hrtc->Instance->CR & RTC_CR_REFCKON) == 0U)
- {
- /* Configure the Shift settings */
- hrtc->Instance->SHIFTR = (uint32_t)(uint32_t)(ShiftSubFS) | (uint32_t)(ShiftAdd1S);
-
- /* Wait for synchro */
- if (HAL_RTC_WaitForSynchro(hrtc) != HAL_OK)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- hrtc->State = HAL_RTC_STATE_ERROR;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_ERROR;
- }
- }
- else
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_ERROR;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_ERROR;
- }
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-
-
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
-/**
- * @brief Configure the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
- * @param hrtc RTC handle
- * @param CalibOutput : Select the Calibration output Selection .
- * This parameter can be one of the following values:
- * @arg RTC_CALIBOUTPUT_512HZ: A signal has a regular waveform at 512Hz.
- * @arg RTC_CALIBOUTPUT_1HZ: A signal has a regular waveform at 1Hz.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc, uint32_t CalibOutput)
-#else
-/**
- * @brief Configure the Calibration Pinout (RTC_CALIB).
- * @param hrtc RTC handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetCalibrationOutPut(RTC_HandleTypeDef *hrtc)
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-{
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
- /* Check the parameters */
- assert_param(IS_RTC_CALIB_OUTPUT(CalibOutput));
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
- /* Clear flags before config */
- hrtc->Instance->CR &= (uint32_t)~RTC_CR_COSEL;
-
- /* Configure the RTC_CR register */
- hrtc->Instance->CR |= (uint32_t)CalibOutput;
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-
- __HAL_RTC_CALIBRATION_OUTPUT_ENABLE(hrtc);
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Deactivate the Calibration Pinout (RTC_CALIB) Selection (1Hz or 512Hz).
- * @param hrtc RTC handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_DeactivateCalibrationOutPut(RTC_HandleTypeDef *hrtc)
-{
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- __HAL_RTC_CALIBRATION_OUTPUT_DISABLE(hrtc);
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Enable the RTC reference clock detection.
- * @param hrtc RTC handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_SetRefClock(RTC_HandleTypeDef *hrtc)
-{
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* Set Initialization mode */
- if (RTC_EnterInitMode(hrtc) != HAL_OK)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Set RTC state*/
- hrtc->State = HAL_RTC_STATE_ERROR;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_ERROR;
- }
- else
- {
- __HAL_RTC_CLOCKREF_DETECTION_ENABLE(hrtc);
-
- /* Exit Initialization mode */
- hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
- }
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Disable the RTC reference clock detection.
- * @param hrtc RTC handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_DeactivateRefClock(RTC_HandleTypeDef *hrtc)
-{
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* Set Initialization mode */
- if (RTC_EnterInitMode(hrtc) != HAL_OK)
- {
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Set RTC state*/
- hrtc->State = HAL_RTC_STATE_ERROR;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_ERROR;
- }
- else
- {
- __HAL_RTC_CLOCKREF_DETECTION_DISABLE(hrtc);
-
- /* Exit Initialization mode */
- hrtc->Instance->ISR &= (uint32_t)~RTC_ISR_INIT;
- }
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-#if defined(STM32L100xBA) || defined (STM32L151xBA) || defined (STM32L152xBA) || defined(STM32L100xC) || defined (STM32L151xC) || defined (STM32L152xC) || defined (STM32L162xC) || defined(STM32L151xCA) || defined (STM32L151xD) || defined (STM32L152xCA) || defined (STM32L152xD) || defined (STM32L162xCA) || defined (STM32L162xD) || defined(STM32L151xE) || defined(STM32L151xDX) || defined (STM32L152xE) || defined (STM32L152xDX) || defined (STM32L162xE) || defined (STM32L162xDX)
-/**
- * @brief Enable the Bypass Shadow feature.
- * @param hrtc RTC handle
- * @note When the Bypass Shadow is enabled the calendar value are taken
- * directly from the Calendar counter.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_EnableBypassShadow(RTC_HandleTypeDef *hrtc)
-{
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* Set the BYPSHAD bit */
- hrtc->Instance->CR |= (uint8_t)RTC_CR_BYPSHAD;
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-
-/**
- * @brief Disable the Bypass Shadow feature.
- * @param hrtc RTC handle
- * @note When the Bypass Shadow is enabled the calendar value are taken
- * directly from the Calendar counter.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_DisableBypassShadow(RTC_HandleTypeDef *hrtc)
-{
- /* Process Locked */
- __HAL_LOCK(hrtc);
-
- hrtc->State = HAL_RTC_STATE_BUSY;
-
- /* Disable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_DISABLE(hrtc);
-
- /* Reset the BYPSHAD bit */
- hrtc->Instance->CR &= ((uint8_t)~RTC_CR_BYPSHAD);
-
- /* Enable the write protection for RTC registers */
- __HAL_RTC_WRITEPROTECTION_ENABLE(hrtc);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(hrtc);
-
- return HAL_OK;
-}
-#endif /* STM32L100xBA || STM32L151xBA || STM32L152xBA || STM32L100xC || STM32L151xC || STM32L152xC || STM32L162xC || STM32L151xCA || STM32L151xD || STM32L152xCA || STM32L152xD || STM32L162xCA || STM32L162xD || STM32L151xE || STM32L151xDX || STM32L152xE || STM32L152xDX || STM32L162xE || STM32L162xDX */
-
-/**
- * @}
- */
-
-/** @addtogroup RTCEx_Exported_Functions_Group4
- * @brief Extended features functions
- *
-@verbatim
- ===============================================================================
- ##### Extended features functions #####
- ===============================================================================
- [..] This section provides functions allowing to:
- (+) RTC Alram B callback
- (+) RTC Poll for Alarm B request
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Alarm B callback.
- * @param hrtc RTC handle
- * @retval None
- */
-__weak void HAL_RTCEx_AlarmBEventCallback(RTC_HandleTypeDef *hrtc)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hrtc);
-
- /* NOTE : This function Should not be modified, when the callback is needed,
- the HAL_RTCEx_AlarmBEventCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Handle Alarm B Polling request.
- * @param hrtc RTC handle
- * @param Timeout Timeout duration
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_RTCEx_PollForAlarmBEvent(RTC_HandleTypeDef *hrtc, uint32_t Timeout)
-{
- uint32_t tickstart = HAL_GetTick();
-
- while (__HAL_RTC_ALARM_GET_FLAG(hrtc, RTC_FLAG_ALRBF) == 0U)
- {
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
- {
- hrtc->State = HAL_RTC_STATE_TIMEOUT;
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Clear the Alarm Flag */
- __HAL_RTC_ALARM_CLEAR_FLAG(hrtc, RTC_FLAG_ALRBF);
-
- /* Change RTC state */
- hrtc->State = HAL_RTC_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* HAL_RTC_MODULE_ENABLED */
-/**
- * @}
- */
-
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_sd.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_sd.c
deleted file mode 100644
index 9368895ecd2..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_sd.c
+++ /dev/null
@@ -1,3231 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_sd.c
- * @author MCD Application Team
- * @brief SD card HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Secure Digital (SD) peripheral:
- * + Initialization and de-initialization functions
- * + IO operation functions
- * + Peripheral Control functions
- * + Peripheral State functions
- *
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- This driver implements a high level communication layer for read and write from/to
- this memory. The needed STM32 hardware resources (SDIO and GPIO) are performed by
- the user in HAL_SD_MspInit() function (MSP layer).
- Basically, the MSP layer configuration should be the same as we provide in the
- examples.
- You can easily tailor this configuration according to hardware resources.
-
- [..]
- This driver is a generic layered driver for SDIO memories which uses the HAL
- SDIO driver functions to interface with SD and uSD cards devices.
- It is used as follows:
-
- (#)Initialize the SDIO low level resources by implementing the HAL_SD_MspInit() API:
- (##) Enable the SDIO interface clock using __HAL_RCC_SDIO_CLK_ENABLE();
- (##) SDIO pins configuration for SD card
- (+++) Enable the clock for the SDIO GPIOs using the functions __HAL_RCC_GPIOx_CLK_ENABLE();
- (+++) Configure these SDIO pins as alternate function pull-up using HAL_GPIO_Init()
- and according to your pin assignment;
- (##) DMA configuration if you need to use DMA process (HAL_SD_ReadBlocks_DMA()
- and HAL_SD_WriteBlocks_DMA() APIs).
- (+++) Enable the DMAx interface clock using __HAL_RCC_DMAx_CLK_ENABLE();
- (+++) Configure the DMA using the function HAL_DMA_Init() with predeclared and filled.
- (##) NVIC configuration if you need to use interrupt process when using DMA transfer.
- (+++) Configure the SDIO and DMA interrupt priorities using functions
- HAL_NVIC_SetPriority(); DMA priority is superior to SDIO's priority
- (+++) Enable the NVIC DMA and SDIO IRQs using function HAL_NVIC_EnableIRQ()
- (+++) SDIO interrupts are managed using the macros __HAL_SD_ENABLE_IT()
- and __HAL_SD_DISABLE_IT() inside the communication process.
- (+++) SDIO interrupts pending bits are managed using the macros __HAL_SD_GET_IT()
- and __HAL_SD_CLEAR_IT()
- (##) NVIC configuration if you need to use interrupt process (HAL_SD_ReadBlocks_IT()
- and HAL_SD_WriteBlocks_IT() APIs).
- (+++) Configure the SDIO interrupt priorities using function HAL_NVIC_SetPriority();
- (+++) Enable the NVIC SDIO IRQs using function HAL_NVIC_EnableIRQ()
- (+++) SDIO interrupts are managed using the macros __HAL_SD_ENABLE_IT()
- and __HAL_SD_DISABLE_IT() inside the communication process.
- (+++) SDIO interrupts pending bits are managed using the macros __HAL_SD_GET_IT()
- and __HAL_SD_CLEAR_IT()
- (#) At this stage, you can perform SD read/write/erase operations after SD card initialization
-
-
- *** SD Card Initialization and configuration ***
- ================================================
- [..]
- To initialize the SD Card, use the HAL_SD_Init() function. It Initializes
- SDIO Peripheral(STM32 side) and the SD Card, and put it into StandBy State (Ready for data transfer).
- This function provide the following operations:
-
- (#) Apply the SD Card initialization process at 400KHz and check the SD Card
- type (Standard Capacity or High Capacity). You can change or adapt this
- frequency by adjusting the "ClockDiv" field.
- The SD Card frequency (SDIO_CK) is computed as follows:
-
- SDIO_CK = SDIOCLK / (ClockDiv + 2)
-
- In initialization mode and according to the SD Card standard,
- make sure that the SDIO_CK frequency doesn't exceed 400KHz.
-
- This phase of initialization is done through SDIO_Init() and
- SDIO_PowerState_ON() SDIO low level APIs.
-
- (#) Initialize the SD card. The API used is HAL_SD_InitCard().
- This phase allows the card initialization and identification
- and check the SD Card type (Standard Capacity or High Capacity)
- The initialization flow is compatible with SD standard.
-
- This API (HAL_SD_InitCard()) could be used also to reinitialize the card in case
- of plug-off plug-in.
-
- (#) Configure the SD Card Data transfer frequency. You can change or adapt this
- frequency by adjusting the "ClockDiv" field.
- In transfer mode and according to the SD Card standard, make sure that the
- SDIO_CK frequency doesn't exceed 25MHz and 50MHz in High-speed mode switch.
- To be able to use a frequency higher than 24MHz, you should use the SDIO
- peripheral in bypass mode. Refer to the corresponding reference manual
- for more details.
-
- (#) Select the corresponding SD Card according to the address read with the step 2.
-
- (#) Configure the SD Card in wide bus mode: 4-bits data.
-
- *** SD Card Read operation ***
- ==============================
- [..]
- (+) You can read from SD card in polling mode by using function HAL_SD_ReadBlocks().
- This function support only 512-bytes block length (the block size should be
- chosen as 512 bytes).
- You can choose either one block read operation or multiple block read operation
- by adjusting the "NumberOfBlocks" parameter.
- After this, you have to ensure that the transfer is done correctly. The check is done
- through HAL_SD_GetCardState() function for SD card state.
-
- (+) You can read from SD card in DMA mode by using function HAL_SD_ReadBlocks_DMA().
- This function support only 512-bytes block length (the block size should be
- chosen as 512 bytes).
- You can choose either one block read operation or multiple block read operation
- by adjusting the "NumberOfBlocks" parameter.
- After this, you have to ensure that the transfer is done correctly. The check is done
- through HAL_SD_GetCardState() function for SD card state.
- You could also check the DMA transfer process through the SD Rx interrupt event.
-
- (+) You can read from SD card in Interrupt mode by using function HAL_SD_ReadBlocks_IT().
- This function support only 512-bytes block length (the block size should be
- chosen as 512 bytes).
- You can choose either one block read operation or multiple block read operation
- by adjusting the "NumberOfBlocks" parameter.
- After this, you have to ensure that the transfer is done correctly. The check is done
- through HAL_SD_GetCardState() function for SD card state.
- You could also check the IT transfer process through the SD Rx interrupt event.
-
- *** SD Card Write operation ***
- ===============================
- [..]
- (+) You can write to SD card in polling mode by using function HAL_SD_WriteBlocks().
- This function support only 512-bytes block length (the block size should be
- chosen as 512 bytes).
- You can choose either one block read operation or multiple block read operation
- by adjusting the "NumberOfBlocks" parameter.
- After this, you have to ensure that the transfer is done correctly. The check is done
- through HAL_SD_GetCardState() function for SD card state.
-
- (+) You can write to SD card in DMA mode by using function HAL_SD_WriteBlocks_DMA().
- This function support only 512-bytes block length (the block size should be
- chosen as 512 bytes).
- You can choose either one block read operation or multiple block read operation
- by adjusting the "NumberOfBlocks" parameter.
- After this, you have to ensure that the transfer is done correctly. The check is done
- through HAL_SD_GetCardState() function for SD card state.
- You could also check the DMA transfer process through the SD Tx interrupt event.
-
- (+) You can write to SD card in Interrupt mode by using function HAL_SD_WriteBlocks_IT().
- This function support only 512-bytes block length (the block size should be
- chosen as 512 bytes).
- You can choose either one block read operation or multiple block read operation
- by adjusting the "NumberOfBlocks" parameter.
- After this, you have to ensure that the transfer is done correctly. The check is done
- through HAL_SD_GetCardState() function for SD card state.
- You could also check the IT transfer process through the SD Tx interrupt event.
-
- *** SD card status ***
- ======================
- [..]
- (+) The SD Status contains status bits that are related to the SD Memory
- Card proprietary features. To get SD card status use the HAL_SD_GetCardStatus().
-
- *** SD card information ***
- ===========================
- [..]
- (+) To get SD card information, you can use the function HAL_SD_GetCardInfo().
- It returns useful information about the SD card such as block size, card type,
- block number ...
-
- *** SD card CSD register ***
- ============================
- (+) The HAL_SD_GetCardCSD() API allows to get the parameters of the CSD register.
- Some of the CSD parameters are useful for card initialization and identification.
-
- *** SD card CID register ***
- ============================
- (+) The HAL_SD_GetCardCID() API allows to get the parameters of the CID register.
- Some of the CSD parameters are useful for card initialization and identification.
-
- *** SD HAL driver macros list ***
- ==================================
- [..]
- Below the list of most used macros in SD HAL driver.
-
- (+) __HAL_SD_ENABLE : Enable the SD device
- (+) __HAL_SD_DISABLE : Disable the SD device
- (+) __HAL_SD_DMA_ENABLE: Enable the SDIO DMA transfer
- (+) __HAL_SD_DMA_DISABLE: Disable the SDIO DMA transfer
- (+) __HAL_SD_ENABLE_IT: Enable the SD device interrupt
- (+) __HAL_SD_DISABLE_IT: Disable the SD device interrupt
- (+) __HAL_SD_GET_FLAG:Check whether the specified SD flag is set or not
- (+) __HAL_SD_CLEAR_FLAG: Clear the SD's pending flags
-
- (@) You can refer to the SD HAL driver header file for more useful macros
-
- *** Callback registration ***
- =============================================
- [..]
- The compilation define USE_HAL_SD_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
-
- Use Functions @ref HAL_SD_RegisterCallback() to register a user callback,
- it allows to register following callbacks:
- (+) TxCpltCallback : callback when a transmission transfer is completed.
- (+) RxCpltCallback : callback when a reception transfer is completed.
- (+) ErrorCallback : callback when error occurs.
- (+) AbortCpltCallback : callback when abort is completed.
- (+) MspInitCallback : SD MspInit.
- (+) MspDeInitCallback : SD MspDeInit.
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
-
- Use function @ref HAL_SD_UnRegisterCallback() to reset a callback to the default
- weak (surcharged) function. It allows to reset following callbacks:
- (+) TxCpltCallback : callback when a transmission transfer is completed.
- (+) RxCpltCallback : callback when a reception transfer is completed.
- (+) ErrorCallback : callback when error occurs.
- (+) AbortCpltCallback : callback when abort is completed.
- (+) MspInitCallback : SD MspInit.
- (+) MspDeInitCallback : SD MspDeInit.
- This function) takes as parameters the HAL peripheral handle and the Callback ID.
-
- By default, after the @ref HAL_SD_Init and if the state is HAL_SD_STATE_RESET
- all callbacks are reset to the corresponding legacy weak (surcharged) functions.
- Exception done for MspInit and MspDeInit callbacks that are respectively
- reset to the legacy weak (surcharged) functions in the @ref HAL_SD_Init
- and @ref HAL_SD_DeInit only when these callbacks are null (not registered beforehand).
- If not, MspInit or MspDeInit are not null, the @ref HAL_SD_Init and @ref HAL_SD_DeInit
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand)
-
- Callbacks can be registered/unregistered in READY state only.
- Exception done for MspInit/MspDeInit callbacks that can be registered/unregistered
- in READY or RESET state, thus registered (user) MspInit/DeInit callbacks can be used
- during the Init/DeInit.
- In that case first register the MspInit/MspDeInit user callbacks
- using @ref HAL_SD_RegisterCallback before calling @ref HAL_SD_DeInit
- or @ref HAL_SD_Init function.
-
- When The compilation define USE_HAL_SD_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registering feature is not available
- and weak (surcharged) callbacks are used.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup TIMEx TIMEx
- * @brief TIM Extended HAL module driver
- * @{
- */
-
-#ifdef HAL_TIM_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macros ------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-
-/* Exported functions --------------------------------------------------------*/
-/** @defgroup TIMEx_Exported_Functions TIM Extended Exported Functions
- * @{
- */
-/** @defgroup TIMEx_Exported_Functions_Group5 Extended Peripheral Control functions
- * @brief Peripheral Control functions
- *
-@verbatim
- ==============================================================================
- ##### Peripheral Control functions #####
- ==============================================================================
- [..]
- This section provides functions allowing to:
- (+) Configure Master synchronization.
- (+) Configure timer remapping capabilities.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Configures the TIM in master mode.
- * @param htim TIM handle.
- * @param sMasterConfig pointer to a TIM_MasterConfigTypeDef structure that
- * contains the selected trigger output (TRGO) and the Master/Slave
- * mode.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_TIMEx_MasterConfigSynchronization(TIM_HandleTypeDef *htim,
- TIM_MasterConfigTypeDef *sMasterConfig)
-{
- uint32_t tmpcr2;
- uint32_t tmpsmcr;
-
- /* Check the parameters */
- assert_param(IS_TIM_MASTER_INSTANCE(htim->Instance));
- assert_param(IS_TIM_TRGO_SOURCE(sMasterConfig->MasterOutputTrigger));
- assert_param(IS_TIM_MSM_STATE(sMasterConfig->MasterSlaveMode));
-
- /* Check input state */
- __HAL_LOCK(htim);
-
- /* Change the handler state */
- htim->State = HAL_TIM_STATE_BUSY;
-
- /* Get the TIMx CR2 register value */
- tmpcr2 = htim->Instance->CR2;
-
- /* Get the TIMx SMCR register value */
- tmpsmcr = htim->Instance->SMCR;
-
- /* Reset the MMS Bits */
- tmpcr2 &= ~TIM_CR2_MMS;
- /* Select the TRGO source */
- tmpcr2 |= sMasterConfig->MasterOutputTrigger;
-
- /* Update TIMx CR2 */
- htim->Instance->CR2 = tmpcr2;
-
- if (IS_TIM_SLAVE_INSTANCE(htim->Instance))
- {
- /* Reset the MSM Bit */
- tmpsmcr &= ~TIM_SMCR_MSM;
- /* Set master mode */
- tmpsmcr |= sMasterConfig->MasterSlaveMode;
-
- /* Update TIMx SMCR */
- htim->Instance->SMCR = tmpsmcr;
- }
-
- /* Change the htim state */
- htim->State = HAL_TIM_STATE_READY;
-
- __HAL_UNLOCK(htim);
-
- return HAL_OK;
-}
-
-/**
- * @brief Configures the TIMx Remapping input capabilities.
- * @param htim TIM handle.
- * @param Remap specifies the TIM remapping source.
- *
- * For TIM2, the parameter can have the following values:(see note)
- * @arg TIM_TIM2_ITR1_TIM10_OC: TIM2 ITR1 input is connected to TIM10 OC
- * @arg TIM_TIM2_ITR1_TIM5_TGO: TIM2 ITR1 input is connected to TIM5 TGO
- *
- * For TIM3, the parameter can have the following values:(see note)
- * @arg TIM_TIM3_ITR2_TIM11_OC: TIM3 ITR2 input is connected to TIM11 OC
- * @arg TIM_TIM3_ITR2_TIM5_TGO: TIM3 ITR2 input is connected to TIM5 TGO
- *
- * For TIM9, the parameter is a combination of 2 fields (field1 | field2):
- *
- * field1 can have the following values:(see note)
- * @arg TIM_TIM9_ITR1_TIM3_TGO: TIM9 ITR1 input is connected to TIM3 TGO
- * @arg TIM_TIM9_ITR1_TS: TIM9 ITR1 input is connected to touch sensing I/O
- *
- * field2 can have the following values:
- * @arg TIM_TIM9_GPIO: TIM9 Channel1 is connected to GPIO
- * @arg TIM_TIM9_LSE: TIM9 Channel1 is connected to LSE internal clock
- * @arg TIM_TIM9_GPIO1: TIM9 Channel1 is connected to GPIO
- * @arg TIM_TIM9_GPIO2: TIM9 Channel1 is connected to GPIO
- *
- * For TIM10, the parameter is a combination of 3 fields (field1 | field2 | field3):
- *
- * field1 can have the following values:(see note)
- * @arg TIM_TIM10_TI1RMP: TIM10 Channel 1 depends on TI1_RMP
- * @arg TIM_TIM10_RI: TIM10 Channel 1 is connected to RI
- *
- * field2 can have the following values:(see note)
- * @arg TIM_TIM10_ETR_LSE: TIM10 ETR input is connected to LSE clock
- * @arg TIM_TIM10_ETR_TIM9_TGO: TIM10 ETR input is connected to TIM9 TGO
- *
- * field3 can have the following values:
- * @arg TIM_TIM10_GPIO: TIM10 Channel1 is connected to GPIO
- * @arg TIM_TIM10_LSI: TIM10 Channel1 is connected to LSI internal clock
- * @arg TIM_TIM10_LSE: TIM10 Channel1 is connected to LSE internal clock
- * @arg TIM_TIM10_RTC: TIM10 Channel1 is connected to RTC wakeup interrupt
- *
- * For TIM11, the parameter is a combination of 3 fields (field1 | field2 | field3):
- *
- * field1 can have the following values:(see note)
- * @arg TIM_TIM11_TI1RMP: TIM11 Channel 1 depends on TI1_RMP
- * @arg TIM_TIM11_RI: TIM11 Channel 1 is connected to RI
- *
- * field2 can have the following values:(see note)
- * @arg TIM_TIM11_ETR_LSE: TIM11 ETR input is connected to LSE clock
- * @arg TIM_TIM11_ETR_TIM9_TGO: TIM11 ETR input is connected to TIM9 TGO
- *
- * field3 can have the following values:
- * @arg TIM_TIM11_GPIO: TIM11 Channel1 is connected to GPIO
- * @arg TIM_TIM11_MSI: TIM11 Channel1 is connected to MSI internal clock
- * @arg TIM_TIM11_HSE_RTC: TIM11 Channel1 is connected to HSE_RTC clock
- * @arg TIM_TIM11_GPIO1: TIM11 Channel1 is connected to GPIO
- *
- * @note Available only in Cat.3, Cat.4,Cat.5 and Cat.6 devices.
- *
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_TIMEx_RemapConfig(TIM_HandleTypeDef *htim, uint32_t Remap)
-{
- __HAL_LOCK(htim);
-
- /* Check parameters */
- assert_param(IS_TIM_REMAP(htim->Instance, Remap));
-
- /* Set the Timer remapping configuration */
- WRITE_REG(htim->Instance->OR, Remap);
-
- __HAL_UNLOCK(htim);
-
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-
-#endif /* HAL_TIM_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_timebase_tim_template.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_timebase_tim_template.c
deleted file mode 100644
index 5a7406abbbd..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_timebase_tim_template.c
+++ /dev/null
@@ -1,195 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_timebase_tim_template.c
- * @author MCD Application Team
- * @brief HAL time base based on the hardware TIM Template.
- *
- * This file override the native HAL time base functions (defined as weak)
- * the TIM time base:
- * + Intializes the TIM peripheral to generate a Period elapsed Event each 1ms
- * + HAL_IncTick is called inside HAL_TIM_PeriodElapsedCallback ie each 1ms
- *
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- This file must be copied to the application folder and modified as follows:
- (#) Rename it to 'stm32l1xx_hal_timebase_tim.c'
- (#) Add this file and the TIM HAL driver files to your project and make sure
- HAL_TIM_MODULE_ENABLED is defined in stm32l1xx_hal_conf.h
-
- [..]
- (@) The application needs to ensure that the time base is always set to 1 millisecond
- to have correct HAL operation.
-
- @endverbatim
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @addtogroup HAL_TimeBase_TIM
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-TIM_HandleTypeDef TimHandle;
-/* Private function prototypes -----------------------------------------------*/
-void TIM6_IRQHandler(void);
-/* Private functions ---------------------------------------------------------*/
-
-/**
- * @brief This function configures the TIM6 as a time base source.
- * The time source is configured to have 1ms time base with a dedicated
- * Tick interrupt priority.
- * @note This function is called automatically at the beginning of program after
- * reset by HAL_Init() or at any time when clock is configured, by HAL_RCC_ClockConfig().
- * @param TickPriority Tick interrupt priority.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_InitTick (uint32_t TickPriority)
-{
- RCC_ClkInitTypeDef clkconfig;
- uint32_t uwTimclock, uwAPB1Prescaler = 0U;
- uint32_t uwPrescalerValue = 0U;
- uint32_t pFLatency;
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Enable TIM6 clock */
- __HAL_RCC_TIM6_CLK_ENABLE();
-
- /* Get clock configuration */
- HAL_RCC_GetClockConfig(&clkconfig, &pFLatency);
-
- /* Get APB1 prescaler */
- uwAPB1Prescaler = clkconfig.APB1CLKDivider;
-
- /* Compute TIM6 clock */
- if (uwAPB1Prescaler == RCC_HCLK_DIV1)
- {
- uwTimclock = HAL_RCC_GetPCLK1Freq();
- }
- else
- {
- uwTimclock = 2U * HAL_RCC_GetPCLK1Freq();
- }
-
- /* Compute the prescaler value to have TIM6 counter clock equal to 1MHz */
- uwPrescalerValue = (uint32_t) ((uwTimclock / 1000000U) - 1U);
-
- /* Initialize TIM6 */
- TimHandle.Instance = TIM6;
-
- /* Initialize TIMx peripheral as follow:
- + Period = [(TIM6CLK/1000) - 1]. to have a (1/1000) s time base.
- + Prescaler = (uwTimclock/1000000 - 1) to have a 1MHz counter clock.
- + ClockDivision = 0
- + Counter direction = Up
- */
- TimHandle.Init.Period = (1000000U / 1000U) - 1U;
- TimHandle.Init.Prescaler = uwPrescalerValue;
- TimHandle.Init.ClockDivision = 0U;
- TimHandle.Init.CounterMode = TIM_COUNTERMODE_UP;
- status = HAL_TIM_Base_Init(&TimHandle);
- if (status == HAL_OK)
- {
- /* Start the TIM time Base generation in interrupt mode */
- status = HAL_TIM_Base_Start_IT(&TimHandle);
- if (status == HAL_OK)
- {
- /* Enable the TIM6 global Interrupt */
- HAL_NVIC_EnableIRQ(TIM6_IRQn);
-
- if (TickPriority < (1UL << __NVIC_PRIO_BITS))
- {
- /*Configure the TIM6 IRQ priority */
- HAL_NVIC_SetPriority(TIM6_IRQn, TickPriority ,0);
- uwTickPrio = TickPriority;
- }
- else
- {
- status = HAL_ERROR;
- }
- }
- }
-
- /* Return function status */
- return status;
-}
-
-/**
- * @brief Suspend Tick increment.
- * @note Disable the tick increment by disabling TIM6 update interrupt.
- * @param None
- * @retval None
- */
-void HAL_SuspendTick(void)
-{
- /* Disable TIM6 update interrupt */
- __HAL_TIM_DISABLE_IT(&TimHandle, TIM_IT_UPDATE);
-}
-
-/**
- * @brief Resume Tick increment.
- * @note Enable the tick increment by enabling TIM6 update interrupt.
- * @param None
- * @retval None
- */
-void HAL_ResumeTick(void)
-{
- /* Enable TIM6 update interrupt */
- __HAL_TIM_ENABLE_IT(&TimHandle, TIM_IT_UPDATE);
-}
-
-/**
- * @brief Period elapsed callback in non blocking mode
- * @note This function is called when TIM6 interrupt took place, inside
- * HAL_TIM_IRQHandler(). It makes a direct call to HAL_IncTick() to increment
- * a global variable "uwTick" used as application time base.
- * @param htim TIM handle
- * @retval None
- */
-void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
-{
- HAL_IncTick();
-}
-
-/**
- * @brief This function handles TIM interrupt request.
- * @param None
- * @retval None
- */
-void TIM6_IRQHandler(void)
-{
- HAL_TIM_IRQHandler(&TimHandle);
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_uart.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_uart.c
deleted file mode 100644
index 4d0309c9bb1..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_uart.c
+++ /dev/null
@@ -1,3718 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_uart.c
- * @author MCD Application Team
- * @brief UART HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Universal Asynchronous Receiver Transmitter Peripheral (UART).
- * + Initialization and de-initialization functions
- * + IO operation functions
- * + Peripheral Control functions
- * + Peripheral State and Errors functions
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- The UART HAL driver can be used as follows:
-
- (#) Declare a UART_HandleTypeDef handle structure (eg. UART_HandleTypeDef huart).
- (#) Initialize the UART low level resources by implementing the HAL_UART_MspInit() API:
- (##) Enable the USARTx interface clock.
- (##) UART pins configuration:
- (+++) Enable the clock for the UART GPIOs.
- (+++) Configure the UART TX/RX pins as alternate function pull-up.
- (##) NVIC configuration if you need to use interrupt process (HAL_UART_Transmit_IT()
- and HAL_UART_Receive_IT() APIs):
- (+++) Configure the USARTx interrupt priority.
- (+++) Enable the NVIC USART IRQ handle.
- (##) DMA Configuration if you need to use DMA process (HAL_UART_Transmit_DMA()
- and HAL_UART_Receive_DMA() APIs):
- (+++) Declare a DMA handle structure for the Tx/Rx channel.
- (+++) Enable the DMAx interface clock.
- (+++) Configure the declared DMA handle structure with the required
- Tx/Rx parameters.
- (+++) Configure the DMA Tx/Rx channel.
- (+++) Associate the initialized DMA handle to the UART DMA Tx/Rx handle.
- (+++) Configure the priority and enable the NVIC for the transfer complete
- interrupt on the DMA Tx/Rx channel.
- (+++) Configure the USARTx interrupt priority and enable the NVIC USART IRQ handle
- (used for last byte sending completion detection in DMA non circular mode)
-
- (#) Program the Baud Rate, Word Length, Stop Bit, Parity, Hardware
- flow control and Mode(Receiver/Transmitter) in the huart Init structure.
-
- (#) For the UART asynchronous mode, initialize the UART registers by calling
- the HAL_UART_Init() API.
-
- (#) For the UART Half duplex mode, initialize the UART registers by calling
- the HAL_HalfDuplex_Init() API.
-
- (#) For the LIN mode, initialize the UART registers by calling the HAL_LIN_Init() API.
-
- (#) For the Multi-Processor mode, initialize the UART registers by calling
- the HAL_MultiProcessor_Init() API.
-
- [..]
- (@) The specific UART interrupts (Transmission complete interrupt,
- RXNE interrupt and Error Interrupts) will be managed using the macros
- __HAL_UART_ENABLE_IT() and __HAL_UART_DISABLE_IT() inside the transmit
- and receive process.
-
- [..]
- (@) These APIs (HAL_UART_Init() and HAL_HalfDuplex_Init()) configure also the
- low level Hardware GPIO, CLOCK, CORTEX...etc) by calling the customized
- HAL_UART_MspInit() API.
-
- ##### Callback registration #####
- ==================================
-
- [..]
- The compilation define USE_HAL_UART_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
-
- [..]
- Use Function @ref HAL_UART_RegisterCallback() to register a user callback.
- Function @ref HAL_UART_RegisterCallback() allows to register following callbacks:
- (+) TxHalfCpltCallback : Tx Half Complete Callback.
- (+) TxCpltCallback : Tx Complete Callback.
- (+) RxHalfCpltCallback : Rx Half Complete Callback.
- (+) RxCpltCallback : Rx Complete Callback.
- (+) ErrorCallback : Error Callback.
- (+) AbortCpltCallback : Abort Complete Callback.
- (+) AbortTransmitCpltCallback : Abort Transmit Complete Callback.
- (+) AbortReceiveCpltCallback : Abort Receive Complete Callback.
- (+) MspInitCallback : UART MspInit.
- (+) MspDeInitCallback : UART MspDeInit.
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
-
- [..]
- Use function @ref HAL_UART_UnRegisterCallback() to reset a callback to the default
- weak (surcharged) function.
- @ref HAL_UART_UnRegisterCallback() takes as parameters the HAL peripheral handle,
- and the Callback ID.
- This function allows to reset following callbacks:
- (+) TxHalfCpltCallback : Tx Half Complete Callback.
- (+) TxCpltCallback : Tx Complete Callback.
- (+) RxHalfCpltCallback : Rx Half Complete Callback.
- (+) RxCpltCallback : Rx Complete Callback.
- (+) ErrorCallback : Error Callback.
- (+) AbortCpltCallback : Abort Complete Callback.
- (+) AbortTransmitCpltCallback : Abort Transmit Complete Callback.
- (+) AbortReceiveCpltCallback : Abort Receive Complete Callback.
- (+) MspInitCallback : UART MspInit.
- (+) MspDeInitCallback : UART MspDeInit.
-
- [..]
- For specific callback RxEventCallback, use dedicated registration/reset functions:
- respectively @ref HAL_UART_RegisterRxEventCallback() , @ref HAL_UART_UnRegisterRxEventCallback().
-
- [..]
- By default, after the @ref HAL_UART_Init() and when the state is HAL_UART_STATE_RESET
- all callbacks are set to the corresponding weak (surcharged) functions:
- examples @ref HAL_UART_TxCpltCallback(), @ref HAL_UART_RxHalfCpltCallback().
- Exception done for MspInit and MspDeInit functions that are respectively
- reset to the legacy weak (surcharged) functions in the @ref HAL_UART_Init()
- and @ref HAL_UART_DeInit() only when these callbacks are null (not registered beforehand).
- If not, MspInit or MspDeInit are not null, the @ref HAL_UART_Init() and @ref HAL_UART_DeInit()
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
-
- [..]
- Callbacks can be registered/unregistered in HAL_UART_STATE_READY state only.
- Exception done MspInit/MspDeInit that can be registered/unregistered
- in HAL_UART_STATE_READY or HAL_UART_STATE_RESET state, thus registered (user)
- MspInit/DeInit callbacks can be used during the Init/DeInit.
- In that case first register the MspInit/MspDeInit user callbacks
- using @ref HAL_UART_RegisterCallback() before calling @ref HAL_UART_DeInit()
- or @ref HAL_UART_Init() function.
-
- [..]
- When The compilation define USE_HAL_UART_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registration feature is not available
- and weak (surcharged) callbacks are used.
-
- [..]
- Three operation modes are available within this driver :
-
- *** Polling mode IO operation ***
- =================================
- [..]
- (+) Send an amount of data in blocking mode using HAL_UART_Transmit()
- (+) Receive an amount of data in blocking mode using HAL_UART_Receive()
-
- *** Interrupt mode IO operation ***
- ===================================
- [..]
- (+) Send an amount of data in non blocking mode using HAL_UART_Transmit_IT()
- (+) At transmission end of transfer HAL_UART_TxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_UART_TxCpltCallback
- (+) Receive an amount of data in non blocking mode using HAL_UART_Receive_IT()
- (+) At reception end of transfer HAL_UART_RxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_UART_RxCpltCallback
- (+) In case of transfer Error, HAL_UART_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer HAL_UART_ErrorCallback
-
- *** DMA mode IO operation ***
- ==============================
- [..]
- (+) Send an amount of data in non blocking mode (DMA) using HAL_UART_Transmit_DMA()
- (+) At transmission end of half transfer HAL_UART_TxHalfCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_UART_TxHalfCpltCallback
- (+) At transmission end of transfer HAL_UART_TxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_UART_TxCpltCallback
- (+) Receive an amount of data in non blocking mode (DMA) using HAL_UART_Receive_DMA()
- (+) At reception end of half transfer HAL_UART_RxHalfCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_UART_RxHalfCpltCallback
- (+) At reception end of transfer HAL_UART_RxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_UART_RxCpltCallback
- (+) In case of transfer Error, HAL_UART_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer HAL_UART_ErrorCallback
- (+) Pause the DMA Transfer using HAL_UART_DMAPause()
- (+) Resume the DMA Transfer using HAL_UART_DMAResume()
- (+) Stop the DMA Transfer using HAL_UART_DMAStop()
-
-
- [..] This subsection also provides a set of additional functions providing enhanced reception
- services to user. (For example, these functions allow application to handle use cases
- where number of data to be received is unknown).
-
- (#) Compared to standard reception services which only consider number of received
- data elements as reception completion criteria, these functions also consider additional events
- as triggers for updating reception status to caller :
- (+) Detection of inactivity period (RX line has not been active for a given period).
- (++) RX inactivity detected by IDLE event, i.e. RX line has been in idle state (normally high state)
- for 1 frame time, after last received byte.
-
- (#) There are two mode of transfer:
- (+) Blocking mode: The reception is performed in polling mode, until either expected number of data is received,
- or till IDLE event occurs. Reception is handled only during function execution.
- When function exits, no data reception could occur. HAL status and number of actually received data elements,
- are returned by function after finishing transfer.
- (+) Non-Blocking mode: The reception is performed using Interrupts or DMA.
- These API's return the HAL status.
- The end of the data processing will be indicated through the
- dedicated UART IRQ when using Interrupt mode or the DMA IRQ when using DMA mode.
- The HAL_UARTEx_RxEventCallback() user callback will be executed during Receive process
- The HAL_UART_ErrorCallback()user callback will be executed when a reception error is detected.
-
- (#) Blocking mode API:
- (+) HAL_UARTEx_ReceiveToIdle()
-
- (#) Non-Blocking mode API with Interrupt:
- (+) HAL_UARTEx_ReceiveToIdle_IT()
-
- (#) Non-Blocking mode API with DMA:
- (+) HAL_UARTEx_ReceiveToIdle_DMA()
-
-
- *** UART HAL driver macros list ***
- =============================================
- [..]
- Below the list of most used macros in UART HAL driver.
-
- (+) __HAL_UART_ENABLE: Enable the UART peripheral
- (+) __HAL_UART_DISABLE: Disable the UART peripheral
- (+) __HAL_UART_GET_FLAG : Check whether the specified UART flag is set or not
- (+) __HAL_UART_CLEAR_FLAG : Clear the specified UART pending flag
- (+) __HAL_UART_ENABLE_IT: Enable the specified UART interrupt
- (+) __HAL_UART_DISABLE_IT: Disable the specified UART interrupt
- (+) __HAL_UART_GET_IT_SOURCE: Check whether the specified UART interrupt has occurred or not
-
- [..]
- (@) You can refer to the UART HAL driver header file for more useful macros
-
- @endverbatim
- [..]
- (@) Additional remark: If the parity is enabled, then the MSB bit of the data written
- in the data register is transmitted but is changed by the parity bit.
- Depending on the frame length defined by the M bit (8-bits or 9-bits),
- the possible UART frame formats are as listed in the following table:
- +-------------------------------------------------------------+
- | M bit | PCE bit | UART frame |
- |---------------------|---------------------------------------|
- | 0 | 0 | | SB | 8 bit data | STB | |
- |---------|-----------|---------------------------------------|
- | 0 | 1 | | SB | 7 bit data | PB | STB | |
- |---------|-----------|---------------------------------------|
- | 1 | 0 | | SB | 9 bit data | STB | |
- |---------|-----------|---------------------------------------|
- | 1 | 1 | | SB | 8 bit data | PB | STB | |
- +-------------------------------------------------------------+
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-/** @defgroup UART UART
- * @brief HAL UART module driver
- * @{
- */
-#ifdef HAL_UART_MODULE_ENABLED
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/** @addtogroup UART_Private_Constants
- * @{
- */
-/**
- * @}
- */
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/** @addtogroup UART_Private_Functions UART Private Functions
- * @{
- */
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
-void UART_InitCallbacksToDefault(UART_HandleTypeDef *huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-static void UART_EndTxTransfer(UART_HandleTypeDef *huart);
-static void UART_EndRxTransfer(UART_HandleTypeDef *huart);
-static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma);
-static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma);
-static void UART_DMATxHalfCplt(DMA_HandleTypeDef *hdma);
-static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma);
-static void UART_DMAError(DMA_HandleTypeDef *hdma);
-static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma);
-static void UART_DMATxAbortCallback(DMA_HandleTypeDef *hdma);
-static void UART_DMARxAbortCallback(DMA_HandleTypeDef *hdma);
-static void UART_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma);
-static void UART_DMARxOnlyAbortCallback(DMA_HandleTypeDef *hdma);
-static HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart);
-static HAL_StatusTypeDef UART_EndTransmit_IT(UART_HandleTypeDef *huart);
-static HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart);
-static HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout);
-static void UART_SetConfig(UART_HandleTypeDef *huart);
-
-/**
- * @}
- */
-
-/* Exported functions ---------------------------------------------------------*/
-/** @defgroup UART_Exported_Functions UART Exported Functions
- * @{
- */
-
-/** @defgroup UART_Exported_Functions_Group1 Initialization and de-initialization functions
- * @brief Initialization and Configuration functions
- *
-@verbatim
- ===============================================================================
- ##### Initialization and Configuration functions #####
- ===============================================================================
- [..]
- This subsection provides a set of functions allowing to initialize the USARTx or the UARTy
- in asynchronous mode.
- (+) For the asynchronous mode only these parameters can be configured:
- (++) Baud Rate
- (++) Word Length
- (++) Stop Bit
- (++) Parity: If the parity is enabled, then the MSB bit of the data written
- in the data register is transmitted but is changed by the parity bit.
- Depending on the frame length defined by the M bit (8-bits or 9-bits),
- please refer to Reference manual for possible UART frame formats.
- (++) Hardware flow control
- (++) Receiver/transmitter modes
- (++) Over Sampling Method
- [..]
- The HAL_UART_Init(), HAL_HalfDuplex_Init(), HAL_LIN_Init() and HAL_MultiProcessor_Init() APIs
- follow respectively the UART asynchronous, UART Half duplex, LIN and Multi-Processor configuration
- procedures (details for the procedures are available in reference manual (RM0038)).
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initializes the UART mode according to the specified parameters in
- * the UART_InitTypeDef and create the associated handle.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Init(UART_HandleTypeDef *huart)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- if (huart->Init.HwFlowCtl != UART_HWCONTROL_NONE)
- {
- /* The hardware flow control is available only for USART1, USART2 and USART3 */
- assert_param(IS_UART_HWFLOW_INSTANCE(huart->Instance));
- assert_param(IS_UART_HARDWARE_FLOW_CONTROL(huart->Init.HwFlowCtl));
- }
- else
- {
- assert_param(IS_UART_INSTANCE(huart->Instance));
- }
- assert_param(IS_UART_WORD_LENGTH(huart->Init.WordLength));
- assert_param(IS_UART_OVERSAMPLING(huart->Init.OverSampling));
-
- if (huart->gState == HAL_UART_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- huart->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- UART_InitCallbacksToDefault(huart);
-
- if (huart->MspInitCallback == NULL)
- {
- huart->MspInitCallback = HAL_UART_MspInit;
- }
-
- /* Init the low level hardware */
- huart->MspInitCallback(huart);
-#else
- /* Init the low level hardware : GPIO, CLOCK */
- HAL_UART_MspInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Disable the peripheral */
- __HAL_UART_DISABLE(huart);
-
- /* Set the UART Communication parameters */
- UART_SetConfig(huart);
-
- /* In asynchronous mode, the following bits must be kept cleared:
- - LINEN and CLKEN bits in the USART_CR2 register,
- - SCEN, HDSEL and IREN bits in the USART_CR3 register.*/
- CLEAR_BIT(huart->Instance->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
- CLEAR_BIT(huart->Instance->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
-
- /* Enable the peripheral */
- __HAL_UART_ENABLE(huart);
-
- /* Initialize the UART state */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @brief Initializes the half-duplex mode according to the specified
- * parameters in the UART_InitTypeDef and create the associated handle.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_HalfDuplex_Init(UART_HandleTypeDef *huart)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_UART_HALFDUPLEX_INSTANCE(huart->Instance));
- assert_param(IS_UART_WORD_LENGTH(huart->Init.WordLength));
- assert_param(IS_UART_OVERSAMPLING(huart->Init.OverSampling));
-
- if (huart->gState == HAL_UART_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- huart->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- UART_InitCallbacksToDefault(huart);
-
- if (huart->MspInitCallback == NULL)
- {
- huart->MspInitCallback = HAL_UART_MspInit;
- }
-
- /* Init the low level hardware */
- huart->MspInitCallback(huart);
-#else
- /* Init the low level hardware : GPIO, CLOCK */
- HAL_UART_MspInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Disable the peripheral */
- __HAL_UART_DISABLE(huart);
-
- /* Set the UART Communication parameters */
- UART_SetConfig(huart);
-
- /* In half-duplex mode, the following bits must be kept cleared:
- - LINEN and CLKEN bits in the USART_CR2 register,
- - SCEN and IREN bits in the USART_CR3 register.*/
- CLEAR_BIT(huart->Instance->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
- CLEAR_BIT(huart->Instance->CR3, (USART_CR3_IREN | USART_CR3_SCEN));
-
- /* Enable the Half-Duplex mode by setting the HDSEL bit in the CR3 register */
- SET_BIT(huart->Instance->CR3, USART_CR3_HDSEL);
-
- /* Enable the peripheral */
- __HAL_UART_ENABLE(huart);
-
- /* Initialize the UART state*/
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @brief Initializes the LIN mode according to the specified
- * parameters in the UART_InitTypeDef and create the associated handle.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @param BreakDetectLength Specifies the LIN break detection length.
- * This parameter can be one of the following values:
- * @arg UART_LINBREAKDETECTLENGTH_10B: 10-bit break detection
- * @arg UART_LINBREAKDETECTLENGTH_11B: 11-bit break detection
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_LIN_Init(UART_HandleTypeDef *huart, uint32_t BreakDetectLength)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the LIN UART instance */
- assert_param(IS_UART_LIN_INSTANCE(huart->Instance));
-
- /* Check the Break detection length parameter */
- assert_param(IS_UART_LIN_BREAK_DETECT_LENGTH(BreakDetectLength));
- assert_param(IS_UART_LIN_WORD_LENGTH(huart->Init.WordLength));
- assert_param(IS_UART_LIN_OVERSAMPLING(huart->Init.OverSampling));
-
- if (huart->gState == HAL_UART_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- huart->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- UART_InitCallbacksToDefault(huart);
-
- if (huart->MspInitCallback == NULL)
- {
- huart->MspInitCallback = HAL_UART_MspInit;
- }
-
- /* Init the low level hardware */
- huart->MspInitCallback(huart);
-#else
- /* Init the low level hardware : GPIO, CLOCK */
- HAL_UART_MspInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Disable the peripheral */
- __HAL_UART_DISABLE(huart);
-
- /* Set the UART Communication parameters */
- UART_SetConfig(huart);
-
- /* In LIN mode, the following bits must be kept cleared:
- - CLKEN bits in the USART_CR2 register,
- - SCEN, HDSEL and IREN bits in the USART_CR3 register.*/
- CLEAR_BIT(huart->Instance->CR2, (USART_CR2_CLKEN));
- CLEAR_BIT(huart->Instance->CR3, (USART_CR3_HDSEL | USART_CR3_IREN | USART_CR3_SCEN));
-
- /* Enable the LIN mode by setting the LINEN bit in the CR2 register */
- SET_BIT(huart->Instance->CR2, USART_CR2_LINEN);
-
- /* Set the USART LIN Break detection length. */
- CLEAR_BIT(huart->Instance->CR2, USART_CR2_LBDL);
- SET_BIT(huart->Instance->CR2, BreakDetectLength);
-
- /* Enable the peripheral */
- __HAL_UART_ENABLE(huart);
-
- /* Initialize the UART state*/
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @brief Initializes the Multi-Processor mode according to the specified
- * parameters in the UART_InitTypeDef and create the associated handle.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @param Address USART address
- * @param WakeUpMethod specifies the USART wake-up method.
- * This parameter can be one of the following values:
- * @arg UART_WAKEUPMETHOD_IDLELINE: Wake-up by an idle line detection
- * @arg UART_WAKEUPMETHOD_ADDRESSMARK: Wake-up by an address mark
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_MultiProcessor_Init(UART_HandleTypeDef *huart, uint8_t Address, uint32_t WakeUpMethod)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_UART_MULTIPROCESSOR_INSTANCE(huart->Instance));
-
- /* Check the Address & wake up method parameters */
- assert_param(IS_UART_WAKEUPMETHOD(WakeUpMethod));
- assert_param(IS_UART_ADDRESS(Address));
- assert_param(IS_UART_WORD_LENGTH(huart->Init.WordLength));
- assert_param(IS_UART_OVERSAMPLING(huart->Init.OverSampling));
-
- if (huart->gState == HAL_UART_STATE_RESET)
- {
- /* Allocate lock resource and initialize it */
- huart->Lock = HAL_UNLOCKED;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- UART_InitCallbacksToDefault(huart);
-
- if (huart->MspInitCallback == NULL)
- {
- huart->MspInitCallback = HAL_UART_MspInit;
- }
-
- /* Init the low level hardware */
- huart->MspInitCallback(huart);
-#else
- /* Init the low level hardware : GPIO, CLOCK */
- HAL_UART_MspInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
- }
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Disable the peripheral */
- __HAL_UART_DISABLE(huart);
-
- /* Set the UART Communication parameters */
- UART_SetConfig(huart);
-
- /* In Multi-Processor mode, the following bits must be kept cleared:
- - LINEN and CLKEN bits in the USART_CR2 register,
- - SCEN, HDSEL and IREN bits in the USART_CR3 register */
- CLEAR_BIT(huart->Instance->CR2, (USART_CR2_LINEN | USART_CR2_CLKEN));
- CLEAR_BIT(huart->Instance->CR3, (USART_CR3_SCEN | USART_CR3_HDSEL | USART_CR3_IREN));
-
- /* Set the USART address node */
- CLEAR_BIT(huart->Instance->CR2, USART_CR2_ADD);
- SET_BIT(huart->Instance->CR2, Address);
-
- /* Set the wake up method by setting the WAKE bit in the CR1 register */
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_WAKE);
- SET_BIT(huart->Instance->CR1, WakeUpMethod);
-
- /* Enable the peripheral */
- __HAL_UART_ENABLE(huart);
-
- /* Initialize the UART state */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @brief DeInitializes the UART peripheral.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_DeInit(UART_HandleTypeDef *huart)
-{
- /* Check the UART handle allocation */
- if (huart == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_UART_INSTANCE(huart->Instance));
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Disable the Peripheral */
- __HAL_UART_DISABLE(huart);
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- if (huart->MspDeInitCallback == NULL)
- {
- huart->MspDeInitCallback = HAL_UART_MspDeInit;
- }
- /* DeInit the low level hardware */
- huart->MspDeInitCallback(huart);
-#else
- /* DeInit the low level hardware */
- HAL_UART_MspDeInit(huart);
-#endif /* (USE_HAL_UART_REGISTER_CALLBACKS) */
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_RESET;
- huart->RxState = HAL_UART_STATE_RESET;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Process Unlock */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief UART MSP Init.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval None
- */
-__weak void HAL_UART_MspInit(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_UART_MspInit could be implemented in the user file
- */
-}
-
-/**
- * @brief UART MSP DeInit.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval None
- */
-__weak void HAL_UART_MspDeInit(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_UART_MspDeInit could be implemented in the user file
- */
-}
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
-/**
- * @brief Register a User UART Callback
- * To be used instead of the weak predefined callback
- * @param huart uart handle
- * @param CallbackID ID of the callback to be registered
- * This parameter can be one of the following values:
- * @arg @ref HAL_UART_TX_HALFCOMPLETE_CB_ID Tx Half Complete Callback ID
- * @arg @ref HAL_UART_TX_COMPLETE_CB_ID Tx Complete Callback ID
- * @arg @ref HAL_UART_RX_HALFCOMPLETE_CB_ID Rx Half Complete Callback ID
- * @arg @ref HAL_UART_RX_COMPLETE_CB_ID Rx Complete Callback ID
- * @arg @ref HAL_UART_ERROR_CB_ID Error Callback ID
- * @arg @ref HAL_UART_ABORT_COMPLETE_CB_ID Abort Complete Callback ID
- * @arg @ref HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID Abort Transmit Complete Callback ID
- * @arg @ref HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID Abort Receive Complete Callback ID
- * @arg @ref HAL_UART_MSPINIT_CB_ID MspInit Callback ID
- * @arg @ref HAL_UART_MSPDEINIT_CB_ID MspDeInit Callback ID
- * @param pCallback pointer to the Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_RegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID, pUART_CallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- /* Update the error code */
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
- /* Process locked */
- __HAL_LOCK(huart);
-
- if (huart->gState == HAL_UART_STATE_READY)
- {
- switch (CallbackID)
- {
- case HAL_UART_TX_HALFCOMPLETE_CB_ID :
- huart->TxHalfCpltCallback = pCallback;
- break;
-
- case HAL_UART_TX_COMPLETE_CB_ID :
- huart->TxCpltCallback = pCallback;
- break;
-
- case HAL_UART_RX_HALFCOMPLETE_CB_ID :
- huart->RxHalfCpltCallback = pCallback;
- break;
-
- case HAL_UART_RX_COMPLETE_CB_ID :
- huart->RxCpltCallback = pCallback;
- break;
-
- case HAL_UART_ERROR_CB_ID :
- huart->ErrorCallback = pCallback;
- break;
-
- case HAL_UART_ABORT_COMPLETE_CB_ID :
- huart->AbortCpltCallback = pCallback;
- break;
-
- case HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID :
- huart->AbortTransmitCpltCallback = pCallback;
- break;
-
- case HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID :
- huart->AbortReceiveCpltCallback = pCallback;
- break;
-
- case HAL_UART_MSPINIT_CB_ID :
- huart->MspInitCallback = pCallback;
- break;
-
- case HAL_UART_MSPDEINIT_CB_ID :
- huart->MspDeInitCallback = pCallback;
- break;
-
- default :
- /* Update the error code */
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else if (huart->gState == HAL_UART_STATE_RESET)
- {
- switch (CallbackID)
- {
- case HAL_UART_MSPINIT_CB_ID :
- huart->MspInitCallback = pCallback;
- break;
-
- case HAL_UART_MSPDEINIT_CB_ID :
- huart->MspDeInitCallback = pCallback;
- break;
-
- default :
- /* Update the error code */
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the error code */
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(huart);
-
- return status;
-}
-
-/**
- * @brief Unregister an UART Callback
- * UART callaback is redirected to the weak predefined callback
- * @param huart uart handle
- * @param CallbackID ID of the callback to be unregistered
- * This parameter can be one of the following values:
- * @arg @ref HAL_UART_TX_HALFCOMPLETE_CB_ID Tx Half Complete Callback ID
- * @arg @ref HAL_UART_TX_COMPLETE_CB_ID Tx Complete Callback ID
- * @arg @ref HAL_UART_RX_HALFCOMPLETE_CB_ID Rx Half Complete Callback ID
- * @arg @ref HAL_UART_RX_COMPLETE_CB_ID Rx Complete Callback ID
- * @arg @ref HAL_UART_ERROR_CB_ID Error Callback ID
- * @arg @ref HAL_UART_ABORT_COMPLETE_CB_ID Abort Complete Callback ID
- * @arg @ref HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID Abort Transmit Complete Callback ID
- * @arg @ref HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID Abort Receive Complete Callback ID
- * @arg @ref HAL_UART_MSPINIT_CB_ID MspInit Callback ID
- * @arg @ref HAL_UART_MSPDEINIT_CB_ID MspDeInit Callback ID
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_UnRegisterCallback(UART_HandleTypeDef *huart, HAL_UART_CallbackIDTypeDef CallbackID)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Process locked */
- __HAL_LOCK(huart);
-
- if (HAL_UART_STATE_READY == huart->gState)
- {
- switch (CallbackID)
- {
- case HAL_UART_TX_HALFCOMPLETE_CB_ID :
- huart->TxHalfCpltCallback = HAL_UART_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
- break;
-
- case HAL_UART_TX_COMPLETE_CB_ID :
- huart->TxCpltCallback = HAL_UART_TxCpltCallback; /* Legacy weak TxCpltCallback */
- break;
-
- case HAL_UART_RX_HALFCOMPLETE_CB_ID :
- huart->RxHalfCpltCallback = HAL_UART_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
- break;
-
- case HAL_UART_RX_COMPLETE_CB_ID :
- huart->RxCpltCallback = HAL_UART_RxCpltCallback; /* Legacy weak RxCpltCallback */
- break;
-
- case HAL_UART_ERROR_CB_ID :
- huart->ErrorCallback = HAL_UART_ErrorCallback; /* Legacy weak ErrorCallback */
- break;
-
- case HAL_UART_ABORT_COMPLETE_CB_ID :
- huart->AbortCpltCallback = HAL_UART_AbortCpltCallback; /* Legacy weak AbortCpltCallback */
- break;
-
- case HAL_UART_ABORT_TRANSMIT_COMPLETE_CB_ID :
- huart->AbortTransmitCpltCallback = HAL_UART_AbortTransmitCpltCallback; /* Legacy weak AbortTransmitCpltCallback */
- break;
-
- case HAL_UART_ABORT_RECEIVE_COMPLETE_CB_ID :
- huart->AbortReceiveCpltCallback = HAL_UART_AbortReceiveCpltCallback; /* Legacy weak AbortReceiveCpltCallback */
- break;
-
- case HAL_UART_MSPINIT_CB_ID :
- huart->MspInitCallback = HAL_UART_MspInit; /* Legacy weak MspInitCallback */
- break;
-
- case HAL_UART_MSPDEINIT_CB_ID :
- huart->MspDeInitCallback = HAL_UART_MspDeInit; /* Legacy weak MspDeInitCallback */
- break;
-
- default :
- /* Update the error code */
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else if (HAL_UART_STATE_RESET == huart->gState)
- {
- switch (CallbackID)
- {
- case HAL_UART_MSPINIT_CB_ID :
- huart->MspInitCallback = HAL_UART_MspInit;
- break;
-
- case HAL_UART_MSPDEINIT_CB_ID :
- huart->MspDeInitCallback = HAL_UART_MspDeInit;
- break;
-
- default :
- /* Update the error code */
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- break;
- }
- }
- else
- {
- /* Update the error code */
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- /* Return error status */
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(huart);
-
- return status;
-}
-
-/**
- * @brief Register a User UART Rx Event Callback
- * To be used instead of the weak predefined callback
- * @param huart Uart handle
- * @param pCallback Pointer to the Rx Event Callback function
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_RegisterRxEventCallback(UART_HandleTypeDef *huart, pUART_RxEventCallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- return HAL_ERROR;
- }
-
- /* Process locked */
- __HAL_LOCK(huart);
-
- if (huart->gState == HAL_UART_STATE_READY)
- {
- huart->RxEventCallback = pCallback;
- }
- else
- {
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(huart);
-
- return status;
-}
-
-/**
- * @brief UnRegister the UART Rx Event Callback
- * UART Rx Event Callback is redirected to the weak HAL_UARTEx_RxEventCallback() predefined callback
- * @param huart Uart handle
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_UnRegisterRxEventCallback(UART_HandleTypeDef *huart)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- /* Process locked */
- __HAL_LOCK(huart);
-
- if (huart->gState == HAL_UART_STATE_READY)
- {
- huart->RxEventCallback = HAL_UARTEx_RxEventCallback; /* Legacy weak UART Rx Event Callback */
- }
- else
- {
- huart->ErrorCode |= HAL_UART_ERROR_INVALID_CALLBACK;
-
- status = HAL_ERROR;
- }
-
- /* Release Lock */
- __HAL_UNLOCK(huart);
- return status;
-}
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-
-/**
- * @}
- */
-
-/** @defgroup UART_Exported_Functions_Group2 IO operation functions
- * @brief UART Transmit and Receive functions
- *
-@verbatim
- ===============================================================================
- ##### IO operation functions #####
- ===============================================================================
- This subsection provides a set of functions allowing to manage the UART asynchronous
- and Half duplex data transfers.
-
- (#) There are two modes of transfer:
- (+) Blocking mode: The communication is performed in polling mode.
- The HAL status of all data processing is returned by the same function
- after finishing transfer.
- (+) Non-Blocking mode: The communication is performed using Interrupts
- or DMA, these API's return the HAL status.
- The end of the data processing will be indicated through the
- dedicated UART IRQ when using Interrupt mode or the DMA IRQ when
- using DMA mode.
- The HAL_UART_TxCpltCallback(), HAL_UART_RxCpltCallback() user callbacks
- will be executed respectively at the end of the transmit or receive process
- The HAL_UART_ErrorCallback()user callback will be executed when a communication error is detected.
-
- (#) Blocking mode API's are :
- (+) HAL_UART_Transmit()
- (+) HAL_UART_Receive()
-
- (#) Non-Blocking mode API's with Interrupt are :
- (+) HAL_UART_Transmit_IT()
- (+) HAL_UART_Receive_IT()
- (+) HAL_UART_IRQHandler()
-
- (#) Non-Blocking mode API's with DMA are :
- (+) HAL_UART_Transmit_DMA()
- (+) HAL_UART_Receive_DMA()
- (+) HAL_UART_DMAPause()
- (+) HAL_UART_DMAResume()
- (+) HAL_UART_DMAStop()
-
- (#) A set of Transfer Complete Callbacks are provided in Non_Blocking mode:
- (+) HAL_UART_TxHalfCpltCallback()
- (+) HAL_UART_TxCpltCallback()
- (+) HAL_UART_RxHalfCpltCallback()
- (+) HAL_UART_RxCpltCallback()
- (+) HAL_UART_ErrorCallback()
-
- (#) Non-Blocking mode transfers could be aborted using Abort API's :
- (+) HAL_UART_Abort()
- (+) HAL_UART_AbortTransmit()
- (+) HAL_UART_AbortReceive()
- (+) HAL_UART_Abort_IT()
- (+) HAL_UART_AbortTransmit_IT()
- (+) HAL_UART_AbortReceive_IT()
-
- (#) For Abort services based on interrupts (HAL_UART_Abortxxx_IT), a set of Abort Complete Callbacks are provided:
- (+) HAL_UART_AbortCpltCallback()
- (+) HAL_UART_AbortTransmitCpltCallback()
- (+) HAL_UART_AbortReceiveCpltCallback()
-
- (#) A Rx Event Reception Callback (Rx event notification) is available for Non_Blocking modes of enhanced reception services:
- (+) HAL_UARTEx_RxEventCallback()
-
- (#) In Non-Blocking mode transfers, possible errors are split into 2 categories.
- Errors are handled as follows :
- (+) Error is considered as Recoverable and non blocking : Transfer could go till end, but error severity is
- to be evaluated by user : this concerns Frame Error, Parity Error or Noise Error in Interrupt mode reception .
- Received character is then retrieved and stored in Rx buffer, Error code is set to allow user to identify error type,
- and HAL_UART_ErrorCallback() user callback is executed. Transfer is kept ongoing on UART side.
- If user wants to abort it, Abort services should be called by user.
- (+) Error is considered as Blocking : Transfer could not be completed properly and is aborted.
- This concerns Overrun Error In Interrupt mode reception and all errors in DMA mode.
- Error code is set to allow user to identify error type, and HAL_UART_ErrorCallback() user callback is executed.
-
- -@- In the Half duplex communication, it is forbidden to run the transmit
- and receive process in parallel, the UART state HAL_UART_STATE_BUSY_TX_RX can't be useful.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Sends an amount of data in blocking mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the sent data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 provided through pData.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be sent
- * @param Timeout Timeout duration
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
-{
- uint8_t *pdata8bits;
- uint16_t *pdata16bits;
- uint32_t tickstart = 0U;
-
- /* Check that a Tx process is not already ongoing */
- if (huart->gState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_BUSY_TX;
-
- /* Init tickstart for timeout management */
- tickstart = HAL_GetTick();
-
- huart->TxXferSize = Size;
- huart->TxXferCount = Size;
-
- /* In case of 9bits/No Parity transfer, pData needs to be handled as a uint16_t pointer */
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
- {
- pdata8bits = NULL;
- pdata16bits = (uint16_t *) pData;
- }
- else
- {
- pdata8bits = pData;
- pdata16bits = NULL;
- }
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- while (huart->TxXferCount > 0U)
- {
- if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TXE, RESET, tickstart, Timeout) != HAL_OK)
- {
- return HAL_TIMEOUT;
- }
- if (pdata8bits == NULL)
- {
- huart->Instance->DR = (uint16_t)(*pdata16bits & 0x01FFU);
- pdata16bits++;
- }
- else
- {
- huart->Instance->DR = (uint8_t)(*pdata8bits & 0xFFU);
- pdata8bits++;
- }
- huart->TxXferCount--;
- }
-
- if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_TC, RESET, tickstart, Timeout) != HAL_OK)
- {
- return HAL_TIMEOUT;
- }
-
- /* At end of Tx process, restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Receives an amount of data in blocking mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the received data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 available through pData.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be received.
- * @param Timeout Timeout duration
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Receive(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint32_t Timeout)
-{
- uint8_t *pdata8bits;
- uint16_t *pdata16bits;
- uint32_t tickstart = 0U;
-
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->RxState = HAL_UART_STATE_BUSY_RX;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Init tickstart for timeout management */
- tickstart = HAL_GetTick();
-
- huart->RxXferSize = Size;
- huart->RxXferCount = Size;
-
- /* In case of 9bits/No Parity transfer, pRxData needs to be handled as a uint16_t pointer */
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
- {
- pdata8bits = NULL;
- pdata16bits = (uint16_t *) pData;
- }
- else
- {
- pdata8bits = pData;
- pdata16bits = NULL;
- }
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- /* Check the remain data to be received */
- while (huart->RxXferCount > 0U)
- {
- if (UART_WaitOnFlagUntilTimeout(huart, UART_FLAG_RXNE, RESET, tickstart, Timeout) != HAL_OK)
- {
- return HAL_TIMEOUT;
- }
- if (pdata8bits == NULL)
- {
- *pdata16bits = (uint16_t)(huart->Instance->DR & 0x01FF);
- pdata16bits++;
- }
- else
- {
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) || ((huart->Init.WordLength == UART_WORDLENGTH_8B) && (huart->Init.Parity == UART_PARITY_NONE)))
- {
- *pdata8bits = (uint8_t)(huart->Instance->DR & (uint8_t)0x00FF);
- }
- else
- {
- *pdata8bits = (uint8_t)(huart->Instance->DR & (uint8_t)0x007F);
- }
- pdata8bits++;
- }
- huart->RxXferCount--;
- }
-
- /* At end of Rx process, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Sends an amount of data in non blocking mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the sent data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 provided through pData.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be sent
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Transmit_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- /* Check that a Tx process is not already ongoing */
- if (huart->gState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->pTxBuffPtr = pData;
- huart->TxXferSize = Size;
- huart->TxXferCount = Size;
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_BUSY_TX;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- /* Enable the UART Transmit data register empty Interrupt */
- __HAL_UART_ENABLE_IT(huart, UART_IT_TXE);
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Receives an amount of data in non blocking mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the received data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 available through pData.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- /* Set Reception type to Standard reception */
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- return(UART_Start_Receive_IT(huart, pData, Size));
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Sends an amount of data in DMA mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the sent data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 provided through pData.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be sent
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Transmit_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- uint32_t *tmp;
-
- /* Check that a Tx process is not already ongoing */
- if (huart->gState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->pTxBuffPtr = pData;
- huart->TxXferSize = Size;
- huart->TxXferCount = Size;
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->gState = HAL_UART_STATE_BUSY_TX;
-
- /* Set the UART DMA transfer complete callback */
- huart->hdmatx->XferCpltCallback = UART_DMATransmitCplt;
-
- /* Set the UART DMA Half transfer complete callback */
- huart->hdmatx->XferHalfCpltCallback = UART_DMATxHalfCplt;
-
- /* Set the DMA error callback */
- huart->hdmatx->XferErrorCallback = UART_DMAError;
-
- /* Set the DMA abort callback */
- huart->hdmatx->XferAbortCallback = NULL;
-
- /* Enable the UART transmit DMA channel */
- tmp = (uint32_t *)&pData;
- HAL_DMA_Start_IT(huart->hdmatx, *(uint32_t *)tmp, (uint32_t)&huart->Instance->DR, Size);
-
- /* Clear the TC flag in the SR register by writing 0 to it */
- __HAL_UART_CLEAR_FLAG(huart, UART_FLAG_TC);
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- /* Enable the DMA transfer for transmit request by setting the DMAT bit
- in the UART CR3 register */
- SET_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Receives an amount of data in DMA mode.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M1-M0 = 01),
- * the received data is handled as a set of u16. In this case, Size must indicate the number
- * of u16 available through pData.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be received.
- * @note When the UART parity is enabled (PCE = 1) the received data contains the parity bit.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- /* Set Reception type to Standard reception */
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- return(UART_Start_Receive_DMA(huart, pData, Size));
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Pauses the DMA Transfer.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_DMAPause(UART_HandleTypeDef *huart)
-{
- uint32_t dmarequest = 0x00U;
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- dmarequest = HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT);
- if ((huart->gState == HAL_UART_STATE_BUSY_TX) && dmarequest)
- {
- /* Disable the UART DMA Tx request */
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
- }
-
- dmarequest = HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR);
- if ((huart->RxState == HAL_UART_STATE_BUSY_RX) && dmarequest)
- {
- /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Disable the UART DMA Rx request */
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
- }
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief Resumes the DMA Transfer.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_DMAResume(UART_HandleTypeDef *huart)
-{
- /* Process Locked */
- __HAL_LOCK(huart);
-
- if (huart->gState == HAL_UART_STATE_BUSY_TX)
- {
- /* Enable the UART DMA Tx request */
- SET_BIT(huart->Instance->CR3, USART_CR3_DMAT);
- }
-
- if (huart->RxState == HAL_UART_STATE_BUSY_RX)
- {
- /* Clear the Overrun flag before resuming the Rx transfer*/
- __HAL_UART_CLEAR_OREFLAG(huart);
-
- /* Re-enable PE and ERR (Frame error, noise error, overrun error) interrupts */
- SET_BIT(huart->Instance->CR1, USART_CR1_PEIE);
- SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Enable the UART DMA Rx request */
- SET_BIT(huart->Instance->CR3, USART_CR3_DMAR);
- }
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief Stops the DMA Transfer.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UART_DMAStop(UART_HandleTypeDef *huart)
-{
- uint32_t dmarequest = 0x00U;
- /* The Lock is not implemented on this API to allow the user application
- to call the HAL UART API under callbacks HAL_UART_TxCpltCallback() / HAL_UART_RxCpltCallback():
- when calling HAL_DMA_Abort() API the DMA TX/RX Transfer complete interrupt is generated
- and the correspond call back is executed HAL_UART_TxCpltCallback() / HAL_UART_RxCpltCallback()
- */
-
- /* Stop UART DMA Tx request if ongoing */
- dmarequest = HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT);
- if ((huart->gState == HAL_UART_STATE_BUSY_TX) && dmarequest)
- {
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Abort the UART DMA Tx channel */
- if (huart->hdmatx != NULL)
- {
- HAL_DMA_Abort(huart->hdmatx);
- }
- UART_EndTxTransfer(huart);
- }
-
- /* Stop UART DMA Rx request if ongoing */
- dmarequest = HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR);
- if ((huart->RxState == HAL_UART_STATE_BUSY_RX) && dmarequest)
- {
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel */
- if (huart->hdmarx != NULL)
- {
- HAL_DMA_Abort(huart->hdmarx);
- }
- UART_EndRxTransfer(huart);
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Receive an amount of data in blocking mode till either the expected number of data is received or an IDLE event occurs.
- * @note HAL_OK is returned if reception is completed (expected number of data has been received)
- * or if reception is stopped after IDLE event (less than the expected number of data has been received)
- * In this case, RxLen output parameter indicates number of data available in reception buffer.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M = 01),
- * the received data is handled as a set of uint16_t. In this case, Size must indicate the number
- * of uint16_t available through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (uint8_t or uint16_t data elements).
- * @param Size Amount of data elements (uint8_t or uint16_t) to be received.
- * @param RxLen Number of data elements finally received (could be lower than Size, in case reception ends on IDLE event)
- * @param Timeout Timeout duration expressed in ms (covers the whole reception sequence).
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size, uint16_t *RxLen, uint32_t Timeout)
-{
- uint8_t *pdata8bits;
- uint16_t *pdata16bits;
- uint32_t tickstart;
-
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- __HAL_LOCK(huart);
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->RxState = HAL_UART_STATE_BUSY_RX;
- huart->ReceptionType = HAL_UART_RECEPTION_TOIDLE;
-
- /* Init tickstart for timeout management */
- tickstart = HAL_GetTick();
-
- huart->RxXferSize = Size;
- huart->RxXferCount = Size;
-
- /* In case of 9bits/No Parity transfer, pRxData needs to be handled as a uint16_t pointer */
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
- {
- pdata8bits = NULL;
- pdata16bits = (uint16_t *) pData;
- }
- else
- {
- pdata8bits = pData;
- pdata16bits = NULL;
- }
-
- __HAL_UNLOCK(huart);
-
- /* Initialize output number of received elements */
- *RxLen = 0U;
-
- /* as long as data have to be received */
- while (huart->RxXferCount > 0U)
- {
- /* Check if IDLE flag is set */
- if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE))
- {
- /* Clear IDLE flag in ISR */
- __HAL_UART_CLEAR_IDLEFLAG(huart);
-
- /* If Set, but no data ever received, clear flag without exiting loop */
- /* If Set, and data has already been received, this means Idle Event is valid : End reception */
- if (*RxLen > 0U)
- {
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_OK;
- }
- }
-
- /* Check if RXNE flag is set */
- if (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE))
- {
- if (pdata8bits == NULL)
- {
- *pdata16bits = (uint16_t)(huart->Instance->DR & (uint16_t)0x01FF);
- pdata16bits++;
- }
- else
- {
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) || ((huart->Init.WordLength == UART_WORDLENGTH_8B) && (huart->Init.Parity == UART_PARITY_NONE)))
- {
- *pdata8bits = (uint8_t)(huart->Instance->DR & (uint8_t)0x00FF);
- }
- else
- {
- *pdata8bits = (uint8_t)(huart->Instance->DR & (uint8_t)0x007F);
- }
-
- pdata8bits++;
- }
- /* Increment number of received elements */
- *RxLen += 1U;
- huart->RxXferCount--;
- }
-
- /* Check for the Timeout */
- if (Timeout != HAL_MAX_DELAY)
- {
- if (((HAL_GetTick() - tickstart) > Timeout) || (Timeout == 0U))
- {
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_TIMEOUT;
- }
- }
- }
-
- /* Set number of received elements in output parameter : RxLen */
- *RxLen = huart->RxXferSize - huart->RxXferCount;
- /* At end of Rx process, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
-
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Receive an amount of data in interrupt mode till either the expected number of data is received or an IDLE event occurs.
- * @note Reception is initiated by this function call. Further progress of reception is achieved thanks
- * to UART interrupts raised by RXNE and IDLE events. Callback is called at end of reception indicating
- * number of received data elements.
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M = 01),
- * the received data is handled as a set of uint16_t. In this case, Size must indicate the number
- * of uint16_t available through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (uint8_t or uint16_t data elements).
- * @param Size Amount of data elements (uint8_t or uint16_t) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- HAL_StatusTypeDef status;
-
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- __HAL_LOCK(huart);
-
- /* Set Reception type to reception till IDLE Event*/
- huart->ReceptionType = HAL_UART_RECEPTION_TOIDLE;
-
- status = UART_Start_Receive_IT(huart, pData, Size);
-
- /* Check Rx process has been successfully started */
- if (status == HAL_OK)
- {
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- __HAL_UART_CLEAR_IDLEFLAG(huart);
- SET_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
- }
- else
- {
- /* In case of errors already pending when reception is started,
- Interrupts may have already been raised and lead to reception abortion.
- (Overrun error for instance).
- In such case Reception Type has been reset to HAL_UART_RECEPTION_STANDARD. */
- status = HAL_ERROR;
- }
- }
-
- return status;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Receive an amount of data in DMA mode till either the expected number of data is received or an IDLE event occurs.
- * @note Reception is initiated by this function call. Further progress of reception is achieved thanks
- * to DMA services, transferring automatically received data elements in user reception buffer and
- * calling registered callbacks at half/end of reception. UART IDLE events are also used to consider
- * reception phase as ended. In all cases, callback execution will indicate number of received data elements.
- * @note When the UART parity is enabled (PCE = 1), the received data contain
- * the parity bit (MSB position).
- * @note When UART parity is not enabled (PCE = 0), and Word Length is configured to 9 bits (M = 01),
- * the received data is handled as a set of uint16_t. In this case, Size must indicate the number
- * of uint16_t available through pData.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (uint8_t or uint16_t data elements).
- * @param Size Amount of data elements (uint8_t or uint16_t) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_UARTEx_ReceiveToIdle_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- HAL_StatusTypeDef status;
-
- /* Check that a Rx process is not already ongoing */
- if (huart->RxState == HAL_UART_STATE_READY)
- {
- if ((pData == NULL) || (Size == 0U))
- {
- return HAL_ERROR;
- }
-
- __HAL_LOCK(huart);
-
- /* Set Reception type to reception till IDLE Event*/
- huart->ReceptionType = HAL_UART_RECEPTION_TOIDLE;
-
- status = UART_Start_Receive_DMA(huart, pData, Size);
-
- /* Check Rx process has been successfully started */
- if (status == HAL_OK)
- {
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- __HAL_UART_CLEAR_IDLEFLAG(huart);
- SET_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
- }
- else
- {
- /* In case of errors already pending when reception is started,
- Interrupts may have already been raised and lead to reception abortion.
- (Overrun error for instance).
- In such case Reception Type has been reset to HAL_UART_RECEPTION_STANDARD. */
- status = HAL_ERROR;
- }
- }
-
- return status;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Abort ongoing transfers (blocking mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Tx and Rx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort (in case of transfer in DMA mode)
- * - Set handle State to READY
- * @note This procedure is executed in blocking mode : when exiting function, Abort is considered as completed.
- * @retval HAL status
-*/
-HAL_StatusTypeDef HAL_UART_Abort(UART_HandleTypeDef *huart)
-{
- /* Disable TXEIE, TCIE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
- }
-
- /* Disable the UART DMA Tx request if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
- {
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Abort the UART DMA Tx channel: use blocking DMA Abort API (no callback) */
- if (huart->hdmatx != NULL)
- {
- /* Set the UART DMA Abort callback to Null.
- No call back execution at end of DMA abort procedure */
- huart->hdmatx->XferAbortCallback = NULL;
-
- if (HAL_DMA_Abort(huart->hdmatx) != HAL_OK)
- {
- if (HAL_DMA_GetError(huart->hdmatx) == HAL_DMA_ERROR_TIMEOUT)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- return HAL_TIMEOUT;
- }
- }
- }
- }
-
- /* Disable the UART DMA Rx request if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel: use blocking DMA Abort API (no callback) */
- if (huart->hdmarx != NULL)
- {
- /* Set the UART DMA Abort callback to Null.
- No call back execution at end of DMA abort procedure */
- huart->hdmarx->XferAbortCallback = NULL;
-
- if (HAL_DMA_Abort(huart->hdmarx) != HAL_OK)
- {
- if (HAL_DMA_GetError(huart->hdmarx) == HAL_DMA_ERROR_TIMEOUT)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- return HAL_TIMEOUT;
- }
- }
- }
- }
-
- /* Reset Tx and Rx transfer counters */
- huart->TxXferCount = 0x00U;
- huart->RxXferCount = 0x00U;
-
- /* Reset ErrorCode */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
-
- /* Restore huart->RxState and huart->gState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->gState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing Transmit transfer (blocking mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Tx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort (in case of transfer in DMA mode)
- * - Set handle State to READY
- * @note This procedure is executed in blocking mode : when exiting function, Abort is considered as completed.
- * @retval HAL status
-*/
-HAL_StatusTypeDef HAL_UART_AbortTransmit(UART_HandleTypeDef *huart)
-{
- /* Disable TXEIE and TCIE interrupts */
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
-
- /* Disable the UART DMA Tx request if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
- {
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Abort the UART DMA Tx channel : use blocking DMA Abort API (no callback) */
- if (huart->hdmatx != NULL)
- {
- /* Set the UART DMA Abort callback to Null.
- No call back execution at end of DMA abort procedure */
- huart->hdmatx->XferAbortCallback = NULL;
-
- if (HAL_DMA_Abort(huart->hdmatx) != HAL_OK)
- {
- if (HAL_DMA_GetError(huart->hdmatx) == HAL_DMA_ERROR_TIMEOUT)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- return HAL_TIMEOUT;
- }
- }
- }
- }
-
- /* Reset Tx transfer counter */
- huart->TxXferCount = 0x00U;
-
- /* Restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing Receive transfer (blocking mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Rx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort (in case of transfer in DMA mode)
- * - Set handle State to READY
- * @note This procedure is executed in blocking mode : when exiting function, Abort is considered as completed.
- * @retval HAL status
-*/
-HAL_StatusTypeDef HAL_UART_AbortReceive(UART_HandleTypeDef *huart)
-{
- /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
- }
-
- /* Disable the UART DMA Rx request if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel : use blocking DMA Abort API (no callback) */
- if (huart->hdmarx != NULL)
- {
- /* Set the UART DMA Abort callback to Null.
- No call back execution at end of DMA abort procedure */
- huart->hdmarx->XferAbortCallback = NULL;
-
- if (HAL_DMA_Abort(huart->hdmarx) != HAL_OK)
- {
- if (HAL_DMA_GetError(huart->hdmarx) == HAL_DMA_ERROR_TIMEOUT)
- {
- /* Set error code to DMA */
- huart->ErrorCode = HAL_UART_ERROR_DMA;
-
- return HAL_TIMEOUT;
- }
- }
- }
- }
-
- /* Reset Rx transfer counter */
- huart->RxXferCount = 0x00U;
-
- /* Restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing transfers (Interrupt mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Tx and Rx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort_IT (in case of transfer in DMA mode)
- * - Set handle State to READY
- * - At abort completion, call user abort complete callback
- * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
- * considered as completed only when user abort complete callback is executed (not when exiting function).
- * @retval HAL status
-*/
-HAL_StatusTypeDef HAL_UART_Abort_IT(UART_HandleTypeDef *huart)
-{
- uint32_t AbortCplt = 0x01U;
-
- /* Disable TXEIE, TCIE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE | USART_CR1_TCIE));
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
- }
-
- /* If DMA Tx and/or DMA Rx Handles are associated to UART Handle, DMA Abort complete callbacks should be initialised
- before any call to DMA Abort functions */
- /* DMA Tx Handle is valid */
- if (huart->hdmatx != NULL)
- {
- /* Set DMA Abort Complete callback if UART DMA Tx request if enabled.
- Otherwise, set it to NULL */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
- {
- huart->hdmatx->XferAbortCallback = UART_DMATxAbortCallback;
- }
- else
- {
- huart->hdmatx->XferAbortCallback = NULL;
- }
- }
- /* DMA Rx Handle is valid */
- if (huart->hdmarx != NULL)
- {
- /* Set DMA Abort Complete callback if UART DMA Rx request if enabled.
- Otherwise, set it to NULL */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- huart->hdmarx->XferAbortCallback = UART_DMARxAbortCallback;
- }
- else
- {
- huart->hdmarx->XferAbortCallback = NULL;
- }
- }
-
- /* Disable the UART DMA Tx request if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
- {
- /* Disable DMA Tx at UART level */
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Abort the UART DMA Tx channel : use non blocking DMA Abort API (callback) */
- if (huart->hdmatx != NULL)
- {
- /* UART Tx DMA Abort callback has already been initialised :
- will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
-
- /* Abort DMA TX */
- if (HAL_DMA_Abort_IT(huart->hdmatx) != HAL_OK)
- {
- huart->hdmatx->XferAbortCallback = NULL;
- }
- else
- {
- AbortCplt = 0x00U;
- }
- }
- }
-
- /* Disable the UART DMA Rx request if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel : use non blocking DMA Abort API (callback) */
- if (huart->hdmarx != NULL)
- {
- /* UART Rx DMA Abort callback has already been initialised :
- will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
-
- /* Abort DMA RX */
- if (HAL_DMA_Abort_IT(huart->hdmarx) != HAL_OK)
- {
- huart->hdmarx->XferAbortCallback = NULL;
- AbortCplt = 0x01U;
- }
- else
- {
- AbortCplt = 0x00U;
- }
- }
- }
-
- /* if no DMA abort complete callback execution is required => call user Abort Complete callback */
- if (AbortCplt == 0x01U)
- {
- /* Reset Tx and Rx transfer counters */
- huart->TxXferCount = 0x00U;
- huart->RxXferCount = 0x00U;
-
- /* Reset ErrorCode */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
-
- /* Restore huart->gState and huart->RxState to Ready */
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* As no DMA to be aborted, call directly user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort complete callback */
- huart->AbortCpltCallback(huart);
-#else
- /* Call legacy weak Abort complete callback */
- HAL_UART_AbortCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing Transmit transfer (Interrupt mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing Tx transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Tx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort_IT (in case of transfer in DMA mode)
- * - Set handle State to READY
- * - At abort completion, call user abort complete callback
- * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
- * considered as completed only when user abort complete callback is executed (not when exiting function).
- * @retval HAL status
-*/
-HAL_StatusTypeDef HAL_UART_AbortTransmit_IT(UART_HandleTypeDef *huart)
-{
- /* Disable TXEIE and TCIE interrupts */
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
-
- /* Disable the UART DMA Tx request if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT))
- {
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Abort the UART DMA Tx channel : use blocking DMA Abort API (no callback) */
- if (huart->hdmatx != NULL)
- {
- /* Set the UART DMA Abort callback :
- will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
- huart->hdmatx->XferAbortCallback = UART_DMATxOnlyAbortCallback;
-
- /* Abort DMA TX */
- if (HAL_DMA_Abort_IT(huart->hdmatx) != HAL_OK)
- {
- /* Call Directly huart->hdmatx->XferAbortCallback function in case of error */
- huart->hdmatx->XferAbortCallback(huart->hdmatx);
- }
- }
- else
- {
- /* Reset Tx transfer counter */
- huart->TxXferCount = 0x00U;
-
- /* Restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- /* As no DMA to be aborted, call directly user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Transmit Complete Callback */
- huart->AbortTransmitCpltCallback(huart);
-#else
- /* Call legacy weak Abort Transmit Complete Callback */
- HAL_UART_AbortTransmitCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- }
- else
- {
- /* Reset Tx transfer counter */
- huart->TxXferCount = 0x00U;
-
- /* Restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- /* As no DMA to be aborted, call directly user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Transmit Complete Callback */
- huart->AbortTransmitCpltCallback(huart);
-#else
- /* Call legacy weak Abort Transmit Complete Callback */
- HAL_UART_AbortTransmitCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief Abort ongoing Receive transfer (Interrupt mode).
- * @param huart UART handle.
- * @note This procedure could be used for aborting any ongoing Rx transfer started in Interrupt or DMA mode.
- * This procedure performs following operations :
- * - Disable UART Interrupts (Rx)
- * - Disable the DMA transfer in the peripheral register (if enabled)
- * - Abort DMA transfer by calling HAL_DMA_Abort_IT (in case of transfer in DMA mode)
- * - Set handle State to READY
- * - At abort completion, call user abort complete callback
- * @note This procedure is executed in Interrupt mode, meaning that abort procedure could be
- * considered as completed only when user abort complete callback is executed (not when exiting function).
- * @retval HAL status
-*/
-HAL_StatusTypeDef HAL_UART_AbortReceive_IT(UART_HandleTypeDef *huart)
-{
- /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* If Reception till IDLE event was ongoing, disable IDLEIE interrupt */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_IDLEIE));
- }
-
- /* Disable the UART DMA Rx request if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel : use blocking DMA Abort API (no callback) */
- if (huart->hdmarx != NULL)
- {
- /* Set the UART DMA Abort callback :
- will lead to call HAL_UART_AbortCpltCallback() at end of DMA abort procedure */
- huart->hdmarx->XferAbortCallback = UART_DMARxOnlyAbortCallback;
-
- /* Abort DMA RX */
- if (HAL_DMA_Abort_IT(huart->hdmarx) != HAL_OK)
- {
- /* Call Directly huart->hdmarx->XferAbortCallback function in case of error */
- huart->hdmarx->XferAbortCallback(huart->hdmarx);
- }
- }
- else
- {
- /* Reset Rx transfer counter */
- huart->RxXferCount = 0x00U;
-
- /* Restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* As no DMA to be aborted, call directly user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Receive Complete Callback */
- huart->AbortReceiveCpltCallback(huart);
-#else
- /* Call legacy weak Abort Receive Complete Callback */
- HAL_UART_AbortReceiveCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- }
- else
- {
- /* Reset Rx transfer counter */
- huart->RxXferCount = 0x00U;
-
- /* Restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* As no DMA to be aborted, call directly user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Receive Complete Callback */
- huart->AbortReceiveCpltCallback(huart);
-#else
- /* Call legacy weak Abort Receive Complete Callback */
- HAL_UART_AbortReceiveCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-
- return HAL_OK;
-}
-
-/**
- * @brief This function handles UART interrupt request.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval None
- */
-void HAL_UART_IRQHandler(UART_HandleTypeDef *huart)
-{
- uint32_t isrflags = READ_REG(huart->Instance->SR);
- uint32_t cr1its = READ_REG(huart->Instance->CR1);
- uint32_t cr3its = READ_REG(huart->Instance->CR3);
- uint32_t errorflags = 0x00U;
- uint32_t dmarequest = 0x00U;
-
- /* If no error occurs */
- errorflags = (isrflags & (uint32_t)(USART_SR_PE | USART_SR_FE | USART_SR_ORE | USART_SR_NE));
- if (errorflags == RESET)
- {
- /* UART in mode Receiver -------------------------------------------------*/
- if (((isrflags & USART_SR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
- {
- UART_Receive_IT(huart);
- return;
- }
- }
-
- /* If some errors occur */
- if ((errorflags != RESET) && (((cr3its & USART_CR3_EIE) != RESET) || ((cr1its & (USART_CR1_RXNEIE | USART_CR1_PEIE)) != RESET)))
- {
- /* UART parity error interrupt occurred ----------------------------------*/
- if (((isrflags & USART_SR_PE) != RESET) && ((cr1its & USART_CR1_PEIE) != RESET))
- {
- huart->ErrorCode |= HAL_UART_ERROR_PE;
- }
-
- /* UART noise error interrupt occurred -----------------------------------*/
- if (((isrflags & USART_SR_NE) != RESET) && ((cr3its & USART_CR3_EIE) != RESET))
- {
- huart->ErrorCode |= HAL_UART_ERROR_NE;
- }
-
- /* UART frame error interrupt occurred -----------------------------------*/
- if (((isrflags & USART_SR_FE) != RESET) && ((cr3its & USART_CR3_EIE) != RESET))
- {
- huart->ErrorCode |= HAL_UART_ERROR_FE;
- }
-
- /* UART Over-Run interrupt occurred --------------------------------------*/
- if (((isrflags & USART_SR_ORE) != RESET) && (((cr1its & USART_CR1_RXNEIE) != RESET) || ((cr3its & USART_CR3_EIE) != RESET)))
- {
- huart->ErrorCode |= HAL_UART_ERROR_ORE;
- }
-
- /* Call UART Error Call back function if need be --------------------------*/
- if (huart->ErrorCode != HAL_UART_ERROR_NONE)
- {
- /* UART in mode Receiver -----------------------------------------------*/
- if (((isrflags & USART_SR_RXNE) != RESET) && ((cr1its & USART_CR1_RXNEIE) != RESET))
- {
- UART_Receive_IT(huart);
- }
-
- /* If Overrun error occurs, or if any error occurs in DMA mode reception,
- consider error as blocking */
- dmarequest = HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR);
- if (((huart->ErrorCode & HAL_UART_ERROR_ORE) != RESET) || dmarequest)
- {
- /* Blocking error : transfer is aborted
- Set the UART state ready to be able to start again the process,
- Disable Rx Interrupts, and disable Rx DMA request, if ongoing */
- UART_EndRxTransfer(huart);
-
- /* Disable the UART DMA Rx request if enabled */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* Abort the UART DMA Rx channel */
- if (huart->hdmarx != NULL)
- {
- /* Set the UART DMA Abort callback :
- will lead to call HAL_UART_ErrorCallback() at end of DMA abort procedure */
- huart->hdmarx->XferAbortCallback = UART_DMAAbortOnError;
- if (HAL_DMA_Abort_IT(huart->hdmarx) != HAL_OK)
- {
- /* Call Directly XferAbortCallback function in case of error */
- huart->hdmarx->XferAbortCallback(huart->hdmarx);
- }
- }
- else
- {
- /* Call user error callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered error callback*/
- huart->ErrorCallback(huart);
-#else
- /*Call legacy weak error callback*/
- HAL_UART_ErrorCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- }
- else
- {
- /* Call user error callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered error callback*/
- huart->ErrorCallback(huart);
-#else
- /*Call legacy weak error callback*/
- HAL_UART_ErrorCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- }
- else
- {
- /* Non Blocking error : transfer could go on.
- Error is notified to user through user error callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered error callback*/
- huart->ErrorCallback(huart);
-#else
- /*Call legacy weak error callback*/
- HAL_UART_ErrorCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- }
- }
- return;
- } /* End if some error occurs */
-
- /* Check current reception Mode :
- If Reception till IDLE event has been selected : */
- if ( (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- &&((isrflags & USART_SR_IDLE) != 0U)
- &&((cr1its & USART_SR_IDLE) != 0U))
- {
- __HAL_UART_CLEAR_IDLEFLAG(huart);
-
- /* Check if DMA mode is enabled in UART */
- if (HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR))
- {
- /* DMA mode enabled */
- /* Check received length : If all expected data are received, do nothing,
- (DMA cplt callback will be called).
- Otherwise, if at least one data has already been received, IDLE event is to be notified to user */
- uint16_t nb_remaining_rx_data = (uint16_t) __HAL_DMA_GET_COUNTER(huart->hdmarx);
- if ( (nb_remaining_rx_data > 0U)
- &&(nb_remaining_rx_data < huart->RxXferSize))
- {
- /* Reception is not complete */
- huart->RxXferCount = nb_remaining_rx_data;
-
- /* In Normal mode, end DMA xfer and HAL UART Rx process*/
- if (huart->hdmarx->Init.Mode != DMA_CIRCULAR)
- {
- /* Disable PE and ERR (Frame error, noise error, overrun error) interrupts */
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Disable the DMA transfer for the receiver request by resetting the DMAR bit
- in the UART CR3 register */
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* At end of Rx process, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
-
- /* Last bytes received, so no need as the abort is immediate */
- (void)HAL_DMA_Abort(huart->hdmarx);
- }
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Event callback*/
- huart->RxEventCallback(huart, (huart->RxXferSize - huart->RxXferCount));
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, (huart->RxXferSize - huart->RxXferCount));
-#endif
- }
- return;
- }
- else
- {
- /* DMA mode not enabled */
- /* Check received length : If all expected data are received, do nothing.
- Otherwise, if at least one data has already been received, IDLE event is to be notified to user */
- uint16_t nb_rx_data = huart->RxXferSize - huart->RxXferCount;
- if ( (huart->RxXferCount > 0U)
- &&(nb_rx_data > 0U) )
- {
- /* Disable the UART Parity Error Interrupt and RXNE interrupts */
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
-
- /* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Rx process is completed, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx complete callback*/
- huart->RxEventCallback(huart, nb_rx_data);
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, nb_rx_data);
-#endif
- }
- return;
- }
- }
-
- /* UART in mode Transmitter ------------------------------------------------*/
- if (((isrflags & USART_SR_TXE) != RESET) && ((cr1its & USART_CR1_TXEIE) != RESET))
- {
- UART_Transmit_IT(huart);
- return;
- }
-
- /* UART in mode Transmitter end --------------------------------------------*/
- if (((isrflags & USART_SR_TC) != RESET) && ((cr1its & USART_CR1_TCIE) != RESET))
- {
- UART_EndTransmit_IT(huart);
- return;
- }
-}
-
-/**
- * @brief Tx Transfer completed callbacks.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval None
- */
-__weak void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_UART_TxCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Tx Half Transfer completed callbacks.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval None
- */
-__weak void HAL_UART_TxHalfCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_UART_TxHalfCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Rx Transfer completed callbacks.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval None
- */
-__weak void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_UART_RxCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief Rx Half Transfer completed callbacks.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval None
- */
-__weak void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_UART_RxHalfCpltCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief UART error callbacks.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval None
- */
-__weak void HAL_UART_ErrorCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_UART_ErrorCallback could be implemented in the user file
- */
-}
-
-/**
- * @brief UART Abort Complete callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_AbortCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_AbortCpltCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief UART Abort Complete callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_AbortTransmitCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_AbortTransmitCpltCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief UART Abort Receive Complete callback.
- * @param huart UART handle.
- * @retval None
- */
-__weak void HAL_UART_AbortReceiveCpltCallback(UART_HandleTypeDef *huart)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UART_AbortReceiveCpltCallback can be implemented in the user file.
- */
-}
-
-/**
- * @brief Reception Event Callback (Rx event notification called after use of advanced reception service).
- * @param huart UART handle
- * @param Size Number of data available in application reception buffer (indicates a position in
- * reception buffer until which, data are available)
- * @retval None
- */
-__weak void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(huart);
- UNUSED(Size);
-
- /* NOTE : This function should not be modified, when the callback is needed,
- the HAL_UARTEx_RxEventCallback can be implemented in the user file.
- */
-}
-
-/**
- * @}
- */
-
-/** @defgroup UART_Exported_Functions_Group3 Peripheral Control functions
- * @brief UART control functions
- *
-@verbatim
- ==============================================================================
- ##### Peripheral Control functions #####
- ==============================================================================
- [..]
- This subsection provides a set of functions allowing to control the UART:
- (+) HAL_LIN_SendBreak() API can be helpful to transmit the break character.
- (+) HAL_MultiProcessor_EnterMuteMode() API can be helpful to enter the UART in mute mode.
- (+) HAL_MultiProcessor_ExitMuteMode() API can be helpful to exit the UART mute mode by software.
- (+) HAL_HalfDuplex_EnableTransmitter() API to enable the UART transmitter and disables the UART receiver in Half Duplex mode
- (+) HAL_HalfDuplex_EnableReceiver() API to enable the UART receiver and disables the UART transmitter in Half Duplex mode
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Transmits break characters.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_LIN_SendBreak(UART_HandleTypeDef *huart)
-{
- /* Check the parameters */
- assert_param(IS_UART_INSTANCE(huart->Instance));
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Send break characters */
- SET_BIT(huart->Instance->CR1, USART_CR1_SBK);
-
- huart->gState = HAL_UART_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief Enters the UART in mute mode.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_MultiProcessor_EnterMuteMode(UART_HandleTypeDef *huart)
-{
- /* Check the parameters */
- assert_param(IS_UART_INSTANCE(huart->Instance));
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Enable the USART mute mode by setting the RWU bit in the CR1 register */
- SET_BIT(huart->Instance->CR1, USART_CR1_RWU);
-
- huart->gState = HAL_UART_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief Exits the UART mute mode: wake up software.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_MultiProcessor_ExitMuteMode(UART_HandleTypeDef *huart)
-{
- /* Check the parameters */
- assert_param(IS_UART_INSTANCE(huart->Instance));
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /* Disable the USART mute mode by clearing the RWU bit in the CR1 register */
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_RWU);
-
- huart->gState = HAL_UART_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief Enables the UART transmitter and disables the UART receiver.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_HalfDuplex_EnableTransmitter(UART_HandleTypeDef *huart)
-{
- uint32_t tmpreg = 0x00U;
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /*-------------------------- USART CR1 Configuration -----------------------*/
- tmpreg = huart->Instance->CR1;
-
- /* Clear TE and RE bits */
- tmpreg &= (uint32_t)~((uint32_t)(USART_CR1_TE | USART_CR1_RE));
-
- /* Enable the USART's transmit interface by setting the TE bit in the USART CR1 register */
- tmpreg |= (uint32_t)USART_CR1_TE;
-
- /* Write to USART CR1 */
- WRITE_REG(huart->Instance->CR1, (uint32_t)tmpreg);
-
- huart->gState = HAL_UART_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @brief Enables the UART receiver and disables the UART transmitter.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_HalfDuplex_EnableReceiver(UART_HandleTypeDef *huart)
-{
- uint32_t tmpreg = 0x00U;
-
- /* Process Locked */
- __HAL_LOCK(huart);
-
- huart->gState = HAL_UART_STATE_BUSY;
-
- /*-------------------------- USART CR1 Configuration -----------------------*/
- tmpreg = huart->Instance->CR1;
-
- /* Clear TE and RE bits */
- tmpreg &= (uint32_t)~((uint32_t)(USART_CR1_TE | USART_CR1_RE));
-
- /* Enable the USART's receive interface by setting the RE bit in the USART CR1 register */
- tmpreg |= (uint32_t)USART_CR1_RE;
-
- /* Write to USART CR1 */
- WRITE_REG(huart->Instance->CR1, (uint32_t)tmpreg);
-
- huart->gState = HAL_UART_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_OK;
-}
-
-/**
- * @}
- */
-
-/** @defgroup UART_Exported_Functions_Group4 Peripheral State and Errors functions
- * @brief UART State and Errors functions
- *
-@verbatim
- ==============================================================================
- ##### Peripheral State and Errors functions #####
- ==============================================================================
- [..]
- This subsection provides a set of functions allowing to return the State of
- UART communication process, return Peripheral Errors occurred during communication
- process
- (+) HAL_UART_GetState() API can be helpful to check in run-time the state of the UART peripheral.
- (+) HAL_UART_GetError() check in run-time errors that could be occurred during communication.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Returns the UART state.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL state
- */
-HAL_UART_StateTypeDef HAL_UART_GetState(UART_HandleTypeDef *huart)
-{
- uint32_t temp1 = 0x00U, temp2 = 0x00U;
- temp1 = huart->gState;
- temp2 = huart->RxState;
-
- return (HAL_UART_StateTypeDef)(temp1 | temp2);
-}
-
-/**
- * @brief Return the UART error code
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART.
- * @retval UART Error Code
- */
-uint32_t HAL_UART_GetError(UART_HandleTypeDef *huart)
-{
- return huart->ErrorCode;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/** @defgroup UART_Private_Functions UART Private Functions
- * @{
- */
-
-/**
- * @brief Initialize the callbacks to their default values.
- * @param huart UART handle.
- * @retval none
- */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
-void UART_InitCallbacksToDefault(UART_HandleTypeDef *huart)
-{
- /* Init the UART Callback settings */
- huart->TxHalfCpltCallback = HAL_UART_TxHalfCpltCallback; /* Legacy weak TxHalfCpltCallback */
- huart->TxCpltCallback = HAL_UART_TxCpltCallback; /* Legacy weak TxCpltCallback */
- huart->RxHalfCpltCallback = HAL_UART_RxHalfCpltCallback; /* Legacy weak RxHalfCpltCallback */
- huart->RxCpltCallback = HAL_UART_RxCpltCallback; /* Legacy weak RxCpltCallback */
- huart->ErrorCallback = HAL_UART_ErrorCallback; /* Legacy weak ErrorCallback */
- huart->AbortCpltCallback = HAL_UART_AbortCpltCallback; /* Legacy weak AbortCpltCallback */
- huart->AbortTransmitCpltCallback = HAL_UART_AbortTransmitCpltCallback; /* Legacy weak AbortTransmitCpltCallback */
- huart->AbortReceiveCpltCallback = HAL_UART_AbortReceiveCpltCallback; /* Legacy weak AbortReceiveCpltCallback */
- huart->RxEventCallback = HAL_UARTEx_RxEventCallback; /* Legacy weak RxEventCallback */
-
-}
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-
-/**
- * @brief DMA UART transmit process complete callback.
- * @param hdma Pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void UART_DMATransmitCplt(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
- /* DMA Normal mode*/
- if ((hdma->Instance->CCR & DMA_CCR_CIRC) == 0U)
- {
- huart->TxXferCount = 0x00U;
-
- /* Disable the DMA transfer for transmit request by setting the DMAT bit
- in the UART CR3 register */
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAT);
-
- /* Enable the UART Transmit Complete Interrupt */
- SET_BIT(huart->Instance->CR1, USART_CR1_TCIE);
-
- }
- /* DMA Circular mode */
- else
- {
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Tx complete callback*/
- huart->TxCpltCallback(huart);
-#else
- /*Call legacy weak Tx complete callback*/
- HAL_UART_TxCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-}
-
-/**
- * @brief DMA UART transmit process half complete callback
- * @param hdma Pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void UART_DMATxHalfCplt(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Tx complete callback*/
- huart->TxHalfCpltCallback(huart);
-#else
- /*Call legacy weak Tx complete callback*/
- HAL_UART_TxHalfCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA UART receive process complete callback.
- * @param hdma Pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void UART_DMAReceiveCplt(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
- /* DMA Normal mode*/
- if ((hdma->Instance->CCR & DMA_CCR_CIRC) == 0U)
- {
- huart->RxXferCount = 0U;
-
- /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_PEIE);
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Disable the DMA transfer for the receiver request by setting the DMAR bit
- in the UART CR3 register */
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- /* At end of Rx process, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
-
- /* If Reception till IDLE event has been selected, Disable IDLE Interrupt */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
- }
- }
-
- /* Check current reception Mode :
- If Reception till IDLE event has been selected : use Rx Event callback */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Event callback*/
- huart->RxEventCallback(huart, huart->RxXferSize);
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- else
- {
- /* In other cases : use Rx Complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx complete callback*/
- huart->RxCpltCallback(huart);
-#else
- /*Call legacy weak Rx complete callback*/
- HAL_UART_RxCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-}
-
-/**
- * @brief DMA UART receive process half complete callback
- * @param hdma Pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void UART_DMARxHalfCplt(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
-
- /* Check current reception Mode :
- If Reception till IDLE event has been selected : use Rx Event callback */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Event callback*/
- huart->RxEventCallback(huart, huart->RxXferSize/2U);
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize/2U);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
- else
- {
- /* In other cases : use Rx Half Complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Half complete callback*/
- huart->RxHalfCpltCallback(huart);
-#else
- /*Call legacy weak Rx Half complete callback*/
- HAL_UART_RxHalfCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-}
-
-/**
- * @brief DMA UART communication error callback.
- * @param hdma Pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void UART_DMAError(DMA_HandleTypeDef *hdma)
-{
- uint32_t dmarequest = 0x00U;
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
-
- /* Stop UART DMA Tx request if ongoing */
- dmarequest = HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAT);
- if ((huart->gState == HAL_UART_STATE_BUSY_TX) && dmarequest)
- {
- huart->TxXferCount = 0x00U;
- UART_EndTxTransfer(huart);
- }
-
- /* Stop UART DMA Rx request if ongoing */
- dmarequest = HAL_IS_BIT_SET(huart->Instance->CR3, USART_CR3_DMAR);
- if ((huart->RxState == HAL_UART_STATE_BUSY_RX) && dmarequest)
- {
- huart->RxXferCount = 0x00U;
- UART_EndRxTransfer(huart);
- }
-
- huart->ErrorCode |= HAL_UART_ERROR_DMA;
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered error callback*/
- huart->ErrorCallback(huart);
-#else
- /*Call legacy weak error callback*/
- HAL_UART_ErrorCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief This function handles UART Communication Timeout.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @param Flag specifies the UART flag to check.
- * @param Status The new Flag status (SET or RESET).
- * @param Tickstart Tick start value
- * @param Timeout Timeout duration
- * @retval HAL status
- */
-static HAL_StatusTypeDef UART_WaitOnFlagUntilTimeout(UART_HandleTypeDef *huart, uint32_t Flag, FlagStatus Status, uint32_t Tickstart, uint32_t Timeout)
-{
- /* Wait until flag is set */
- while ((__HAL_UART_GET_FLAG(huart, Flag) ? SET : RESET) == Status)
- {
- /* Check for the Timeout */
- if (Timeout != HAL_MAX_DELAY)
- {
- if ((Timeout == 0U) || ((HAL_GetTick() - Tickstart) > Timeout))
- {
- /* Disable TXE, RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts for the interrupt process */
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE | USART_CR1_TXEIE));
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- return HAL_TIMEOUT;
- }
- }
- }
- return HAL_OK;
-}
-
-/**
- * @brief Start Receive operation in interrupt mode.
- * @note This function could be called by all HAL UART API providing reception in Interrupt mode.
- * @note When calling this function, parameters validity is considered as already checked,
- * i.e. Rx State, buffer address, ...
- * UART Handle is assumed as Locked.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef UART_Start_Receive_IT(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- huart->pRxBuffPtr = pData;
- huart->RxXferSize = Size;
- huart->RxXferCount = Size;
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->RxState = HAL_UART_STATE_BUSY_RX;
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- /* Enable the UART Parity Error Interrupt */
- __HAL_UART_ENABLE_IT(huart, UART_IT_PE);
-
- /* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
- __HAL_UART_ENABLE_IT(huart, UART_IT_ERR);
-
- /* Enable the UART Data Register not empty Interrupt */
- __HAL_UART_ENABLE_IT(huart, UART_IT_RXNE);
-
- return HAL_OK;
-}
-
-/**
- * @brief Start Receive operation in DMA mode.
- * @note This function could be called by all HAL UART API providing reception in DMA mode.
- * @note When calling this function, parameters validity is considered as already checked,
- * i.e. Rx State, buffer address, ...
- * UART Handle is assumed as Locked.
- * @param huart UART handle.
- * @param pData Pointer to data buffer (u8 or u16 data elements).
- * @param Size Amount of data elements (u8 or u16) to be received.
- * @retval HAL status
- */
-HAL_StatusTypeDef UART_Start_Receive_DMA(UART_HandleTypeDef *huart, uint8_t *pData, uint16_t Size)
-{
- uint32_t *tmp;
-
- huart->pRxBuffPtr = pData;
- huart->RxXferSize = Size;
-
- huart->ErrorCode = HAL_UART_ERROR_NONE;
- huart->RxState = HAL_UART_STATE_BUSY_RX;
-
- /* Set the UART DMA transfer complete callback */
- huart->hdmarx->XferCpltCallback = UART_DMAReceiveCplt;
-
- /* Set the UART DMA Half transfer complete callback */
- huart->hdmarx->XferHalfCpltCallback = UART_DMARxHalfCplt;
-
- /* Set the DMA error callback */
- huart->hdmarx->XferErrorCallback = UART_DMAError;
-
- /* Set the DMA abort callback */
- huart->hdmarx->XferAbortCallback = NULL;
-
- /* Enable the DMA stream */
- tmp = (uint32_t *)&pData;
- HAL_DMA_Start_IT(huart->hdmarx, (uint32_t)&huart->Instance->DR, *(uint32_t *)tmp, Size);
-
- /* Clear the Overrun flag just before enabling the DMA Rx request: can be mandatory for the second transfer */
- __HAL_UART_CLEAR_OREFLAG(huart);
-
- /* Process Unlocked */
- __HAL_UNLOCK(huart);
-
- /* Enable the UART Parity Error Interrupt */
- SET_BIT(huart->Instance->CR1, USART_CR1_PEIE);
-
- /* Enable the UART Error Interrupt: (Frame error, noise error, overrun error) */
- SET_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* Enable the DMA transfer for the receiver request by setting the DMAR bit
- in the UART CR3 register */
- SET_BIT(huart->Instance->CR3, USART_CR3_DMAR);
-
- return HAL_OK;
-}
-
-/**
- * @brief End ongoing Tx transfer on UART peripheral (following error detection or Transmit completion).
- * @param huart UART handle.
- * @retval None
- */
-static void UART_EndTxTransfer(UART_HandleTypeDef *huart)
-{
- /* Disable TXEIE and TCIE interrupts */
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_TXEIE | USART_CR1_TCIE));
-
- /* At end of Tx process, restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-}
-
-/**
- * @brief End ongoing Rx transfer on UART peripheral (following error detection or Reception completion).
- * @param huart UART handle.
- * @retval None
- */
-static void UART_EndRxTransfer(UART_HandleTypeDef *huart)
-{
- /* Disable RXNE, PE and ERR (Frame error, noise error, overrun error) interrupts */
- CLEAR_BIT(huart->Instance->CR1, (USART_CR1_RXNEIE | USART_CR1_PEIE));
- CLEAR_BIT(huart->Instance->CR3, USART_CR3_EIE);
-
- /* In case of reception waiting for IDLE event, disable also the IDLE IE interrupt source */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
- }
-
- /* At end of Rx process, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-}
-
-/**
- * @brief DMA UART communication abort callback, when initiated by HAL services on Error
- * (To be called at end of DMA Abort procedure following error occurrence).
- * @param hdma Pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void UART_DMAAbortOnError(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
- huart->RxXferCount = 0x00U;
- huart->TxXferCount = 0x00U;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered error callback*/
- huart->ErrorCallback(huart);
-#else
- /*Call legacy weak error callback*/
- HAL_UART_ErrorCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA UART Tx communication abort callback, when initiated by user
- * (To be called at end of DMA Tx Abort procedure following user abort request).
- * @note When this callback is executed, User Abort complete call back is called only if no
- * Abort still ongoing for Rx DMA Handle.
- * @param hdma Pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void UART_DMATxAbortCallback(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
-
- huart->hdmatx->XferAbortCallback = NULL;
-
- /* Check if an Abort process is still ongoing */
- if (huart->hdmarx != NULL)
- {
- if (huart->hdmarx->XferAbortCallback != NULL)
- {
- return;
- }
- }
-
- /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */
- huart->TxXferCount = 0x00U;
- huart->RxXferCount = 0x00U;
-
- /* Reset ErrorCode */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
-
- /* Restore huart->gState and huart->RxState to Ready */
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Call user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort complete callback */
- huart->AbortCpltCallback(huart);
-#else
- /* Call legacy weak Abort complete callback */
- HAL_UART_AbortCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA UART Rx communication abort callback, when initiated by user
- * (To be called at end of DMA Rx Abort procedure following user abort request).
- * @note When this callback is executed, User Abort complete call back is called only if no
- * Abort still ongoing for Tx DMA Handle.
- * @param hdma Pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void UART_DMARxAbortCallback(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
-
- huart->hdmarx->XferAbortCallback = NULL;
-
- /* Check if an Abort process is still ongoing */
- if (huart->hdmatx != NULL)
- {
- if (huart->hdmatx->XferAbortCallback != NULL)
- {
- return;
- }
- }
-
- /* No Abort process still ongoing : All DMA channels are aborted, call user Abort Complete callback */
- huart->TxXferCount = 0x00U;
- huart->RxXferCount = 0x00U;
-
- /* Reset ErrorCode */
- huart->ErrorCode = HAL_UART_ERROR_NONE;
-
- /* Restore huart->gState and huart->RxState to Ready */
- huart->gState = HAL_UART_STATE_READY;
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Call user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort complete callback */
- huart->AbortCpltCallback(huart);
-#else
- /* Call legacy weak Abort complete callback */
- HAL_UART_AbortCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA UART Tx communication abort callback, when initiated by user by a call to
- * HAL_UART_AbortTransmit_IT API (Abort only Tx transfer)
- * (This callback is executed at end of DMA Tx Abort procedure following user abort request,
- * and leads to user Tx Abort Complete callback execution).
- * @param hdma Pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void UART_DMATxOnlyAbortCallback(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
-
- huart->TxXferCount = 0x00U;
-
- /* Restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
- /* Call user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Transmit Complete Callback */
- huart->AbortTransmitCpltCallback(huart);
-#else
- /* Call legacy weak Abort Transmit Complete Callback */
- HAL_UART_AbortTransmitCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief DMA UART Rx communication abort callback, when initiated by user by a call to
- * HAL_UART_AbortReceive_IT API (Abort only Rx transfer)
- * (This callback is executed at end of DMA Rx Abort procedure following user abort request,
- * and leads to user Rx Abort Complete callback execution).
- * @param hdma Pointer to a DMA_HandleTypeDef structure that contains
- * the configuration information for the specified DMA module.
- * @retval None
- */
-static void UART_DMARxOnlyAbortCallback(DMA_HandleTypeDef *hdma)
-{
- UART_HandleTypeDef *huart = (UART_HandleTypeDef *)((DMA_HandleTypeDef *)hdma)->Parent;
-
- huart->RxXferCount = 0x00U;
-
- /* Restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Call user Abort complete callback */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /* Call registered Abort Receive Complete Callback */
- huart->AbortReceiveCpltCallback(huart);
-#else
- /* Call legacy weak Abort Receive Complete Callback */
- HAL_UART_AbortReceiveCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-}
-
-/**
- * @brief Sends an amount of data in non blocking mode.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-static HAL_StatusTypeDef UART_Transmit_IT(UART_HandleTypeDef *huart)
-{
- uint16_t *tmp;
-
- /* Check that a Tx process is ongoing */
- if (huart->gState == HAL_UART_STATE_BUSY_TX)
- {
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
- {
- tmp = (uint16_t *) huart->pTxBuffPtr;
- huart->Instance->DR = (uint16_t)(*tmp & (uint16_t)0x01FF);
- huart->pTxBuffPtr += 2U;
- }
- else
- {
- huart->Instance->DR = (uint8_t)(*huart->pTxBuffPtr++ & (uint8_t)0x00FF);
- }
-
- if (--huart->TxXferCount == 0U)
- {
- /* Disable the UART Transmit Complete Interrupt */
- __HAL_UART_DISABLE_IT(huart, UART_IT_TXE);
-
- /* Enable the UART Transmit Complete Interrupt */
- __HAL_UART_ENABLE_IT(huart, UART_IT_TC);
- }
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Wraps up transmission in non blocking mode.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-static HAL_StatusTypeDef UART_EndTransmit_IT(UART_HandleTypeDef *huart)
-{
- /* Disable the UART Transmit Complete Interrupt */
- __HAL_UART_DISABLE_IT(huart, UART_IT_TC);
-
- /* Tx process is ended, restore huart->gState to Ready */
- huart->gState = HAL_UART_STATE_READY;
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Tx complete callback*/
- huart->TxCpltCallback(huart);
-#else
- /*Call legacy weak Tx complete callback*/
- HAL_UART_TxCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
-
- return HAL_OK;
-}
-
-/**
- * @brief Receives an amount of data in non blocking mode
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval HAL status
- */
-static HAL_StatusTypeDef UART_Receive_IT(UART_HandleTypeDef *huart)
-{
- uint8_t *pdata8bits;
- uint16_t *pdata16bits;
-
- /* Check that a Rx process is ongoing */
- if (huart->RxState == HAL_UART_STATE_BUSY_RX)
- {
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) && (huart->Init.Parity == UART_PARITY_NONE))
- {
- pdata8bits = NULL;
- pdata16bits = (uint16_t *) huart->pRxBuffPtr;
- *pdata16bits = (uint16_t)(huart->Instance->DR & (uint16_t)0x01FF);
- huart->pRxBuffPtr += 2U;
- }
- else
- {
- pdata8bits = (uint8_t *) huart->pRxBuffPtr;
- pdata16bits = NULL;
-
- if ((huart->Init.WordLength == UART_WORDLENGTH_9B) || ((huart->Init.WordLength == UART_WORDLENGTH_8B) && (huart->Init.Parity == UART_PARITY_NONE)))
- {
- *pdata8bits = (uint8_t)(huart->Instance->DR & (uint8_t)0x00FF);
- }
- else
- {
- *pdata8bits = (uint8_t)(huart->Instance->DR & (uint8_t)0x007F);
- }
- huart->pRxBuffPtr += 1U;
- }
-
- if (--huart->RxXferCount == 0U)
- {
- /* Disable the UART Data Register not empty Interrupt */
- __HAL_UART_DISABLE_IT(huart, UART_IT_RXNE);
-
- /* Disable the UART Parity Error Interrupt */
- __HAL_UART_DISABLE_IT(huart, UART_IT_PE);
-
- /* Disable the UART Error Interrupt: (Frame error, noise error, overrun error) */
- __HAL_UART_DISABLE_IT(huart, UART_IT_ERR);
-
- /* Rx process is completed, restore huart->RxState to Ready */
- huart->RxState = HAL_UART_STATE_READY;
-
- /* Check current reception Mode :
- If Reception till IDLE event has been selected : */
- if (huart->ReceptionType == HAL_UART_RECEPTION_TOIDLE)
- {
- /* Set reception type to Standard */
- huart->ReceptionType = HAL_UART_RECEPTION_STANDARD;
-
- /* Disable IDLE interrupt */
- CLEAR_BIT(huart->Instance->CR1, USART_CR1_IDLEIE);
-
- /* Check if IDLE flag is set */
- if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE))
- {
- /* Clear IDLE flag in ISR */
- __HAL_UART_CLEAR_IDLEFLAG(huart);
- }
-
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx Event callback*/
- huart->RxEventCallback(huart, huart->RxXferSize);
-#else
- /*Call legacy weak Rx Event callback*/
- HAL_UARTEx_RxEventCallback(huart, huart->RxXferSize);
-#endif
- }
- else
- {
- /* Standard reception API called */
-#if (USE_HAL_UART_REGISTER_CALLBACKS == 1)
- /*Call registered Rx complete callback*/
- huart->RxCpltCallback(huart);
-#else
- /*Call legacy weak Rx complete callback*/
- HAL_UART_RxCpltCallback(huart);
-#endif /* USE_HAL_UART_REGISTER_CALLBACKS */
- }
-
- return HAL_OK;
- }
- return HAL_OK;
- }
- else
- {
- return HAL_BUSY;
- }
-}
-
-/**
- * @brief Configures the UART peripheral.
- * @param huart Pointer to a UART_HandleTypeDef structure that contains
- * the configuration information for the specified UART module.
- * @retval None
- */
-static void UART_SetConfig(UART_HandleTypeDef *huart)
-{
- uint32_t tmpreg;
- uint32_t pclk;
-
- /* Check the parameters */
- assert_param(IS_UART_BAUDRATE(huart->Init.BaudRate));
- assert_param(IS_UART_STOPBITS(huart->Init.StopBits));
- assert_param(IS_UART_PARITY(huart->Init.Parity));
- assert_param(IS_UART_MODE(huart->Init.Mode));
-
- /*-------------------------- USART CR2 Configuration -----------------------*/
- /* Configure the UART Stop Bits: Set STOP[13:12] bits
- according to huart->Init.StopBits value */
- MODIFY_REG(huart->Instance->CR2, USART_CR2_STOP, huart->Init.StopBits);
-
- /*-------------------------- USART CR1 Configuration -----------------------*/
- /* Configure the UART Word Length, Parity and mode:
- Set the M bits according to huart->Init.WordLength value
- Set PCE and PS bits according to huart->Init.Parity value
- Set TE and RE bits according to huart->Init.Mode value
- Set OVER8 bit according to huart->Init.OverSampling value */
-
- tmpreg = (uint32_t)huart->Init.WordLength | huart->Init.Parity | huart->Init.Mode | huart->Init.OverSampling;
- MODIFY_REG(huart->Instance->CR1,
- (uint32_t)(USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | USART_CR1_TE | USART_CR1_RE | USART_CR1_OVER8),
- tmpreg);
-
- /*-------------------------- USART CR3 Configuration -----------------------*/
- /* Configure the UART HFC: Set CTSE and RTSE bits according to huart->Init.HwFlowCtl value */
- MODIFY_REG(huart->Instance->CR3, (USART_CR3_RTSE | USART_CR3_CTSE), huart->Init.HwFlowCtl);
-
-
- if((huart->Instance == USART1))
- {
- pclk = HAL_RCC_GetPCLK2Freq();
- }
- else
- {
- pclk = HAL_RCC_GetPCLK1Freq();
- }
-
- /*-------------------------- USART BRR Configuration ---------------------*/
- if (huart->Init.OverSampling == UART_OVERSAMPLING_8)
- {
- huart->Instance->BRR = UART_BRR_SAMPLING8(pclk, huart->Init.BaudRate);
- }
- else
- {
- huart->Instance->BRR = UART_BRR_SAMPLING16(pclk, huart->Init.BaudRate);
- }
-}
-
-/**
- * @}
- */
-
-#endif /* HAL_UART_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_usart.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_usart.c
deleted file mode 100644
index 15b945e3373..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_hal_usart.c
+++ /dev/null
@@ -1,2800 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_hal_usart.c
- * @author MCD Application Team
- * @brief USART HAL module driver.
- * This file provides firmware functions to manage the following
- * functionalities of the Universal Synchronous/Asynchronous Receiver Transmitter
- * Peripheral (USART).
- * + Initialization and de-initialization functions
- * + IO operation functions
- * + Peripheral Control functions
- @verbatim
- ==============================================================================
- ##### How to use this driver #####
- ==============================================================================
- [..]
- The USART HAL driver can be used as follows:
-
- (#) Declare a USART_HandleTypeDef handle structure (eg. USART_HandleTypeDef husart).
- (#) Initialize the USART low level resources by implementing the HAL_USART_MspInit() API:
- (##) Enable the USARTx interface clock.
- (##) USART pins configuration:
- (+++) Enable the clock for the USART GPIOs.
- (+++) Configure the USART pins as alternate function pull-up.
- (##) NVIC configuration if you need to use interrupt process (HAL_USART_Transmit_IT(),
- HAL_USART_Receive_IT() and HAL_USART_TransmitReceive_IT() APIs):
- (+++) Configure the USARTx interrupt priority.
- (+++) Enable the NVIC USART IRQ handle.
- (##) DMA Configuration if you need to use DMA process (HAL_USART_Transmit_DMA()
- HAL_USART_Receive_DMA() and HAL_USART_TransmitReceive_DMA() APIs):
- (+++) Declare a DMA handle structure for the Tx/Rx channel.
- (+++) Enable the DMAx interface clock.
- (+++) Configure the declared DMA handle structure with the required Tx/Rx parameters.
- (+++) Configure the DMA Tx/Rx channel.
- (+++) Associate the initialized DMA handle to the USART DMA Tx/Rx handle.
- (+++) Configure the priority and enable the NVIC for the transfer complete interrupt on the DMA Tx/Rx channel.
- (+++) Configure the USARTx interrupt priority and enable the NVIC USART IRQ handle
- (used for last byte sending completion detection in DMA non circular mode)
-
- (#) Program the Baud Rate, Word Length, Stop Bit, Parity, Hardware
- flow control and Mode(Receiver/Transmitter) in the husart Init structure.
-
- (#) Initialize the USART registers by calling the HAL_USART_Init() API:
- (++) These APIs configures also the low level Hardware GPIO, CLOCK, CORTEX...etc)
- by calling the customized HAL_USART_MspInit(&husart) API.
-
- -@@- The specific USART interrupts (Transmission complete interrupt,
- RXNE interrupt and Error Interrupts) will be managed using the macros
- __HAL_USART_ENABLE_IT() and __HAL_USART_DISABLE_IT() inside the transmit and receive process.
-
- (#) Three operation modes are available within this driver :
-
- *** Polling mode IO operation ***
- =================================
- [..]
- (+) Send an amount of data in blocking mode using HAL_USART_Transmit()
- (+) Receive an amount of data in blocking mode using HAL_USART_Receive()
-
- *** Interrupt mode IO operation ***
- ===================================
- [..]
- (+) Send an amount of data in non blocking mode using HAL_USART_Transmit_IT()
- (+) At transmission end of transfer HAL_USART_TxHalfCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_USART_TxCpltCallback
- (+) Receive an amount of data in non blocking mode using HAL_USART_Receive_IT()
- (+) At reception end of transfer HAL_USART_RxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_USART_RxCpltCallback
- (+) In case of transfer Error, HAL_USART_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer HAL_USART_ErrorCallback
-
- *** DMA mode IO operation ***
- ==============================
- [..]
- (+) Send an amount of data in non blocking mode (DMA) using HAL_USART_Transmit_DMA()
- (+) At transmission end of half transfer HAL_USART_TxHalfCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_USART_TxHalfCpltCallback
- (+) At transmission end of transfer HAL_USART_TxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_USART_TxCpltCallback
- (+) Receive an amount of data in non blocking mode (DMA) using HAL_USART_Receive_DMA()
- (+) At reception end of half transfer HAL_USART_RxHalfCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_USART_RxHalfCpltCallback
- (+) At reception end of transfer HAL_USART_RxCpltCallback is executed and user can
- add his own code by customization of function pointer HAL_USART_RxCpltCallback
- (+) In case of transfer Error, HAL_USART_ErrorCallback() function is executed and user can
- add his own code by customization of function pointer HAL_USART_ErrorCallback
- (+) Pause the DMA Transfer using HAL_USART_DMAPause()
- (+) Resume the DMA Transfer using HAL_USART_DMAResume()
- (+) Stop the DMA Transfer using HAL_USART_DMAStop()
-
- *** USART HAL driver macros list ***
- =============================================
- [..]
- Below the list of most used macros in USART HAL driver.
-
- (+) __HAL_USART_ENABLE: Enable the USART peripheral
- (+) __HAL_USART_DISABLE: Disable the USART peripheral
- (+) __HAL_USART_GET_FLAG : Check whether the specified USART flag is set or not
- (+) __HAL_USART_CLEAR_FLAG : Clear the specified USART pending flag
- (+) __HAL_USART_ENABLE_IT: Enable the specified USART interrupt
- (+) __HAL_USART_DISABLE_IT: Disable the specified USART interrupt
-
- [..]
- (@) You can refer to the USART HAL driver header file for more useful macros
-
- ##### Callback registration #####
- ==================================
-
- [..]
- The compilation define USE_HAL_USART_REGISTER_CALLBACKS when set to 1
- allows the user to configure dynamically the driver callbacks.
-
- [..]
- Use Function @ref HAL_USART_RegisterCallback() to register a user callback.
- Function @ref HAL_USART_RegisterCallback() allows to register following callbacks:
- (+) TxHalfCpltCallback : Tx Half Complete Callback.
- (+) TxCpltCallback : Tx Complete Callback.
- (+) RxHalfCpltCallback : Rx Half Complete Callback.
- (+) RxCpltCallback : Rx Complete Callback.
- (+) TxRxCpltCallback : Tx Rx Complete Callback.
- (+) ErrorCallback : Error Callback.
- (+) AbortCpltCallback : Abort Complete Callback.
- (+) MspInitCallback : USART MspInit.
- (+) MspDeInitCallback : USART MspDeInit.
- This function takes as parameters the HAL peripheral handle, the Callback ID
- and a pointer to the user callback function.
-
- [..]
- Use function @ref HAL_USART_UnRegisterCallback() to reset a callback to the default
- weak (surcharged) function.
- @ref HAL_USART_UnRegisterCallback() takes as parameters the HAL peripheral handle,
- and the Callback ID.
- This function allows to reset following callbacks:
- (+) TxHalfCpltCallback : Tx Half Complete Callback.
- (+) TxCpltCallback : Tx Complete Callback.
- (+) RxHalfCpltCallback : Rx Half Complete Callback.
- (+) RxCpltCallback : Rx Complete Callback.
- (+) TxRxCpltCallback : Tx Rx Complete Callback.
- (+) ErrorCallback : Error Callback.
- (+) AbortCpltCallback : Abort Complete Callback.
- (+) MspInitCallback : USART MspInit.
- (+) MspDeInitCallback : USART MspDeInit.
-
- [..]
- By default, after the @ref HAL_USART_Init() and when the state is HAL_USART_STATE_RESET
- all callbacks are set to the corresponding weak (surcharged) functions:
- examples @ref HAL_USART_TxCpltCallback(), @ref HAL_USART_RxHalfCpltCallback().
- Exception done for MspInit and MspDeInit functions that are respectively
- reset to the legacy weak (surcharged) functions in the @ref HAL_USART_Init()
- and @ref HAL_USART_DeInit() only when these callbacks are null (not registered beforehand).
- If not, MspInit or MspDeInit are not null, the @ref HAL_USART_Init() and @ref HAL_USART_DeInit()
- keep and use the user MspInit/MspDeInit callbacks (registered beforehand).
-
- [..]
- Callbacks can be registered/unregistered in HAL_USART_STATE_READY state only.
- Exception done MspInit/MspDeInit that can be registered/unregistered
- in HAL_USART_STATE_READY or HAL_USART_STATE_RESET state, thus registered (user)
- MspInit/DeInit callbacks can be used during the Init/DeInit.
- In that case first register the MspInit/MspDeInit user callbacks
- using @ref HAL_USART_RegisterCallback() before calling @ref HAL_USART_DeInit()
- or @ref HAL_USART_Init() function.
-
- [..]
- When The compilation define USE_HAL_USART_REGISTER_CALLBACKS is set to 0 or
- not defined, the callback registration feature is not available
- and weak (surcharged) callbacks are used.
-
- @endverbatim
- [..]
- (@) Additional remark: If the parity is enabled, then the MSB bit of the data written
- in the data register is transmitted but is changed by the parity bit.
- Depending on the frame length defined by the M bit (8-bits or 9-bits),
- the possible USART frame formats are as listed in the following table:
- +-------------------------------------------------------------+
- | M bit | PCE bit | USART frame |
- |---------------------|---------------------------------------|
- | 0 | 0 | | SB | 8 bit data | STB | |
- |---------|-----------|---------------------------------------|
- | 0 | 1 | | SB | 7 bit data | PB | STB | |
- |---------|-----------|---------------------------------------|
- | 1 | 0 | | SB | 9 bit data | STB | |
- |---------|-----------|---------------------------------------|
- | 1 | 1 | | SB | 8 bit data | PB | STB | |
- +-------------------------------------------------------------+
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_hal.h"
-
-/** @addtogroup STM32L1xx_HAL_Driver
- * @{
- */
-
-#ifdef HAL_WWDG_MODULE_ENABLED
-/** @defgroup WWDG WWDG
- * @brief WWDG HAL module driver.
- * @{
- */
-
-/* Private typedef -----------------------------------------------------------*/
-/* Private define ------------------------------------------------------------*/
-/* Private macro -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private function prototypes -----------------------------------------------*/
-/* Exported functions --------------------------------------------------------*/
-
-/** @defgroup WWDG_Exported_Functions WWDG Exported Functions
- * @{
- */
-
-/** @defgroup WWDG_Exported_Functions_Group1 Initialization and Configuration functions
- * @brief Initialization and Configuration functions.
- *
-@verbatim
- ==============================================================================
- ##### Initialization and Configuration functions #####
- ==============================================================================
- [..]
- This section provides functions allowing to:
- (+) Initialize and start the WWDG according to the specified parameters
- in the WWDG_InitTypeDef of associated handle.
- (+) Initialize the WWDG MSP.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Initialize the WWDG according to the specified.
- * parameters in the WWDG_InitTypeDef of associated handle.
- * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains
- * the configuration information for the specified WWDG module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_WWDG_Init(WWDG_HandleTypeDef *hwwdg)
-{
- /* Check the WWDG handle allocation */
- if (hwwdg == NULL)
- {
- return HAL_ERROR;
- }
-
- /* Check the parameters */
- assert_param(IS_WWDG_ALL_INSTANCE(hwwdg->Instance));
- assert_param(IS_WWDG_PRESCALER(hwwdg->Init.Prescaler));
- assert_param(IS_WWDG_WINDOW(hwwdg->Init.Window));
- assert_param(IS_WWDG_COUNTER(hwwdg->Init.Counter));
- assert_param(IS_WWDG_EWI_MODE(hwwdg->Init.EWIMode));
-
-#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
- /* Reset Callback pointers */
- if (hwwdg->EwiCallback == NULL)
- {
- hwwdg->EwiCallback = HAL_WWDG_EarlyWakeupCallback;
- }
-
- if (hwwdg->MspInitCallback == NULL)
- {
- hwwdg->MspInitCallback = HAL_WWDG_MspInit;
- }
-
- /* Init the low level hardware */
- hwwdg->MspInitCallback(hwwdg);
-#else
- /* Init the low level hardware */
- HAL_WWDG_MspInit(hwwdg);
-#endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
-
- /* Set WWDG Counter */
- WRITE_REG(hwwdg->Instance->CR, (WWDG_CR_WDGA | hwwdg->Init.Counter));
-
- /* Set WWDG Prescaler and Window */
- WRITE_REG(hwwdg->Instance->CFR, (hwwdg->Init.EWIMode | hwwdg->Init.Prescaler | hwwdg->Init.Window));
-
- /* Return function status */
- return HAL_OK;
-}
-
-
-/**
- * @brief Initialize the WWDG MSP.
- * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains
- * the configuration information for the specified WWDG module.
- * @note When rewriting this function in user file, mechanism may be added
- * to avoid multiple initialize when HAL_WWDG_Init function is called
- * again to change parameters.
- * @retval None
- */
-__weak void HAL_WWDG_MspInit(WWDG_HandleTypeDef *hwwdg)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hwwdg);
-
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_WWDG_MspInit could be implemented in the user file
- */
-}
-
-
-#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
-/**
- * @brief Register a User WWDG Callback
- * To be used instead of the weak (surcharged) predefined callback
- * @param hwwdg WWDG handle
- * @param CallbackID ID of the callback to be registered
- * This parameter can be one of the following values:
- * @arg @ref HAL_WWDG_EWI_CB_ID Early WakeUp Interrupt Callback ID
- * @arg @ref HAL_WWDG_MSPINIT_CB_ID MspInit callback ID
- * @param pCallback pointer to the Callback function
- * @retval status
- */
-HAL_StatusTypeDef HAL_WWDG_RegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID,
- pWWDG_CallbackTypeDef pCallback)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- if (pCallback == NULL)
- {
- status = HAL_ERROR;
- }
- else
- {
- switch (CallbackID)
- {
- case HAL_WWDG_EWI_CB_ID:
- hwwdg->EwiCallback = pCallback;
- break;
-
- case HAL_WWDG_MSPINIT_CB_ID:
- hwwdg->MspInitCallback = pCallback;
- break;
-
- default:
- status = HAL_ERROR;
- break;
- }
- }
-
- return status;
-}
-
-
-/**
- * @brief Unregister a WWDG Callback
- * WWDG Callback is redirected to the weak (surcharged) predefined callback
- * @param hwwdg WWDG handle
- * @param CallbackID ID of the callback to be registered
- * This parameter can be one of the following values:
- * @arg @ref HAL_WWDG_EWI_CB_ID Early WakeUp Interrupt Callback ID
- * @arg @ref HAL_WWDG_MSPINIT_CB_ID MspInit callback ID
- * @retval status
- */
-HAL_StatusTypeDef HAL_WWDG_UnRegisterCallback(WWDG_HandleTypeDef *hwwdg, HAL_WWDG_CallbackIDTypeDef CallbackID)
-{
- HAL_StatusTypeDef status = HAL_OK;
-
- switch (CallbackID)
- {
- case HAL_WWDG_EWI_CB_ID:
- hwwdg->EwiCallback = HAL_WWDG_EarlyWakeupCallback;
- break;
-
- case HAL_WWDG_MSPINIT_CB_ID:
- hwwdg->MspInitCallback = HAL_WWDG_MspInit;
- break;
-
- default:
- status = HAL_ERROR;
- break;
- }
-
- return status;
-}
-#endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
-
-/**
- * @}
- */
-
-/** @defgroup WWDG_Exported_Functions_Group2 IO operation functions
- * @brief IO operation functions
- *
-@verbatim
- ==============================================================================
- ##### IO operation functions #####
- ==============================================================================
- [..]
- This section provides functions allowing to:
- (+) Refresh the WWDG.
- (+) Handle WWDG interrupt request and associated function callback.
-
-@endverbatim
- * @{
- */
-
-/**
- * @brief Refresh the WWDG.
- * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains
- * the configuration information for the specified WWDG module.
- * @retval HAL status
- */
-HAL_StatusTypeDef HAL_WWDG_Refresh(WWDG_HandleTypeDef *hwwdg)
-{
- /* Write to WWDG CR the WWDG Counter value to refresh with */
- WRITE_REG(hwwdg->Instance->CR, (hwwdg->Init.Counter));
-
- /* Return function status */
- return HAL_OK;
-}
-
-/**
- * @brief Handle WWDG interrupt request.
- * @note The Early Wakeup Interrupt (EWI) can be used if specific safety operations
- * or data logging must be performed before the actual reset is generated.
- * The EWI interrupt is enabled by calling HAL_WWDG_Init function with
- * EWIMode set to WWDG_EWI_ENABLE.
- * When the downcounter reaches the value 0x40, and EWI interrupt is
- * generated and the corresponding Interrupt Service Routine (ISR) can
- * be used to trigger specific actions (such as communications or data
- * logging), before resetting the device.
- * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains
- * the configuration information for the specified WWDG module.
- * @retval None
- */
-void HAL_WWDG_IRQHandler(WWDG_HandleTypeDef *hwwdg)
-{
- /* Check if Early Wakeup Interrupt is enable */
- if (__HAL_WWDG_GET_IT_SOURCE(hwwdg, WWDG_IT_EWI) != RESET)
- {
- /* Check if WWDG Early Wakeup Interrupt occurred */
- if (__HAL_WWDG_GET_FLAG(hwwdg, WWDG_FLAG_EWIF) != RESET)
- {
- /* Clear the WWDG Early Wakeup flag */
- __HAL_WWDG_CLEAR_FLAG(hwwdg, WWDG_FLAG_EWIF);
-
-#if (USE_HAL_WWDG_REGISTER_CALLBACKS == 1)
- /* Early Wakeup registered callback */
- hwwdg->EwiCallback(hwwdg);
-#else
- /* Early Wakeup callback */
- HAL_WWDG_EarlyWakeupCallback(hwwdg);
-#endif /* USE_HAL_WWDG_REGISTER_CALLBACKS */
- }
- }
-}
-
-
-/**
- * @brief WWDG Early Wakeup callback.
- * @param hwwdg pointer to a WWDG_HandleTypeDef structure that contains
- * the configuration information for the specified WWDG module.
- * @retval None
- */
-__weak void HAL_WWDG_EarlyWakeupCallback(WWDG_HandleTypeDef *hwwdg)
-{
- /* Prevent unused argument(s) compilation warning */
- UNUSED(hwwdg);
-
- /* NOTE: This function should not be modified, when the callback is needed,
- the HAL_WWDG_EarlyWakeupCallback could be implemented in the user file
- */
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-#endif /* HAL_WWDG_MODULE_ENABLED */
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
diff --git a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_ll_adc.c b/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_ll_adc.c
deleted file mode 100644
index c674ab1ab0e..00000000000
--- a/bsp/stm32/libraries/STM32L1xx_HAL/STM32L1xx_HAL_Driver/Src/stm32l1xx_ll_adc.c
+++ /dev/null
@@ -1,883 +0,0 @@
-/**
- ******************************************************************************
- * @file stm32l1xx_ll_adc.c
- * @author MCD Application Team
- * @brief ADC LL module driver
- ******************************************************************************
- * @attention
- *
- *
- *
- * This software component is licensed by ST under BSD 3-Clause license,
- * the "License"; You may not use this file except in compliance with the
- * License. You may obtain a copy of the License at:
- * opensource.org/licenses/BSD-3-Clause
- *
- ******************************************************************************
- */
-/* Includes ------------------------------------------------------------------*/
-#include "stm32l1xx_ll_rcc.h"
-#include "stm32l1xx_ll_utils.h"
-#include "stm32l1xx_ll_system.h"
-#include "stm32l1xx_ll_pwr.h"
-#ifdef USE_FULL_ASSERT
-#include "stm32_assert.h"
-#else
-#define assert_param(expr) ((void)0U)
-#endif
-
-/** @addtogroup STM32L1xx_LL_Driver
- * @{
- */
-
-/** @addtogroup UTILS_LL
- * @{
- */
-
-/* Private types -------------------------------------------------------------*/
-/* Private variables ---------------------------------------------------------*/
-/* Private constants ---------------------------------------------------------*/
-/** @addtogroup UTILS_LL_Private_Constants
- * @{
- */
-#define UTILS_MAX_FREQUENCY_SCALE1 32000000U /*!< Maximum frequency for system clock at power scale1, in Hz */
-#define UTILS_MAX_FREQUENCY_SCALE2 16000000U /*!< Maximum frequency for system clock at power scale2, in Hz */
-#define UTILS_MAX_FREQUENCY_SCALE3 4000000U /*!< Maximum frequency for system clock at power scale3, in Hz */
-
-/* Defines used for PLL range */
-#define UTILS_PLLVCO_OUTPUT_SCALE1 96000000U /*!< Frequency max for PLLVCO output at power scale1, in Hz */
-#define UTILS_PLLVCO_OUTPUT_SCALE2 48000000U /*!< Frequency max for PLLVCO output at power scale2, in Hz */
-#define UTILS_PLLVCO_OUTPUT_SCALE3 24000000U /*!< Frequency max for PLLVCO output at power scale3, in Hz */
-
-/* Defines used for HSE range */
-#define UTILS_HSE_FREQUENCY_MIN 1000000U /*!< Frequency min for HSE frequency, in Hz */
-#define UTILS_HSE_FREQUENCY_MAX 24000000U /*!< Frequency max for HSE frequency, in Hz */
-
-/* Defines used for FLASH latency according to HCLK Frequency */
-#define UTILS_SCALE1_LATENCY1_FREQ 16000000U /*!< HCLK frequency to set FLASH latency 1 in power scale 1 */
-#define UTILS_SCALE2_LATENCY1_FREQ 8000000U /*!< HCLK frequency to set FLASH latency 1 in power scale 2 */
-#define UTILS_SCALE3_LATENCY1_FREQ 2000000U /*!< HCLK frequency to set FLASH latency 1 in power scale 3 */
-/**
- * @}
- */
-/* Private macros ------------------------------------------------------------*/
-/** @addtogroup UTILS_LL_Private_Macros
- * @{
- */
-#define IS_LL_UTILS_SYSCLK_DIV(__VALUE__) (((__VALUE__) == LL_RCC_SYSCLK_DIV_1) \
- || ((__VALUE__) == LL_RCC_SYSCLK_DIV_2) \
- || ((__VALUE__) == LL_RCC_SYSCLK_DIV_4) \
- || ((__VALUE__) == LL_RCC_SYSCLK_DIV_8) \
- || ((__VALUE__) == LL_RCC_SYSCLK_DIV_16) \
- || ((__VALUE__) == LL_RCC_SYSCLK_DIV_64) \
- || ((__VALUE__) == LL_RCC_SYSCLK_DIV_128) \
- || ((__VALUE__) == LL_RCC_SYSCLK_DIV_256) \
- || ((__VALUE__) == LL_RCC_SYSCLK_DIV_512))
-
-#define IS_LL_UTILS_APB1_DIV(__VALUE__) (((__VALUE__) == LL_RCC_APB1_DIV_1) \
- || ((__VALUE__) == LL_RCC_APB1_DIV_2) \
- || ((__VALUE__) == LL_RCC_APB1_DIV_4) \
- || ((__VALUE__) == LL_RCC_APB1_DIV_8) \
- || ((__VALUE__) == LL_RCC_APB1_DIV_16))
-
-#define IS_LL_UTILS_APB2_DIV(__VALUE__) (((__VALUE__) == LL_RCC_APB2_DIV_1) \
- || ((__VALUE__) == LL_RCC_APB2_DIV_2) \
- || ((__VALUE__) == LL_RCC_APB2_DIV_4) \
- || ((__VALUE__) == LL_RCC_APB2_DIV_8) \
- || ((__VALUE__) == LL_RCC_APB2_DIV_16))
-
-#define IS_LL_UTILS_PLLMUL_VALUE(__VALUE__) (((__VALUE__) == LL_RCC_PLL_MUL_3) \
- || ((__VALUE__) == LL_RCC_PLL_MUL_4) \
- || ((__VALUE__) == LL_RCC_PLL_MUL_6) \
- || ((__VALUE__) == LL_RCC_PLL_MUL_8) \
- || ((__VALUE__) == LL_RCC_PLL_MUL_12) \
- || ((__VALUE__) == LL_RCC_PLL_MUL_16) \
- || ((__VALUE__) == LL_RCC_PLL_MUL_24) \
- || ((__VALUE__) == LL_RCC_PLL_MUL_32) \
- || ((__VALUE__) == LL_RCC_PLL_MUL_48))
-
-#define IS_LL_UTILS_PLLDIV_VALUE(__VALUE__) (((__VALUE__) == LL_RCC_PLL_DIV_2) || ((__VALUE__) == LL_RCC_PLL_DIV_3) || \
- ((__VALUE__) == LL_RCC_PLL_DIV_4))
-
-#define IS_LL_UTILS_PLLVCO_OUTPUT(__VALUE__) ((LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE1) ? ((__VALUE__) <= UTILS_PLLVCO_OUTPUT_SCALE1) : \
- ((LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE2) ? ((__VALUE__) <= UTILS_PLLVCO_OUTPUT_SCALE2) : \
- ((__VALUE__) <= UTILS_PLLVCO_OUTPUT_SCALE3)))
-
-#define IS_LL_UTILS_PLL_FREQUENCY(__VALUE__) ((LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE1) ? ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE1) : \
- ((LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE2) ? ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE2) : \
- ((__VALUE__) <= UTILS_MAX_FREQUENCY_SCALE3)))
-
-#define IS_LL_UTILS_HSE_BYPASS(__STATE__) (((__STATE__) == LL_UTILS_HSEBYPASS_ON) \
- || ((__STATE__) == LL_UTILS_HSEBYPASS_OFF))
-
-#define IS_LL_UTILS_HSE_FREQUENCY(__FREQUENCY__) (((__FREQUENCY__) >= UTILS_HSE_FREQUENCY_MIN) && ((__FREQUENCY__) <= UTILS_HSE_FREQUENCY_MAX))
-/**
- * @}
- */
-/* Private function prototypes -----------------------------------------------*/
-/** @defgroup UTILS_LL_Private_Functions UTILS Private functions
- * @{
- */
-static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency,
- LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct);
-static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
-static ErrorStatus UTILS_PLL_IsBusy(void);
-/**
- * @}
- */
-
-/* Exported functions --------------------------------------------------------*/
-/** @addtogroup UTILS_LL_Exported_Functions
- * @{
- */
-
-/** @addtogroup UTILS_LL_EF_DELAY
- * @{
- */
-
-/**
- * @brief This function configures the Cortex-M SysTick source to have 1ms time base.
- * @note When a RTOS is used, it is recommended to avoid changing the Systick
- * configuration by calling this function, for a delay use rather osDelay RTOS service.
- * @param HCLKFrequency HCLK frequency in Hz
- * @note HCLK frequency can be calculated thanks to RCC helper macro or function @ref LL_RCC_GetSystemClocksFreq
- * @retval None
- */
-void LL_Init1msTick(uint32_t HCLKFrequency)
-{
- /* Use frequency provided in argument */
- LL_InitTick(HCLKFrequency, 1000U);
-}
-
-/**
- * @brief This function provides accurate delay (in milliseconds) based
- * on SysTick counter flag
- * @note When a RTOS is used, it is recommended to avoid using blocking delay
- * and use rather osDelay service.
- * @note To respect 1ms timebase, user should call @ref LL_Init1msTick function which
- * will configure Systick to 1ms
- * @param Delay specifies the delay time length, in milliseconds.
- * @retval None
- */
-void LL_mDelay(uint32_t Delay)
-{
- __IO uint32_t tmp = SysTick->CTRL; /* Clear the COUNTFLAG first */
- uint32_t tmpDelay = Delay;
-
- /* Add this code to indicate that local variable is not used */
- ((void)tmp);
-
- /* Add a period to guaranty minimum wait */
- if(tmpDelay < LL_MAX_DELAY)
- {
- tmpDelay++;
- }
-
- while (tmpDelay != 0U)
- {
- if((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
- {
- tmpDelay--;
- }
- }
-}
-
-/**
- * @}
- */
-
-/** @addtogroup UTILS_EF_SYSTEM
- * @brief System Configuration functions
- *
- @verbatim
- ===============================================================================
- ##### System Configuration functions #####
- ===============================================================================
- [..]
- System, AHB and APB buses clocks configuration
-
- (+) The maximum frequency of the SYSCLK, HCLK, PCLK1 and PCLK2 is 32000000 Hz.
- @endverbatim
- @internal
- Depending on the device voltage range, the maximum frequency should be
- adapted accordingly:
- (++) +----------------------------------------------------------------+
- (++) | Wait states | HCLK clock frequency (MHz) |
- (++) | |------------------------------------------------|
- (++) | (Latency) | voltage range | voltage range |
- (++) | | 1.65 V - 3.6 V | 2.0 V - 3.6 V |
- (++) | |----------------|---------------|---------------|
- (++) | | VCORE = 1.2 V | VCORE = 1.5 V | VCORE = 1.8 V |
- (++) |-------------- |----------------|---------------|---------------|
- (++) |0WS(1CPU cycle)|0 < HCLK <= 2 |0 < HCLK <= 8 |0 < HCLK <= 16 |
- (++) |---------------|----------------|---------------|---------------|
- (++) |1WS(2CPU cycle)|2 < HCLK <= 4 |8 < HCLK <= 16 |16 < HCLK <= 32|
- (++) +----------------------------------------------------------------+
- @endinternal
- * @{
- */
-
-/**
- * @brief This function sets directly SystemCoreClock CMSIS variable.
- * @note Variable can be calculated also through SystemCoreClockUpdate function.
- * @param HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro)
- * @retval None
- */
-void LL_SetSystemCoreClock(uint32_t HCLKFrequency)
-{
- /* HCLK clock frequency */
- SystemCoreClock = HCLKFrequency;
-}
-
-/**
- * @brief Update number of Flash wait states in line with new frequency and current
- voltage range.
- * @param Frequency HCLK frequency
- * @retval An ErrorStatus enumeration value:
- * - SUCCESS: Latency has been modified
- * - ERROR: Latency cannot be modified
- */
-#if defined(FLASH_ACR_LATENCY)
-ErrorStatus LL_SetFlashLatency(uint32_t Frequency)
-{
- ErrorStatus status = SUCCESS;
-
- uint32_t latency = LL_FLASH_LATENCY_0; /* default value 0WS */
-
- /* Frequency cannot be equal to 0 or greater than max clock */
- if ((Frequency == 0U) || (Frequency > UTILS_MAX_FREQUENCY_SCALE1))
- {
- status = ERROR;
- }
- else
- {
- if (LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE1)
- {
- if (Frequency > UTILS_SCALE1_LATENCY1_FREQ)
- {
- /* 16 < HCLK <= 32 => 1WS (2 CPU cycles) */
- latency = LL_FLASH_LATENCY_1;
- }
- /* else HCLK < 16MHz default LL_FLASH_LATENCY_0 0WS */
- }
- else if (LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE2)
- {
- if (Frequency > UTILS_SCALE2_LATENCY1_FREQ)
- {
- /* 8 < HCLK <= 16 => 1WS (2 CPU cycles) */
- latency = LL_FLASH_LATENCY_1;
- }
- /* else HCLK < 8MHz default LL_FLASH_LATENCY_0 0WS */
- }
- else
- {
- if (Frequency > UTILS_SCALE3_LATENCY1_FREQ)
- {
- /* 2 < HCLK <= 4 => 1WS (2 CPU cycles) */
- latency = LL_FLASH_LATENCY_1;
- }
- /* else HCLK < 4MHz default LL_FLASH_LATENCY_0 0WS */
- }
-
- /* Latency cannot be set to 1WS only if 64-bit access bit is enabled */
- if (latency == LL_FLASH_LATENCY_1)
- {
- LL_FLASH_Enable64bitAccess();
- }
-
- LL_FLASH_SetLatency(latency);
-
- /* Check that the new number of wait states is taken into account to access the Flash
- memory by reading the FLASH_ACR register */
- if (LL_FLASH_GetLatency() != latency)
- {
- status = ERROR;
- }
- }
- return status;
-}
-#endif /* FLASH_ACR_LATENCY */
-
-/**
- * @brief This function configures system clock with HSI as clock source of the PLL
- * @note The application need to ensure that PLL is disabled.
- * @note Function is based on the following formula:
- * - PLL output frequency = ((HSI frequency * PLLMul) / PLLDiv)
- * - PLLMul: The application software must set correctly the PLL multiplication factor to avoid exceeding
- * - 96 MHz as PLLVCO when the product is in range 1,
- * - 48 MHz as PLLVCO when the product is in range 2,
- * - 24 MHz when the product is in range 3
- * @note FLASH latency can be modified through this function.
- * @note If this latency increases to 1WS, FLASH 64-bit access will be automatically enabled.
- * A decrease of FLASH latency to 0WS will not disable 64-bit access. If needed, user should call
- * the following function @ref LL_FLASH_Disable64bitAccess.
- * @param UTILS_PLLInitStruct pointer to a @ref LL_UTILS_PLLInitTypeDef structure that contains
- * the configuration information for the PLL.
- * @param UTILS_ClkInitStruct pointer to a @ref LL_UTILS_ClkInitTypeDef structure that contains
- * the configuration information for the BUS prescalers.
- * @retval An ErrorStatus enumeration value:
- * - SUCCESS: Max frequency configuration done
- * - ERROR: Max frequency configuration not done
- */
-ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct,
- LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
-{
- ErrorStatus status;
- uint32_t pllfreq;
-
- /* Check if one of the PLL is enabled */
- if (UTILS_PLL_IsBusy() == SUCCESS)
- {
- /* Calculate the new PLL output frequency */
- pllfreq = UTILS_GetPLLOutputFrequency(HSI_VALUE, UTILS_PLLInitStruct);
-
- /* Enable HSI if not enabled */
- if (LL_RCC_HSI_IsReady() != 1U)
- {
- LL_RCC_HSI_Enable();
- while (LL_RCC_HSI_IsReady() != 1U)
- {
- /* Wait for HSI ready */
- }
- }
-
- /* Configure PLL */
- LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, UTILS_PLLInitStruct->PLLMul, UTILS_PLLInitStruct->PLLDiv);
-
- /* Enable PLL and switch system clock to PLL */
- status = UTILS_EnablePLLAndSwitchSystem(pllfreq, UTILS_ClkInitStruct);
- }
- else
- {
- /* Current PLL configuration cannot be modified */
- status = ERROR;
- }
-
- return status;
-}
-
-/**
- * @brief This function configures system clock with HSE as clock source of the PLL
- * @note The application need to ensure that PLL is disabled.
- * @note Function is based on the following formula:
- * - PLL output frequency = ((HSE frequency * PLLMul) / PLLDiv)
- * - PLLMul: The application software must set correctly the PLL multiplication factor to avoid exceeding
- * - 96 MHz as PLLVCO when the product is in range 1,
- * - 48 MHz as PLLVCO when the product is in range 2,
- * - 24 MHz when the product is in range 3
- * @note FLASH latency can be modified through this function.
- * @note If this latency increases to 1WS, FLASH 64-bit access will be automatically enabled.
- * A decrease of FLASH latency to 0WS will not disable 64-bit access. If needed, user should call
- * the following function @ref LL_FLASH_Disable64bitAccess.
- * @param HSEFrequency Value between Min_Data = 1000000 and Max_Data = 24000000
- * @param HSEBypass This parameter can be one of the following values:
- * @arg @ref LL_UTILS_HSEBYPASS_ON
- * @arg @ref LL_UTILS_HSEBYPASS_OFF
- * @param UTILS_PLLInitStruct pointer to a @ref LL_UTILS_PLLInitTypeDef structure that contains
- * the configuration information for the PLL.
- * @param UTILS_ClkInitStruct pointer to a @ref LL_UTILS_ClkInitTypeDef structure that contains
- * the configuration information for the BUS prescalers.
- * @retval An ErrorStatus enumeration value:
- * - SUCCESS: Max frequency configuration done
- * - ERROR: Max frequency configuration not done
- */
-ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass,
- LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
-{
- ErrorStatus status;
- uint32_t pllfreq;
-
- /* Check the parameters */
- assert_param(IS_LL_UTILS_HSE_FREQUENCY(HSEFrequency));
- assert_param(IS_LL_UTILS_HSE_BYPASS(HSEBypass));
-
- /* Check if one of the PLL is enabled */
- if (UTILS_PLL_IsBusy() == SUCCESS)
- {
-
- /* Calculate the new PLL output frequency */
- pllfreq = UTILS_GetPLLOutputFrequency(HSEFrequency, UTILS_PLLInitStruct);
-
- /* Enable HSE if not enabled */
- if (LL_RCC_HSE_IsReady() != 1U)
- {
- /* Check if need to enable HSE bypass feature or not */
- if (HSEBypass == LL_UTILS_HSEBYPASS_ON)
- {
- LL_RCC_HSE_EnableBypass();
- }
- else
- {
- LL_RCC_HSE_DisableBypass();
- }
-
- /* Enable HSE */
- LL_RCC_HSE_Enable();
- while (LL_RCC_HSE_IsReady() != 1U)
- {
- /* Wait for HSE ready */
- }
- }
-
- /* Configure PLL */
- LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, UTILS_PLLInitStruct->PLLMul, UTILS_PLLInitStruct->PLLDiv);
-
- /* Enable PLL and switch system clock to PLL */
- status = UTILS_EnablePLLAndSwitchSystem(pllfreq, UTILS_ClkInitStruct);
- }
- else
- {
- /* Current PLL configuration cannot be modified */
- status = ERROR;
- }
-
- return status;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/** @addtogroup UTILS_LL_Private_Functions
- * @{
- */
-
-/**
- * @brief Function to check that PLL can be modified
- * @param PLL_InputFrequency PLL input frequency (in Hz)
- * @param UTILS_PLLInitStruct pointer to a @ref LL_UTILS_PLLInitTypeDef structure that contains
- * the configuration information for the PLL.
- * @retval PLL output frequency (in Hz)
- */
-static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency, LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct)
-{
- uint32_t pllfreq;
-
- /* Check the parameters */
- assert_param(IS_LL_UTILS_PLLMUL_VALUE(UTILS_PLLInitStruct->PLLMul));
- assert_param(IS_LL_UTILS_PLLDIV_VALUE(UTILS_PLLInitStruct->PLLDiv));
-
- /* Check different PLL parameters according to RM */
- /* The application software must set correctly the PLL multiplication factor to avoid exceeding
- 96 MHz as PLLVCO when the product is in range 1,
- 48 MHz as PLLVCO when the product is in range 2,
- 24 MHz when the product is in range 3. */
- pllfreq = PLL_InputFrequency * (PLLMulTable[UTILS_PLLInitStruct->PLLMul >> RCC_CFGR_PLLMUL_Pos]);
- assert_param(IS_LL_UTILS_PLLVCO_OUTPUT(pllfreq));
-
- /* The application software must set correctly the PLL multiplication factor to avoid exceeding
- maximum frequency 32000000 in range 1 */
- pllfreq = pllfreq / ((UTILS_PLLInitStruct->PLLDiv >> RCC_CFGR_PLLDIV_Pos)+1U);
- assert_param(IS_LL_UTILS_PLL_FREQUENCY(pllfreq));
-
- return pllfreq;
-}
-
-/**
- * @brief Function to check that PLL can be modified
- * @retval An ErrorStatus enumeration value:
- * - SUCCESS: PLL modification can be done
- * - ERROR: PLL is busy
- */
-static ErrorStatus UTILS_PLL_IsBusy(void)
-{
- ErrorStatus status = SUCCESS;
-
- /* Check if PLL is busy*/
- if (LL_RCC_PLL_IsReady() != 0U)
- {
- /* PLL configuration cannot be modified */
- status = ERROR;
- }
-
- return status;
-}
-
-/**
- * @brief Function to enable PLL and switch system clock to PLL
- * @param SYSCLK_Frequency SYSCLK frequency
- * @param UTILS_ClkInitStruct pointer to a @ref LL_UTILS_ClkInitTypeDef structure that contains
- * the configuration information for the BUS prescalers.
- * @retval An ErrorStatus enumeration value:
- * - SUCCESS: No problem to switch system to PLL
- * - ERROR: Problem to switch system to PLL
- */
-static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct)
-{
- ErrorStatus status = SUCCESS;
- uint32_t hclk_frequency;
-
- assert_param(IS_LL_UTILS_SYSCLK_DIV(UTILS_ClkInitStruct->AHBCLKDivider));
- assert_param(IS_LL_UTILS_APB1_DIV(UTILS_ClkInitStruct->APB1CLKDivider));
- assert_param(IS_LL_UTILS_APB2_DIV(UTILS_ClkInitStruct->APB2CLKDivider));
-
- /* Calculate HCLK frequency */
- hclk_frequency = __LL_RCC_CALC_HCLK_FREQ(SYSCLK_Frequency, UTILS_ClkInitStruct->AHBCLKDivider);
-
- /* Increasing the number of wait states because of higher CPU frequency */
- if (SystemCoreClock < hclk_frequency)
- {
- /* Set FLASH latency to highest latency */
- status = LL_SetFlashLatency(hclk_frequency);
- }
-
- /* Update system clock configuration */
- if (status == SUCCESS)
- {
- /* Enable PLL */
- LL_RCC_PLL_Enable();
- while (LL_RCC_PLL_IsReady() != 1U)
- {
- /* Wait for PLL ready */
- }
-
- /* Sysclk activation on the main PLL */
- LL_RCC_SetAHBPrescaler(UTILS_ClkInitStruct->AHBCLKDivider);
- LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
- while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL)
- {
- /* Wait for system clock switch to PLL */
- }
-
- /* Set APB1 & APB2 prescaler*/
- LL_RCC_SetAPB1Prescaler(UTILS_ClkInitStruct->APB1CLKDivider);
- LL_RCC_SetAPB2Prescaler(UTILS_ClkInitStruct->APB2CLKDivider);
- }
-
- /* Decreasing the number of wait states because of lower CPU frequency */
- if (SystemCoreClock > hclk_frequency)
- {
- /* Set FLASH latency to lowest latency */
- status = LL_SetFlashLatency(hclk_frequency);
- }
-
- /* Update SystemCoreClock variable */
- if (status == SUCCESS)
- {
- LL_SetSystemCoreClock(hclk_frequency);
- }
-
- return status;
-}
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/**
- * @}
- */
-
-/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/