STM32G474xx HAL 用户手册
stm32g4xx_ll_lpuart.h
转到该文件的文档。
00001 /**
00002   ******************************************************************************
00003   * @file    stm32g4xx_ll_lpuart.h
00004   * @author  MCD Application Team
00005   * @brief   Header file of LPUART LL module.
00006   ******************************************************************************
00007   * @attention
00008   *
00009   * Copyright (c) 2019 STMicroelectronics.
00010   * All rights reserved.
00011   *
00012   * This software is licensed under terms that can be found in the LICENSE file
00013   * in the root directory of this software component.
00014   * If no LICENSE file comes with this software, it is provided AS-IS.
00015   *
00016   ******************************************************************************
00017   */
00018 
00019 /* Define to prevent recursive inclusion -------------------------------------*/
00020 #ifndef STM32G4xx_LL_LPUART_H
00021 #define STM32G4xx_LL_LPUART_H
00022 
00023 #ifdef __cplusplus
00024 extern "C" {
00025 #endif
00026 
00027 /* Includes ------------------------------------------------------------------*/
00028 #include "stm32g4xx.h"
00029 
00030 /** @addtogroup STM32G4xx_LL_Driver
00031   * @{
00032   */
00033 
00034 #if defined (LPUART1)
00035 
00036 /** @defgroup LPUART_LL LPUART
00037   * @{
00038   */
00039 
00040 /* Private types -------------------------------------------------------------*/
00041 /* Private variables ---------------------------------------------------------*/
00042 /** @defgroup LPUART_LL_Private_Variables LPUART Private Variables
00043   * @{
00044   */
00045 /* Array used to get the LPUART prescaler division decimal values versus @ref LPUART_LL_EC_PRESCALER values */
00046 static const uint16_t LPUART_PRESCALER_TAB[] =
00047 {
00048   (uint16_t)1,
00049   (uint16_t)2,
00050   (uint16_t)4,
00051   (uint16_t)6,
00052   (uint16_t)8,
00053   (uint16_t)10,
00054   (uint16_t)12,
00055   (uint16_t)16,
00056   (uint16_t)32,
00057   (uint16_t)64,
00058   (uint16_t)128,
00059   (uint16_t)256,
00060   (uint16_t)256,
00061   (uint16_t)256,
00062   (uint16_t)256,
00063   (uint16_t)256
00064 };
00065 /**
00066   * @}
00067   */
00068 
00069 /* Private constants ---------------------------------------------------------*/
00070 /** @defgroup LPUART_LL_Private_Constants LPUART Private Constants
00071   * @{
00072   */
00073 /* Defines used in Baud Rate related macros and corresponding register setting computation */
00074 #define LPUART_LPUARTDIV_FREQ_MUL     256U
00075 #define LPUART_BRR_MASK               0x000FFFFFU
00076 #define LPUART_BRR_MIN_VALUE          0x00000300U
00077 /**
00078   * @}
00079   */
00080 
00081 
00082 /* Private macros ------------------------------------------------------------*/
00083 #if defined(USE_FULL_LL_DRIVER)
00084 /** @defgroup LPUART_LL_Private_Macros LPUART Private Macros
00085   * @{
00086   */
00087 /**
00088   * @}
00089   */
00090 #endif /*USE_FULL_LL_DRIVER*/
00091 
00092 /* Exported types ------------------------------------------------------------*/
00093 #if defined(USE_FULL_LL_DRIVER)
00094 /** @defgroup LPUART_LL_ES_INIT LPUART Exported Init structures
00095   * @{
00096   */
00097 
00098 /**
00099   * @brief LL LPUART Init Structure definition
00100   */
00101 typedef struct
00102 {
00103   uint32_t PrescalerValue;            /*!< Specifies the Prescaler to compute the communication baud rate.
00104                                            This parameter can be a value of @ref LPUART_LL_EC_PRESCALER.
00105 
00106                                            This feature can be modified afterwards using unitary
00107                                            function @ref LL_LPUART_SetPrescaler().*/
00108 
00109   uint32_t BaudRate;                  /*!< This field defines expected LPUART communication baud rate.
00110 
00111                                            This feature can be modified afterwards using unitary
00112                                            function @ref LL_LPUART_SetBaudRate().*/
00113 
00114   uint32_t DataWidth;                 /*!< Specifies the number of data bits transmitted or received in a frame.
00115                                            This parameter can be a value of @ref LPUART_LL_EC_DATAWIDTH.
00116 
00117                                            This feature can be modified afterwards using unitary
00118                                            function @ref LL_LPUART_SetDataWidth().*/
00119 
00120   uint32_t StopBits;                  /*!< Specifies the number of stop bits transmitted.
00121                                            This parameter can be a value of @ref LPUART_LL_EC_STOPBITS.
00122 
00123                                            This feature can be modified afterwards using unitary
00124                                            function @ref LL_LPUART_SetStopBitsLength().*/
00125 
00126   uint32_t Parity;                    /*!< Specifies the parity mode.
00127                                            This parameter can be a value of @ref LPUART_LL_EC_PARITY.
00128 
00129                                            This feature can be modified afterwards using unitary
00130                                            function @ref LL_LPUART_SetParity().*/
00131 
00132   uint32_t TransferDirection;         /*!< Specifies whether the Receive and/or Transmit mode is enabled or disabled.
00133                                            This parameter can be a value of @ref LPUART_LL_EC_DIRECTION.
00134 
00135                                            This feature can be modified afterwards using unitary
00136                                            function @ref LL_LPUART_SetTransferDirection().*/
00137 
00138   uint32_t HardwareFlowControl;       /*!< Specifies whether the hardware flow control mode is enabled or disabled.
00139                                            This parameter can be a value of @ref LPUART_LL_EC_HWCONTROL.
00140 
00141                                            This feature can be modified afterwards using unitary
00142                                            function @ref LL_LPUART_SetHWFlowCtrl().*/
00143 
00144 } LL_LPUART_InitTypeDef;
00145 
00146 /**
00147   * @}
00148   */
00149 #endif /* USE_FULL_LL_DRIVER */
00150 
00151 /* Exported constants --------------------------------------------------------*/
00152 /** @defgroup LPUART_LL_Exported_Constants LPUART Exported Constants
00153   * @{
00154   */
00155 
00156 /** @defgroup LPUART_LL_EC_CLEAR_FLAG Clear Flags Defines
00157   * @brief    Flags defines which can be used with LL_LPUART_WriteReg function
00158   * @{
00159   */
00160 #define LL_LPUART_ICR_PECF                 USART_ICR_PECF                /*!< Parity error clear flag */
00161 #define LL_LPUART_ICR_FECF                 USART_ICR_FECF                /*!< Framing error clear flag */
00162 #define LL_LPUART_ICR_NCF                  USART_ICR_NECF                /*!< Noise error detected clear flag */
00163 #define LL_LPUART_ICR_ORECF                USART_ICR_ORECF               /*!< Overrun error clear flag */
00164 #define LL_LPUART_ICR_IDLECF               USART_ICR_IDLECF              /*!< Idle line detected clear flag */
00165 #define LL_LPUART_ICR_TCCF                 USART_ICR_TCCF                /*!< Transmission complete clear flag */
00166 #define LL_LPUART_ICR_CTSCF                USART_ICR_CTSCF               /*!< CTS clear flag */
00167 #define LL_LPUART_ICR_CMCF                 USART_ICR_CMCF                /*!< Character match clear flag */
00168 #define LL_LPUART_ICR_WUCF                 USART_ICR_WUCF                /*!< Wakeup from Stop mode clear flag */
00169 /**
00170   * @}
00171   */
00172 
00173 /** @defgroup LPUART_LL_EC_GET_FLAG Get Flags Defines
00174   * @brief    Flags defines which can be used with LL_LPUART_ReadReg function
00175   * @{
00176   */
00177 #define LL_LPUART_ISR_PE               USART_ISR_PE         /*!< Parity error flag */
00178 #define LL_LPUART_ISR_FE               USART_ISR_FE         /*!< Framing error flag */
00179 #define LL_LPUART_ISR_NE               USART_ISR_NE         /*!< Noise detected flag */
00180 #define LL_LPUART_ISR_ORE              USART_ISR_ORE        /*!< Overrun error flag */
00181 #define LL_LPUART_ISR_IDLE             USART_ISR_IDLE       /*!< Idle line detected flag */
00182 #define LL_LPUART_ISR_RXNE_RXFNE       USART_ISR_RXNE_RXFNE /*!< Read data register or RX FIFO not empty flag */
00183 #define LL_LPUART_ISR_TC               USART_ISR_TC         /*!< Transmission complete flag */
00184 #define LL_LPUART_ISR_TXE_TXFNF        USART_ISR_TXE_TXFNF  /*!< Transmit data register empty or TX FIFO Not Full flag*/
00185 #define LL_LPUART_ISR_CTSIF            USART_ISR_CTSIF      /*!< CTS interrupt flag */
00186 #define LL_LPUART_ISR_CTS              USART_ISR_CTS        /*