mirror of https://github.com/ARMmbed/mbed-os.git
				
				
				
			
							parent
							
								
									04a31f3b39
								
							
						
					
					
						commit
						32d04ead8a
					
				| 
						 | 
				
			
			@ -0,0 +1,660 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_adc.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   ADC LL module driver
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_adc.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
  #include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
  #define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (ADC1)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup ADC_LL ADC
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup ADC_LL_Private_Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Definitions of ADC hardware constraints delays */
 | 
			
		||||
/* 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.                   */
 | 
			
		||||
/*       Refer to @ref ADC_LL_EC_HW_DELAYS for description of ADC timeout     */
 | 
			
		||||
/*       values definition.                                                   */
 | 
			
		||||
/* Note: ADC timeout values are defined here in CPU cycles to be independent  */
 | 
			
		||||
/*       of device clock setting.                                             */
 | 
			
		||||
/*       In user application, ADC timeout values should be defined with       */
 | 
			
		||||
/*       temporal values, in function of device clock settings.               */
 | 
			
		||||
/*       Highest ratio CPU clock frequency vs ADC clock frequency:            */
 | 
			
		||||
/*        - ADC clock from synchronous clock with AHB prescaler 512,          */
 | 
			
		||||
/*          APB prescaler 16, ADC prescaler 4.                                */
 | 
			
		||||
/*        - ADC clock from asynchronous clock (HSI) with prescaler 1,         */
 | 
			
		||||
/*          with highest ratio CPU clock frequency vs HSI clock frequency:    */
 | 
			
		||||
/*          CPU clock frequency max 32MHz, HSI frequency 16MHz: ratio 2.      */
 | 
			
		||||
/* Unit: CPU cycles.                                                          */
 | 
			
		||||
#define ADC_CLOCK_RATIO_VS_CPU_HIGHEST          ((uint32_t) 512U * 16U * 4U)
 | 
			
		||||
#define ADC_TIMEOUT_DISABLE_CPU_CYCLES          (ADC_CLOCK_RATIO_VS_CPU_HIGHEST * 1U)
 | 
			
		||||
#define ADC_TIMEOUT_STOP_CONVERSION_CPU_CYCLES  (ADC_CLOCK_RATIO_VS_CPU_HIGHEST * 1U)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/** @addtogroup ADC_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Check of parameters for configuration of ADC hierarchical scope:           */
 | 
			
		||||
/* common to several ADC instances.                                           */
 | 
			
		||||
#define IS_LL_ADC_COMMON_CLOCK(__CLOCK__)                                      \
 | 
			
		||||
  (   ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV1)                                 \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV2)                                 \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV4)                                 \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV6)                                 \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV8)                                 \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV10)                                \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV12)                                \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV16)                                \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV32)                                \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV64)                                \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV128)                               \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC_DIV256)                               \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_ADC_CLOCK_FREQ_MODE(__CLOCK_FREQ_MODE__)                         \
 | 
			
		||||
  (   ((__CLOCK_FREQ_MODE__) == LL_ADC_CLOCK_FREQ_MODE_HIGH)                   \
 | 
			
		||||
   || ((__CLOCK_FREQ_MODE__) == LL_ADC_CLOCK_FREQ_MODE_LOW)                    \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
/* Check of parameters for configuration of ADC hierarchical scope:           */
 | 
			
		||||
/* ADC instance.                                                              */
 | 
			
		||||
#define IS_LL_ADC_CLOCK(__CLOCK__)                                             \
 | 
			
		||||
  (   ((__CLOCK__) == LL_ADC_CLOCK_SYNC_PCLK_DIV4)                             \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_SYNC_PCLK_DIV2)                             \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_SYNC_PCLK_DIV1)                             \
 | 
			
		||||
   || ((__CLOCK__) == LL_ADC_CLOCK_ASYNC)                                      \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_ADC_RESOLUTION(__RESOLUTION__)                                   \
 | 
			
		||||
  (   ((__RESOLUTION__) == LL_ADC_RESOLUTION_12B)                              \
 | 
			
		||||
   || ((__RESOLUTION__) == LL_ADC_RESOLUTION_10B)                              \
 | 
			
		||||
   || ((__RESOLUTION__) == LL_ADC_RESOLUTION_8B)                               \
 | 
			
		||||
   || ((__RESOLUTION__) == LL_ADC_RESOLUTION_6B)                               \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_ADC_DATA_ALIGN(__DATA_ALIGN__)                                   \
 | 
			
		||||
  (   ((__DATA_ALIGN__) == LL_ADC_DATA_ALIGN_RIGHT)                            \
 | 
			
		||||
   || ((__DATA_ALIGN__) == LL_ADC_DATA_ALIGN_LEFT)                             \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_ADC_LOW_POWER(__LOW_POWER__)                                     \
 | 
			
		||||
  (   ((__LOW_POWER__) == LL_ADC_LP_MODE_NONE)                                 \
 | 
			
		||||
   || ((__LOW_POWER__) == LL_ADC_LP_AUTOWAIT)                                  \
 | 
			
		||||
   || ((__LOW_POWER__) == LL_ADC_LP_AUTOPOWEROFF)                              \
 | 
			
		||||
   || ((__LOW_POWER__) == LL_ADC_LP_AUTOWAIT_AUTOPOWEROFF)                     \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
/* Check of parameters for configuration of ADC hierarchical scope:           */
 | 
			
		||||
/* ADC group regular                                                          */
 | 
			
		||||
#define IS_LL_ADC_REG_TRIG_SOURCE(__REG_TRIG_SOURCE__)                         \
 | 
			
		||||
  (   ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_SOFTWARE)                      \
 | 
			
		||||
   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM6_TRGO)                 \
 | 
			
		||||
   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM21_CH2)                 \
 | 
			
		||||
   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_TRGO)                 \
 | 
			
		||||
   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_CH4)                  \
 | 
			
		||||
   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM22_TRGO)                \
 | 
			
		||||
   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM2_CH3)                  \
 | 
			
		||||
   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_TIM3_TRGO)                 \
 | 
			
		||||
   || ((__REG_TRIG_SOURCE__) == LL_ADC_REG_TRIG_EXT_EXTI_LINE11)               \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_ADC_REG_CONTINUOUS_MODE(__REG_CONTINUOUS_MODE__)                 \
 | 
			
		||||
  (   ((__REG_CONTINUOUS_MODE__) == LL_ADC_REG_CONV_SINGLE)                    \
 | 
			
		||||
   || ((__REG_CONTINUOUS_MODE__) == LL_ADC_REG_CONV_CONTINUOUS)                \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_ADC_REG_DMA_TRANSFER(__REG_DMA_TRANSFER__)                       \
 | 
			
		||||
  (   ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_NONE)                 \
 | 
			
		||||
   || ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_LIMITED)              \
 | 
			
		||||
   || ((__REG_DMA_TRANSFER__) == LL_ADC_REG_DMA_TRANSFER_UNLIMITED)            \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_ADC_REG_OVR_DATA_BEHAVIOR(__REG_OVR_DATA_BEHAVIOR__)             \
 | 
			
		||||
  (   ((__REG_OVR_DATA_BEHAVIOR__) == LL_ADC_REG_OVR_DATA_PRESERVED)           \
 | 
			
		||||
   || ((__REG_OVR_DATA_BEHAVIOR__) == LL_ADC_REG_OVR_DATA_OVERWRITTEN)         \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_ADC_REG_SEQ_SCAN_DISCONT_MODE(__REG_SEQ_DISCONT_MODE__)          \
 | 
			
		||||
  (   ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_DISABLE)           \
 | 
			
		||||
   || ((__REG_SEQ_DISCONT_MODE__) == LL_ADC_REG_SEQ_DISCONT_1RANK)             \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup ADC_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup ADC_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize registers of all ADC instances belonging to
 | 
			
		||||
  *         the same ADC common instance to their default reset values.
 | 
			
		||||
  * @note   This function is performing a hard reset, using high level
 | 
			
		||||
  *         clock source RCC ADC reset.
 | 
			
		||||
  * @param  ADCxy_COMMON ADC common instance
 | 
			
		||||
  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: ADC common registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_ADC_CommonDeInit(ADC_Common_TypeDef *ADCxy_COMMON)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_ADC_COMMON_INSTANCE(ADCxy_COMMON));
 | 
			
		||||
  
 | 
			
		||||
  /* Force reset of ADC clock (core clock) */
 | 
			
		||||
  LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_ADC1);
 | 
			
		||||
 | 
			
		||||
  /* Release reset of ADC clock (core clock) */
 | 
			
		||||
  LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_ADC1);
 | 
			
		||||
  
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize some features of ADC common parameters
 | 
			
		||||
  *         (all ADC instances belonging to the same ADC common instance)
 | 
			
		||||
  *         and multimode (for devices with several ADC instances available).
 | 
			
		||||
  * @note   The setting of ADC common parameters is conditioned to
 | 
			
		||||
  *         ADC instances state:
 | 
			
		||||
  *         All ADC instances belonging to the same ADC common instance
 | 
			
		||||
  *         must be disabled.
 | 
			
		||||
  * @param  ADCxy_COMMON ADC common instance
 | 
			
		||||
  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_ADC_COMMON_INSTANCE() )
 | 
			
		||||
  * @param  ADC_CommonInitStruct Pointer to a @ref LL_ADC_CommonInitTypeDef structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: ADC common registers are initialized
 | 
			
		||||
  *          - ERROR: ADC common registers are not initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_ADC_CommonInit(ADC_Common_TypeDef *ADCxy_COMMON, LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
  
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_ADC_COMMON_INSTANCE(ADCxy_COMMON));
 | 
			
		||||
  assert_param(IS_LL_ADC_COMMON_CLOCK(ADC_CommonInitStruct->CommonClock));
 | 
			
		||||
  
 | 
			
		||||
  /* Note: Hardware constraint (refer to description of functions             */
 | 
			
		||||
  /*       "LL_ADC_SetCommonXXX()":                                           */
 | 
			
		||||
  /*       On this STM32 serie, setting of these features is conditioned to   */
 | 
			
		||||
  /*       ADC state:                                                         */
 | 
			
		||||
  /*       All ADC instances of the ADC common group must be disabled.        */
 | 
			
		||||
  if(__LL_ADC_IS_ENABLED_ALL_COMMON_INSTANCE(ADCxy_COMMON) == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    /* Configuration of ADC hierarchical scope:                               */
 | 
			
		||||
    /*  - common to several ADC                                               */
 | 
			
		||||
    /*    (all ADC instances belonging to the same ADC common instance)       */
 | 
			
		||||
    /*    - Set ADC clock (conversion clock)                                  */
 | 
			
		||||
    LL_ADC_SetCommonClock(ADCxy_COMMON, ADC_CommonInitStruct->CommonClock);
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* Initialization error: One or several ADC instances belonging to        */
 | 
			
		||||
    /* the same ADC common instance are not disabled.                         */
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_ADC_CommonInitTypeDef field to default value.
 | 
			
		||||
  * @param  ADC_CommonInitStruct Pointer to a @ref LL_ADC_CommonInitTypeDef structure
 | 
			
		||||
  *                              whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_ADC_CommonStructInit(LL_ADC_CommonInitTypeDef *ADC_CommonInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set ADC_CommonInitStruct fields to default values */
 | 
			
		||||
  /* Set fields of ADC common */
 | 
			
		||||
  /* (all ADC instances belonging to the same ADC common instance) */
 | 
			
		||||
  ADC_CommonInitStruct->CommonClock = LL_ADC_CLOCK_ASYNC_DIV2;
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize registers of the selected ADC instance
 | 
			
		||||
  *         to their default reset values.
 | 
			
		||||
  * @note   To reset all ADC instances quickly (perform a hard reset),
 | 
			
		||||
  *         use function @ref LL_ADC_CommonDeInit().
 | 
			
		||||
  * @note   If this functions returns error status, it means that ADC instance
 | 
			
		||||
  *         is in an unknown state.
 | 
			
		||||
  *         In this case, perform a hard reset using high level
 | 
			
		||||
  *         clock source RCC ADC reset.
 | 
			
		||||
  *         Refer to function @ref LL_ADC_CommonDeInit().
 | 
			
		||||
  * @param  ADCx ADC instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: ADC registers are de-initialized
 | 
			
		||||
  *          - ERROR: ADC registers are not de-initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_ADC_DeInit(ADC_TypeDef *ADCx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
  
 | 
			
		||||
  __IO uint32_t timeout_cpu_cycles = 0U;
 | 
			
		||||
  
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
 | 
			
		||||
  
 | 
			
		||||
  /* Disable ADC instance if not already disabled.                            */
 | 
			
		||||
  if(LL_ADC_IsEnabled(ADCx) == 1U)
 | 
			
		||||
  {
 | 
			
		||||
    /* Set ADC group regular trigger source to SW start to ensure to not      */
 | 
			
		||||
    /* have an external trigger event occurring during the conversion stop    */
 | 
			
		||||
    /* ADC disable process.                                                   */
 | 
			
		||||
    LL_ADC_REG_SetTriggerSource(ADCx, LL_ADC_REG_TRIG_SOFTWARE);
 | 
			
		||||
    
 | 
			
		||||
    /* Stop potential ADC conversion on going on ADC group regular.           */
 | 
			
		||||
    if(LL_ADC_REG_IsConversionOngoing(ADCx) != 0U)
 | 
			
		||||
    {
 | 
			
		||||
      if(LL_ADC_REG_IsStopConversionOngoing(ADCx) == 0U)
 | 
			
		||||
      {
 | 
			
		||||
        LL_ADC_REG_StopConversion(ADCx);
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /* Wait for ADC conversions are effectively stopped                       */
 | 
			
		||||
    timeout_cpu_cycles = ADC_TIMEOUT_STOP_CONVERSION_CPU_CYCLES;
 | 
			
		||||
    while (LL_ADC_REG_IsStopConversionOngoing(ADCx) == 1U)
 | 
			
		||||
    {
 | 
			
		||||
      if(timeout_cpu_cycles-- == 0U)
 | 
			
		||||
      {
 | 
			
		||||
        /* Time-out error */
 | 
			
		||||
        status = ERROR;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    /* Disable the ADC instance */
 | 
			
		||||
    LL_ADC_Disable(ADCx);
 | 
			
		||||
    
 | 
			
		||||
    /* Wait for ADC instance is effectively disabled */
 | 
			
		||||
    timeout_cpu_cycles = ADC_TIMEOUT_DISABLE_CPU_CYCLES;
 | 
			
		||||
    while (LL_ADC_IsDisableOngoing(ADCx) == 1U)
 | 
			
		||||
    {
 | 
			
		||||
      if(timeout_cpu_cycles-- == 0U)
 | 
			
		||||
      {
 | 
			
		||||
        /* Time-out error */
 | 
			
		||||
        status = ERROR;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  /* Check whether ADC state is compliant with expected state */
 | 
			
		||||
  if(READ_BIT(ADCx->CR,
 | 
			
		||||
              (  ADC_CR_ADSTP | ADC_CR_ADSTART
 | 
			
		||||
               | ADC_CR_ADDIS | ADC_CR_ADEN   )
 | 
			
		||||
             )
 | 
			
		||||
     == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    /* ========== Reset ADC registers ========== */
 | 
			
		||||
    /* Reset register IER */
 | 
			
		||||
    CLEAR_BIT(ADCx->IER,
 | 
			
		||||
              (  LL_ADC_IT_ADRDY
 | 
			
		||||
               | LL_ADC_IT_EOC
 | 
			
		||||
               | LL_ADC_IT_EOS
 | 
			
		||||
               | LL_ADC_IT_OVR
 | 
			
		||||
               | LL_ADC_IT_EOSMP
 | 
			
		||||
               | LL_ADC_IT_AWD1 )
 | 
			
		||||
             );
 | 
			
		||||
    
 | 
			
		||||
    /* Reset register ISR */
 | 
			
		||||
    SET_BIT(ADCx->ISR,
 | 
			
		||||
            (  LL_ADC_FLAG_ADRDY
 | 
			
		||||
             | LL_ADC_FLAG_EOC
 | 
			
		||||
             | LL_ADC_FLAG_EOS
 | 
			
		||||
             | LL_ADC_FLAG_OVR
 | 
			
		||||
             | LL_ADC_FLAG_EOSMP
 | 
			
		||||
             | LL_ADC_FLAG_AWD1 )
 | 
			
		||||
           );
 | 
			
		||||
    
 | 
			
		||||
    /* Reset register CR */
 | 
			
		||||
    /* Bits ADC_CR_ADCAL, ADC_CR_ADSTP, ADC_CR_ADSTART are in access mode     */
 | 
			
		||||
    /* "read-set": no direct reset applicable.                                */
 | 
			
		||||
    CLEAR_BIT(ADCx->CR, ADC_CR_ADVREGEN);
 | 
			
		||||
    
 | 
			
		||||
    /* Reset register CFGR1 */
 | 
			
		||||
    CLEAR_BIT(ADCx->CFGR1,
 | 
			
		||||
              (  ADC_CFGR1_AWDCH   | ADC_CFGR1_AWDEN  | ADC_CFGR1_AWDSGL | ADC_CFGR1_DISCEN
 | 
			
		||||
               | ADC_CFGR1_AUTOFF  | ADC_CFGR1_WAIT   | ADC_CFGR1_CONT   | ADC_CFGR1_OVRMOD
 | 
			
		||||
               | ADC_CFGR1_EXTEN   | ADC_CFGR1_EXTSEL | ADC_CFGR1_ALIGN  | ADC_CFGR1_RES
 | 
			
		||||
               | ADC_CFGR1_SCANDIR | ADC_CFGR1_DMACFG | ADC_CFGR1_DMAEN                    )
 | 
			
		||||
             );
 | 
			
		||||
    
 | 
			
		||||
    /* Reset register CFGR2 */
 | 
			
		||||
    /* Note: Update of ADC clock mode is conditioned to ADC state disabled:   */
 | 
			
		||||
    /*       already done above.                                              */
 | 
			
		||||
    CLEAR_BIT(ADCx->CFGR2,
 | 
			
		||||
              (  ADC_CFGR2_CKMODE
 | 
			
		||||
               | ADC_CFGR2_TOVS   | ADC_CFGR2_OVSS  | ADC_CFGR2_OVSR
 | 
			
		||||
               | ADC_CFGR2_OVSE   | ADC_CFGR2_CKMODE                )
 | 
			
		||||
             );
 | 
			
		||||
    
 | 
			
		||||
    /* Reset register SMPR */
 | 
			
		||||
    CLEAR_BIT(ADCx->SMPR, ADC_SMPR_SMP);
 | 
			
		||||
 | 
			
		||||
    /* Reset register TR */
 | 
			
		||||
    MODIFY_REG(ADCx->TR, ADC_TR_HT | ADC_TR_LT, ADC_TR_HT);
 | 
			
		||||
    
 | 
			
		||||
    /* Reset register CHSELR */
 | 
			
		||||
#if defined(ADC_CCR_VLCDEN)
 | 
			
		||||
    CLEAR_BIT(ADCx->CHSELR,
 | 
			
		||||
              (  ADC_CHSELR_CHSEL18 | ADC_CHSELR_CHSEL17 | ADC_CHSELR_CHSEL16
 | 
			
		||||
               | ADC_CHSELR_CHSEL15 | ADC_CHSELR_CHSEL14 | ADC_CHSELR_CHSEL13 | ADC_CHSELR_CHSEL12
 | 
			
		||||
               | ADC_CHSELR_CHSEL11 | ADC_CHSELR_CHSEL10 | ADC_CHSELR_CHSEL9  | ADC_CHSELR_CHSEL8
 | 
			
		||||
               | ADC_CHSELR_CHSEL7  | ADC_CHSELR_CHSEL6  | ADC_CHSELR_CHSEL5  | ADC_CHSELR_CHSEL4
 | 
			
		||||
               | ADC_CHSELR_CHSEL3  | ADC_CHSELR_CHSEL2  | ADC_CHSELR_CHSEL1  | ADC_CHSELR_CHSEL0 )
 | 
			
		||||
             );
 | 
			
		||||
#else
 | 
			
		||||
    CLEAR_BIT(ADCx->CHSELR,
 | 
			
		||||
              (  ADC_CHSELR_CHSEL18 | ADC_CHSELR_CHSEL17
 | 
			
		||||
               | ADC_CHSELR_CHSEL15 | ADC_CHSELR_CHSEL14 | ADC_CHSELR_CHSEL13 | ADC_CHSELR_CHSEL12
 | 
			
		||||
               | ADC_CHSELR_CHSEL11 | ADC_CHSELR_CHSEL10 | ADC_CHSELR_CHSEL9  | ADC_CHSELR_CHSEL8
 | 
			
		||||
               | ADC_CHSELR_CHSEL7  | ADC_CHSELR_CHSEL6  | ADC_CHSELR_CHSEL5  | ADC_CHSELR_CHSEL4
 | 
			
		||||
               | ADC_CHSELR_CHSEL3  | ADC_CHSELR_CHSEL2  | ADC_CHSELR_CHSEL1  | ADC_CHSELR_CHSEL0 )
 | 
			
		||||
             );
 | 
			
		||||
#endif
 | 
			
		||||
    
 | 
			
		||||
    /* Reset register DR */
 | 
			
		||||
    /* bits in access mode read only, no direct reset applicable */
 | 
			
		||||
    
 | 
			
		||||
    /* Reset register CALFACT */
 | 
			
		||||
    CLEAR_BIT(ADCx->CALFACT, ADC_CALFACT_CALFACT);
 | 
			
		||||
    
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* ADC instance is in an unknown state */
 | 
			
		||||
    /* Need to performing a hard reset of ADC instance, using high level      */
 | 
			
		||||
    /* clock source RCC ADC reset.                                            */
 | 
			
		||||
    /* Caution: On this STM32 serie, if several ADC instances are available   */
 | 
			
		||||
    /*          on the selected device, RCC ADC reset will reset              */
 | 
			
		||||
    /*          all ADC instances belonging to the common ADC instance.       */
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize some features of ADC instance.
 | 
			
		||||
  * @note   These parameters have an impact on ADC scope: ADC instance.
 | 
			
		||||
  *         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.
 | 
			
		||||
  * @note   After using this function, some other features must be configured
 | 
			
		||||
  *         using LL unitary functions.
 | 
			
		||||
  *         The minimum configuration remaining to be done is:
 | 
			
		||||
  *          - Set ADC group regular sequencer:
 | 
			
		||||
  *            map channel on rank corresponding to channel number.
 | 
			
		||||
  *            Refer to function @ref LL_ADC_REG_SetSequencerChannels();
 | 
			
		||||
  *          - Set ADC channel sampling time
 | 
			
		||||
  *            Refer to function LL_ADC_SetChannelSamplingTime();
 | 
			
		||||
  * @param  ADCx ADC instance
 | 
			
		||||
  * @param  ADC_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: ADC registers are initialized
 | 
			
		||||
  *          - ERROR: ADC registers are not initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_ADC_Init(ADC_TypeDef *ADCx, LL_ADC_InitTypeDef *ADC_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
  
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
 | 
			
		||||
  
 | 
			
		||||
  assert_param(IS_LL_ADC_CLOCK(ADC_InitStruct->Clock));
 | 
			
		||||
  assert_param(IS_LL_ADC_RESOLUTION(ADC_InitStruct->Resolution));
 | 
			
		||||
  assert_param(IS_LL_ADC_DATA_ALIGN(ADC_InitStruct->DataAlignment));
 | 
			
		||||
  assert_param(IS_LL_ADC_LOW_POWER(ADC_InitStruct->LowPowerMode));
 | 
			
		||||
  
 | 
			
		||||
  /* Note: Hardware constraint (refer to description of this function):       */
 | 
			
		||||
  /*       ADC instance must be disabled.                                     */
 | 
			
		||||
  if(LL_ADC_IsEnabled(ADCx) == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    /* Configuration of ADC hierarchical scope:                               */
 | 
			
		||||
    /*  - ADC instance                                                        */
 | 
			
		||||
    /*    - Set ADC data resolution                                           */
 | 
			
		||||
    /*    - Set ADC conversion data alignment                                 */
 | 
			
		||||
    /*    - Set ADC low power mode                                            */
 | 
			
		||||
    MODIFY_REG(ADCx->CFGR1,
 | 
			
		||||
                 ADC_CFGR1_RES
 | 
			
		||||
               | ADC_CFGR1_ALIGN
 | 
			
		||||
               | ADC_CFGR1_WAIT
 | 
			
		||||
               | ADC_CFGR1_AUTOFF
 | 
			
		||||
              ,
 | 
			
		||||
                 ADC_InitStruct->Resolution
 | 
			
		||||
               | ADC_InitStruct->DataAlignment
 | 
			
		||||
               | ADC_InitStruct->LowPowerMode
 | 
			
		||||
              );
 | 
			
		||||
    
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* Initialization error: ADC instance is not disabled. */
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_ADC_InitTypeDef field to default value.
 | 
			
		||||
  * @param  ADC_InitStruct Pointer to a @ref LL_ADC_InitTypeDef structure
 | 
			
		||||
  *                        whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_ADC_StructInit(LL_ADC_InitTypeDef *ADC_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set ADC_InitStruct fields to default values */
 | 
			
		||||
  /* Set fields of ADC instance */
 | 
			
		||||
  ADC_InitStruct->Clock         = LL_ADC_CLOCK_SYNC_PCLK_DIV2;
 | 
			
		||||
  ADC_InitStruct->Resolution    = LL_ADC_RESOLUTION_12B;
 | 
			
		||||
  ADC_InitStruct->DataAlignment = LL_ADC_DATA_ALIGN_RIGHT;
 | 
			
		||||
  ADC_InitStruct->LowPowerMode  = LL_ADC_LP_MODE_NONE;
 | 
			
		||||
  
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize 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_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.
 | 
			
		||||
  * @note   After using this function, other features must be configured
 | 
			
		||||
  *         using LL unitary functions.
 | 
			
		||||
  *         The minimum configuration remaining to be done is:
 | 
			
		||||
  *          - Set ADC group regular sequencer:
 | 
			
		||||
  *            map channel on rank corresponding to channel number.
 | 
			
		||||
  *            Refer to function @ref LL_ADC_REG_SetSequencerChannels();
 | 
			
		||||
  *          - Set ADC channel sampling time
 | 
			
		||||
  *            Refer to function LL_ADC_SetChannelSamplingTime();
 | 
			
		||||
  * @param  ADCx ADC instance
 | 
			
		||||
  * @param  ADC_REG_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: ADC registers are initialized
 | 
			
		||||
  *          - ERROR: ADC registers are not initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_ADC_REG_Init(ADC_TypeDef *ADCx, LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
  
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_ADC_ALL_INSTANCE(ADCx));
 | 
			
		||||
  assert_param(IS_LL_ADC_REG_TRIG_SOURCE(ADC_REG_InitStruct->TriggerSource));
 | 
			
		||||
  assert_param(IS_LL_ADC_REG_SEQ_SCAN_DISCONT_MODE(ADC_REG_InitStruct->SequencerDiscont));
 | 
			
		||||
  assert_param(IS_LL_ADC_REG_CONTINUOUS_MODE(ADC_REG_InitStruct->ContinuousMode));
 | 
			
		||||
  assert_param(IS_LL_ADC_REG_DMA_TRANSFER(ADC_REG_InitStruct->DMATransfer));
 | 
			
		||||
  assert_param(IS_LL_ADC_REG_OVR_DATA_BEHAVIOR(ADC_REG_InitStruct->Overrun));
 | 
			
		||||
  
 | 
			
		||||
  /* Note: Hardware constraint (refer to description of this function):       */
 | 
			
		||||
  /*       ADC instance must be disabled.                                     */
 | 
			
		||||
  if(LL_ADC_IsEnabled(ADCx) == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    /* Configuration of ADC hierarchical scope:                               */
 | 
			
		||||
    /*  - ADC group regular                                                   */
 | 
			
		||||
    /*    - Set ADC group regular trigger source                              */
 | 
			
		||||
    /*    - Set ADC group regular sequencer discontinuous mode                */
 | 
			
		||||
    /*    - Set ADC group regular continuous mode                             */
 | 
			
		||||
    /*    - Set ADC group regular conversion data transfer: no transfer or    */
 | 
			
		||||
    /*      transfer by DMA, and DMA requests mode                            */
 | 
			
		||||
    /*    - Set ADC group regular overrun behavior                            */
 | 
			
		||||
    /* Note: On this STM32 serie, ADC trigger edge is set to value 0x0 by     */
 | 
			
		||||
    /*       setting of trigger source to SW start.                           */
 | 
			
		||||
    MODIFY_REG(ADCx->CFGR1,
 | 
			
		||||
                 ADC_CFGR1_EXTSEL
 | 
			
		||||
               | ADC_CFGR1_EXTEN
 | 
			
		||||
               | ADC_CFGR1_DISCEN
 | 
			
		||||
               | ADC_CFGR1_CONT
 | 
			
		||||
               | ADC_CFGR1_DMAEN
 | 
			
		||||
               | ADC_CFGR1_DMACFG
 | 
			
		||||
               | ADC_CFGR1_OVRMOD
 | 
			
		||||
              ,
 | 
			
		||||
                 ADC_REG_InitStruct->TriggerSource
 | 
			
		||||
               | ADC_REG_InitStruct->SequencerDiscont
 | 
			
		||||
               | ADC_REG_InitStruct->ContinuousMode
 | 
			
		||||
               | ADC_REG_InitStruct->DMATransfer
 | 
			
		||||
               | ADC_REG_InitStruct->Overrun
 | 
			
		||||
              );
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* Initialization error: ADC instance is not disabled. */
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_ADC_REG_InitTypeDef field to default value.
 | 
			
		||||
  * @param  ADC_REG_InitStruct Pointer to a @ref LL_ADC_REG_InitTypeDef structure
 | 
			
		||||
  *                            whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_ADC_REG_StructInit(LL_ADC_REG_InitTypeDef *ADC_REG_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set ADC_REG_InitStruct fields to default values */
 | 
			
		||||
  /* Set fields of ADC group regular */
 | 
			
		||||
  /* Note: On this STM32 serie, ADC trigger edge is set to value 0x0 by       */
 | 
			
		||||
  /*       setting of trigger source to SW start.                             */
 | 
			
		||||
  ADC_REG_InitStruct->TriggerSource    = LL_ADC_REG_TRIG_SOFTWARE;
 | 
			
		||||
  ADC_REG_InitStruct->SequencerDiscont = LL_ADC_REG_SEQ_DISCONT_DISABLE;
 | 
			
		||||
  ADC_REG_InitStruct->ContinuousMode   = LL_ADC_REG_CONV_SINGLE;
 | 
			
		||||
  ADC_REG_InitStruct->DMATransfer      = LL_ADC_REG_DMA_TRANSFER_NONE;
 | 
			
		||||
  ADC_REG_InitStruct->Overrun          = LL_ADC_REG_OVR_DATA_OVERWRITTEN;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* ADC1 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,325 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_comp.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   COMP LL module driver
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_comp.h"
 | 
			
		||||
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
  #include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
  #define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (COMP1) || defined (COMP2)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup COMP_LL COMP
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/** @addtogroup COMP_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Check of parameters for configuration of COMP hierarchical scope:          */
 | 
			
		||||
/* COMP instance.                                                             */
 | 
			
		||||
 | 
			
		||||
#define IS_LL_COMP_POWER_MODE(__POWER_MODE__)                                  \
 | 
			
		||||
  (   ((__POWER_MODE__) == LL_COMP_POWERMODE_MEDIUMSPEED)                      \
 | 
			
		||||
   || ((__POWER_MODE__) == LL_COMP_POWERMODE_ULTRALOWPOWER)                    \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#if defined (STM32L011xx) || defined (STM32L021xx)
 | 
			
		||||
#define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__)               \
 | 
			
		||||
  (((__COMP_INSTANCE__) == COMP1)                                              \
 | 
			
		||||
    ? (                                                                        \
 | 
			
		||||
       (__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1                              \
 | 
			
		||||
      )                                                                        \
 | 
			
		||||
      :                                                                        \
 | 
			
		||||
      (                                                                        \
 | 
			
		||||
          ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1)                         \
 | 
			
		||||
       || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2)                         \
 | 
			
		||||
       || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO3)                         \
 | 
			
		||||
       || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO4)                         \
 | 
			
		||||
       || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO5)                         \
 | 
			
		||||
       || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO6)                         \
 | 
			
		||||
      )                                                                        \
 | 
			
		||||
  )
 | 
			
		||||
#else
 | 
			
		||||
#define IS_LL_COMP_INPUT_PLUS(__COMP_INSTANCE__, __INPUT_PLUS__)               \
 | 
			
		||||
  (((__COMP_INSTANCE__) == COMP1)                                              \
 | 
			
		||||
    ? (                                                                        \
 | 
			
		||||
       (__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1                              \
 | 
			
		||||
      )                                                                        \
 | 
			
		||||
      :                                                                        \
 | 
			
		||||
      (                                                                        \
 | 
			
		||||
          ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO1)                         \
 | 
			
		||||
       || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO2)                         \
 | 
			
		||||
       || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO3)                         \
 | 
			
		||||
       || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO4)                         \
 | 
			
		||||
       || ((__INPUT_PLUS__) == LL_COMP_INPUT_PLUS_IO5)                         \
 | 
			
		||||
      )                                                                        \
 | 
			
		||||
  )
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Note: On this STM32 serie, comparator input minus parameters are           */
 | 
			
		||||
/*       the different depending on COMP instances.                           */
 | 
			
		||||
#define IS_LL_COMP_INPUT_MINUS(__COMP_INSTANCE__, __INPUT_MINUS__)             \
 | 
			
		||||
  (((__COMP_INSTANCE__) == COMP1)                                              \
 | 
			
		||||
    ? (                                                                        \
 | 
			
		||||
          ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT)                   \
 | 
			
		||||
       || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH1)                  \
 | 
			
		||||
       || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH2)                  \
 | 
			
		||||
       || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO1)                       \
 | 
			
		||||
      )                                                                        \
 | 
			
		||||
      :                                                                        \
 | 
			
		||||
      (                                                                        \
 | 
			
		||||
          ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_4VREFINT)                \
 | 
			
		||||
       || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_1_2VREFINT)                \
 | 
			
		||||
       || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_3_4VREFINT)                \
 | 
			
		||||
       || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_VREFINT)                   \
 | 
			
		||||
       || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH1)                  \
 | 
			
		||||
       || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_DAC1_CH2)                  \
 | 
			
		||||
       || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO1)                       \
 | 
			
		||||
       || ((__INPUT_MINUS__) == LL_COMP_INPUT_MINUS_IO2)                       \
 | 
			
		||||
      )                                                                        \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_COMP_OUTPUT_POLARITY(__POLARITY__)                               \
 | 
			
		||||
  (   ((__POLARITY__) == LL_COMP_OUTPUTPOL_NONINVERTED)                        \
 | 
			
		||||
   || ((__POLARITY__) == LL_COMP_OUTPUTPOL_INVERTED)                           \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup COMP_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup COMP_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize registers of the selected COMP instance
 | 
			
		||||
  *         to their default reset values.
 | 
			
		||||
  * @note   If comparator is locked, de-initialization by software is
 | 
			
		||||
  *         not possible.
 | 
			
		||||
  *         The only way to unlock the comparator is a device hardware reset.
 | 
			
		||||
  * @param  COMPx COMP instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: COMP registers are de-initialized
 | 
			
		||||
  *          - ERROR: COMP registers are not de-initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
  
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_COMP_ALL_INSTANCE(COMPx));
 | 
			
		||||
  
 | 
			
		||||
  /* Note: Hardware constraint (refer to description of this function):       */
 | 
			
		||||
  /*       COMP instance must not be locked.                                  */
 | 
			
		||||
  if(LL_COMP_IsLocked(COMPx) == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    if(COMPx == COMP1)
 | 
			
		||||
    {
 | 
			
		||||
      CLEAR_BIT(COMPx->CSR,
 | 
			
		||||
                (  COMP_CSR_COMP1EN
 | 
			
		||||
                 | COMP_CSR_COMP1INNSEL
 | 
			
		||||
                 | COMP_CSR_COMP1WM
 | 
			
		||||
                 | COMP_CSR_COMP1LPTIM1IN1
 | 
			
		||||
                 | COMP_CSR_COMP1POLARITY
 | 
			
		||||
                 | COMP_CSR_COMP1LOCK
 | 
			
		||||
                ) 
 | 
			
		||||
               );
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      CLEAR_BIT(COMPx->CSR,
 | 
			
		||||
                (  COMP_CSR_COMP2EN
 | 
			
		||||
                 | COMP_CSR_COMP2SPEED
 | 
			
		||||
                 | COMP_CSR_COMP2INNSEL
 | 
			
		||||
                 | COMP_CSR_COMP2INPSEL
 | 
			
		||||
                 | COMP_CSR_COMP2LPTIM1IN2
 | 
			
		||||
                 | COMP_CSR_COMP2LPTIM1IN1
 | 
			
		||||
                 | COMP_CSR_COMP2POLARITY
 | 
			
		||||
                 | COMP_CSR_COMP2LOCK
 | 
			
		||||
                ) 
 | 
			
		||||
               );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* Comparator instance is locked: de-initialization by software is         */
 | 
			
		||||
    /* not possible.                                                           */
 | 
			
		||||
    /* The only way to unlock the comparator is a device hardware reset.       */
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize some features of COMP instance.
 | 
			
		||||
  * @note   This function configures features of the selected COMP instance.
 | 
			
		||||
  *         Some features are also available at scope COMP common instance
 | 
			
		||||
  *         (common to several COMP instances).
 | 
			
		||||
  *         Refer to functions having argument "COMPxy_COMMON" as parameter.
 | 
			
		||||
  * @param  COMPx COMP instance
 | 
			
		||||
  * @param  COMP_InitStruct Pointer to a @ref LL_COMP_InitTypeDef structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: COMP registers are initialized
 | 
			
		||||
  *          - ERROR: COMP registers are not initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
  
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_COMP_ALL_INSTANCE(COMPx));
 | 
			
		||||
  if(COMPx == COMP2)
 | 
			
		||||
  {
 | 
			
		||||
    assert_param(IS_LL_COMP_POWER_MODE(COMP_InitStruct->PowerMode));
 | 
			
		||||
    assert_param(IS_LL_COMP_INPUT_PLUS(COMPx, COMP_InitStruct->InputPlus));
 | 
			
		||||
  }
 | 
			
		||||
  assert_param(IS_LL_COMP_INPUT_MINUS(COMPx, COMP_InitStruct->InputMinus));
 | 
			
		||||
  assert_param(IS_LL_COMP_OUTPUT_POLARITY(COMP_InitStruct->OutputPolarity));
 | 
			
		||||
  
 | 
			
		||||
  /* Note: Hardware constraint (refer to description of this function)        */
 | 
			
		||||
  /*       COMP instance must not be locked.                                  */
 | 
			
		||||
  if(LL_COMP_IsLocked(COMPx) == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    /* Configuration of comparator instance :                                 */
 | 
			
		||||
    /*  - PowerMode                                                           */
 | 
			
		||||
    /*  - InputPlus                                                           */
 | 
			
		||||
    /*  - InputMinus                                                          */
 | 
			
		||||
    /*  - OutputPolarity                                                      */
 | 
			
		||||
    /* Note: Connection switch is applicable only to COMP instance COMP1,     */
 | 
			
		||||
    /*       therefore is COMP2 is selected the equivalent bit is             */
 | 
			
		||||
    /*       kept unmodified.                                                 */
 | 
			
		||||
    if(COMPx == COMP1)
 | 
			
		||||
    {
 | 
			
		||||
      MODIFY_REG(COMPx->CSR,
 | 
			
		||||
                 ( COMP_CSR_COMP1INNSEL
 | 
			
		||||
                  | COMP_CSR_COMP1POLARITY
 | 
			
		||||
                 ) 
 | 
			
		||||
                ,
 | 
			
		||||
                 (  COMP_InitStruct->InputMinus
 | 
			
		||||
                  | COMP_InitStruct->OutputPolarity
 | 
			
		||||
                 ) 
 | 
			
		||||
                );
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      MODIFY_REG(COMPx->CSR,
 | 
			
		||||
                 (  COMP_CSR_COMP2SPEED       
 | 
			
		||||
                  | COMP_CSR_COMP2INPSEL      
 | 
			
		||||
                  | COMP_CSR_COMP2INNSEL      
 | 
			
		||||
                  | COMP_CSR_COMP2POLARITY
 | 
			
		||||
                 ) 
 | 
			
		||||
                ,
 | 
			
		||||
                 (  COMP_InitStruct->PowerMode
 | 
			
		||||
                  | COMP_InitStruct->InputPlus
 | 
			
		||||
                  | COMP_InitStruct->InputMinus
 | 
			
		||||
                  | COMP_InitStruct->OutputPolarity
 | 
			
		||||
                 ) 
 | 
			
		||||
                );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* Initialization error: COMP instance is locked.                         */
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Set each @ref LL_COMP_InitTypeDef field to default value.
 | 
			
		||||
  * @param COMP_InitStruct: pointer to a @ref LL_COMP_InitTypeDef structure
 | 
			
		||||
  *                         whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set COMP_InitStruct fields to default values */
 | 
			
		||||
  COMP_InitStruct->PowerMode            = LL_COMP_POWERMODE_MEDIUMSPEED;
 | 
			
		||||
  COMP_InitStruct->InputPlus            = LL_COMP_INPUT_PLUS_IO1;
 | 
			
		||||
  COMP_InitStruct->InputMinus           = LL_COMP_INPUT_MINUS_VREFINT;
 | 
			
		||||
  COMP_InitStruct->OutputPolarity       = LL_COMP_OUTPUTPOL_NONINVERTED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* COMP1 || COMP2 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,723 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_comp.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   Header file of COMP LL module.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32L0xx_LL_COMP_H
 | 
			
		||||
#define __STM32L0xx_LL_COMP_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (COMP1) || defined (COMP2)
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL COMP
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @defgroup COMP_LL_Private_Constants COMP Private Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* COMP registers bits positions */
 | 
			
		||||
#define LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS ((uint32_t)30U) /* Value equivalent to POSITION_VAL(COMP_CSR_COMP1VALUE) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
/** @defgroup COMP_LL_ES_INIT COMP Exported Init structure
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Structure definition of some features of COMP instance.
 | 
			
		||||
  */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint32_t PowerMode;                   /*!< Set comparator operating mode to adjust power and speed.
 | 
			
		||||
                                             This parameter can be a value of @ref COMP_LL_EC_POWERMODE
 | 
			
		||||
                                             
 | 
			
		||||
                                             This feature can be modified afterwards using unitary function @ref LL_COMP_SetPowerMode(). */
 | 
			
		||||
 | 
			
		||||
  uint32_t InputPlus;                   /*!< Set comparator input plus (non-inverting input).
 | 
			
		||||
                                             This parameter can be a value of @ref COMP_LL_EC_INPUT_PLUS
 | 
			
		||||
                                             
 | 
			
		||||
                                             This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputPlus(). */
 | 
			
		||||
 | 
			
		||||
  uint32_t InputMinus;                  /*!< Set comparator input minus (inverting input).
 | 
			
		||||
                                             This parameter can be a value of @ref COMP_LL_EC_INPUT_MINUS
 | 
			
		||||
                                             
 | 
			
		||||
                                             This feature can be modified afterwards using unitary function @ref LL_COMP_SetInputMinus(). */
 | 
			
		||||
 | 
			
		||||
  uint32_t OutputPolarity;              /*!< Set comparator output polarity.
 | 
			
		||||
                                             This parameter can be a value of @ref COMP_LL_EC_OUTPUT_POLARITY
 | 
			
		||||
                                             
 | 
			
		||||
                                             This feature can be modified afterwards using unitary function @ref LL_COMP_SetOutputPolarity(). */
 | 
			
		||||
 | 
			
		||||
} LL_COMP_InitTypeDef;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup COMP_LL_Exported_Constants COMP Exported Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EC_COMMON_WINDOWMODE Comparator common modes - Window mode
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_COMP_WINDOWMODE_DISABLE                 ((uint32_t)0x00000000U) /*!< Window mode disable: Comparators 1 and 2 are independent */
 | 
			
		||||
#define LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON (COMP_CSR_COMP1WM)      /*!< Window mode enable: Comparators instances pair COMP1 and COMP2 have their input plus connected together. The common input is COMP1 input plus (COMP2 input plus is no more accessible). */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EC_POWERMODE Comparator modes - Power mode
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_COMP_POWERMODE_ULTRALOWPOWER   ((uint32_t)0x00000000U)     /*!< COMP power mode to low speed (specific to COMP instance: COMP2) */
 | 
			
		||||
#define LL_COMP_POWERMODE_MEDIUMSPEED     (COMP_CSR_COMP2SPEED)       /*!< COMP power mode to fast speed (specific to COMP instance: COMP2) */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EC_INPUT_PLUS Comparator inputs - Input plus (input non-inverting) selection
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_COMP_INPUT_PLUS_IO1          ((uint32_t)0x00000000U)                            /*!< Comparator input plus connected to IO1 (pin PA1 for COMP1, pin PA3 for COMP2) */
 | 
			
		||||
#define LL_COMP_INPUT_PLUS_IO2          (COMP_CSR_COMP2INPSEL_0)                           /*!< Comparator input plus connected to IO2 (pin PB4 for COMP2) (specific to COMP instance: COMP2) */
 | 
			
		||||
#define LL_COMP_INPUT_PLUS_IO3          (COMP_CSR_COMP2INPSEL_1)                           /*!< Comparator input plus connected to IO3 (pin PA5 for COMP2) (specific to COMP instance: COMP2) */
 | 
			
		||||
#define LL_COMP_INPUT_PLUS_IO4          (COMP_CSR_COMP2INPSEL_0 | COMP_CSR_COMP2INPSEL_1)  /*!< Comparator input plus connected to IO4 (pin PB6 for COMP2) (specific to COMP instance: COMP2) */
 | 
			
		||||
#define LL_COMP_INPUT_PLUS_IO5          (COMP_CSR_COMP2INPSEL_2)                           /*!< Comparator input plus connected to IO5 (pin PB7 for COMP2) (specific to COMP instance: COMP2) */
 | 
			
		||||
#if defined (STM32L011xx) || defined (STM32L021xx)
 | 
			
		||||
#define LL_COMP_INPUT_PLUS_IO6          (COMP_CSR_COMP2INPSEL_2 | COMP_CSR_COMP2INPSEL_0)  /*!< Comparator input plus connected to IO6 (pin PA7 for COMP2) (specific to COMP instance: COMP2) (Available only on devices STM32L0 category 1) */
 | 
			
		||||
#endif
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EC_INPUT_MINUS Comparator inputs - Input minus (input inverting) selection
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_COMP_INPUT_MINUS_1_4VREFINT  (COMP_CSR_COMP2INNSEL_2                                                  ) /*!< Comparator input minus connected to 1/4 VrefInt (specifity of COMP2 related to path to enable via SYSCFG: refer to comment in function @ref LL_COMP_SetInputMinus() ) (specific to COMP instance: COMP2) */
 | 
			
		||||
#define LL_COMP_INPUT_MINUS_1_2VREFINT  (COMP_CSR_COMP2INNSEL_2 |                          COMP_CSR_COMP2INNSEL_0) /*!< Comparator input minus connected to 1/2 VrefInt (specifity of COMP2 related to path to enable via SYSCFG: refer to comment in function @ref LL_COMP_SetInputMinus() ) (specific to COMP instance: COMP2) */
 | 
			
		||||
#define LL_COMP_INPUT_MINUS_3_4VREFINT  (COMP_CSR_COMP2INNSEL_2 | COMP_CSR_COMP2INNSEL_1                         ) /*!< Comparator input minus connected to 3/4 VrefInt (specifity of COMP2 related to path to enable via SYSCFG: refer to comment in function @ref LL_COMP_SetInputMinus() ) (specific to COMP instance: COMP2) */
 | 
			
		||||
#define LL_COMP_INPUT_MINUS_VREFINT     ((uint32_t)0x00000000U)                                                    /*!< Comparator input minus connected to VrefInt (specifity of COMP2 related to path to enable via SYSCFG: refer to comment in function @ref LL_COMP_SetInputMinus() ) */
 | 
			
		||||
#define LL_COMP_INPUT_MINUS_DAC1_CH1    (                         COMP_CSR_COMP2INNSEL_1                         ) /*!< Comparator input minus connected to DAC1 channel 1 (DAC_OUT1)  */
 | 
			
		||||
#define LL_COMP_INPUT_MINUS_DAC1_CH2    (                         COMP_CSR_COMP2INNSEL_1 | COMP_CSR_COMP2INNSEL_0) /*!< Comparator input minus connected to DAC1 channel 2 (DAC_OUT2)  */
 | 
			
		||||
#define LL_COMP_INPUT_MINUS_IO1         (                                                  COMP_CSR_COMP2INNSEL_0) /*!< Comparator input minus connected to IO1 (pin PA0 for COMP1, pin PA2 for COMP2) */
 | 
			
		||||
#define LL_COMP_INPUT_MINUS_IO2         (COMP_CSR_COMP2INNSEL_2 | COMP_CSR_COMP2INNSEL_1 | COMP_CSR_COMP2INNSEL_0) /*!< Comparator input minus connected to IO2 (pin PB3 for COMP2) (specific to COMP instance: COMP2) */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EC_OUTPUT_SELECTION_LPTIM Comparator output - Output selection specific to LPTIM peripheral
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_COMP_OUTPUT_LPTIM1_IN1_COMP1         (COMP_CSR_COMP1LPTIM1IN1)                                                   /*!< COMP output connected to TIM2 input capture 4 */
 | 
			
		||||
#define LL_COMP_OUTPUT_LPTIM1_IN1_COMP2         (COMP_CSR_COMP2LPTIM1IN1)                                                   /*!< COMP output connected to TIM2 input capture 4 */
 | 
			
		||||
#define LL_COMP_OUTPUT_LPTIM1_IN2_COMP2         (COMP_CSR_COMP2LPTIM1IN2)                                                   /*!< COMP output connected to TIM2 input capture 4 */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EC_OUTPUT_POLARITY Comparator output - Output polarity
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_COMP_OUTPUTPOL_NONINVERTED   ((uint32_t)0x00000000U)  /*!< COMP output polarity is not inverted: comparator output is high when the plus (non-inverting) input is at a higher voltage than the minus (inverting) input */
 | 
			
		||||
#define LL_COMP_OUTPUTPOL_INVERTED      (COMP_CSR_COMP1POLARITY) /*!< COMP output polarity is inverted: comparator output is low when the plus (non-inverting) input is at a lower voltage than the minus (inverting) input */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EC_OUTPUT_LEVEL Comparator output - Output level
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_COMP_OUTPUT_LEVEL_LOW        ((uint32_t)0x00000000U) /*!< Comparator output level low (if the polarity is not inverted, otherwise to be complemented) */
 | 
			
		||||
#define LL_COMP_OUTPUT_LEVEL_HIGH       ((uint32_t)0x00000001U) /*!< Comparator output level high (if the polarity is not inverted, otherwise to be complemented) */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EC_HW_DELAYS  Definitions of COMP hardware constraints delays
 | 
			
		||||
  * @note   Only COMP IP HW delays are defined in COMP LL driver driver,
 | 
			
		||||
  *         not timeout values.
 | 
			
		||||
  *         For details on delays values, refer to descriptions in source code
 | 
			
		||||
  *         above each literal definition.
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Delay for comparator startup time.                                         */
 | 
			
		||||
/* Note: Delay required to reach propagation delay specification.             */
 | 
			
		||||
/* Literal set to maximum value (refer to device datasheet,                   */
 | 
			
		||||
/* parameter "tSTART").                                                       */
 | 
			
		||||
/* Unit: us                                                                   */
 | 
			
		||||
#define LL_COMP_DELAY_STARTUP_US          ((uint32_t) 25U)  /*!< Delay for COMP startup time */
 | 
			
		||||
 | 
			
		||||
/* Delay for comparator voltage scaler stabilization time                     */
 | 
			
		||||
/* (voltage from VrefInt, delay based on VrefInt startup time).               */
 | 
			
		||||
/* Literal set to maximum value (refer to device datasheet,                   */
 | 
			
		||||
/* parameter "TVREFINT").                                                     */
 | 
			
		||||
/* Unit: us                                                                   */
 | 
			
		||||
#define LL_COMP_DELAY_VOLTAGE_SCALER_STAB_US ((uint32_t)3000U)  /*!< Delay for COMP voltage scaler stabilization time */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup COMP_LL_Exported_Macros COMP Exported Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/** @defgroup COMP_LL_EM_WRITE_READ Common write and read registers macro
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write a value in COMP register
 | 
			
		||||
  * @param  __INSTANCE__ comparator instance
 | 
			
		||||
  * @param  __REG__ Register to be written
 | 
			
		||||
  * @param  __VALUE__ Value to be written in the register
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
#define LL_COMP_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Read a value in COMP register
 | 
			
		||||
  * @param  __INSTANCE__ comparator instance
 | 
			
		||||
  * @param  __REG__ Register to be read
 | 
			
		||||
  * @retval Register value
 | 
			
		||||
  */
 | 
			
		||||
#define LL_COMP_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EM_HELPER_MACRO COMP helper macro
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Helper macro to select the COMP common instance
 | 
			
		||||
  *         to which is belonging the selected COMP instance.
 | 
			
		||||
  * @note   COMP common register instance can be used to
 | 
			
		||||
  *         set parameters common to several COMP instances.
 | 
			
		||||
  *         Refer to functions having argument "COMPxy_COMMON" as parameter.
 | 
			
		||||
  * @param  __COMPx__ COMP instance
 | 
			
		||||
  * @retval COMP common instance or value "0" if there is no COMP common instance.
 | 
			
		||||
  */
 | 
			
		||||
#define __LL_COMP_COMMON_INSTANCE(__COMPx__)                                   \
 | 
			
		||||
  (COMP12_COMMON)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup COMP_LL_Exported_Functions COMP Exported Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EF_Configuration_comparator_common Configuration of COMP hierarchical scope: common to several COMP instances
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set window mode of a pair of comparators instances
 | 
			
		||||
  *         (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1WM         LL_COMP_SetCommonWindowMode
 | 
			
		||||
  * @param  COMPxy_COMMON Comparator common instance
 | 
			
		||||
  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
 | 
			
		||||
  * @param  WindowMode This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_WINDOWMODE_DISABLE
 | 
			
		||||
  *         @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_COMP_SetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON, uint32_t WindowMode)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(COMPxy_COMMON->CSR, COMP_CSR_COMP1WM, WindowMode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get window mode of a pair of comparators instances
 | 
			
		||||
  *         (2 consecutive COMP instances odd and even COMP<x> and COMP<x+1>).
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1WM         LL_COMP_GetCommonWindowMode
 | 
			
		||||
  * @param  COMPxy_COMMON Comparator common instance
 | 
			
		||||
  *         (can be set directly from CMSIS definition or by using helper macro @ref __LL_COMP_COMMON_INSTANCE() )
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_WINDOWMODE_DISABLE
 | 
			
		||||
  *         @arg @ref LL_COMP_WINDOWMODE_COMP1_INPUT_PLUS_COMMON
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_COMP_GetCommonWindowMode(COMP_Common_TypeDef *COMPxy_COMMON)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(COMPxy_COMMON->CSR, COMP_CSR_COMP1WM));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EF_Configuration_comparator_modes Configuration of comparator modes
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set comparator instance operating mode to adjust power and speed.
 | 
			
		||||
  * @rmtoll COMP2_CSR   COMP2SPEED      LL_COMP_SetPowerMode
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @param  PowerMode This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED   (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER (1)
 | 
			
		||||
  *         
 | 
			
		||||
  *         (1) Available only on COMP instance: COMP2.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_COMP_SetPowerMode(COMP_TypeDef *COMPx, uint32_t PowerMode)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(COMPx->CSR, COMP_CSR_COMP2SPEED, PowerMode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get comparator instance operating mode to adjust power and speed.
 | 
			
		||||
  * @note  Available only on COMP instance: COMP2.
 | 
			
		||||
  * @rmtoll COMP2_CSR   COMP2SPEED      LL_COMP_GetPowerMode\n
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_POWERMODE_MEDIUMSPEED   (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_POWERMODE_ULTRALOWPOWER (1)
 | 
			
		||||
  *         
 | 
			
		||||
  *         (1) Available only on COMP instance: COMP2.
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_COMP_GetPowerMode(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMP2SPEED));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EF_Configuration_comparator_inputs Configuration of comparator inputs
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set comparator inputs minus (inverting) and plus (non-inverting).
 | 
			
		||||
  * @note   This function shall only be used for COMP2.
 | 
			
		||||
  *         For setting COMP1 input it is recommended to use LL_COMP_SetInputMinus()
 | 
			
		||||
  *         Plus (non-inverting) input is not configurable on COMP1.
 | 
			
		||||
  *         Using this function for COMP1 will corrupt COMP1WM register
 | 
			
		||||
  * @note   On this STM32 serie, specificity if using COMP instance COMP2
 | 
			
		||||
  *         with COMP input based on VrefInt (VrefInt or subdivision
 | 
			
		||||
  *         of VrefInt): scaler bridge is based on VrefInt and requires
 | 
			
		||||
  *         to enable path from VrefInt (refer to literal
 | 
			
		||||
  *         SYSCFG_CFGR3_ENBUFLP_VREFINT_COMP).
 | 
			
		||||
  * @rmtoll COMP2_CSR   COMP2INNSEL     LL_COMP_ConfigInputs\n
 | 
			
		||||
  *         COMP2_CSR   COMP2INPSEL     LL_COMP_ConfigInputs
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @param  InputMinus This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_IO1
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_IO2
 | 
			
		||||
  * @param  InputPlus This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO1 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO2 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO3 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO4 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO5 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO6 (1)(2)
 | 
			
		||||
  *
 | 
			
		||||
  *         (1) Available only on COMP instance: COMP2.
 | 
			
		||||
  *         (2) Available only on devices STM32L0 category 1.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_COMP_ConfigInputs(COMP_TypeDef *COMPx, uint32_t InputMinus, uint32_t InputPlus)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(COMPx->CSR,
 | 
			
		||||
             COMP_CSR_COMP2INNSEL | COMP_CSR_COMP2INPSEL,
 | 
			
		||||
             InputMinus | InputPlus);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set comparator input plus (non-inverting).
 | 
			
		||||
  * @note   Only COMP2 allows to set the input plus (non-inverting).
 | 
			
		||||
  *         For COMP1 it is always PA1 IO, except when Windows Mode is selected.
 | 
			
		||||
  * @rmtoll COMP2_CSR   COMP2INPSEL     LL_COMP_SetInputPlus
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @param  InputPlus This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO1 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO2 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO3 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO4 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO5 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO6 (1)(2)
 | 
			
		||||
  *
 | 
			
		||||
  *         (1) Available only on COMP instance: COMP2.
 | 
			
		||||
  *         (2) Available only on devices STM32L0 category 1.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_COMP_SetInputPlus(COMP_TypeDef *COMPx, uint32_t InputPlus)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(COMPx->CSR, COMP_CSR_COMP2INPSEL, InputPlus);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get comparator input plus (non-inverting).
 | 
			
		||||
  * @note   Only COMP2 allows to set the input plus (non-inverting).
 | 
			
		||||
  *         For COMP1 it is always PA1 IO, except when Windows Mode is selected.
 | 
			
		||||
  * @rmtoll COMP2_CSR   COMP2INPSEL     LL_COMP_GetInputPlus
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO1 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO2 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO3 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO4 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO5 (1)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_PLUS_IO6 (1)(2)
 | 
			
		||||
  *
 | 
			
		||||
  *         (1) Available only on COMP instance: COMP2.
 | 
			
		||||
  *         (2) Available only on devices STM32L0 category 1.
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_COMP_GetInputPlus(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMP2INPSEL));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set comparator input minus (inverting).
 | 
			
		||||
  * @note   In case of comparator input selected to be connected to IO:
 | 
			
		||||
  *         GPIO pins are specific to each comparator instance.
 | 
			
		||||
  *         Refer to description of parameters or to reference manual.
 | 
			
		||||
  * @note   On this STM32 serie, specificity if using COMP instance COMP2
 | 
			
		||||
  *         with COMP input based on VrefInt (VrefInt or subdivision
 | 
			
		||||
  *         of VrefInt): scaler bridge is based on VrefInt and requires
 | 
			
		||||
  *         to enable path from VrefInt (refer to literal
 | 
			
		||||
  *         SYSCFG_CFGR3_ENBUFLP_VREFINT_COMP).
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1INNSEL     LL_COMP_SetInputMinus\n
 | 
			
		||||
  *         COMP2_CSR   COMP2INNSEL     LL_COMP_SetInputMinus
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @param  InputMinus This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_IO1
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT (*)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT (*)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT (*)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_IO2        (*)
 | 
			
		||||
  *         
 | 
			
		||||
  *         (*) Available only on COMP instance: COMP2.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_COMP_SetInputMinus(COMP_TypeDef *COMPx, uint32_t InputMinus)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(COMPx->CSR, COMP_CSR_COMP2INNSEL, InputMinus);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get comparator input minus (inverting).
 | 
			
		||||
  * @note   In case of comparator input selected to be connected to IO:
 | 
			
		||||
  *         GPIO pins are specific to each comparator instance.
 | 
			
		||||
  *         Refer to description of parameters or to reference manual.
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1INNSEL     LL_COMP_GetInputMinus\n
 | 
			
		||||
  *         COMP2_CSR   COMP2INNSEL     LL_COMP_GetInputMinus
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_VREFINT
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_IO1
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH1
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_DAC1_CH2
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_1_4VREFINT (*)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_1_2VREFINT (*)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_3_4VREFINT (*)
 | 
			
		||||
  *         @arg @ref LL_COMP_INPUT_MINUS_IO2        (*)
 | 
			
		||||
  *         
 | 
			
		||||
  *         (*) Available only on COMP instance: COMP2.
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_COMP_GetInputMinus(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMP2INNSEL));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EF_Configuration_comparator_output Configuration of comparator output
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set comparator output LPTIM.
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1LPTIMIN1   LL_COMP_SetOutputLPTIM\n
 | 
			
		||||
  *         COMP2_CSR   COMP2LPTIMIN1   LL_COMP_SetOutputLPTIM\n
 | 
			
		||||
  *         COMP2_CSR   COMP2LPTIMIN2   LL_COMP_SetOutputLPTIM
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @param  OutputLptim This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUT_LPTIM1_IN1_COMP1 (*)
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUT_LPTIM1_IN1_COMP2 (**)
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUT_LPTIM1_IN2_COMP2 (**)
 | 
			
		||||
  *         
 | 
			
		||||
  *         (*)  Available only on COMP instance: COMP1.\n
 | 
			
		||||
  *         (**) Available only on COMP instance: COMP2.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_COMP_SetOutputLPTIM(COMP_TypeDef *COMPx, uint32_t OutputLptim)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(COMPx->CSR, (COMP_CSR_COMP1LPTIM1IN1 | COMP_CSR_COMP2LPTIM1IN1 | COMP_CSR_COMP2LPTIM1IN2), OutputLptim);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get comparator output LPTIM.
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1LPTIMIN1   LL_COMP_GetOutputLPTIM\n
 | 
			
		||||
  *         COMP2_CSR   COMP2LPTIMIN1   LL_COMP_GetOutputLPTIM\n
 | 
			
		||||
  *         COMP2_CSR   COMP2LPTIMIN2   LL_COMP_GetOutputLPTIM
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUT_LPTIM1_IN1_COMP1 (*)
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUT_LPTIM1_IN1_COMP2 (**)
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUT_LPTIM1_IN2_COMP2 (**)
 | 
			
		||||
  *         
 | 
			
		||||
  *         (*)  Available only on COMP instance: COMP1.\n
 | 
			
		||||
  *         (**) Available only on COMP instance: COMP2.
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_COMP_GetOutputLPTIM(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(COMPx->CSR, (COMP_CSR_COMP1LPTIM1IN1 | COMP_CSR_COMP2LPTIM1IN1 | COMP_CSR_COMP2LPTIM1IN2)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set comparator instance output polarity.
 | 
			
		||||
  * @rmtoll COMP     COMP1POLARITY  LL_COMP_SetOutputPolarity
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @param  OutputPolarity This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUTPOL_INVERTED
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_COMP_SetOutputPolarity(COMP_TypeDef *COMPx, uint32_t OutputPolarity)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(COMPx->CSR, COMP_CSR_COMPxPOLARITY, OutputPolarity);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get comparator instance output polarity.
 | 
			
		||||
  * @rmtoll COMP     COMP1POLARITY  LL_COMP_GetOutputPolarity
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUTPOL_NONINVERTED
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUTPOL_INVERTED
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_COMP_GetOutputPolarity(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxPOLARITY));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup COMP_LL_EF_Operation Operation on comparator instance
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable comparator instance.
 | 
			
		||||
  * @note   After enable from off state, comparator requires a delay
 | 
			
		||||
  *         to reach reach propagation delay specification.
 | 
			
		||||
  *         Refer to device datasheet, parameter "tSTART".
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1EN         LL_COMP_Enable\n
 | 
			
		||||
  *         COMP2_CSR   COMP2EN         LL_COMP_Enable
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_COMP_Enable(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(COMPx->CSR, COMP_CSR_COMPxEN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable comparator instance.
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1EN         LL_COMP_Disable\n
 | 
			
		||||
  *         COMP2_CSR   COMP2EN         LL_COMP_Disable
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_COMP_Disable(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(COMPx->CSR, COMP_CSR_COMPxEN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get comparator enable state
 | 
			
		||||
  *         (0: COMP is disabled, 1: COMP is enabled)
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1EN         LL_COMP_IsEnabled\n
 | 
			
		||||
  *         COMP2_CSR   COMP2EN         LL_COMP_IsEnabled
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_COMP_IsEnabled(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(COMPx->CSR, COMP_CSR_COMPxEN) == (COMP_CSR_COMPxEN));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Lock comparator instance.
 | 
			
		||||
  * @note   Once locked, comparator configuration can be accessed in read-only.
 | 
			
		||||
  * @note   The only way to unlock the comparator is a device hardware reset.
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1LOCK       LL_COMP_Lock\n
 | 
			
		||||
  *         COMP2_CSR   COMP2LOCK       LL_COMP_Lock
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_COMP_Lock(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(COMPx->CSR, COMP_CSR_COMPxLOCK);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get comparator lock state
 | 
			
		||||
  *         (0: COMP is unlocked, 1: COMP is locked).
 | 
			
		||||
  * @note   Once locked, comparator configuration can be accessed in read-only.
 | 
			
		||||
  * @note   The only way to unlock the comparator is a device hardware reset.
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1LOCK       LL_COMP_IsLocked\n
 | 
			
		||||
  *         COMP2_CSR   COMP2LOCK       LL_COMP_IsLocked
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_COMP_IsLocked(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(COMPx->CSR, COMP_CSR_COMPxLOCK) == (COMP_CSR_COMPxLOCK));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Read comparator instance output level.
 | 
			
		||||
  * @note   The comparator output level depends on the selected polarity
 | 
			
		||||
  *         (Refer to function @ref LL_COMP_SetOutputPolarity()).
 | 
			
		||||
  *         If the comparator polarity is not inverted:
 | 
			
		||||
  *          - Comparator output is low when the input plus
 | 
			
		||||
  *            is at a lower voltage than the input minus
 | 
			
		||||
  *          - Comparator output is high when the input plus
 | 
			
		||||
  *            is at a higher voltage than the input minus
 | 
			
		||||
  *         If the comparator polarity is inverted:
 | 
			
		||||
  *          - Comparator output is high when the input plus
 | 
			
		||||
  *            is at a lower voltage than the input minus
 | 
			
		||||
  *          - Comparator output is low when the input plus
 | 
			
		||||
  *            is at a higher voltage than the input minus
 | 
			
		||||
  * @rmtoll COMP1_CSR   COMP1VALUE      LL_COMP_ReadOutputLevel\n
 | 
			
		||||
  *         COMP2_CSR   COMP2VALUE      LL_COMP_ReadOutputLevel
 | 
			
		||||
  * @param  COMPx Comparator instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUT_LEVEL_LOW
 | 
			
		||||
  *         @arg @ref LL_COMP_OUTPUT_LEVEL_HIGH
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_COMP_ReadOutputLevel(COMP_TypeDef *COMPx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(COMPx->CSR, COMP_CSR_COMPxOUTVALUE)
 | 
			
		||||
                    >> LL_COMP_OUTPUT_LEVEL_BITOFFSET_POS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
/** @defgroup COMP_LL_EF_Init Initialization and de-initialization functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
ErrorStatus LL_COMP_DeInit(COMP_TypeDef *COMPx);
 | 
			
		||||
ErrorStatus LL_COMP_Init(COMP_TypeDef *COMPx, LL_COMP_InitTypeDef *COMP_InitStruct);
 | 
			
		||||
void        LL_COMP_StructInit(LL_COMP_InitTypeDef *COMP_InitStruct);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* COMP1 || COMP2 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32L0xx_LL_COMP_H */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,608 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_cortex.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   Header file of CORTEX LL module.
 | 
			
		||||
  @verbatim
 | 
			
		||||
  ==============================================================================
 | 
			
		||||
                     ##### How to use this driver #####
 | 
			
		||||
  ==============================================================================
 | 
			
		||||
    [..]
 | 
			
		||||
    The LL CORTEX driver contains a set of generic APIs that can be
 | 
			
		||||
    used by user:
 | 
			
		||||
      (+) SYSTICK configuration used by @ref LL_mDelay and @ref LL_Init1msTick
 | 
			
		||||
          functions
 | 
			
		||||
      (+) Low power mode configuration (SCB register of Cortex-MCU)
 | 
			
		||||
      (+) MPU API to configure and enable regions
 | 
			
		||||
      (+) API to access to MCU info (CPUID register)
 | 
			
		||||
 | 
			
		||||
  @endverbatim
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32L0xx_LL_CORTEX_H
 | 
			
		||||
#define __STM32L0xx_LL_CORTEX_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL CORTEX
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup CORTEX_LL_Exported_Constants CORTEX Exported Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EC_CLKSOURCE_HCLK SYSTICK Clock Source
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_SYSTICK_CLKSOURCE_HCLK_DIV8     ((uint32_t)0x00000000U)                 /*!< AHB clock divided by 8 selected as SysTick clock source.*/
 | 
			
		||||
#define LL_SYSTICK_CLKSOURCE_HCLK          ((uint32_t)SysTick_CTRL_CLKSOURCE_Msk) /*!< AHB clock selected as SysTick clock source. */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if __MPU_PRESENT
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EC_CTRL_HFNMI_PRIVDEF MPU Control
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_MPU_CTRL_HFNMI_PRIVDEF_NONE     ((uint32_t)0x00000000U)                            /*!< Disable NMI and privileged SW access */
 | 
			
		||||
#define LL_MPU_CTRL_HARDFAULT_NMI          MPU_CTRL_HFNMIENA_Msk                             /*!< Enables the operation of MPU during hard fault, NMI, and FAULTMASK handlers */
 | 
			
		||||
#define LL_MPU_CTRL_PRIVILEGED_DEFAULT     MPU_CTRL_PRIVDEFENA_Msk                           /*!< Enable privileged software access to default memory map */
 | 
			
		||||
#define LL_MPU_CTRL_HFNMI_PRIVDEF          (MPU_CTRL_HFNMIENA_Msk | MPU_CTRL_PRIVDEFENA_Msk) /*!< Enable NMI and privileged SW access */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EC_REGION MPU Region Number
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_MPU_REGION_NUMBER0              ((uint32_t)0x00U) /*!< REGION Number 0 */
 | 
			
		||||
#define LL_MPU_REGION_NUMBER1              ((uint32_t)0x01U) /*!< REGION Number 1 */
 | 
			
		||||
#define LL_MPU_REGION_NUMBER2              ((uint32_t)0x02U) /*!< REGION Number 2 */
 | 
			
		||||
#define LL_MPU_REGION_NUMBER3              ((uint32_t)0x03U) /*!< REGION Number 3 */
 | 
			
		||||
#define LL_MPU_REGION_NUMBER4              ((uint32_t)0x04U) /*!< REGION Number 4 */
 | 
			
		||||
#define LL_MPU_REGION_NUMBER5              ((uint32_t)0x05U) /*!< REGION Number 5 */
 | 
			
		||||
#define LL_MPU_REGION_NUMBER6              ((uint32_t)0x06U) /*!< REGION Number 6 */
 | 
			
		||||
#define LL_MPU_REGION_NUMBER7              ((uint32_t)0x07U) /*!< REGION Number 7 */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EC_REGION_SIZE MPU Region Size
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_32B             ((uint32_t)(0x04U << MPU_RASR_SIZE_Pos)) /*!< 32B Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_64B             ((uint32_t)(0x05U << MPU_RASR_SIZE_Pos)) /*!< 64B Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_128B            ((uint32_t)(0x06U << MPU_RASR_SIZE_Pos)) /*!< 128B Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_256B            ((uint32_t)(0x07U << MPU_RASR_SIZE_Pos)) /*!< 256B Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_512B            ((uint32_t)(0x08U << MPU_RASR_SIZE_Pos)) /*!< 512B Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_1KB             ((uint32_t)(0x09U << MPU_RASR_SIZE_Pos)) /*!< 1KB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_2KB             ((uint32_t)(0x0AU << MPU_RASR_SIZE_Pos)) /*!< 2KB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_4KB             ((uint32_t)(0x0BU << MPU_RASR_SIZE_Pos)) /*!< 4KB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_8KB             ((uint32_t)(0x0CU << MPU_RASR_SIZE_Pos)) /*!< 8KB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_16KB            ((uint32_t)(0x0DU << MPU_RASR_SIZE_Pos)) /*!< 16KB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_32KB            ((uint32_t)(0x0EU << MPU_RASR_SIZE_Pos)) /*!< 32KB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_64KB            ((uint32_t)(0x0FU << MPU_RASR_SIZE_Pos)) /*!< 64KB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_128KB           ((uint32_t)(0x10U << MPU_RASR_SIZE_Pos)) /*!< 128KB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_256KB           ((uint32_t)(0x11U << MPU_RASR_SIZE_Pos)) /*!< 256KB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_512KB           ((uint32_t)(0x12U << MPU_RASR_SIZE_Pos)) /*!< 512KB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_1MB             ((uint32_t)(0x13U << MPU_RASR_SIZE_Pos)) /*!< 1MB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_2MB             ((uint32_t)(0x14U << MPU_RASR_SIZE_Pos)) /*!< 2MB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_4MB             ((uint32_t)(0x15U << MPU_RASR_SIZE_Pos)) /*!< 4MB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_8MB             ((uint32_t)(0x16U << MPU_RASR_SIZE_Pos)) /*!< 8MB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_16MB            ((uint32_t)(0x17U << MPU_RASR_SIZE_Pos)) /*!< 16MB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_32MB            ((uint32_t)(0x18U << MPU_RASR_SIZE_Pos)) /*!< 32MB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_64MB            ((uint32_t)(0x19U << MPU_RASR_SIZE_Pos)) /*!< 64MB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_128MB           ((uint32_t)(0x1AU << MPU_RASR_SIZE_Pos)) /*!< 128MB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_256MB           ((uint32_t)(0x1BU << MPU_RASR_SIZE_Pos)) /*!< 256MB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_512MB           ((uint32_t)(0x1CU << MPU_RASR_SIZE_Pos)) /*!< 512MB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_1GB             ((uint32_t)(0x1DU << MPU_RASR_SIZE_Pos)) /*!< 1GB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_2GB             ((uint32_t)(0x1EU << MPU_RASR_SIZE_Pos)) /*!< 2GB Size of the MPU protection region */
 | 
			
		||||
#define LL_MPU_REGION_SIZE_4GB             ((uint32_t)(0x1FU << MPU_RASR_SIZE_Pos)) /*!< 4GB Size of the MPU protection region */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EC_REGION_PRIVILEDGES MPU Region Privileges
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_MPU_REGION_NO_ACCESS            ((uint32_t)(0x00U << MPU_RASR_AP_Pos)) /*!< No access*/
 | 
			
		||||
#define LL_MPU_REGION_PRIV_RW              ((uint32_t)(0x01U << MPU_RASR_AP_Pos)) /*!< RW privileged (privileged access only)*/
 | 
			
		||||
#define LL_MPU_REGION_PRIV_RW_URO          ((uint32_t)(0x02U << MPU_RASR_AP_Pos)) /*!< RW privileged - RO user (Write in a user program generates a fault) */
 | 
			
		||||
#define LL_MPU_REGION_FULL_ACCESS          ((uint32_t)(0x03U << MPU_RASR_AP_Pos)) /*!< RW privileged & user (Full access) */
 | 
			
		||||
#define LL_MPU_REGION_PRIV_RO              ((uint32_t)(0x05U << MPU_RASR_AP_Pos)) /*!< RO privileged (privileged read only)*/
 | 
			
		||||
#define LL_MPU_REGION_PRIV_RO_URO          ((uint32_t)(0x06U << MPU_RASR_AP_Pos)) /*!< RO privileged & user (read only) */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EC_TEX MPU TEX Level
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_MPU_TEX_LEVEL0                  ((uint32_t)(0x00U << MPU_RASR_TEX_Pos)) /*!< b000 for TEX bits */
 | 
			
		||||
#define LL_MPU_TEX_LEVEL1                  ((uint32_t)(0x01U << MPU_RASR_TEX_Pos)) /*!< b001 for TEX bits */
 | 
			
		||||
#define LL_MPU_TEX_LEVEL2                  ((uint32_t)(0x02U << MPU_RASR_TEX_Pos)) /*!< b010 for TEX bits */
 | 
			
		||||
#define LL_MPU_TEX_LEVEL4                  ((uint32_t)(0x04U << MPU_RASR_TEX_Pos)) /*!< b100 for TEX bits */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EC_INSTRUCTION_ACCESS MPU Instruction Access
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_MPU_INSTRUCTION_ACCESS_ENABLE   ((uint32_t)0x00U) /*!< Instruction fetches enabled */
 | 
			
		||||
#define LL_MPU_INSTRUCTION_ACCESS_DISABLE  MPU_RASR_XN_Msk  /*!< Instruction fetches disabled*/
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EC_SHAREABLE_ACCESS MPU Shareable Access
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_MPU_ACCESS_SHAREABLE            MPU_RASR_S_Msk   /*!< Shareable memory attribute */
 | 
			
		||||
#define LL_MPU_ACCESS_NOT_SHAREABLE        ((uint32_t)0x00U) /*!< Not Shareable memory attribute */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EC_CACHEABLE_ACCESS MPU Cacheable Access
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_MPU_ACCESS_CACHEABLE            MPU_RASR_C_Msk   /*!< Cacheable memory attribute */
 | 
			
		||||
#define LL_MPU_ACCESS_NOT_CACHEABLE        ((uint32_t)0x00U) /*!< Not Cacheable memory attribute */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EC_BUFFERABLE_ACCESS MPU Bufferable Access
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_MPU_ACCESS_BUFFERABLE           MPU_RASR_B_Msk   /*!< Bufferable memory attribute */
 | 
			
		||||
#define LL_MPU_ACCESS_NOT_BUFFERABLE       ((uint32_t)0x00U) /*!< Not Bufferable memory attribute */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* __MPU_PRESENT */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup CORTEX_LL_Exported_Functions CORTEX Exported Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EF_SYSTICK SYSTICK
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  This function checks if the Systick counter flag is active or not.
 | 
			
		||||
  * @note   It can be used in timeout function on application side.
 | 
			
		||||
  * @rmtoll STK_CTRL     COUNTFLAG     LL_SYSTICK_IsActiveCounterFlag
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_SYSTICK_IsActiveCounterFlag(void)
 | 
			
		||||
{
 | 
			
		||||
  return ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) == (SysTick_CTRL_COUNTFLAG_Msk));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configures the SysTick clock source
 | 
			
		||||
  * @rmtoll STK_CTRL     CLKSOURCE     LL_SYSTICK_SetClkSource
 | 
			
		||||
  * @param  Source This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8
 | 
			
		||||
  *         @arg @ref LL_SYSTICK_CLKSOURCE_HCLK
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_SYSTICK_SetClkSource(uint32_t Source)
 | 
			
		||||
{
 | 
			
		||||
  if (Source == LL_SYSTICK_CLKSOURCE_HCLK)
 | 
			
		||||
  {
 | 
			
		||||
    SET_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    CLEAR_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get the SysTick clock source
 | 
			
		||||
  * @rmtoll STK_CTRL     CLKSOURCE     LL_SYSTICK_GetClkSource
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_SYSTICK_CLKSOURCE_HCLK_DIV8
 | 
			
		||||
  *         @arg @ref LL_SYSTICK_CLKSOURCE_HCLK
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_SYSTICK_GetClkSource(void)
 | 
			
		||||
{
 | 
			
		||||
  return READ_BIT(SysTick->CTRL, LL_SYSTICK_CLKSOURCE_HCLK);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable SysTick exception request
 | 
			
		||||
  * @rmtoll STK_CTRL     TICKINT       LL_SYSTICK_EnableIT
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_SYSTICK_EnableIT(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable SysTick exception request
 | 
			
		||||
  * @rmtoll STK_CTRL     TICKINT       LL_SYSTICK_DisableIT
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_SYSTICK_DisableIT(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Checks if the SYSTICK interrupt is enabled or disabled.
 | 
			
		||||
  * @rmtoll STK_CTRL     TICKINT       LL_SYSTICK_IsEnabledIT
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_SYSTICK_IsEnabledIT(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(SysTick->CTRL, SysTick_CTRL_TICKINT_Msk) == (SysTick_CTRL_TICKINT_Msk));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EF_LOW_POWER_MODE LOW POWER MODE
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Processor uses sleep as its low power mode
 | 
			
		||||
  * @rmtoll SCB_SCR      SLEEPDEEP     LL_LPM_EnableSleep
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_LPM_EnableSleep(void)
 | 
			
		||||
{
 | 
			
		||||
  /* Clear SLEEPDEEP bit of Cortex System Control Register */
 | 
			
		||||
  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Processor uses deep sleep as its low power mode
 | 
			
		||||
  * @rmtoll SCB_SCR      SLEEPDEEP     LL_LPM_EnableDeepSleep
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_LPM_EnableDeepSleep(void)
 | 
			
		||||
{
 | 
			
		||||
  /* Set SLEEPDEEP bit of Cortex System Control Register */
 | 
			
		||||
  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configures sleep-on-exit when returning from Handler mode to Thread mode.
 | 
			
		||||
  * @note   Setting this bit to 1 enables an interrupt-driven application to avoid returning to an
 | 
			
		||||
  *         empty main application.
 | 
			
		||||
  * @rmtoll SCB_SCR      SLEEPONEXIT   LL_LPM_EnableSleepOnExit
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_LPM_EnableSleepOnExit(void)
 | 
			
		||||
{
 | 
			
		||||
  /* Set SLEEPONEXIT bit of Cortex System Control Register */
 | 
			
		||||
  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Do not sleep when returning to Thread mode.
 | 
			
		||||
  * @rmtoll SCB_SCR      SLEEPONEXIT   LL_LPM_DisableSleepOnExit
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_LPM_DisableSleepOnExit(void)
 | 
			
		||||
{
 | 
			
		||||
  /* Clear SLEEPONEXIT bit of Cortex System Control Register */
 | 
			
		||||
  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enabled events and all interrupts, including disabled interrupts, can wakeup the
 | 
			
		||||
  *         processor.
 | 
			
		||||
  * @rmtoll SCB_SCR      SEVEONPEND    LL_LPM_EnableEventOnPend
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_LPM_EnableEventOnPend(void)
 | 
			
		||||
{
 | 
			
		||||
  /* Set SEVEONPEND bit of Cortex System Control Register */
 | 
			
		||||
  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Only enabled interrupts or events can wakeup the processor, disabled interrupts are
 | 
			
		||||
  *         excluded
 | 
			
		||||
  * @rmtoll SCB_SCR      SEVEONPEND    LL_LPM_DisableEventOnPend
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_LPM_DisableEventOnPend(void)
 | 
			
		||||
{
 | 
			
		||||
  /* Clear SEVEONPEND bit of Cortex System Control Register */
 | 
			
		||||
  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CORTEX_LL_EF_MCU_INFO MCU INFO
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Implementer code
 | 
			
		||||
  * @rmtoll SCB_CPUID    IMPLEMENTER   LL_CPUID_GetImplementer
 | 
			
		||||
  * @retval Value should be equal to 0x41 for ARM
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CPUID_GetImplementer(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_IMPLEMENTER_Msk) >> SCB_CPUID_IMPLEMENTER_Pos);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Variant number (The r value in the rnpn product revision identifier)
 | 
			
		||||
  * @rmtoll SCB_CPUID    VARIANT       LL_CPUID_GetVariant
 | 
			
		||||
  * @retval Value between 0 and 255 (0x0: revision 0)
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CPUID_GetVariant(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_VARIANT_Msk) >> SCB_CPUID_VARIANT_Pos);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Architecture number 
 | 
			
		||||
  * @rmtoll SCB_CPUID    ARCHITECTURE  LL_CPUID_GetArchitecture
 | 
			
		||||
  * @retval Value should be equal to 0xC for Cortex-M0+ devices
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CPUID_GetArchitecture(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_ARCHITECTURE_Msk) >> SCB_CPUID_ARCHITECTURE_Pos);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Part number
 | 
			
		||||
  * @rmtoll SCB_CPUID    PARTNO        LL_CPUID_GetParNo
 | 
			
		||||
  * @retval Value should be equal to 0xC60 for Cortex-M0+
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CPUID_GetParNo(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_PARTNO_Msk) >> SCB_CPUID_PARTNO_Pos);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Revision number (The p value in the rnpn product revision identifier, indicates patch release)
 | 
			
		||||
  * @rmtoll SCB_CPUID    REVISION      LL_CPUID_GetRevision
 | 
			
		||||
  * @retval Value between 0 and 255 (0x1: patch 1)
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CPUID_GetRevision(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(SCB->CPUID, SCB_CPUID_REVISION_Msk) >> SCB_CPUID_REVISION_Pos);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if __MPU_PRESENT
 | 
			
		||||
/** @defgroup CORTEX_LL_EF_MPU MPU
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable MPU with input options
 | 
			
		||||
  * @rmtoll MPU_CTRL     ENABLE        LL_MPU_Enable
 | 
			
		||||
  * @param  Options This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_MPU_CTRL_HFNMI_PRIVDEF_NONE
 | 
			
		||||
  *         @arg @ref LL_MPU_CTRL_HARDFAULT_NMI
 | 
			
		||||
  *         @arg @ref LL_MPU_CTRL_PRIVILEGED_DEFAULT
 | 
			
		||||
  *         @arg @ref LL_MPU_CTRL_HFNMI_PRIVDEF
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_MPU_Enable(uint32_t Options)
 | 
			
		||||
{
 | 
			
		||||
  /* Enable the MPU*/
 | 
			
		||||
  WRITE_REG(MPU->CTRL, (MPU_CTRL_ENABLE_Msk | Options));
 | 
			
		||||
  /* Ensure MPU settings take effects */
 | 
			
		||||
  __DSB();
 | 
			
		||||
  /* Sequence instruction fetches using update settings */
 | 
			
		||||
  __ISB();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable MPU
 | 
			
		||||
  * @rmtoll MPU_CTRL     ENABLE        LL_MPU_Disable
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_MPU_Disable(void)
 | 
			
		||||
{
 | 
			
		||||
  /* Make sure outstanding transfers are done */
 | 
			
		||||
  __DMB();
 | 
			
		||||
  /* Disable MPU*/
 | 
			
		||||
  WRITE_REG(MPU->CTRL, 0U);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if MPU is enabled or not
 | 
			
		||||
  * @rmtoll MPU_CTRL     ENABLE        LL_MPU_IsEnabled
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_MPU_IsEnabled(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(MPU->CTRL, MPU_CTRL_ENABLE_Msk) == (MPU_CTRL_ENABLE_Msk));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable a MPU region
 | 
			
		||||
  * @rmtoll MPU_RASR     ENABLE        LL_MPU_EnableRegion
 | 
			
		||||
  * @param  Region This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER0
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER1
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER2
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER3
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER4
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER5
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER6
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER7
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_MPU_EnableRegion(uint32_t Region)
 | 
			
		||||
{
 | 
			
		||||
  /* Set Region number */
 | 
			
		||||
  WRITE_REG(MPU->RNR, Region);
 | 
			
		||||
  /* Enable the MPU region */
 | 
			
		||||
  SET_BIT(MPU->RASR, MPU_RASR_ENABLE_Msk);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure and enable a region
 | 
			
		||||
  * @rmtoll MPU_RNR      REGION        LL_MPU_ConfigRegion\n
 | 
			
		||||
  *         MPU_RBAR     REGION        LL_MPU_ConfigRegion\n
 | 
			
		||||
  *         MPU_RBAR     ADDR          LL_MPU_ConfigRegion\n
 | 
			
		||||
  *         MPU_RASR     XN            LL_MPU_ConfigRegion\n
 | 
			
		||||
  *         MPU_RASR     AP            LL_MPU_ConfigRegion\n
 | 
			
		||||
  *         MPU_RASR     S             LL_MPU_ConfigRegion\n
 | 
			
		||||
  *         MPU_RASR     C             LL_MPU_ConfigRegion\n
 | 
			
		||||
  *         MPU_RASR     B             LL_MPU_ConfigRegion\n
 | 
			
		||||
  *         MPU_RASR     SIZE          LL_MPU_ConfigRegion
 | 
			
		||||
  * @param  Region This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER0
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER1
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER2
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER3
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER4
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER5
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER6
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER7
 | 
			
		||||
  * @param  Address Value of region base address
 | 
			
		||||
  * @param  SubRegionDisable Sub-region disable value between Min_Data = 0x00 and Max_Data = 0xFF
 | 
			
		||||
  * @param  Attributes This parameter can be a combination of the following values:
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_SIZE_32B or @ref LL_MPU_REGION_SIZE_64B or @ref LL_MPU_REGION_SIZE_128B or @ref LL_MPU_REGION_SIZE_256B or @ref LL_MPU_REGION_SIZE_512B
 | 
			
		||||
  *           or @ref LL_MPU_REGION_SIZE_1KB or @ref LL_MPU_REGION_SIZE_2KB or @ref LL_MPU_REGION_SIZE_4KB or @ref LL_MPU_REGION_SIZE_8KB or @ref LL_MPU_REGION_SIZE_16KB
 | 
			
		||||
  *           or @ref LL_MPU_REGION_SIZE_32KB or @ref LL_MPU_REGION_SIZE_64KB or @ref LL_MPU_REGION_SIZE_128KB or @ref LL_MPU_REGION_SIZE_256KB or @ref LL_MPU_REGION_SIZE_512KB
 | 
			
		||||
  *           or @ref LL_MPU_REGION_SIZE_1MB or @ref LL_MPU_REGION_SIZE_2MB or @ref LL_MPU_REGION_SIZE_4MB or @ref LL_MPU_REGION_SIZE_8MB or @ref LL_MPU_REGION_SIZE_16MB
 | 
			
		||||
  *           or @ref LL_MPU_REGION_SIZE_32MB or @ref LL_MPU_REGION_SIZE_64MB or @ref LL_MPU_REGION_SIZE_128MB or @ref LL_MPU_REGION_SIZE_256MB or @ref LL_MPU_REGION_SIZE_512MB
 | 
			
		||||
  *           or @ref LL_MPU_REGION_SIZE_1GB or @ref LL_MPU_REGION_SIZE_2GB or @ref LL_MPU_REGION_SIZE_4GB
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NO_ACCESS or @ref LL_MPU_REGION_PRIV_RW or @ref LL_MPU_REGION_PRIV_RW_URO or @ref LL_MPU_REGION_FULL_ACCESS
 | 
			
		||||
  *           or @ref LL_MPU_REGION_PRIV_RO or @ref LL_MPU_REGION_PRIV_RO_URO
 | 
			
		||||
  *         @arg @ref LL_MPU_TEX_LEVEL0 or @ref LL_MPU_TEX_LEVEL1 or @ref LL_MPU_TEX_LEVEL2 or @ref LL_MPU_TEX_LEVEL4
 | 
			
		||||
  *         @arg @ref LL_MPU_INSTRUCTION_ACCESS_ENABLE or  @ref LL_MPU_INSTRUCTION_ACCESS_DISABLE
 | 
			
		||||
  *         @arg @ref LL_MPU_ACCESS_SHAREABLE or @ref LL_MPU_ACCESS_NOT_SHAREABLE
 | 
			
		||||
  *         @arg @ref LL_MPU_ACCESS_CACHEABLE or @ref LL_MPU_ACCESS_NOT_CACHEABLE
 | 
			
		||||
  *         @arg @ref LL_MPU_ACCESS_BUFFERABLE or @ref LL_MPU_ACCESS_NOT_BUFFERABLE
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_MPU_ConfigRegion(uint32_t Region, uint32_t SubRegionDisable, uint32_t Address, uint32_t Attributes)
 | 
			
		||||
{
 | 
			
		||||
  /* Set Region number */
 | 
			
		||||
  WRITE_REG(MPU->RNR, Region);
 | 
			
		||||
  /* Set base address */
 | 
			
		||||
  WRITE_REG(MPU->RBAR, (Address & 0xFFFFFFE0U));
 | 
			
		||||
  /* Configure MPU */
 | 
			
		||||
  WRITE_REG(MPU->RASR, (MPU_RASR_ENABLE_Msk | Attributes | SubRegionDisable << MPU_RASR_SRD_Pos));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable a region
 | 
			
		||||
  * @rmtoll MPU_RNR      REGION        LL_MPU_DisableRegion\n
 | 
			
		||||
  *         MPU_RASR     ENABLE        LL_MPU_DisableRegion
 | 
			
		||||
  * @param  Region This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER0
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER1
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER2
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER3
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER4
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER5
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER6
 | 
			
		||||
  *         @arg @ref LL_MPU_REGION_NUMBER7
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_MPU_DisableRegion(uint32_t Region)
 | 
			
		||||
{
 | 
			
		||||
  /* Set Region number */
 | 
			
		||||
  WRITE_REG(MPU->RNR, Region);
 | 
			
		||||
  /* Disable the MPU region */
 | 
			
		||||
  CLEAR_BIT(MPU->RASR, MPU_RASR_ENABLE_Msk);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* __MPU_PRESENT */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32L0xx_LL_CORTEX_H */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,125 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_crc.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   CRC LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_crc.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (CRC)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup CRC_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup CRC_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup CRC_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize CRC registers (Registers restored to their default values).
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: CRC registers are de-initialized
 | 
			
		||||
  *          - ERROR: CRC registers are not de-initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_CRC_ALL_INSTANCE(CRCx));
 | 
			
		||||
 | 
			
		||||
  if (CRCx == CRC)
 | 
			
		||||
  {
 | 
			
		||||
    /* Force CRC reset */
 | 
			
		||||
    LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_CRC);
 | 
			
		||||
 | 
			
		||||
    /* Release CRC reset */
 | 
			
		||||
    LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_CRC);
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return (status);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined (CRC) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,479 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_crc.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   Header file of CRC LL module.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32L0xx_LL_CRC_H
 | 
			
		||||
#define __STM32L0xx_LL_CRC_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(CRC)
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRC_LL CRC
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup CRC_LL_Exported_Constants CRC Exported Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRC_LL_EC_POLYLENGTH Polynomial length
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRC_POLYLENGTH_32B              (uint32_t)0x00000000U                    /*!< 32 bits Polynomial size */
 | 
			
		||||
#define LL_CRC_POLYLENGTH_16B              CRC_CR_POLYSIZE_0                        /*!< 16 bits Polynomial size */
 | 
			
		||||
#define LL_CRC_POLYLENGTH_8B               CRC_CR_POLYSIZE_1                        /*!< 8 bits Polynomial size */
 | 
			
		||||
#define LL_CRC_POLYLENGTH_7B               (CRC_CR_POLYSIZE_1 | CRC_CR_POLYSIZE_0)  /*!< 7 bits Polynomial size */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRC_LL_EC_INDATA_REVERSE Input Data Reverse
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRC_INDATA_REVERSE_NONE         (uint32_t)0x00000000U                    /*!< Input Data bit order not affected */
 | 
			
		||||
#define LL_CRC_INDATA_REVERSE_BYTE         CRC_CR_REV_IN_0                          /*!< Input Data bit reversal done by byte */
 | 
			
		||||
#define LL_CRC_INDATA_REVERSE_HALFWORD     CRC_CR_REV_IN_1                          /*!< Input Data bit reversal done by half-word */
 | 
			
		||||
#define LL_CRC_INDATA_REVERSE_WORD         (CRC_CR_REV_IN_1 | CRC_CR_REV_IN_0)      /*!< Input Data bit reversal done by word */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRC_LL_EC_OUTDATA_REVERSE Output Data Reverse
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRC_OUTDATA_REVERSE_NONE        (uint32_t)0x00000000U                     /*!< Output Data bit order not affected */
 | 
			
		||||
#define LL_CRC_OUTDATA_REVERSE_BIT         CRC_CR_REV_OUT                            /*!< Output Data bit reversal done by bit */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRC_LL_EC_Default_Polynomial_Value    Default CRC generating polynomial value
 | 
			
		||||
  * @brief    Normal representation of this polynomial value is
 | 
			
		||||
  *           X^32 + X^26 + X^23 + X^22 + X^16 + X^12 + X^11 + X^10 +X^8 + X^7 + X^5 + X^4 + X^2 + X + 1 .
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRC_DEFAULT_CRC32_POLY          (uint32_t)0x04C11DB7U                     /*!< Default CRC generating polynomial value */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRC_LL_EC_Default_InitValue    Default CRC computation initialization value
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRC_DEFAULT_CRC_INITVALUE       (uint32_t)0xFFFFFFFFU                     /*!< Default CRC computation initialization value */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup CRC_LL_Exported_Macros CRC Exported Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRC_LL_EM_WRITE_READ Common Write and read registers Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write a value in CRC register
 | 
			
		||||
  * @param  __INSTANCE__ CRC Instance
 | 
			
		||||
  * @param  __REG__ Register to be written
 | 
			
		||||
  * @param  __VALUE__ Value to be written in the register
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRC_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Read a value in CRC register
 | 
			
		||||
  * @param  __INSTANCE__ CRC Instance
 | 
			
		||||
  * @param  __REG__ Register to be read
 | 
			
		||||
  * @retval Register value
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRC_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup CRC_LL_Exported_Functions CRC Exported Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRC_LL_EF_Configuration CRC Configuration functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Reset the CRC calculation unit.
 | 
			
		||||
  * @note   If Programmable Initial CRC value feature
 | 
			
		||||
  *         is available, also set the Data Register to the value stored in the
 | 
			
		||||
  *         CRC_INIT register, otherwise, reset Data Register to its default value.
 | 
			
		||||
  * @rmtoll CR           RESET         LL_CRC_ResetCRCCalculationUnit
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRC_ResetCRCCalculationUnit(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(CRCx->CR, CRC_CR_RESET);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure size of the polynomial.
 | 
			
		||||
  * @rmtoll CR           POLYSIZE      LL_CRC_SetPolynomialSize
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @param  PolySize This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRC_POLYLENGTH_32B
 | 
			
		||||
  *         @arg @ref LL_CRC_POLYLENGTH_16B
 | 
			
		||||
  *         @arg @ref LL_CRC_POLYLENGTH_8B
 | 
			
		||||
  *         @arg @ref LL_CRC_POLYLENGTH_7B
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRC_SetPolynomialSize(CRC_TypeDef *CRCx, uint32_t PolySize)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(CRCx->CR, CRC_CR_POLYSIZE, PolySize);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return size of the polynomial.
 | 
			
		||||
  * @rmtoll CR           POLYSIZE      LL_CRC_GetPolynomialSize
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRC_POLYLENGTH_32B
 | 
			
		||||
  *         @arg @ref LL_CRC_POLYLENGTH_16B
 | 
			
		||||
  *         @arg @ref LL_CRC_POLYLENGTH_8B
 | 
			
		||||
  *         @arg @ref LL_CRC_POLYLENGTH_7B
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRC_GetPolynomialSize(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_POLYSIZE));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the reversal of the bit order of the input data
 | 
			
		||||
  * @rmtoll CR           REV_IN        LL_CRC_SetInputDataReverseMode
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @param  ReverseMode This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRC_INDATA_REVERSE_NONE
 | 
			
		||||
  *         @arg @ref LL_CRC_INDATA_REVERSE_BYTE
 | 
			
		||||
  *         @arg @ref LL_CRC_INDATA_REVERSE_HALFWORD
 | 
			
		||||
  *         @arg @ref LL_CRC_INDATA_REVERSE_WORD
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRC_SetInputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(CRCx->CR, CRC_CR_REV_IN, ReverseMode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return type of reversal for input data bit order
 | 
			
		||||
  * @rmtoll CR           REV_IN        LL_CRC_GetInputDataReverseMode
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRC_INDATA_REVERSE_NONE
 | 
			
		||||
  *         @arg @ref LL_CRC_INDATA_REVERSE_BYTE
 | 
			
		||||
  *         @arg @ref LL_CRC_INDATA_REVERSE_HALFWORD
 | 
			
		||||
  *         @arg @ref LL_CRC_INDATA_REVERSE_WORD
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRC_GetInputDataReverseMode(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_REV_IN));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the reversal of the bit order of the Output data
 | 
			
		||||
  * @rmtoll CR           REV_OUT       LL_CRC_SetOutputDataReverseMode
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @param  ReverseMode This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRC_OUTDATA_REVERSE_NONE
 | 
			
		||||
  *         @arg @ref LL_CRC_OUTDATA_REVERSE_BIT
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRC_SetOutputDataReverseMode(CRC_TypeDef *CRCx, uint32_t ReverseMode)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(CRCx->CR, CRC_CR_REV_OUT, ReverseMode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the reversal of the bit order of the Output data
 | 
			
		||||
  * @rmtoll CR           REV_OUT       LL_CRC_GetOutputDataReverseMode
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRC_OUTDATA_REVERSE_NONE
 | 
			
		||||
  *         @arg @ref LL_CRC_OUTDATA_REVERSE_BIT
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRC_GetOutputDataReverseMode(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRCx->CR, CRC_CR_REV_OUT));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize the Programmable initial CRC value.
 | 
			
		||||
  * @note   If the CRC size is less than 32 bits, the least significant bits
 | 
			
		||||
  *         are used to write the correct value
 | 
			
		||||
  * @note   LL_CRC_DEFAULT_CRC_INITVALUE could be used as value for InitCrc parameter.
 | 
			
		||||
  * @rmtoll INIT         INIT          LL_CRC_SetInitialData
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @param  InitCrc Value to be programmed in Programmable initial CRC value register
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRC_SetInitialData(CRC_TypeDef *CRCx, uint32_t InitCrc)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(CRCx->INIT, InitCrc);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return current Initial CRC value.
 | 
			
		||||
  * @note   If the CRC size is less than 32 bits, the least significant bits
 | 
			
		||||
  *         are used to read the correct value
 | 
			
		||||
  * @rmtoll INIT         INIT          LL_CRC_GetInitialData
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval Value programmed in Programmable initial CRC value register
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRC_GetInitialData(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(CRCx->INIT));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize the Programmable polynomial value
 | 
			
		||||
  *         (coefficients of the polynomial to be used for CRC calculation).
 | 
			
		||||
  * @note   LL_CRC_DEFAULT_CRC32_POLY could be used as value for PolynomCoef parameter.
 | 
			
		||||
  * @note   Please check Reference Manual and existing Errata Sheets,
 | 
			
		||||
  *         regarding possible limitations for Polynomial values usage.
 | 
			
		||||
  *         For example, for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65
 | 
			
		||||
  * @rmtoll POL          POL           LL_CRC_SetPolynomialCoef
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @param  PolynomCoef Value to be programmed in Programmable Polynomial value register
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRC_SetPolynomialCoef(CRC_TypeDef *CRCx, uint32_t PolynomCoef)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(CRCx->POL, PolynomCoef);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return current Programmable polynomial value
 | 
			
		||||
  * @note   Please check Reference Manual and existing Errata Sheets,
 | 
			
		||||
  *         regarding possible limitations for Polynomial values usage.
 | 
			
		||||
  *         For example, for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65
 | 
			
		||||
  * @rmtoll POL          POL           LL_CRC_GetPolynomialCoef
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval Value programmed in Programmable Polynomial value register
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRC_GetPolynomialCoef(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(CRCx->POL));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRC_LL_EF_Data_Management Data_Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write given 32-bit data to the CRC calculator
 | 
			
		||||
  * @rmtoll DR           DR            LL_CRC_FeedData32
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @param  InData value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFFFFFF
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRC_FeedData32(CRC_TypeDef *CRCx, uint32_t InData)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(CRCx->DR, InData);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write given 16-bit data to the CRC calculator
 | 
			
		||||
  * @rmtoll DR           DR            LL_CRC_FeedData16
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @param  InData 16 bit value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFFFF
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRC_FeedData16(CRC_TypeDef *CRCx, uint16_t InData)
 | 
			
		||||
{
 | 
			
		||||
  *(uint16_t __IO *)(&CRCx->DR) = (uint16_t) InData;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write given 8-bit data to the CRC calculator
 | 
			
		||||
  * @rmtoll DR           DR            LL_CRC_FeedData8
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @param  InData 8 bit value to be provided to CRC calculator between between Min_Data=0 and Max_Data=0xFF
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRC_FeedData8(CRC_TypeDef *CRCx, uint8_t InData)
 | 
			
		||||
{
 | 
			
		||||
  *(uint8_t __IO *)(&CRCx->DR) = (uint8_t) InData;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return current CRC calculation result. 32 bits value is returned.
 | 
			
		||||
  * @rmtoll DR           DR            LL_CRC_ReadData32
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval Current CRC calculation result as stored in CRC_DR register (32 bits).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRC_ReadData32(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(CRCx->DR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return current CRC calculation result. 16 bits value is returned.
 | 
			
		||||
  * @note   This function is expected to be used in a 16 bits CRC polynomial size context.
 | 
			
		||||
  * @rmtoll DR           DR            LL_CRC_ReadData16
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval Current CRC calculation result as stored in CRC_DR register (16 bits).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint16_t LL_CRC_ReadData16(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint16_t)READ_REG(CRCx->DR);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return current CRC calculation result. 8 bits value is returned.
 | 
			
		||||
  * @note   This function is expected to be used in a 8 bits CRC polynomial size context.
 | 
			
		||||
  * @rmtoll DR           DR            LL_CRC_ReadData8
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval Current CRC calculation result as stored in CRC_DR register (8 bits).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint8_t LL_CRC_ReadData8(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint8_t)READ_REG(CRCx->DR);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return current CRC calculation result. 7 bits value is returned.
 | 
			
		||||
  * @note   This function is expected to be used in a 7 bits CRC polynomial size context.
 | 
			
		||||
  * @rmtoll DR           DR            LL_CRC_ReadData7
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval Current CRC calculation result as stored in CRC_DR register (7 bits).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint8_t LL_CRC_ReadData7(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint8_t)(READ_REG(CRCx->DR) & 0x7FU);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return data stored in the Independent Data(IDR) register.
 | 
			
		||||
  * @note   This register can be used as a temporary storage location for one byte.
 | 
			
		||||
  * @rmtoll IDR          IDR           LL_CRC_Read_IDR
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @retval Value stored in CRC_IDR register (General-purpose 8-bit data register).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRC_Read_IDR(CRC_TypeDef *CRCx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(CRCx->IDR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Store data in the Independent Data(IDR) register.
 | 
			
		||||
  * @note   This register can be used as a temporary storage location for one byte.
 | 
			
		||||
  * @rmtoll IDR          IDR           LL_CRC_Write_IDR
 | 
			
		||||
  * @param  CRCx CRC Instance
 | 
			
		||||
  * @param  InData value to be stored in CRC_IDR register (8-bit) between between Min_Data=0 and Max_Data=0xFF
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRC_Write_IDR(CRC_TypeDef *CRCx, uint32_t InData)
 | 
			
		||||
{
 | 
			
		||||
  *((uint8_t __IO *)(&CRCx->IDR)) = (uint8_t) InData;
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
/** @defgroup CRC_LL_EF_Init Initialization and de-initialization functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
ErrorStatus LL_CRC_DeInit(CRC_TypeDef *CRCx);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined(CRC) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32L0xx_LL_CRC_H */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,104 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_crs.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   CRS LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_crs.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(CRS)
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL CRS
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup CRS_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup CRS_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-Initializes CRS peripheral registers to their default reset values.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: CRS registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_CRS_DeInit(void)
 | 
			
		||||
{
 | 
			
		||||
  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_CRS);
 | 
			
		||||
  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_CRS);
 | 
			
		||||
 | 
			
		||||
  return  SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined(CRS) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
  
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,817 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_crs.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   Header file of CRS LL module.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32L0xx_LL_CRS_H
 | 
			
		||||
#define __STM32L0xx_LL_CRS_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(CRS)
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL CRS
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @defgroup CRS_LL_Private_Constants CRS Private Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Defines used for the bit position in the register and perform offsets*/
 | 
			
		||||
#define CRS_POSITION_TRIM        (uint32_t)8U   /* bit position in CR reg */
 | 
			
		||||
#define CRS_POSITION_FECAP       (uint32_t)16U  /* bit position in ISR reg */
 | 
			
		||||
#define CRS_POSITION_RELOAD      (uint32_t)0U   /* bit position in CFGR reg */
 | 
			
		||||
#define CRS_POSITION_FELIM       (uint32_t)16U  /* bit position in CFGR reg */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup CRS_LL_Exported_Constants CRS Exported Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EC_GET_FLAG Get Flags Defines
 | 
			
		||||
  * @brief    Flags defines which can be used with LL_CRS_ReadReg function
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_ISR_SYNCOKF                 CRS_ISR_SYNCOKF
 | 
			
		||||
#define LL_CRS_ISR_SYNCWARNF               CRS_ISR_SYNCWARNF
 | 
			
		||||
#define LL_CRS_ISR_ERRF                    CRS_ISR_ERRF
 | 
			
		||||
#define LL_CRS_ISR_ESYNCF                  CRS_ISR_ESYNCF
 | 
			
		||||
#define LL_CRS_ISR_SYNCERR                 CRS_ISR_SYNCERR
 | 
			
		||||
#define LL_CRS_ISR_SYNCMISS                CRS_ISR_SYNCMISS
 | 
			
		||||
#define LL_CRS_ISR_TRIMOVF                 CRS_ISR_TRIMOVF
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EC_IT IT Defines
 | 
			
		||||
  * @brief    IT defines which can be used with LL_CRS_ReadReg and  LL_CRS_WriteReg functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_CR_SYNCOKIE                 CRS_CR_SYNCOKIE
 | 
			
		||||
#define LL_CRS_CR_SYNCWARNIE               CRS_CR_SYNCWARNIE
 | 
			
		||||
#define LL_CRS_CR_ERRIE                    CRS_CR_ERRIE
 | 
			
		||||
#define LL_CRS_CR_ESYNCIE                  CRS_CR_ESYNCIE
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EC_SYNC_DIV Synchronization Signal Divider
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_SYNC_DIV_1                  ((uint32_t)0x00U)                         /*!< Synchro Signal not divided (default) */
 | 
			
		||||
#define LL_CRS_SYNC_DIV_2                  CRS_CFGR_SYNCDIV_0                        /*!< Synchro Signal divided by 2 */
 | 
			
		||||
#define LL_CRS_SYNC_DIV_4                  CRS_CFGR_SYNCDIV_1                        /*!< Synchro Signal divided by 4 */
 | 
			
		||||
#define LL_CRS_SYNC_DIV_8                  (CRS_CFGR_SYNCDIV_1 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 8 */
 | 
			
		||||
#define LL_CRS_SYNC_DIV_16                 CRS_CFGR_SYNCDIV_2                        /*!< Synchro Signal divided by 16 */
 | 
			
		||||
#define LL_CRS_SYNC_DIV_32                 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_0) /*!< Synchro Signal divided by 32 */
 | 
			
		||||
#define LL_CRS_SYNC_DIV_64                 (CRS_CFGR_SYNCDIV_2 | CRS_CFGR_SYNCDIV_1) /*!< Synchro Signal divided by 64 */
 | 
			
		||||
#define LL_CRS_SYNC_DIV_128                CRS_CFGR_SYNCDIV                          /*!< Synchro Signal divided by 128 */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EC_SYNC_SOURCE Synchronization Signal Source
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_SYNC_SOURCE_GPIO            ((uint32_t)0x00U)       /*!< Synchro Signal soucre GPIO */
 | 
			
		||||
#define LL_CRS_SYNC_SOURCE_LSE             CRS_CFGR_SYNCSRC_0      /*!< Synchro Signal source LSE */
 | 
			
		||||
#define LL_CRS_SYNC_SOURCE_USB             CRS_CFGR_SYNCSRC_1      /*!< Synchro Signal source USB SOF (default)*/
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EC_SYNC_POLARITY Synchronization Signal Polarity
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_SYNC_POLARITY_RISING        ((uint32_t)0x00U)     /*!< Synchro Active on rising edge (default) */
 | 
			
		||||
#define LL_CRS_SYNC_POLARITY_FALLING       CRS_CFGR_SYNCPOL      /*!< Synchro Active on falling edge */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EC_FREQERRORDIR Frequency Error Direction
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_FREQ_ERROR_DIR_UP             ((uint32_t)0x00U)         /*!< Upcounting direction, the actual frequency is above the target */
 | 
			
		||||
#define LL_CRS_FREQ_ERROR_DIR_DOWN           ((uint32_t)CRS_ISR_FEDIR) /*!< Downcounting direction, the actual frequency is below the target */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EC_DEFAULTVALUES Default Values
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Reset value of the RELOAD field
 | 
			
		||||
  * @note The reset value of the RELOAD field corresponds to a target frequency of 48 MHz
 | 
			
		||||
  *       and a synchronization signal frequency of 1 kHz (SOF signal from USB)
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_RELOADVALUE_DEFAULT         ((uint32_t)0xBB7FU)      
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Reset value of Frequency error limit.
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_ERRORLIMIT_DEFAULT          ((uint32_t)0x22U)      
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Reset value of the HSI48 Calibration field
 | 
			
		||||
  * @note The default value is 32, which corresponds to the middle of the trimming interval. 
 | 
			
		||||
  *       The trimming step is around 67 kHz between two consecutive TRIM steps. 
 | 
			
		||||
  *       A higher TRIM value corresponds to a higher output frequency
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_HSI48CALIBRATION_DEFAULT    ((uint32_t)0x20U)      
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */ 
 | 
			
		||||
  
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup CRS_LL_Exported_Macros CRS Exported Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EM_WRITE_READ Common Write and read registers Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write a value in CRS register
 | 
			
		||||
  * @param  __INSTANCE__ CRS Instance
 | 
			
		||||
  * @param  __REG__ Register to be written
 | 
			
		||||
  * @param  __VALUE__ Value to be written in the register
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Read a value in CRS register
 | 
			
		||||
  * @param  __INSTANCE__ CRS Instance
 | 
			
		||||
  * @param  __REG__ Register to be read
 | 
			
		||||
  * @retval Register value
 | 
			
		||||
  */
 | 
			
		||||
#define LL_CRS_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EM_Exported_Macros_Calculate_Reload Exported_Macros_Calculate_Reload
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Macro to calculate reload value to be set in CRS register according to target and sync frequencies
 | 
			
		||||
  * @note   The RELOAD value should be selected according to the ratio between 
 | 
			
		||||
  *         the target frequency and the frequency of the synchronization source after
 | 
			
		||||
  *         prescaling. It is then decreased by one in order to reach the expected
 | 
			
		||||
  *         synchronization on the zero value. The formula is the following:
 | 
			
		||||
  *              RELOAD = (fTARGET / fSYNC) -1
 | 
			
		||||
  * @param  __FTARGET__ Target frequency (value in Hz)
 | 
			
		||||
  * @param  __FSYNC__ Synchronization signal frequency (value in Hz)
 | 
			
		||||
  * @retval Reload value (in Hz)
 | 
			
		||||
  */
 | 
			
		||||
#define __LL_CRS_CALC_CALCULATE_RELOADVALUE(__FTARGET__, __FSYNC__) (((__FTARGET__) / (__FSYNC__)) - 1U)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup CRS_LL_Exported_Functions CRS Exported Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EF_Configuration Configuration
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable Frequency error counter
 | 
			
		||||
  * @note When this bit is set, the CRS_CFGR register is write-protected and cannot be modified
 | 
			
		||||
  * @rmtoll CR           CEN           LL_CRS_EnableFreqErrorCounter
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_EnableFreqErrorCounter(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(CRS->CR, CRS_CR_CEN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable Frequency error counter
 | 
			
		||||
  * @rmtoll CR           CEN           LL_CRS_DisableFreqErrorCounter
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_DisableFreqErrorCounter(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(CRS->CR, CRS_CR_CEN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Frequency error counter is enabled or not
 | 
			
		||||
  * @rmtoll CR           CEN           LL_CRS_IsEnabledFreqErrorCounter
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledFreqErrorCounter(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->CR, CRS_CR_CEN) == (CRS_CR_CEN));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable Automatic trimming counter
 | 
			
		||||
  * @rmtoll CR           AUTOTRIMEN    LL_CRS_EnableAutoTrimming
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_EnableAutoTrimming(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable Automatic trimming counter
 | 
			
		||||
  * @rmtoll CR           AUTOTRIMEN    LL_CRS_DisableAutoTrimming
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_DisableAutoTrimming(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(CRS->CR, CRS_CR_AUTOTRIMEN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Automatic trimming is enabled or not
 | 
			
		||||
  * @rmtoll CR           AUTOTRIMEN    LL_CRS_IsEnabledAutoTrimming
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledAutoTrimming(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->CR, CRS_CR_AUTOTRIMEN) == (CRS_CR_AUTOTRIMEN));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set HSI48 oscillator smooth trimming
 | 
			
		||||
  * @note   When the AUTOTRIMEN bit is set, this field is controlled by hardware and is read-only
 | 
			
		||||
  * @rmtoll CR           TRIM          LL_CRS_SetHSI48SmoothTrimming
 | 
			
		||||
  * @param  Value a number between Min_Data = 0 and Max_Data = 63
 | 
			
		||||
  * @note   Default value can be set thanks to @ref LL_CRS_HSI48CALIBRATION_DEFAULT 
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_SetHSI48SmoothTrimming(uint32_t Value)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(CRS->CR, CRS_CR_TRIM, Value << CRS_POSITION_TRIM);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get HSI48 oscillator smooth trimming
 | 
			
		||||
  * @rmtoll CR           TRIM          LL_CRS_GetHSI48SmoothTrimming
 | 
			
		||||
  * @retval a number between Min_Data = 0 and Max_Data = 63
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_GetHSI48SmoothTrimming(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRS->CR, CRS_CR_TRIM) >> CRS_POSITION_TRIM);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set counter reload value
 | 
			
		||||
  * @rmtoll CFGR         RELOAD        LL_CRS_SetReloadCounter
 | 
			
		||||
  * @param  Value a number between Min_Data = 0 and Max_Data = 0xFFFF
 | 
			
		||||
  * @note   Default value can be set thanks to @ref LL_CRS_RELOADVALUE_DEFAULT 
 | 
			
		||||
  *         Otherwise it can be calculated in using macro @ref __LL_CRS_CALC_CALCULATE_RELOADVALUE (_FTARGET_, _FSYNC_)
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_SetReloadCounter(uint32_t Value)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(CRS->CFGR, CRS_CFGR_RELOAD, Value);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get counter reload value
 | 
			
		||||
  * @rmtoll CFGR         RELOAD        LL_CRS_GetReloadCounter
 | 
			
		||||
  * @retval a number between Min_Data = 0 and Max_Data = 0xFFFF
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_GetReloadCounter(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_RELOAD));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set frequency error limit
 | 
			
		||||
  * @rmtoll CFGR         FELIM         LL_CRS_SetFreqErrorLimit
 | 
			
		||||
  * @param  Value a number between Min_Data = 0 and Max_Data = 255
 | 
			
		||||
  * @note   Default value can be set thanks to @ref LL_CRS_ERRORLIMIT_DEFAULT 
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_SetFreqErrorLimit(uint32_t Value)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(CRS->CFGR, CRS_CFGR_FELIM, Value << CRS_POSITION_FELIM);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get frequency error limit
 | 
			
		||||
  * @rmtoll CFGR         FELIM         LL_CRS_GetFreqErrorLimit
 | 
			
		||||
  * @retval A number between Min_Data = 0 and Max_Data = 255
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorLimit(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_FELIM) >> CRS_POSITION_FELIM);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set division factor for SYNC signal
 | 
			
		||||
  * @rmtoll CFGR         SYNCDIV       LL_CRS_SetSyncDivider
 | 
			
		||||
  * @param  Divider This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_1
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_2
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_4
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_8
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_16
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_32
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_64
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_128
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_SetSyncDivider(uint32_t Divider)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCDIV, Divider);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get division factor for SYNC signal
 | 
			
		||||
  * @rmtoll CFGR         SYNCDIV       LL_CRS_GetSyncDivider
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_1
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_2
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_4
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_8
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_16
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_32
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_64
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_128
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_GetSyncDivider(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCDIV));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set SYNC signal source
 | 
			
		||||
  * @rmtoll CFGR         SYNCSRC       LL_CRS_SetSyncSignalSource
 | 
			
		||||
  * @param  Source This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_SOURCE_GPIO
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_SOURCE_LSE
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_SOURCE_USB
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_SetSyncSignalSource(uint32_t Source)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCSRC, Source);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get SYNC signal source
 | 
			
		||||
  * @rmtoll CFGR         SYNCSRC       LL_CRS_GetSyncSignalSource
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_SOURCE_GPIO
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_SOURCE_LSE
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_SOURCE_USB
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_GetSyncSignalSource(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCSRC));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set input polarity for the SYNC signal source
 | 
			
		||||
  * @rmtoll CFGR         SYNCPOL       LL_CRS_SetSyncPolarity
 | 
			
		||||
  * @param  Polarity This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_POLARITY_RISING
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_POLARITY_FALLING
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_SetSyncPolarity(uint32_t Polarity)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(CRS->CFGR, CRS_CFGR_SYNCPOL, Polarity);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get input polarity for the SYNC signal source
 | 
			
		||||
  * @rmtoll CFGR         SYNCPOL       LL_CRS_GetSyncPolarity
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_POLARITY_RISING
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_POLARITY_FALLING
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_GetSyncPolarity(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRS->CFGR, CRS_CFGR_SYNCPOL));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure CRS for the synchronization
 | 
			
		||||
  * @rmtoll CR           TRIM          LL_CRS_ConfigSynchronization\n
 | 
			
		||||
  *         CFGR         RELOAD        LL_CRS_ConfigSynchronization\n
 | 
			
		||||
  *         CFGR         FELIM         LL_CRS_ConfigSynchronization\n
 | 
			
		||||
  *         CFGR         SYNCDIV       LL_CRS_ConfigSynchronization\n
 | 
			
		||||
  *         CFGR         SYNCSRC       LL_CRS_ConfigSynchronization\n
 | 
			
		||||
  *         CFGR         SYNCPOL       LL_CRS_ConfigSynchronization
 | 
			
		||||
  * @param  HSI48CalibrationValue a number between Min_Data = 0 and Max_Data = 63
 | 
			
		||||
  * @param  ErrorLimitValue a number between Min_Data = 0 and Max_Data = 0xFFFF
 | 
			
		||||
  * @param  ReloadValue a number between Min_Data = 0 and Max_Data = 255
 | 
			
		||||
  * @param  Settings This parameter can be a combination of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_DIV_1 or @ref LL_CRS_SYNC_DIV_2 or @ref LL_CRS_SYNC_DIV_4 or @ref LL_CRS_SYNC_DIV_8
 | 
			
		||||
  *              or @ref LL_CRS_SYNC_DIV_16 or @ref LL_CRS_SYNC_DIV_32 or @ref LL_CRS_SYNC_DIV_64 or @ref LL_CRS_SYNC_DIV_128
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_SOURCE_GPIO or @ref LL_CRS_SYNC_SOURCE_LSE or @ref LL_CRS_SYNC_SOURCE_USB
 | 
			
		||||
  *         @arg @ref LL_CRS_SYNC_POLARITY_RISING or @ref LL_CRS_SYNC_POLARITY_FALLING
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_ConfigSynchronization(uint32_t HSI48CalibrationValue, uint32_t ErrorLimitValue, uint32_t ReloadValue, uint32_t Settings)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(CRS->CR, CRS_CR_TRIM, HSI48CalibrationValue);
 | 
			
		||||
  MODIFY_REG(CRS->CFGR, 
 | 
			
		||||
             CRS_CFGR_RELOAD | CRS_CFGR_FELIM | CRS_CFGR_SYNCDIV | CRS_CFGR_SYNCSRC | CRS_CFGR_SYNCPOL, 
 | 
			
		||||
             ReloadValue | (ErrorLimitValue << CRS_POSITION_FELIM) | Settings);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EF_CRS_Management CRS_Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Generate software SYNC event
 | 
			
		||||
  * @rmtoll CR           SWSYNC        LL_CRS_GenerateEvent_SWSYNC
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_GenerateEvent_SWSYNC(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(CRS->CR, CRS_CR_SWSYNC);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get the frequency error direction latched in the time of the last 
 | 
			
		||||
  * SYNC event
 | 
			
		||||
  * @rmtoll ISR          FEDIR         LL_CRS_GetFreqErrorDirection
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_CRS_FREQ_ERROR_DIR_UP
 | 
			
		||||
  *         @arg @ref LL_CRS_FREQ_ERROR_DIR_DOWN
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorDirection(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FEDIR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get the frequency error counter value latched in the time of the last SYNC event
 | 
			
		||||
  * @rmtoll ISR          FECAP         LL_CRS_GetFreqErrorCapture
 | 
			
		||||
  * @retval A number between Min_Data = 0x0000 and Max_Data = 0xFFFF
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_GetFreqErrorCapture(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(CRS->ISR, CRS_ISR_FECAP) >> CRS_POSITION_FECAP);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EF_FLAG_Management FLAG_Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if SYNC event OK signal occurred or not
 | 
			
		||||
  * @rmtoll ISR          SYNCOKF       LL_CRS_IsActiveFlag_SYNCOK
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCOK(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->ISR, CRS_ISR_SYNCOKF) == (CRS_ISR_SYNCOKF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if SYNC warning signal occurred or not
 | 
			
		||||
  * @rmtoll ISR          SYNCWARNF     LL_CRS_IsActiveFlag_SYNCWARN
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCWARN(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->ISR, CRS_ISR_SYNCWARNF) == (CRS_ISR_SYNCWARNF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Synchronization or trimming error signal occurred or not
 | 
			
		||||
  * @rmtoll ISR          ERRF          LL_CRS_IsActiveFlag_ERR
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ERR(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->ISR, CRS_ISR_ERRF) == (CRS_ISR_ERRF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Expected SYNC signal occurred or not
 | 
			
		||||
  * @rmtoll ISR          ESYNCF        LL_CRS_IsActiveFlag_ESYNC
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_ESYNC(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->ISR, CRS_ISR_ESYNCF) == (CRS_ISR_ESYNCF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if SYNC error signal occurred or not
 | 
			
		||||
  * @rmtoll ISR          SYNCERR       LL_CRS_IsActiveFlag_SYNCERR
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCERR(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->ISR, CRS_ISR_SYNCERR) == (CRS_ISR_SYNCERR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if SYNC missed error signal occurred or not
 | 
			
		||||
  * @rmtoll ISR          SYNCMISS      LL_CRS_IsActiveFlag_SYNCMISS
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_SYNCMISS(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->ISR, CRS_ISR_SYNCMISS) == (CRS_ISR_SYNCMISS));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Trimming overflow or underflow occurred or not
 | 
			
		||||
  * @rmtoll ISR          TRIMOVF       LL_CRS_IsActiveFlag_TRIMOVF
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsActiveFlag_TRIMOVF(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->ISR, CRS_ISR_TRIMOVF) == (CRS_ISR_TRIMOVF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Clear the SYNC event OK flag
 | 
			
		||||
  * @rmtoll ICR          SYNCOKC       LL_CRS_ClearFlag_SYNCOK
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_ClearFlag_SYNCOK(void)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(CRS->ICR, CRS_ICR_SYNCOKC);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Clear the  SYNC warning flag
 | 
			
		||||
  * @rmtoll ICR          SYNCWARNC     LL_CRS_ClearFlag_SYNCWARN
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_ClearFlag_SYNCWARN(void)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(CRS->ICR, CRS_ICR_SYNCWARNC);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Clear TRIMOVF, SYNCMISS and SYNCERR bits and consequently also 
 | 
			
		||||
  * the ERR flag
 | 
			
		||||
  * @rmtoll ICR          ERRC          LL_CRS_ClearFlag_ERR
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_ClearFlag_ERR(void)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(CRS->ICR, CRS_ICR_ERRC);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Clear Expected SYNC flag
 | 
			
		||||
  * @rmtoll ICR          ESYNCC        LL_CRS_ClearFlag_ESYNC
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_ClearFlag_ESYNC(void)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(CRS->ICR, CRS_ICR_ESYNCC);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup CRS_LL_EF_IT_Management IT_Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable SYNC event OK interrupt
 | 
			
		||||
  * @rmtoll CR           SYNCOKIE      LL_CRS_EnableIT_SYNCOK
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_EnableIT_SYNCOK(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(CRS->CR, CRS_CR_SYNCOKIE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable SYNC event OK interrupt
 | 
			
		||||
  * @rmtoll CR           SYNCOKIE      LL_CRS_DisableIT_SYNCOK
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_DisableIT_SYNCOK(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(CRS->CR, CRS_CR_SYNCOKIE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if SYNC event OK interrupt is enabled or not
 | 
			
		||||
  * @rmtoll CR           SYNCOKIE      LL_CRS_IsEnabledIT_SYNCOK
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCOK(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->CR, CRS_CR_SYNCOKIE) == (CRS_CR_SYNCOKIE));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable SYNC warning interrupt
 | 
			
		||||
  * @rmtoll CR           SYNCWARNIE    LL_CRS_EnableIT_SYNCWARN
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_EnableIT_SYNCWARN(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable SYNC warning interrupt
 | 
			
		||||
  * @rmtoll CR           SYNCWARNIE    LL_CRS_DisableIT_SYNCWARN
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_DisableIT_SYNCWARN(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(CRS->CR, CRS_CR_SYNCWARNIE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if SYNC warning interrupt is enabled or not
 | 
			
		||||
  * @rmtoll CR           SYNCWARNIE    LL_CRS_IsEnabledIT_SYNCWARN
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_SYNCWARN(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->CR, CRS_CR_SYNCWARNIE) == (CRS_CR_SYNCWARNIE));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable Synchronization or trimming error interrupt
 | 
			
		||||
  * @rmtoll CR           ERRIE         LL_CRS_EnableIT_ERR
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_EnableIT_ERR(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(CRS->CR, CRS_CR_ERRIE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable Synchronization or trimming error interrupt
 | 
			
		||||
  * @rmtoll CR           ERRIE         LL_CRS_DisableIT_ERR
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_DisableIT_ERR(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(CRS->CR, CRS_CR_ERRIE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Synchronization or trimming error interrupt is enabled or not
 | 
			
		||||
  * @rmtoll CR           ERRIE         LL_CRS_IsEnabledIT_ERR
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ERR(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->CR, CRS_CR_ERRIE) == (CRS_CR_ERRIE));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable Expected SYNC interrupt
 | 
			
		||||
  * @rmtoll CR           ESYNCIE       LL_CRS_EnableIT_ESYNC
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_EnableIT_ESYNC(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(CRS->CR, CRS_CR_ESYNCIE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable Expected SYNC interrupt
 | 
			
		||||
  * @rmtoll CR           ESYNCIE       LL_CRS_DisableIT_ESYNC
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_CRS_DisableIT_ESYNC(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(CRS->CR, CRS_CR_ESYNCIE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Expected SYNC interrupt is enabled or not
 | 
			
		||||
  * @rmtoll CR           ESYNCIE       LL_CRS_IsEnabledIT_ESYNC
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_CRS_IsEnabledIT_ESYNC(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(CRS->CR, CRS_CR_ESYNCIE) == (CRS_CR_ESYNCIE));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
/** @defgroup CRS_LL_EF_Init Initialization and de-initialization functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
  
 | 
			
		||||
ErrorStatus LL_CRS_DeInit(void);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined(CRS) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32L0xx_LL_CRS_H */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,284 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_dac.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   DAC LL module driver
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_dac.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
  #include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
  #define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (DAC1)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup DAC_LL DAC
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/** @addtogroup DAC_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(DAC_CHANNEL2_SUPPORT)
 | 
			
		||||
#define IS_LL_DAC_CHANNEL(__DACX__, __DAC_CHANNEL__)                           \
 | 
			
		||||
  (                                                                            \
 | 
			
		||||
      ((__DAC_CHANNEL__) == LL_DAC_CHANNEL_1)                                  \
 | 
			
		||||
   || ((__DAC_CHANNEL__) == LL_DAC_CHANNEL_2)                                  \
 | 
			
		||||
  )
 | 
			
		||||
#else
 | 
			
		||||
#define IS_LL_DAC_CHANNEL(__DACX__, __DAC_CHANNEL__)                           \
 | 
			
		||||
  (                                                                            \
 | 
			
		||||
   ((__DAC_CHANNEL__) == LL_DAC_CHANNEL_1)                                     \
 | 
			
		||||
  )
 | 
			
		||||
#endif /* DAC_CHANNEL2_SUPPORT */
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DAC_TRIGGER_SOURCE(__TRIGGER_SOURCE__)                           \
 | 
			
		||||
  (   ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_SOFTWARE)                           \
 | 
			
		||||
   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM2_TRGO)                      \
 | 
			
		||||
   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM3_TRGO)                      \
 | 
			
		||||
   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM3_CH3)                       \
 | 
			
		||||
   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM6_TRGO)                      \
 | 
			
		||||
   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM7_TRGO)                      \
 | 
			
		||||
   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_TIM21_TRGO)                     \
 | 
			
		||||
   || ((__TRIGGER_SOURCE__) == LL_DAC_TRIG_EXT_EXTI_LINE9)                     \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DAC_WAVE_AUTO_GENER_MODE(__WAVE_AUTO_GENERATION_MODE__)           \
 | 
			
		||||
  (   ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_NONE)     \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_NOISE)    \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_MODE__) == LL_DAC_WAVE_AUTO_GENERATION_TRIANGLE) \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DAC_WAVE_AUTO_GENER_CONFIG(__WAVE_AUTO_GENERATION_CONFIG__)      \
 | 
			
		||||
  (   ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BIT0)     \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS1_0)  \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS2_0)  \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS3_0)  \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS4_0)  \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS5_0)  \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS6_0)  \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS7_0)  \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS8_0)  \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS9_0)  \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS10_0) \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_NOISE_LFSR_UNMASK_BITS11_0) \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_1)       \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_3)       \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_7)       \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_15)      \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_31)      \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_63)      \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_127)     \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_255)     \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_511)     \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_1023)    \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_2047)    \
 | 
			
		||||
   || ((__WAVE_AUTO_GENERATION_CONFIG__) == LL_DAC_TRIANGLE_AMPLITUDE_4095)    \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DAC_OUTPUT_BUFFER(__OUTPUT_BUFFER__)                             \
 | 
			
		||||
  (   ((__OUTPUT_BUFFER__) == LL_DAC_OUTPUT_BUFFER_ENABLE)                     \
 | 
			
		||||
   || ((__OUTPUT_BUFFER__) == LL_DAC_OUTPUT_BUFFER_DISABLE)                    \
 | 
			
		||||
  )
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup DAC_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup DAC_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize registers of the selected DAC instance
 | 
			
		||||
  *         to their default reset values.
 | 
			
		||||
  * @param  DACx DAC instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: DAC registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_DAC_DeInit(DAC_TypeDef *DACx)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_DAC_ALL_INSTANCE(DACx));
 | 
			
		||||
  
 | 
			
		||||
  /* Force reset of DAC clock */
 | 
			
		||||
  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_DAC1);
 | 
			
		||||
  
 | 
			
		||||
  /* Release reset of DAC clock */
 | 
			
		||||
  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_DAC1);
 | 
			
		||||
  
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize some features of DAC instance.
 | 
			
		||||
  * @note   The setting of these parameters by function @ref LL_DAC_Init()
 | 
			
		||||
  *         is conditioned to DAC state:
 | 
			
		||||
  *         DAC instance must be disabled.
 | 
			
		||||
  * @param  DACx DAC instance
 | 
			
		||||
  * @param  DAC_Channel This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_DAC_CHANNEL_1
 | 
			
		||||
  *         @arg @ref LL_DAC_CHANNEL_2 (1)
 | 
			
		||||
  *         
 | 
			
		||||
  *         (1) On this STM32 family, parameter not available on all devices.
 | 
			
		||||
  *             Refer to device datasheet for channels availability.
 | 
			
		||||
  * @param  DAC_InitStruct Pointer to a @ref LL_DAC_InitTypeDef structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: DAC registers are initialized
 | 
			
		||||
  *          - ERROR: DAC registers are not initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_DAC_Init(DAC_TypeDef *DACx, uint32_t DAC_Channel, LL_DAC_InitTypeDef *DAC_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
  
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_DAC_ALL_INSTANCE(DACx));
 | 
			
		||||
  assert_param(IS_LL_DAC_CHANNEL(DACx, DAC_Channel));
 | 
			
		||||
  assert_param(IS_LL_DAC_TRIGGER_SOURCE(DAC_InitStruct->TriggerSource));
 | 
			
		||||
  assert_param(IS_LL_DAC_OUTPUT_BUFFER(DAC_InitStruct->OutputBuffer));
 | 
			
		||||
  assert_param(IS_LL_DAC_WAVE_AUTO_GENER_MODE(DAC_InitStruct->WaveAutoGeneration));
 | 
			
		||||
  if (DAC_InitStruct->WaveAutoGeneration != LL_DAC_WAVE_AUTO_GENERATION_NONE)
 | 
			
		||||
  {
 | 
			
		||||
    assert_param(IS_LL_DAC_WAVE_AUTO_GENER_CONFIG(DAC_InitStruct->WaveAutoGenerationConfig));
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  /* Note: Hardware constraint (refer to description of this function)        */
 | 
			
		||||
  /*       DAC instance must be disabled.                                     */
 | 
			
		||||
  if(LL_DAC_IsEnabled(DACx, DAC_Channel) == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    /* Configuration of DAC channel:                                          */
 | 
			
		||||
    /*  - TriggerSource                                                       */
 | 
			
		||||
    /*  - WaveAutoGeneration                                                  */
 | 
			
		||||
    /*  - OutputBuffer                                                        */
 | 
			
		||||
    if (DAC_InitStruct->WaveAutoGeneration != LL_DAC_WAVE_AUTO_GENERATION_NONE)
 | 
			
		||||
    {
 | 
			
		||||
      MODIFY_REG(DACx->CR,
 | 
			
		||||
                 (  DAC_CR_TSEL1
 | 
			
		||||
                  | DAC_CR_WAVE1
 | 
			
		||||
                  | DAC_CR_MAMP1
 | 
			
		||||
                  | DAC_CR_BOFF1
 | 
			
		||||
                 ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
 | 
			
		||||
                ,
 | 
			
		||||
                 (  DAC_InitStruct->TriggerSource
 | 
			
		||||
                  | DAC_InitStruct->WaveAutoGeneration
 | 
			
		||||
                  | DAC_InitStruct->WaveAutoGenerationConfig
 | 
			
		||||
                  | DAC_InitStruct->OutputBuffer
 | 
			
		||||
                 ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
 | 
			
		||||
                );
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      MODIFY_REG(DACx->CR,
 | 
			
		||||
                 (  DAC_CR_TSEL1
 | 
			
		||||
                  | DAC_CR_WAVE1
 | 
			
		||||
                  | DAC_CR_BOFF1
 | 
			
		||||
                 ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
 | 
			
		||||
                ,
 | 
			
		||||
                 (  DAC_InitStruct->TriggerSource
 | 
			
		||||
                  | LL_DAC_WAVE_AUTO_GENERATION_NONE
 | 
			
		||||
                  | DAC_InitStruct->OutputBuffer
 | 
			
		||||
                 ) << (DAC_Channel & DAC_CR_CHX_BITOFFSET_MASK)
 | 
			
		||||
                );
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* Initialization error: DAC instance is not disabled.                    */
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Set each @ref LL_DAC_InitTypeDef field to default value.
 | 
			
		||||
  * @param DAC_InitStruct pointer to a @ref LL_DAC_InitTypeDef structure
 | 
			
		||||
  *                       whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_DAC_StructInit(LL_DAC_InitTypeDef *DAC_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set DAC_InitStruct fields to default values */
 | 
			
		||||
  DAC_InitStruct->TriggerSource            = LL_DAC_TRIG_SOFTWARE;
 | 
			
		||||
  DAC_InitStruct->WaveAutoGeneration       = LL_DAC_WAVE_AUTO_GENERATION_NONE;
 | 
			
		||||
  /* Note: Parameter discarded if wave auto generation is disabled,           */
 | 
			
		||||
  /*       set anyway to its default value.                                   */
 | 
			
		||||
  DAC_InitStruct->WaveAutoGenerationConfig = LL_DAC_NOISE_LFSR_UNMASK_BIT0;
 | 
			
		||||
  DAC_InitStruct->OutputBuffer             = LL_DAC_OUTPUT_BUFFER_ENABLE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* DAC1 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,397 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_dma.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   DMA LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_dma.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (DMA1)
 | 
			
		||||
 | 
			
		||||
/** @defgroup DMA_LL DMA
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup DMA_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define IS_LL_DMA_DIRECTION(__VALUE__)          (((__VALUE__) == LL_DMA_DIRECTION_PERIPH_TO_MEMORY) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_DIRECTION_MEMORY_TO_PERIPH) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_DIRECTION_MEMORY_TO_MEMORY))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DMA_MODE(__VALUE__)               (((__VALUE__) == LL_DMA_MODE_NORMAL) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_MODE_CIRCULAR))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DMA_PERIPHINCMODE(__VALUE__)      (((__VALUE__) == LL_DMA_PERIPH_INCREMENT) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_PERIPH_NOINCREMENT))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DMA_MEMORYINCMODE(__VALUE__)      (((__VALUE__) == LL_DMA_MEMORY_INCREMENT) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_MEMORY_NOINCREMENT))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DMA_PERIPHDATASIZE(__VALUE__)     (((__VALUE__) == LL_DMA_PDATAALIGN_BYTE)      || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_PDATAALIGN_HALFWORD)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_PDATAALIGN_WORD))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DMA_MEMORYDATASIZE(__VALUE__)     (((__VALUE__) == LL_DMA_MDATAALIGN_BYTE)      || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_MDATAALIGN_HALFWORD)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_MDATAALIGN_WORD))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DMA_NBDATA(__VALUE__)             ((__VALUE__)  <= (uint32_t)0x0000FFFFU)
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DMA_PERIPHREQUEST(__VALUE__)      (((__VALUE__) == LL_DMA_REQUEST_0)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_1)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_2)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_3)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_4)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_5)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_6)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_7)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_8)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_9)  || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_10) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_11) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_12) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_13) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_14) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_REQUEST_15))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_DMA_PRIORITY(__VALUE__)           (((__VALUE__) == LL_DMA_PRIORITY_LOW)    || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_PRIORITY_MEDIUM) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_PRIORITY_HIGH)   || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_DMA_PRIORITY_VERYHIGH))
 | 
			
		||||
 | 
			
		||||
#if defined (DMA1_Channel6) && defined (DMA1_Channel7)
 | 
			
		||||
#define IS_LL_DMA_ALL_CHANNEL_INSTANCE(INSTANCE, CHANNEL)  ((((INSTANCE) == DMA1) && \
 | 
			
		||||
                                                            (((CHANNEL) == LL_DMA_CHANNEL_1)|| \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_2) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_3) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_4) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_5) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_6) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_7))))
 | 
			
		||||
#elif defined (DMA1_Channel6)
 | 
			
		||||
#define IS_LL_DMA_ALL_CHANNEL_INSTANCE(INSTANCE, CHANNEL)  ((((INSTANCE) == DMA1) && \
 | 
			
		||||
                                                            (((CHANNEL) == LL_DMA_CHANNEL_1)|| \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_2) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_3) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_4) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_5) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_6))))
 | 
			
		||||
#else
 | 
			
		||||
#define IS_LL_DMA_ALL_CHANNEL_INSTANCE(INSTANCE, CHANNEL)  ((((INSTANCE) == DMA1) && \
 | 
			
		||||
                                                            (((CHANNEL) == LL_DMA_CHANNEL_1)|| \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_2) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_3) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_4) || \
 | 
			
		||||
                                                            ((CHANNEL) == LL_DMA_CHANNEL_5))))
 | 
			
		||||
#endif /* DMA1_Channel6 && DMA1_Channel7 */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup DMA_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup DMA_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize the DMA registers to their default reset values.
 | 
			
		||||
  * @param  DMAx DMAx Instance
 | 
			
		||||
  * @param  Channel This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_1
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_2
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_3
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_4
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_5
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_6 (*)
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_7 (*)
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_ALL
 | 
			
		||||
  *
 | 
			
		||||
  *         (*) value not defined in all devices
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: DMA registers are de-initialized
 | 
			
		||||
  *          - ERROR: DMA registers are not de-initialized
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_DMA_DeInit(DMA_TypeDef *DMAx, uint32_t Channel)
 | 
			
		||||
{
 | 
			
		||||
  DMA_Channel_TypeDef *tmp = (DMA_Channel_TypeDef *)DMA1_Channel1;
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
 | 
			
		||||
  /* Check the DMA Instance DMAx and Channel parameters*/
 | 
			
		||||
  assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel) || (Channel == LL_DMA_CHANNEL_ALL));
 | 
			
		||||
 | 
			
		||||
  if (Channel == LL_DMA_CHANNEL_ALL)
 | 
			
		||||
  {
 | 
			
		||||
    if (DMAx == DMA1)
 | 
			
		||||
    {
 | 
			
		||||
      /* Force reset of DMA clock */
 | 
			
		||||
      LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_DMA1);
 | 
			
		||||
 | 
			
		||||
      /* Release reset of DMA clock */
 | 
			
		||||
      LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_DMA1);
 | 
			
		||||
    }
 | 
			
		||||
#if defined(DMA2)
 | 
			
		||||
    else if (DMAx == DMA2)
 | 
			
		||||
    {
 | 
			
		||||
      /* Force reset of DMA clock */
 | 
			
		||||
      LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_DMA2);
 | 
			
		||||
 | 
			
		||||
      /* Release reset of DMA clock */
 | 
			
		||||
      LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_DMA2);
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      status = ERROR;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    tmp = (DMA_Channel_TypeDef *)(__LL_DMA_GET_CHANNEL_INSTANCE(DMAx, Channel));
 | 
			
		||||
 | 
			
		||||
    /* Disable the selected DMAx_Channely */
 | 
			
		||||
    CLEAR_BIT(tmp->CCR, DMA_CCR_EN);
 | 
			
		||||
 | 
			
		||||
    /* Reset DMAx_Channely control register */
 | 
			
		||||
    LL_DMA_WriteReg(tmp, CCR, 0U);
 | 
			
		||||
 | 
			
		||||
    /* Reset DMAx_Channely remaining bytes register */
 | 
			
		||||
    LL_DMA_WriteReg(tmp, CNDTR, 0U);
 | 
			
		||||
 | 
			
		||||
    /* Reset DMAx_Channely peripheral address register */
 | 
			
		||||
    LL_DMA_WriteReg(tmp, CPAR, 0U);
 | 
			
		||||
 | 
			
		||||
    /* Reset DMAx_Channely memory address register */
 | 
			
		||||
    LL_DMA_WriteReg(tmp, CMAR, 0U);
 | 
			
		||||
 | 
			
		||||
    /* Reset Request register field for DMAx Channel */
 | 
			
		||||
    LL_DMA_SetPeriphRequest(DMAx, Channel, LL_DMA_REQUEST_0);
 | 
			
		||||
 | 
			
		||||
    if (Channel == LL_DMA_CHANNEL_1)
 | 
			
		||||
    {
 | 
			
		||||
      /* Reset interrupt pending bits for DMAx Channel1 */
 | 
			
		||||
      LL_DMA_ClearFlag_GI1(DMAx);
 | 
			
		||||
    }
 | 
			
		||||
    else if (Channel == LL_DMA_CHANNEL_2)
 | 
			
		||||
    {
 | 
			
		||||
      /* Reset interrupt pending bits for DMAx Channel2 */
 | 
			
		||||
      LL_DMA_ClearFlag_GI2(DMAx);
 | 
			
		||||
    }
 | 
			
		||||
    else if (Channel == LL_DMA_CHANNEL_3)
 | 
			
		||||
    {
 | 
			
		||||
      /* Reset interrupt pending bits for DMAx Channel3 */
 | 
			
		||||
      LL_DMA_ClearFlag_GI3(DMAx);
 | 
			
		||||
    }
 | 
			
		||||
    else if (Channel == LL_DMA_CHANNEL_4)
 | 
			
		||||
    {
 | 
			
		||||
      /* Reset interrupt pending bits for DMAx Channel4 */
 | 
			
		||||
      LL_DMA_ClearFlag_GI4(DMAx);
 | 
			
		||||
    }
 | 
			
		||||
    else if (Channel == LL_DMA_CHANNEL_5)
 | 
			
		||||
    {
 | 
			
		||||
      /* Reset interrupt pending bits for DMAx Channel5 */
 | 
			
		||||
      LL_DMA_ClearFlag_GI5(DMAx);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
#if defined(DMA1_Channel6)
 | 
			
		||||
    else if (Channel == LL_DMA_CHANNEL_6)
 | 
			
		||||
    {
 | 
			
		||||
      /* Reset interrupt pending bits for DMAx Channel6 */
 | 
			
		||||
      LL_DMA_ClearFlag_GI6(DMAx);
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(DMA1_Channel7)
 | 
			
		||||
    else if (Channel == LL_DMA_CHANNEL_7)
 | 
			
		||||
    {
 | 
			
		||||
      /* Reset interrupt pending bits for DMAx Channel7 */
 | 
			
		||||
      LL_DMA_ClearFlag_GI7(DMAx);
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      status = ERROR;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize the DMA registers according to the specified parameters in DMA_InitStruct.
 | 
			
		||||
  * @note   To convert DMAx_Channely Instance to DMAx Instance and Channely, use helper macros :
 | 
			
		||||
  *         @arg @ref __LL_DMA_GET_INSTANCE
 | 
			
		||||
  *         @arg @ref __LL_DMA_GET_CHANNEL
 | 
			
		||||
  * @param  DMAx DMAx Instance
 | 
			
		||||
  * @param  Channel This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_1
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_2
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_3
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_4
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_5
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_6 (*)
 | 
			
		||||
  *         @arg @ref LL_DMA_CHANNEL_7 (*)
 | 
			
		||||
  *
 | 
			
		||||
  *         (*) value not defined in all devices
 | 
			
		||||
  * @param  DMA_InitStruct pointer to a @ref LL_DMA_InitTypeDef structure.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: DMA registers are initialized
 | 
			
		||||
  *          - ERROR: Not applicable
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_DMA_Init(DMA_TypeDef *DMAx, uint32_t Channel, LL_DMA_InitTypeDef *DMA_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the DMA Instance DMAx and Channel parameters*/
 | 
			
		||||
  assert_param(IS_LL_DMA_ALL_CHANNEL_INSTANCE(DMAx, Channel));
 | 
			
		||||
 | 
			
		||||
  /* Check the DMA parameters from DMA_InitStruct */
 | 
			
		||||
  assert_param(IS_LL_DMA_DIRECTION(DMA_InitStruct->Direction));
 | 
			
		||||
  assert_param(IS_LL_DMA_MODE(DMA_InitStruct->Mode));
 | 
			
		||||
  assert_param(IS_LL_DMA_PERIPHINCMODE(DMA_InitStruct->PeriphOrM2MSrcIncMode));
 | 
			
		||||
  assert_param(IS_LL_DMA_MEMORYINCMODE(DMA_InitStruct->MemoryOrM2MDstIncMode));
 | 
			
		||||
  assert_param(IS_LL_DMA_PERIPHDATASIZE(DMA_InitStruct->PeriphOrM2MSrcDataSize));
 | 
			
		||||
  assert_param(IS_LL_DMA_MEMORYDATASIZE(DMA_InitStruct->MemoryOrM2MDstDataSize));
 | 
			
		||||
  assert_param(IS_LL_DMA_NBDATA(DMA_InitStruct->NbData));
 | 
			
		||||
  assert_param(IS_LL_DMA_PERIPHREQUEST(DMA_InitStruct->PeriphRequest));
 | 
			
		||||
  assert_param(IS_LL_DMA_PRIORITY(DMA_InitStruct->Priority));
 | 
			
		||||
 | 
			
		||||
  /*---------------------------- DMAx CCR Configuration ------------------------
 | 
			
		||||
   * Configure DMAx_Channely: data transfer direction, data transfer mode,
 | 
			
		||||
   *                          peripheral and memory increment mode,
 | 
			
		||||
   *                          data size alignment and  priority level with parameters :
 | 
			
		||||
   * - Direction:      DMA_CCR_DIR and DMA_CCR_MEM2MEM bits
 | 
			
		||||
   * - Mode:           DMA_CCR_CIRC bit
 | 
			
		||||
   * - PeriphOrM2MSrcIncMode:  DMA_CCR_PINC bit
 | 
			
		||||
   * - MemoryOrM2MDstIncMode:  DMA_CCR_MINC bit
 | 
			
		||||
   * - PeriphOrM2MSrcDataSize: DMA_CCR_PSIZE[1:0] bits
 | 
			
		||||
   * - MemoryOrM2MDstDataSize: DMA_CCR_MSIZE[1:0] bits
 | 
			
		||||
   * - Priority:               DMA_CCR_PL[1:0] bits
 | 
			
		||||
   */
 | 
			
		||||
  LL_DMA_ConfigTransfer(DMAx, Channel, DMA_InitStruct->Direction              | \
 | 
			
		||||
                        DMA_InitStruct->Mode                   | \
 | 
			
		||||
                        DMA_InitStruct->PeriphOrM2MSrcIncMode  | \
 | 
			
		||||
                        DMA_InitStruct->MemoryOrM2MDstIncMode  | \
 | 
			
		||||
                        DMA_InitStruct->PeriphOrM2MSrcDataSize | \
 | 
			
		||||
                        DMA_InitStruct->MemoryOrM2MDstDataSize | \
 | 
			
		||||
                        DMA_InitStruct->Priority);
 | 
			
		||||
 | 
			
		||||
  /*-------------------------- DMAx CMAR Configuration -------------------------
 | 
			
		||||
   * Configure the memory or destination base address with parameter :
 | 
			
		||||
   * - MemoryOrM2MDstAddress: DMA_CMAR_MA[31:0] bits
 | 
			
		||||
   */
 | 
			
		||||
  LL_DMA_SetMemoryAddress(DMAx, Channel, DMA_InitStruct->MemoryOrM2MDstAddress);
 | 
			
		||||
 | 
			
		||||
  /*-------------------------- DMAx CPAR Configuration -------------------------
 | 
			
		||||
   * Configure the peripheral or source base address with parameter :
 | 
			
		||||
   * - PeriphOrM2MSrcAddress: DMA_CPAR_PA[31:0] bits
 | 
			
		||||
   */
 | 
			
		||||
  LL_DMA_SetPeriphAddress(DMAx, Channel, DMA_InitStruct->PeriphOrM2MSrcAddress);
 | 
			
		||||
 | 
			
		||||
  /*--------------------------- DMAx CNDTR Configuration -----------------------
 | 
			
		||||
   * Configure the peripheral base address with parameter :
 | 
			
		||||
   * - NbData: DMA_CNDTR_NDT[15:0] bits
 | 
			
		||||
   */
 | 
			
		||||
  LL_DMA_SetDataLength(DMAx, Channel, DMA_InitStruct->NbData);
 | 
			
		||||
 | 
			
		||||
  /*--------------------------- DMAx CSELR Configuration -----------------------
 | 
			
		||||
   * Configure the peripheral base address with parameter :
 | 
			
		||||
   * - PeriphRequest: DMA_CSELR[31:0] bits
 | 
			
		||||
   */
 | 
			
		||||
  LL_DMA_SetPeriphRequest(DMAx, Channel, DMA_InitStruct->PeriphRequest);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_DMA_InitTypeDef field to default value.
 | 
			
		||||
  * @param  DMA_InitStruct Pointer to a @ref LL_DMA_InitTypeDef structure.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_DMA_StructInit(LL_DMA_InitTypeDef *DMA_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set DMA_InitStruct fields to default values */
 | 
			
		||||
  DMA_InitStruct->PeriphOrM2MSrcAddress  = (uint32_t)0x00000000U;
 | 
			
		||||
  DMA_InitStruct->MemoryOrM2MDstAddress  = (uint32_t)0x00000000U;
 | 
			
		||||
  DMA_InitStruct->Direction              = LL_DMA_DIRECTION_PERIPH_TO_MEMORY;
 | 
			
		||||
  DMA_InitStruct->Mode                   = LL_DMA_MODE_NORMAL;
 | 
			
		||||
  DMA_InitStruct->PeriphOrM2MSrcIncMode  = LL_DMA_PERIPH_NOINCREMENT;
 | 
			
		||||
  DMA_InitStruct->MemoryOrM2MDstIncMode  = LL_DMA_MEMORY_NOINCREMENT;
 | 
			
		||||
  DMA_InitStruct->PeriphOrM2MSrcDataSize = LL_DMA_PDATAALIGN_BYTE;
 | 
			
		||||
  DMA_InitStruct->MemoryOrM2MDstDataSize = LL_DMA_MDATAALIGN_BYTE;
 | 
			
		||||
  DMA_InitStruct->NbData                 = (uint32_t)0x00000000U;
 | 
			
		||||
  DMA_InitStruct->PeriphRequest          = LL_DMA_REQUEST_0;
 | 
			
		||||
  DMA_InitStruct->Priority               = LL_DMA_PRIORITY_LOW;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* DMA1 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,232 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_exti.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   EXTI LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_exti.h"
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (EXTI)
 | 
			
		||||
 | 
			
		||||
/** @defgroup EXTI_LL EXTI
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup EXTI_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#define IS_LL_EXTI_LINE_0_31(__VALUE__)              (((__VALUE__) & ~LL_EXTI_LINE_ALL_0_31) == 0x00000000U)
 | 
			
		||||
 | 
			
		||||
#define IS_LL_EXTI_MODE(__VALUE__)                   (((__VALUE__) == LL_EXTI_MODE_IT)            \
 | 
			
		||||
                                                   || ((__VALUE__) == LL_EXTI_MODE_EVENT)         \
 | 
			
		||||
                                                   || ((__VALUE__) == LL_EXTI_MODE_IT_EVENT))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define IS_LL_EXTI_TRIGGER(__VALUE__)                (((__VALUE__) == LL_EXTI_TRIGGER_NONE)       \
 | 
			
		||||
                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_RISING)     \
 | 
			
		||||
                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_FALLING)    \
 | 
			
		||||
                                                   || ((__VALUE__) == LL_EXTI_TRIGGER_RISING_FALLING))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup EXTI_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup EXTI_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize the EXTI registers to their default reset values.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: EXTI registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_EXTI_DeInit(void)
 | 
			
		||||
{
 | 
			
		||||
  /* Interrupt mask register set to default reset values */
 | 
			
		||||
  LL_EXTI_WriteReg(IMR,   0x3F840000U);
 | 
			
		||||
  /* Event mask register set to default reset values */
 | 
			
		||||
  LL_EXTI_WriteReg(EMR,   0x00000000U);
 | 
			
		||||
  /* Rising Trigger selection register set to default reset values */
 | 
			
		||||
  LL_EXTI_WriteReg(RTSR,  0x00000000U);
 | 
			
		||||
  /* Falling Trigger selection register set to default reset values */
 | 
			
		||||
  LL_EXTI_WriteReg(FTSR,  0x00000000U);
 | 
			
		||||
  /* Software interrupt event register set to default reset values */
 | 
			
		||||
  LL_EXTI_WriteReg(SWIER, 0x00000000U);
 | 
			
		||||
  /* Pending register set to default reset values */
 | 
			
		||||
  LL_EXTI_WriteReg(PR,    0x007BFFFFU);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize the EXTI registers according to the specified parameters in EXTI_InitStruct.
 | 
			
		||||
  * @param  EXTI_InitStruct pointer to a @ref LL_EXTI_InitTypeDef structure.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: EXTI registers are initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_EXTI_Init(LL_EXTI_InitTypeDef *EXTI_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_LL_EXTI_LINE_0_31(EXTI_InitStruct->Line_0_31));
 | 
			
		||||
  assert_param(IS_FUNCTIONAL_STATE(EXTI_InitStruct->LineCommand));
 | 
			
		||||
  assert_param(IS_LL_EXTI_MODE(EXTI_InitStruct->Mode));
 | 
			
		||||
 | 
			
		||||
  /* ENABLE LineCommand */
 | 
			
		||||
  if (EXTI_InitStruct->LineCommand != DISABLE)
 | 
			
		||||
  {
 | 
			
		||||
    assert_param(IS_LL_EXTI_TRIGGER(EXTI_InitStruct->Trigger));
 | 
			
		||||
 | 
			
		||||
    /* Configure EXTI Lines in range from 0 to 31 */
 | 
			
		||||
    if (EXTI_InitStruct->Line_0_31 != LL_EXTI_LINE_NONE)
 | 
			
		||||
    {
 | 
			
		||||
      switch (EXTI_InitStruct->Mode)
 | 
			
		||||
      {
 | 
			
		||||
        case LL_EXTI_MODE_IT:
 | 
			
		||||
          /* First Disable Event on provided Lines */
 | 
			
		||||
          LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
          /* Then Enable IT on provided Lines */
 | 
			
		||||
          LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
          break;
 | 
			
		||||
        case LL_EXTI_MODE_EVENT:
 | 
			
		||||
          /* First Disable IT on provided Lines */
 | 
			
		||||
          LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
          /* Then Enable Event on provided Lines */
 | 
			
		||||
          LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
          break;
 | 
			
		||||
        case LL_EXTI_MODE_IT_EVENT:
 | 
			
		||||
          /* Directly Enable IT & Event on provided Lines */
 | 
			
		||||
          LL_EXTI_EnableIT_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
          LL_EXTI_EnableEvent_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
          break;
 | 
			
		||||
        default:
 | 
			
		||||
          status = ERROR;
 | 
			
		||||
          break;
 | 
			
		||||
      }
 | 
			
		||||
      if (EXTI_InitStruct->Trigger != LL_EXTI_TRIGGER_NONE)
 | 
			
		||||
      {
 | 
			
		||||
        switch (EXTI_InitStruct->Trigger)
 | 
			
		||||
        {
 | 
			
		||||
          case LL_EXTI_TRIGGER_RISING:
 | 
			
		||||
            /* First Disable Falling Trigger on provided Lines */
 | 
			
		||||
            LL_EXTI_DisableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
            /* Then Enable Rising Trigger on provided Lines */
 | 
			
		||||
            LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
            break;
 | 
			
		||||
          case LL_EXTI_TRIGGER_FALLING:
 | 
			
		||||
            /* First Disable Rising Trigger on provided Lines */
 | 
			
		||||
            LL_EXTI_DisableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
            /* Then Enable Falling Trigger on provided Lines */
 | 
			
		||||
            LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
            break;
 | 
			
		||||
          case LL_EXTI_TRIGGER_RISING_FALLING:
 | 
			
		||||
            LL_EXTI_EnableRisingTrig_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
            LL_EXTI_EnableFallingTrig_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
            break;
 | 
			
		||||
          default:
 | 
			
		||||
            status = ERROR;
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  /* DISABLE LineCommand */
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* De-configure EXTI Lines in range from 0 to 31 */
 | 
			
		||||
    LL_EXTI_DisableIT_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
    LL_EXTI_DisableEvent_0_31(EXTI_InitStruct->Line_0_31);
 | 
			
		||||
  }
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_EXTI_InitTypeDef field to default value.
 | 
			
		||||
  * @param  EXTI_InitStruct Pointer to a @ref LL_EXTI_InitTypeDef structure.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_EXTI_StructInit(LL_EXTI_InitTypeDef *EXTI_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  EXTI_InitStruct->Line_0_31      = LL_EXTI_LINE_NONE;
 | 
			
		||||
  EXTI_InitStruct->LineCommand    = DISABLE;
 | 
			
		||||
  EXTI_InitStruct->Mode           = LL_EXTI_MODE_IT;
 | 
			
		||||
  EXTI_InitStruct->Trigger        = LL_EXTI_TRIGGER_FALLING;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined (EXTI) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,283 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_gpio.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   GPIO LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_gpio.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOH)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup GPIO_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup GPIO_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define IS_LL_GPIO_PIN(__VALUE__)          ((((uint32_t)0x00000000U) < (__VALUE__)) && ((__VALUE__) <= (LL_GPIO_PIN_ALL)))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_GPIO_MODE(__VALUE__)         (((__VALUE__) == LL_GPIO_MODE_INPUT)     ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_MODE_OUTPUT)    ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_MODE_ALTERNATE) ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_MODE_ANALOG))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_GPIO_OUTPUT_TYPE(__VALUE__)  (((__VALUE__) == LL_GPIO_OUTPUT_PUSHPULL)  ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_OUTPUT_OPENDRAIN))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_GPIO_SPEED(__VALUE__)        (((__VALUE__) == LL_GPIO_SPEED_FREQ_LOW)       ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_SPEED_FREQ_MEDIUM)    ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_SPEED_FREQ_HIGH)      ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_SPEED_FREQ_VERY_HIGH))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_GPIO_PULL(__VALUE__)         (((__VALUE__) == LL_GPIO_PULL_NO)   ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_PULL_UP)   ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_PULL_DOWN))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_GPIO_ALTERNATE(__VALUE__)    (((__VALUE__) == LL_GPIO_AF_0  )   ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_AF_1  )   ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_AF_2  )   ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_AF_3  )   ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_AF_4  )   ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_AF_5  )   ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_AF_6  )   ||\
 | 
			
		||||
                                            ((__VALUE__) == LL_GPIO_AF_7 ))
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup GPIO_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup GPIO_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize GPIO registers (Registers restored to their default values).
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: GPIO registers are de-initialized
 | 
			
		||||
  *          - ERROR:   Wrong GPIO Port
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
 | 
			
		||||
 | 
			
		||||
  /* Force and Release reset on clock of GPIOx Port */
 | 
			
		||||
  if (GPIOx == GPIOA)
 | 
			
		||||
  {
 | 
			
		||||
    LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOA);
 | 
			
		||||
    LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOA);
 | 
			
		||||
  }
 | 
			
		||||
  else if (GPIOx == GPIOB)
 | 
			
		||||
  {
 | 
			
		||||
    LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOB);
 | 
			
		||||
    LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOB);
 | 
			
		||||
  }
 | 
			
		||||
  else if (GPIOx == GPIOC)
 | 
			
		||||
  {
 | 
			
		||||
    LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOC);
 | 
			
		||||
    LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOC);
 | 
			
		||||
  }
 | 
			
		||||
#if defined(GPIOD)
 | 
			
		||||
  else if (GPIOx == GPIOD)
 | 
			
		||||
  {
 | 
			
		||||
    LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOD);
 | 
			
		||||
    LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOD);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* GPIOD */
 | 
			
		||||
#if defined(GPIOE)
 | 
			
		||||
  else if (GPIOx == GPIOE)
 | 
			
		||||
  {
 | 
			
		||||
    LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOE);
 | 
			
		||||
    LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOE);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* GPIOE */
 | 
			
		||||
#if defined(GPIOH)
 | 
			
		||||
  else if (GPIOx == GPIOH)
 | 
			
		||||
  {
 | 
			
		||||
    LL_IOP_GRP1_ForceReset(LL_IOP_GRP1_PERIPH_GPIOH);
 | 
			
		||||
    LL_IOP_GRP1_ReleaseReset(LL_IOP_GRP1_PERIPH_GPIOH);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* GPIOH */
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return (status);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize GPIO registers according to the specified parameters in GPIO_InitStruct.
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  GPIO_InitStruct: pointer to a @ref LL_GPIO_InitTypeDef structure
 | 
			
		||||
  *         that contains the configuration information for the specified GPIO peripheral.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: GPIO registers are initialized according to GPIO_InitStruct content
 | 
			
		||||
  *          - ERROR:   Not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t pinpos     = 0x00000000U;
 | 
			
		||||
  uint32_t currentpin = 0x00000000U;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_GPIO_ALL_INSTANCE(GPIOx));
 | 
			
		||||
  assert_param(IS_LL_GPIO_PIN(GPIO_InitStruct->Pin));
 | 
			
		||||
  assert_param(IS_LL_GPIO_MODE(GPIO_InitStruct->Mode));
 | 
			
		||||
  assert_param(IS_LL_GPIO_PULL(GPIO_InitStruct->Pull));
 | 
			
		||||
 | 
			
		||||
  /* ------------------------- Configure the port pins ---------------- */
 | 
			
		||||
  /* Initialize  pinpos on first pin set */
 | 
			
		||||
  /* pinpos = 0; useless as already done in default initialization */
 | 
			
		||||
 | 
			
		||||
  /* Configure the port pins */
 | 
			
		||||
  while (((GPIO_InitStruct->Pin) >> pinpos) != 0x00000000U)
 | 
			
		||||
  {
 | 
			
		||||
    /* Get current io position */
 | 
			
		||||
    currentpin = (GPIO_InitStruct->Pin) & (0x00000001U << pinpos);
 | 
			
		||||
 | 
			
		||||
    if (currentpin)
 | 
			
		||||
    {
 | 
			
		||||
      /* Pin Mode configuration */
 | 
			
		||||
      LL_GPIO_SetPinMode(GPIOx, currentpin, GPIO_InitStruct->Mode);
 | 
			
		||||
 | 
			
		||||
      if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
 | 
			
		||||
      {
 | 
			
		||||
        /* Check Speed mode parameters */
 | 
			
		||||
        assert_param(IS_LL_GPIO_SPEED(GPIO_InitStruct->Speed));
 | 
			
		||||
 | 
			
		||||
        /* Speed mode configuration */
 | 
			
		||||
        LL_GPIO_SetPinSpeed(GPIOx, currentpin, GPIO_InitStruct->Speed);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      /* Pull-up Pull down resistor configuration*/
 | 
			
		||||
      LL_GPIO_SetPinPull(GPIOx, currentpin, GPIO_InitStruct->Pull);
 | 
			
		||||
 | 
			
		||||
      if (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE)
 | 
			
		||||
      {
 | 
			
		||||
        /* Check Alternate parameter */
 | 
			
		||||
        assert_param(IS_LL_GPIO_ALTERNATE(GPIO_InitStruct->Alternate));
 | 
			
		||||
 | 
			
		||||
        /* Speed mode configuration */
 | 
			
		||||
        if (currentpin < LL_GPIO_PIN_8)
 | 
			
		||||
        {
 | 
			
		||||
          LL_GPIO_SetAFPin_0_7(GPIOx, currentpin, GPIO_InitStruct->Alternate);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
          LL_GPIO_SetAFPin_8_15(GPIOx, currentpin, GPIO_InitStruct->Alternate);
 | 
			
		||||
        }
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
    pinpos++;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if ((GPIO_InitStruct->Mode == LL_GPIO_MODE_OUTPUT) || (GPIO_InitStruct->Mode == LL_GPIO_MODE_ALTERNATE))
 | 
			
		||||
  {
 | 
			
		||||
    /* Check Output mode parameters */
 | 
			
		||||
    assert_param(IS_LL_GPIO_OUTPUT_TYPE(GPIO_InitStruct->OutputType));
 | 
			
		||||
 | 
			
		||||
    /* Output mode configuration*/
 | 
			
		||||
    LL_GPIO_SetPinOutputType(GPIOx, GPIO_InitStruct->Pin, GPIO_InitStruct->OutputType);
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
  return (SUCCESS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Set each @ref LL_GPIO_InitTypeDef field to default value.
 | 
			
		||||
  * @param GPIO_InitStruct: pointer to a @ref LL_GPIO_InitTypeDef structure
 | 
			
		||||
  *                          whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
void LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Reset GPIO init structure parameters values */
 | 
			
		||||
  GPIO_InitStruct->Pin        = LL_GPIO_PIN_ALL;
 | 
			
		||||
  GPIO_InitStruct->Mode       = LL_GPIO_MODE_ANALOG;
 | 
			
		||||
  GPIO_InitStruct->Speed      = LL_GPIO_SPEED_FREQ_LOW;
 | 
			
		||||
  GPIO_InitStruct->OutputType = LL_GPIO_OUTPUT_PUSHPULL;
 | 
			
		||||
  GPIO_InitStruct->Pull       = LL_GPIO_PULL_NO;
 | 
			
		||||
  GPIO_InitStruct->Alternate  = LL_GPIO_AF_0;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOH) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,962 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_gpio.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   Header file of GPIO LL module.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32L0xx_LL_GPIO_H
 | 
			
		||||
#define __STM32L0xx_LL_GPIO_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOH)
 | 
			
		||||
 | 
			
		||||
/** @defgroup GPIO_LL GPIO
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
/** @defgroup GPIO_LL_Private_Macros GPIO Private Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /*USE_FULL_LL_DRIVER*/
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
/** @defgroup GPIO_LL_ES_INIT GPIO Exported Init structures
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief LL GPIO Init Structure definition
 | 
			
		||||
  */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint32_t Pin;          /*!< Specifies the GPIO pins to be configured.
 | 
			
		||||
                              This parameter can be any value of @ref GPIO_LL_EC_PIN */
 | 
			
		||||
 | 
			
		||||
  uint32_t Mode;         /*!< Specifies the operating mode for the selected pins.
 | 
			
		||||
                              This parameter can be a value of @ref GPIO_LL_EC_MODE.
 | 
			
		||||
 | 
			
		||||
                              GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinMode().*/
 | 
			
		||||
 | 
			
		||||
  uint32_t Speed;        /*!< Specifies the speed for the selected pins.
 | 
			
		||||
                              This parameter can be a value of @ref GPIO_LL_EC_SPEED.
 | 
			
		||||
 | 
			
		||||
                              GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinSpeed().*/
 | 
			
		||||
 | 
			
		||||
  uint32_t OutputType;   /*!< Specifies the operating output type for the selected pins.
 | 
			
		||||
                              This parameter can be a value of @ref GPIO_LL_EC_OUTPUT.
 | 
			
		||||
 | 
			
		||||
                              GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinOutputType().*/
 | 
			
		||||
 | 
			
		||||
  uint32_t Pull;         /*!< Specifies the operating Pull-up/Pull down for the selected pins.
 | 
			
		||||
                              This parameter can be a value of @ref GPIO_LL_EC_PULL.
 | 
			
		||||
 | 
			
		||||
                              GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetPinPull().*/
 | 
			
		||||
 | 
			
		||||
  uint32_t Alternate;    /*!< Specifies the Peripheral to be connected to the selected pins.
 | 
			
		||||
                              This parameter can be a value of @ref GPIO_LL_EC_AF.
 | 
			
		||||
 | 
			
		||||
                              GPIO HW configuration can be modified afterwards using unitary function @ref LL_GPIO_SetAFPin_0_7() and LL_GPIO_SetAFPin_8_15().*/
 | 
			
		||||
} LL_GPIO_InitTypeDef;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup GPIO_LL_Exported_Constants GPIO Exported Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup GPIO_LL_EC_PIN PIN
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_GPIO_PIN_0                      GPIO_BSRR_BS_0 /*!< Select pin 0 */
 | 
			
		||||
#define LL_GPIO_PIN_1                      GPIO_BSRR_BS_1 /*!< Select pin 1 */
 | 
			
		||||
#define LL_GPIO_PIN_2                      GPIO_BSRR_BS_2 /*!< Select pin 2 */
 | 
			
		||||
#define LL_GPIO_PIN_3                      GPIO_BSRR_BS_3 /*!< Select pin 3 */
 | 
			
		||||
#define LL_GPIO_PIN_4                      GPIO_BSRR_BS_4 /*!< Select pin 4 */
 | 
			
		||||
#define LL_GPIO_PIN_5                      GPIO_BSRR_BS_5 /*!< Select pin 5 */
 | 
			
		||||
#define LL_GPIO_PIN_6                      GPIO_BSRR_BS_6 /*!< Select pin 6 */
 | 
			
		||||
#define LL_GPIO_PIN_7                      GPIO_BSRR_BS_7 /*!< Select pin 7 */
 | 
			
		||||
#define LL_GPIO_PIN_8                      GPIO_BSRR_BS_8 /*!< Select pin 8 */
 | 
			
		||||
#define LL_GPIO_PIN_9                      GPIO_BSRR_BS_9 /*!< Select pin 9 */
 | 
			
		||||
#define LL_GPIO_PIN_10                     GPIO_BSRR_BS_10 /*!< Select pin 10 */
 | 
			
		||||
#define LL_GPIO_PIN_11                     GPIO_BSRR_BS_11 /*!< Select pin 11 */
 | 
			
		||||
#define LL_GPIO_PIN_12                     GPIO_BSRR_BS_12 /*!< Select pin 12 */
 | 
			
		||||
#define LL_GPIO_PIN_13                     GPIO_BSRR_BS_13 /*!< Select pin 13 */
 | 
			
		||||
#define LL_GPIO_PIN_14                     GPIO_BSRR_BS_14 /*!< Select pin 14 */
 | 
			
		||||
#define LL_GPIO_PIN_15                     GPIO_BSRR_BS_15 /*!< Select pin 15 */
 | 
			
		||||
#define LL_GPIO_PIN_ALL                    (GPIO_BSRR_BS_0 | GPIO_BSRR_BS_1  | GPIO_BSRR_BS_2  | \
 | 
			
		||||
                                           GPIO_BSRR_BS_3  | GPIO_BSRR_BS_4  | GPIO_BSRR_BS_5  | \
 | 
			
		||||
                                           GPIO_BSRR_BS_6  | GPIO_BSRR_BS_7  | GPIO_BSRR_BS_8  | \
 | 
			
		||||
                                           GPIO_BSRR_BS_9  | GPIO_BSRR_BS_10 | GPIO_BSRR_BS_11 | \
 | 
			
		||||
                                           GPIO_BSRR_BS_12 | GPIO_BSRR_BS_13 | GPIO_BSRR_BS_14 | \
 | 
			
		||||
                                           GPIO_BSRR_BS_15) /*!< Select all pins */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup GPIO_LL_EC_MODE Mode
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_GPIO_MODE_INPUT                 ((uint32_t)0x00000000U) /*!< Select input mode */
 | 
			
		||||
#define LL_GPIO_MODE_OUTPUT                GPIO_MODER_MODE0_0  /*!< Select output mode */
 | 
			
		||||
#define LL_GPIO_MODE_ALTERNATE             GPIO_MODER_MODE0_1  /*!< Select alternate function mode */
 | 
			
		||||
#define LL_GPIO_MODE_ANALOG                GPIO_MODER_MODE0    /*!< Select analog mode */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup GPIO_LL_EC_OUTPUT Output Type
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_GPIO_OUTPUT_PUSHPULL            ((uint32_t)0x00000000U) /*!< Select push-pull as output type */
 | 
			
		||||
#define LL_GPIO_OUTPUT_OPENDRAIN           GPIO_OTYPER_OT_0 /*!< Select open-drain as output type */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup GPIO_LL_EC_SPEED Output Speed
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_GPIO_SPEED_FREQ_LOW             ((uint32_t)0x00000000U) /*!< Select I/O low output speed    */
 | 
			
		||||
#define LL_GPIO_SPEED_FREQ_MEDIUM          GPIO_OSPEEDER_OSPEED0_0 /*!< Select I/O medium output speed */
 | 
			
		||||
#define LL_GPIO_SPEED_FREQ_HIGH            GPIO_OSPEEDER_OSPEED0_1 /*!< Select I/O fast output speed   */
 | 
			
		||||
#define LL_GPIO_SPEED_FREQ_VERY_HIGH       GPIO_OSPEEDER_OSPEED0   /*!< Select I/O high output speed   */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#define LL_GPIO_SPEED_LOW                  LL_GPIO_SPEED_FREQ_LOW
 | 
			
		||||
#define LL_GPIO_SPEED_MEDIUM               LL_GPIO_SPEED_FREQ_MEDIUM
 | 
			
		||||
#define LL_GPIO_SPEED_FAST                 LL_GPIO_SPEED_FREQ_HIGH
 | 
			
		||||
#define LL_GPIO_SPEED_HIGH                 LL_GPIO_SPEED_FREQ_VERY_HIGH
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/** @defgroup GPIO_LL_EC_PULL Pull Up Pull Down
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_GPIO_PULL_NO                    ((uint32_t)0x00000000U) /*!< Select I/O no pull */
 | 
			
		||||
#define LL_GPIO_PULL_UP                    GPIO_PUPDR_PUPD0_0 /*!< Select I/O pull up */
 | 
			
		||||
#define LL_GPIO_PULL_DOWN                  GPIO_PUPDR_PUPD0_1 /*!< Select I/O pull down */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup GPIO_LL_EC_AF Alternate Function
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_GPIO_AF_0                       ((uint32_t)0x0000000U) /*!< Select alternate function 0 */
 | 
			
		||||
#define LL_GPIO_AF_1                       ((uint32_t)0x0000001U) /*!< Select alternate function 1 */
 | 
			
		||||
#define LL_GPIO_AF_2                       ((uint32_t)0x0000002U) /*!< Select alternate function 2 */
 | 
			
		||||
#define LL_GPIO_AF_3                       ((uint32_t)0x0000003U) /*!< Select alternate function 3 */
 | 
			
		||||
#define LL_GPIO_AF_4                       ((uint32_t)0x0000004U) /*!< Select alternate function 4 */
 | 
			
		||||
#define LL_GPIO_AF_5                       ((uint32_t)0x0000005U) /*!< Select alternate function 5 */
 | 
			
		||||
#define LL_GPIO_AF_6                       ((uint32_t)0x0000006U) /*!< Select alternate function 6 */
 | 
			
		||||
#define LL_GPIO_AF_7                       ((uint32_t)0x0000007U) /*!< Select alternate function 7 */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup GPIO_LL_Exported_Macros GPIO Exported Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup GPIO_LL_EM_WRITE_READ Common Write and read registers Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write a value in GPIO register
 | 
			
		||||
  * @param  __INSTANCE__ GPIO Instance
 | 
			
		||||
  * @param  __REG__ Register to be written
 | 
			
		||||
  * @param  __VALUE__ Value to be written in the register
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
#define LL_GPIO_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Read a value in GPIO register
 | 
			
		||||
  * @param  __INSTANCE__ GPIO Instance
 | 
			
		||||
  * @param  __REG__ Register to be read
 | 
			
		||||
  * @retval Register value
 | 
			
		||||
  */
 | 
			
		||||
#define LL_GPIO_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup GPIO_LL_Exported_Functions GPIO Exported Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup GPIO_LL_EF_Port_Configuration Port Configuration
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure gpio mode for a dedicated pin on dedicated port.
 | 
			
		||||
  * @note   I/O mode can be Input mode, General purpose output, Alternate function mode or Analog.
 | 
			
		||||
  * @note   Warning: only one pin can be passed as parameter.
 | 
			
		||||
  * @rmtoll MODER        MODEy         LL_GPIO_SetPinMode
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  * @param  Mode This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_MODE_INPUT
 | 
			
		||||
  *         @arg @ref LL_GPIO_MODE_OUTPUT
 | 
			
		||||
  *         @arg @ref LL_GPIO_MODE_ALTERNATE
 | 
			
		||||
  *         @arg @ref LL_GPIO_MODE_ANALOG
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_SetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Mode)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(GPIOx->MODER, ((Pin * Pin) * GPIO_MODER_MODE0), ((Pin * Pin) * Mode));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return gpio mode for a dedicated pin on dedicated port.
 | 
			
		||||
  * @note   I/O mode can be Input mode, General purpose output, Alternate function mode or Analog.
 | 
			
		||||
  * @note   Warning: only one pin can be passed as parameter.
 | 
			
		||||
  * @rmtoll MODER        MODEy         LL_GPIO_GetPinMode
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_MODE_INPUT
 | 
			
		||||
  *         @arg @ref LL_GPIO_MODE_OUTPUT
 | 
			
		||||
  *         @arg @ref LL_GPIO_MODE_ALTERNATE
 | 
			
		||||
  *         @arg @ref LL_GPIO_MODE_ANALOG
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_GetPinMode(GPIO_TypeDef *GPIOx, uint32_t Pin)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(GPIOx->MODER, ((Pin * Pin) * GPIO_MODER_MODE0)) / (Pin * Pin));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure gpio output type for several pins on dedicated port.
 | 
			
		||||
  * @note   Output type as to be set when gpio pin is in output or
 | 
			
		||||
  *         alternate modes. Possible type are Push-pull or Open-drain.
 | 
			
		||||
  * @rmtoll OTYPER       OTy           LL_GPIO_SetPinOutputType
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  PinMask This parameter can be a combination of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_ALL
 | 
			
		||||
  * @param  OutputType This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_OUTPUT_PUSHPULL
 | 
			
		||||
  *         @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_SetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t PinMask, uint32_t OutputType)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(GPIOx->OTYPER, PinMask, (PinMask * OutputType));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return gpio output type for several pins on dedicated port.
 | 
			
		||||
  * @note   Output type as to be set when gpio pin is in output or
 | 
			
		||||
  *         alternate modes. Possible type are Push-pull or Open-drain.
 | 
			
		||||
  * @note   Warning: only one pin can be passed as parameter.
 | 
			
		||||
  * @rmtoll OTYPER       OTy           LL_GPIO_GetPinOutputType
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_ALL
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_OUTPUT_PUSHPULL
 | 
			
		||||
  *         @arg @ref LL_GPIO_OUTPUT_OPENDRAIN
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_GetPinOutputType(GPIO_TypeDef *GPIOx, uint32_t Pin)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(GPIOx->OTYPER, Pin) / Pin);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure gpio speed for a dedicated pin on dedicated port.
 | 
			
		||||
  * @note   I/O speed can be Low, Medium, Fast or High speed.
 | 
			
		||||
  * @note   Warning: only one pin can be passed as parameter.
 | 
			
		||||
  * @note   Refer to datasheet for frequency specifications and the power
 | 
			
		||||
  *         supply and load conditions for each speed.
 | 
			
		||||
  * @rmtoll OSPEEDR      OSPEEDy       LL_GPIO_SetPinSpeed
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  * @param  Speed This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_SPEED_FREQ_LOW
 | 
			
		||||
  *         @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
 | 
			
		||||
  *         @arg @ref LL_GPIO_SPEED_FREQ_HIGH
 | 
			
		||||
  *         @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_SetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t  Speed)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(GPIOx->OSPEEDR, ((Pin * Pin) * GPIO_OSPEEDER_OSPEED0), ((Pin * Pin) * Speed));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return gpio speed for a dedicated pin on dedicated port.
 | 
			
		||||
  * @note   I/O speed can be Low, Medium, Fast or High speed.
 | 
			
		||||
  * @note   Warning: only one pin can be passed as parameter.
 | 
			
		||||
  * @note   Refer to datasheet for frequency specifications and the power
 | 
			
		||||
  *         supply and load conditions for each speed.
 | 
			
		||||
  * @rmtoll OSPEEDR      OSPEEDy       LL_GPIO_GetPinSpeed
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_SPEED_FREQ_LOW
 | 
			
		||||
  *         @arg @ref LL_GPIO_SPEED_FREQ_MEDIUM
 | 
			
		||||
  *         @arg @ref LL_GPIO_SPEED_FREQ_HIGH
 | 
			
		||||
  *         @arg @ref LL_GPIO_SPEED_FREQ_VERY_HIGH
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_GetPinSpeed(GPIO_TypeDef *GPIOx, uint32_t Pin)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(GPIOx->OSPEEDR, ((Pin * Pin) * GPIO_OSPEEDER_OSPEED0)) / (Pin * Pin));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure gpio pull-up or pull-down for a dedicated pin on a dedicated port.
 | 
			
		||||
  * @note   Warning: only one pin can be passed as parameter.
 | 
			
		||||
  * @rmtoll PUPDR        PUPDy         LL_GPIO_SetPinPull
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  * @param  Pull This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PULL_NO
 | 
			
		||||
  *         @arg @ref LL_GPIO_PULL_UP
 | 
			
		||||
  *         @arg @ref LL_GPIO_PULL_DOWN
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_SetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Pull)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(GPIOx->PUPDR, ((Pin * Pin) * GPIO_PUPDR_PUPD0), ((Pin * Pin) * Pull));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return gpio pull-up or pull-down for a dedicated pin on a dedicated port
 | 
			
		||||
  * @note   Warning: only one pin can be passed as parameter.
 | 
			
		||||
  * @rmtoll PUPDR        PUPDy         LL_GPIO_GetPinPull
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PULL_NO
 | 
			
		||||
  *         @arg @ref LL_GPIO_PULL_UP
 | 
			
		||||
  *         @arg @ref LL_GPIO_PULL_DOWN
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_GetPinPull(GPIO_TypeDef *GPIOx, uint32_t Pin)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(GPIOx->PUPDR, ((Pin * Pin) * GPIO_PUPDR_PUPD0)) / (Pin * Pin));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
 | 
			
		||||
  * @note   Possible values are from AF0 to AF7 depending on target.
 | 
			
		||||
  * @note   Warning: only one pin can be passed as parameter.
 | 
			
		||||
  * @rmtoll AFRL         AFSELy        LL_GPIO_SetAFPin_0_7
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  * @param  Alternate This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_7
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_SetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(GPIOx->AFR[0], ((((Pin * Pin) * Pin) * Pin) * GPIO_AFRL_AFRL0),
 | 
			
		||||
             ((((Pin * Pin) * Pin) * Pin) * Alternate));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return gpio alternate function of a dedicated pin from 0 to 7 for a dedicated port.
 | 
			
		||||
  * @rmtoll AFRL         AFSELy        LL_GPIO_GetAFPin_0_7
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_7
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_GetAFPin_0_7(GPIO_TypeDef *GPIOx, uint32_t Pin)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(GPIOx->AFR[0],
 | 
			
		||||
                             ((((Pin * Pin) * Pin) * Pin) * GPIO_AFRL_AFRL0)) / (((Pin * Pin) * Pin) * Pin));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port.
 | 
			
		||||
  * @note   Possible values are from AF0 to AF7 depending on target.
 | 
			
		||||
  * @note   Warning: only one pin can be passed as parameter.
 | 
			
		||||
  * @rmtoll AFRH         AFSELy        LL_GPIO_SetAFPin_8_15
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  * @param  Alternate This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_7
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_SetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin, uint32_t Alternate)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(GPIOx->AFR[1], (((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)) * GPIO_AFRH_AFRH0),
 | 
			
		||||
             (((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)) * Alternate));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return gpio alternate function of a dedicated pin from 8 to 15 for a dedicated port.
 | 
			
		||||
  * @note   Possible values are from AF0 to AF7 depending on target.
 | 
			
		||||
  * @rmtoll AFRH         AFSELy        LL_GPIO_GetAFPin_8_15
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  Pin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_AF_7
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_GetAFPin_8_15(GPIO_TypeDef *GPIOx, uint32_t Pin)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(GPIOx->AFR[1],
 | 
			
		||||
                             (((((Pin >> 8U) * (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)) * GPIO_AFRH_AFRH0)) / ((((Pin >> 8U) *
 | 
			
		||||
                                 (Pin >> 8U)) * (Pin >> 8U)) * (Pin >> 8U)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Lock configuration of several pins for a dedicated port.
 | 
			
		||||
  * @note   When the lock sequence has been applied on a port bit, the
 | 
			
		||||
  *         value of this port bit can no longer be modified until the
 | 
			
		||||
  *         next reset.
 | 
			
		||||
  * @note   Each lock bit freezes a specific configuration register
 | 
			
		||||
  *         (control and alternate function registers).
 | 
			
		||||
  * @rmtoll LCKR         LCKK          LL_GPIO_LockPin
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  PinMask This parameter can be a combination of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_ALL
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_LockPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
 | 
			
		||||
{
 | 
			
		||||
  __IO uint32_t temp;
 | 
			
		||||
  WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask);
 | 
			
		||||
  WRITE_REG(GPIOx->LCKR, PinMask);
 | 
			
		||||
  WRITE_REG(GPIOx->LCKR, GPIO_LCKR_LCKK | PinMask);
 | 
			
		||||
  temp = READ_REG(GPIOx->LCKR);
 | 
			
		||||
  (void) temp;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return 1 if all pins passed as parameter, of a dedicated port, are locked. else Return 0.
 | 
			
		||||
  * @rmtoll LCKR         LCKy          LL_GPIO_IsPinLocked
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  PinMask This parameter can be a combination of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_ALL
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_IsPinLocked(GPIO_TypeDef *GPIOx, uint32_t PinMask)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(GPIOx->LCKR, PinMask) == (PinMask));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return 1 if one of the pin of a dedicated port is locked. else return 0.
 | 
			
		||||
  * @rmtoll LCKR         LCKK          LL_GPIO_IsAnyPinLocked
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_IsAnyPinLocked(GPIO_TypeDef *GPIOx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(GPIOx->LCKR, GPIO_LCKR_LCKK) == (GPIO_LCKR_LCKK));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup GPIO_LL_EF_Data_Access Data Access
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return full input data register value for a dedicated port.
 | 
			
		||||
  * @rmtoll IDR          IDy           LL_GPIO_ReadInputPort
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @retval Input data register value of port
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_ReadInputPort(GPIO_TypeDef *GPIOx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(GPIOx->IDR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return if input data level for several pins of dedicated port is high or low.
 | 
			
		||||
  * @rmtoll IDR          IDy           LL_GPIO_IsInputPinSet
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  PinMask This parameter can be a combination of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_ALL
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_IsInputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(GPIOx->IDR, PinMask) == (PinMask));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write output data register for the port.
 | 
			
		||||
  * @rmtoll ODR          ODy           LL_GPIO_WriteOutputPort
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  PortValue Level value for each pin of the port
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_WriteOutputPort(GPIO_TypeDef *GPIOx, uint32_t PortValue)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(GPIOx->ODR, PortValue);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return full output data register value for a dedicated port.
 | 
			
		||||
  * @rmtoll ODR          ODy           LL_GPIO_ReadOutputPort
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @retval Output data register value of port
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_ReadOutputPort(GPIO_TypeDef *GPIOx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(GPIOx->ODR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return if input data level for several pins of dedicated port is high or low.
 | 
			
		||||
  * @rmtoll ODR          ODy           LL_GPIO_IsOutputPinSet
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  PinMask This parameter can be a combination of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_ALL
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GPIO_IsOutputPinSet(GPIO_TypeDef *GPIOx, uint32_t PinMask)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(GPIOx->ODR, PinMask) == (PinMask));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set several pins to high level on dedicated gpio port.
 | 
			
		||||
  * @rmtoll BSRR         BSy           LL_GPIO_SetOutputPin
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  PinMask This parameter can be a combination of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_ALL
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_SetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(GPIOx->BSRR, PinMask);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set several pins to low level on dedicated gpio port.
 | 
			
		||||
  * @rmtoll BRR          BRy           LL_GPIO_ResetOutputPin
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  PinMask This parameter can be a combination of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_ALL
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_ResetOutputPin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(GPIOx->BRR, PinMask);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Toggle data value for several pin of dedicated port.
 | 
			
		||||
  * @rmtoll ODR          ODy           LL_GPIO_TogglePin
 | 
			
		||||
  * @param  GPIOx GPIO Port
 | 
			
		||||
  * @param  PinMask This parameter can be a combination of the following values:
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_0
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_1
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_2
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_3
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_4
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_5
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_6
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_7
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_8
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_9
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_10
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_11
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_12
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_13
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_14
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_15
 | 
			
		||||
  *         @arg @ref LL_GPIO_PIN_ALL
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_GPIO_TogglePin(GPIO_TypeDef *GPIOx, uint32_t PinMask)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(GPIOx->ODR, READ_REG(GPIOx->ODR) ^ PinMask);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
/** @defgroup GPIO_LL_EF_Init Initialization and de-initialization functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
ErrorStatus LL_GPIO_DeInit(GPIO_TypeDef *GPIOx);
 | 
			
		||||
ErrorStatus LL_GPIO_Init(GPIO_TypeDef *GPIOx, LL_GPIO_InitTypeDef *GPIO_InitStruct);
 | 
			
		||||
void        LL_GPIO_StructInit(LL_GPIO_InitTypeDef *GPIO_InitStruct);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined (GPIOA) || defined (GPIOB) || defined (GPIOC) || defined (GPIOD) || defined (GPIOE) || defined (GPIOH) */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32L0xx_LL_GPIO_H */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,252 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_i2c.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   I2C LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_i2c.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (I2C1) || defined (I2C2) || defined (I2C3)
 | 
			
		||||
 | 
			
		||||
/** @defgroup I2C_LL I2C
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup I2C_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2C_PERIPHERAL_MODE(__VALUE__)    (((__VALUE__) == LL_I2C_MODE_I2C)          || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_I2C_MODE_SMBUS_HOST)   || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_I2C_MODE_SMBUS_DEVICE_ARP))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2C_ANALOG_FILTER(__VALUE__)      (((__VALUE__) == LL_I2C_ANALOGFILTER_ENABLE) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_I2C_ANALOGFILTER_DISABLE))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2C_DIGITAL_FILTER(__VALUE__)     ((__VALUE__) <= 0x0000000FU)
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2C_OWN_ADDRESS1(__VALUE__)       ((__VALUE__) <= (uint32_t)0x000003FFU)
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2C_TYPE_ACKNOWLEDGE(__VALUE__)   (((__VALUE__) == LL_I2C_ACK) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_I2C_NACK))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2C_OWN_ADDRSIZE(__VALUE__)       (((__VALUE__) == LL_I2C_OWNADDRESS1_7BIT) || \
 | 
			
		||||
                                                 ((__VALUE__) == LL_I2C_OWNADDRESS1_10BIT))
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup I2C_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup I2C_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize the I2C registers to their default reset values.
 | 
			
		||||
  * @param  I2Cx I2C Instance.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: I2C registers are de-initialized
 | 
			
		||||
  *          - ERROR: I2C registers are not de-initialized
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_I2C_DeInit(I2C_TypeDef *I2Cx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
 | 
			
		||||
  /* Check the I2C Instance I2Cx */
 | 
			
		||||
  assert_param(IS_I2C_ALL_INSTANCE(I2Cx));
 | 
			
		||||
 | 
			
		||||
  if (I2Cx == I2C1)
 | 
			
		||||
  {
 | 
			
		||||
    /* Force reset of I2C clock */
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C1);
 | 
			
		||||
 | 
			
		||||
    /* Release reset of I2C clock */
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C1);
 | 
			
		||||
  }
 | 
			
		||||
#if defined(I2C2)
 | 
			
		||||
  else if (I2Cx == I2C2)
 | 
			
		||||
  {
 | 
			
		||||
    /* Force reset of I2C clock */
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C2);
 | 
			
		||||
 | 
			
		||||
    /* Release reset of I2C clock */
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C2);
 | 
			
		||||
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(I2C3)
 | 
			
		||||
  else if (I2Cx == I2C3)
 | 
			
		||||
  {
 | 
			
		||||
    /* Force reset of I2C clock */
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_I2C3);
 | 
			
		||||
 | 
			
		||||
    /* Release reset of I2C clock */
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_I2C3);
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize the I2C registers according to the specified parameters in I2C_InitStruct.
 | 
			
		||||
  * @param  I2Cx I2C Instance.
 | 
			
		||||
  * @param  I2C_InitStruct pointer to a @ref LL_I2C_InitTypeDef structure.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: I2C registers are initialized
 | 
			
		||||
  *          - ERROR: Not applicable
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_I2C_Init(I2C_TypeDef *I2Cx, LL_I2C_InitTypeDef *I2C_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the I2C Instance I2Cx */
 | 
			
		||||
  assert_param(IS_I2C_ALL_INSTANCE(I2Cx));
 | 
			
		||||
 | 
			
		||||
  /* Check the I2C parameters from I2C_InitStruct */
 | 
			
		||||
  assert_param(IS_LL_I2C_PERIPHERAL_MODE(I2C_InitStruct->PeripheralMode));
 | 
			
		||||
  assert_param(IS_LL_I2C_ANALOG_FILTER(I2C_InitStruct->AnalogFilter));
 | 
			
		||||
  assert_param(IS_LL_I2C_DIGITAL_FILTER(I2C_InitStruct->DigitalFilter));
 | 
			
		||||
  assert_param(IS_LL_I2C_OWN_ADDRESS1(I2C_InitStruct->OwnAddress1));
 | 
			
		||||
  assert_param(IS_LL_I2C_TYPE_ACKNOWLEDGE(I2C_InitStruct->TypeAcknowledge));
 | 
			
		||||
  assert_param(IS_LL_I2C_OWN_ADDRSIZE(I2C_InitStruct->OwnAddrSize));
 | 
			
		||||
 | 
			
		||||
  /* Disable the selected I2Cx Peripheral */
 | 
			
		||||
  LL_I2C_Disable(I2Cx);
 | 
			
		||||
 | 
			
		||||
  /*---------------------------- I2Cx CR1 Configuration ------------------------
 | 
			
		||||
   * Configure the analog and digital noise filters with parameters :
 | 
			
		||||
   * - AnalogFilter: I2C_CR1_ANFOFF bit
 | 
			
		||||
   * - DigitalFilter: I2C_CR1_DNF[3:0] bits
 | 
			
		||||
   */
 | 
			
		||||
  LL_I2C_ConfigFilters(I2Cx, I2C_InitStruct->AnalogFilter, I2C_InitStruct->DigitalFilter);
 | 
			
		||||
 | 
			
		||||
  /*---------------------------- I2Cx TIMINGR Configuration --------------------
 | 
			
		||||
   * Configure the SDA setup, hold time and the SCL high, low period with parameter :
 | 
			
		||||
   * - Timing: I2C_TIMINGR_PRESC[3:0], I2C_TIMINGR_SCLDEL[3:0], I2C_TIMINGR_SDADEL[3:0],
 | 
			
		||||
   *           I2C_TIMINGR_SCLH[7:0] and I2C_TIMINGR_SCLL[7:0] bits
 | 
			
		||||
   */
 | 
			
		||||
  LL_I2C_SetTiming(I2Cx, I2C_InitStruct->Timing);
 | 
			
		||||
 | 
			
		||||
  /* Enable the selected I2Cx Peripheral */
 | 
			
		||||
  LL_I2C_Enable(I2Cx);
 | 
			
		||||
 | 
			
		||||
  /*---------------------------- I2Cx OAR1 Configuration -----------------------
 | 
			
		||||
   * Disable, Configure and Enable I2Cx device own address 1 with parameters :
 | 
			
		||||
   * - OwnAddress1:  I2C_OAR1_OA1[9:0] bits
 | 
			
		||||
   * - OwnAddrSize:  I2C_OAR1_OA1MODE bit
 | 
			
		||||
   */
 | 
			
		||||
  LL_I2C_DisableOwnAddress1(I2Cx);
 | 
			
		||||
  LL_I2C_SetOwnAddress1(I2Cx, I2C_InitStruct->OwnAddress1, I2C_InitStruct->OwnAddrSize);
 | 
			
		||||
  LL_I2C_EnableOwnAddress1(I2Cx);
 | 
			
		||||
 | 
			
		||||
  /*---------------------------- I2Cx MODE Configuration -----------------------
 | 
			
		||||
  * Configure I2Cx peripheral mode with parameter :
 | 
			
		||||
   * - PeripheralMode: I2C_CR1_SMBDEN and I2C_CR1_SMBHEN bits
 | 
			
		||||
   */
 | 
			
		||||
  LL_I2C_SetMode(I2Cx, I2C_InitStruct->PeripheralMode);
 | 
			
		||||
 | 
			
		||||
  /*---------------------------- I2Cx CR2 Configuration ------------------------
 | 
			
		||||
   * Configure the ACKnowledge or Non ACKnowledge condition
 | 
			
		||||
   * after the address receive match code or next received byte with parameter :
 | 
			
		||||
   * - TypeAcknowledge: I2C_CR2_NACK bit
 | 
			
		||||
   */
 | 
			
		||||
  LL_I2C_AcknowledgeNextData(I2Cx, I2C_InitStruct->TypeAcknowledge);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_I2C_InitTypeDef field to default value.
 | 
			
		||||
  * @param  I2C_InitStruct Pointer to a @ref LL_I2C_InitTypeDef structure.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_I2C_StructInit(LL_I2C_InitTypeDef *I2C_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set I2C_InitStruct fields to default values */
 | 
			
		||||
  I2C_InitStruct->PeripheralMode  = LL_I2C_MODE_I2C;
 | 
			
		||||
  I2C_InitStruct->Timing          = 0U;
 | 
			
		||||
  I2C_InitStruct->AnalogFilter    = LL_I2C_ANALOGFILTER_ENABLE;
 | 
			
		||||
  I2C_InitStruct->DigitalFilter   = 0U;
 | 
			
		||||
  I2C_InitStruct->OwnAddress1     = 0U;
 | 
			
		||||
  I2C_InitStruct->TypeAcknowledge = LL_I2C_NACK;
 | 
			
		||||
  I2C_InitStruct->OwnAddrSize     = LL_I2C_OWNADDRESS1_7BIT;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* I2C1 || I2C2 || I2C3 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,363 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_iwdg.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   Header file of IWDG LL module.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32L0xx_LL_IWDG_H
 | 
			
		||||
#define __STM32L0xx_LL_IWDG_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(IWDG)
 | 
			
		||||
 | 
			
		||||
/** @defgroup IWDG_LL IWDG
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @defgroup IWDG_LL_Private_Constants IWDG Private Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#define LL_IWDG_KEY_RELOAD                 ((uint32_t)0x0000AAAAU)               /*!< IWDG Reload Counter Enable   */
 | 
			
		||||
#define LL_IWDG_KEY_ENABLE                 ((uint32_t)0x0000CCCCU)               /*!< IWDG Peripheral Enable       */
 | 
			
		||||
#define LL_IWDG_KEY_WR_ACCESS_ENABLE       ((uint32_t)0x00005555U)               /*!< IWDG KR Write Access Enable  */
 | 
			
		||||
#define LL_IWDG_KEY_WR_ACCESS_DISABLE      ((uint32_t)0x00000000U)               /*!< IWDG KR Write Access Disable */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup IWDG_LL_Exported_Constants IWDG Exported Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup IWDG_LL_EC_GET_FLAG Get Flags Defines
 | 
			
		||||
  * @brief    Flags defines which can be used with LL_IWDG_ReadReg function
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_IWDG_SR_PVU                     IWDG_SR_PVU                           /*!< Watchdog prescaler value update */
 | 
			
		||||
#define LL_IWDG_SR_RVU                     IWDG_SR_RVU                           /*!< Watchdog counter reload value update */
 | 
			
		||||
#define LL_IWDG_SR_WVU                     IWDG_SR_WVU                           /*!< Watchdog counter window value update */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup IWDG_LL_EC_PRESCALER  Prescaler Divider
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_IWDG_PRESCALER_4                ((uint32_t)0x00000000U)               /*!< Divider by 4   */
 | 
			
		||||
#define LL_IWDG_PRESCALER_8                (IWDG_PR_PR_0)                        /*!< Divider by 8   */
 | 
			
		||||
#define LL_IWDG_PRESCALER_16               (IWDG_PR_PR_1)                        /*!< Divider by 16  */
 | 
			
		||||
#define LL_IWDG_PRESCALER_32               (IWDG_PR_PR_1 | IWDG_PR_PR_0)         /*!< Divider by 32  */
 | 
			
		||||
#define LL_IWDG_PRESCALER_64               (IWDG_PR_PR_2)                        /*!< Divider by 64  */
 | 
			
		||||
#define LL_IWDG_PRESCALER_128              (IWDG_PR_PR_2 | IWDG_PR_PR_0)         /*!< Divider by 128 */
 | 
			
		||||
#define LL_IWDG_PRESCALER_256              (IWDG_PR_PR_2 | IWDG_PR_PR_1)         /*!< Divider by 256 */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup IWDG_LL_Exported_Macros IWDG Exported Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup IWDG_LL_EM_WRITE_READ Common Write and read registers Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write a value in IWDG register
 | 
			
		||||
  * @param  __INSTANCE__ IWDG Instance
 | 
			
		||||
  * @param  __REG__ Register to be written
 | 
			
		||||
  * @param  __VALUE__ Value to be written in the register
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
#define LL_IWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Read a value in IWDG register
 | 
			
		||||
  * @param  __INSTANCE__ IWDG Instance
 | 
			
		||||
  * @param  __REG__ Register to be read
 | 
			
		||||
  * @retval Register value
 | 
			
		||||
  */
 | 
			
		||||
#define LL_IWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup IWDG_LL_Exported_Functions IWDG Exported Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/** @defgroup IWDG_LL_EF_Configuration Configuration
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Start the Independent Watchdog
 | 
			
		||||
  * @note   Except if the hardware watchdog option is selected
 | 
			
		||||
  * @rmtoll KR           KEY           LL_IWDG_Enable
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_IWDG_Enable(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(IWDG->KR, LL_IWDG_KEY_ENABLE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Reloads IWDG counter with value defined in the reload register
 | 
			
		||||
  * @rmtoll KR           KEY           LL_IWDG_ReloadCounter
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_IWDG_ReloadCounter(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(IWDG->KR, LL_IWDG_KEY_RELOAD);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
 | 
			
		||||
  * @rmtoll KR           KEY           LL_IWDG_EnableWriteAccess
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_IWDG_EnableWriteAccess(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(IWDG->KR, LL_IWDG_KEY_WR_ACCESS_ENABLE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable write access to IWDG_PR, IWDG_RLR and IWDG_WINR registers
 | 
			
		||||
  * @rmtoll KR           KEY           LL_IWDG_DisableWriteAccess
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_IWDG_DisableWriteAccess(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(IWDG->KR, LL_IWDG_KEY_WR_ACCESS_DISABLE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Select the prescaler of the IWDG
 | 
			
		||||
  * @rmtoll PR           PR            LL_IWDG_SetPrescaler
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @param  Prescaler This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_4
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_8
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_16
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_32
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_64
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_128
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_256
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_IWDG_SetPrescaler(IWDG_TypeDef *IWDGx, uint32_t Prescaler)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(IWDGx->PR, IWDG_PR_PR & Prescaler);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get the selected prescaler of the IWDG
 | 
			
		||||
  * @rmtoll PR           PR            LL_IWDG_GetPrescaler
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_4
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_8
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_16
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_32
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_64
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_128
 | 
			
		||||
  *         @arg @ref LL_IWDG_PRESCALER_256
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_IWDG_GetPrescaler(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(IWDGx->PR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Specify the IWDG down-counter reload value
 | 
			
		||||
  * @rmtoll RLR          RL            LL_IWDG_SetReloadCounter
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @param  Counter Value between Min_Data=0 and Max_Data=0x0FFF
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_IWDG_SetReloadCounter(IWDG_TypeDef *IWDGx, uint32_t Counter)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(IWDGx->RLR, IWDG_RLR_RL & Counter);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get the specified IWDG down-counter reload value
 | 
			
		||||
  * @rmtoll RLR          RL            LL_IWDG_GetReloadCounter
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval Value between Min_Data=0 and Max_Data=0x0FFF
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_IWDG_GetReloadCounter(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(IWDGx->RLR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Specify high limit of the window value to be compared to the down-counter.
 | 
			
		||||
  * @rmtoll WINR         WIN           LL_IWDG_SetWindow
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @param  Window Value between Min_Data=0 and Max_Data=0x0FFF
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_IWDG_SetWindow(IWDG_TypeDef *IWDGx, uint32_t Window)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(IWDGx->WINR, IWDG_WINR_WIN & Window);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get the high limit of the window value specified.
 | 
			
		||||
  * @rmtoll WINR         WIN           LL_IWDG_GetWindow
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval Value between Min_Data=0 and Max_Data=0x0FFF
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_IWDG_GetWindow(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(IWDGx->WINR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup IWDG_LL_EF_FLAG_Management FLAG_Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if flag Prescaler Value Update is set or not
 | 
			
		||||
  * @rmtoll SR           PVU           LL_IWDG_IsActiveFlag_PVU
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_PVU(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(IWDGx->SR, IWDG_SR_PVU) == (IWDG_SR_PVU));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if flag Reload Value Update is set or not
 | 
			
		||||
  * @rmtoll SR           RVU           LL_IWDG_IsActiveFlag_RVU
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_RVU(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(IWDGx->SR, IWDG_SR_RVU) == (IWDG_SR_RVU));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if flag Window Value Update is set or not
 | 
			
		||||
  * @rmtoll SR           WVU           LL_IWDG_IsActiveFlag_WVU
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_IWDG_IsActiveFlag_WVU(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(IWDGx->SR, IWDG_SR_WVU) == (IWDG_SR_WVU));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if all flags Prescaler, Reload & Window Value Update are reset or not
 | 
			
		||||
  * @rmtoll SR           PVU           LL_IWDG_IsReady\n
 | 
			
		||||
  *         SR           WVU           LL_IWDG_IsReady\n
 | 
			
		||||
  *         SR           RVU           LL_IWDG_IsReady
 | 
			
		||||
  * @param  IWDGx IWDG Instance
 | 
			
		||||
  * @retval State of bits (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_IWDG_IsReady(IWDG_TypeDef *IWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(IWDGx->SR, IWDG_SR_PVU | IWDG_SR_RVU | IWDG_SR_WVU) == 0U);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* IWDG) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32L0xx_LL_IWDG_H */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,212 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_lptim.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   LPTIM LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_lptim.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
  #include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
  #define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (LPTIM1) || defined (LPTIM2)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup LPTIM_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup LPTIM_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define IS_LPTIM_CLOCK_SOURCE(__VALUE__) (((__VALUE__) == LL_LPTIM_CLK_SOURCE_INTERNAL) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_LPTIM_CLK_SOURCE_EXTERNAL))
 | 
			
		||||
 | 
			
		||||
#define IS_LPTIM_CLOCK_PRESCALER(__VALUE__) (((__VALUE__) == LL_LPTIM_PRESCALER_DIV1)   \
 | 
			
		||||
                                          || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV2)   \
 | 
			
		||||
                                          || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV4)   \
 | 
			
		||||
                                          || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV8)   \
 | 
			
		||||
                                          || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV16)  \
 | 
			
		||||
                                          || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV32)  \
 | 
			
		||||
                                          || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV64)  \
 | 
			
		||||
                                          || ((__VALUE__) == LL_LPTIM_PRESCALER_DIV128))
 | 
			
		||||
 | 
			
		||||
#define IS_LPTIM_WAVEFORM(__VALUE__) (((__VALUE__) == LL_LPTIM_OUTPUT_WAVEFORM_PWM) \
 | 
			
		||||
                                   || ((__VALUE__) == LL_LPTIM_OUTPUT_WAVEFORM_SETONCE))
 | 
			
		||||
 | 
			
		||||
#define IS_LPTIM_OUTPUT_POLARITY(__VALUE__) (((__VALUE__) == LL_LPTIM_OUTPUT_POLARITY_REGULAR) \
 | 
			
		||||
                                          || ((__VALUE__) == LL_LPTIM_OUTPUT_POLARITY_INVERSE))
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup LPTIM_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup LPTIM_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set LPTIMx registers to their reset values.
 | 
			
		||||
  * @param  LPTIMx LP Timer instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: LPTIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: invalid LPTIMx instance
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_LPTIM_DeInit(LPTIM_TypeDef* LPTIMx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus result = SUCCESS;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_LPTIM_INSTANCE(LPTIMx)); 
 | 
			
		||||
 
 | 
			
		||||
  if (LPTIMx == LPTIM1)
 | 
			
		||||
  {
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_LPTIM1);
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_LPTIM1);  
 | 
			
		||||
  } 
 | 
			
		||||
#if defined(LPTIM2)  
 | 
			
		||||
  else if (LPTIMx == LPTIM2)
 | 
			
		||||
  { 
 | 
			
		||||
    LL_APB1_GRP2_ForceReset(LL_APB1_GRP2_PERIPH_LPTIM2);
 | 
			
		||||
    LL_APB1_GRP2_ReleaseReset(LL_APB1_GRP2_PERIPH_LPTIM2);
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    result = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each fields of the LPTIM_InitStruct structure to its default
 | 
			
		||||
  *         value.
 | 
			
		||||
  * @param  LPTIM_InitStruct pointer to a @ref LL_LPTIM_InitTypeDef structure
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_LPTIM_StructInit(LL_LPTIM_InitTypeDef* LPTIM_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set the default configuration */
 | 
			
		||||
  LPTIM_InitStruct->ClockSource = LL_LPTIM_CLK_SOURCE_INTERNAL;
 | 
			
		||||
  LPTIM_InitStruct->Prescaler   = LL_LPTIM_PRESCALER_DIV1;
 | 
			
		||||
  LPTIM_InitStruct->Waveform    = LL_LPTIM_OUTPUT_WAVEFORM_PWM;
 | 
			
		||||
  LPTIM_InitStruct->Polarity    = LL_LPTIM_OUTPUT_POLARITY_REGULAR;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the LPTIMx peripheral according to the specified parameters.
 | 
			
		||||
  * @note LL_LPTIM_Init can only be called when the LPTIM instance is disabled.
 | 
			
		||||
  * @note LPTIMx can be disabled using unitary function @ref LL_LPTIM_Disable().
 | 
			
		||||
  * @param  LPTIMx LP Timer Instance
 | 
			
		||||
  * @param  LPTIM_InitStruct pointer to a @ref LL_LPTIM_InitTypeDef structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: LPTIMx instance has been initialized
 | 
			
		||||
  *          - ERROR: LPTIMx instance hasn't been initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_LPTIM_Init(LPTIM_TypeDef * LPTIMx, LL_LPTIM_InitTypeDef* LPTIM_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus result = SUCCESS;
 | 
			
		||||
  
 | 
			
		||||
  /* The LPTIMx_CFGR register must only be modified when the LPTIM is disabled 
 | 
			
		||||
     (ENABLE bit is reset to 0).
 | 
			
		||||
  */
 | 
			
		||||
  if (LL_LPTIM_IsEnabled(LPTIMx))
 | 
			
		||||
  {
 | 
			
		||||
    result = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_LPTIM_INSTANCE(LPTIMx)); 
 | 
			
		||||
  assert_param(IS_LPTIM_CLOCK_SOURCE(LPTIM_InitStruct->ClockSource));
 | 
			
		||||
  assert_param(IS_LPTIM_CLOCK_PRESCALER(LPTIM_InitStruct->Prescaler));
 | 
			
		||||
  assert_param(IS_LPTIM_WAVEFORM(LPTIM_InitStruct->Waveform));
 | 
			
		||||
  assert_param(IS_LPTIM_OUTPUT_POLARITY(LPTIM_InitStruct->Polarity));
 | 
			
		||||
  
 | 
			
		||||
  /* Set CKSEL bitfield according to ClockSource value */
 | 
			
		||||
  /* Set PRESC bitfield according to Prescaler value */
 | 
			
		||||
  /* Set WAVE bitfield according to Waveform value */
 | 
			
		||||
  /* Set WAVEPOL bitfield according to Polarity value */
 | 
			
		||||
  MODIFY_REG(LPTIMx->CFGR, 
 | 
			
		||||
             (LPTIM_CFGR_CKSEL | LPTIM_CFGR_PRESC | LPTIM_CFGR_WAVE| LPTIM_CFGR_WAVPOL), 
 | 
			
		||||
             LPTIM_InitStruct->ClockSource | \
 | 
			
		||||
             LPTIM_InitStruct->Prescaler | \
 | 
			
		||||
             LPTIM_InitStruct->Waveform | \
 | 
			
		||||
             LPTIM_InitStruct->Polarity);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined (LPTIM1) || defined (LPTIM2) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
  
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,259 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_lpuart.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   LPUART LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_lpuart.h"
 | 
			
		||||
#include "stm32l0xx_ll_rcc.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (LPUART1)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup LPUART_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup LPUART_LL_Private_Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup LPUART_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Check of parameters for configuration of LPUART registers                  */
 | 
			
		||||
 | 
			
		||||
/* __BAUDRATE__ Depending on constraints applicable for LPUART BRR register   */
 | 
			
		||||
/*              value :                                                       */
 | 
			
		||||
/*                - fck must be in the range [3 x baudrate, 4096 x baudrate]  */
 | 
			
		||||
/*                - LPUART_BRR register value should be >= 0x300              */
 | 
			
		||||
/*                - LPUART_BRR register value should be <= 0xFFFFF (20 bits)  */
 | 
			
		||||
/*              Baudrate specified by the user should belong to [8, 10600000].*/
 | 
			
		||||
#define IS_LL_LPUART_BAUDRATE(__BAUDRATE__) (((__BAUDRATE__) <= 10600000U) && ((__BAUDRATE__) >= 8U))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_LPUART_DIRECTION(__VALUE__) (((__VALUE__) == LL_LPUART_DIRECTION_NONE) \
 | 
			
		||||
                                        || ((__VALUE__) == LL_LPUART_DIRECTION_RX) \
 | 
			
		||||
                                        || ((__VALUE__) == LL_LPUART_DIRECTION_TX) \
 | 
			
		||||
                                        || ((__VALUE__) == LL_LPUART_DIRECTION_TX_RX))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_LPUART_PARITY(__VALUE__) (((__VALUE__) == LL_LPUART_PARITY_NONE) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_LPUART_PARITY_EVEN) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_LPUART_PARITY_ODD))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_LPUART_DATAWIDTH(__VALUE__) (((__VALUE__) == LL_LPUART_DATAWIDTH_7B) \
 | 
			
		||||
                                        || ((__VALUE__) == LL_LPUART_DATAWIDTH_8B) \
 | 
			
		||||
                                        || ((__VALUE__) == LL_LPUART_DATAWIDTH_9B))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_LPUART_STOPBITS(__VALUE__) (((__VALUE__) == LL_LPUART_STOPBITS_1) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_LPUART_STOPBITS_2))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_LPUART_HWCONTROL(__VALUE__) (((__VALUE__) == LL_LPUART_HWCONTROL_NONE) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_LPUART_HWCONTROL_RTS) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_LPUART_HWCONTROL_CTS) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_LPUART_HWCONTROL_RTS_CTS))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup LPUART_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup LPUART_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize LPUART registers (Registers restored to their default values).
 | 
			
		||||
  * @param  LPUARTx LPUART Instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: LPUART registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_LPUART_DeInit(USART_TypeDef *LPUARTx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_LPUART_INSTANCE(LPUARTx));
 | 
			
		||||
 | 
			
		||||
  /* Force reset of LPUART peripheral */
 | 
			
		||||
  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_LPUART1);
 | 
			
		||||
 | 
			
		||||
  /* Release reset of LPUART peripheral */
 | 
			
		||||
  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_LPUART1);
 | 
			
		||||
 | 
			
		||||
  return (status);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize LPUART registers according to the specified
 | 
			
		||||
  *         parameters in LPUART_InitStruct.
 | 
			
		||||
  * @note   As some bits in LPUART configuration registers can only be written when the LPUART is disabled (USART_CR1_UE bit =0),
 | 
			
		||||
  *         LPUART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
 | 
			
		||||
  * @note   Baud rate value stored in LPUART_InitStruct BaudRate field, should be valid (different from 0).
 | 
			
		||||
  * @param  LPUARTx LPUART Instance
 | 
			
		||||
  * @param  LPUART_InitStruct pointer to a @ref LL_LPUART_InitTypeDef structure
 | 
			
		||||
  *         that contains the configuration information for the specified LPUART peripheral.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: LPUART registers are initialized according to LPUART_InitStruct content
 | 
			
		||||
  *          - ERROR: Problem occurred during LPUART Registers initialization
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_LPUART_Init(USART_TypeDef *LPUARTx, LL_LPUART_InitTypeDef *LPUART_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = ERROR;
 | 
			
		||||
  uint32_t periphclk = LL_RCC_PERIPH_FREQUENCY_NO;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_LPUART_INSTANCE(LPUARTx));
 | 
			
		||||
  assert_param(IS_LL_LPUART_BAUDRATE(LPUART_InitStruct->BaudRate));
 | 
			
		||||
  assert_param(IS_LL_LPUART_DATAWIDTH(LPUART_InitStruct->DataWidth));
 | 
			
		||||
  assert_param(IS_LL_LPUART_STOPBITS(LPUART_InitStruct->StopBits));
 | 
			
		||||
  assert_param(IS_LL_LPUART_PARITY(LPUART_InitStruct->Parity));
 | 
			
		||||
  assert_param(IS_LL_LPUART_DIRECTION(LPUART_InitStruct->TransferDirection));
 | 
			
		||||
  assert_param(IS_LL_LPUART_HWCONTROL(LPUART_InitStruct->HardwareFlowControl));
 | 
			
		||||
 | 
			
		||||
  /* LPUART needs to be in disabled state, in order to be able to configure some bits in
 | 
			
		||||
     CRx registers. Otherwise (LPUART not in Disabled state) => return ERROR */
 | 
			
		||||
  if (LL_LPUART_IsEnabled(LPUARTx) == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    /*---------------------------- LPUART CR1 Configuration -----------------------
 | 
			
		||||
     * Configure LPUARTx CR1 (LPUART Word Length, Parity and Transfer Direction bits) with parameters:
 | 
			
		||||
     * - DataWidth:          USART_CR1_M bits according to LPUART_InitStruct->DataWidth value
 | 
			
		||||
     * - Parity:             USART_CR1_PCE, USART_CR1_PS bits according to LPUART_InitStruct->Parity value
 | 
			
		||||
     * - TransferDirection:  USART_CR1_TE, USART_CR1_RE bits according to LPUART_InitStruct->TransferDirection value
 | 
			
		||||
     */
 | 
			
		||||
    MODIFY_REG(LPUARTx->CR1,
 | 
			
		||||
               (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS | USART_CR1_TE | USART_CR1_RE),
 | 
			
		||||
               (LPUART_InitStruct->DataWidth | LPUART_InitStruct->Parity | LPUART_InitStruct->TransferDirection));
 | 
			
		||||
 | 
			
		||||
    /*---------------------------- LPUART CR2 Configuration -----------------------
 | 
			
		||||
     * Configure LPUARTx CR2 (Stop bits) with parameters:
 | 
			
		||||
     * - Stop Bits:          USART_CR2_STOP bits according to LPUART_InitStruct->StopBits value.
 | 
			
		||||
     */
 | 
			
		||||
    LL_LPUART_SetStopBitsLength(LPUARTx, LPUART_InitStruct->StopBits);
 | 
			
		||||
 | 
			
		||||
    /*---------------------------- LPUART CR3 Configuration -----------------------
 | 
			
		||||
     * Configure LPUARTx CR3 (Hardware Flow Control) with parameters:
 | 
			
		||||
     * - HardwareFlowControl: USART_CR3_RTSE, USART_CR3_CTSE bits according to LPUART_InitStruct->HardwareFlowControl value.
 | 
			
		||||
     */
 | 
			
		||||
    LL_LPUART_SetHWFlowCtrl(LPUARTx, LPUART_InitStruct->HardwareFlowControl);
 | 
			
		||||
 | 
			
		||||
    /*---------------------------- LPUART BRR Configuration -----------------------
 | 
			
		||||
     * Retrieve Clock frequency used for LPUART Peripheral
 | 
			
		||||
     */
 | 
			
		||||
    periphclk = LL_RCC_GetLPUARTClockFreq(LL_RCC_LPUART1_CLKSOURCE);
 | 
			
		||||
 | 
			
		||||
    /* Configure the LPUART Baud Rate :
 | 
			
		||||
       - valid baud rate value (different from 0) is required
 | 
			
		||||
       - Peripheral clock as returned by RCC service, should be valid (different from 0).
 | 
			
		||||
    */
 | 
			
		||||
    if ((periphclk != LL_RCC_PERIPH_FREQUENCY_NO)
 | 
			
		||||
        && (LPUART_InitStruct->BaudRate != 0U))
 | 
			
		||||
    {
 | 
			
		||||
      status = SUCCESS;
 | 
			
		||||
      LL_LPUART_SetBaudRate(LPUARTx,
 | 
			
		||||
                            periphclk,
 | 
			
		||||
                            LPUART_InitStruct->BaudRate);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return (status);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Set each @ref LL_LPUART_InitTypeDef field to default value.
 | 
			
		||||
  * @param LPUART_InitStruct pointer to a @ref LL_LPUART_InitTypeDef structure
 | 
			
		||||
  *                          whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
void LL_LPUART_StructInit(LL_LPUART_InitTypeDef *LPUART_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set LPUART_InitStruct fields to default values */
 | 
			
		||||
  LPUART_InitStruct->BaudRate            = 9600U;
 | 
			
		||||
  LPUART_InitStruct->DataWidth           = LL_LPUART_DATAWIDTH_8B;
 | 
			
		||||
  LPUART_InitStruct->StopBits            = LL_LPUART_STOPBITS_1;
 | 
			
		||||
  LPUART_InitStruct->Parity              = LL_LPUART_PARITY_NONE ;
 | 
			
		||||
  LPUART_InitStruct->TransferDirection   = LL_LPUART_DIRECTION_TX_RX;
 | 
			
		||||
  LPUART_InitStruct->HardwareFlowControl = LL_LPUART_HWCONTROL_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined (LPUART1) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,103 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_pwr.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   PWR LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_pwr.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(PWR)
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL PWR
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup PWR_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup PWR_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize the PWR registers to their default reset values.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: PWR registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_PWR_DeInit(void)
 | 
			
		||||
{
 | 
			
		||||
  /* Force reset of PWR clock */
 | 
			
		||||
  LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_PWR);
 | 
			
		||||
 | 
			
		||||
  /* Release reset of PWR clock */
 | 
			
		||||
  LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_PWR);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* defined(PWR) */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,774 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_pwr.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   Header file of PWR LL module.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32L0xx_LL_PWR_H
 | 
			
		||||
#define __STM32L0xx_LL_PWR_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(PWR)
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL PWR
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup PWR_LL_Exported_Constants PWR Exported Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL_EC_CLEAR_FLAG Clear Flags Defines
 | 
			
		||||
  * @brief    Flags defines which can be used with LL_PWR_WriteReg function
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_PWR_CR_CSBF                     PWR_CR_CSBF            /*!< Clear standby flag */
 | 
			
		||||
#define LL_PWR_CR_CWUF                     PWR_CR_CWUF            /*!< Clear wakeup flag */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL_EC_GET_FLAG Get Flags Defines
 | 
			
		||||
  * @brief    Flags defines which can be used with LL_PWR_ReadReg function
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_PWR_CSR_WUF                     PWR_CSR_WUF            /*!< Wakeup flag */
 | 
			
		||||
#define LL_PWR_CSR_SBF                     PWR_CSR_SBF            /*!< Standby flag */
 | 
			
		||||
#if defined (PWR_PVD_SUPPORT)
 | 
			
		||||
#define LL_PWR_CSR_PVDO                    PWR_CSR_PVDO           /*!< Power voltage detector output flag */
 | 
			
		||||
#endif
 | 
			
		||||
#if defined (PWR_CSR_VREFINTRDYF)
 | 
			
		||||
#define LL_PWR_CSR_VREFINTRDYF             PWR_CSR_VREFINTRDYF    /*!< VREFINT ready flag */
 | 
			
		||||
#endif
 | 
			
		||||
#define LL_PWR_CSR_VOSF                    PWR_CSR_VOSF           /*!< Voltage scaling select flag */
 | 
			
		||||
#define LL_PWR_CSR_REGLPF                  PWR_CSR_REGLPF         /*!< Regulator low power flag */
 | 
			
		||||
#define LL_PWR_CSR_EWUP1                   PWR_CSR_EWUP1          /*!< Enable WKUP pin 1 */
 | 
			
		||||
#define LL_PWR_CSR_EWUP2                   PWR_CSR_EWUP2          /*!< Enable WKUP pin 2 */
 | 
			
		||||
#if defined (PWR_CSR_EWUP3)
 | 
			
		||||
#define LL_PWR_CSR_EWUP3                   PWR_CSR_EWUP3          /*!< Enable WKUP pin 3 */
 | 
			
		||||
#endif /* PWR_CSR_EWUP3 */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL_EC_REGU_VOLTAGE Regulator Voltage
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_PWR_REGU_VOLTAGE_SCALE1         (PWR_CR_VOS_0)                   /*!< 1.8V (range 1) */
 | 
			
		||||
#define LL_PWR_REGU_VOLTAGE_SCALE2         (PWR_CR_VOS_1)                   /*!< 1.5V (range 2) */
 | 
			
		||||
#define LL_PWR_REGU_VOLTAGE_SCALE3         (PWR_CR_VOS_0 | PWR_CR_VOS_1)    /*!< 1.2V (range 3) */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL_EC_MODE_PWR Mode Power
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_PWR_MODE_STOP                   ((uint32_t)0x00000000U)        /*!< Enter Stop mode when the CPU enters deepsleep */
 | 
			
		||||
#define LL_PWR_MODE_STANDBY                (PWR_CR_PDDS)                  /*!< Enter Standby mode when the CPU enters deepsleep */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL_EC_REGU_MODE_LP_MODES  Regulator Mode In Low Power Modes
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_PWR_REGU_LPMODES_MAIN           ((uint32_t)0x00000000U)        /*!< Voltage regulator in main mode during deepsleep/sleep/low-power run mode */
 | 
			
		||||
#define LL_PWR_REGU_LPMODES_LOW_POWER      (PWR_CR_LPSDSR)                /*!< Voltage regulator in low-power mode during deepsleep/sleep/low-power run mode */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(PWR_CR_LPDS)
 | 
			
		||||
/** @defgroup PWR_LL_EC_REGU_MODE_DS_MODE  Regulator Mode In Deep Sleep Mode
 | 
			
		||||
 * @{
 | 
			
		||||
 */
 | 
			
		||||
#define LL_PWR_REGU_DSMODE_MAIN       ((uint32_t)0x00000000U)        /*!< Voltage regulator in main mode during deepsleep mode when PWR_CR_LPSDSR = 0 */
 | 
			
		||||
#define LL_PWR_REGU_DSMODE_LOW_POWER  (PWR_CR_LPDS)                  /*!< Voltage regulator in low-power mode during deepsleep mode when PWR_CR_LPSDSR = 0 */
 | 
			
		||||
/**
 | 
			
		||||
 * @}
 | 
			
		||||
 */
 | 
			
		||||
#endif /* PWR_CR_LPDS */
 | 
			
		||||
 | 
			
		||||
#if defined (PWR_PVD_SUPPORT)
 | 
			
		||||
/** @defgroup PWR_LL_EC_PVDLEVEL Power Voltage Detector Level
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_PWR_PVDLEVEL_0                  (PWR_CR_PLS_LEV0)      /*!< Voltage threshold detected by PVD 1.9 V */
 | 
			
		||||
#define LL_PWR_PVDLEVEL_1                  (PWR_CR_PLS_LEV1)      /*!< Voltage threshold detected by PVD 2.1 V */
 | 
			
		||||
#define LL_PWR_PVDLEVEL_2                  (PWR_CR_PLS_LEV2)      /*!< Voltage threshold detected by PVD 2.3 V */
 | 
			
		||||
#define LL_PWR_PVDLEVEL_3                  (PWR_CR_PLS_LEV3)      /*!< Voltage threshold detected by PVD 2.5 V */
 | 
			
		||||
#define LL_PWR_PVDLEVEL_4                  (PWR_CR_PLS_LEV4)      /*!< Voltage threshold detected by PVD 2.7 V */
 | 
			
		||||
#define LL_PWR_PVDLEVEL_5                  (PWR_CR_PLS_LEV5)      /*!< Voltage threshold detected by PVD 2.9 V */
 | 
			
		||||
#define LL_PWR_PVDLEVEL_6                  (PWR_CR_PLS_LEV6)      /*!< Voltage threshold detected by PVD 3.1 V */
 | 
			
		||||
#define LL_PWR_PVDLEVEL_7                  (PWR_CR_PLS_LEV7)      /*!< External input analog voltage   (Compare internally to VREFINT) */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL_EC_WAKEUP_PIN  Wakeup Pins
 | 
			
		||||
* @{
 | 
			
		||||
*/
 | 
			
		||||
#define LL_PWR_WAKEUP_PIN1                 (PWR_CSR_EWUP1)        /*!< WKUP pin 1 : PA0 */
 | 
			
		||||
#define LL_PWR_WAKEUP_PIN2                 (PWR_CSR_EWUP2)        /*!< WKUP pin 2 : PC13 */
 | 
			
		||||
#if defined (PWR_CSR_EWUP3)
 | 
			
		||||
#define LL_PWR_WAKEUP_PIN3                 (PWR_CSR_EWUP3)        /*!< WKUP pin 3 : PE6 or PA2 according to device */
 | 
			
		||||
#endif /* PWR_CSR_EWUP3 */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup PWR_LL_Exported_Macros PWR Exported Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL_EM_WRITE_READ Common write and read registers Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write a value in PWR register
 | 
			
		||||
  * @param  __REG__ Register to be written
 | 
			
		||||
  * @param  __VALUE__ Value to be written in the register
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
#define LL_PWR_WriteReg(__REG__, __VALUE__) WRITE_REG(PWR->__REG__, (__VALUE__))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Read a value in PWR register
 | 
			
		||||
  * @param  __REG__ Register to be read
 | 
			
		||||
  * @retval Register value
 | 
			
		||||
  */
 | 
			
		||||
#define LL_PWR_ReadReg(__REG__) READ_REG(PWR->__REG__)
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup PWR_LL_Exported_Functions PWR Exported Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL_EF_Configuration Configuration
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Switch the regulator from main mode to low-power mode
 | 
			
		||||
  * @rmtoll CR    LPRUN       LL_PWR_EnableLowPowerRunMode
 | 
			
		||||
  * @note   Remind to set the regulator to low power before enabling
 | 
			
		||||
  *         LowPower run mode (bit @ref LL_PWR_REGU_LPMODES_LOW_POWER).
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_EnableLowPowerRunMode(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(PWR->CR, PWR_CR_LPRUN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Switch the regulator from low-power mode to main mode
 | 
			
		||||
  * @rmtoll CR    LPRUN       LL_PWR_DisableLowPowerRunMode
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_DisableLowPowerRunMode(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(PWR->CR, PWR_CR_LPRUN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if the regulator is in low-power mode
 | 
			
		||||
  * @rmtoll CR    LPRUN       LL_PWR_IsEnabledLowPowerRunMode
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsEnabledLowPowerRunMode(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CR, PWR_CR_LPRUN) == (PWR_CR_LPRUN));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set voltage regulator to low-power and switch from 
 | 
			
		||||
  *         run main mode to run low-power mode.
 | 
			
		||||
  * @rmtoll CR    LPSDSR       LL_PWR_EnterLowPowerRunMode\n
 | 
			
		||||
  *         CR    LPRUN        LL_PWR_EnterLowPowerRunMode
 | 
			
		||||
  * @note   This "high level" function is introduced to provide functional
 | 
			
		||||
  *         compatibility with other families. Notice that the two registers
 | 
			
		||||
  *         have to be written sequentially, so this function is not atomic.
 | 
			
		||||
  *         To assure atomicity you can call separately the following functions:
 | 
			
		||||
  *         - @ref LL_PWR_SetRegulModeLP(@ref LL_PWR_REGU_LPMODES_LOW_POWER);
 | 
			
		||||
  *         - @ref LL_PWR_EnableLowPowerRunMode();
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_EnterLowPowerRunMode(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(PWR->CR, PWR_CR_LPSDSR); /* => LL_PWR_SetRegulModeLP(LL_PWR_REGU_LPMODES_LOW_POWER) */
 | 
			
		||||
  SET_BIT(PWR->CR, PWR_CR_LPRUN);  /* => LL_PWR_EnableLowPowerRunMode() */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set voltage regulator to main and switch from 
 | 
			
		||||
  *         run main mode to low-power mode.
 | 
			
		||||
  * @rmtoll CR    LPSDSR       LL_PWR_ExitLowPowerRunMode\n
 | 
			
		||||
  *         CR    LPRUN        LL_PWR_ExitLowPowerRunMode
 | 
			
		||||
  * @note   This "high level" function is introduced to provide functional   
 | 
			
		||||
  *         compatibility with other families. Notice that the two registers 
 | 
			
		||||
  *         have to be written sequentially, so this function is not atomic.
 | 
			
		||||
  *         To assure atomicity you can call separately the following functions:
 | 
			
		||||
  *         - @ref LL_PWR_DisableLowPowerRunMode();
 | 
			
		||||
  *         - @ref LL_PWR_SetRegulModeLP(@ref LL_PWR_REGU_LPMODES_MAIN);
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_ExitLowPowerRunMode(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(PWR->CR, PWR_CR_LPRUN);   /* => LL_PWR_DisableLowPowerRunMode() */
 | 
			
		||||
  CLEAR_BIT(PWR->CR, PWR_CR_LPSDSR);  /* => LL_PWR_SetRegulModeLP(LL_PWR_REGU_LPMODES_MAIN) */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the main internal regulator output voltage
 | 
			
		||||
  * @rmtoll CR    VOS       LL_PWR_SetRegulVoltageScaling
 | 
			
		||||
  * @param  VoltageScaling This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_VOLTAGE_SCALE3
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_SetRegulVoltageScaling(uint32_t VoltageScaling)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(PWR->CR, PWR_CR_VOS, VoltageScaling);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get the main internal regulator output voltage
 | 
			
		||||
  * @rmtoll CR    VOS       LL_PWR_GetRegulVoltageScaling
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_VOLTAGE_SCALE1
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_VOLTAGE_SCALE2
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_VOLTAGE_SCALE3
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_GetRegulVoltageScaling(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_VOS));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable access to the backup domain
 | 
			
		||||
  * @rmtoll CR    DBP       LL_PWR_EnableBkUpAccess
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_EnableBkUpAccess(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(PWR->CR, PWR_CR_DBP);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable access to the backup domain
 | 
			
		||||
  * @rmtoll CR    DBP       LL_PWR_DisableBkUpAccess
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_DisableBkUpAccess(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(PWR->CR, PWR_CR_DBP);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if the backup domain is enabled
 | 
			
		||||
  * @rmtoll CR    DBP       LL_PWR_IsEnabledBkUpAccess
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsEnabledBkUpAccess(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CR, PWR_CR_DBP) == (PWR_CR_DBP));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set voltage regulator mode during low power modes
 | 
			
		||||
  * @rmtoll CR    LPSDSR       LL_PWR_SetRegulModeLP
 | 
			
		||||
  * @param  RegulMode This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_LPMODES_MAIN
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_LPMODES_LOW_POWER
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_SetRegulModeLP(uint32_t RegulMode)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(PWR->CR, PWR_CR_LPSDSR, RegulMode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get voltage regulator mode during low power modes
 | 
			
		||||
  * @rmtoll CR    LPSDSR       LL_PWR_GetRegulModeLP
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_LPMODES_MAIN
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_LPMODES_LOW_POWER
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_GetRegulModeLP(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_LPSDSR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if defined(PWR_CR_LPDS)
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set voltage regulator mode during deep sleep mode
 | 
			
		||||
  * @rmtoll CR    LPDS         LL_PWR_SetRegulModeDS
 | 
			
		||||
  * @param  RegulMode This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_DSMODE_MAIN
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_DSMODE_LOW_POWER
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_SetRegulModeDS(uint32_t RegulMode)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(PWR->CR, PWR_CR_LPDS, RegulMode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get voltage regulator mode during deep sleep mode
 | 
			
		||||
  * @rmtoll CR    LPDS         LL_PWR_GetRegulModeDS
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_DSMODE_MAIN
 | 
			
		||||
  *         @arg @ref LL_PWR_REGU_DSMODE_LOW_POWER
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_GetRegulModeDS(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_LPDS));
 | 
			
		||||
}
 | 
			
		||||
#endif /* PWR_CR_LPDS */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set power down mode when CPU enters deepsleep
 | 
			
		||||
  * @rmtoll CR    PDDS         LL_PWR_SetPowerMode
 | 
			
		||||
  * @param  PDMode This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_MODE_STOP
 | 
			
		||||
  *         @arg @ref LL_PWR_MODE_STANDBY
 | 
			
		||||
  * @note   Set the regulator to low power (bit @ref LL_PWR_REGU_LPMODES_LOW_POWER)  
 | 
			
		||||
  *         before setting MODE_STOP. If the regulator remains in "main mode",   
 | 
			
		||||
  *         it consumes more power without providing any additional feature. 
 | 
			
		||||
  *         In MODE_STANDBY the regulator is automatically off.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_SetPowerMode(uint32_t PDMode)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(PWR->CR, PWR_CR_PDDS, PDMode);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get power down mode when CPU enters deepsleep
 | 
			
		||||
  * @rmtoll CR    PDDS         LL_PWR_GetPowerMode
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_MODE_STOP
 | 
			
		||||
  *         @arg @ref LL_PWR_MODE_STANDBY
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_GetPowerMode(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_PDDS));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if defined (PWR_PVD_SUPPORT)
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the voltage threshold detected by the Power Voltage Detector
 | 
			
		||||
  * @rmtoll CR    PLS       LL_PWR_SetPVDLevel
 | 
			
		||||
  * @param  PVDLevel This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_0
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_1
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_2
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_3
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_4
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_5
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_6
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_7
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_SetPVDLevel(uint32_t PVDLevel)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(PWR->CR, PWR_CR_PLS, PVDLevel);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get the voltage threshold detection
 | 
			
		||||
  * @rmtoll CR    PLS       LL_PWR_GetPVDLevel
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_0
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_1
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_2
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_3
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_4
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_5
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_6
 | 
			
		||||
  *         @arg @ref LL_PWR_PVDLEVEL_7
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_GetPVDLevel(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(PWR->CR, PWR_CR_PLS));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable Power Voltage Detector
 | 
			
		||||
  * @rmtoll CR    PVDE       LL_PWR_EnablePVD
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_EnablePVD(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(PWR->CR, PWR_CR_PVDE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable Power Voltage Detector
 | 
			
		||||
  * @rmtoll CR    PVDE       LL_PWR_DisablePVD
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_DisablePVD(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(PWR->CR, PWR_CR_PVDE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Power Voltage Detector is enabled
 | 
			
		||||
  * @rmtoll CR    PVDE       LL_PWR_IsEnabledPVD
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsEnabledPVD(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CR, PWR_CR_PVDE) == (PWR_CR_PVDE));
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable the WakeUp PINx functionality
 | 
			
		||||
  * @rmtoll CSR   EWUP1       LL_PWR_EnableWakeUpPin\n
 | 
			
		||||
  *         CSR   EWUP2       LL_PWR_EnableWakeUpPin\n
 | 
			
		||||
  *         CSR   EWUP3       LL_PWR_EnableWakeUpPin
 | 
			
		||||
  * @param  WakeUpPin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_WAKEUP_PIN1
 | 
			
		||||
  *         @arg @ref LL_PWR_WAKEUP_PIN2
 | 
			
		||||
  *         @arg @ref LL_PWR_WAKEUP_PIN3 (*)
 | 
			
		||||
  *
 | 
			
		||||
  *         (*) not available on all devices
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_EnableWakeUpPin(uint32_t WakeUpPin)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(PWR->CSR, WakeUpPin);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable the WakeUp PINx functionality
 | 
			
		||||
  * @rmtoll CSR   EWUP1       LL_PWR_DisableWakeUpPin\n
 | 
			
		||||
  *         CSR   EWUP2       LL_PWR_DisableWakeUpPin\n
 | 
			
		||||
  *         CSR   EWUP3       LL_PWR_DisableWakeUpPin
 | 
			
		||||
  * @param  WakeUpPin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_WAKEUP_PIN1
 | 
			
		||||
  *         @arg @ref LL_PWR_WAKEUP_PIN2
 | 
			
		||||
  *         @arg @ref LL_PWR_WAKEUP_PIN3 (*)
 | 
			
		||||
  *
 | 
			
		||||
  *         (*) not available on all devices
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_DisableWakeUpPin(uint32_t WakeUpPin)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(PWR->CSR, WakeUpPin);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if the WakeUp PINx functionality is enabled
 | 
			
		||||
  * @rmtoll CSR   EWUP1       LL_PWR_IsEnabledWakeUpPin\n
 | 
			
		||||
  *         CSR   EWUP2       LL_PWR_IsEnabledWakeUpPin\n
 | 
			
		||||
  *         CSR   EWUP3       LL_PWR_IsEnabledWakeUpPin
 | 
			
		||||
  * @param  WakeUpPin This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_PWR_WAKEUP_PIN1
 | 
			
		||||
  *         @arg @ref LL_PWR_WAKEUP_PIN2
 | 
			
		||||
  *         @arg @ref LL_PWR_WAKEUP_PIN3 (*)
 | 
			
		||||
  *
 | 
			
		||||
  *         (*) not available on all devices
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsEnabledWakeUpPin(uint32_t WakeUpPin)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CSR, WakeUpPin) == (WakeUpPin));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable ultra low-power mode by enabling VREFINT switch off in low-power modes
 | 
			
		||||
  * @rmtoll CR    ULP       LL_PWR_EnableUltraLowPower
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_EnableUltraLowPower(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(PWR->CR, PWR_CR_ULP);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable ultra low-power mode by disabling VREFINT switch off in low-power modes
 | 
			
		||||
  * @rmtoll CR    ULP       LL_PWR_DisableUltraLowPower
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_DisableUltraLowPower(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(PWR->CR, PWR_CR_ULP);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if ultra low-power mode is enabled by checking if VREFINT switch off in low-power modes is enabled
 | 
			
		||||
  * @rmtoll CR    ULP       LL_PWR_IsEnabledUltraLowPower
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsEnabledUltraLowPower(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CR, PWR_CR_ULP) == (PWR_CR_ULP));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable fast wakeup by ignoring VREFINT startup time when exiting from low-power mode
 | 
			
		||||
  * @rmtoll CR    FWU       LL_PWR_EnableFastWakeUp
 | 
			
		||||
  * @note   Works in conjunction with ultra low power mode.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_EnableFastWakeUp(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(PWR->CR, PWR_CR_FWU);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable fast wakeup by waiting VREFINT startup time when exiting from low-power mode
 | 
			
		||||
  * @rmtoll CR    FWU       LL_PWR_DisableFastWakeUp
 | 
			
		||||
  * @note   Works in conjunction with ultra low power mode.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_DisableFastWakeUp(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(PWR->CR, PWR_CR_FWU);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if fast wakeup is enabled by checking if VREFINT startup time when exiting from low-power mode is ignored
 | 
			
		||||
  * @rmtoll CR    FWU       LL_PWR_IsEnabledFastWakeUp
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsEnabledFastWakeUp(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CR, PWR_CR_FWU) == (PWR_CR_FWU));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable non-volatile memory (Flash and EEPROM) keeping off feature when exiting from low-power mode
 | 
			
		||||
  * @rmtoll CR    DS_EE_KOFF       LL_PWR_EnableNVMKeptOff
 | 
			
		||||
  * @note   When enabled, after entering low-power mode (Stop or Standby only), if RUN_PD of FLASH_ACR register
 | 
			
		||||
  *         is also set, the Flash memory will not be woken up when exiting from deepsleep mode.
 | 
			
		||||
  *         When enabled, the EEPROM will not be woken up when exiting from low-power mode (if the bit RUN_PD is set)
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_EnableNVMKeptOff(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(PWR->CR, PWR_CR_DSEEKOFF);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable non-volatile memory (Flash and EEPROM) keeping off feature when exiting from low-power mode
 | 
			
		||||
  * @rmtoll CR    DS_EE_KOFF       LL_PWR_DisableNVMKeptOff
 | 
			
		||||
  * @note   When disabled, Flash memory is woken up when exiting from deepsleep mode even if the bit RUN_PD is set
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_DisableNVMKeptOff(void)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(PWR->CR, PWR_CR_DSEEKOFF);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if non-volatile memory (Flash and EEPROM) keeping off feature when exiting from low-power mode is enabled
 | 
			
		||||
  * @rmtoll CR    DS_EE_KOFF       LL_PWR_IsEnabledNVMKeptOff
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsEnabledNVMKeptOff(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CR, PWR_CR_DSEEKOFF) == (PWR_CR_DSEEKOFF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup PWR_LL_EF_FLAG_Management FLAG_Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Wake-up Flag
 | 
			
		||||
  * @rmtoll CSR   WUF       LL_PWR_IsActiveFlag_WU
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_WU(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CSR, PWR_CSR_WUF) == (PWR_CSR_WUF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Standby Flag
 | 
			
		||||
  * @rmtoll CSR   SBF       LL_PWR_IsActiveFlag_SB
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_SB(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CSR, PWR_CSR_SBF) == (PWR_CSR_SBF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if defined (PWR_PVD_SUPPORT)
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Indicate whether VDD voltage is below the selected PVD threshold
 | 
			
		||||
  * @rmtoll CSR   PVDO       LL_PWR_IsActiveFlag_PVDO
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_PVDO(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CSR, PWR_CSR_PVDO) == (PWR_CSR_PVDO));
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#if defined (PWR_CSR_VREFINTRDYF)
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Internal Reference VrefInt Flag
 | 
			
		||||
  * @rmtoll CSR   VREFINTRDYF       LL_PWR_IsActiveFlag_VREFINTRDY
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VREFINTRDY(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CSR, PWR_CSR_VREFINTRDYF) == (PWR_CSR_VREFINTRDYF));
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Indicate whether the regulator is ready in the selected voltage range or if its output voltage is still changing to the required voltage level
 | 
			
		||||
  * @rmtoll CSR   VOSF       LL_PWR_IsActiveFlag_VOSF
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_VOSF(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CSR, PWR_CSR_VOSF) == (PWR_CSR_VOSF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Indicate whether the regulator is ready in main mode or is in low-power mode
 | 
			
		||||
  * @rmtoll CSR   REGLPF       LL_PWR_IsActiveFlag_REGLPF
 | 
			
		||||
  * @note Take care, return value "0" means the regulator is ready.  Return value "1" means the output voltage range is still changing.
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_PWR_IsActiveFlag_REGLPF(void)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(PWR->CSR, PWR_CSR_REGLPF) == (PWR_CSR_REGLPF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Clear Standby Flag
 | 
			
		||||
  * @rmtoll CR   CSBF       LL_PWR_ClearFlag_SB
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_ClearFlag_SB(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(PWR->CR, PWR_CR_CSBF);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Clear Wake-up Flags
 | 
			
		||||
  * @rmtoll CR   CWUF       LL_PWR_ClearFlag_WU
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_PWR_ClearFlag_WU(void)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(PWR->CR, PWR_CR_CWUF);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
/** @defgroup PWR_LL_EF_Init De-initialization function
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_PWR_DeInit(void);
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined(PWR) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32L0xx_LL_PWR_H */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,652 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_rcc.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   RCC LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_rcc.h"
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
  #include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
  #define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif /* USE_FULL_ASSERT */
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(RCC)
 | 
			
		||||
 | 
			
		||||
/** @defgroup RCC_LL RCC
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup RCC_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#if defined(RCC_CCIPR_USART1SEL) && defined(RCC_CCIPR_USART2SEL)
 | 
			
		||||
#define IS_LL_RCC_USART_CLKSOURCE(__VALUE__)  (((__VALUE__) == LL_RCC_USART1_CLKSOURCE) \
 | 
			
		||||
                                            || ((__VALUE__) == LL_RCC_USART2_CLKSOURCE))
 | 
			
		||||
#elif defined(RCC_CCIPR_USART1SEL) && !defined(RCC_CCIPR_USART2SEL)
 | 
			
		||||
#define IS_LL_RCC_USART_CLKSOURCE(__VALUE__)  (((__VALUE__) == LL_RCC_USART1_CLKSOURCE))
 | 
			
		||||
#else
 | 
			
		||||
#define IS_LL_RCC_USART_CLKSOURCE(__VALUE__)  (((__VALUE__) == LL_RCC_USART2_CLKSOURCE))
 | 
			
		||||
#endif /* RCC_CCIPR_USART1SEL && RCC_CCIPR_USART2SEL */
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RCC_LPUART_CLKSOURCE(__VALUE__) (((__VALUE__) == LL_RCC_LPUART1_CLKSOURCE))
 | 
			
		||||
 | 
			
		||||
#if defined(RCC_CCIPR_I2C3SEL) 
 | 
			
		||||
#define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__)    (((__VALUE__) == LL_RCC_I2C1_CLKSOURCE) \
 | 
			
		||||
                                            || ((__VALUE__) == LL_RCC_I2C3_CLKSOURCE))
 | 
			
		||||
#else
 | 
			
		||||
#define IS_LL_RCC_I2C_CLKSOURCE(__VALUE__)     ((__VALUE__) == LL_RCC_I2C1_CLKSOURCE)
 | 
			
		||||
#endif /* RCC_CCIPR_I2C3SEL */
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RCC_LPTIM_CLKSOURCE(__VALUE__)  ((__VALUE__) == LL_RCC_LPTIM1_CLKSOURCE)
 | 
			
		||||
 | 
			
		||||
#if defined(USB)
 | 
			
		||||
#define IS_LL_RCC_USB_CLKSOURCE(__VALUE__)    (((__VALUE__) == LL_RCC_USB_CLKSOURCE))
 | 
			
		||||
#endif /* USB */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
/** @defgroup RCC_LL_Private_Functions RCC Private functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
uint32_t RCC_GetSystemClockFreq(void);
 | 
			
		||||
uint32_t RCC_GetHCLKClockFreq(uint32_t SYSCLK_Frequency);
 | 
			
		||||
uint32_t RCC_GetPCLK1ClockFreq(uint32_t HCLK_Frequency);
 | 
			
		||||
uint32_t RCC_GetPCLK2ClockFreq(uint32_t HCLK_Frequency);
 | 
			
		||||
uint32_t RCC_PLL_GetFreqDomain_SYS(void);
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup RCC_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup RCC_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Reset 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
 | 
			
		||||
  *         - HSE, HSI and PLL OFF
 | 
			
		||||
  *         - AHB, APB1 and APB2 prescaler set to 1.
 | 
			
		||||
  *         - CSS, MCO OFF
 | 
			
		||||
  *         - All interrupts disabled
 | 
			
		||||
  * @note   This function doesn't modify the configuration of the
 | 
			
		||||
  *         - Peripheral clocks
 | 
			
		||||
  *         - LSI, LSE and RTC clocks
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: RCC registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RCC_DeInit(void)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t vl_mask = 0U;
 | 
			
		||||
 | 
			
		||||
  /* Set MSION bit */
 | 
			
		||||
  LL_RCC_MSI_Enable();
 | 
			
		||||
 | 
			
		||||
  /* Insure MSIRDY bit is set before writing default MSIRANGE value */
 | 
			
		||||
  while (LL_RCC_MSI_IsReady() == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    __NOP();
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Set MSIRANGE default value */
 | 
			
		||||
  LL_RCC_MSI_SetRange(LL_RCC_MSIRANGE_5);
 | 
			
		||||
  /* Set MSITRIM bits to the reset value*/
 | 
			
		||||
  LL_RCC_MSI_SetCalibTrimming(0U);
 | 
			
		||||
 | 
			
		||||
  /* Set HSITRIM bits to the reset value*/
 | 
			
		||||
  LL_RCC_HSI_SetCalibTrimming(0x10U);
 | 
			
		||||
 | 
			
		||||
  /* Reset SW, HPRE, PPRE and MCOSEL bits */
 | 
			
		||||
  vl_mask = 0xFFFFFFFFU;
 | 
			
		||||
  CLEAR_BIT(vl_mask, (RCC_CFGR_SW | RCC_CFGR_HPRE | RCC_CFGR_PPRE1 | RCC_CFGR_PPRE2 | RCC_CFGR_MCOSEL));
 | 
			
		||||
  LL_RCC_WriteReg(CFGR, vl_mask);
 | 
			
		||||
 | 
			
		||||
  /* Reset HSI, HSE, PLL */
 | 
			
		||||
  vl_mask = LL_RCC_ReadReg(CR);
 | 
			
		||||
#if defined(RCC_CR_HSIOUTEN)  	
 | 
			
		||||
  CLEAR_BIT(vl_mask, RCC_CR_HSION| RCC_CR_HSIKERON| RCC_CR_HSIDIVEN | RCC_CR_HSIOUTEN | \
 | 
			
		||||
                     RCC_CR_HSEON | RCC_CR_PLLON); 
 | 
			
		||||
#else
 | 
			
		||||
  CLEAR_BIT(vl_mask, RCC_CR_HSION| RCC_CR_HSIKERON| RCC_CR_HSIDIVEN | \
 | 
			
		||||
                     RCC_CR_HSEON | RCC_CR_PLLON); 
 | 
			
		||||
#endif					 
 | 
			
		||||
  LL_RCC_WriteReg(CR, vl_mask);
 | 
			
		||||
  /* Delay after an RCC peripheral clock */
 | 
			
		||||
  vl_mask = LL_RCC_ReadReg(CR);
 | 
			
		||||
 | 
			
		||||
  /* Reset HSEBYP bit */
 | 
			
		||||
  LL_RCC_HSE_DisableBypass();
 | 
			
		||||
 | 
			
		||||
  /* Set RCC_CR_RTCPRE to 0b00*/
 | 
			
		||||
  CLEAR_BIT(vl_mask, RCC_CR_RTCPRE); 
 | 
			
		||||
  LL_RCC_WriteReg(CR, vl_mask);
 | 
			
		||||
 
 | 
			
		||||
  /* Reset CFGR register */
 | 
			
		||||
  LL_RCC_WriteReg(CFGR, 0x00000000U);
 | 
			
		||||
 | 
			
		||||
#if defined(RCC_HSI48_SUPPORT)
 | 
			
		||||
  /* Reset CRRCR register */
 | 
			
		||||
  LL_RCC_WriteReg(CRRCR, 0x00000000U);
 | 
			
		||||
 | 
			
		||||
  /* Disable HSI48 */
 | 
			
		||||
  LL_RCC_HSI48_Disable();
 | 
			
		||||
 | 
			
		||||
#endif /*RCC_HSI48_SUPPORT*/
 | 
			
		||||
 | 
			
		||||
  /* Disable all interrupts */
 | 
			
		||||
  LL_RCC_WriteReg(CIER, 0x00000000U);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup RCC_LL_EF_Get_Freq
 | 
			
		||||
  * @brief  Return the frequencies of different on chip clocks;  System, AHB, APB1 and APB2 buses clocks
 | 
			
		||||
  *         and different peripheral clocks available on the device.
 | 
			
		||||
  * @note   If SYSCLK source is MSI, function returns values based on MSI clock(*)
 | 
			
		||||
  * @note   If SYSCLK source is HSI, function returns values based on HSI_VALUE(**)
 | 
			
		||||
  * @note   If SYSCLK source is HSE, function returns values based on HSE_VALUE(***)
 | 
			
		||||
  * @note   If SYSCLK source is PLL, function returns values based on 
 | 
			
		||||
  *         HSI_VALUE(**) or HSE_VALUE(***) multiplied/divided by the PLL factors.
 | 
			
		||||
  * @note   (*) MSI clock depends on the selected MSI range but the real value
 | 
			
		||||
  *             may vary depending on the variations in voltage and temperature. 
 | 
			
		||||
  * @note   (**) HSI_VALUE is a defined constant but the real value may vary 
 | 
			
		||||
  *              depending on the variations in voltage and temperature.
 | 
			
		||||
  * @note   (***) HSE_VALUE is a defined constant, 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 incorrect 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.
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return the frequencies of different on chip clocks;  System, AHB, APB1 and APB2 buses clocks
 | 
			
		||||
  * @note   Each time SYSCLK, HCLK, PCLK1 and/or PCLK2 clock changes, this function
 | 
			
		||||
  *         must be called to update structure fields. Otherwise, any
 | 
			
		||||
  *         configuration based on this function will be incorrect.
 | 
			
		||||
  * @param  RCC_Clocks pointer to a @ref LL_RCC_ClocksTypeDef structure which will hold the clocks frequencies
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_RCC_GetSystemClocksFreq(LL_RCC_ClocksTypeDef *RCC_Clocks)
 | 
			
		||||
{
 | 
			
		||||
  /* Get SYSCLK frequency */
 | 
			
		||||
  RCC_Clocks->SYSCLK_Frequency = RCC_GetSystemClockFreq();
 | 
			
		||||
 | 
			
		||||
  /* HCLK clock frequency */
 | 
			
		||||
  RCC_Clocks->HCLK_Frequency   = RCC_GetHCLKClockFreq(RCC_Clocks->SYSCLK_Frequency);
 | 
			
		||||
 | 
			
		||||
  /* PCLK1 clock frequency */
 | 
			
		||||
  RCC_Clocks->PCLK1_Frequency  = RCC_GetPCLK1ClockFreq(RCC_Clocks->HCLK_Frequency);
 | 
			
		||||
 | 
			
		||||
  /* PCLK2 clock frequency */
 | 
			
		||||
  RCC_Clocks->PCLK2_Frequency  = RCC_GetPCLK2ClockFreq(RCC_Clocks->HCLK_Frequency);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return USARTx clock frequency
 | 
			
		||||
  * @param  USARTxSource This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_RCC_USART1_CLKSOURCE
 | 
			
		||||
  *         @arg @ref LL_RCC_USART2_CLKSOURCE (*)
 | 
			
		||||
  *
 | 
			
		||||
  *         (*) value not defined in all devices.
 | 
			
		||||
  * @retval USART clock frequency (in Hz)
 | 
			
		||||
  *         @arg @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_RCC_GetUSARTClockFreq(uint32_t USARTxSource)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t usart_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
 | 
			
		||||
 | 
			
		||||
  /* Check parameter */
 | 
			
		||||
  assert_param(IS_LL_RCC_USART_CLKSOURCE(USARTxSource));
 | 
			
		||||
#if defined(RCC_CCIPR_USART1SEL)
 | 
			
		||||
  if (USARTxSource == LL_RCC_USART1_CLKSOURCE)
 | 
			
		||||
  {
 | 
			
		||||
    /* USART1CLK clock frequency */
 | 
			
		||||
    switch (LL_RCC_GetUSARTClockSource(USARTxSource))
 | 
			
		||||
    {
 | 
			
		||||
      case LL_RCC_USART1_CLKSOURCE_SYSCLK: /* USART1 Clock is System Clock */
 | 
			
		||||
        usart_frequency = RCC_GetSystemClockFreq();
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_USART1_CLKSOURCE_HSI:    /* USART1 Clock is HSI Osc. */
 | 
			
		||||
        if (LL_RCC_HSI_IsReady())
 | 
			
		||||
        {
 | 
			
		||||
          usart_frequency = HSI_VALUE;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_USART1_CLKSOURCE_LSE:    /* USART1 Clock is LSE Osc. */
 | 
			
		||||
        if (LL_RCC_LSE_IsReady())
 | 
			
		||||
        {
 | 
			
		||||
          usart_frequency = LSE_VALUE;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_USART1_CLKSOURCE_PCLK2:  /* USART1 Clock is PCLK2 */
 | 
			
		||||
      default:
 | 
			
		||||
        usart_frequency = RCC_GetPCLK2ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
#endif /* RCC_CCIPR_USART1SEL  */
 | 
			
		||||
 | 
			
		||||
#if defined(RCC_CCIPR_USART2SEL)
 | 
			
		||||
  if (USARTxSource == LL_RCC_USART2_CLKSOURCE)
 | 
			
		||||
  {
 | 
			
		||||
    /* USART2CLK clock frequency */
 | 
			
		||||
    switch (LL_RCC_GetUSARTClockSource(USARTxSource))
 | 
			
		||||
    {
 | 
			
		||||
      case LL_RCC_USART2_CLKSOURCE_SYSCLK: /* USART2 Clock is System Clock */
 | 
			
		||||
        usart_frequency = RCC_GetSystemClockFreq();
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_USART2_CLKSOURCE_HSI:    /* USART2 Clock is HSI Osc. */
 | 
			
		||||
        if (LL_RCC_HSI_IsReady())
 | 
			
		||||
        {
 | 
			
		||||
          usart_frequency = HSI_VALUE;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_USART2_CLKSOURCE_LSE:    /* USART2 Clock is LSE Osc. */
 | 
			
		||||
        if (LL_RCC_LSE_IsReady())
 | 
			
		||||
        {
 | 
			
		||||
          usart_frequency = LSE_VALUE;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_USART2_CLKSOURCE_PCLK1:  /* USART2 Clock is PCLK1 */
 | 
			
		||||
      default:
 | 
			
		||||
        usart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
#endif /* RCC_CCIPR_USART2SEL */
 | 
			
		||||
 | 
			
		||||
  return usart_frequency;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return I2Cx clock frequency
 | 
			
		||||
  * @param  I2CxSource This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_RCC_I2C1_CLKSOURCE
 | 
			
		||||
  *         @arg @ref LL_RCC_I2C3_CLKSOURCE (*)
 | 
			
		||||
  *
 | 
			
		||||
  *         (*) value not defined in all devices
 | 
			
		||||
  * @retval I2C clock frequency (in Hz)
 | 
			
		||||
  *         @arg @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that HSI oscillator is not ready
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_RCC_GetI2CClockFreq(uint32_t I2CxSource)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t i2c_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
 | 
			
		||||
 | 
			
		||||
  /* Check parameter */
 | 
			
		||||
  assert_param(IS_LL_RCC_I2C_CLKSOURCE(I2CxSource));
 | 
			
		||||
 | 
			
		||||
  /* I2C1 CLK clock frequency */
 | 
			
		||||
  if (I2CxSource == LL_RCC_I2C1_CLKSOURCE)
 | 
			
		||||
  {
 | 
			
		||||
    switch (LL_RCC_GetI2CClockSource(I2CxSource))
 | 
			
		||||
    {
 | 
			
		||||
      case LL_RCC_I2C1_CLKSOURCE_SYSCLK: /* I2C1 Clock is System Clock */
 | 
			
		||||
        i2c_frequency = RCC_GetSystemClockFreq();
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_I2C1_CLKSOURCE_HSI:    /* I2C1 Clock is HSI Osc. */
 | 
			
		||||
        if (LL_RCC_HSI_IsReady())
 | 
			
		||||
        {
 | 
			
		||||
          i2c_frequency = HSI_VALUE;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_I2C1_CLKSOURCE_PCLK1:  /* I2C1 Clock is PCLK1 */
 | 
			
		||||
      default:
 | 
			
		||||
        i2c_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#if defined(RCC_CCIPR_I2C3SEL)
 | 
			
		||||
  /* I2C3 CLK clock frequency */
 | 
			
		||||
  if (I2CxSource == LL_RCC_I2C3_CLKSOURCE)
 | 
			
		||||
  {
 | 
			
		||||
    switch (LL_RCC_GetI2CClockSource(I2CxSource))
 | 
			
		||||
    {
 | 
			
		||||
      case LL_RCC_I2C3_CLKSOURCE_SYSCLK: /* I2C3 Clock is System Clock */
 | 
			
		||||
        i2c_frequency = RCC_GetSystemClockFreq();
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_I2C3_CLKSOURCE_HSI:    /* I2C3 Clock is HSI Osc. */
 | 
			
		||||
        if (LL_RCC_HSI_IsReady())
 | 
			
		||||
        {
 | 
			
		||||
          i2c_frequency = HSI_VALUE;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_I2C3_CLKSOURCE_PCLK1:  /* I2C3 Clock is PCLK1 */
 | 
			
		||||
      default:
 | 
			
		||||
        i2c_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
#endif /*RCC_CCIPR_I2C3SEL*/
 | 
			
		||||
 | 
			
		||||
  return i2c_frequency;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return LPUARTx clock frequency
 | 
			
		||||
  * @param  LPUARTxSource This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_RCC_LPUART1_CLKSOURCE
 | 
			
		||||
  * @retval LPUART clock frequency (in Hz)
 | 
			
		||||
  *         @arg @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_RCC_GetLPUARTClockFreq(uint32_t LPUARTxSource)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t lpuart_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
 | 
			
		||||
 | 
			
		||||
  /* Check parameter */
 | 
			
		||||
  assert_param(IS_LL_RCC_LPUART_CLKSOURCE(LPUARTxSource));
 | 
			
		||||
 | 
			
		||||
  /* LPUART1CLK clock frequency */
 | 
			
		||||
  switch (LL_RCC_GetLPUARTClockSource(LPUARTxSource))
 | 
			
		||||
  {
 | 
			
		||||
    case LL_RCC_LPUART1_CLKSOURCE_SYSCLK: /* LPUART1 Clock is System Clock */
 | 
			
		||||
      lpuart_frequency = RCC_GetSystemClockFreq();
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case LL_RCC_LPUART1_CLKSOURCE_HSI:    /* LPUART1 Clock is HSI Osc. */
 | 
			
		||||
      if (LL_RCC_HSI_IsReady())
 | 
			
		||||
      {
 | 
			
		||||
        lpuart_frequency = HSI_VALUE;
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case LL_RCC_LPUART1_CLKSOURCE_LSE:    /* LPUART1 Clock is LSE Osc. */
 | 
			
		||||
      if (LL_RCC_LSE_IsReady())
 | 
			
		||||
      {
 | 
			
		||||
        lpuart_frequency = LSE_VALUE;
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case LL_RCC_LPUART1_CLKSOURCE_PCLK1:  /* LPUART1 Clock is PCLK1 */
 | 
			
		||||
    default:
 | 
			
		||||
      lpuart_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return lpuart_frequency;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return LPTIMx clock frequency
 | 
			
		||||
  * @param  LPTIMxSource This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_RCC_LPTIM1_CLKSOURCE
 | 
			
		||||
  * @retval LPTIM clock frequency (in Hz)
 | 
			
		||||
  *         @arg @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI or LSE) is not ready
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_RCC_GetLPTIMClockFreq(uint32_t LPTIMxSource)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t lptim_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
 | 
			
		||||
 | 
			
		||||
  /* Check parameter */
 | 
			
		||||
  assert_param(IS_LL_RCC_LPTIM_CLKSOURCE(LPTIMxSource));
 | 
			
		||||
 | 
			
		||||
  if (LPTIMxSource == LL_RCC_LPTIM1_CLKSOURCE)
 | 
			
		||||
  {
 | 
			
		||||
    /* LPTIM1CLK clock frequency */
 | 
			
		||||
    switch (LL_RCC_GetLPTIMClockSource(LPTIMxSource))
 | 
			
		||||
    {
 | 
			
		||||
      case LL_RCC_LPTIM1_CLKSOURCE_LSI:    /* LPTIM1 Clock is LSI Osc. */
 | 
			
		||||
        if (LL_RCC_LSI_IsReady())
 | 
			
		||||
        {
 | 
			
		||||
          lptim_frequency = LSI_VALUE;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_LPTIM1_CLKSOURCE_HSI:    /* LPTIM1 Clock is HSI Osc. */
 | 
			
		||||
        if (LL_RCC_HSI_IsReady())
 | 
			
		||||
        {
 | 
			
		||||
          lptim_frequency = HSI_VALUE;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_LPTIM1_CLKSOURCE_LSE:    /* LPTIM1 Clock is LSE Osc. */
 | 
			
		||||
        if (LL_RCC_LSE_IsReady())
 | 
			
		||||
        {
 | 
			
		||||
          lptim_frequency = LSE_VALUE;
 | 
			
		||||
        }
 | 
			
		||||
        break;
 | 
			
		||||
 | 
			
		||||
      case LL_RCC_LPTIM1_CLKSOURCE_PCLK1:  /* LPTIM1 Clock is PCLK1 */
 | 
			
		||||
      default:
 | 
			
		||||
        lptim_frequency = RCC_GetPCLK1ClockFreq(RCC_GetHCLKClockFreq(RCC_GetSystemClockFreq()));
 | 
			
		||||
        break;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return lptim_frequency;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#if defined(USB)
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return USBx clock frequency
 | 
			
		||||
  * @param  USBxSource This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_RCC_USB_CLKSOURCE
 | 
			
		||||
  * @retval USB clock frequency (in Hz)
 | 
			
		||||
  *         @arg @ref LL_RCC_PERIPH_FREQUENCY_NO indicates that oscillator (HSI48) or PLL is not ready
 | 
			
		||||
  *         @arg @ref LL_RCC_PERIPH_FREQUENCY_NA indicates that no clock source selected
 | 
			
		||||
  */
 | 
			
		||||
uint32_t LL_RCC_GetUSBClockFreq(uint32_t USBxSource)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t usb_frequency = LL_RCC_PERIPH_FREQUENCY_NO;
 | 
			
		||||
 | 
			
		||||
  /* Check parameter */
 | 
			
		||||
  assert_param(IS_LL_RCC_USB_CLKSOURCE(USBxSource));
 | 
			
		||||
 | 
			
		||||
  /* USBCLK clock frequency */
 | 
			
		||||
  switch (LL_RCC_GetUSBClockSource(USBxSource))
 | 
			
		||||
  {
 | 
			
		||||
    case LL_RCC_USB_CLKSOURCE_PLL:        /* PLL clock used as USB clock source */
 | 
			
		||||
      if (LL_RCC_PLL_IsReady())
 | 
			
		||||
      {
 | 
			
		||||
        usb_frequency = RCC_PLL_GetFreqDomain_SYS();
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case LL_RCC_USB_CLKSOURCE_HSI48:      /* HSI48 clock used as USB clock source */
 | 
			
		||||
    default:
 | 
			
		||||
      if (LL_RCC_HSI48_IsReady())
 | 
			
		||||
      {
 | 
			
		||||
        usb_frequency = HSI48_VALUE;
 | 
			
		||||
      }
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return usb_frequency;
 | 
			
		||||
}
 | 
			
		||||
#endif /* USB */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup RCC_LL_Private_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return SYSTEM clock frequency
 | 
			
		||||
  * @retval SYSTEM clock frequency (in Hz)
 | 
			
		||||
  */
 | 
			
		||||
uint32_t RCC_GetSystemClockFreq(void)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t frequency = 0U;
 | 
			
		||||
 | 
			
		||||
  /* Get SYSCLK source -------------------------------------------------------*/
 | 
			
		||||
  switch (LL_RCC_GetSysClkSource())
 | 
			
		||||
  {
 | 
			
		||||
    case LL_RCC_SYS_CLKSOURCE_STATUS_MSI:  /* MSI used as system clock source */
 | 
			
		||||
      frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_GetRange());
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case LL_RCC_SYS_CLKSOURCE_STATUS_HSI:  /* HSI used as system clock  source */
 | 
			
		||||
      frequency = HSI_VALUE;
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case LL_RCC_SYS_CLKSOURCE_STATUS_HSE:  /* HSE used as system clock  source */
 | 
			
		||||
      frequency = HSE_VALUE;
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case LL_RCC_SYS_CLKSOURCE_STATUS_PLL:  /* PLL used as system clock  source */
 | 
			
		||||
      frequency = RCC_PLL_GetFreqDomain_SYS();
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
      frequency = __LL_RCC_CALC_MSI_FREQ(LL_RCC_MSI_GetRange());
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return frequency;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return HCLK clock frequency
 | 
			
		||||
  * @param  SYSCLK_Frequency SYSCLK clock frequency
 | 
			
		||||
  * @retval HCLK clock frequency (in Hz)
 | 
			
		||||
  */
 | 
			
		||||
uint32_t RCC_GetHCLKClockFreq(uint32_t SYSCLK_Frequency)
 | 
			
		||||
{
 | 
			
		||||
  /* HCLK clock frequency */
 | 
			
		||||
  return __LL_RCC_CALC_HCLK_FREQ(SYSCLK_Frequency, LL_RCC_GetAHBPrescaler());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return PCLK1 clock frequency
 | 
			
		||||
  * @param  HCLK_Frequency HCLK clock frequency
 | 
			
		||||
  * @retval PCLK1 clock frequency (in Hz)
 | 
			
		||||
  */
 | 
			
		||||
uint32_t RCC_GetPCLK1ClockFreq(uint32_t HCLK_Frequency)
 | 
			
		||||
{
 | 
			
		||||
  /* PCLK1 clock frequency */
 | 
			
		||||
  return __LL_RCC_CALC_PCLK1_FREQ(HCLK_Frequency, LL_RCC_GetAPB1Prescaler());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return PCLK2 clock frequency
 | 
			
		||||
  * @param  HCLK_Frequency HCLK clock frequency
 | 
			
		||||
  * @retval PCLK2 clock frequency (in Hz)
 | 
			
		||||
  */
 | 
			
		||||
uint32_t RCC_GetPCLK2ClockFreq(uint32_t HCLK_Frequency)
 | 
			
		||||
{
 | 
			
		||||
  /* PCLK2 clock frequency */
 | 
			
		||||
  return __LL_RCC_CALC_PCLK2_FREQ(HCLK_Frequency, LL_RCC_GetAPB2Prescaler());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return PLL clock frequency used for system domain
 | 
			
		||||
  * @retval PLL clock frequency (in Hz)
 | 
			
		||||
  */
 | 
			
		||||
uint32_t RCC_PLL_GetFreqDomain_SYS(void)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t pllinputfreq = 0U, pllsource = 0U;
 | 
			
		||||
 | 
			
		||||
  /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLL divider) * PLL Multiplicator */
 | 
			
		||||
 | 
			
		||||
  /* Get PLL source */
 | 
			
		||||
  pllsource = LL_RCC_PLL_GetMainSource();
 | 
			
		||||
 | 
			
		||||
  switch (pllsource)
 | 
			
		||||
  {
 | 
			
		||||
    case LL_RCC_PLLSOURCE_HSI:       /* HSI used as PLL clock source */
 | 
			
		||||
      pllinputfreq = HSI_VALUE;
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    case LL_RCC_PLLSOURCE_HSE:       /* HSE used as PLL clock source */
 | 
			
		||||
      pllinputfreq = HSE_VALUE;
 | 
			
		||||
      break;
 | 
			
		||||
 | 
			
		||||
    default:
 | 
			
		||||
      pllinputfreq = HSI_VALUE;
 | 
			
		||||
      break;
 | 
			
		||||
  }
 | 
			
		||||
  return __LL_RCC_CALC_PLLCLK_FREQ(pllinputfreq, LL_RCC_PLL_GetMultiplicator(), LL_RCC_PLL_GetDivider());
 | 
			
		||||
}
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined(RCC) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,116 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_rng.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   RNG LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_rng.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (RNG)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup RNG_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup RNG_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup RNG_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize RNG registers (Registers restored to their default values).
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: RNG registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_RNG_ALL_INSTANCE(RNGx));
 | 
			
		||||
 | 
			
		||||
  /* Enable RNG reset state */
 | 
			
		||||
  LL_AHB1_GRP1_ForceReset(LL_AHB1_GRP1_PERIPH_RNG);
 | 
			
		||||
 | 
			
		||||
  /* Release RNG from reset state */
 | 
			
		||||
  LL_AHB1_GRP1_ReleaseReset(LL_AHB1_GRP1_PERIPH_RNG);
 | 
			
		||||
 | 
			
		||||
  return (SUCCESS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined (RNG) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,355 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_rng.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   Header file of RNG LL module.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32L0xx_LL_RNG_H
 | 
			
		||||
#define __STM32L0xx_LL_RNG_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(RNG)
 | 
			
		||||
 | 
			
		||||
/** @defgroup RNG_LL RNG
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup RNG_LL_Exported_Constants RNG Exported Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup RNG_LL_EC_GET_FLAG Get Flags Defines
 | 
			
		||||
  * @brief    Flags defines which can be used with LL_RNG_ReadReg function
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_RNG_SR_DRDY RNG_SR_DRDY    /*!< Register contains valid random data */
 | 
			
		||||
#define LL_RNG_SR_CECS RNG_SR_CECS    /*!< Clock error current status */
 | 
			
		||||
#define LL_RNG_SR_SECS RNG_SR_SECS    /*!< Seed error current status */
 | 
			
		||||
#define LL_RNG_SR_CEIS RNG_SR_CEIS    /*!< Clock error interrupt status */
 | 
			
		||||
#define LL_RNG_SR_SEIS RNG_SR_SEIS    /*!< Seed error interrupt status */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup RNG_LL_EC_IT IT Defines
 | 
			
		||||
  * @brief    IT defines which can be used with LL_RNG_ReadReg and  LL_RNG_WriteReg macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_RNG_CR_IE   RNG_CR_IE      /*!< RNG Interrupt enable */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup RNG_LL_Exported_Macros RNG Exported Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup RNG_LL_EM_WRITE_READ Common Write and read registers Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write a value in RNG register
 | 
			
		||||
  * @param  __INSTANCE__ RNG Instance
 | 
			
		||||
  * @param  __REG__ Register to be written
 | 
			
		||||
  * @param  __VALUE__ Value to be written in the register
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
#define LL_RNG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Read a value in RNG register
 | 
			
		||||
  * @param  __INSTANCE__ RNG Instance
 | 
			
		||||
  * @param  __REG__ Register to be read
 | 
			
		||||
  * @retval Register value
 | 
			
		||||
  */
 | 
			
		||||
#define LL_RNG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup RNG_LL_Exported_Functions RNG Exported Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/** @defgroup RNG_LL_EF_Configuration RNG Configuration functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable Random Number Generation
 | 
			
		||||
  * @rmtoll CR           RNGEN         LL_RNG_Enable
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_RNG_Enable(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(RNGx->CR, RNG_CR_RNGEN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable Random Number Generation
 | 
			
		||||
  * @rmtoll CR           RNGEN         LL_RNG_Disable
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_RNG_Disable(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(RNGx->CR, RNG_CR_RNGEN);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Random Number Generator is enabled
 | 
			
		||||
  * @rmtoll CR           RNGEN         LL_RNG_IsEnabled
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_RNG_IsEnabled(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(RNGx->CR, RNG_CR_RNGEN) == (RNG_CR_RNGEN));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup RNG_LL_EF_FLAG_Management FLAG Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Indicate if the RNG Data ready Flag is set or not
 | 
			
		||||
  * @rmtoll SR           DRDY          LL_RNG_IsActiveFlag_DRDY
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_DRDY(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(RNGx->SR, RNG_SR_DRDY) == (RNG_SR_DRDY));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Indicate if the Clock Error Current Status Flag is set or not
 | 
			
		||||
  * @rmtoll SR           CECS          LL_RNG_IsActiveFlag_CECS
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CECS(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(RNGx->SR, RNG_SR_CECS) == (RNG_SR_CECS));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Indicate if the Seed Error Current Status Flag is set or not
 | 
			
		||||
  * @rmtoll SR           SECS          LL_RNG_IsActiveFlag_SECS
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SECS(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(RNGx->SR, RNG_SR_SECS) == (RNG_SR_SECS));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Indicate if the Clock Error Interrupt Status Flag is set or not
 | 
			
		||||
  * @rmtoll SR           CEIS          LL_RNG_IsActiveFlag_CEIS
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_CEIS(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(RNGx->SR, RNG_SR_CEIS) == (RNG_SR_CEIS));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Indicate if the Seed Error Interrupt Status Flag is set or not
 | 
			
		||||
  * @rmtoll SR           SEIS          LL_RNG_IsActiveFlag_SEIS
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_RNG_IsActiveFlag_SEIS(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(RNGx->SR, RNG_SR_SEIS) == (RNG_SR_SEIS));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Clear Clock Error interrupt Status (CEIS) Flag
 | 
			
		||||
  * @rmtoll SR           CEIS          LL_RNG_ClearFlag_CEIS
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_RNG_ClearFlag_CEIS(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(RNGx->SR, ~RNG_SR_CEIS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Clear Seed Error interrupt Status (SEIS) Flag
 | 
			
		||||
  * @rmtoll SR           SEIS          LL_RNG_ClearFlag_SEIS
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_RNG_ClearFlag_SEIS(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(RNGx->SR, ~RNG_SR_SEIS);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup RNG_LL_EF_IT_Management IT Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable Random Number Generator Interrupt
 | 
			
		||||
  *         (applies for either Seed error, Clock Error or Data ready interrupts)
 | 
			
		||||
  * @rmtoll CR           IE            LL_RNG_EnableIT
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_RNG_EnableIT(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(RNGx->CR, RNG_CR_IE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Disable Random Number Generator Interrupt
 | 
			
		||||
  *         (applies for either Seed error, Clock Error or Data ready interrupts)
 | 
			
		||||
  * @rmtoll CR           IE            LL_RNG_DisableIT
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_RNG_DisableIT(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  CLEAR_BIT(RNGx->CR, RNG_CR_IE);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Random Number Generator Interrupt is enabled
 | 
			
		||||
  *         (applies for either Seed error, Clock Error or Data ready interrupts)
 | 
			
		||||
  * @rmtoll CR           IE            LL_RNG_IsEnabledIT
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_RNG_IsEnabledIT(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(RNGx->CR, RNG_CR_IE) == (RNG_CR_IE));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup RNG_LL_EF_Data_Management Data Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return32-bit Random Number value
 | 
			
		||||
  * @rmtoll DR           RNDATA        LL_RNG_ReadRandData32
 | 
			
		||||
  * @param  RNGx RNG Instance
 | 
			
		||||
  * @retval Generated 32-bit random value
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_RNG_ReadRandData32(RNG_TypeDef *RNGx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(RNGx->DR));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
/** @defgroup RNG_LL_EF_Init Initialization and de-initialization functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
ErrorStatus LL_RNG_DeInit(RNG_TypeDef *RNGx);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined(RNG) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32L0xx_LL_RNG_H */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,897 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_rtc.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   RTC LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_rtc.h"
 | 
			
		||||
#include "stm32l0xx_ll_cortex.h"
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(RTC)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup RTC_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup RTC_LL_Private_Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/* Default values used for prescaler */
 | 
			
		||||
#define RTC_ASYNCH_PRESC_DEFAULT     ((uint32_t) 0x0000007FU)
 | 
			
		||||
#define RTC_SYNCH_PRESC_DEFAULT      ((uint32_t) 0x000000FFU)
 | 
			
		||||
 | 
			
		||||
/* Values used for timeout */
 | 
			
		||||
#define RTC_INITMODE_TIMEOUT         ((uint32_t) 1000U) /* 1s when tick set to 1ms */
 | 
			
		||||
#define RTC_SYNCHRO_TIMEOUT          ((uint32_t) 1000U) /* 1s when tick set to 1ms */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup RTC_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_HOURFORMAT(__VALUE__) (((__VALUE__) == LL_RTC_HOURFORMAT_24HOUR) \
 | 
			
		||||
                                      || ((__VALUE__) == LL_RTC_HOURFORMAT_AMPM))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_ASYNCH_PREDIV(__VALUE__)   ((__VALUE__) <= (uint32_t)0x7FU)
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_SYNCH_PREDIV(__VALUE__)    ((__VALUE__) <= (uint32_t)0x7FFFU)
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_FORMAT_BIN) \
 | 
			
		||||
                                  || ((__VALUE__) == LL_RTC_FORMAT_BCD))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_TIME_FORMAT(__VALUE__) (((__VALUE__) == LL_RTC_TIME_FORMAT_AM_OR_24) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_RTC_TIME_FORMAT_PM))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_HOUR12(__HOUR__)            (((__HOUR__) > 0U) && ((__HOUR__) <= 12U))
 | 
			
		||||
#define IS_LL_RTC_HOUR24(__HOUR__)            ((__HOUR__) <= 23U)
 | 
			
		||||
#define IS_LL_RTC_MINUTES(__MINUTES__)        ((__MINUTES__) <= 59U)
 | 
			
		||||
#define IS_LL_RTC_SECONDS(__SECONDS__)        ((__SECONDS__) <= 59U)
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_WEEKDAY(__VALUE__) (((__VALUE__) == LL_RTC_WEEKDAY_MONDAY) \
 | 
			
		||||
                                   || ((__VALUE__) == LL_RTC_WEEKDAY_TUESDAY) \
 | 
			
		||||
                                   || ((__VALUE__) == LL_RTC_WEEKDAY_WEDNESDAY) \
 | 
			
		||||
                                   || ((__VALUE__) == LL_RTC_WEEKDAY_THURSDAY) \
 | 
			
		||||
                                   || ((__VALUE__) == LL_RTC_WEEKDAY_FRIDAY) \
 | 
			
		||||
                                   || ((__VALUE__) == LL_RTC_WEEKDAY_SATURDAY) \
 | 
			
		||||
                                   || ((__VALUE__) == LL_RTC_WEEKDAY_SUNDAY))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_DAY(__DAY__)    (((__DAY__) >= (uint32_t)1U) && ((__DAY__) <= (uint32_t)31U))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_MONTH(__VALUE__) (((__VALUE__) == LL_RTC_MONTH_JANUARY) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_FEBRUARY) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_MARCH) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_APRIL) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_MAY) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_JUNE) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_JULY) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_AUGUST) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_SEPTEMBER) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_OCTOBER) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_NOVEMBER) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_RTC_MONTH_DECEMBER))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_YEAR(__YEAR__) ((__YEAR__) <= 99U)
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_ALMA_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMA_MASK_NONE) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_RTC_ALMA_MASK_DATEWEEKDAY) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_RTC_ALMA_MASK_HOURS) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_RTC_ALMA_MASK_MINUTES) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_RTC_ALMA_MASK_SECONDS) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_RTC_ALMA_MASK_ALL))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_ALMB_MASK(__VALUE__) (((__VALUE__) == LL_RTC_ALMB_MASK_NONE) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_RTC_ALMB_MASK_DATEWEEKDAY) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_RTC_ALMB_MASK_HOURS) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_RTC_ALMB_MASK_MINUTES) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_RTC_ALMB_MASK_SECONDS) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_RTC_ALMB_MASK_ALL))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE) || \
 | 
			
		||||
                                                  ((__SEL__) == LL_RTC_ALMA_DATEWEEKDAYSEL_WEEKDAY))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(__SEL__) (((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE) || \
 | 
			
		||||
                                                  ((__SEL__) == LL_RTC_ALMB_DATEWEEKDAYSEL_WEEKDAY))
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup RTC_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup RTC_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-Initializes the RTC registers to their default reset values.
 | 
			
		||||
  * @note   This function doesn't reset the RTC Clock source and RTC Backup Data
 | 
			
		||||
  *         registers.
 | 
			
		||||
  * @param  RTCx RTC Instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: RTC registers are de-initialized
 | 
			
		||||
  *          - ERROR: RTC registers are not de-initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RTC_DeInit(RTC_TypeDef *RTCx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = ERROR;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameter */
 | 
			
		||||
  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
 | 
			
		||||
 | 
			
		||||
  /* Disable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_DisableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  /* Set Initialization mode */
 | 
			
		||||
  if (LL_RTC_EnterInitMode(RTCx) != ERROR)
 | 
			
		||||
  {
 | 
			
		||||
    /* Reset TR, DR and CR registers */
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, TR,       0x00000000U);
 | 
			
		||||
#if defined(RTC_WAKEUP_SUPPORT)
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, WUTR,     RTC_WUTR_WUT);
 | 
			
		||||
#endif /* RTC_WAKEUP_SUPPORT */
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, DR  ,     (RTC_DR_WDU_0 | RTC_DR_MU_0 | RTC_DR_DU_0));
 | 
			
		||||
    /* Reset All CR bits except CR[2:0] */
 | 
			
		||||
#if defined(RTC_WAKEUP_SUPPORT)
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, CR, (LL_RTC_ReadReg(RTCx, CR) & RTC_CR_WUCKSEL));
 | 
			
		||||
#else
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, CR, 0x00000000U);
 | 
			
		||||
#endif /* RTC_WAKEUP_SUPPORT */
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, PRER,     (RTC_PRER_PREDIV_A | RTC_SYNCH_PRESC_DEFAULT));
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, ALRMAR,   0x00000000U);
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, ALRMBR,   0x00000000U);
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, SHIFTR,   0x00000000U);
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, CALR,     0x00000000U);
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, ALRMASSR, 0x00000000U);
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, ALRMBSSR, 0x00000000U);
 | 
			
		||||
 | 
			
		||||
    /* Reset ISR register and exit initialization mode */
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, ISR,      0x00000000U);
 | 
			
		||||
 | 
			
		||||
    /* Reset Tamper and alternate functions configuration register */
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, TAMPCR, 0x00000000U);
 | 
			
		||||
 | 
			
		||||
    /* Reset Option register */
 | 
			
		||||
    LL_RTC_WriteReg(RTCx, OR, 0x00000000U);
 | 
			
		||||
 | 
			
		||||
    /* Wait till the RTC RSF flag is set */
 | 
			
		||||
    status = LL_RTC_WaitForSynchro(RTCx);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Enable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_EnableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initializes the RTC registers according to the specified parameters
 | 
			
		||||
  *         in RTC_InitStruct.
 | 
			
		||||
  * @param  RTCx RTC Instance
 | 
			
		||||
  * @param  RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure that contains
 | 
			
		||||
  *         the configuration information for the RTC peripheral.
 | 
			
		||||
  * @note   The RTC Prescaler register is write protected and can be written in
 | 
			
		||||
  *         initialization mode only.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: RTC registers are initialized
 | 
			
		||||
  *          - ERROR: RTC registers are not initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RTC_Init(RTC_TypeDef *RTCx, LL_RTC_InitTypeDef *RTC_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = ERROR;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
 | 
			
		||||
  assert_param(IS_LL_RTC_HOURFORMAT(RTC_InitStruct->HourFormat));
 | 
			
		||||
  assert_param(IS_LL_RTC_ASYNCH_PREDIV(RTC_InitStruct->AsynchPrescaler));
 | 
			
		||||
  assert_param(IS_LL_RTC_SYNCH_PREDIV(RTC_InitStruct->SynchPrescaler));
 | 
			
		||||
 | 
			
		||||
  /* Disable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_DisableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  /* Set Initialization mode */
 | 
			
		||||
  if (LL_RTC_EnterInitMode(RTCx) != ERROR)
 | 
			
		||||
  {
 | 
			
		||||
    /* Set Hour Format */
 | 
			
		||||
    LL_RTC_SetHourFormat(RTCx, RTC_InitStruct->HourFormat);
 | 
			
		||||
 | 
			
		||||
    /* Configure Synchronous and Asynchronous prescaler factor */
 | 
			
		||||
    LL_RTC_SetSynchPrescaler(RTCx, RTC_InitStruct->SynchPrescaler);
 | 
			
		||||
    LL_RTC_SetAsynchPrescaler(RTCx, RTC_InitStruct->AsynchPrescaler);
 | 
			
		||||
 | 
			
		||||
    /* Exit Initialization mode */
 | 
			
		||||
    LL_RTC_DisableInitMode(RTCx);
 | 
			
		||||
 | 
			
		||||
    status = SUCCESS;
 | 
			
		||||
  }
 | 
			
		||||
  /* Enable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_EnableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_RTC_InitTypeDef field to default value.
 | 
			
		||||
  * @param  RTC_InitStruct pointer to a @ref LL_RTC_InitTypeDef structure which will be initialized.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_RTC_StructInit(LL_RTC_InitTypeDef *RTC_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set RTC_InitStruct fields to default values */
 | 
			
		||||
  RTC_InitStruct->HourFormat      = LL_RTC_HOURFORMAT_24HOUR;
 | 
			
		||||
  RTC_InitStruct->AsynchPrescaler = RTC_ASYNCH_PRESC_DEFAULT;
 | 
			
		||||
  RTC_InitStruct->SynchPrescaler  = RTC_SYNCH_PRESC_DEFAULT;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the RTC current time.
 | 
			
		||||
  * @param  RTCx RTC Instance
 | 
			
		||||
  * @param  RTC_Format This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_RTC_FORMAT_BIN
 | 
			
		||||
  *         @arg @ref LL_RTC_FORMAT_BCD
 | 
			
		||||
  * @param  RTC_TimeStruct pointer to a RTC_TimeTypeDef structure that contains
 | 
			
		||||
  *                        the time configuration information for the RTC.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: RTC Time register is configured
 | 
			
		||||
  *          - ERROR: RTC Time register is not configured
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RTC_TIME_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_TimeTypeDef *RTC_TimeStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = ERROR;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
 | 
			
		||||
  assert_param(IS_LL_RTC_FORMAT(RTC_Format));
 | 
			
		||||
 | 
			
		||||
  if (RTC_Format == LL_RTC_FORMAT_BIN)
 | 
			
		||||
  {
 | 
			
		||||
    if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR12(RTC_TimeStruct->Hours));
 | 
			
		||||
      assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      RTC_TimeStruct->TimeFormat = 0x00U;
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR24(RTC_TimeStruct->Hours));
 | 
			
		||||
    }
 | 
			
		||||
    assert_param(IS_LL_RTC_MINUTES(RTC_TimeStruct->Minutes));
 | 
			
		||||
    assert_param(IS_LL_RTC_SECONDS(RTC_TimeStruct->Seconds));
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours)));
 | 
			
		||||
      assert_param(IS_LL_RTC_TIME_FORMAT(RTC_TimeStruct->TimeFormat));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      RTC_TimeStruct->TimeFormat = 0x00U;
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Hours)));
 | 
			
		||||
    }
 | 
			
		||||
    assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Minutes)));
 | 
			
		||||
    assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_TimeStruct->Seconds)));
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Disable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_DisableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  /* Set Initialization mode */
 | 
			
		||||
  if (LL_RTC_EnterInitMode(RTCx) != ERROR)
 | 
			
		||||
  {
 | 
			
		||||
    /* Check the input parameters format */
 | 
			
		||||
    if (RTC_Format != LL_RTC_FORMAT_BIN)
 | 
			
		||||
    {
 | 
			
		||||
      LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, RTC_TimeStruct->Hours,
 | 
			
		||||
                         RTC_TimeStruct->Minutes, RTC_TimeStruct->Seconds);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      LL_RTC_TIME_Config(RTCx, RTC_TimeStruct->TimeFormat, __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Hours),
 | 
			
		||||
                         __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Minutes),
 | 
			
		||||
                         __LL_RTC_CONVERT_BIN2BCD(RTC_TimeStruct->Seconds));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Exit Initialization mode */
 | 
			
		||||
    LL_RTC_DisableInitMode(RTC);
 | 
			
		||||
 | 
			
		||||
    /* If  RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
 | 
			
		||||
    if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U)
 | 
			
		||||
    {
 | 
			
		||||
      status = LL_RTC_WaitForSynchro(RTCx);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      status = SUCCESS;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  /* Enable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_EnableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_RTC_TimeTypeDef field to default value (Time = 00h:00min:00sec).
 | 
			
		||||
  * @param  RTC_TimeStruct pointer to a @ref LL_RTC_TimeTypeDef structure which will be initialized.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_RTC_TIME_StructInit(LL_RTC_TimeTypeDef *RTC_TimeStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Time = 00h:00min:00sec */
 | 
			
		||||
  RTC_TimeStruct->TimeFormat = LL_RTC_TIME_FORMAT_AM_OR_24;
 | 
			
		||||
  RTC_TimeStruct->Hours      = 0U;
 | 
			
		||||
  RTC_TimeStruct->Minutes    = 0U;
 | 
			
		||||
  RTC_TimeStruct->Seconds    = 0U;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the RTC current date.
 | 
			
		||||
  * @param  RTCx RTC Instance
 | 
			
		||||
  * @param  RTC_Format This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_RTC_FORMAT_BIN
 | 
			
		||||
  *         @arg @ref LL_RTC_FORMAT_BCD
 | 
			
		||||
  * @param  RTC_DateStruct: pointer to a RTC_DateTypeDef structure that contains
 | 
			
		||||
  *                         the date configuration information for the RTC.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: RTC Day register is configured
 | 
			
		||||
  *          - ERROR: RTC Day register is not configured
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RTC_DATE_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_DateTypeDef *RTC_DateStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = ERROR;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
 | 
			
		||||
  assert_param(IS_LL_RTC_FORMAT(RTC_Format));
 | 
			
		||||
 | 
			
		||||
  if ((RTC_Format == LL_RTC_FORMAT_BIN) && ((RTC_DateStruct->Month & 0x10U) == 0x10U))
 | 
			
		||||
  {
 | 
			
		||||
    RTC_DateStruct->Month = (RTC_DateStruct->Month & (uint32_t)~(0x10U)) + 0x0AU;
 | 
			
		||||
  }
 | 
			
		||||
  if (RTC_Format == LL_RTC_FORMAT_BIN)
 | 
			
		||||
  {
 | 
			
		||||
    assert_param(IS_LL_RTC_YEAR(RTC_DateStruct->Year));
 | 
			
		||||
    assert_param(IS_LL_RTC_MONTH(RTC_DateStruct->Month));
 | 
			
		||||
    assert_param(IS_LL_RTC_DAY(RTC_DateStruct->Day));
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    assert_param(IS_LL_RTC_YEAR(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Year)));
 | 
			
		||||
    assert_param(IS_LL_RTC_MONTH(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Month)));
 | 
			
		||||
    assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_DateStruct->Day)));
 | 
			
		||||
  }
 | 
			
		||||
  assert_param(IS_LL_RTC_WEEKDAY(RTC_DateStruct->WeekDay));
 | 
			
		||||
 | 
			
		||||
  /* Disable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_DisableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  /* Set Initialization mode */
 | 
			
		||||
  if (LL_RTC_EnterInitMode(RTCx) != ERROR)
 | 
			
		||||
  {
 | 
			
		||||
    /* Check the input parameters format */
 | 
			
		||||
    if (RTC_Format != LL_RTC_FORMAT_BIN)
 | 
			
		||||
    {
 | 
			
		||||
      LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, RTC_DateStruct->Day, RTC_DateStruct->Month, RTC_DateStruct->Year);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      LL_RTC_DATE_Config(RTCx, RTC_DateStruct->WeekDay, __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Day),
 | 
			
		||||
                         __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Month), __LL_RTC_CONVERT_BIN2BCD(RTC_DateStruct->Year));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Exit Initialization mode */
 | 
			
		||||
    LL_RTC_DisableInitMode(RTC);
 | 
			
		||||
 | 
			
		||||
    /* If  RTC_CR_BYPSHAD bit = 0, wait for synchro else this check is not needed */
 | 
			
		||||
    if (LL_RTC_IsShadowRegBypassEnabled(RTCx) == 0U)
 | 
			
		||||
    {
 | 
			
		||||
      status = LL_RTC_WaitForSynchro(RTCx);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      status = SUCCESS;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  /* Enable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_EnableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_RTC_DateTypeDef field to default value (date = Monday, January 01 xx00)
 | 
			
		||||
  * @param  RTC_DateStruct pointer to a @ref LL_RTC_DateTypeDef structure which will be initialized.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_RTC_DATE_StructInit(LL_RTC_DateTypeDef *RTC_DateStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Monday, January 01 xx00 */
 | 
			
		||||
  RTC_DateStruct->WeekDay = LL_RTC_WEEKDAY_MONDAY;
 | 
			
		||||
  RTC_DateStruct->Day     = 1U;
 | 
			
		||||
  RTC_DateStruct->Month   = LL_RTC_MONTH_JANUARY;
 | 
			
		||||
  RTC_DateStruct->Year    = 0U;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the RTC Alarm A.
 | 
			
		||||
  * @note   The Alarm register can only be written when the corresponding Alarm
 | 
			
		||||
  *         is disabled (Use @ref LL_RTC_ALMA_Disable function).
 | 
			
		||||
  * @param  RTCx RTC Instance
 | 
			
		||||
  * @param  RTC_Format This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_RTC_FORMAT_BIN
 | 
			
		||||
  *         @arg @ref LL_RTC_FORMAT_BCD
 | 
			
		||||
  * @param  RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that
 | 
			
		||||
  *                         contains the alarm configuration parameters.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: ALARMA registers are configured
 | 
			
		||||
  *          - ERROR: ALARMA registers are not configured
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RTC_ALMA_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
 | 
			
		||||
  assert_param(IS_LL_RTC_FORMAT(RTC_Format));
 | 
			
		||||
  assert_param(IS_LL_RTC_ALMA_MASK(RTC_AlarmStruct->AlarmMask));
 | 
			
		||||
  assert_param(IS_LL_RTC_ALMA_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel));
 | 
			
		||||
 | 
			
		||||
  if (RTC_Format == LL_RTC_FORMAT_BIN)
 | 
			
		||||
  {
 | 
			
		||||
    if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours));
 | 
			
		||||
      assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U;
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours));
 | 
			
		||||
    }
 | 
			
		||||
    assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes));
 | 
			
		||||
    assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds));
 | 
			
		||||
 | 
			
		||||
    if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)));
 | 
			
		||||
      assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U;
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes)));
 | 
			
		||||
    assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds)));
 | 
			
		||||
 | 
			
		||||
    if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay)));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay)));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Disable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_DisableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  /* Select weekday selection */
 | 
			
		||||
  if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMA_DATEWEEKDAYSEL_DATE)
 | 
			
		||||
  {
 | 
			
		||||
    /* Set the date for ALARM */
 | 
			
		||||
    LL_RTC_ALMA_DisableWeekday(RTCx);
 | 
			
		||||
    if (RTC_Format != LL_RTC_FORMAT_BIN)
 | 
			
		||||
    {
 | 
			
		||||
      LL_RTC_ALMA_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      LL_RTC_ALMA_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* Set the week day for ALARM */
 | 
			
		||||
    LL_RTC_ALMA_EnableWeekday(RTCx);
 | 
			
		||||
    LL_RTC_ALMA_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Configure the Alarm register */
 | 
			
		||||
  if (RTC_Format != LL_RTC_FORMAT_BIN)
 | 
			
		||||
  {
 | 
			
		||||
    LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours,
 | 
			
		||||
                           RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds);
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    LL_RTC_ALMA_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat,
 | 
			
		||||
                           __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours),
 | 
			
		||||
                           __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes),
 | 
			
		||||
                           __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds));
 | 
			
		||||
  }
 | 
			
		||||
  /* Set ALARM mask */
 | 
			
		||||
  LL_RTC_ALMA_SetMask(RTCx, RTC_AlarmStruct->AlarmMask);
 | 
			
		||||
 | 
			
		||||
  /* Enable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_EnableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the RTC Alarm B.
 | 
			
		||||
  * @note   The Alarm register can only be written when the corresponding Alarm
 | 
			
		||||
  *         is disabled (@ref LL_RTC_ALMB_Disable function).
 | 
			
		||||
  * @param  RTCx RTC Instance
 | 
			
		||||
  * @param  RTC_Format This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_RTC_FORMAT_BIN
 | 
			
		||||
  *         @arg @ref LL_RTC_FORMAT_BCD
 | 
			
		||||
  * @param  RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure that
 | 
			
		||||
  *                         contains the alarm configuration parameters.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: ALARMB registers are configured
 | 
			
		||||
  *          - ERROR: ALARMB registers are not configured
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RTC_ALMB_Init(RTC_TypeDef *RTCx, uint32_t RTC_Format, LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
 | 
			
		||||
  assert_param(IS_LL_RTC_FORMAT(RTC_Format));
 | 
			
		||||
  assert_param(IS_LL_RTC_ALMB_MASK(RTC_AlarmStruct->AlarmMask));
 | 
			
		||||
  assert_param(IS_LL_RTC_ALMB_DATE_WEEKDAY_SEL(RTC_AlarmStruct->AlarmDateWeekDaySel));
 | 
			
		||||
 | 
			
		||||
  if (RTC_Format == LL_RTC_FORMAT_BIN)
 | 
			
		||||
  {
 | 
			
		||||
    if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR12(RTC_AlarmStruct->AlarmTime.Hours));
 | 
			
		||||
      assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U;
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR24(RTC_AlarmStruct->AlarmTime.Hours));
 | 
			
		||||
    }
 | 
			
		||||
    assert_param(IS_LL_RTC_MINUTES(RTC_AlarmStruct->AlarmTime.Minutes));
 | 
			
		||||
    assert_param(IS_LL_RTC_SECONDS(RTC_AlarmStruct->AlarmTime.Seconds));
 | 
			
		||||
 | 
			
		||||
    if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_DAY(RTC_AlarmStruct->AlarmDateWeekDay));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_WEEKDAY(RTC_AlarmStruct->AlarmDateWeekDay));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    if (LL_RTC_GetHourFormat(RTCx) != LL_RTC_HOURFORMAT_24HOUR)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR12(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)));
 | 
			
		||||
      assert_param(IS_LL_RTC_TIME_FORMAT(RTC_AlarmStruct->AlarmTime.TimeFormat));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      RTC_AlarmStruct->AlarmTime.TimeFormat = 0x00U;
 | 
			
		||||
      assert_param(IS_LL_RTC_HOUR24(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Hours)));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    assert_param(IS_LL_RTC_MINUTES(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Minutes)));
 | 
			
		||||
    assert_param(IS_LL_RTC_SECONDS(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmTime.Seconds)));
 | 
			
		||||
 | 
			
		||||
    if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_DAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay)));
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_RTC_WEEKDAY(__LL_RTC_CONVERT_BCD2BIN(RTC_AlarmStruct->AlarmDateWeekDay)));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Disable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_DisableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  /* Select weekday selection */
 | 
			
		||||
  if (RTC_AlarmStruct->AlarmDateWeekDaySel == LL_RTC_ALMB_DATEWEEKDAYSEL_DATE)
 | 
			
		||||
  {
 | 
			
		||||
    /* Set the date for ALARM */
 | 
			
		||||
    LL_RTC_ALMB_DisableWeekday(RTCx);
 | 
			
		||||
    if (RTC_Format != LL_RTC_FORMAT_BIN)
 | 
			
		||||
    {
 | 
			
		||||
      LL_RTC_ALMB_SetDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      LL_RTC_ALMB_SetDay(RTCx, __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmDateWeekDay));
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    /* Set the week day for ALARM */
 | 
			
		||||
    LL_RTC_ALMB_EnableWeekday(RTCx);
 | 
			
		||||
    LL_RTC_ALMB_SetWeekDay(RTCx, RTC_AlarmStruct->AlarmDateWeekDay);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Configure the Alarm register */
 | 
			
		||||
  if (RTC_Format != LL_RTC_FORMAT_BIN)
 | 
			
		||||
  {
 | 
			
		||||
    LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat, RTC_AlarmStruct->AlarmTime.Hours,
 | 
			
		||||
                           RTC_AlarmStruct->AlarmTime.Minutes, RTC_AlarmStruct->AlarmTime.Seconds);
 | 
			
		||||
  }
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    LL_RTC_ALMB_ConfigTime(RTCx, RTC_AlarmStruct->AlarmTime.TimeFormat,
 | 
			
		||||
                           __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Hours),
 | 
			
		||||
                           __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Minutes),
 | 
			
		||||
                           __LL_RTC_CONVERT_BIN2BCD(RTC_AlarmStruct->AlarmTime.Seconds));
 | 
			
		||||
  }
 | 
			
		||||
  /* Set ALARM mask */
 | 
			
		||||
  LL_RTC_ALMB_SetMask(RTCx, RTC_AlarmStruct->AlarmMask);
 | 
			
		||||
 | 
			
		||||
  /* Enable the write protection for RTC registers */
 | 
			
		||||
  LL_RTC_EnableWriteProtection(RTCx);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec /
 | 
			
		||||
  *         Day = 1st day of the month/Mask = all fields are masked).
 | 
			
		||||
  * @param  RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_RTC_ALMA_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Alarm Time Settings : Time = 00h:00mn:00sec */
 | 
			
		||||
  RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMA_TIME_FORMAT_AM;
 | 
			
		||||
  RTC_AlarmStruct->AlarmTime.Hours      = 0U;
 | 
			
		||||
  RTC_AlarmStruct->AlarmTime.Minutes    = 0U;
 | 
			
		||||
  RTC_AlarmStruct->AlarmTime.Seconds    = 0U;
 | 
			
		||||
 | 
			
		||||
  /* Alarm Day Settings : Day = 1st day of the month */
 | 
			
		||||
  RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMA_DATEWEEKDAYSEL_DATE;
 | 
			
		||||
  RTC_AlarmStruct->AlarmDateWeekDay    = 1U;
 | 
			
		||||
 | 
			
		||||
  /* Alarm Masks Settings : Mask =  all fields are not masked */
 | 
			
		||||
  RTC_AlarmStruct->AlarmMask           = LL_RTC_ALMA_MASK_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_RTC_AlarmTypeDef of ALARMA field to default value (Time = 00h:00mn:00sec /
 | 
			
		||||
  *         Day = 1st day of the month/Mask = all fields are masked).
 | 
			
		||||
  * @param  RTC_AlarmStruct pointer to a @ref LL_RTC_AlarmTypeDef structure which will be initialized.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_RTC_ALMB_StructInit(LL_RTC_AlarmTypeDef *RTC_AlarmStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Alarm Time Settings : Time = 00h:00mn:00sec */
 | 
			
		||||
  RTC_AlarmStruct->AlarmTime.TimeFormat = LL_RTC_ALMB_TIME_FORMAT_AM;
 | 
			
		||||
  RTC_AlarmStruct->AlarmTime.Hours      = 0U;
 | 
			
		||||
  RTC_AlarmStruct->AlarmTime.Minutes    = 0U;
 | 
			
		||||
  RTC_AlarmStruct->AlarmTime.Seconds    = 0U;
 | 
			
		||||
 | 
			
		||||
  /* Alarm Day Settings : Day = 1st day of the month */
 | 
			
		||||
  RTC_AlarmStruct->AlarmDateWeekDaySel = LL_RTC_ALMB_DATEWEEKDAYSEL_DATE;
 | 
			
		||||
  RTC_AlarmStruct->AlarmDateWeekDay    = 1U;
 | 
			
		||||
 | 
			
		||||
  /* Alarm Masks Settings : Mask =  all fields are not masked */
 | 
			
		||||
  RTC_AlarmStruct->AlarmMask           = LL_RTC_ALMB_MASK_NONE;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enters the RTC Initialization mode.
 | 
			
		||||
  * @note   The RTC Initialization mode is write protected, use the
 | 
			
		||||
  *         @ref LL_RTC_DisableWriteProtection before calling this function.
 | 
			
		||||
  * @param  RTCx RTC Instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: RTC is in Init mode
 | 
			
		||||
  *          - ERROR: RTC is not in Init mode
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RTC_EnterInitMode(RTC_TypeDef *RTCx)
 | 
			
		||||
{
 | 
			
		||||
  __IO uint32_t timeout = RTC_INITMODE_TIMEOUT;
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
  uint32_t tmp = 0U;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameter */
 | 
			
		||||
  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
 | 
			
		||||
 | 
			
		||||
  /* Check if the Initialization mode is set */
 | 
			
		||||
  if (LL_RTC_IsActiveFlag_INIT(RTCx) == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    /* Set the Initialization mode */
 | 
			
		||||
    LL_RTC_EnableInitMode(RTCx);
 | 
			
		||||
 | 
			
		||||
    /* Wait till RTC is in INIT state and if Time out is reached exit */
 | 
			
		||||
    tmp = LL_RTC_IsActiveFlag_INIT(RTCx);
 | 
			
		||||
    while ((timeout != 0U) && (tmp != 1U))
 | 
			
		||||
    {
 | 
			
		||||
      if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
 | 
			
		||||
      {
 | 
			
		||||
        timeout --;
 | 
			
		||||
      }
 | 
			
		||||
      tmp = LL_RTC_IsActiveFlag_INIT(RTCx);
 | 
			
		||||
      if (timeout == 0U)
 | 
			
		||||
      {
 | 
			
		||||
        status = ERROR;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Exit the RTC Initialization mode.
 | 
			
		||||
  * @note   When the initialization sequence is complete, the calendar restarts
 | 
			
		||||
  *         counting after 4 RTCCLK cycles.
 | 
			
		||||
  * @note   The RTC Initialization mode is write protected, use the
 | 
			
		||||
  *         @ref LL_RTC_DisableWriteProtection before calling this function.
 | 
			
		||||
  * @param  RTCx RTC Instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: RTC exited from in Init mode
 | 
			
		||||
  *          - ERROR: Not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RTC_ExitInitMode(RTC_TypeDef *RTCx)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the parameter */
 | 
			
		||||
  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
 | 
			
		||||
 | 
			
		||||
  /* Disable initialization mode */
 | 
			
		||||
  LL_RTC_DisableInitMode(RTCx);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Waits until the RTC Time and Day registers (RTC_TR and RTC_DR) are
 | 
			
		||||
  *         synchronized with RTC APB clock.
 | 
			
		||||
  * @note   The RTC Resynchronization mode is write protected, use the
 | 
			
		||||
  *         @ref LL_RTC_DisableWriteProtection before calling this function.
 | 
			
		||||
  * @note   To read the calendar through the shadow registers after Calendar
 | 
			
		||||
  *         initialization, calendar update or after wakeup from low power modes
 | 
			
		||||
  *         the software must first clear the RSF flag.
 | 
			
		||||
  *         The software must then wait until it is set again before reading
 | 
			
		||||
  *         the calendar, which means that the calendar registers have been
 | 
			
		||||
  *         correctly copied into the RTC_TR and RTC_DR shadow registers.
 | 
			
		||||
  * @param  RTCx RTC Instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: RTC registers are synchronised
 | 
			
		||||
  *          - ERROR: RTC registers are not synchronised
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_RTC_WaitForSynchro(RTC_TypeDef *RTCx)
 | 
			
		||||
{
 | 
			
		||||
  __IO uint32_t timeout = RTC_SYNCHRO_TIMEOUT;
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
  uint32_t tmp = 0U;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameter */
 | 
			
		||||
  assert_param(IS_RTC_ALL_INSTANCE(RTCx));
 | 
			
		||||
 | 
			
		||||
  /* Clear RSF flag */
 | 
			
		||||
  LL_RTC_ClearFlag_RS(RTCx);
 | 
			
		||||
 | 
			
		||||
  /* Wait the registers to be synchronised */
 | 
			
		||||
  tmp = LL_RTC_IsActiveFlag_RS(RTCx);
 | 
			
		||||
  while ((timeout != 0U) && (tmp != 0U))
 | 
			
		||||
  {
 | 
			
		||||
    if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
 | 
			
		||||
    {
 | 
			
		||||
      timeout--;
 | 
			
		||||
    }
 | 
			
		||||
    tmp = LL_RTC_IsActiveFlag_RS(RTCx);
 | 
			
		||||
    if (timeout == 0U)
 | 
			
		||||
    {
 | 
			
		||||
      status = ERROR;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  if (status != ERROR)
 | 
			
		||||
  {
 | 
			
		||||
    timeout = RTC_SYNCHRO_TIMEOUT;
 | 
			
		||||
    tmp = LL_RTC_IsActiveFlag_RS(RTCx);
 | 
			
		||||
    while ((timeout != 0U) && (tmp != 1U))
 | 
			
		||||
    {
 | 
			
		||||
      if (LL_SYSTICK_IsActiveCounterFlag() == 1U)
 | 
			
		||||
      {
 | 
			
		||||
        timeout--;
 | 
			
		||||
      }
 | 
			
		||||
      tmp = LL_RTC_IsActiveFlag_RS(RTCx);
 | 
			
		||||
      if (timeout == 0U)
 | 
			
		||||
      {
 | 
			
		||||
        status = ERROR;
 | 
			
		||||
      }
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return (status);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* defined(RTC) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,541 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_spi.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   SPI LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_spi.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
#include "stm32l0xx_ll_rcc.h"
 | 
			
		||||
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (SPI1) || defined (SPI2)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup SPI_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @defgroup SPI_LL_Private_Constants SPI Private Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/* SPI registers Masks */
 | 
			
		||||
#define SPI_CR1_CLEAR_MASK                 (SPI_CR1_CPHA    | SPI_CR1_CPOL     | SPI_CR1_MSTR   | \
 | 
			
		||||
                                            SPI_CR1_BR      | SPI_CR1_LSBFIRST | SPI_CR1_SSI    | \
 | 
			
		||||
                                            SPI_CR1_SSM     | SPI_CR1_RXONLY   | SPI_CR1_DFF    | \
 | 
			
		||||
                                            SPI_CR1_CRCNEXT | SPI_CR1_CRCEN    | SPI_CR1_BIDIOE | \
 | 
			
		||||
                                            SPI_CR1_BIDIMODE)
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup SPI_LL_Private_Macros SPI Private Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define IS_LL_SPI_TRANSFER_DIRECTION(__VALUE__) (((__VALUE__) == LL_SPI_FULL_DUPLEX)    \
 | 
			
		||||
                                              || ((__VALUE__) == LL_SPI_SIMPLEX_RX)     \
 | 
			
		||||
                                              || ((__VALUE__) == LL_SPI_HALF_DUPLEX_RX) \
 | 
			
		||||
                                              || ((__VALUE__) == LL_SPI_HALF_DUPLEX_TX))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_SPI_MODE(__VALUE__) (((__VALUE__) == LL_SPI_MODE_MASTER) \
 | 
			
		||||
                                || ((__VALUE__) == LL_SPI_MODE_SLAVE))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_SPI_DATAWIDTH(__VALUE__) (((__VALUE__) == LL_SPI_DATAWIDTH_8BIT)  \
 | 
			
		||||
                                     || ((__VALUE__) == LL_SPI_DATAWIDTH_16BIT))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_SPI_POLARITY(__VALUE__) (((__VALUE__) == LL_SPI_POLARITY_LOW) \
 | 
			
		||||
                                    || ((__VALUE__) == LL_SPI_POLARITY_HIGH))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_SPI_PHASE(__VALUE__) (((__VALUE__) == LL_SPI_PHASE_1EDGE) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_SPI_PHASE_2EDGE))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_SPI_NSS(__VALUE__) (((__VALUE__) == LL_SPI_NSS_SOFT) \
 | 
			
		||||
                               || ((__VALUE__) == LL_SPI_NSS_HARD_INPUT) \
 | 
			
		||||
                               || ((__VALUE__) == LL_SPI_NSS_HARD_OUTPUT))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_SPI_BAUDRATE(__VALUE__) (((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV2)   \
 | 
			
		||||
                                    || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV4)   \
 | 
			
		||||
                                    || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV8)   \
 | 
			
		||||
                                    || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV16)  \
 | 
			
		||||
                                    || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV32)  \
 | 
			
		||||
                                    || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV64)  \
 | 
			
		||||
                                    || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV128) \
 | 
			
		||||
                                    || ((__VALUE__) == LL_SPI_BAUDRATEPRESCALER_DIV256))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_SPI_BITORDER(__VALUE__) (((__VALUE__) == LL_SPI_LSB_FIRST) \
 | 
			
		||||
                                    || ((__VALUE__) == LL_SPI_MSB_FIRST))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_SPI_CRCCALCULATION(__VALUE__) (((__VALUE__) == LL_SPI_CRCCALCULATION_ENABLE) \
 | 
			
		||||
                                          || ((__VALUE__) == LL_SPI_CRCCALCULATION_DISABLE))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_SPI_CRC_POLYNOMIAL(__VALUE__) ((__VALUE__) >= 0x1U)
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup SPI_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup SPI_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize the SPI registers to their default reset values.
 | 
			
		||||
  * @param  SPIx SPI Instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: SPI registers are de-initialized
 | 
			
		||||
  *          - ERROR: SPI registers are not de-initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_SPI_DeInit(SPI_TypeDef *SPIx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = ERROR;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_SPI_ALL_INSTANCE(SPIx));
 | 
			
		||||
 | 
			
		||||
#if defined(SPI1)
 | 
			
		||||
  if (SPIx == SPI1)
 | 
			
		||||
  {
 | 
			
		||||
    /* Force reset of SPI clock */
 | 
			
		||||
    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_SPI1);
 | 
			
		||||
 | 
			
		||||
    /* Release reset of SPI clock */
 | 
			
		||||
    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_SPI1);
 | 
			
		||||
 | 
			
		||||
    status = SUCCESS;
 | 
			
		||||
  }
 | 
			
		||||
#endif /* SPI1 */
 | 
			
		||||
#if defined(SPI2)
 | 
			
		||||
  if (SPIx == SPI2)
 | 
			
		||||
  {
 | 
			
		||||
    /* Force reset of SPI clock */
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_SPI2);
 | 
			
		||||
 | 
			
		||||
    /* Release reset of SPI clock */
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_SPI2);
 | 
			
		||||
 | 
			
		||||
    status = SUCCESS;
 | 
			
		||||
  }
 | 
			
		||||
#endif /* SPI2 */
 | 
			
		||||
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize the SPI registers according to the specified parameters in SPI_InitStruct.
 | 
			
		||||
  * @note   As some bits in SPI configuration registers can only be written when the SPI is disabled (SPI_CR1_SPE bit =0),
 | 
			
		||||
  *         SPI IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
 | 
			
		||||
  * @param  SPIx SPI Instance
 | 
			
		||||
  * @param  SPI_InitStruct pointer to a @ref LL_SPI_InitTypeDef structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value. (Return always SUCCESS)
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_SPI_Init(SPI_TypeDef *SPIx, LL_SPI_InitTypeDef *SPI_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = ERROR;
 | 
			
		||||
 | 
			
		||||
  /* Check the SPI Instance SPIx*/
 | 
			
		||||
  assert_param(IS_SPI_ALL_INSTANCE(SPIx));
 | 
			
		||||
 | 
			
		||||
  /* Check the SPI parameters from SPI_InitStruct*/
 | 
			
		||||
  assert_param(IS_LL_SPI_TRANSFER_DIRECTION(SPI_InitStruct->TransferDirection));
 | 
			
		||||
  assert_param(IS_LL_SPI_MODE(SPI_InitStruct->Mode));
 | 
			
		||||
  assert_param(IS_LL_SPI_DATAWIDTH(SPI_InitStruct->DataWidth));
 | 
			
		||||
  assert_param(IS_LL_SPI_POLARITY(SPI_InitStruct->ClockPolarity));
 | 
			
		||||
  assert_param(IS_LL_SPI_PHASE(SPI_InitStruct->ClockPhase));
 | 
			
		||||
  assert_param(IS_LL_SPI_NSS(SPI_InitStruct->NSS));
 | 
			
		||||
  assert_param(IS_LL_SPI_BAUDRATE(SPI_InitStruct->BaudRate));
 | 
			
		||||
  assert_param(IS_LL_SPI_BITORDER(SPI_InitStruct->BitOrder));
 | 
			
		||||
  assert_param(IS_LL_SPI_CRCCALCULATION(SPI_InitStruct->CRCCalculation));
 | 
			
		||||
 | 
			
		||||
  if (LL_SPI_IsEnabled(SPIx) == 0x00000000U)
 | 
			
		||||
  {
 | 
			
		||||
    /*---------------------------- SPIx CR1 Configuration ------------------------
 | 
			
		||||
     * Configure SPIx CR1 with parameters:
 | 
			
		||||
     * - TransferDirection:  SPI_CR1_BIDIMODE, SPI_CR1_BIDIOE and SPI_CR1_RXONLY bits
 | 
			
		||||
     * - Master/Slave Mode:  SPI_CR1_MSTR bit
 | 
			
		||||
     * - DataWidth:          SPI_CR1_DFF bit
 | 
			
		||||
     * - ClockPolarity:      SPI_CR1_CPOL bit
 | 
			
		||||
     * - ClockPhase:         SPI_CR1_CPHA bit
 | 
			
		||||
     * - NSS management:     SPI_CR1_SSM bit
 | 
			
		||||
     * - BaudRate prescaler: SPI_CR1_BR[2:0] bits
 | 
			
		||||
     * - BitOrder:           SPI_CR1_LSBFIRST bit
 | 
			
		||||
     * - CRCCalculation:     SPI_CR1_CRCEN bit
 | 
			
		||||
     */
 | 
			
		||||
    MODIFY_REG(SPIx->CR1,
 | 
			
		||||
               SPI_CR1_CLEAR_MASK,
 | 
			
		||||
               SPI_InitStruct->TransferDirection | SPI_InitStruct->Mode | SPI_InitStruct->DataWidth |
 | 
			
		||||
               SPI_InitStruct->ClockPolarity | SPI_InitStruct->ClockPhase |
 | 
			
		||||
               SPI_InitStruct->NSS | SPI_InitStruct->BaudRate |
 | 
			
		||||
               SPI_InitStruct->BitOrder | SPI_InitStruct->CRCCalculation);
 | 
			
		||||
 | 
			
		||||
    /*---------------------------- SPIx CR2 Configuration ------------------------
 | 
			
		||||
     * Configure SPIx CR2 with parameters:
 | 
			
		||||
     * - NSS management:     SSOE bit
 | 
			
		||||
     */
 | 
			
		||||
    MODIFY_REG(SPIx->CR2, SPI_CR2_SSOE, (SPI_InitStruct->NSS >> 16U));
 | 
			
		||||
 | 
			
		||||
    /*---------------------------- SPIx CRCPR Configuration ----------------------
 | 
			
		||||
     * Configure SPIx CRCPR with parameters:
 | 
			
		||||
     * - CRCPoly:            CRCPOLY[15:0] bits
 | 
			
		||||
     */
 | 
			
		||||
    if (SPI_InitStruct->CRCCalculation == LL_SPI_CRCCALCULATION_ENABLE)
 | 
			
		||||
    {
 | 
			
		||||
      assert_param(IS_LL_SPI_CRC_POLYNOMIAL(SPI_InitStruct->CRCPoly));
 | 
			
		||||
      LL_SPI_SetCRCPolynomial(SPIx, SPI_InitStruct->CRCPoly);
 | 
			
		||||
    }
 | 
			
		||||
    status = SUCCESS;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
#if defined (SPI_I2S_SUPPORT)
 | 
			
		||||
  /* Activate the SPI mode (Reset I2SMOD bit in I2SCFGR register) */
 | 
			
		||||
  CLEAR_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SMOD);
 | 
			
		||||
#endif /* SPI_I2S_SUPPORT */
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_SPI_InitTypeDef field to default value.
 | 
			
		||||
  * @param  SPI_InitStruct pointer to a @ref LL_SPI_InitTypeDef structure
 | 
			
		||||
  * whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_SPI_StructInit(LL_SPI_InitTypeDef *SPI_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set SPI_InitStruct fields to default values */
 | 
			
		||||
  SPI_InitStruct->TransferDirection = LL_SPI_FULL_DUPLEX;
 | 
			
		||||
  SPI_InitStruct->Mode              = LL_SPI_MODE_SLAVE;
 | 
			
		||||
  SPI_InitStruct->DataWidth         = LL_SPI_DATAWIDTH_8BIT;
 | 
			
		||||
  SPI_InitStruct->ClockPolarity     = LL_SPI_POLARITY_LOW;
 | 
			
		||||
  SPI_InitStruct->ClockPhase        = LL_SPI_PHASE_1EDGE;
 | 
			
		||||
  SPI_InitStruct->NSS               = LL_SPI_NSS_HARD_INPUT;
 | 
			
		||||
  SPI_InitStruct->BaudRate          = LL_SPI_BAUDRATEPRESCALER_DIV2;
 | 
			
		||||
  SPI_InitStruct->BitOrder          = LL_SPI_MSB_FIRST;
 | 
			
		||||
  SPI_InitStruct->CRCCalculation    = LL_SPI_CRCCALCULATION_DISABLE;
 | 
			
		||||
  SPI_InitStruct->CRCPoly           = 7U;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined(SPI_I2S_SUPPORT)
 | 
			
		||||
/** @addtogroup I2S_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @defgroup I2S_LL_Private_Constants I2S Private Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/* I2S registers Masks */
 | 
			
		||||
#define I2S_I2SCFGR_CLEAR_MASK             (SPI_I2SCFGR_CHLEN   | SPI_I2SCFGR_DATLEN | \
 | 
			
		||||
                                            SPI_I2SCFGR_CKPOL   | SPI_I2SCFGR_I2SSTD | \
 | 
			
		||||
                                            SPI_I2SCFGR_I2SCFG  | SPI_I2SCFGR_I2SMOD )
 | 
			
		||||
 | 
			
		||||
#define I2S_I2SPR_CLEAR_MASK               0x0002U
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup I2S_LL_Private_Macros I2S Private Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2S_DATAFORMAT(__VALUE__)  (((__VALUE__) == LL_I2S_DATAFORMAT_16B)          \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_DATAFORMAT_16B_EXTENDED) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_DATAFORMAT_24B)          \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_DATAFORMAT_32B))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2S_CPOL(__VALUE__)        (((__VALUE__) == LL_I2S_POLARITY_LOW)  \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_POLARITY_HIGH))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2S_STANDARD(__VALUE__)    (((__VALUE__) == LL_I2S_STANDARD_PHILIPS)   \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_STANDARD_MSB)       \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_STANDARD_LSB)       \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_STANDARD_PCM_SHORT) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_STANDARD_PCM_LONG))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2S_MODE(__VALUE__)        (((__VALUE__) == LL_I2S_MODE_SLAVE_TX)  \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_MODE_SLAVE_RX)  \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_MODE_MASTER_TX) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_MODE_MASTER_RX))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2S_MCLK_OUTPUT(__VALUE__) (((__VALUE__) == LL_I2S_MCLK_OUTPUT_ENABLE) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_MCLK_OUTPUT_DISABLE))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2S_AUDIO_FREQ(__VALUE__) ((((__VALUE__) >= LL_I2S_AUDIOFREQ_8K)    \
 | 
			
		||||
                                       && ((__VALUE__) <= LL_I2S_AUDIOFREQ_192K)) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_I2S_AUDIOFREQ_DEFAULT))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2S_PRESCALER_LINEAR(__VALUE__)  ((__VALUE__) >= 0x2U)
 | 
			
		||||
 | 
			
		||||
#define IS_LL_I2S_PRESCALER_PARITY(__VALUE__) (((__VALUE__) == LL_I2S_PRESCALER_PARITY_EVEN) \
 | 
			
		||||
                                           || ((__VALUE__) == LL_I2S_PRESCALER_PARITY_ODD))
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup I2S_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup I2S_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize the SPI/I2S registers to their default reset values.
 | 
			
		||||
  * @param  SPIx SPI Instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: SPI registers are de-initialized
 | 
			
		||||
  *          - ERROR: SPI registers are not de-initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_I2S_DeInit(SPI_TypeDef *SPIx)
 | 
			
		||||
{
 | 
			
		||||
  return LL_SPI_DeInit(SPIx);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initializes the SPI/I2S registers according to the specified parameters in I2S_InitStruct.
 | 
			
		||||
  * @note   As some bits in SPI configuration registers can only be written when the SPI is disabled (SPI_CR1_SPE bit =0),
 | 
			
		||||
  *         SPI IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
 | 
			
		||||
  * @param  SPIx SPI Instance
 | 
			
		||||
  * @param  I2S_InitStruct pointer to a @ref LL_I2S_InitTypeDef structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: SPI registers are Initialized
 | 
			
		||||
  *          - ERROR: SPI registers are not Initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_I2S_Init(SPI_TypeDef *SPIx, LL_I2S_InitTypeDef *I2S_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  uint16_t i2sdiv = 2U, i2sodd = 0U, packetlength = 1U;
 | 
			
		||||
  uint32_t tmp = 0U;
 | 
			
		||||
  LL_RCC_ClocksTypeDef rcc_clocks;
 | 
			
		||||
  uint32_t sourceclock = 0U;
 | 
			
		||||
  ErrorStatus status = ERROR;
 | 
			
		||||
 | 
			
		||||
  /* Check the I2S parameters */
 | 
			
		||||
  assert_param(IS_I2S_ALL_INSTANCE(SPIx));
 | 
			
		||||
  assert_param(IS_LL_I2S_MODE(I2S_InitStruct->Mode));
 | 
			
		||||
  assert_param(IS_LL_I2S_STANDARD(I2S_InitStruct->Standard));
 | 
			
		||||
  assert_param(IS_LL_I2S_DATAFORMAT(I2S_InitStruct->DataFormat));
 | 
			
		||||
  assert_param(IS_LL_I2S_MCLK_OUTPUT(I2S_InitStruct->MCLKOutput));
 | 
			
		||||
  assert_param(IS_LL_I2S_AUDIO_FREQ(I2S_InitStruct->AudioFreq));
 | 
			
		||||
  assert_param(IS_LL_I2S_CPOL(I2S_InitStruct->ClockPolarity));
 | 
			
		||||
 | 
			
		||||
  if (LL_I2S_IsEnabled(SPIx) == 0x00000000U)
 | 
			
		||||
  {
 | 
			
		||||
    /*---------------------------- SPIx I2SCFGR Configuration --------------------
 | 
			
		||||
     * Configure SPIx I2SCFGR with parameters:
 | 
			
		||||
     * - Mode:          SPI_I2SCFGR_I2SCFG[1:0] bit
 | 
			
		||||
     * - Standard:      SPI_I2SCFGR_I2SSTD[1:0] and SPI_I2SCFGR_PCMSYNC bits
 | 
			
		||||
     * - DataFormat:    SPI_I2SCFGR_CHLEN and SPI_I2SCFGR_DATLEN bits
 | 
			
		||||
     * - ClockPolarity: SPI_I2SCFGR_CKPOL bit
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    /* Write to SPIx I2SCFGR */
 | 
			
		||||
    MODIFY_REG(SPIx->I2SCFGR,
 | 
			
		||||
               I2S_I2SCFGR_CLEAR_MASK,
 | 
			
		||||
               I2S_InitStruct->Mode | I2S_InitStruct->Standard |
 | 
			
		||||
               I2S_InitStruct->DataFormat | I2S_InitStruct->ClockPolarity |
 | 
			
		||||
               SPI_I2SCFGR_I2SMOD);
 | 
			
		||||
 | 
			
		||||
    /*---------------------------- SPIx I2SPR Configuration ----------------------
 | 
			
		||||
     * Configure SPIx I2SPR with parameters:
 | 
			
		||||
     * - MCLKOutput:    SPI_I2SPR_MCKOE bit
 | 
			
		||||
     * - AudioFreq:     SPI_I2SPR_I2SDIV[7:0] and SPI_I2SPR_ODD bits
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    /* If the default value has to be written, reinitialize i2sdiv and i2sodd*/
 | 
			
		||||
    if (I2S_InitStruct->AudioFreq == LL_I2S_AUDIOFREQ_DEFAULT)
 | 
			
		||||
    {
 | 
			
		||||
      i2sodd = 0U;
 | 
			
		||||
      i2sdiv = 2U;
 | 
			
		||||
    }
 | 
			
		||||
    /* If the requested audio frequency is not the default, compute the prescaler */
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      /* Check the frame length (For the Prescaler computing) */
 | 
			
		||||
      if (I2S_InitStruct->DataFormat == LL_I2S_DATAFORMAT_16B)
 | 
			
		||||
      {
 | 
			
		||||
        /* Packet length is 16 bits */
 | 
			
		||||
        packetlength = 1U;
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        /* Packet length is 32 bits */
 | 
			
		||||
        packetlength = 2U;
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      /* I2S Clock source is System clock: Get System Clock frequency */
 | 
			
		||||
      LL_RCC_GetSystemClocksFreq(&rcc_clocks);
 | 
			
		||||
 | 
			
		||||
      /* Get the source clock value: based on System Clock value */
 | 
			
		||||
      sourceclock = rcc_clocks.SYSCLK_Frequency;
 | 
			
		||||
 | 
			
		||||
      /* Compute the Real divider depending on the MCLK output state with a floating point */
 | 
			
		||||
      if (I2S_InitStruct->MCLKOutput == LL_I2S_MCLK_OUTPUT_ENABLE)
 | 
			
		||||
      {
 | 
			
		||||
        /* MCLK output is enabled */
 | 
			
		||||
        tmp = (uint16_t)(((((sourceclock / 256U) * 10U) / I2S_InitStruct->AudioFreq)) + 5U);
 | 
			
		||||
      }
 | 
			
		||||
      else
 | 
			
		||||
      {
 | 
			
		||||
        /* MCLK output is disabled */
 | 
			
		||||
        tmp = (uint16_t)(((((sourceclock / (32U * packetlength)) * 10U) / I2S_InitStruct->AudioFreq)) + 5U);
 | 
			
		||||
      }
 | 
			
		||||
 | 
			
		||||
      /* Remove the floating point */
 | 
			
		||||
      tmp = tmp / 10U;
 | 
			
		||||
 | 
			
		||||
      /* Check the parity of the divider */
 | 
			
		||||
      i2sodd = (uint16_t)(tmp & (uint16_t)0x0001U);
 | 
			
		||||
 | 
			
		||||
      /* Compute the i2sdiv prescaler */
 | 
			
		||||
      i2sdiv = (uint16_t)((tmp - i2sodd) / 2U);
 | 
			
		||||
 | 
			
		||||
      /* Get the Mask for the Odd bit (SPI_I2SPR[8]) register */
 | 
			
		||||
      i2sodd = (uint16_t)(i2sodd << 8U);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Test if the divider is 1 or 0 or greater than 0xFF */
 | 
			
		||||
    if ((i2sdiv < 2U) || (i2sdiv > 0xFFU))
 | 
			
		||||
    {
 | 
			
		||||
      /* Set the default values */
 | 
			
		||||
      i2sdiv = 2U;
 | 
			
		||||
      i2sodd = 0U;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Write to SPIx I2SPR register the computed value */
 | 
			
		||||
    WRITE_REG(SPIx->I2SPR, i2sdiv | i2sodd | I2S_InitStruct->MCLKOutput);
 | 
			
		||||
 | 
			
		||||
    status = SUCCESS;
 | 
			
		||||
  }
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set each @ref LL_I2S_InitTypeDef field to default value.
 | 
			
		||||
  * @param  I2S_InitStruct pointer to a @ref LL_I2S_InitTypeDef structure
 | 
			
		||||
  *         whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_I2S_StructInit(LL_I2S_InitTypeDef *I2S_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /*--------------- Reset I2S init structure parameters values -----------------*/
 | 
			
		||||
  I2S_InitStruct->Mode              = LL_I2S_MODE_SLAVE_TX;
 | 
			
		||||
  I2S_InitStruct->Standard          = LL_I2S_STANDARD_PHILIPS;
 | 
			
		||||
  I2S_InitStruct->DataFormat        = LL_I2S_DATAFORMAT_16B;
 | 
			
		||||
  I2S_InitStruct->MCLKOutput        = LL_I2S_MCLK_OUTPUT_DISABLE;
 | 
			
		||||
  I2S_InitStruct->AudioFreq         = LL_I2S_AUDIOFREQ_DEFAULT;
 | 
			
		||||
  I2S_InitStruct->ClockPolarity     = LL_I2S_POLARITY_LOW;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set linear and parity prescaler.
 | 
			
		||||
  * @note   To calculate value of PrescalerLinear(I2SDIV[7:0] bits) and PrescalerParity(ODD bit)\n
 | 
			
		||||
  *         Check Audio frequency table and formulas inside Reference Manual (SPI/I2S).
 | 
			
		||||
  * @param  SPIx SPI Instance
 | 
			
		||||
  * @param  PrescalerLinear value: Min_Data=0x02 and Max_Data=0xFF.
 | 
			
		||||
  * @param  PrescalerParity This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_I2S_PRESCALER_PARITY_EVEN
 | 
			
		||||
  *         @arg @ref LL_I2S_PRESCALER_PARITY_ODD
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_I2S_ConfigPrescaler(SPI_TypeDef *SPIx, uint32_t PrescalerLinear, uint32_t PrescalerParity)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the I2S parameters */
 | 
			
		||||
  assert_param(IS_I2S_ALL_INSTANCE(SPIx));
 | 
			
		||||
  assert_param(IS_LL_I2S_PRESCALER_LINEAR(PrescalerLinear));
 | 
			
		||||
  assert_param(IS_LL_I2S_PRESCALER_PARITY(PrescalerParity));
 | 
			
		||||
 | 
			
		||||
  /* Write to SPIx I2SPR */
 | 
			
		||||
  MODIFY_REG(SPIx->I2SPR, SPI_I2SPR_I2SDIV | SPI_I2SPR_ODD, PrescalerLinear | (PrescalerParity << 8U));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
#endif /* SPI_I2S_SUPPORT */
 | 
			
		||||
 | 
			
		||||
#endif /* defined (SPI1) || defined (SPI2) */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,868 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_tim.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   TIM LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_tim.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
  #include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
  #define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (TIM2) || defined (TIM3) || defined (TIM21) || defined (TIM22) || defined (TIM6) || defined (TIM7)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup TIM_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup TIM_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define IS_LL_TIM_COUNTERMODE(__VALUE__) (((__VALUE__) == LL_TIM_COUNTERMODE_UP) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_TIM_COUNTERMODE_DOWN) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_TIM_COUNTERMODE_CENTER_UP) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_TIM_COUNTERMODE_CENTER_DOWN) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_TIM_COUNTERMODE_CENTER_UP_DOWN))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_TIM_CLOCKDIVISION(__VALUE__) (((__VALUE__) == LL_TIM_CLOCKDIVISION_DIV1) \
 | 
			
		||||
                                         || ((__VALUE__) == LL_TIM_CLOCKDIVISION_DIV2) \
 | 
			
		||||
                                         || ((__VALUE__) == LL_TIM_CLOCKDIVISION_DIV4))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_TIM_OCMODE(__VALUE__) (((__VALUE__) == LL_TIM_OCMODE_FROZEN) \
 | 
			
		||||
                                  || ((__VALUE__) == LL_TIM_OCMODE_ACTIVE) \
 | 
			
		||||
                                  || ((__VALUE__) == LL_TIM_OCMODE_INACTIVE) \
 | 
			
		||||
                                  || ((__VALUE__) == LL_TIM_OCMODE_TOGGLE) \
 | 
			
		||||
                                  || ((__VALUE__) == LL_TIM_OCMODE_FORCED_INACTIVE) \
 | 
			
		||||
                                  || ((__VALUE__) == LL_TIM_OCMODE_FORCED_ACTIVE) \
 | 
			
		||||
                                  || ((__VALUE__) == LL_TIM_OCMODE_PWM1) \
 | 
			
		||||
                                  || ((__VALUE__) == LL_TIM_OCMODE_PWM2))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_TIM_OCSTATE(__VALUE__) (((__VALUE__) == LL_TIM_OCSTATE_DISABLE) \
 | 
			
		||||
                                   || ((__VALUE__) == LL_TIM_OCSTATE_ENABLE))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_TIM_OCPOLARITY(__VALUE__) (((__VALUE__) == LL_TIM_OCPOLARITY_HIGH) \
 | 
			
		||||
                                      || ((__VALUE__) == LL_TIM_OCPOLARITY_LOW))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_TIM_ACTIVEINPUT(__VALUE__) (((__VALUE__) == LL_TIM_ACTIVEINPUT_DIRECTTI) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_TIM_ACTIVEINPUT_INDIRECTTI) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_TIM_ACTIVEINPUT_TRC))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_TIM_ICPSC(__VALUE__) (((__VALUE__) == LL_TIM_ICPSC_DIV1) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_TIM_ICPSC_DIV2) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_TIM_ICPSC_DIV4) \
 | 
			
		||||
                                 || ((__VALUE__) == LL_TIM_ICPSC_DIV8))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_TIM_IC_FILTER(__VALUE__) (((__VALUE__) == LL_TIM_IC_FILTER_FDIV1) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV1_N2) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV1_N4) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV1_N8) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV2_N6) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV2_N8) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV4_N6) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV4_N8) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV8_N6) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV8_N8) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV16_N5) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV16_N6) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV16_N8) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV32_N5) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV32_N6) \
 | 
			
		||||
                                     || ((__VALUE__) == LL_TIM_IC_FILTER_FDIV32_N8))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_TIM_IC_POLARITY(__VALUE__) (((__VALUE__) == LL_TIM_IC_POLARITY_RISING) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_TIM_IC_POLARITY_FALLING) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_TIM_IC_POLARITY_BOTHEDGE))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_TIM_ENCODERMODE(__VALUE__) (((__VALUE__) == LL_TIM_ENCODERMODE_X2_TI1) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_TIM_ENCODERMODE_X2_TI2) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_TIM_ENCODERMODE_X4_TI12))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_TIM_IC_POLARITY_ENCODER(__VALUE__) (((__VALUE__) == LL_TIM_IC_POLARITY_RISING) \
 | 
			
		||||
                                               || ((__VALUE__) == LL_TIM_IC_POLARITY_FALLING))
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
/** @defgroup TIM_LL_Private_Functions TIM Private Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
static ErrorStatus OC1Config(TIM_TypeDef* TIMx, LL_TIM_OC_InitTypeDef* TIM_OCInitStruct);
 | 
			
		||||
static ErrorStatus OC2Config(TIM_TypeDef* TIMx, LL_TIM_OC_InitTypeDef* TIM_OCInitStruct);
 | 
			
		||||
static ErrorStatus OC3Config(TIM_TypeDef* TIMx, LL_TIM_OC_InitTypeDef* TIM_OCInitStruct);
 | 
			
		||||
static ErrorStatus OC4Config(TIM_TypeDef* TIMx, LL_TIM_OC_InitTypeDef* TIM_OCInitStruct);
 | 
			
		||||
static ErrorStatus IC1Config(TIM_TypeDef* TIMx, LL_TIM_IC_InitTypeDef* TIM_ICInitStruct);
 | 
			
		||||
static ErrorStatus IC2Config(TIM_TypeDef* TIMx, LL_TIM_IC_InitTypeDef* TIM_ICInitStruct);
 | 
			
		||||
static ErrorStatus IC3Config(TIM_TypeDef* TIMx, LL_TIM_IC_InitTypeDef* TIM_ICInitStruct);
 | 
			
		||||
static ErrorStatus IC4Config(TIM_TypeDef* TIMx, LL_TIM_IC_InitTypeDef* TIM_ICInitStruct);
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup TIM_LL_Exported_Functions 
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup TIM_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set TIMx registers to their reset values.
 | 
			
		||||
  * @param  TIMx Timer instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: invalid TIMx instance
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_TIM_DeInit(TIM_TypeDef* TIMx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus result = SUCCESS;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_INSTANCE(TIMx)); 
 | 
			
		||||
 | 
			
		||||
if (TIMx == TIM2) 
 | 
			
		||||
  {     
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM2);
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM2);
 | 
			
		||||
  }
 | 
			
		||||
#if defined(TIM3)  
 | 
			
		||||
  else if (TIMx == TIM3)
 | 
			
		||||
  { 
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM3);
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM3);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* TIM3 */
 | 
			
		||||
#if defined(TIM6)  
 | 
			
		||||
  else if (TIMx == TIM6)
 | 
			
		||||
  { 
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM6);
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM6);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* TIM6 */
 | 
			
		||||
#if defined(TIM7)  
 | 
			
		||||
  else if (TIMx == TIM7)
 | 
			
		||||
  { 
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_TIM7);
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_TIM7);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* TIM7 */
 | 
			
		||||
  else if (TIMx == TIM21)
 | 
			
		||||
  { 
 | 
			
		||||
    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM21);
 | 
			
		||||
    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM21);
 | 
			
		||||
  }
 | 
			
		||||
#if defined(TIM22)  
 | 
			
		||||
  else if (TIMx == TIM22)
 | 
			
		||||
  { 
 | 
			
		||||
    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_TIM22);
 | 
			
		||||
    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_TIM22);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* TIM22 */
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    result = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the fields of the time base unit configuration data structure
 | 
			
		||||
  *         to their default values.
 | 
			
		||||
  * @param  TIM_InitStruct pointer to a @ref LL_TIM_InitTypeDef structure (time base unit configuration data structure)
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_TIM_StructInit(LL_TIM_InitTypeDef* TIM_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set the default configuration */
 | 
			
		||||
  TIM_InitStruct->Prescaler         = (uint16_t)0x0000U;
 | 
			
		||||
  TIM_InitStruct->CounterMode       = LL_TIM_COUNTERMODE_UP;
 | 
			
		||||
  TIM_InitStruct->Autoreload        = (uint32_t)0xFFFFFFFFU;
 | 
			
		||||
  TIM_InitStruct->ClockDivision     = LL_TIM_CLOCKDIVISION_DIV1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx time base unit.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  TIM_InitStruct pointer to a @ref LL_TIM_InitTypeDef structure (TIMx time base unit configuration data structure)
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_TIM_Init(TIM_TypeDef * TIMx, LL_TIM_InitTypeDef* TIM_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  uint16_t tmpcr1 = 0U;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_INSTANCE(TIMx)); 
 | 
			
		||||
  assert_param(IS_LL_TIM_COUNTERMODE(TIM_InitStruct->CounterMode));
 | 
			
		||||
  assert_param(IS_LL_TIM_CLOCKDIVISION(TIM_InitStruct->ClockDivision));
 | 
			
		||||
 | 
			
		||||
  tmpcr1 = LL_TIM_ReadReg(TIMx, CR1);  
 | 
			
		||||
 | 
			
		||||
  if(IS_TIM_COUNTER_MODE_SELECT_INSTANCE(TIMx)) 
 | 
			
		||||
  {
 | 
			
		||||
    /* Select the Counter Mode */
 | 
			
		||||
    tmpcr1 &= (uint16_t)(~(TIM_CR1_DIR | TIM_CR1_CMS));
 | 
			
		||||
    tmpcr1 |= (uint32_t)TIM_InitStruct->CounterMode;
 | 
			
		||||
  }
 | 
			
		||||
 
 | 
			
		||||
  if(IS_TIM_CLOCK_DIVISION_INSTANCE(TIMx))
 | 
			
		||||
  {
 | 
			
		||||
    /* Set the clock division */
 | 
			
		||||
    tmpcr1 &=  (uint16_t)(~TIM_CR1_CKD);
 | 
			
		||||
    tmpcr1 |= (uint32_t)TIM_InitStruct->ClockDivision;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Write to TIMx CR1 */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CR1, tmpcr1);
 | 
			
		||||
 | 
			
		||||
  /* Set the Autoreload value */
 | 
			
		||||
  LL_TIM_SetAutoReload(TIMx, TIM_InitStruct->Autoreload);
 | 
			
		||||
 
 | 
			
		||||
  /* Set the Prescaler value */
 | 
			
		||||
  LL_TIM_SetPrescaler(TIMx, TIM_InitStruct->Prescaler);
 | 
			
		||||
  /* Generate an update event to reload the Prescaler 
 | 
			
		||||
     and the repetition counter value (if applicable) immediately */
 | 
			
		||||
  LL_TIM_GenerateEvent_UPDATE(TIMx);
 | 
			
		||||
  
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the fields of the TIMx output channel configuration data 
 | 
			
		||||
  *         structure to their default values.
 | 
			
		||||
  * @param  TIM_OC_InitStruct pointer to a @ref LL_TIM_OC_InitTypeDef structure (the output channel configuration data structure)
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_TIM_OC_StructInit(LL_TIM_OC_InitTypeDef* TIM_OC_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set the default configuration */
 | 
			
		||||
  TIM_OC_InitStruct->OCMode       = LL_TIM_OCMODE_FROZEN;
 | 
			
		||||
  TIM_OC_InitStruct->OCState      = LL_TIM_OCSTATE_DISABLE;
 | 
			
		||||
  TIM_OC_InitStruct->CompareValue = (uint32_t)0x00000000U;
 | 
			
		||||
  TIM_OC_InitStruct->OCPolarity   = LL_TIM_OCPOLARITY_HIGH;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx output channel.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  Channel This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_TIM_CHANNEL_CH1
 | 
			
		||||
  *         @arg @ref LL_TIM_CHANNEL_CH2
 | 
			
		||||
  *         @arg @ref LL_TIM_CHANNEL_CH3
 | 
			
		||||
  *         @arg @ref LL_TIM_CHANNEL_CH4
 | 
			
		||||
  * @param  TIM_OC_InitStruct pointer to a @ref LL_TIM_OC_InitTypeDef structure (TIMx output channel configuration data structure)
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx output channel is initialized
 | 
			
		||||
  *          - ERROR: TIMx output channel is not initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_TIM_OC_Init(TIM_TypeDef* TIMx, uint32_t Channel, LL_TIM_OC_InitTypeDef* TIM_OC_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus result = ERROR;
 | 
			
		||||
   
 | 
			
		||||
  switch(Channel)
 | 
			
		||||
  {
 | 
			
		||||
  case LL_TIM_CHANNEL_CH1:
 | 
			
		||||
    result = OC1Config(TIMx, TIM_OC_InitStruct);
 | 
			
		||||
    break;
 | 
			
		||||
  case LL_TIM_CHANNEL_CH2:
 | 
			
		||||
    result = OC2Config(TIMx, TIM_OC_InitStruct);
 | 
			
		||||
    break;
 | 
			
		||||
  case LL_TIM_CHANNEL_CH3:
 | 
			
		||||
    result = OC3Config(TIMx, TIM_OC_InitStruct);
 | 
			
		||||
    break;
 | 
			
		||||
  case LL_TIM_CHANNEL_CH4:
 | 
			
		||||
    result = OC4Config(TIMx, TIM_OC_InitStruct);
 | 
			
		||||
    break;
 | 
			
		||||
  default:
 | 
			
		||||
    break;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the fields of the TIMx input channel configuration data 
 | 
			
		||||
  *         structure to their default values.
 | 
			
		||||
  * @param  TIM_ICInitStruct pointer to a @ref LL_TIM_IC_InitTypeDef structure (the input channel configuration data structure)
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_TIM_IC_StructInit(LL_TIM_IC_InitTypeDef* TIM_ICInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set the default configuration */
 | 
			
		||||
  TIM_ICInitStruct->ICPolarity    = LL_TIM_IC_POLARITY_RISING;
 | 
			
		||||
  TIM_ICInitStruct->ICActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
 | 
			
		||||
  TIM_ICInitStruct->ICPrescaler   = LL_TIM_ICPSC_DIV1;
 | 
			
		||||
  TIM_ICInitStruct->ICFilter      = LL_TIM_IC_FILTER_FDIV1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx input channel.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  Channel This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_TIM_CHANNEL_CH1
 | 
			
		||||
  *         @arg @ref LL_TIM_CHANNEL_CH2
 | 
			
		||||
  *         @arg @ref LL_TIM_CHANNEL_CH3
 | 
			
		||||
  *         @arg @ref LL_TIM_CHANNEL_CH4
 | 
			
		||||
  * @param  TIM_IC_InitStruct pointer to a @ref LL_TIM_IC_InitTypeDef structure (TIMx input channel configuration data structure)
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx output channel is initialized
 | 
			
		||||
  *          - ERROR: TIMx output channel is not initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_TIM_IC_Init(TIM_TypeDef* TIMx, uint32_t Channel, LL_TIM_IC_InitTypeDef* TIM_IC_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus result = ERROR;
 | 
			
		||||
   
 | 
			
		||||
  switch(Channel)
 | 
			
		||||
  {
 | 
			
		||||
  case LL_TIM_CHANNEL_CH1:
 | 
			
		||||
    result = IC1Config(TIMx, TIM_IC_InitStruct);
 | 
			
		||||
    break;
 | 
			
		||||
  case LL_TIM_CHANNEL_CH2:
 | 
			
		||||
    result = IC2Config(TIMx, TIM_IC_InitStruct);
 | 
			
		||||
    break;
 | 
			
		||||
  case LL_TIM_CHANNEL_CH3:
 | 
			
		||||
    result = IC3Config(TIMx, TIM_IC_InitStruct);
 | 
			
		||||
    break;
 | 
			
		||||
  case LL_TIM_CHANNEL_CH4:
 | 
			
		||||
    result = IC4Config(TIMx, TIM_IC_InitStruct);
 | 
			
		||||
    break;
 | 
			
		||||
  default:
 | 
			
		||||
    break;
 | 
			
		||||
  }
 | 
			
		||||
  
 | 
			
		||||
  return result;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Fills each TIM_EncoderInitStruct field with its default value
 | 
			
		||||
  * @param  TIM_EncoderInitStruct pointer to a @ref LL_TIM_ENCODER_InitTypeDef structure (encoder interface configuration data structure)
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_TIM_ENCODER_StructInit(LL_TIM_ENCODER_InitTypeDef* TIM_EncoderInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set the default configuration */
 | 
			
		||||
  TIM_EncoderInitStruct->EncoderMode    = LL_TIM_ENCODERMODE_X2_TI1;
 | 
			
		||||
  TIM_EncoderInitStruct->IC1Polarity    = LL_TIM_IC_POLARITY_RISING;
 | 
			
		||||
  TIM_EncoderInitStruct->IC1ActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
 | 
			
		||||
  TIM_EncoderInitStruct->IC1Prescaler   = LL_TIM_ICPSC_DIV1;
 | 
			
		||||
  TIM_EncoderInitStruct->IC1Filter      = LL_TIM_IC_FILTER_FDIV1;
 | 
			
		||||
  TIM_EncoderInitStruct->IC2Polarity    = LL_TIM_IC_POLARITY_RISING;
 | 
			
		||||
  TIM_EncoderInitStruct->IC2ActiveInput = LL_TIM_ACTIVEINPUT_DIRECTTI;
 | 
			
		||||
  TIM_EncoderInitStruct->IC2Prescaler   = LL_TIM_ICPSC_DIV1;
 | 
			
		||||
  TIM_EncoderInitStruct->IC2Filter      = LL_TIM_IC_FILTER_FDIV1;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the encoder interface of the timer instance.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  TIM_EncoderInitStruct pointer to a @ref LL_TIM_ENCODER_InitTypeDef structure (TIMx encoder interface configuration data structure)
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_TIM_ENCODER_Init(TIM_TypeDef* TIMx, LL_TIM_ENCODER_InitTypeDef* TIM_EncoderInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t tmpccmr1 = 0U;
 | 
			
		||||
  uint32_t tmpccer = 0U;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_ENCODER_INTERFACE_INSTANCE(TIMx));
 | 
			
		||||
  assert_param(IS_LL_TIM_ENCODERMODE(TIM_EncoderInitStruct->EncoderMode));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_EncoderInitStruct->IC1Polarity));
 | 
			
		||||
  assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_EncoderInitStruct->IC1ActiveInput));
 | 
			
		||||
  assert_param(IS_LL_TIM_ICPSC(TIM_EncoderInitStruct->IC1Prescaler));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_FILTER(TIM_EncoderInitStruct->IC1Filter));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_POLARITY_ENCODER(TIM_EncoderInitStruct->IC2Polarity));
 | 
			
		||||
  assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_EncoderInitStruct->IC2ActiveInput));
 | 
			
		||||
  assert_param(IS_LL_TIM_ICPSC(TIM_EncoderInitStruct->IC2Prescaler));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_FILTER(TIM_EncoderInitStruct->IC2Filter));
 | 
			
		||||
  
 | 
			
		||||
  /* Disable the CC1 and CC2: Reset the CC1E and CC2E Bits */
 | 
			
		||||
  TIMx->CCER &= (uint32_t)~(TIM_CCER_CC1E | TIM_CCER_CC2E);
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CCMR1 register value */
 | 
			
		||||
  tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1);
 | 
			
		||||
 | 
			
		||||
  /* Get the TIMx CCER register value */
 | 
			
		||||
  tmpccer = LL_TIM_ReadReg(TIMx, CCER);  
 | 
			
		||||
 | 
			
		||||
  /* Configure TI1 */
 | 
			
		||||
  tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC1S | TIM_CCMR1_IC1F  | TIM_CCMR1_IC1PSC);
 | 
			
		||||
  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1ActiveInput >> 16U);
 | 
			
		||||
  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1Filter >> 16U);
 | 
			
		||||
  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC1Prescaler >> 16U);
 | 
			
		||||
  
 | 
			
		||||
  /* Configure TI2 */
 | 
			
		||||
  tmpccmr1 &= (uint32_t)~(TIM_CCMR1_CC2S | TIM_CCMR1_IC2F  | TIM_CCMR1_IC2PSC);
 | 
			
		||||
  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2ActiveInput >> 8U);
 | 
			
		||||
  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2Filter >> 8U);
 | 
			
		||||
  tmpccmr1 |= (uint32_t)(TIM_EncoderInitStruct->IC2Prescaler >> 8U);
 | 
			
		||||
  
 | 
			
		||||
  /* Set TI1 and TI2 polarity and enable TI1 and TI2 */
 | 
			
		||||
  tmpccer &= (uint32_t)~(TIM_CCER_CC1P | TIM_CCER_CC1NP | TIM_CCER_CC2P | TIM_CCER_CC2NP);
 | 
			
		||||
  tmpccer |= (uint32_t)(TIM_EncoderInitStruct->IC1Polarity);
 | 
			
		||||
  tmpccer |= (uint32_t)(TIM_EncoderInitStruct->IC2Polarity << 4U);
 | 
			
		||||
  tmpccer |= (uint32_t)(TIM_CCER_CC1E | TIM_CCER_CC2E);
 | 
			
		||||
 | 
			
		||||
  /* Set encoder mode */  
 | 
			
		||||
  LL_TIM_SetEncoderMode(TIMx, TIM_EncoderInitStruct->EncoderMode);
 | 
			
		||||
    
 | 
			
		||||
  /* Write to TIMx CCMR1 */  
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1);
 | 
			
		||||
    
 | 
			
		||||
  /* Write to TIMx CCER */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CCER, tmpccer);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup TIM_LL_Private_Functions TIM Private Functions
 | 
			
		||||
 *  @brief   Private functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx output channel 1.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  TIM_OCInitStruct pointer to the the TIMx output channel 1 configuration data structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
static ErrorStatus OC1Config(TIM_TypeDef* TIMx, LL_TIM_OC_InitTypeDef* TIM_OCInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t tmpccmr1 = 0U;
 | 
			
		||||
  uint32_t tmpccer = 0U;
 | 
			
		||||
  uint32_t tmpcr2 = 0U;
 | 
			
		||||
   
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_CC1_INSTANCE(TIMx)); 
 | 
			
		||||
  assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode));
 | 
			
		||||
  assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState));
 | 
			
		||||
  assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity));   
 | 
			
		||||
 | 
			
		||||
  /* Disable the Channel 1: Reset the CC1E Bit */
 | 
			
		||||
  CLEAR_BIT(TIMx->CCER, TIM_CCER_CC1E);
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CCER register value */
 | 
			
		||||
  tmpccer = LL_TIM_ReadReg(TIMx, CCER);  
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CR2 register value */
 | 
			
		||||
  tmpcr2 = LL_TIM_ReadReg(TIMx, CR2);  
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CCMR1 register value */
 | 
			
		||||
  tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1);
 | 
			
		||||
    
 | 
			
		||||
  /* Reset Capture/Compare selection Bits */
 | 
			
		||||
  CLEAR_BIT(tmpccmr1, TIM_CCMR1_CC1S);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Output Compare Mode */
 | 
			
		||||
  MODIFY_REG(tmpccmr1, TIM_CCMR1_OC1M, TIM_OCInitStruct->OCMode);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Output Compare Polarity */
 | 
			
		||||
  MODIFY_REG(tmpccer, TIM_CCER_CC1P, TIM_OCInitStruct->OCPolarity);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Output State */
 | 
			
		||||
  MODIFY_REG(tmpccer, TIM_CCER_CC1E, TIM_OCInitStruct->OCState);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CR2 */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CR2, tmpcr2);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CCMR1 */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Capture Compare Register value */
 | 
			
		||||
  LL_TIM_OC_SetCompareCH1(TIMx, TIM_OCInitStruct->CompareValue);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CCER */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CCER, tmpccer);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx output channel 2.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  TIM_OCInitStruct pointer to the the TIMx output channel 2 configuration data structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
static ErrorStatus OC2Config(TIM_TypeDef* TIMx, LL_TIM_OC_InitTypeDef* TIM_OCInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t tmpccmr1 = 0U;
 | 
			
		||||
  uint32_t tmpccer = 0U;
 | 
			
		||||
  uint32_t tmpcr2 = 0U;
 | 
			
		||||
   
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_CC2_INSTANCE(TIMx)); 
 | 
			
		||||
  assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode));
 | 
			
		||||
  assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState));
 | 
			
		||||
  assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity));   
 | 
			
		||||
 | 
			
		||||
  /* Disable the Channel 2: Reset the CC2E Bit */
 | 
			
		||||
  CLEAR_BIT(TIMx->CCER, TIM_CCER_CC2E);
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CCER register value */  
 | 
			
		||||
  tmpccer =  LL_TIM_ReadReg(TIMx, CCER);  
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CR2 register value */
 | 
			
		||||
  tmpcr2 = LL_TIM_ReadReg(TIMx, CR2);  
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CCMR1 register value */
 | 
			
		||||
  tmpccmr1 = LL_TIM_ReadReg(TIMx, CCMR1);
 | 
			
		||||
    
 | 
			
		||||
  /* Reset Capture/Compare selection Bits */
 | 
			
		||||
  CLEAR_BIT(tmpccmr1, TIM_CCMR1_CC2S);
 | 
			
		||||
  
 | 
			
		||||
  /* Select the Output Compare Mode */
 | 
			
		||||
  MODIFY_REG(tmpccmr1, TIM_CCMR1_OC2M, TIM_OCInitStruct->OCMode << 8U);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Output Compare Polarity */
 | 
			
		||||
  MODIFY_REG(tmpccer, TIM_CCER_CC2P, TIM_OCInitStruct->OCPolarity<< 4U);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Output State */
 | 
			
		||||
  MODIFY_REG(tmpccer, TIM_CCER_CC2E, TIM_OCInitStruct->OCState << 4U);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CR2 */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CR2, tmpcr2);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CCMR1 */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CCMR1, tmpccmr1);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Capture Compare Register value */
 | 
			
		||||
  LL_TIM_OC_SetCompareCH2(TIMx, TIM_OCInitStruct->CompareValue);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CCER */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CCER, tmpccer);
 | 
			
		||||
  
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx output channel 3.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  TIM_OCInitStruct pointer to the the TIMx output channel 3 configuration data structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
static ErrorStatus OC3Config(TIM_TypeDef* TIMx, LL_TIM_OC_InitTypeDef* TIM_OCInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t tmpccmr2 = 0U;
 | 
			
		||||
  uint32_t tmpccer = 0U;
 | 
			
		||||
  uint32_t tmpcr2 = 0U;
 | 
			
		||||
   
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_CC3_INSTANCE(TIMx)); 
 | 
			
		||||
  assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode));
 | 
			
		||||
  assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState));
 | 
			
		||||
  assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity));   
 | 
			
		||||
 | 
			
		||||
  /* Disable the Channel 3: Reset the CC3E Bit */
 | 
			
		||||
  CLEAR_BIT(TIMx->CCER, TIM_CCER_CC3E);
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CCER register value */
 | 
			
		||||
  tmpccer =  LL_TIM_ReadReg(TIMx, CCER);  
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CR2 register value */
 | 
			
		||||
  tmpcr2 = LL_TIM_ReadReg(TIMx, CR2);  
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CCMR2 register value */
 | 
			
		||||
  tmpccmr2 = LL_TIM_ReadReg(TIMx, CCMR2);
 | 
			
		||||
    
 | 
			
		||||
  /* Reset Capture/Compare selection Bits */
 | 
			
		||||
  CLEAR_BIT(tmpccmr2, TIM_CCMR2_CC3S);
 | 
			
		||||
  
 | 
			
		||||
  /* Select the Output Compare Mode */
 | 
			
		||||
  MODIFY_REG(tmpccmr2, TIM_CCMR2_OC3M, TIM_OCInitStruct->OCMode);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Output Compare Polarity */
 | 
			
		||||
  MODIFY_REG(tmpccer, TIM_CCER_CC3P, TIM_OCInitStruct->OCPolarity << 8U);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Output State */
 | 
			
		||||
  MODIFY_REG(tmpccer, TIM_CCER_CC3E, TIM_OCInitStruct->OCState << 8U);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CR2 */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CR2, tmpcr2);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CCMR2 */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CCMR2, tmpccmr2);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Capture Compare Register value */
 | 
			
		||||
  LL_TIM_OC_SetCompareCH3(TIMx, TIM_OCInitStruct->CompareValue);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CCER */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CCER, tmpccer);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx output channel 4.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  TIM_OCInitStruct pointer to the the TIMx output channel 4 configuration data structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
static ErrorStatus OC4Config(TIM_TypeDef* TIMx, LL_TIM_OC_InitTypeDef* TIM_OCInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  uint32_t tmpccmr2 = 0U;
 | 
			
		||||
  uint32_t tmpccer = 0U;
 | 
			
		||||
  uint32_t tmpcr2 = 0U;
 | 
			
		||||
   
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_CC4_INSTANCE(TIMx)); 
 | 
			
		||||
  assert_param(IS_LL_TIM_OCMODE(TIM_OCInitStruct->OCMode));
 | 
			
		||||
  assert_param(IS_LL_TIM_OCSTATE(TIM_OCInitStruct->OCState));
 | 
			
		||||
  assert_param(IS_LL_TIM_OCPOLARITY(TIM_OCInitStruct->OCPolarity));   
 | 
			
		||||
 | 
			
		||||
  /* Disable the Channel 4: Reset the CC4E Bit */
 | 
			
		||||
  CLEAR_BIT(TIMx->CCER, TIM_CCER_CC4E);
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CCER register value */
 | 
			
		||||
  tmpccer = LL_TIM_ReadReg(TIMx, CCER);  
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CR2 register value */
 | 
			
		||||
  tmpcr2 =  LL_TIM_ReadReg(TIMx, CR2);  
 | 
			
		||||
  
 | 
			
		||||
  /* Get the TIMx CCMR2 register value */
 | 
			
		||||
  tmpccmr2 = LL_TIM_ReadReg(TIMx, CCMR2);
 | 
			
		||||
    
 | 
			
		||||
  /* Reset Capture/Compare selection Bits */
 | 
			
		||||
  CLEAR_BIT(tmpccmr2, TIM_CCMR2_CC4S);
 | 
			
		||||
  
 | 
			
		||||
  /* Select the Output Compare Mode */
 | 
			
		||||
  MODIFY_REG(tmpccmr2, TIM_CCMR2_OC4M, TIM_OCInitStruct->OCMode << 8U);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Output Compare Polarity */
 | 
			
		||||
  MODIFY_REG(tmpccer, TIM_CCER_CC4P, TIM_OCInitStruct->OCPolarity << 12U);
 | 
			
		||||
  
 | 
			
		||||
  /* Set the Output State */
 | 
			
		||||
  MODIFY_REG(tmpccer, TIM_CCER_CC4E, TIM_OCInitStruct->OCState << 12U);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CR2 */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CR2, tmpcr2);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CCMR2 */  
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CCMR2, tmpccmr2);
 | 
			
		||||
    
 | 
			
		||||
  /* Set the Capture Compare Register value */
 | 
			
		||||
  LL_TIM_OC_SetCompareCH4(TIMx, TIM_OCInitStruct->CompareValue);
 | 
			
		||||
  
 | 
			
		||||
  /* Write to TIMx CCER */
 | 
			
		||||
  LL_TIM_WriteReg(TIMx, CCER, tmpccer);
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx input channel 1.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  TIM_ICInitStruct pointer to the the TIMx input channel 1 configuration data structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
static ErrorStatus IC1Config(TIM_TypeDef* TIMx, LL_TIM_IC_InitTypeDef* TIM_ICInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_CC1_INSTANCE(TIMx));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity));
 | 
			
		||||
  assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput));
 | 
			
		||||
  assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter));
 | 
			
		||||
  
 | 
			
		||||
  /* Disable the Channel 1: Reset the CC1E Bit */
 | 
			
		||||
  TIMx->CCER &= (uint32_t)~TIM_CCER_CC1E;
 | 
			
		||||
  
 | 
			
		||||
  /* Select the Input and set the filter and the prescaler value */
 | 
			
		||||
  MODIFY_REG(TIMx->CCMR1, 
 | 
			
		||||
             (TIM_CCMR1_CC1S | TIM_CCMR1_IC1F | TIM_CCMR1_IC1PSC),
 | 
			
		||||
             (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 16U);
 | 
			
		||||
 | 
			
		||||
  /* Select the Polarity and set the CC1E Bit */
 | 
			
		||||
  MODIFY_REG(TIMx->CCER, 
 | 
			
		||||
             (TIM_CCER_CC1P | TIM_CCER_CC1NP),
 | 
			
		||||
             (TIM_ICInitStruct->ICPolarity | TIM_CCER_CC1E));
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx input channel 2.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  TIM_ICInitStruct pointer to the the TIMx input channel 2 configuration data structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
static ErrorStatus IC2Config(TIM_TypeDef* TIMx, LL_TIM_IC_InitTypeDef* TIM_ICInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_CC2_INSTANCE(TIMx));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity));
 | 
			
		||||
  assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput));
 | 
			
		||||
  assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter));
 | 
			
		||||
  
 | 
			
		||||
  /* Disable the Channel 2: Reset the CC2E Bit */
 | 
			
		||||
  TIMx->CCER &= (uint32_t)~TIM_CCER_CC2E;
 | 
			
		||||
  
 | 
			
		||||
  /* Select the Input and set the filter and the prescaler value */
 | 
			
		||||
  MODIFY_REG(TIMx->CCMR1, 
 | 
			
		||||
             (TIM_CCMR1_CC2S | TIM_CCMR1_IC2F | TIM_CCMR1_IC2PSC),
 | 
			
		||||
             (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 8U);
 | 
			
		||||
 | 
			
		||||
  /* Select the Polarity and set the CC2E Bit */
 | 
			
		||||
  MODIFY_REG(TIMx->CCER, 
 | 
			
		||||
             (TIM_CCER_CC2P | TIM_CCER_CC2NP),
 | 
			
		||||
             ((TIM_ICInitStruct->ICPolarity << 4U) | TIM_CCER_CC2E) );
 | 
			
		||||
  
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx input channel 3.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  TIM_ICInitStruct pointer to the the TIMx input channel 3 configuration data structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
static ErrorStatus IC3Config(TIM_TypeDef* TIMx, LL_TIM_IC_InitTypeDef* TIM_ICInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_CC3_INSTANCE(TIMx));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity));
 | 
			
		||||
  assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput));
 | 
			
		||||
  assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter));
 | 
			
		||||
  
 | 
			
		||||
  /* Disable the Channel 3: Reset the CC3E Bit */
 | 
			
		||||
  TIMx->CCER &= (uint32_t)~TIM_CCER_CC3E;
 | 
			
		||||
  
 | 
			
		||||
  /* Select the Input and set the filter and the prescaler value */
 | 
			
		||||
  MODIFY_REG(TIMx->CCMR2, 
 | 
			
		||||
             (TIM_CCMR2_CC3S | TIM_CCMR2_IC3F | TIM_CCMR2_IC3PSC),
 | 
			
		||||
             (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 16U);
 | 
			
		||||
 | 
			
		||||
  /* Select the Polarity and set the CC3E Bit */
 | 
			
		||||
  MODIFY_REG(TIMx->CCER, 
 | 
			
		||||
             (TIM_CCER_CC3P | TIM_CCER_CC3NP),
 | 
			
		||||
             ((TIM_ICInitStruct->ICPolarity << 8U) | TIM_CCER_CC3E) );
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Configure the TIMx input channel 4.
 | 
			
		||||
  * @param  TIMx Timer Instance
 | 
			
		||||
  * @param  TIM_ICInitStruct pointer to the the TIMx input channel 4 configuration data structure
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: TIMx registers are de-initialized
 | 
			
		||||
  *          - ERROR: not applicable
 | 
			
		||||
  */
 | 
			
		||||
static ErrorStatus IC4Config(TIM_TypeDef* TIMx, LL_TIM_IC_InitTypeDef* TIM_ICInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_TIM_CC4_INSTANCE(TIMx));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_POLARITY(TIM_ICInitStruct->ICPolarity));
 | 
			
		||||
  assert_param(IS_LL_TIM_ACTIVEINPUT(TIM_ICInitStruct->ICActiveInput));
 | 
			
		||||
  assert_param(IS_LL_TIM_ICPSC(TIM_ICInitStruct->ICPrescaler));
 | 
			
		||||
  assert_param(IS_LL_TIM_IC_FILTER(TIM_ICInitStruct->ICFilter));
 | 
			
		||||
  
 | 
			
		||||
  /* Disable the Channel 4: Reset the CC4E Bit */
 | 
			
		||||
  TIMx->CCER &= (uint32_t)~TIM_CCER_CC4E;
 | 
			
		||||
  
 | 
			
		||||
  /* Select the Input and set the filter and the prescaler value */
 | 
			
		||||
  MODIFY_REG(TIMx->CCMR2, 
 | 
			
		||||
             (TIM_CCMR2_CC4S | TIM_CCMR2_IC4F | TIM_CCMR2_IC4PSC),
 | 
			
		||||
             (TIM_ICInitStruct->ICActiveInput | TIM_ICInitStruct->ICFilter | TIM_ICInitStruct->ICPrescaler) >> 8U);
 | 
			
		||||
 | 
			
		||||
  /* Select the Polarity and set the CC2E Bit */
 | 
			
		||||
  MODIFY_REG(TIMx->CCER, 
 | 
			
		||||
             (TIM_CCER_CC4P | TIM_CCER_CC4NP),
 | 
			
		||||
             ((TIM_ICInitStruct->ICPolarity << 12U) | TIM_CCER_CC4E) );
 | 
			
		||||
 | 
			
		||||
  return SUCCESS;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* TIM1 || TIM3 || TIM21 || TIM22 || TIM6 || TIM7 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
  
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,435 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_usart.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   USART LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
#if defined(USE_FULL_LL_DRIVER)
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_usart.h"
 | 
			
		||||
#include "stm32l0xx_ll_rcc.h"
 | 
			
		||||
#include "stm32l0xx_ll_bus.h"
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (USART1) || defined (USART2) || defined (USART4) || defined (USART5)
 | 
			
		||||
 | 
			
		||||
/** @addtogroup USART_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup USART_LL_Private_Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup USART_LL_Private_Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* __BAUDRATE__ The maximum Baud Rate is derived from the maximum clock available
 | 
			
		||||
 *              divided by the smallest oversampling used on the USART (i.e. 8)    */
 | 
			
		||||
#define IS_LL_USART_BAUDRATE(__BAUDRATE__) ((__BAUDRATE__) <= 4000000U)
 | 
			
		||||
 | 
			
		||||
#define IS_LL_USART_DIRECTION(__VALUE__) (((__VALUE__) == LL_USART_DIRECTION_NONE) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_USART_DIRECTION_RX) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_USART_DIRECTION_TX) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_USART_DIRECTION_TX_RX))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_USART_PARITY(__VALUE__) (((__VALUE__) == LL_USART_PARITY_NONE) \
 | 
			
		||||
                                    || ((__VALUE__) == LL_USART_PARITY_EVEN) \
 | 
			
		||||
                                    || ((__VALUE__) == LL_USART_PARITY_ODD))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_USART_DATAWIDTH(__VALUE__) (((__VALUE__) == LL_USART_DATAWIDTH_7B) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_USART_DATAWIDTH_8B) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_USART_DATAWIDTH_9B))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_USART_OVERSAMPLING(__VALUE__) (((__VALUE__) == LL_USART_OVERSAMPLING_16) \
 | 
			
		||||
                                          || ((__VALUE__) == LL_USART_OVERSAMPLING_8))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_USART_LASTBITCLKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_LASTCLKPULSE_NO_OUTPUT) \
 | 
			
		||||
                                              || ((__VALUE__) == LL_USART_LASTCLKPULSE_OUTPUT))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_USART_CLOCKPHASE(__VALUE__) (((__VALUE__) == LL_USART_PHASE_1EDGE) \
 | 
			
		||||
                                        || ((__VALUE__) == LL_USART_PHASE_2EDGE))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_USART_CLOCKPOLARITY(__VALUE__) (((__VALUE__) == LL_USART_POLARITY_LOW) \
 | 
			
		||||
                                           || ((__VALUE__) == LL_USART_POLARITY_HIGH))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_USART_CLOCKOUTPUT(__VALUE__) (((__VALUE__) == LL_USART_CLOCK_DISABLE) \
 | 
			
		||||
                                         || ((__VALUE__) == LL_USART_CLOCK_ENABLE))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_USART_STOPBITS(__VALUE__) (((__VALUE__) == LL_USART_STOPBITS_0_5) \
 | 
			
		||||
                                      || ((__VALUE__) == LL_USART_STOPBITS_1) \
 | 
			
		||||
                                      || ((__VALUE__) == LL_USART_STOPBITS_1_5) \
 | 
			
		||||
                                      || ((__VALUE__) == LL_USART_STOPBITS_2))
 | 
			
		||||
 | 
			
		||||
#define IS_LL_USART_HWCONTROL(__VALUE__) (((__VALUE__) == LL_USART_HWCONTROL_NONE) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_USART_HWCONTROL_RTS) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_USART_HWCONTROL_CTS) \
 | 
			
		||||
                                       || ((__VALUE__) == LL_USART_HWCONTROL_RTS_CTS))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private function prototypes -----------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup USART_LL_Exported_Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup USART_LL_EF_Init
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  De-initialize USART registers (Registers restored to their default values).
 | 
			
		||||
  * @param  USARTx USART Instance
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: USART registers are de-initialized
 | 
			
		||||
  *          - ERROR: USART registers are not de-initialized
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_USART_DeInit(USART_TypeDef *USARTx)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_UART_INSTANCE(USARTx));
 | 
			
		||||
 | 
			
		||||
#if defined(USART1)
 | 
			
		||||
  if (USARTx == USART1)
 | 
			
		||||
  {
 | 
			
		||||
    /* Force reset of USART clock */
 | 
			
		||||
    LL_APB2_GRP1_ForceReset(LL_APB2_GRP1_PERIPH_USART1);
 | 
			
		||||
 | 
			
		||||
    /* Release reset of USART clock */
 | 
			
		||||
    LL_APB2_GRP1_ReleaseReset(LL_APB2_GRP1_PERIPH_USART1);
 | 
			
		||||
  }
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(USART1)
 | 
			
		||||
  else if (USARTx == USART2)
 | 
			
		||||
#else
 | 
			
		||||
  if (USARTx == USART2)
 | 
			
		||||
#endif
 | 
			
		||||
  {
 | 
			
		||||
    /* Force reset of USART clock */
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART2);
 | 
			
		||||
 | 
			
		||||
    /* Release reset of USART clock */
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART2);
 | 
			
		||||
  }
 | 
			
		||||
#if defined(USART4)
 | 
			
		||||
  else if (USARTx == USART4)
 | 
			
		||||
  {
 | 
			
		||||
    /* Force reset of USART clock */
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART4);
 | 
			
		||||
 | 
			
		||||
    /* Release reset of USART clock */
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART4);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* USART4 */
 | 
			
		||||
#if defined(USART5)
 | 
			
		||||
  else if (USARTx == USART5)
 | 
			
		||||
  {
 | 
			
		||||
    /* Force reset of USART clock */
 | 
			
		||||
    LL_APB1_GRP1_ForceReset(LL_APB1_GRP1_PERIPH_USART5);
 | 
			
		||||
 | 
			
		||||
    /* Release reset of USART clock */
 | 
			
		||||
    LL_APB1_GRP1_ReleaseReset(LL_APB1_GRP1_PERIPH_USART5);
 | 
			
		||||
  }
 | 
			
		||||
#endif /* USART5 */
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return (status);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize USART registers according to the specified
 | 
			
		||||
  *         parameters in USART_InitStruct.
 | 
			
		||||
  * @note   As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0),
 | 
			
		||||
  *         USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
 | 
			
		||||
  * @note   Baud rate value stored in USART_InitStruct BaudRate field, should be valid (different from 0).
 | 
			
		||||
  * @param  USARTx USART Instance
 | 
			
		||||
  * @param  USART_InitStruct: pointer to a LL_USART_InitTypeDef structure
 | 
			
		||||
  *         that contains the configuration information for the specified USART peripheral.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: USART registers are initialized according to USART_InitStruct content
 | 
			
		||||
  *          - ERROR: Problem occurred during USART Registers initialization
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_USART_Init(USART_TypeDef *USARTx, LL_USART_InitTypeDef *USART_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = ERROR;
 | 
			
		||||
  uint32_t periphclk = LL_RCC_PERIPH_FREQUENCY_NO;
 | 
			
		||||
#if (defined(USART4) || defined(USART5))
 | 
			
		||||
  LL_RCC_ClocksTypeDef RCC_Clocks;
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
  /* Check the parameters */
 | 
			
		||||
  assert_param(IS_UART_INSTANCE(USARTx));
 | 
			
		||||
  assert_param(IS_LL_USART_BAUDRATE(USART_InitStruct->BaudRate));
 | 
			
		||||
  assert_param(IS_LL_USART_DATAWIDTH(USART_InitStruct->DataWidth));
 | 
			
		||||
  assert_param(IS_LL_USART_STOPBITS(USART_InitStruct->StopBits));
 | 
			
		||||
  assert_param(IS_LL_USART_PARITY(USART_InitStruct->Parity));
 | 
			
		||||
  assert_param(IS_LL_USART_DIRECTION(USART_InitStruct->TransferDirection));
 | 
			
		||||
  assert_param(IS_LL_USART_HWCONTROL(USART_InitStruct->HardwareFlowControl));
 | 
			
		||||
  assert_param(IS_LL_USART_OVERSAMPLING(USART_InitStruct->OverSampling));
 | 
			
		||||
 | 
			
		||||
  /* USART needs to be in disabled state, in order to be able to configure some bits in
 | 
			
		||||
     CRx registers */
 | 
			
		||||
  if (LL_USART_IsEnabled(USARTx) == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    /*---------------------------- USART CR1 Configuration -----------------------
 | 
			
		||||
     * Configure USARTx CR1 (USART Word Length, Parity, Mode and Oversampling bits) with parameters:
 | 
			
		||||
     * - DataWidth:          USART_CR1_M bits according to USART_InitStruct->DataWidth value
 | 
			
		||||
     * - Parity:             USART_CR1_PCE, USART_CR1_PS bits according to USART_InitStruct->Parity value
 | 
			
		||||
     * - TransferDirection:  USART_CR1_TE, USART_CR1_RE bits according to USART_InitStruct->TransferDirection value
 | 
			
		||||
     * - Oversampling:       USART_CR1_OVER8 bit according to USART_InitStruct->OverSampling value.
 | 
			
		||||
     */
 | 
			
		||||
    MODIFY_REG(USARTx->CR1,
 | 
			
		||||
               (USART_CR1_M | USART_CR1_PCE | USART_CR1_PS |
 | 
			
		||||
                USART_CR1_TE | USART_CR1_RE | USART_CR1_OVER8),
 | 
			
		||||
               (USART_InitStruct->DataWidth | USART_InitStruct->Parity |
 | 
			
		||||
                USART_InitStruct->TransferDirection | USART_InitStruct->OverSampling));
 | 
			
		||||
 | 
			
		||||
    /*---------------------------- USART CR2 Configuration -----------------------
 | 
			
		||||
     * Configure USARTx CR2 (Stop bits) with parameters:
 | 
			
		||||
     * - Stop Bits:          USART_CR2_STOP bits according to USART_InitStruct->StopBits value.
 | 
			
		||||
     * - CLKEN, CPOL, CPHA and LBCL bits are to be configured using LL_USART_ClockInit().
 | 
			
		||||
     */
 | 
			
		||||
    LL_USART_SetStopBitsLength(USARTx, USART_InitStruct->StopBits);
 | 
			
		||||
 | 
			
		||||
    /*---------------------------- USART CR3 Configuration -----------------------
 | 
			
		||||
     * Configure USARTx CR3 (Hardware Flow Control) with parameters:
 | 
			
		||||
     * - HardwareFlowControl: USART_CR3_RTSE, USART_CR3_CTSE bits according to USART_InitStruct->HardwareFlowControl value.
 | 
			
		||||
     */
 | 
			
		||||
    LL_USART_SetHWFlowCtrl(USARTx, USART_InitStruct->HardwareFlowControl);
 | 
			
		||||
 | 
			
		||||
    /*---------------------------- USART BRR Configuration -----------------------
 | 
			
		||||
     * Retrieve Clock frequency used for USART Peripheral
 | 
			
		||||
     */
 | 
			
		||||
#if defined(USART1)
 | 
			
		||||
    if (USARTx == USART1)
 | 
			
		||||
    {
 | 
			
		||||
      periphclk = LL_RCC_GetUSARTClockFreq(LL_RCC_USART1_CLKSOURCE);
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(USART1)
 | 
			
		||||
    else if (USARTx == USART2)
 | 
			
		||||
#else
 | 
			
		||||
    if (USARTx == USART2)
 | 
			
		||||
#endif
 | 
			
		||||
    {
 | 
			
		||||
      periphclk = LL_RCC_GetUSARTClockFreq(LL_RCC_USART2_CLKSOURCE);
 | 
			
		||||
    }
 | 
			
		||||
#if defined(USART4)
 | 
			
		||||
    else if (USARTx == USART4)
 | 
			
		||||
    {
 | 
			
		||||
      /* USART4 clock is PCLK1 */
 | 
			
		||||
      LL_RCC_GetSystemClocksFreq(&RCC_Clocks);
 | 
			
		||||
      periphclk = RCC_Clocks.PCLK1_Frequency;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
#if defined(USART5)
 | 
			
		||||
    else if (USARTx == USART5)
 | 
			
		||||
    {
 | 
			
		||||
      /* USART5 clock is PCLK1 */
 | 
			
		||||
      LL_RCC_GetSystemClocksFreq(&RCC_Clocks);
 | 
			
		||||
      periphclk = RCC_Clocks.PCLK1_Frequency;
 | 
			
		||||
    }
 | 
			
		||||
#endif
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      /* Nothing to do, as error code is already assigned to ERROR value */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /* Configure the USART Baud Rate :
 | 
			
		||||
       - valid baud rate value (different from 0) is required
 | 
			
		||||
       - Peripheral clock as returned by RCC service, should be valid (different from 0).
 | 
			
		||||
    */
 | 
			
		||||
    if ((periphclk != LL_RCC_PERIPH_FREQUENCY_NO)
 | 
			
		||||
        && (USART_InitStruct->BaudRate != 0U))
 | 
			
		||||
    {
 | 
			
		||||
      status = SUCCESS;
 | 
			
		||||
      LL_USART_SetBaudRate(USARTx,
 | 
			
		||||
                           periphclk,
 | 
			
		||||
                           USART_InitStruct->OverSampling,
 | 
			
		||||
                           USART_InitStruct->BaudRate);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  /* Endif (=> USART not in Disabled state => return ERROR) */
 | 
			
		||||
 | 
			
		||||
  return (status);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Set each @ref LL_USART_InitTypeDef field to default value.
 | 
			
		||||
  * @param USART_InitStruct: pointer to a @ref LL_USART_InitTypeDef structure
 | 
			
		||||
  *                          whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
void LL_USART_StructInit(LL_USART_InitTypeDef *USART_InitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set USART_InitStruct fields to default values */
 | 
			
		||||
  USART_InitStruct->BaudRate            = 9600U;
 | 
			
		||||
  USART_InitStruct->DataWidth           = LL_USART_DATAWIDTH_8B;
 | 
			
		||||
  USART_InitStruct->StopBits            = LL_USART_STOPBITS_1;
 | 
			
		||||
  USART_InitStruct->Parity              = LL_USART_PARITY_NONE ;
 | 
			
		||||
  USART_InitStruct->TransferDirection   = LL_USART_DIRECTION_TX_RX;
 | 
			
		||||
  USART_InitStruct->HardwareFlowControl = LL_USART_HWCONTROL_NONE;
 | 
			
		||||
  USART_InitStruct->OverSampling        = LL_USART_OVERSAMPLING_16;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Initialize USART Clock related settings according to the
 | 
			
		||||
  *         specified parameters in the USART_ClockInitStruct.
 | 
			
		||||
  * @note   As some bits in USART configuration registers can only be written when the USART is disabled (USART_CR1_UE bit =0),
 | 
			
		||||
  *         USART IP should be in disabled state prior calling this function. Otherwise, ERROR result will be returned.
 | 
			
		||||
  * @param  USARTx USART Instance
 | 
			
		||||
  * @param  USART_ClockInitStruct: pointer to a @ref LL_USART_ClockInitTypeDef structure
 | 
			
		||||
  *         that contains the Clock configuration information for the specified USART peripheral.
 | 
			
		||||
  * @retval An ErrorStatus enumeration value:
 | 
			
		||||
  *          - SUCCESS: USART registers related to Clock settings are initialized according to USART_ClockInitStruct content
 | 
			
		||||
  *          - ERROR: Problem occurred during USART Registers initialization
 | 
			
		||||
  */
 | 
			
		||||
ErrorStatus LL_USART_ClockInit(USART_TypeDef *USARTx, LL_USART_ClockInitTypeDef *USART_ClockInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
 | 
			
		||||
  /* Check USART Instance and Clock signal output parameters */
 | 
			
		||||
  assert_param(IS_UART_INSTANCE(USARTx));
 | 
			
		||||
  assert_param(IS_LL_USART_CLOCKOUTPUT(USART_ClockInitStruct->ClockOutput));
 | 
			
		||||
 | 
			
		||||
  /* USART needs to be in disabled state, in order to be able to configure some bits in
 | 
			
		||||
     CRx registers */
 | 
			
		||||
  if (LL_USART_IsEnabled(USARTx) == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    /*---------------------------- USART CR2 Configuration -----------------------*/
 | 
			
		||||
    /* If Clock signal has to be output */
 | 
			
		||||
    if (USART_ClockInitStruct->ClockOutput == LL_USART_CLOCK_DISABLE)
 | 
			
		||||
    {
 | 
			
		||||
      /* Deactivate Clock signal delivery :
 | 
			
		||||
       * - Disable Clock Output:        USART_CR2_CLKEN cleared
 | 
			
		||||
       */
 | 
			
		||||
      LL_USART_DisableSCLKOutput(USARTx);
 | 
			
		||||
    }
 | 
			
		||||
    else
 | 
			
		||||
    {
 | 
			
		||||
      /* Ensure USART instance is USART capable */
 | 
			
		||||
      assert_param(IS_USART_INSTANCE(USARTx));
 | 
			
		||||
 | 
			
		||||
      /* Check clock related parameters */
 | 
			
		||||
      assert_param(IS_LL_USART_CLOCKPOLARITY(USART_ClockInitStruct->ClockPolarity));
 | 
			
		||||
      assert_param(IS_LL_USART_CLOCKPHASE(USART_ClockInitStruct->ClockPhase));
 | 
			
		||||
      assert_param(IS_LL_USART_LASTBITCLKOUTPUT(USART_ClockInitStruct->LastBitClockPulse));
 | 
			
		||||
 | 
			
		||||
      /*---------------------------- USART CR2 Configuration -----------------------
 | 
			
		||||
       * Configure USARTx CR2 (Clock signal related bits) with parameters:
 | 
			
		||||
       * - Enable Clock Output:         USART_CR2_CLKEN set
 | 
			
		||||
       * - Clock Polarity:              USART_CR2_CPOL bit according to USART_ClockInitStruct->ClockPolarity value
 | 
			
		||||
       * - Clock Phase:                 USART_CR2_CPHA bit according to USART_ClockInitStruct->ClockPhase value
 | 
			
		||||
       * - Last Bit Clock Pulse Output: USART_CR2_LBCL bit according to USART_ClockInitStruct->LastBitClockPulse value.
 | 
			
		||||
       */
 | 
			
		||||
      MODIFY_REG(USARTx->CR2,
 | 
			
		||||
                 USART_CR2_CLKEN | USART_CR2_CPHA | USART_CR2_CPOL | USART_CR2_LBCL,
 | 
			
		||||
                 USART_CR2_CLKEN | USART_ClockInitStruct->ClockPolarity |
 | 
			
		||||
                 USART_ClockInitStruct->ClockPhase | USART_ClockInitStruct->LastBitClockPulse);
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
  /* Else (USART not in Disabled state => return ERROR */
 | 
			
		||||
  else
 | 
			
		||||
  {
 | 
			
		||||
    status = ERROR;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return (status);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief Set each field of a @ref LL_USART_ClockInitTypeDef type structure to default value.
 | 
			
		||||
  * @param USART_ClockInitStruct: pointer to a @ref LL_USART_ClockInitTypeDef structure
 | 
			
		||||
  *                               whose fields will be set to default values.
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
void LL_USART_ClockStructInit(LL_USART_ClockInitTypeDef *USART_ClockInitStruct)
 | 
			
		||||
{
 | 
			
		||||
  /* Set LL_USART_ClockInitStruct fields with default values */
 | 
			
		||||
  USART_ClockInitStruct->ClockOutput       = LL_USART_CLOCK_DISABLE;
 | 
			
		||||
  USART_ClockInitStruct->ClockPolarity     = LL_USART_POLARITY_LOW;            /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
 | 
			
		||||
  USART_ClockInitStruct->ClockPhase        = LL_USART_PHASE_1EDGE;             /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
 | 
			
		||||
  USART_ClockInitStruct->LastBitClockPulse = LL_USART_LASTCLKPULSE_NO_OUTPUT;  /* Not relevant when ClockOutput = LL_USART_CLOCK_DISABLE */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USART1 || USART2 || USART4 || USART5 */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* USE_FULL_LL_DRIVER */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
 | 
			
		||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							| 
						 | 
				
			
			@ -0,0 +1,582 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_utils.c
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   UTILS LL module driver.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx_ll_rcc.h"
 | 
			
		||||
#include "stm32l0xx_ll_utils.h"
 | 
			
		||||
#include "stm32l0xx_ll_system.h"
 | 
			
		||||
#include "stm32l0xx_ll_pwr.h"
 | 
			
		||||
#ifdef  USE_FULL_ASSERT
 | 
			
		||||
#include "stm32_assert.h"
 | 
			
		||||
#else
 | 
			
		||||
#define assert_param(expr) ((void)0U)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @addtogroup UTILS_LL
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @addtogroup UTILS_LL_Private_Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define UTILS_MAX_FREQUENCY_SCALE1  ((uint32_t)32000000U)        /*!< Maximum frequency for system clock at power scale1, in Hz */
 | 
			
		||||
#define UTILS_MAX_FREQUENCY_SCALE2  ((uint32_t)16000000U)        /*!< Maximum frequency for system clock at power scale2, in Hz */
 | 
			
		||||
#define UTILS_MAX_FREQUENCY_SCALE3  ((uint32_t)4000000U)         /*!< Maximum frequency for system clock at power scale3, in Hz */
 | 
			
		||||
 | 
			
		||||
/* Defines used for PLL range */
 | 
			
		||||
#define UTILS_PLLVCO_OUTPUT_SCALE1  ((uint32_t)96000000U)        /*!< Frequency max for PLLVCO output at power scale1, in Hz  */
 | 
			
		||||
#define UTILS_PLLVCO_OUTPUT_SCALE2  ((uint32_t)48000000U)        /*!< Frequency max for PLLVCO output at power scale2, in Hz  */
 | 
			
		||||
#define UTILS_PLLVCO_OUTPUT_SCALE3  ((uint32_t)24000000U)        /*!< Frequency max for PLLVCO output at power scale3, in Hz  */
 | 
			
		||||
 | 
			
		||||
/* Defines used for HSE range */
 | 
			
		||||
#define UTILS_HSE_FREQUENCY_MIN     ((uint32_t)1000000U)         /*!< Frequency min for HSE frequency, in Hz   */
 | 
			
		||||
#define UTILS_HSE_FREQUENCY_MAX     ((uint32_t)24000000U)        /*!< Frequency max for HSE frequency, in Hz   */
 | 
			
		||||
 | 
			
		||||
/* Defines used for FLASH latency according to HCLK Frequency */
 | 
			
		||||
#define UTILS_SCALE1_LATENCY1_FREQ  ((uint32_t)16000000U)        /*!< HCLK frequency to set FLASH latency 1 in power scale 1 */
 | 
			
		||||
#define UTILS_SCALE2_LATENCY1_FREQ  ((uint32_t)8000000U)         /*!< HCLK frequency to set FLASH latency 1 in power scale 2 */
 | 
			
		||||
#define UTILS_SCALE3_LATENCY1_FREQ  ((uint32_t)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_SetFlashLatency(uint32_t Frequency);
 | 
			
		||||
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 */
 | 
			
		||||
  /* Add this code to indicate that local variable is not used */
 | 
			
		||||
  ((void)tmp);
 | 
			
		||||
 | 
			
		||||
  /* Add a period to guaranty minimum wait */
 | 
			
		||||
  if (Delay < LL_MAX_DELAY)
 | 
			
		||||
  {
 | 
			
		||||
    Delay++;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  while (Delay)
 | 
			
		||||
  {
 | 
			
		||||
    if ((SysTick->CTRL & SysTick_CTRL_COUNTFLAG_Msk) != 0U)
 | 
			
		||||
    {
 | 
			
		||||
      Delay--;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @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  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. 
 | 
			
		||||
  * @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 = SUCCESS;
 | 
			
		||||
  uint32_t pllfreq = 0U;
 | 
			
		||||
 | 
			
		||||
  /* 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. 
 | 
			
		||||
  * @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 = SUCCESS;
 | 
			
		||||
  uint32_t pllfreq = 0U;
 | 
			
		||||
 | 
			
		||||
  /* 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  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
 | 
			
		||||
  */
 | 
			
		||||
static ErrorStatus UTILS_SetFlashLatency(uint32_t Frequency)
 | 
			
		||||
{
 | 
			
		||||
  ErrorStatus status = SUCCESS;
 | 
			
		||||
 | 
			
		||||
  uint32_t latency = LL_FLASH_LATENCY_0;  /* default value 0WS */
 | 
			
		||||
 | 
			
		||||
  /* Frequency cannot be equal to 0 */
 | 
			
		||||
  if (Frequency == 0U)
 | 
			
		||||
  {
 | 
			
		||||
    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 */
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    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;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @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 = 0U;
 | 
			
		||||
 | 
			
		||||
  /* 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_POSITION_PLLMUL]);
 | 
			
		||||
  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_POSITION_PLLDIV)+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 = 0U;
 | 
			
		||||
 | 
			
		||||
  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 = UTILS_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 = UTILS_SetFlashLatency(hclk_frequency);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  /* Update SystemCoreClock variable */
 | 
			
		||||
  if (status == SUCCESS)
 | 
			
		||||
  {
 | 
			
		||||
    LL_SetSystemCoreClock(hclk_frequency);
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return status;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,283 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_utils.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   Header file of UTILS LL module.
 | 
			
		||||
  @verbatim
 | 
			
		||||
  ==============================================================================
 | 
			
		||||
                     ##### How to use this driver #####
 | 
			
		||||
  ==============================================================================
 | 
			
		||||
    [..]
 | 
			
		||||
    The LL UTILS driver contains a set of generic APIs that can be
 | 
			
		||||
    used by user:
 | 
			
		||||
      (+) Device electronic signature
 | 
			
		||||
      (+) Timing functions
 | 
			
		||||
      (+) PLL configuration functions
 | 
			
		||||
 | 
			
		||||
  @endverbatim
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32L0xx_LL_UTILS_H
 | 
			
		||||
#define __STM32L0xx_LL_UTILS_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup UTILS_LL UTILS
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
/** @defgroup UTILS_LL_Private_Constants UTILS Private Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Max delay can be used in LL_mDelay */
 | 
			
		||||
#define LL_MAX_DELAY                  (uint32_t)0xFFFFFFFFU
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Unique device ID register base address
 | 
			
		||||
 */
 | 
			
		||||
#define UID_BASE_ADDRESS              UID_BASE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * @brief Flash size data register base address
 | 
			
		||||
 */
 | 
			
		||||
#define FLASHSIZE_BASE_ADDRESS        FLASHSIZE_BASE
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup UTILS_LL_Private_Macros UTILS Private Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup UTILS_LL_ES_INIT UTILS Exported structures
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  UTILS PLL structure definition
 | 
			
		||||
  */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint32_t PLLMul;   /*!< Multiplication factor for PLL VCO input clock.
 | 
			
		||||
                          This parameter can be a value of @ref RCC_LL_EC_PLL_MUL
 | 
			
		||||
 | 
			
		||||
                          This feature can be modified afterwards using unitary function
 | 
			
		||||
                          @ref LL_RCC_PLL_ConfigDomain_SYS(). */
 | 
			
		||||
 | 
			
		||||
  uint32_t PLLDiv;   /*!< Division factor for PLL VCO output clock.
 | 
			
		||||
                          This parameter can be a value of @ref RCC_LL_EC_PLL_DIV 
 | 
			
		||||
  
 | 
			
		||||
                          This feature can be modified afterwards using unitary function
 | 
			
		||||
                          @ref LL_RCC_PLL_ConfigDomain_SYS(). */
 | 
			
		||||
} LL_UTILS_PLLInitTypeDef;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  UTILS System, AHB and APB buses clock configuration structure definition
 | 
			
		||||
  */
 | 
			
		||||
typedef struct
 | 
			
		||||
{
 | 
			
		||||
  uint32_t AHBCLKDivider;         /*!< The AHB clock (HCLK) divider. This clock is derived from the system clock (SYSCLK).
 | 
			
		||||
                                       This parameter can be a value of @ref RCC_LL_EC_SYSCLK_DIV
 | 
			
		||||
 | 
			
		||||
                                       This feature can be modified afterwards using unitary function
 | 
			
		||||
                                       @ref LL_RCC_SetAHBPrescaler(). */
 | 
			
		||||
 | 
			
		||||
  uint32_t APB1CLKDivider;        /*!< The APB1 clock (PCLK1) divider. This clock is derived from the AHB clock (HCLK).
 | 
			
		||||
                                       This parameter can be a value of @ref RCC_LL_EC_APB1_DIV
 | 
			
		||||
 | 
			
		||||
                                       This feature can be modified afterwards using unitary function
 | 
			
		||||
                                       @ref LL_RCC_SetAPB1Prescaler(). */
 | 
			
		||||
 | 
			
		||||
  uint32_t APB2CLKDivider;        /*!< The APB2 clock (PCLK2) divider. This clock is derived from the AHB clock (HCLK).
 | 
			
		||||
                                       This parameter can be a value of @ref RCC_LL_EC_APB2_DIV
 | 
			
		||||
 | 
			
		||||
                                       This feature can be modified afterwards using unitary function
 | 
			
		||||
                                       @ref LL_RCC_SetAPB2Prescaler(). */
 | 
			
		||||
 | 
			
		||||
} LL_UTILS_ClkInitTypeDef;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup UTILS_LL_Exported_Constants UTILS Exported Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup UTILS_EC_HSE_BYPASS HSE Bypass activation
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_UTILS_HSEBYPASS_OFF        (uint32_t)0x00000000U       /*!< HSE Bypass is not enabled                */
 | 
			
		||||
#define LL_UTILS_HSEBYPASS_ON         (uint32_t)0x00000001U       /*!< HSE Bypass is enabled                    */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup UTILS_LL_Exported_Functions UTILS Exported Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup UTILS_EF_DEVICE_ELECTRONIC_SIGNATURE DEVICE ELECTRONIC SIGNATURE
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Word0 of the unique device identifier (UID based on 96 bits)
 | 
			
		||||
  * @retval UID[31:0]
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GetUID_Word0(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(*((uint32_t *)UID_BASE_ADDRESS)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Word1 of the unique device identifier (UID based on 96 bits)
 | 
			
		||||
  * @retval UID[63:32]
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GetUID_Word1(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 4U))));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Word2 of the unique device identifier (UID based on 96 bits)
 | 
			
		||||
  * @retval UID[95:64]
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GetUID_Word2(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_REG(*((uint32_t *)(UID_BASE_ADDRESS + 8U))));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Get Flash memory size
 | 
			
		||||
  * @note   This bitfield indicates the size of the device Flash memory expressed in
 | 
			
		||||
  *         Kbytes. As an example, 0x040 corresponds to 64 Kbytes.
 | 
			
		||||
  * @retval FLASH_SIZE[15:0]: Flash memory size
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_GetFlashSize(void)
 | 
			
		||||
{
 | 
			
		||||
  return (uint16_t)(READ_REG(*((uint32_t *)FLASHSIZE_BASE_ADDRESS)));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup UTILS_LL_EF_DELAY DELAY
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  This function configures the Cortex-M SysTick source of the time base.
 | 
			
		||||
  * @param  HCLKFrequency HCLK frequency in Hz (can be calculated thanks to RCC helper macro)
 | 
			
		||||
  * @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  Ticks Number of ticks
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_InitTick(uint32_t HCLKFrequency, uint32_t Ticks)
 | 
			
		||||
{
 | 
			
		||||
  /* Configure the SysTick to have interrupt in 1ms time base */
 | 
			
		||||
  SysTick->LOAD  = (uint32_t)((HCLKFrequency / Ticks) - 1UL);  /* set reload register */
 | 
			
		||||
  SysTick->VAL   = 0UL;                                       /* Load the SysTick Counter Value */
 | 
			
		||||
  SysTick->CTRL  = SysTick_CTRL_CLKSOURCE_Msk |
 | 
			
		||||
                   SysTick_CTRL_ENABLE_Msk;                   /* Enable the Systick Timer */
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void        LL_Init1msTick(uint32_t HCLKFrequency);
 | 
			
		||||
void        LL_mDelay(uint32_t Delay);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup UTILS_EF_SYSTEM SYSTEM
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
void        LL_SetSystemCoreClock(uint32_t HCLKFrequency);
 | 
			
		||||
ErrorStatus LL_PLL_ConfigSystemClock_HSI(LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct,
 | 
			
		||||
                                         LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
 | 
			
		||||
ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypass,
 | 
			
		||||
                                         LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32L0xx_LL_UTILS_H */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
| 
						 | 
				
			
			@ -0,0 +1,342 @@
 | 
			
		|||
/**
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @file    stm32l0xx_ll_wwdg.h
 | 
			
		||||
  * @author  MCD Application Team
 | 
			
		||||
  * @version V1.7.0
 | 
			
		||||
  * @date    31-May-2016
 | 
			
		||||
  * @brief   Header file of WWDG LL module.
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  * @attention
 | 
			
		||||
  *
 | 
			
		||||
  * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
 | 
			
		||||
  *
 | 
			
		||||
  * Redistribution and use in source and binary forms, with or without modification,
 | 
			
		||||
  * are permitted provided that the following conditions are met:
 | 
			
		||||
  *   1. Redistributions of source code must retain the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer.
 | 
			
		||||
  *   2. Redistributions in binary form must reproduce the above copyright notice,
 | 
			
		||||
  *      this list of conditions and the following disclaimer in the documentation
 | 
			
		||||
  *      and/or other materials provided with the distribution.
 | 
			
		||||
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
 | 
			
		||||
  *      may be used to endorse or promote products derived from this software
 | 
			
		||||
  *      without specific prior written permission.
 | 
			
		||||
  *
 | 
			
		||||
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 | 
			
		||||
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 | 
			
		||||
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 | 
			
		||||
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
 | 
			
		||||
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 | 
			
		||||
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 | 
			
		||||
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 | 
			
		||||
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
 | 
			
		||||
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 | 
			
		||||
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 | 
			
		||||
  *
 | 
			
		||||
  ******************************************************************************
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Define to prevent recursive inclusion -------------------------------------*/
 | 
			
		||||
#ifndef __STM32L0xx_LL_WWDG_H
 | 
			
		||||
#define __STM32L0xx_LL_WWDG_H
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
extern "C" {
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
/* Includes ------------------------------------------------------------------*/
 | 
			
		||||
#include "stm32l0xx.h"
 | 
			
		||||
 | 
			
		||||
/** @addtogroup STM32L0xx_LL_Driver
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#if defined (WWDG)
 | 
			
		||||
 | 
			
		||||
/** @defgroup WWDG_LL WWDG
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Private types -------------------------------------------------------------*/
 | 
			
		||||
/* Private variables ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private constants ---------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Private macros ------------------------------------------------------------*/
 | 
			
		||||
 | 
			
		||||
/* Exported types ------------------------------------------------------------*/
 | 
			
		||||
/* Exported constants --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup WWDG_LL_Exported_Constants WWDG Exported Constants
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/** @defgroup WWDG_LL_EC_IT IT Defines
 | 
			
		||||
  * @brief    IT defines which can be used with LL_WWDG_ReadReg and  LL_WWDG_WriteReg functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
#define LL_WWDG_CFR_EWI                    WWDG_CFR_EWI
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup WWDG_LL_EC_PRESCALER  PRESCALER
 | 
			
		||||
* @{
 | 
			
		||||
*/
 | 
			
		||||
#define LL_WWDG_PRESCALER_1                (uint32_t)0x00000000U                                   /*!< WWDG counter clock = (PCLK1/4096)/1 */
 | 
			
		||||
#define LL_WWDG_PRESCALER_2                WWDG_CFR_WDGTB_0                                        /*!< WWDG counter clock = (PCLK1/4096)/2 */
 | 
			
		||||
#define LL_WWDG_PRESCALER_4                WWDG_CFR_WDGTB_1                                        /*!< WWDG counter clock = (PCLK1/4096)/4 */
 | 
			
		||||
#define LL_WWDG_PRESCALER_8                (WWDG_CFR_WDGTB_0 | WWDG_CFR_WDGTB_1)                   /*!< WWDG counter clock = (PCLK1/4096)/8 */
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported macro ------------------------------------------------------------*/
 | 
			
		||||
/** @defgroup WWDG_LL_Exported_Macros WWDG Exported Macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/** @defgroup WWDG_LL_EM_WRITE_READ Common Write and read registers macros
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Write a value in WWDG register
 | 
			
		||||
  * @param  __INSTANCE__ WWDG Instance
 | 
			
		||||
  * @param  __REG__ Register to be written
 | 
			
		||||
  * @param  __VALUE__ Value to be written in the register
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
#define LL_WWDG_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__))
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Read a value in WWDG register
 | 
			
		||||
  * @param  __INSTANCE__ WWDG Instance
 | 
			
		||||
  * @param  __REG__ Register to be read
 | 
			
		||||
  * @retval Register value
 | 
			
		||||
  */
 | 
			
		||||
#define LL_WWDG_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__)
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/* Exported functions --------------------------------------------------------*/
 | 
			
		||||
/** @defgroup WWDG_LL_Exported_Functions WWDG Exported Functions
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup WWDG_LL_EF_Configuration Configuration
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable Window Watchdog. The watchdog is always disabled after a reset.
 | 
			
		||||
  * @note   It is enabled by setting the WDGA bit in the WWDG_CR register,
 | 
			
		||||
  *         then it cannot be disabled again except by a reset.
 | 
			
		||||
  *         This bit is set by software and only cleared by hardware after a reset.
 | 
			
		||||
  *         When WDGA = 1, the watchdog can generate a reset.
 | 
			
		||||
  * @rmtoll CR           WDGA          LL_WWDG_Enable
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_WWDG_Enable(WWDG_TypeDef *WWDGx)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(WWDGx->CR, WWDG_CR_WDGA);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Checks if Window Watchdog is enabled
 | 
			
		||||
  * @rmtoll CR           WDGA          LL_WWDG_IsEnabled
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_WWDG_IsEnabled(WWDG_TypeDef *WWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(WWDGx->CR, WWDG_CR_WDGA) == (WWDG_CR_WDGA));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the Watchdog counter value to provided value (7-bits T[6:0])
 | 
			
		||||
  * @note   When writing to the WWDG_CR register, always write 1 in the MSB b6 to avoid generating an immediate reset
 | 
			
		||||
  *         This counter is decremented every (4096 x 2expWDGTB) PCLK cycles
 | 
			
		||||
  *         A reset is produced when it rolls over from 0x40 to 0x3F (bit T6 becomes cleared)
 | 
			
		||||
  *         Setting the counter lower then 0x40 causes an immediate reset (if WWDG enabled)
 | 
			
		||||
  * @rmtoll CR           T             LL_WWDG_SetCounter
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @param  Counter 0..0x7F (7 bit counter value)
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_WWDG_SetCounter(WWDG_TypeDef *WWDGx, uint32_t Counter)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(WWDGx->CR, WWDG_CR_T, Counter);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return current Watchdog Counter Value (7 bits counter value)
 | 
			
		||||
  * @rmtoll CR           T             LL_WWDG_GetCounter
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @retval 7 bit Watchdog Counter value
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_WWDG_GetCounter(WWDG_TypeDef *WWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(WWDGx->CR, WWDG_CR_T));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the time base of the prescaler (WDGTB).
 | 
			
		||||
  * @note   Prescaler is used to apply ratio on PCLK clock, so that Watchdog counter
 | 
			
		||||
  *         is decremented every (4096 x 2expWDGTB) PCLK cycles
 | 
			
		||||
  * @rmtoll CFR          WDGTB         LL_WWDG_SetPrescaler
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @param  Prescaler This parameter can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_WWDG_PRESCALER_1
 | 
			
		||||
  *         @arg @ref LL_WWDG_PRESCALER_2
 | 
			
		||||
  *         @arg @ref LL_WWDG_PRESCALER_4
 | 
			
		||||
  *         @arg @ref LL_WWDG_PRESCALER_8
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_WWDG_SetPrescaler(WWDG_TypeDef *WWDGx, uint32_t Prescaler)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(WWDGx->CFR, WWDG_CFR_WDGTB, Prescaler);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return current Watchdog Prescaler Value
 | 
			
		||||
  * @rmtoll CFR          WDGTB         LL_WWDG_GetPrescaler
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @retval Returned value can be one of the following values:
 | 
			
		||||
  *         @arg @ref LL_WWDG_PRESCALER_1
 | 
			
		||||
  *         @arg @ref LL_WWDG_PRESCALER_2
 | 
			
		||||
  *         @arg @ref LL_WWDG_PRESCALER_4
 | 
			
		||||
  *         @arg @ref LL_WWDG_PRESCALER_8
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_WWDG_GetPrescaler(WWDG_TypeDef *WWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(WWDGx->CFR, WWDG_CFR_WDGTB));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Set the Watchdog Window value to be compared to the downcounter (7-bits W[6:0]).
 | 
			
		||||
  * @note   This window value defines when write in the WWDG_CR register
 | 
			
		||||
  *         to program Watchdog counter is allowed.
 | 
			
		||||
  *         Watchdog counter value update must occur only when the counter value
 | 
			
		||||
  *         is lower than the Watchdog window register value.
 | 
			
		||||
  *         Otherwise, a MCU reset is generated if the 7-bit Watchdog counter value
 | 
			
		||||
  *         (in the control register) is refreshed before the downcounter has reached
 | 
			
		||||
  *         the watchdog window register value.
 | 
			
		||||
  *         Physically is possible to set the Window lower then 0x40 but it is not recommended.
 | 
			
		||||
  *         To generate an immediate reset, it is possible to set the Counter lower than 0x40.
 | 
			
		||||
  * @rmtoll CFR          W             LL_WWDG_SetWindow
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @param  Window 0x00..0x7F (7 bit Window value)
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_WWDG_SetWindow(WWDG_TypeDef *WWDGx, uint32_t Window)
 | 
			
		||||
{
 | 
			
		||||
  MODIFY_REG(WWDGx->CFR, WWDG_CFR_W, Window);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Return current Watchdog Window Value (7 bits value)
 | 
			
		||||
  * @rmtoll CFR          W             LL_WWDG_GetWindow
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @retval 7 bit Watchdog Window value
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_WWDG_GetWindow(WWDG_TypeDef *WWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (uint32_t)(READ_BIT(WWDGx->CFR, WWDG_CFR_W));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup WWDG_LL_EF_FLAG_Management FLAG_Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Indicates if the WWDG Early Wakeup Interrupt Flag is set or not.
 | 
			
		||||
  * @note   This bit is set by hardware when the counter has reached the value 0x40.
 | 
			
		||||
  *         It must be cleared by software by writing 0.
 | 
			
		||||
  *         A write of 1 has no effect. This bit is also set if the interrupt is not enabled.
 | 
			
		||||
  * @rmtoll SR           EWIF          LL_WWDG_IsActiveFlag_EWKUP
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_WWDG_IsActiveFlag_EWKUP(WWDG_TypeDef *WWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(WWDGx->SR, WWDG_SR_EWIF) == (WWDG_SR_EWIF));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Clear WWDG Early Wakeup Interrupt Flag (EWIF)
 | 
			
		||||
  * @rmtoll SR           EWIF          LL_WWDG_ClearFlag_EWKUP
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_WWDG_ClearFlag_EWKUP(WWDG_TypeDef *WWDGx)
 | 
			
		||||
{
 | 
			
		||||
  WRITE_REG(WWDGx->SR, ~WWDG_SR_EWIF);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/** @defgroup WWDG_LL_EF_IT_Management IT_Management
 | 
			
		||||
  * @{
 | 
			
		||||
  */
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Enable the Early Wakeup Interrupt.
 | 
			
		||||
  * @note   When set, an interrupt occurs whenever the counter reaches value 0x40.
 | 
			
		||||
  *         This interrupt is only cleared by hardware after a reset
 | 
			
		||||
  * @rmtoll CFR          EWI           LL_WWDG_EnableIT_EWKUP
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @retval None
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE void LL_WWDG_EnableIT_EWKUP(WWDG_TypeDef *WWDGx)
 | 
			
		||||
{
 | 
			
		||||
  SET_BIT(WWDGx->CFR, WWDG_CFR_EWI);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @brief  Check if Early Wakeup Interrupt is enabled
 | 
			
		||||
  * @rmtoll CFR          EWI           LL_WWDG_IsEnabledIT_EWKUP
 | 
			
		||||
  * @param  WWDGx WWDG Instance
 | 
			
		||||
  * @retval State of bit (1 or 0).
 | 
			
		||||
  */
 | 
			
		||||
__STATIC_INLINE uint32_t LL_WWDG_IsEnabledIT_EWKUP(WWDG_TypeDef *WWDGx)
 | 
			
		||||
{
 | 
			
		||||
  return (READ_BIT(WWDGx->CFR, WWDG_CFR_EWI) == (WWDG_CFR_EWI));
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#endif /* WWDG */
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
  * @}
 | 
			
		||||
  */
 | 
			
		||||
 | 
			
		||||
#ifdef __cplusplus
 | 
			
		||||
}
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
#endif /* __STM32L0xx_LL_WWDG_H */
 | 
			
		||||
 | 
			
		||||
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
 | 
			
		||||
		Loading…
	
		Reference in New Issue