STM32H735xx HAL User Manual
|
00001 /** 00002 ****************************************************************************** 00003 * @file stm32h7xx_ll_spi.h 00004 * @author MCD Application Team 00005 * @brief Header file of SPI LL module. 00006 ****************************************************************************** 00007 * @attention 00008 * 00009 * Copyright (c) 2017 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 STM32H7xx_LL_SPI_H 00021 #define STM32H7xx_LL_SPI_H 00022 00023 #ifdef __cplusplus 00024 extern "C" { 00025 #endif 00026 00027 /* Includes ------------------------------------------------------------------*/ 00028 #include "stm32h7xx.h" 00029 00030 /** @addtogroup STM32H7xx_LL_Driver 00031 * @{ 00032 */ 00033 00034 #if defined(SPI1) || defined(SPI2) || defined(SPI3) || defined(SPI4) || defined(SPI5) || defined(SPI6) 00035 00036 /** @defgroup SPI_LL SPI 00037 * @{ 00038 */ 00039 00040 /* Private variables ---------------------------------------------------------*/ 00041 00042 /* Private constants ---------------------------------------------------------*/ 00043 00044 /* Private macros ------------------------------------------------------------*/ 00045 /** @defgroup SPI_LL_Private_Macros SPI Private Macros 00046 * @{ 00047 */ 00048 /** 00049 * @} 00050 */ 00051 00052 /* Exported types ------------------------------------------------------------*/ 00053 #if defined(USE_FULL_LL_DRIVER) 00054 /** @defgroup SPI_LL_Exported_Types SPI Exported Types 00055 * @{ 00056 */ 00057 00058 /** 00059 * @brief SPI Init structures definition 00060 */ 00061 typedef struct 00062 { 00063 uint32_t TransferDirection; /*!< Specifies the SPI unidirectional or bidirectional data mode. 00064 This parameter can be a value of @ref SPI_LL_EC_TRANSFER_MODE. 00065 00066 This feature can be modified afterwards using unitary function 00067 @ref LL_SPI_SetTransferDirection().*/ 00068 00069 uint32_t Mode; /*!< Specifies the SPI mode (Master/Slave). 00070 This parameter can be a value of @ref SPI_LL_EC_MODE. 00071 00072 This feature can be modified afterwards using unitary function 00073 @ref LL_SPI_SetMode().*/ 00074 00075 uint32_t DataWidth; /*!< Specifies the SPI data width. 00076 This parameter can be a value of @ref SPI_LL_EC_DATAWIDTH. 00077 00078 This feature can be modified afterwards using unitary function 00079 @ref LL_SPI_SetDataWidth().*/ 00080 00081 uint32_t ClockPolarity; /*!< Specifies the serial clock steady state. 00082 This parameter can be a value of @ref SPI_LL_EC_POLARITY. 00083 00084 This feature can be modified afterwards using unitary function 00085 @ref LL_SPI_SetClockPolarity().*/ 00086 00087 uint32_t ClockPhase; /*!< Specifies the clock active edge for the bit capture. 00088 This parameter can be a value of @ref SPI_LL_EC_PHASE. 00089 00090 This feature can be modified afterwards using unitary function 00091 @ref LL_SPI_SetClockPhase().*/ 00092 00093 uint32_t NSS; /*!< Specifies whether the NSS signal is managed by hardware (NSS pin) 00094 or by software using the SSI bit. 00095 00096 This parameter can be a value of @ref SPI_LL_EC_NSS_MODE. 00097 00098 This feature can be modified afterwards using unitary function 00099 @ref LL_SPI_SetNSSMode().*/ 00100 00101 uint32_t BaudRate; /*!< Specifies the BaudRate prescaler value which will be used to configure 00102 the transmit and receive SCK clock. 00103 This parameter can be a value of @ref SPI_LL_EC_BAUDRATEPRESCALER. 00104 @note The communication clock is derived from the master clock. 00105 The slave clock does not need to be set. 00106 00107 This feature can be modified afterwards using unitary function 00108 @ref LL_SPI_SetBaudRatePrescaler().*/ 00109 00110 uint32_t BitOrder; /*!< Specifies whether data transfers start from MSB or LSB bit. 00111 This parameter can be a value of @ref SPI_LL_EC_BIT_ORDER. 00112 00113 This feature can be modified afterwards using unitary function 00114 @ref LL_SPI_SetTransferBitOrder().*/ 00115 00116 uint32_t CRCCalculation; /*!< Specifies if the CRC calculation is enabled or not. 00117 This parameter can be a value of @ref SPI_LL_EC_CRC_CALCULATION. 00118 00119 This feature can be modified afterwards using unitary functions 00120 @ref LL_SPI_EnableCRC() and @ref LL_SPI_DisableCRC().*/ 00121 00122 uint32_t CRCPoly; /*!< Specifies the polynomial used for the CRC calculation. 00123 This parameter must be a number between Min_Data = 0x00 00124 and Max_Data = 0xFFFFFFFF. 00125 00126 This feature can be modified afterwards using unitary function 00127 @ref LL_SPI_SetCRCPolynomial().*/ 00128 00129 } LL_SPI_InitTypeDef; 00130 00131 /** 00132 * @} 00133 */ 00134 #endif /*USE_FULL_LL_DRIVER*/ 00135 00136 /* Exported types ------------------------------------------------------------*/ 00137 00138 /* Exported constants --------------------------------------------------------*/ 00139 /** @defgroup SPI_LL_Exported_Constants SPI Exported Constants 00140 * @{ 00141 */ 00142 00143 /** @defgroup SPI_LL_EC_GET_FLAG Get Flags Defines 00144 * @brief Flags defines which can be used with LL_SPI_ReadReg function 00145 * @{ 00146 */ 00147 #define LL_SPI_SR_RXP (SPI_SR_RXP) 00148 #define LL_SPI_SR_TXP (SPI_SR_TXP) 00149 #define LL_SPI_SR_DXP (SPI_SR_DXP) 00150 #define LL_SPI_SR_EOT (SPI_SR_EOT) 00151 #define LL_SPI_SR_TXTF (SPI_SR_TXTF) 00152 #define LL_SPI_SR_UDR (SPI_SR_UDR) 00153 #define LL_SPI_SR_CRCE (SPI_SR_CRCE) 00154 #define LL_SPI_SR_MODF (SPI_SR_MODF) 00155 #define LL_SPI_SR_OVR (SPI_SR_OVR) 00156 #define LL_SPI_SR_TIFRE (SPI_SR_TIFRE) 00157 #define LL_SPI_SR_TSERF (SPI_SR_TSERF) 00158 #define LL_SPI_SR_SUSP (SPI_SR_SUSP) 00159 #define LL_SPI_SR_TXC (SPI_SR_TXC) 00160 #define LL_SPI_SR_RXWNE (SPI_SR_RXWNE) 00161 /** 00162 * @} 00163 */ 00164 00165 /** @defgroup SPI_LL_EC_IT IT Defines 00166 * @brief IT defines which can be used with LL_SPI_ReadReg and LL_SPI_WriteReg functions 00167 * @{ 00168 */ 00169 #define LL_SPI_IER_RXPIE (SPI_IER_RXPIE) 00170 #define LL_SPI_IER_TXPIE (SPI_IER_TXPIE) 00171 #define LL_SPI_IER_DXPIE (SPI_IER_DXPIE) 00172 #define LL_SPI_IER_EOTIE (SPI_IER_EOTIE) 00173 #define LL_SPI_IER_TXTFIE (SPI_IER_TXTFIE) 00174 #define LL_SPI_IER_UDRIE (SPI_IER_UDRIE) 00175 #define LL_SPI_IER_OVRIE (SPI_IER_OVRIE) 00176 #define LL_SPI_IER_CRCEIE (SPI_IER_CRCEIE) 00177 #define LL_SPI_IER_TIFREIE (SPI_IER_TIFREIE) 00178 #define LL_SPI_IER_MODFIE (SPI_IER_MODFIE) 00179 #define LL_SPI_IER_TSERFIE (SPI_IER_TSERFIE) 00180 /** 00181 * @} 00182 */ 00183 00184 /** @defgroup SPI_LL_EC_MODE Mode 00185 * @{ 00186 */ 00187 #define LL_SPI_MODE_MASTER (SPI_CFG2_MASTER) 00188 #define LL_SPI_MODE_SLAVE (0x00000000UL) 00189 /** 00190 * @} 00191 */ 00192 00193 /** @defgroup SPI_LL_EC_SS_LEVEL SS Level 00194 * @{ 00195 */ 00196 #define LL_SPI_SS_LEVEL_HIGH (SPI_CR1_SSI) 00197 #define LL_SPI_SS_LEVEL_LOW (0x00000000UL) 00198 /** 00199 * @} 00200 */ 00201 00202 /** @defgroup SPI_LL_EC_SS_IDLENESS SS Idleness 00203 * @{ 00204 */ 00205 #define LL_SPI_SS_IDLENESS_00CYCLE (0x00000000UL) 00206 #define LL_SPI_SS_IDLENESS_01CYCLE (SPI_CFG2_MSSI_0) 00207 #define LL_SPI_SS_IDLENESS_02CYCLE (SPI_CFG2_MSSI_1) 00208 #define LL_SPI_SS_IDLENESS_03CYCLE (SPI_CFG2_MSSI_0 | SPI_CFG2_MSSI_1) 00209 #define LL_SPI_SS_IDLENESS_04CYCLE (SPI_CFG2_MSSI_2) 00210 #define LL_SPI_SS_IDLENESS_05CYCLE (SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_0) 00211 #define LL_SPI_SS_IDLENESS_06CYCLE (SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_1) 00212 #define LL_SPI_SS_IDLENESS_07CYCLE (SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_1 | SPI_CFG2_MSSI_0) 00213 #define LL_SPI_SS_IDLENESS_08CYCLE (SPI_CFG2_MSSI_3) 00214 #define LL_SPI_SS_IDLENESS_09CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_0) 00215 #define LL_SPI_SS_IDLENESS_10CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_1) 00216 #define LL_SPI_SS_IDLENESS_11CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_1 | SPI_CFG2_MSSI_0) 00217 #define LL_SPI_SS_IDLENESS_12CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_2) 00218 #define LL_SPI_SS_IDLENESS_13CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_0) 00219 #define LL_SPI_SS_IDLENESS_14CYCLE (SPI_CFG2_MSSI_3 | SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_1) 00220 #define LL_SPI_SS_IDLENESS_15CYCLE (SPI_CFG2_MSSI_3\ 00221 | SPI_CFG2_MSSI_2 | SPI_CFG2_MSSI_1 | SPI_CFG2_MSSI_0) 00222 /** 00223 * @} 00224 */ 00225 00226 /** @defgroup SPI_LL_EC_ID_IDLENESS Master Inter-Data Idleness 00227 * @{ 00228 */ 00229 #define LL_SPI_ID_IDLENESS_00CYCLE (0x00000000UL) 00230 #define LL_SPI_ID_IDLENESS_01CYCLE (SPI_CFG2_MIDI_0) 00231 #define LL_SPI_ID_IDLENESS_02CYCLE (SPI_CFG2_MIDI_1) 00232 #define LL_SPI_ID_IDLENESS_03CYCLE (SPI_CFG2_MIDI_0 | SPI_CFG2_MIDI_1) 00233 #define LL_SPI_ID_IDLENESS_04CYCLE (SPI_CFG2_MIDI_2) 00234 #define LL_SPI_ID_IDLENESS_05CYCLE (SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_0) 00235 #define LL_SPI_ID_IDLENESS_06CYCLE (SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_1) 00236 #define LL_SPI_ID_IDLENESS_07CYCLE (SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_1 | SPI_CFG2_MIDI_0) 00237 #define LL_SPI_ID_IDLENESS_08CYCLE (SPI_CFG2_MIDI_3) 00238 #define LL_SPI_ID_IDLENESS_09CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_0) 00239 #define LL_SPI_ID_IDLENESS_10CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_1) 00240 #define LL_SPI_ID_IDLENESS_11CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_1 | SPI_CFG2_MIDI_0) 00241 #define LL_SPI_ID_IDLENESS_12CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_2) 00242 #define LL_SPI_ID_IDLENESS_13CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_0) 00243 #define LL_SPI_ID_IDLENESS_14CYCLE (SPI_CFG2_MIDI_3 | SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_1) 00244 #define LL_SPI_ID_IDLENESS_15CYCLE (SPI_CFG2_MIDI_3\ 00245 | SPI_CFG2_MIDI_2 | SPI_CFG2_MIDI_1 | SPI_CFG2_MIDI_0) 00246 /** 00247 * @} 00248 */ 00249 00250 /** @defgroup SPI_LL_EC_TXCRCINIT_ALL TXCRC Init All 00251 * @{ 00252 */ 00253 #define LL_SPI_TXCRCINIT_ALL_ZERO_PATTERN (0x00000000UL) 00254 #define LL_SPI_TXCRCINIT_ALL_ONES_PATTERN (SPI_CR1_TCRCINI) 00255 /** 00256 * @} 00257 */ 00258 00259 /** @defgroup SPI_LL_EC_RXCRCINIT_ALL RXCRC Init All 00260 * @{ 00261 */ 00262 #define LL_SPI_RXCRCINIT_ALL_ZERO_PATTERN (0x00000000UL) 00263 #define LL_SPI_RXCRCINIT_ALL_ONES_PATTERN (SPI_CR1_RCRCINI) 00264 /** 00265 * @} 00266 */ 00267 00268 /** @defgroup SPI_LL_EC_UDR_CONFIG_REGISTER UDR Config Register 00269 * @{ 00270 */ 00271 #define LL_SPI_UDR_CONFIG_REGISTER_PATTERN (0x00000000UL) 00272 #define LL_SPI_UDR_CONFIG_LAST_RECEIVED (SPI_CFG1_UDRCFG_0) 00273 #define LL_SPI_UDR_CONFIG_LAST_TRANSMITTED (SPI_CFG1_UDRCFG_1) 00274 /** 00275 * @} 00276 */ 00277 00278 /** @defgroup SPI_LL_EC_UDR_DETECT_BEGIN_DATA UDR Detect Begin Data 00279 * @{ 00280 */ 00281 #define LL_SPI_UDR_DETECT_BEGIN_DATA_FRAME (0x00000000UL) 00282 #define LL_SPI_UDR_DETECT_END_DATA_FRAME (SPI_CFG1_UDRDET_0) 00283 #define LL_SPI_UDR_DETECT_BEGIN_ACTIVE_NSS (SPI_CFG1_UDRDET_1) 00284 /** 00285 * @} 00286 */ 00287 00288 /** @defgroup SPI_LL_EC_PROTOCOL Protocol 00289 * @{ 00290 */ 00291 #define LL_SPI_PROTOCOL_MOTOROLA (0x00000000UL) 00292 #define LL_SPI_PROTOCOL_TI (SPI_CFG2_SP_0) 00293 /** 00294 * @} 00295 */ 00296 00297 /** @defgroup SPI_LL_EC_PHASE Phase 00298 * @{ 00299 */ 00300 #define LL_SPI_PHASE_1EDGE (0x00000000UL) 00301 #define LL_SPI_PHASE_2EDGE (SPI_CFG2_CPHA) 00302 /** 00303 * @} 00304 */ 00305 00306 /** @defgroup SPI_LL_EC_POLARITY Polarity 00307 * @{ 00308 */ 00309 #define LL_SPI_POLARITY_LOW (0x00000000UL) 00310 #define LL_SPI_POLARITY_HIGH (SPI_CFG2_CPOL) 00311 /** 00312 * @} 00313 */ 00314 00315 /** @defgroup SPI_LL_EC_NSS_POLARITY NSS Polarity 00316 * @{ 00317 */ 00318 #define LL_SPI_NSS_POLARITY_LOW (0x00000000UL) 00319 #define LL_SPI_NSS_POLARITY_HIGH (SPI_CFG2_SSIOP) 00320 /** 00321 * @} 00322 */ 00323 00324 /** @defgroup SPI_LL_EC_BAUDRATEPRESCALER Baud Rate Prescaler 00325 * @{ 00326 */ 00327 #define LL_SPI_BAUDRATEPRESCALER_DIV2 (0x00000000UL) 00328 #define LL_SPI_BAUDRATEPRESCALER_DIV4 (SPI_CFG1_MBR_0) 00329 #define LL_SPI_BAUDRATEPRESCALER_DIV8 (SPI_CFG1_MBR_1) 00330 #define LL_SPI_BAUDRATEPRESCALER_DIV16 (SPI_CFG1_MBR_1 | SPI_CFG1_MBR_0) 00331 #define LL_SPI_BAUDRATEPRESCALER_DIV32 (SPI_CFG1_MBR_2) 00332 #define LL_SPI_BAUDRATEPRESCALER_DIV64 (SPI_CFG1_MBR_2 | SPI_CFG1_MBR_0) 00333 #define LL_SPI_BAUDRATEPRESCALER_DIV128 (SPI_CFG1_MBR_2 | SPI_CFG1_MBR_1) 00334 #define LL_SPI_BAUDRATEPRESCALER_DIV256 (SPI_CFG1_MBR_2 | SPI_CFG1_MBR_1 | SPI_CFG1_MBR_0) 00335 /** 00336 * @} 00337 */ 00338 00339 /** @defgroup SPI_LL_EC_BIT_ORDER Bit Order 00340 * @{ 00341 */ 00342 #define LL_SPI_LSB_FIRST (SPI_CFG2_LSBFRST) 00343 #define LL_SPI_MSB_FIRST (0x00000000UL) 00344 /** 00345 * @} 00346 */ 00347 00348 /** @defgroup SPI_LL_EC_TRANSFER_MODE Transfer Mode 00349 * @{ 00350 */ 00351 #define LL_SPI_FULL_DUPLEX (0x00000000UL) 00352 #define LL_SPI_SIMPLEX_TX (SPI_CFG2_COMM_0) 00353 #define LL_SPI_SIMPLEX_RX (SPI_CFG2_COMM_1) 00354 #define LL_SPI_HALF_DUPLEX_RX (SPI_CFG2_COMM_0|SPI_CFG2_COMM_1) 00355 #define LL_SPI_HALF_DUPLEX_TX (SPI_CFG2_COMM_0|SPI_CFG2_COMM_1|SPI_CR1_HDDIR) 00356 /** 00357 * @} 00358 */ 00359 00360 /** @defgroup SPI_LL_EC_DATAWIDTH Data Width 00361 * @{ 00362 */ 00363 #define LL_SPI_DATAWIDTH_4BIT (SPI_CFG1_DSIZE_0 | SPI_CFG1_DSIZE_1) 00364 #define LL_SPI_DATAWIDTH_5BIT (SPI_CFG1_DSIZE_2) 00365 #define LL_SPI_DATAWIDTH_6BIT (SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_0) 00366 #define LL_SPI_DATAWIDTH_7BIT (SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1) 00367 #define LL_SPI_DATAWIDTH_8BIT (SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0) 00368 #define LL_SPI_DATAWIDTH_9BIT (SPI_CFG1_DSIZE_3) 00369 #define LL_SPI_DATAWIDTH_10BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_0) 00370 #define LL_SPI_DATAWIDTH_11BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_1) 00371 #define LL_SPI_DATAWIDTH_12BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0) 00372 #define LL_SPI_DATAWIDTH_13BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2) 00373 #define LL_SPI_DATAWIDTH_14BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_0) 00374 #define LL_SPI_DATAWIDTH_15BIT (SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1) 00375 #define LL_SPI_DATAWIDTH_16BIT (SPI_CFG1_DSIZE_3\ 00376 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0) 00377 #define LL_SPI_DATAWIDTH_17BIT (SPI_CFG1_DSIZE_4) 00378 #define LL_SPI_DATAWIDTH_18BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_0) 00379 #define LL_SPI_DATAWIDTH_19BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_1) 00380 #define LL_SPI_DATAWIDTH_20BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_0 | SPI_CFG1_DSIZE_1) 00381 #define LL_SPI_DATAWIDTH_21BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_2) 00382 #define LL_SPI_DATAWIDTH_22BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_0) 00383 #define LL_SPI_DATAWIDTH_23BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1) 00384 #define LL_SPI_DATAWIDTH_24BIT (SPI_CFG1_DSIZE_4\ 00385 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0) 00386 #define LL_SPI_DATAWIDTH_25BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_3) 00387 #define LL_SPI_DATAWIDTH_26BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_0) 00388 #define LL_SPI_DATAWIDTH_27BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_1) 00389 #define LL_SPI_DATAWIDTH_28BIT (SPI_CFG1_DSIZE_4\ 00390 | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0) 00391 #define LL_SPI_DATAWIDTH_29BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2) 00392 #define LL_SPI_DATAWIDTH_30BIT (SPI_CFG1_DSIZE_4\ 00393 | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_0) 00394 #define LL_SPI_DATAWIDTH_31BIT (SPI_CFG1_DSIZE_4\ 00395 | SPI_CFG1_DSIZE_3 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1) 00396 #define LL_SPI_DATAWIDTH_32BIT (SPI_CFG1_DSIZE_4 | SPI_CFG1_DSIZE_3\ 00397 | SPI_CFG1_DSIZE_2 | SPI_CFG1_DSIZE_1 | SPI_CFG1_DSIZE_0) 00398 /** 00399 * @} 00400 */ 00401 00402 /** @defgroup SPI_LL_EC_FIFO_TH FIFO Threshold 00403 * @{ 00404 */ 00405 #define LL_SPI_FIFO_TH_01DATA (0x00000000UL) 00406 #define LL_SPI_FIFO_TH_02DATA (SPI_CFG1_FTHLV_0) 00407 #define LL_SPI_FIFO_TH_03DATA (SPI_CFG1_FTHLV_1) 00408 #define LL_SPI_FIFO_TH_04DATA (SPI_CFG1_FTHLV_0 | SPI_CFG1_FTHLV_1) 00409 #define LL_SPI_FIFO_TH_05DATA (SPI_CFG1_FTHLV_2) 00410 #define LL_SPI_FIFO_TH_06DATA (SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_0) 00411 #define LL_SPI_FIFO_TH_07DATA (SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_1) 00412 #define LL_SPI_FIFO_TH_08DATA (SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_1 | SPI_CFG1_FTHLV_0) 00413 #define LL_SPI_FIFO_TH_09DATA (SPI_CFG1_FTHLV_3) 00414 #define LL_SPI_FIFO_TH_10DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_0) 00415 #define LL_SPI_FIFO_TH_11DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_1) 00416 #define LL_SPI_FIFO_TH_12DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_1 | SPI_CFG1_FTHLV_0) 00417 #define LL_SPI_FIFO_TH_13DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_2) 00418 #define LL_SPI_FIFO_TH_14DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_0) 00419 #define LL_SPI_FIFO_TH_15DATA (SPI_CFG1_FTHLV_3 | SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_1) 00420 #define LL_SPI_FIFO_TH_16DATA (SPI_CFG1_FTHLV_3\ 00421 | SPI_CFG1_FTHLV_2 | SPI_CFG1_FTHLV_1 | SPI_CFG1_FTHLV_0) 00422 /** 00423 * @} 00424 */ 00425 00426 #if defined(USE_FULL_LL_DRIVER) 00427 00428 /** @defgroup SPI_LL_EC_CRC_CALCULATION CRC Calculation 00429 * @{ 00430 */ 00431 #define LL_SPI_CRCCALCULATION_DISABLE (0x00000000UL) /*!< CRC calculation disabled */ 00432 #define LL_SPI_CRCCALCULATION_ENABLE (SPI_CFG1_CRCEN) /*!< CRC calculation enabled */ 00433 /** 00434 * @} 00435 */ 00436 #endif /* USE_FULL_LL_DRIVER */ 00437 00438 /** @defgroup SPI_LL_EC_CRC CRC 00439 * @{ 00440 */ 00441 #define LL_SPI_CRC_4BIT (SPI_CFG1_CRCSIZE_0 | SPI_CFG1_CRCSIZE_1) 00442 #define LL_SPI_CRC_5BIT (SPI_CFG1_CRCSIZE_2) 00443 #define LL_SPI_CRC_6BIT (SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_0) 00444 #define LL_SPI_CRC_7BIT (SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1) 00445 #define LL_SPI_CRC_8BIT (SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0) 00446 #define LL_SPI_CRC_9BIT (SPI_CFG1_CRCSIZE_3) 00447 #define LL_SPI_CRC_10BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_0) 00448 #define LL_SPI_CRC_11BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_1) 00449 #define LL_SPI_CRC_12BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0) 00450 #define LL_SPI_CRC_13BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2) 00451 #define LL_SPI_CRC_14BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_0) 00452 #define LL_SPI_CRC_15BIT (SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1) 00453 #define LL_SPI_CRC_16BIT (SPI_CFG1_CRCSIZE_3\ 00454 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0) 00455 #define LL_SPI_CRC_17BIT (SPI_CFG1_CRCSIZE_4) 00456 #define LL_SPI_CRC_18BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_0) 00457 #define LL_SPI_CRC_19BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_1) 00458 #define LL_SPI_CRC_20BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_0 | SPI_CFG1_CRCSIZE_1) 00459 #define LL_SPI_CRC_21BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_2) 00460 #define LL_SPI_CRC_22BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_0) 00461 #define LL_SPI_CRC_23BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1) 00462 #define LL_SPI_CRC_24BIT (SPI_CFG1_CRCSIZE_4\ 00463 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0) 00464 #define LL_SPI_CRC_25BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_3) 00465 #define LL_SPI_CRC_26BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_0) 00466 #define LL_SPI_CRC_27BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_1) 00467 #define LL_SPI_CRC_28BIT (SPI_CFG1_CRCSIZE_4\ 00468 | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0) 00469 #define LL_SPI_CRC_29BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2) 00470 #define LL_SPI_CRC_30BIT (SPI_CFG1_CRCSIZE_4\ 00471 | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_0) 00472 #define LL_SPI_CRC_31BIT (SPI_CFG1_CRCSIZE_4\ 00473 | SPI_CFG1_CRCSIZE_3 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1) 00474 #define LL_SPI_CRC_32BIT (SPI_CFG1_CRCSIZE_4 | SPI_CFG1_CRCSIZE_3\ 00475 | SPI_CFG1_CRCSIZE_2 | SPI_CFG1_CRCSIZE_1 | SPI_CFG1_CRCSIZE_0) 00476 /** 00477 * @} 00478 */ 00479 00480 /** @defgroup SPI_LL_EC_NSS_MODE NSS Mode 00481 * @{ 00482 */ 00483 #define LL_SPI_NSS_SOFT (SPI_CFG2_SSM) 00484 #define LL_SPI_NSS_HARD_INPUT (0x00000000UL) 00485 #define LL_SPI_NSS_HARD_OUTPUT (SPI_CFG2_SSOE) 00486 /** 00487 * @} 00488 */ 00489 00490 /** @defgroup SPI_LL_EC_RX_FIFO RxFIFO Packing LeVel 00491 * @{ 00492 */ 00493 #define LL_SPI_RX_FIFO_0PACKET (0x00000000UL) /* 0 or multiple of 4 packet available is the RxFIFO */ 00494 #define LL_SPI_RX_FIFO_1PACKET (SPI_SR_RXPLVL_0) 00495 #define LL_SPI_RX_FIFO_2PACKET (SPI_SR_RXPLVL_1) 00496 #define LL_SPI_RX_FIFO_3PACKET (SPI_SR_RXPLVL_1 | SPI_SR_RXPLVL_0) 00497 /** 00498 * @} 00499 */ 00500 00501 /** 00502 * @} 00503 */ 00504 00505 /* Exported macro ------------------------------------------------------------*/ 00506 /** @defgroup SPI_LL_Exported_Macros SPI Exported Macros 00507 * @{ 00508 */ 00509 00510 /** @defgroup SPI_LL_EM_WRITE_READ Common Write and read registers Macros 00511 * @{ 00512 */ 00513 00514 /** 00515 * @brief Write a value in SPI register 00516 * @param __INSTANCE__ SPI Instance 00517 * @param __REG__ Register to be written 00518 * @param __VALUE__ Value to be written in the register 00519 * @retval None 00520 */ 00521 #define LL_SPI_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 00522 00523 /** 00524 * @brief Read a value in SPI register 00525 * @param __INSTANCE__ SPI Instance 00526 * @param __REG__ Register to be read 00527 * @retval Register value 00528 */ 00529 #define LL_SPI_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 00530 /** 00531 * @} 00532 */ 00533 00534 /** 00535 * @} 00536 */ 00537 00538 00539 /* Exported functions --------------------------------------------------------*/ 00540 00541 /** @defgroup SPI_LL_Exported_Functions SPI Exported Functions 00542 * @{ 00543 */ 00544 00545 /** @defgroup SPI_LL_EF_Configuration Configuration 00546 * @{ 00547 */ 00548 00549 /** 00550 * @brief Enable SPI peripheral 00551 * @rmtoll CR1 SPE LL_SPI_Enable 00552 * @param SPIx SPI Instance 00553 * @retval None 00554 */ 00555 __STATIC_INLINE void LL_SPI_Enable(SPI_TypeDef *SPIx) 00556 { 00557 SET_BIT(SPIx->CR1, SPI_CR1_SPE); 00558 } 00559 00560 /** 00561 * @brief Disable SPI peripheral 00562 * @note When disabling the SPI, follow the procedure described in the Reference Manual. 00563 * @rmtoll CR1 SPE LL_SPI_Disable 00564 * @param SPIx SPI Instance 00565 * @retval None 00566 */ 00567 __STATIC_INLINE void LL_SPI_Disable(SPI_TypeDef *SPIx) 00568 { 00569 CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE); 00570 } 00571 00572 /** 00573 * @brief Check if SPI peripheral is enabled 00574 * @rmtoll CR1 SPE LL_SPI_IsEnabled 00575 * @param SPIx SPI Instance 00576 * @retval State of bit (1 or 0) 00577 */ 00578 __STATIC_INLINE uint32_t LL_SPI_IsEnabled(SPI_TypeDef *SPIx) 00579 { 00580 return ((READ_BIT(SPIx->CR1, SPI_CR1_SPE) == (SPI_CR1_SPE)) ? 1UL : 0UL); 00581 } 00582 00583 /** 00584 * @brief Swap the MOSI and MISO pin 00585 * @note This configuration can not be changed when SPI is enabled. 00586 * @rmtoll CFG2 IOSWP LL_SPI_EnableIOSwap 00587 * @param SPIx SPI Instance 00588 * @retval None 00589 */ 00590 __STATIC_INLINE void LL_SPI_EnableIOSwap(SPI_TypeDef *SPIx) 00591 { 00592 SET_BIT(SPIx->CFG2, SPI_CFG2_IOSWP); 00593 } 00594 00595 /** 00596 * @brief Restore default function for MOSI and MISO pin 00597 * @note This configuration can not be changed when SPI is enabled. 00598 * @rmtoll CFG2 IOSWP LL_SPI_DisableIOSwap 00599 * @param SPIx SPI Instance 00600 * @retval None 00601 */ 00602 __STATIC_INLINE void LL_SPI_DisableIOSwap(SPI_TypeDef *SPIx) 00603 { 00604 CLEAR_BIT(SPIx->CFG2, SPI_CFG2_IOSWP); 00605 } 00606 00607 /** 00608 * @brief Check if MOSI and MISO pin are swapped 00609 * @rmtoll CFG2 IOSWP LL_SPI_IsEnabledIOSwap 00610 * @param SPIx SPI Instance 00611 * @retval State of bit (1 or 0) 00612 */ 00613 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIOSwap(SPI_TypeDef *SPIx) 00614 { 00615 return ((READ_BIT(SPIx->CFG2, SPI_CFG2_IOSWP) == (SPI_CFG2_IOSWP)) ? 1UL : 0UL); 00616 } 00617 00618 /** 00619 * @brief Enable GPIO control 00620 * @note This configuration can not be changed when SPI is enabled. 00621 * @rmtoll CFG2 AFCNTR LL_SPI_EnableGPIOControl 00622 * @param SPIx SPI Instance 00623 * @retval None 00624 */ 00625 __STATIC_INLINE void LL_SPI_EnableGPIOControl(SPI_TypeDef *SPIx) 00626 { 00627 SET_BIT(SPIx->CFG2, SPI_CFG2_AFCNTR); 00628 } 00629 00630 /** 00631 * @brief Disable GPIO control 00632 * @note This configuration can not be changed when SPI is enabled. 00633 * @rmtoll CFG2 AFCNTR LL_SPI_DisableGPIOControl 00634 * @param SPIx SPI Instance 00635 * @retval None 00636 */ 00637 __STATIC_INLINE void LL_SPI_DisableGPIOControl(SPI_TypeDef *SPIx) 00638 { 00639 CLEAR_BIT(SPIx->CFG2, SPI_CFG2_AFCNTR); 00640 } 00641 00642 /** 00643 * @brief Check if GPIO control is active 00644 * @rmtoll CFG2 AFCNTR LL_SPI_IsEnabledGPIOControl 00645 * @param SPIx SPI Instance 00646 * @retval State of bit (1 or 0) 00647 */ 00648 __STATIC_INLINE uint32_t LL_SPI_IsEnabledGPIOControl(SPI_TypeDef *SPIx) 00649 { 00650 return ((READ_BIT(SPIx->CFG2, SPI_CFG2_AFCNTR) == (SPI_CFG2_AFCNTR)) ? 1UL : 0UL); 00651 } 00652 00653 /** 00654 * @brief Set SPI Mode to Master or Slave 00655 * @note This configuration can not be changed when SPI is enabled. 00656 * @rmtoll CFG2 MASTER LL_SPI_SetMode 00657 * @param SPIx SPI Instance 00658 * @param Mode This parameter can be one of the following values: 00659 * @arg @ref LL_SPI_MODE_MASTER 00660 * @arg @ref LL_SPI_MODE_SLAVE 00661 * @retval None 00662 */ 00663 __STATIC_INLINE void LL_SPI_SetMode(SPI_TypeDef *SPIx, uint32_t Mode) 00664 { 00665 MODIFY_REG(SPIx->CFG2, SPI_CFG2_MASTER, Mode); 00666 } 00667 00668 /** 00669 * @brief Get SPI Mode (Master or Slave) 00670 * @rmtoll CFG2 MASTER LL_SPI_GetMode 00671 * @param SPIx SPI Instance 00672 * @retval Returned value can be one of the following values: 00673 * @arg @ref LL_SPI_MODE_MASTER 00674 * @arg @ref LL_SPI_MODE_SLAVE 00675 */ 00676 __STATIC_INLINE uint32_t LL_SPI_GetMode(SPI_TypeDef *SPIx) 00677 { 00678 return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_MASTER)); 00679 } 00680 00681 /** 00682 * @brief Configure the Idleness applied by master between active edge of SS and first send data 00683 * @rmtoll CFG2 MSSI LL_SPI_SetMasterSSIdleness 00684 * @param SPIx SPI Instance 00685 * @param MasterSSIdleness This parameter can be one of the following values: 00686 * @arg @ref LL_SPI_SS_IDLENESS_00CYCLE 00687 * @arg @ref LL_SPI_SS_IDLENESS_01CYCLE 00688 * @arg @ref LL_SPI_SS_IDLENESS_02CYCLE 00689 * @arg @ref LL_SPI_SS_IDLENESS_03CYCLE 00690 * @arg @ref LL_SPI_SS_IDLENESS_04CYCLE 00691 * @arg @ref LL_SPI_SS_IDLENESS_05CYCLE 00692 * @arg @ref LL_SPI_SS_IDLENESS_06CYCLE 00693 * @arg @ref LL_SPI_SS_IDLENESS_07CYCLE 00694 * @arg @ref LL_SPI_SS_IDLENESS_08CYCLE 00695 * @arg @ref LL_SPI_SS_IDLENESS_09CYCLE 00696 * @arg @ref LL_SPI_SS_IDLENESS_10CYCLE 00697 * @arg @ref LL_SPI_SS_IDLENESS_11CYCLE 00698 * @arg @ref LL_SPI_SS_IDLENESS_12CYCLE 00699 * @arg @ref LL_SPI_SS_IDLENESS_13CYCLE 00700 * @arg @ref LL_SPI_SS_IDLENESS_14CYCLE 00701 * @arg @ref LL_SPI_SS_IDLENESS_15CYCLE 00702 * @retval None 00703 */ 00704 __STATIC_INLINE void LL_SPI_SetMasterSSIdleness(SPI_TypeDef *SPIx, uint32_t MasterSSIdleness) 00705 { 00706 MODIFY_REG(SPIx->CFG2, SPI_CFG2_MSSI, MasterSSIdleness); 00707 } 00708 00709 /** 00710 * @brief Get the configured Idleness applied by master 00711 * @rmtoll CFG2 MSSI LL_SPI_GetMasterSSIdleness 00712 * @param SPIx SPI Instance 00713 * @retval Returned value can be one of the following values: 00714 * @arg @ref LL_SPI_SS_IDLENESS_00CYCLE 00715 * @arg @ref LL_SPI_SS_IDLENESS_01CYCLE 00716 * @arg @ref LL_SPI_SS_IDLENESS_02CYCLE 00717 * @arg @ref LL_SPI_SS_IDLENESS_03CYCLE 00718 * @arg @ref LL_SPI_SS_IDLENESS_04CYCLE 00719 * @arg @ref LL_SPI_SS_IDLENESS_05CYCLE 00720 * @arg @ref LL_SPI_SS_IDLENESS_06CYCLE 00721 * @arg @ref LL_SPI_SS_IDLENESS_07CYCLE 00722 * @arg @ref LL_SPI_SS_IDLENESS_08CYCLE 00723 * @arg @ref LL_SPI_SS_IDLENESS_09CYCLE 00724 * @arg @ref LL_SPI_SS_IDLENESS_10CYCLE 00725 * @arg @ref LL_SPI_SS_IDLENESS_11CYCLE 00726 * @arg @ref LL_SPI_SS_IDLENESS_12CYCLE 00727 * @arg @ref LL_SPI_SS_IDLENESS_13CYCLE 00728 * @arg @ref LL_SPI_SS_IDLENESS_14CYCLE 00729 * @arg @ref LL_SPI_SS_IDLENESS_15CYCLE 00730 */ 00731 __STATIC_INLINE uint32_t LL_SPI_GetMasterSSIdleness(SPI_TypeDef *SPIx) 00732 { 00733 return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_MSSI)); 00734 } 00735 00736 /** 00737 * @brief Configure the idleness applied by master between data frame 00738 * @rmtoll CFG2 MIDI LL_SPI_SetInterDataIdleness 00739 * @param SPIx SPI Instance 00740 * @param MasterInterDataIdleness This parameter can be one of the following values: 00741 * @arg @ref LL_SPI_ID_IDLENESS_00CYCLE 00742 * @arg @ref LL_SPI_ID_IDLENESS_01CYCLE 00743 * @arg @ref LL_SPI_ID_IDLENESS_02CYCLE 00744 * @arg @ref LL_SPI_ID_IDLENESS_03CYCLE 00745 * @arg @ref LL_SPI_ID_IDLENESS_04CYCLE 00746 * @arg @ref LL_SPI_ID_IDLENESS_05CYCLE 00747 * @arg @ref LL_SPI_ID_IDLENESS_06CYCLE 00748 * @arg @ref LL_SPI_ID_IDLENESS_07CYCLE 00749 * @arg @ref LL_SPI_ID_IDLENESS_08CYCLE 00750 * @arg @ref LL_SPI_ID_IDLENESS_09CYCLE 00751 * @arg @ref LL_SPI_ID_IDLENESS_10CYCLE 00752 * @arg @ref LL_SPI_ID_IDLENESS_11CYCLE 00753 * @arg @ref LL_SPI_ID_IDLENESS_12CYCLE 00754 * @arg @ref LL_SPI_ID_IDLENESS_13CYCLE 00755 * @arg @ref LL_SPI_ID_IDLENESS_14CYCLE 00756 * @arg @ref LL_SPI_ID_IDLENESS_15CYCLE 00757 * @retval None 00758 */ 00759 __STATIC_INLINE void LL_SPI_SetInterDataIdleness(SPI_TypeDef *SPIx, uint32_t MasterInterDataIdleness) 00760 { 00761 MODIFY_REG(SPIx->CFG2, SPI_CFG2_MIDI, MasterInterDataIdleness); 00762 } 00763 00764 /** 00765 * @brief Get the configured inter data idleness 00766 * @rmtoll CFG2 MIDI LL_SPI_SetInterDataIdleness 00767 * @param SPIx SPI Instance 00768 * @retval Returned value can be one of the following values: 00769 * @arg @ref LL_SPI_ID_IDLENESS_00CYCLE 00770 * @arg @ref LL_SPI_ID_IDLENESS_01CYCLE 00771 * @arg @ref LL_SPI_ID_IDLENESS_02CYCLE 00772 * @arg @ref LL_SPI_ID_IDLENESS_03CYCLE 00773 * @arg @ref LL_SPI_ID_IDLENESS_04CYCLE 00774 * @arg @ref LL_SPI_ID_IDLENESS_05CYCLE 00775 * @arg @ref LL_SPI_ID_IDLENESS_06CYCLE 00776 * @arg @ref LL_SPI_ID_IDLENESS_07CYCLE 00777 * @arg @ref LL_SPI_ID_IDLENESS_08CYCLE 00778 * @arg @ref LL_SPI_ID_IDLENESS_09CYCLE 00779 * @arg @ref LL_SPI_ID_IDLENESS_10CYCLE 00780 * @arg @ref LL_SPI_ID_IDLENESS_11CYCLE 00781 * @arg @ref LL_SPI_ID_IDLENESS_12CYCLE 00782 * @arg @ref LL_SPI_ID_IDLENESS_13CYCLE 00783 * @arg @ref LL_SPI_ID_IDLENESS_14CYCLE 00784 * @arg @ref LL_SPI_ID_IDLENESS_15CYCLE 00785 */ 00786 __STATIC_INLINE uint32_t LL_SPI_GetInterDataIdleness(SPI_TypeDef *SPIx) 00787 { 00788 return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_MIDI)); 00789 } 00790 00791 /** 00792 * @brief Set transfer size 00793 * @note Count is the number of frame to be transferred 00794 * @rmtoll CR2 TSIZE LL_SPI_SetTransferSize 00795 * @param SPIx SPI Instance 00796 * @param Count 0..0xFFFF 00797 * @retval None 00798 */ 00799 __STATIC_INLINE void LL_SPI_SetTransferSize(SPI_TypeDef *SPIx, uint32_t Count) 00800 { 00801 MODIFY_REG(SPIx->CR2, SPI_CR2_TSIZE, Count); 00802 } 00803 00804 /** 00805 * @brief Get transfer size 00806 * @note Count is the number of frame to be transferred 00807 * @rmtoll CR2 TSIZE LL_SPI_GetTransferSize 00808 * @param SPIx SPI Instance 00809 * @retval 0..0xFFFF 00810 */ 00811 __STATIC_INLINE uint32_t LL_SPI_GetTransferSize(SPI_TypeDef *SPIx) 00812 { 00813 return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_TSIZE)); 00814 } 00815 00816 /** 00817 * @brief Set reload transfer size 00818 * @note Count is the number of frame to be transferred 00819 * @rmtoll CR2 TSER LL_SPI_SetReloadSize 00820 * @param SPIx SPI Instance 00821 * @param Count 0..0xFFFF 00822 * @retval None 00823 */ 00824 __STATIC_INLINE void LL_SPI_SetReloadSize(SPI_TypeDef *SPIx, uint32_t Count) 00825 { 00826 MODIFY_REG(SPIx->CR2, SPI_CR2_TSER, Count << SPI_CR2_TSER_Pos); 00827 } 00828 00829 /** 00830 * @brief Get reload transfer size 00831 * @note Count is the number of frame to be transferred 00832 * @rmtoll CR2 TSER LL_SPI_GetReloadSize 00833 * @param SPIx SPI Instance 00834 * @retval 0..0xFFFF 00835 */ 00836 __STATIC_INLINE uint32_t LL_SPI_GetReloadSize(SPI_TypeDef *SPIx) 00837 { 00838 return (uint32_t)(READ_BIT(SPIx->CR2, SPI_CR2_TSER) >> SPI_CR2_TSER_Pos); 00839 } 00840 00841 /** 00842 * @brief Lock the AF configuration of associated IOs 00843 * @note Once this bit is set, the AF configuration remains locked until a hardware reset occurs. 00844 * the reset of the IOLock bit is done by hardware. for that, LL_SPI_DisableIOLock can not exist. 00845 * @rmtoll CR1 IOLOCK LL_SPI_EnableIOLock 00846 * @param SPIx SPI Instance 00847 * @retval None 00848 */ 00849 __STATIC_INLINE void LL_SPI_EnableIOLock(SPI_TypeDef *SPIx) 00850 { 00851 SET_BIT(SPIx->CR1, SPI_CR1_IOLOCK); 00852 } 00853 00854 /** 00855 * @brief Check if the AF configuration is locked. 00856 * @rmtoll CR1 IOLOCK LL_SPI_IsEnabledIOLock 00857 * @param SPIx SPI Instance 00858 * @retval State of bit (1 or 0) 00859 */ 00860 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIOLock(SPI_TypeDef *SPIx) 00861 { 00862 return ((READ_BIT(SPIx->CR1, SPI_CR1_IOLOCK) == (SPI_CR1_IOLOCK)) ? 1UL : 0UL); 00863 } 00864 00865 /** 00866 * @brief Set Tx CRC Initialization Pattern 00867 * @rmtoll CR1 TCRCINI LL_SPI_SetTxCRCInitPattern 00868 * @param SPIx SPI Instance 00869 * @param TXCRCInitAll This parameter can be one of the following values: 00870 * @arg @ref LL_SPI_TXCRCINIT_ALL_ZERO_PATTERN 00871 * @arg @ref LL_SPI_TXCRCINIT_ALL_ONES_PATTERN 00872 * @retval None 00873 */ 00874 __STATIC_INLINE void LL_SPI_SetTxCRCInitPattern(SPI_TypeDef *SPIx, uint32_t TXCRCInitAll) 00875 { 00876 MODIFY_REG(SPIx->CR1, SPI_CR1_RCRCINI, TXCRCInitAll); 00877 } 00878 00879 /** 00880 * @brief Get Tx CRC Initialization Pattern 00881 * @rmtoll CR1 TCRCINI LL_SPI_GetTxCRCInitPattern 00882 * @param SPIx SPI Instance 00883 * @retval Returned value can be one of the following values: 00884 * @arg @ref LL_SPI_TXCRCINIT_ALL_ZERO_PATTERN 00885 * @arg @ref LL_SPI_TXCRCINIT_ALL_ONES_PATTERN 00886 */ 00887 __STATIC_INLINE uint32_t LL_SPI_GetTxCRCInitPattern(SPI_TypeDef *SPIx) 00888 { 00889 return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_TCRCINI)); 00890 } 00891 00892 /** 00893 * @brief Set Rx CRC Initialization Pattern 00894 * @rmtoll CR1 RCRCINI LL_SPI_SetRxCRCInitPattern 00895 * @param SPIx SPI Instance 00896 * @param RXCRCInitAll This parameter can be one of the following values: 00897 * @arg @ref LL_SPI_RXCRCINIT_ALL_ZERO_PATTERN 00898 * @arg @ref LL_SPI_RXCRCINIT_ALL_ONES_PATTERN 00899 * @retval None 00900 */ 00901 __STATIC_INLINE void LL_SPI_SetRxCRCInitPattern(SPI_TypeDef *SPIx, uint32_t RXCRCInitAll) 00902 { 00903 MODIFY_REG(SPIx->CR1, SPI_CR1_RCRCINI, RXCRCInitAll); 00904 } 00905 00906 /** 00907 * @brief Get Rx CRC Initialization Pattern 00908 * @rmtoll CR1 RCRCINI LL_SPI_GetRxCRCInitPattern 00909 * @param SPIx SPI Instance 00910 * @retval Returned value can be one of the following values: 00911 * @arg @ref LL_SPI_RXCRCINIT_ALL_ZERO_PATTERN 00912 * @arg @ref LL_SPI_RXCRCINIT_ALL_ONES_PATTERN 00913 */ 00914 __STATIC_INLINE uint32_t LL_SPI_GetRxCRCInitPattern(SPI_TypeDef *SPIx) 00915 { 00916 return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_RCRCINI)); 00917 } 00918 00919 /** 00920 * @brief Set internal SS input level ignoring what comes from PIN. 00921 * @note This configuration has effect only with config LL_SPI_NSS_SOFT 00922 * @rmtoll CR1 SSI LL_SPI_SetInternalSSLevel 00923 * @param SPIx SPI Instance 00924 * @param SSLevel This parameter can be one of the following values: 00925 * @arg @ref LL_SPI_SS_LEVEL_HIGH 00926 * @arg @ref LL_SPI_SS_LEVEL_LOW 00927 * @retval None 00928 */ 00929 __STATIC_INLINE void LL_SPI_SetInternalSSLevel(SPI_TypeDef *SPIx, uint32_t SSLevel) 00930 { 00931 MODIFY_REG(SPIx->CR1, SPI_CR1_SSI, SSLevel); 00932 } 00933 00934 /** 00935 * @brief Get internal SS input level 00936 * @rmtoll CR1 SSI LL_SPI_GetInternalSSLevel 00937 * @param SPIx SPI Instance 00938 * @retval Returned value can be one of the following values: 00939 * @arg @ref LL_SPI_SS_LEVEL_HIGH 00940 * @arg @ref LL_SPI_SS_LEVEL_LOW 00941 */ 00942 __STATIC_INLINE uint32_t LL_SPI_GetInternalSSLevel(SPI_TypeDef *SPIx) 00943 { 00944 return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_SSI)); 00945 } 00946 00947 /** 00948 * @brief Enable CRC computation on 33/17 bits 00949 * @rmtoll CR1 CRC33_17 LL_SPI_EnableFullSizeCRC 00950 * @param SPIx SPI Instance 00951 * @retval None 00952 */ 00953 __STATIC_INLINE void LL_SPI_EnableFullSizeCRC(SPI_TypeDef *SPIx) 00954 { 00955 SET_BIT(SPIx->CR1, SPI_CR1_CRC33_17); 00956 } 00957 00958 /** 00959 * @brief Disable CRC computation on 33/17 bits 00960 * @rmtoll CR1 CRC33_17 LL_SPI_DisableFullSizeCRC 00961 * @param SPIx SPI Instance 00962 * @retval None 00963 */ 00964 __STATIC_INLINE void LL_SPI_DisableFullSizeCRC(SPI_TypeDef *SPIx) 00965 { 00966 CLEAR_BIT(SPIx->CR1, SPI_CR1_CRC33_17); 00967 } 00968 00969 /** 00970 * @brief Check if Enable CRC computation on 33/17 bits is enabled 00971 * @rmtoll CR1 CRC33_17 LL_SPI_IsEnabledFullSizeCRC 00972 * @param SPIx SPI Instance 00973 * @retval State of bit (1 or 0) 00974 */ 00975 __STATIC_INLINE uint32_t LL_SPI_IsEnabledFullSizeCRC(SPI_TypeDef *SPIx) 00976 { 00977 return ((READ_BIT(SPIx->CR1, SPI_CR1_CRC33_17) == (SPI_CR1_CRC33_17)) ? 1UL : 0UL); 00978 } 00979 00980 /** 00981 * @brief Suspend an ongoing transfer for Master configuration 00982 * @rmtoll CR1 CSUSP LL_SPI_SuspendMasterTransfer 00983 * @param SPIx SPI Instance 00984 * @retval None 00985 */ 00986 __STATIC_INLINE void LL_SPI_SuspendMasterTransfer(SPI_TypeDef *SPIx) 00987 { 00988 SET_BIT(SPIx->CR1, SPI_CR1_CSUSP); 00989 } 00990 00991 /** 00992 * @brief Start effective transfer on wire for Master configuration 00993 * @rmtoll CR1 CSTART LL_SPI_StartMasterTransfer 00994 * @param SPIx SPI Instance 00995 * @retval None 00996 */ 00997 __STATIC_INLINE void LL_SPI_StartMasterTransfer(SPI_TypeDef *SPIx) 00998 { 00999 SET_BIT(SPIx->CR1, SPI_CR1_CSTART); 01000 } 01001 01002 /** 01003 * @brief Check if there is an unfinished master transfer 01004 * @rmtoll CR1 CSTART LL_SPI_IsActiveMasterTransfer 01005 * @param SPIx SPI Instance 01006 * @retval State of bit (1 or 0) 01007 */ 01008 __STATIC_INLINE uint32_t LL_SPI_IsActiveMasterTransfer(SPI_TypeDef *SPIx) 01009 { 01010 return ((READ_BIT(SPIx->CR1, SPI_CR1_CSTART) == (SPI_CR1_CSTART)) ? 1UL : 0UL); 01011 } 01012 01013 /** 01014 * @brief Enable Master Rx auto suspend in case of overrun 01015 * @rmtoll CR1 MASRX LL_SPI_EnableMasterRxAutoSuspend 01016 * @param SPIx SPI Instance 01017 * @retval None 01018 */ 01019 __STATIC_INLINE void LL_SPI_EnableMasterRxAutoSuspend(SPI_TypeDef *SPIx) 01020 { 01021 SET_BIT(SPIx->CR1, SPI_CR1_MASRX); 01022 } 01023 01024 /** 01025 * @brief Disable Master Rx auto suspend in case of overrun 01026 * @rmtoll CR1 MASRX LL_SPI_DisableMasterRxAutoSuspend 01027 * @param SPIx SPI Instance 01028 * @retval None 01029 */ 01030 __STATIC_INLINE void LL_SPI_DisableMasterRxAutoSuspend(SPI_TypeDef *SPIx) 01031 { 01032 CLEAR_BIT(SPIx->CR1, SPI_CR1_MASRX); 01033 } 01034 01035 /** 01036 * @brief Check if Master Rx auto suspend is activated 01037 * @rmtoll CR1 MASRX LL_SPI_IsEnabledMasterRxAutoSuspend 01038 * @param SPIx SPI Instance 01039 * @retval State of bit (1 or 0) 01040 */ 01041 __STATIC_INLINE uint32_t LL_SPI_IsEnabledMasterRxAutoSuspend(SPI_TypeDef *SPIx) 01042 { 01043 return ((READ_BIT(SPIx->CR1, SPI_CR1_MASRX) == (SPI_CR1_MASRX)) ? 1UL : 0UL); 01044 } 01045 01046 /** 01047 * @brief Set Underrun behavior 01048 * @note This configuration can not be changed when SPI is enabled. 01049 * @rmtoll CFG1 UDRCFG LL_SPI_SetUDRConfiguration 01050 * @param SPIx SPI Instance 01051 * @param UDRConfig This parameter can be one of the following values: 01052 * @arg @ref LL_SPI_UDR_CONFIG_REGISTER_PATTERN 01053 * @arg @ref LL_SPI_UDR_CONFIG_LAST_RECEIVED 01054 * @arg @ref LL_SPI_UDR_CONFIG_LAST_TRANSMITTED 01055 * @retval None 01056 */ 01057 __STATIC_INLINE void LL_SPI_SetUDRConfiguration(SPI_TypeDef *SPIx, uint32_t UDRConfig) 01058 { 01059 MODIFY_REG(SPIx->CFG1, SPI_CFG1_UDRCFG, UDRConfig); 01060 } 01061 01062 /** 01063 * @brief Get Underrun behavior 01064 * @rmtoll CFG1 UDRCFG LL_SPI_GetUDRConfiguration 01065 * @param SPIx SPI Instance 01066 * @retval Returned value can be one of the following values: 01067 * @arg @ref LL_SPI_UDR_CONFIG_REGISTER_PATTERN 01068 * @arg @ref LL_SPI_UDR_CONFIG_LAST_RECEIVED 01069 * @arg @ref LL_SPI_UDR_CONFIG_LAST_TRANSMITTED 01070 */ 01071 __STATIC_INLINE uint32_t LL_SPI_GetUDRConfiguration(SPI_TypeDef *SPIx) 01072 { 01073 return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_UDRCFG)); 01074 } 01075 01076 /** 01077 * @brief Set Underrun Detection method 01078 * @note This configuration can not be changed when SPI is enabled. 01079 * @rmtoll CFG1 UDRDET LL_SPI_SetUDRDetection 01080 * @param SPIx SPI Instance 01081 * @param UDRDetection This parameter can be one of the following values: 01082 * @arg @ref LL_SPI_UDR_DETECT_BEGIN_DATA_FRAME 01083 * @arg @ref LL_SPI_UDR_DETECT_END_DATA_FRAME 01084 * @arg @ref LL_SPI_UDR_DETECT_BEGIN_ACTIVE_NSS 01085 * @retval None 01086 */ 01087 __STATIC_INLINE void LL_SPI_SetUDRDetection(SPI_TypeDef *SPIx, uint32_t UDRDetection) 01088 { 01089 MODIFY_REG(SPIx->CFG1, SPI_CFG1_UDRDET, UDRDetection); 01090 } 01091 01092 /** 01093 * @brief Get Underrun Detection method 01094 * @rmtoll CFG1 UDRDET LL_SPI_GetUDRDetection 01095 * @param SPIx SPI Instance 01096 * @retval Returned value can be one of the following values: 01097 * @arg @ref LL_SPI_UDR_DETECT_BEGIN_DATA_FRAME 01098 * @arg @ref LL_SPI_UDR_DETECT_END_DATA_FRAME 01099 * @arg @ref LL_SPI_UDR_DETECT_BEGIN_ACTIVE_NSS 01100 */ 01101 __STATIC_INLINE uint32_t LL_SPI_GetUDRDetection(SPI_TypeDef *SPIx) 01102 { 01103 return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_UDRDET)); 01104 } 01105 01106 /** 01107 * @brief Set Serial protocol used 01108 * @note This configuration can not be changed when SPI is enabled. 01109 * @rmtoll CFG2 SP LL_SPI_SetStandard 01110 * @param SPIx SPI Instance 01111 * @param Standard This parameter can be one of the following values: 01112 * @arg @ref LL_SPI_PROTOCOL_MOTOROLA 01113 * @arg @ref LL_SPI_PROTOCOL_TI 01114 * @retval None 01115 */ 01116 __STATIC_INLINE void LL_SPI_SetStandard(SPI_TypeDef *SPIx, uint32_t Standard) 01117 { 01118 MODIFY_REG(SPIx->CFG2, SPI_CFG2_SP, Standard); 01119 } 01120 01121 /** 01122 * @brief Get Serial protocol used 01123 * @rmtoll CFG2 SP LL_SPI_GetStandard 01124 * @param SPIx SPI Instance 01125 * @retval Returned value can be one of the following values: 01126 * @arg @ref LL_SPI_PROTOCOL_MOTOROLA 01127 * @arg @ref LL_SPI_PROTOCOL_TI 01128 */ 01129 __STATIC_INLINE uint32_t LL_SPI_GetStandard(SPI_TypeDef *SPIx) 01130 { 01131 return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_SP)); 01132 } 01133 01134 /** 01135 * @brief Set Clock phase 01136 * @note This configuration can not be changed when SPI is enabled. 01137 * This bit is not used in SPI TI mode. 01138 * @rmtoll CFG2 CPHA LL_SPI_SetClockPhase 01139 * @param SPIx SPI Instance 01140 * @param ClockPhase This parameter can be one of the following values: 01141 * @arg @ref LL_SPI_PHASE_1EDGE 01142 * @arg @ref LL_SPI_PHASE_2EDGE 01143 * @retval None 01144 */ 01145 __STATIC_INLINE void LL_SPI_SetClockPhase(SPI_TypeDef *SPIx, uint32_t ClockPhase) 01146 { 01147 MODIFY_REG(SPIx->CFG2, SPI_CFG2_CPHA, ClockPhase); 01148 } 01149 01150 /** 01151 * @brief Get Clock phase 01152 * @rmtoll CFG2 CPHA LL_SPI_GetClockPhase 01153 * @param SPIx SPI Instance 01154 * @retval Returned value can be one of the following values: 01155 * @arg @ref LL_SPI_PHASE_1EDGE 01156 * @arg @ref LL_SPI_PHASE_2EDGE 01157 */ 01158 __STATIC_INLINE uint32_t LL_SPI_GetClockPhase(SPI_TypeDef *SPIx) 01159 { 01160 return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_CPHA)); 01161 } 01162 01163 /** 01164 * @brief Set Clock polarity 01165 * @note This configuration can not be changed when SPI is enabled. 01166 * This bit is not used in SPI TI mode. 01167 * @rmtoll CFG2 CPOL LL_SPI_SetClockPolarity 01168 * @param SPIx SPI Instance 01169 * @param ClockPolarity This parameter can be one of the following values: 01170 * @arg @ref LL_SPI_POLARITY_LOW 01171 * @arg @ref LL_SPI_POLARITY_HIGH 01172 * @retval None 01173 */ 01174 __STATIC_INLINE void LL_SPI_SetClockPolarity(SPI_TypeDef *SPIx, uint32_t ClockPolarity) 01175 { 01176 MODIFY_REG(SPIx->CFG2, SPI_CFG2_CPOL, ClockPolarity); 01177 } 01178 01179 /** 01180 * @brief Get Clock polarity 01181 * @rmtoll CFG2 CPOL LL_SPI_GetClockPolarity 01182 * @param SPIx SPI Instance 01183 * @retval Returned value can be one of the following values: 01184 * @arg @ref LL_SPI_POLARITY_LOW 01185 * @arg @ref LL_SPI_POLARITY_HIGH 01186 */ 01187 __STATIC_INLINE uint32_t LL_SPI_GetClockPolarity(SPI_TypeDef *SPIx) 01188 { 01189 return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_CPOL)); 01190 } 01191 01192 /** 01193 * @brief Set NSS polarity 01194 * @note This configuration can not be changed when SPI is enabled. 01195 * This bit is not used in SPI TI mode. 01196 * @rmtoll CFG2 SSIOP LL_SPI_SetNSSPolarity 01197 * @param SPIx SPI Instance 01198 * @param NSSPolarity This parameter can be one of the following values: 01199 * @arg @ref LL_SPI_NSS_POLARITY_LOW 01200 * @arg @ref LL_SPI_NSS_POLARITY_HIGH 01201 * @retval None 01202 */ 01203 __STATIC_INLINE void LL_SPI_SetNSSPolarity(SPI_TypeDef *SPIx, uint32_t NSSPolarity) 01204 { 01205 MODIFY_REG(SPIx->CFG2, SPI_CFG2_SSIOP, NSSPolarity); 01206 } 01207 01208 /** 01209 * @brief Get NSS polarity 01210 * @rmtoll CFG2 SSIOP LL_SPI_GetNSSPolarity 01211 * @param SPIx SPI Instance 01212 * @retval Returned value can be one of the following values: 01213 * @arg @ref LL_SPI_NSS_POLARITY_LOW 01214 * @arg @ref LL_SPI_NSS_POLARITY_HIGH 01215 */ 01216 __STATIC_INLINE uint32_t LL_SPI_GetNSSPolarity(SPI_TypeDef *SPIx) 01217 { 01218 return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_SSIOP)); 01219 } 01220 01221 /** 01222 * @brief Set Baudrate Prescaler 01223 * @note This configuration can not be changed when SPI is enabled. 01224 * SPI BaudRate = fPCLK/Pescaler. 01225 * @rmtoll CFG1 MBR LL_SPI_SetBaudRatePrescaler 01226 * @param SPIx SPI Instance 01227 * @param Baudrate This parameter can be one of the following values: 01228 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV2 01229 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV4 01230 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV8 01231 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV16 01232 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV32 01233 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV64 01234 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128 01235 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256 01236 * @retval None 01237 */ 01238 __STATIC_INLINE void LL_SPI_SetBaudRatePrescaler(SPI_TypeDef *SPIx, uint32_t Baudrate) 01239 { 01240 MODIFY_REG(SPIx->CFG1, SPI_CFG1_MBR, Baudrate); 01241 } 01242 01243 /** 01244 * @brief Get Baudrate Prescaler 01245 * @rmtoll CFG1 MBR LL_SPI_GetBaudRatePrescaler 01246 * @param SPIx SPI Instance 01247 * @retval Returned value can be one of the following values: 01248 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV2 01249 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV4 01250 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV8 01251 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV16 01252 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV32 01253 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV64 01254 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV128 01255 * @arg @ref LL_SPI_BAUDRATEPRESCALER_DIV256 01256 */ 01257 __STATIC_INLINE uint32_t LL_SPI_GetBaudRatePrescaler(SPI_TypeDef *SPIx) 01258 { 01259 return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_MBR)); 01260 } 01261 01262 /** 01263 * @brief Set Transfer Bit Order 01264 * @note This configuration can not be changed when SPI is enabled. 01265 * This bit is not used in SPI TI mode. 01266 * @rmtoll CFG2 LSBFRST LL_SPI_SetTransferBitOrder 01267 * @param SPIx SPI Instance 01268 * @param BitOrder This parameter can be one of the following values: 01269 * @arg @ref LL_SPI_LSB_FIRST 01270 * @arg @ref LL_SPI_MSB_FIRST 01271 * @retval None 01272 */ 01273 __STATIC_INLINE void LL_SPI_SetTransferBitOrder(SPI_TypeDef *SPIx, uint32_t BitOrder) 01274 { 01275 MODIFY_REG(SPIx->CFG2, SPI_CFG2_LSBFRST, BitOrder); 01276 } 01277 01278 /** 01279 * @brief Get Transfer Bit Order 01280 * @rmtoll CFG2 LSBFRST LL_SPI_GetTransferBitOrder 01281 * @param SPIx SPI Instance 01282 * @retval Returned value can be one of the following values: 01283 * @arg @ref LL_SPI_LSB_FIRST 01284 * @arg @ref LL_SPI_MSB_FIRST 01285 */ 01286 __STATIC_INLINE uint32_t LL_SPI_GetTransferBitOrder(SPI_TypeDef *SPIx) 01287 { 01288 return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_LSBFRST)); 01289 } 01290 01291 /** 01292 * @brief Set Transfer Mode 01293 * @note This configuration can not be changed when SPI is enabled except for half duplex direction 01294 * using LL_SPI_SetHalfDuplexDirection. 01295 * @rmtoll CR1 HDDIR LL_SPI_SetTransferDirection\n 01296 * CFG2 COMM LL_SPI_SetTransferDirection 01297 * @param SPIx SPI Instance 01298 * @param TransferDirection This parameter can be one of the following values: 01299 * @arg @ref LL_SPI_FULL_DUPLEX 01300 * @arg @ref LL_SPI_SIMPLEX_TX 01301 * @arg @ref LL_SPI_SIMPLEX_RX 01302 * @arg @ref LL_SPI_HALF_DUPLEX_RX 01303 * @arg @ref LL_SPI_HALF_DUPLEX_TX 01304 * @retval None 01305 */ 01306 __STATIC_INLINE void LL_SPI_SetTransferDirection(SPI_TypeDef *SPIx, uint32_t TransferDirection) 01307 { 01308 MODIFY_REG(SPIx->CR1, SPI_CR1_HDDIR, TransferDirection & SPI_CR1_HDDIR); 01309 MODIFY_REG(SPIx->CFG2, SPI_CFG2_COMM, TransferDirection & SPI_CFG2_COMM); 01310 } 01311 01312 /** 01313 * @brief Get Transfer Mode 01314 * @rmtoll CR1 HDDIR LL_SPI_GetTransferDirection\n 01315 * CFG2 COMM LL_SPI_GetTransferDirection 01316 * @param SPIx SPI Instance 01317 * @retval Returned value can be one of the following values: 01318 * @arg @ref LL_SPI_FULL_DUPLEX 01319 * @arg @ref LL_SPI_SIMPLEX_TX 01320 * @arg @ref LL_SPI_SIMPLEX_RX 01321 * @arg @ref LL_SPI_HALF_DUPLEX_RX 01322 * @arg @ref LL_SPI_HALF_DUPLEX_TX 01323 */ 01324 __STATIC_INLINE uint32_t LL_SPI_GetTransferDirection(SPI_TypeDef *SPIx) 01325 { 01326 uint32_t Hddir = READ_BIT(SPIx->CR1, SPI_CR1_HDDIR); 01327 uint32_t Comm = READ_BIT(SPIx->CFG2, SPI_CFG2_COMM); 01328 return (Hddir | Comm); 01329 } 01330 01331 /** 01332 * @brief Set direction for Half-Duplex Mode 01333 * @note In master mode the MOSI pin is used and in slave mode the MISO pin is used for Half-Duplex. 01334 * @rmtoll CR1 HDDIR LL_SPI_SetHalfDuplexDirection 01335 * @param SPIx SPI Instance 01336 * @param HalfDuplexDirection This parameter can be one of the following values: 01337 * @arg @ref LL_SPI_HALF_DUPLEX_RX 01338 * @arg @ref LL_SPI_HALF_DUPLEX_TX 01339 * @retval None 01340 */ 01341 __STATIC_INLINE void LL_SPI_SetHalfDuplexDirection(SPI_TypeDef *SPIx, uint32_t HalfDuplexDirection) 01342 { 01343 MODIFY_REG(SPIx->CR1, SPI_CR1_HDDIR, HalfDuplexDirection & SPI_CR1_HDDIR); 01344 } 01345 01346 /** 01347 * @brief Get direction for Half-Duplex Mode 01348 * @note In master mode the MOSI pin is used and in slave mode the MISO pin is used for Half-Duplex. 01349 * @rmtoll CR1 HDDIR LL_SPI_GetHalfDuplexDirection 01350 * @param SPIx SPI Instance 01351 * @retval Returned value can be one of the following values: 01352 * @arg @ref LL_SPI_HALF_DUPLEX_RX 01353 * @arg @ref LL_SPI_HALF_DUPLEX_TX 01354 */ 01355 __STATIC_INLINE uint32_t LL_SPI_GetHalfDuplexDirection(SPI_TypeDef *SPIx) 01356 { 01357 return (uint32_t)(READ_BIT(SPIx->CR1, SPI_CR1_HDDIR) | SPI_CFG2_COMM); 01358 } 01359 01360 /** 01361 * @brief Set Frame Data Size 01362 * @note This configuration can not be changed when SPI is enabled. 01363 * @rmtoll CFG1 DSIZE LL_SPI_SetDataWidth 01364 * @param SPIx SPI Instance 01365 * @param DataWidth This parameter can be one of the following values: 01366 * @arg @ref LL_SPI_DATAWIDTH_4BIT 01367 * @arg @ref LL_SPI_DATAWIDTH_5BIT 01368 * @arg @ref LL_SPI_DATAWIDTH_6BIT 01369 * @arg @ref LL_SPI_DATAWIDTH_7BIT 01370 * @arg @ref LL_SPI_DATAWIDTH_8BIT 01371 * @arg @ref LL_SPI_DATAWIDTH_9BIT 01372 * @arg @ref LL_SPI_DATAWIDTH_10BIT 01373 * @arg @ref LL_SPI_DATAWIDTH_11BIT 01374 * @arg @ref LL_SPI_DATAWIDTH_12BIT 01375 * @arg @ref LL_SPI_DATAWIDTH_13BIT 01376 * @arg @ref LL_SPI_DATAWIDTH_14BIT 01377 * @arg @ref LL_SPI_DATAWIDTH_15BIT 01378 * @arg @ref LL_SPI_DATAWIDTH_16BIT 01379 * @arg @ref LL_SPI_DATAWIDTH_17BIT 01380 * @arg @ref LL_SPI_DATAWIDTH_18BIT 01381 * @arg @ref LL_SPI_DATAWIDTH_19BIT 01382 * @arg @ref LL_SPI_DATAWIDTH_20BIT 01383 * @arg @ref LL_SPI_DATAWIDTH_21BIT 01384 * @arg @ref LL_SPI_DATAWIDTH_22BIT 01385 * @arg @ref LL_SPI_DATAWIDTH_23BIT 01386 * @arg @ref LL_SPI_DATAWIDTH_24BIT 01387 * @arg @ref LL_SPI_DATAWIDTH_25BIT 01388 * @arg @ref LL_SPI_DATAWIDTH_26BIT 01389 * @arg @ref LL_SPI_DATAWIDTH_27BIT 01390 * @arg @ref LL_SPI_DATAWIDTH_28BIT 01391 * @arg @ref LL_SPI_DATAWIDTH_29BIT 01392 * @arg @ref LL_SPI_DATAWIDTH_30BIT 01393 * @arg @ref LL_SPI_DATAWIDTH_31BIT 01394 * @arg @ref LL_SPI_DATAWIDTH_32BIT 01395 * @retval None 01396 */ 01397 __STATIC_INLINE void LL_SPI_SetDataWidth(SPI_TypeDef *SPIx, uint32_t DataWidth) 01398 { 01399 MODIFY_REG(SPIx->CFG1, SPI_CFG1_DSIZE, DataWidth); 01400 } 01401 01402 /** 01403 * @brief Get Frame Data Size 01404 * @rmtoll CFG1 DSIZE LL_SPI_GetDataWidth 01405 * @param SPIx SPI Instance 01406 * @retval Returned value can be one of the following values: 01407 * @arg @ref LL_SPI_DATAWIDTH_4BIT 01408 * @arg @ref LL_SPI_DATAWIDTH_5BIT 01409 * @arg @ref LL_SPI_DATAWIDTH_6BIT 01410 * @arg @ref LL_SPI_DATAWIDTH_7BIT 01411 * @arg @ref LL_SPI_DATAWIDTH_8BIT 01412 * @arg @ref LL_SPI_DATAWIDTH_9BIT 01413 * @arg @ref LL_SPI_DATAWIDTH_10BIT 01414 * @arg @ref LL_SPI_DATAWIDTH_11BIT 01415 * @arg @ref LL_SPI_DATAWIDTH_12BIT 01416 * @arg @ref LL_SPI_DATAWIDTH_13BIT 01417 * @arg @ref LL_SPI_DATAWIDTH_14BIT 01418 * @arg @ref LL_SPI_DATAWIDTH_15BIT 01419 * @arg @ref LL_SPI_DATAWIDTH_16BIT 01420 * @arg @ref LL_SPI_DATAWIDTH_17BIT 01421 * @arg @ref LL_SPI_DATAWIDTH_18BIT 01422 * @arg @ref LL_SPI_DATAWIDTH_19BIT 01423 * @arg @ref LL_SPI_DATAWIDTH_20BIT 01424 * @arg @ref LL_SPI_DATAWIDTH_21BIT 01425 * @arg @ref LL_SPI_DATAWIDTH_22BIT 01426 * @arg @ref LL_SPI_DATAWIDTH_23BIT 01427 * @arg @ref LL_SPI_DATAWIDTH_24BIT 01428 * @arg @ref LL_SPI_DATAWIDTH_25BIT 01429 * @arg @ref LL_SPI_DATAWIDTH_26BIT 01430 * @arg @ref LL_SPI_DATAWIDTH_27BIT 01431 * @arg @ref LL_SPI_DATAWIDTH_28BIT 01432 * @arg @ref LL_SPI_DATAWIDTH_29BIT 01433 * @arg @ref LL_SPI_DATAWIDTH_30BIT 01434 * @arg @ref LL_SPI_DATAWIDTH_31BIT 01435 * @arg @ref LL_SPI_DATAWIDTH_32BIT 01436 */ 01437 __STATIC_INLINE uint32_t LL_SPI_GetDataWidth(SPI_TypeDef *SPIx) 01438 { 01439 return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_DSIZE)); 01440 } 01441 01442 /** 01443 * @brief Set threshold of FIFO that triggers a transfer event 01444 * @note This configuration can not be changed when SPI is enabled. 01445 * @rmtoll CFG1 FTHLV LL_SPI_SetFIFOThreshold 01446 * @param SPIx SPI Instance 01447 * @param Threshold This parameter can be one of the following values: 01448 * @arg @ref LL_SPI_FIFO_TH_01DATA 01449 * @arg @ref LL_SPI_FIFO_TH_02DATA 01450 * @arg @ref LL_SPI_FIFO_TH_03DATA 01451 * @arg @ref LL_SPI_FIFO_TH_04DATA 01452 * @arg @ref LL_SPI_FIFO_TH_05DATA 01453 * @arg @ref LL_SPI_FIFO_TH_06DATA 01454 * @arg @ref LL_SPI_FIFO_TH_07DATA 01455 * @arg @ref LL_SPI_FIFO_TH_08DATA 01456 * @arg @ref LL_SPI_FIFO_TH_09DATA 01457 * @arg @ref LL_SPI_FIFO_TH_10DATA 01458 * @arg @ref LL_SPI_FIFO_TH_11DATA 01459 * @arg @ref LL_SPI_FIFO_TH_12DATA 01460 * @arg @ref LL_SPI_FIFO_TH_13DATA 01461 * @arg @ref LL_SPI_FIFO_TH_14DATA 01462 * @arg @ref LL_SPI_FIFO_TH_15DATA 01463 * @arg @ref LL_SPI_FIFO_TH_16DATA 01464 * @retval None 01465 */ 01466 __STATIC_INLINE void LL_SPI_SetFIFOThreshold(SPI_TypeDef *SPIx, uint32_t Threshold) 01467 { 01468 MODIFY_REG(SPIx->CFG1, SPI_CFG1_FTHLV, Threshold); 01469 } 01470 01471 /** 01472 * @brief Get threshold of FIFO that triggers a transfer event 01473 * @rmtoll CFG1 FTHLV LL_SPI_GetFIFOThreshold 01474 * @param SPIx SPI Instance 01475 * @retval Returned value can be one of the following values: 01476 * @arg @ref LL_SPI_FIFO_TH_01DATA 01477 * @arg @ref LL_SPI_FIFO_TH_02DATA 01478 * @arg @ref LL_SPI_FIFO_TH_03DATA 01479 * @arg @ref LL_SPI_FIFO_TH_04DATA 01480 * @arg @ref LL_SPI_FIFO_TH_05DATA 01481 * @arg @ref LL_SPI_FIFO_TH_06DATA 01482 * @arg @ref LL_SPI_FIFO_TH_07DATA 01483 * @arg @ref LL_SPI_FIFO_TH_08DATA 01484 * @arg @ref LL_SPI_FIFO_TH_09DATA 01485 * @arg @ref LL_SPI_FIFO_TH_10DATA 01486 * @arg @ref LL_SPI_FIFO_TH_11DATA 01487 * @arg @ref LL_SPI_FIFO_TH_12DATA 01488 * @arg @ref LL_SPI_FIFO_TH_13DATA 01489 * @arg @ref LL_SPI_FIFO_TH_14DATA 01490 * @arg @ref LL_SPI_FIFO_TH_15DATA 01491 * @arg @ref LL_SPI_FIFO_TH_16DATA 01492 */ 01493 __STATIC_INLINE uint32_t LL_SPI_GetFIFOThreshold(SPI_TypeDef *SPIx) 01494 { 01495 return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_FTHLV)); 01496 } 01497 01498 /** 01499 * @brief Enable CRC 01500 * @note This configuration can not be changed when SPI is enabled. 01501 * @rmtoll CFG1 CRCEN LL_SPI_EnableCRC 01502 * @param SPIx SPI Instance 01503 * @retval None 01504 */ 01505 __STATIC_INLINE void LL_SPI_EnableCRC(SPI_TypeDef *SPIx) 01506 { 01507 SET_BIT(SPIx->CFG1, SPI_CFG1_CRCEN); 01508 } 01509 01510 /** 01511 * @brief Disable CRC 01512 * @rmtoll CFG1 CRCEN LL_SPI_DisableCRC 01513 * @param SPIx SPI Instance 01514 * @retval None 01515 */ 01516 __STATIC_INLINE void LL_SPI_DisableCRC(SPI_TypeDef *SPIx) 01517 { 01518 CLEAR_BIT(SPIx->CFG1, SPI_CFG1_CRCEN); 01519 } 01520 01521 /** 01522 * @brief Check if CRC is enabled 01523 * @rmtoll CFG1 CRCEN LL_SPI_IsEnabledCRC 01524 * @param SPIx SPI Instance 01525 * @retval State of bit (1 or 0). 01526 */ 01527 __STATIC_INLINE uint32_t LL_SPI_IsEnabledCRC(SPI_TypeDef *SPIx) 01528 { 01529 return ((READ_BIT(SPIx->CFG1, SPI_CFG1_CRCEN) == SPI_CFG1_CRCEN) ? 1UL : 0UL); 01530 } 01531 01532 /** 01533 * @brief Set CRC Length 01534 * @note This configuration can not be changed when SPI is enabled. 01535 * @rmtoll CFG1 CRCSIZE LL_SPI_SetCRCWidth 01536 * @param SPIx SPI Instance 01537 * @param CRCLength This parameter can be one of the following values: 01538 * @arg @ref LL_SPI_CRC_4BIT 01539 * @arg @ref LL_SPI_CRC_5BIT 01540 * @arg @ref LL_SPI_CRC_6BIT 01541 * @arg @ref LL_SPI_CRC_7BIT 01542 * @arg @ref LL_SPI_CRC_8BIT 01543 * @arg @ref LL_SPI_CRC_9BIT 01544 * @arg @ref LL_SPI_CRC_10BIT 01545 * @arg @ref LL_SPI_CRC_11BIT 01546 * @arg @ref LL_SPI_CRC_12BIT 01547 * @arg @ref LL_SPI_CRC_13BIT 01548 * @arg @ref LL_SPI_CRC_14BIT 01549 * @arg @ref LL_SPI_CRC_15BIT 01550 * @arg @ref LL_SPI_CRC_16BIT 01551 * @arg @ref LL_SPI_CRC_17BIT 01552 * @arg @ref LL_SPI_CRC_18BIT 01553 * @arg @ref LL_SPI_CRC_19BIT 01554 * @arg @ref LL_SPI_CRC_20BIT 01555 * @arg @ref LL_SPI_CRC_21BIT 01556 * @arg @ref LL_SPI_CRC_22BIT 01557 * @arg @ref LL_SPI_CRC_23BIT 01558 * @arg @ref LL_SPI_CRC_24BIT 01559 * @arg @ref LL_SPI_CRC_25BIT 01560 * @arg @ref LL_SPI_CRC_26BIT 01561 * @arg @ref LL_SPI_CRC_27BIT 01562 * @arg @ref LL_SPI_CRC_28BIT 01563 * @arg @ref LL_SPI_CRC_29BIT 01564 * @arg @ref LL_SPI_CRC_30BIT 01565 * @arg @ref LL_SPI_CRC_31BIT 01566 * @arg @ref LL_SPI_CRC_32BIT 01567 * @retval None 01568 */ 01569 __STATIC_INLINE void LL_SPI_SetCRCWidth(SPI_TypeDef *SPIx, uint32_t CRCLength) 01570 { 01571 MODIFY_REG(SPIx->CFG1, SPI_CFG1_CRCSIZE, CRCLength); 01572 } 01573 01574 /** 01575 * @brief Get CRC Length 01576 * @rmtoll CFG1 CRCSIZE LL_SPI_GetCRCWidth 01577 * @param SPIx SPI Instance 01578 * @retval Returned value can be one of the following values: 01579 * @arg @ref LL_SPI_CRC_4BIT 01580 * @arg @ref LL_SPI_CRC_5BIT 01581 * @arg @ref LL_SPI_CRC_6BIT 01582 * @arg @ref LL_SPI_CRC_7BIT 01583 * @arg @ref LL_SPI_CRC_8BIT 01584 * @arg @ref LL_SPI_CRC_9BIT 01585 * @arg @ref LL_SPI_CRC_10BIT 01586 * @arg @ref LL_SPI_CRC_11BIT 01587 * @arg @ref LL_SPI_CRC_12BIT 01588 * @arg @ref LL_SPI_CRC_13BIT 01589 * @arg @ref LL_SPI_CRC_14BIT 01590 * @arg @ref LL_SPI_CRC_15BIT 01591 * @arg @ref LL_SPI_CRC_16BIT 01592 * @arg @ref LL_SPI_CRC_17BIT 01593 * @arg @ref LL_SPI_CRC_18BIT 01594 * @arg @ref LL_SPI_CRC_19BIT 01595 * @arg @ref LL_SPI_CRC_20BIT 01596 * @arg @ref LL_SPI_CRC_21BIT 01597 * @arg @ref LL_SPI_CRC_22BIT 01598 * @arg @ref LL_SPI_CRC_23BIT 01599 * @arg @ref LL_SPI_CRC_24BIT 01600 * @arg @ref LL_SPI_CRC_25BIT 01601 * @arg @ref LL_SPI_CRC_26BIT 01602 * @arg @ref LL_SPI_CRC_27BIT 01603 * @arg @ref LL_SPI_CRC_28BIT 01604 * @arg @ref LL_SPI_CRC_29BIT 01605 * @arg @ref LL_SPI_CRC_30BIT 01606 * @arg @ref LL_SPI_CRC_31BIT 01607 * @arg @ref LL_SPI_CRC_32BIT 01608 */ 01609 __STATIC_INLINE uint32_t LL_SPI_GetCRCWidth(SPI_TypeDef *SPIx) 01610 { 01611 return (uint32_t)(READ_BIT(SPIx->CFG1, SPI_CFG1_CRCSIZE)); 01612 } 01613 01614 /** 01615 * @brief Set NSS Mode 01616 * @note This configuration can not be changed when SPI is enabled. 01617 * This bit is not used in SPI TI mode. 01618 * @rmtoll CFG2 SSM LL_SPI_SetNSSMode\n 01619 * CFG2 SSOE LL_SPI_SetNSSMode 01620 * @param SPIx SPI Instance 01621 * @param NSS This parameter can be one of the following values: 01622 * @arg @ref LL_SPI_NSS_SOFT 01623 * @arg @ref LL_SPI_NSS_HARD_INPUT 01624 * @arg @ref LL_SPI_NSS_HARD_OUTPUT 01625 * @retval None 01626 */ 01627 __STATIC_INLINE void LL_SPI_SetNSSMode(SPI_TypeDef *SPIx, uint32_t NSS) 01628 { 01629 MODIFY_REG(SPIx->CFG2, SPI_CFG2_SSM | SPI_CFG2_SSOE, NSS); 01630 } 01631 01632 /** 01633 * @brief Set NSS Mode 01634 * @rmtoll CFG2 SSM LL_SPI_GetNSSMode\n 01635 * CFG2 SSOE LL_SPI_GetNSSMode 01636 * @param SPIx SPI Instance 01637 * @retval Returned value can be one of the following values: 01638 * @arg @ref LL_SPI_NSS_SOFT 01639 * @arg @ref LL_SPI_NSS_HARD_INPUT 01640 * @arg @ref LL_SPI_NSS_HARD_OUTPUT 01641 */ 01642 __STATIC_INLINE uint32_t LL_SPI_GetNSSMode(SPI_TypeDef *SPIx) 01643 { 01644 return (uint32_t)(READ_BIT(SPIx->CFG2, SPI_CFG2_SSM | SPI_CFG2_SSOE)); 01645 } 01646 01647 /** 01648 * @brief Enable NSS pulse mgt 01649 * @note This configuration can not be changed when SPI is enabled. 01650 * This bit is not used in SPI TI mode. 01651 * @rmtoll CFG2 SSOM LL_SPI_EnableNSSPulseMgt 01652 * @param SPIx SPI Instance 01653 * @retval None 01654 */ 01655 __STATIC_INLINE void LL_SPI_EnableNSSPulseMgt(SPI_TypeDef *SPIx) 01656 { 01657 SET_BIT(SPIx->CFG2, SPI_CFG2_SSOM); 01658 } 01659 01660 /** 01661 * @brief Disable NSS pulse mgt 01662 * @note This configuration can not be changed when SPI is enabled. 01663 * This bit is not used in SPI TI mode. 01664 * @rmtoll CFG2 SSOM LL_SPI_DisableNSSPulseMgt 01665 * @param SPIx SPI Instance 01666 * @retval None 01667 */ 01668 __STATIC_INLINE void LL_SPI_DisableNSSPulseMgt(SPI_TypeDef *SPIx) 01669 { 01670 CLEAR_BIT(SPIx->CFG2, SPI_CFG2_SSOM); 01671 } 01672 01673 /** 01674 * @brief Check if NSS pulse is enabled 01675 * @rmtoll CFG2 SSOM LL_SPI_IsEnabledNSSPulse 01676 * @param SPIx SPI Instance 01677 * @retval State of bit (1 or 0) 01678 */ 01679 __STATIC_INLINE uint32_t LL_SPI_IsEnabledNSSPulse(SPI_TypeDef *SPIx) 01680 { 01681 return ((READ_BIT(SPIx->CFG2, SPI_CFG2_SSOM) == SPI_CFG2_SSOM) ? 1UL : 0UL); 01682 } 01683 01684 /** 01685 * @} 01686 */ 01687 01688 /** @defgroup SPI_LL_EF_FLAG_Management FLAG_Management 01689 * @{ 01690 */ 01691 01692 /** 01693 * @brief Check if there is enough data in FIFO to read a full packet 01694 * @rmtoll SR RXP LL_SPI_IsActiveFlag_RXP 01695 * @param SPIx SPI Instance 01696 * @retval State of bit (1 or 0) 01697 */ 01698 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXP(SPI_TypeDef *SPIx) 01699 { 01700 return ((READ_BIT(SPIx->SR, SPI_SR_RXP) == (SPI_SR_RXP)) ? 1UL : 0UL); 01701 } 01702 01703 /** 01704 * @brief Check if there is enough space in FIFO to hold a full packet 01705 * @rmtoll SR TXP LL_SPI_IsActiveFlag_TXP 01706 * @param SPIx SPI Instance 01707 * @retval State of bit (1 or 0) 01708 */ 01709 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXP(SPI_TypeDef *SPIx) 01710 { 01711 return ((READ_BIT(SPIx->SR, SPI_SR_TXP) == (SPI_SR_TXP)) ? 1UL : 0UL); 01712 } 01713 01714 /** 01715 * @brief Check if there enough space in FIFO to hold a full packet, AND enough data to read a full packet 01716 * @rmtoll SR DXP LL_SPI_IsActiveFlag_DXP 01717 * @param SPIx SPI Instance 01718 * @retval State of bit (1 or 0) 01719 */ 01720 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_DXP(SPI_TypeDef *SPIx) 01721 { 01722 return ((READ_BIT(SPIx->SR, SPI_SR_DXP) == (SPI_SR_DXP)) ? 1UL : 0UL); 01723 } 01724 01725 /** 01726 * @brief Check that end of transfer event occurred 01727 * @rmtoll SR EOT LL_SPI_IsActiveFlag_EOT 01728 * @param SPIx SPI Instance 01729 * @retval State of bit (1 or 0). 01730 */ 01731 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_EOT(SPI_TypeDef *SPIx) 01732 { 01733 return ((READ_BIT(SPIx->SR, SPI_SR_EOT) == (SPI_SR_EOT)) ? 1UL : 0UL); 01734 } 01735 01736 /** 01737 * @brief Check that all required data has been filled in the fifo according to transfer size 01738 * @rmtoll SR TXTF LL_SPI_IsActiveFlag_TXTF 01739 * @param SPIx SPI Instance 01740 * @retval State of bit (1 or 0). 01741 */ 01742 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXTF(SPI_TypeDef *SPIx) 01743 { 01744 return ((READ_BIT(SPIx->SR, SPI_SR_TXTF) == (SPI_SR_TXTF)) ? 1UL : 0UL); 01745 } 01746 01747 /** 01748 * @brief Get Underrun error flag 01749 * @rmtoll SR UDR LL_SPI_IsActiveFlag_UDR 01750 * @param SPIx SPI Instance 01751 * @retval State of bit (1 or 0). 01752 */ 01753 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_UDR(SPI_TypeDef *SPIx) 01754 { 01755 return ((READ_BIT(SPIx->SR, SPI_SR_UDR) == (SPI_SR_UDR)) ? 1UL : 0UL); 01756 } 01757 01758 /** 01759 * @brief Get CRC error flag 01760 * @rmtoll SR CRCE LL_SPI_IsActiveFlag_CRCERR 01761 * @param SPIx SPI Instance 01762 * @retval State of bit (1 or 0). 01763 */ 01764 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_CRCERR(SPI_TypeDef *SPIx) 01765 { 01766 return ((READ_BIT(SPIx->SR, SPI_SR_CRCE) == (SPI_SR_CRCE)) ? 1UL : 0UL); 01767 } 01768 01769 /** 01770 * @brief Get Mode fault error flag 01771 * @rmtoll SR MODF LL_SPI_IsActiveFlag_MODF 01772 * @param SPIx SPI Instance 01773 * @retval State of bit (1 or 0). 01774 */ 01775 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_MODF(SPI_TypeDef *SPIx) 01776 { 01777 return ((READ_BIT(SPIx->SR, SPI_SR_MODF) == (SPI_SR_MODF)) ? 1UL : 0UL); 01778 } 01779 01780 /** 01781 * @brief Get Overrun error flag 01782 * @rmtoll SR OVR LL_SPI_IsActiveFlag_OVR 01783 * @param SPIx SPI Instance 01784 * @retval State of bit (1 or 0). 01785 */ 01786 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_OVR(SPI_TypeDef *SPIx) 01787 { 01788 return ((READ_BIT(SPIx->SR, SPI_SR_OVR) == (SPI_SR_OVR)) ? 1UL : 0UL); 01789 } 01790 01791 /** 01792 * @brief Get TI Frame format error flag 01793 * @rmtoll SR TIFRE LL_SPI_IsActiveFlag_FRE 01794 * @param SPIx SPI Instance 01795 * @retval State of bit (1 or 0). 01796 */ 01797 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_FRE(SPI_TypeDef *SPIx) 01798 { 01799 return ((READ_BIT(SPIx->SR, SPI_SR_TIFRE) == (SPI_SR_TIFRE)) ? 1UL : 0UL); 01800 } 01801 01802 /** 01803 * @brief Check if the additional number of data has been reloaded 01804 * @rmtoll SR TSERF LL_SPI_IsActiveFlag_TSER 01805 * @param SPIx SPI Instance 01806 * @retval State of bit (1 or 0). 01807 */ 01808 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TSER(SPI_TypeDef *SPIx) 01809 { 01810 return ((READ_BIT(SPIx->SR, SPI_SR_TSERF) == (SPI_SR_TSERF)) ? 1UL : 0UL); 01811 } 01812 01813 /** 01814 * @brief Check if a suspend operation is done 01815 * @rmtoll SR SUSP LL_SPI_IsActiveFlag_SUSP 01816 * @param SPIx SPI Instance 01817 * @retval State of bit (1 or 0) 01818 */ 01819 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_SUSP(SPI_TypeDef *SPIx) 01820 { 01821 return ((READ_BIT(SPIx->SR, SPI_SR_SUSP) == (SPI_SR_SUSP)) ? 1UL : 0UL); 01822 } 01823 01824 /** 01825 * @brief Check if last TxFIFO or CRC frame transmission is completed 01826 * @rmtoll SR TXC LL_SPI_IsActiveFlag_TXC 01827 * @param SPIx SPI Instance 01828 * @retval State of bit (1 or 0). 01829 */ 01830 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_TXC(SPI_TypeDef *SPIx) 01831 { 01832 return ((READ_BIT(SPIx->SR, SPI_SR_TXC) == (SPI_SR_TXC)) ? 1UL : 0UL); 01833 } 01834 01835 /** 01836 * @brief Check if at least one 32-bit data is available in RxFIFO 01837 * @rmtoll SR RXWNE LL_SPI_IsActiveFlag_RXWNE 01838 * @param SPIx SPI Instance 01839 * @retval State of bit (1 or 0) 01840 */ 01841 __STATIC_INLINE uint32_t LL_SPI_IsActiveFlag_RXWNE(SPI_TypeDef *SPIx) 01842 { 01843 return ((READ_BIT(SPIx->SR, SPI_SR_RXWNE) == (SPI_SR_RXWNE)) ? 1UL : 0UL); 01844 } 01845 01846 /** 01847 * @brief Get number of data framed remaining in current TSIZE 01848 * @rmtoll SR CTSIZE LL_SPI_GetRemainingDataFrames 01849 * @param SPIx SPI Instance 01850 * @retval 0..0xFFFF 01851 */ 01852 __STATIC_INLINE uint32_t LL_SPI_GetRemainingDataFrames(SPI_TypeDef *SPIx) 01853 { 01854 return (uint32_t)(READ_BIT(SPIx->SR, SPI_SR_CTSIZE) >> SPI_SR_CTSIZE_Pos); 01855 } 01856 01857 /** 01858 * @brief Get RxFIFO packing Level 01859 * @rmtoll SR RXPLVL LL_SPI_GetRxFIFOPackingLevel 01860 * @param SPIx SPI Instance 01861 * @retval Returned value can be one of the following values: 01862 * @arg @ref LL_SPI_RX_FIFO_0PACKET 01863 * @arg @ref LL_SPI_RX_FIFO_1PACKET 01864 * @arg @ref LL_SPI_RX_FIFO_2PACKET 01865 * @arg @ref LL_SPI_RX_FIFO_3PACKET 01866 */ 01867 __STATIC_INLINE uint32_t LL_SPI_GetRxFIFOPackingLevel(SPI_TypeDef *SPIx) 01868 { 01869 return (uint32_t)(READ_BIT(SPIx->SR, SPI_SR_RXPLVL)); 01870 } 01871 01872 /** 01873 * @brief Clear End Of Transfer flag 01874 * @rmtoll IFCR EOTC LL_SPI_ClearFlag_EOT 01875 * @param SPIx SPI Instance 01876 * @retval None 01877 */ 01878 __STATIC_INLINE void LL_SPI_ClearFlag_EOT(SPI_TypeDef *SPIx) 01879 { 01880 SET_BIT(SPIx->IFCR, SPI_IFCR_EOTC); 01881 } 01882 01883 /** 01884 * @brief Clear TXTF flag 01885 * @rmtoll IFCR TXTFC LL_SPI_ClearFlag_TXTF 01886 * @param SPIx SPI Instance 01887 * @retval None 01888 */ 01889 __STATIC_INLINE void LL_SPI_ClearFlag_TXTF(SPI_TypeDef *SPIx) 01890 { 01891 SET_BIT(SPIx->IFCR, SPI_IFCR_TXTFC); 01892 } 01893 01894 /** 01895 * @brief Clear Underrun error flag 01896 * @rmtoll IFCR UDRC LL_SPI_ClearFlag_UDR 01897 * @param SPIx SPI Instance 01898 * @retval None 01899 */ 01900 __STATIC_INLINE void LL_SPI_ClearFlag_UDR(SPI_TypeDef *SPIx) 01901 { 01902 SET_BIT(SPIx->IFCR, SPI_IFCR_UDRC); 01903 } 01904 01905 /** 01906 * @brief Clear Overrun error flag 01907 * @rmtoll IFCR OVRC LL_SPI_ClearFlag_OVR 01908 * @param SPIx SPI Instance 01909 * @retval None 01910 */ 01911 __STATIC_INLINE void LL_SPI_ClearFlag_OVR(SPI_TypeDef *SPIx) 01912 { 01913 SET_BIT(SPIx->IFCR, SPI_IFCR_OVRC); 01914 } 01915 01916 /** 01917 * @brief Clear CRC error flag 01918 * @rmtoll IFCR CRCEC LL_SPI_ClearFlag_CRCERR 01919 * @param SPIx SPI Instance 01920 * @retval None 01921 */ 01922 __STATIC_INLINE void LL_SPI_ClearFlag_CRCERR(SPI_TypeDef *SPIx) 01923 { 01924 SET_BIT(SPIx->IFCR, SPI_IFCR_CRCEC); 01925 } 01926 01927 /** 01928 * @brief Clear Mode fault error flag 01929 * @rmtoll IFCR MODFC LL_SPI_ClearFlag_MODF 01930 * @param SPIx SPI Instance 01931 * @retval None 01932 */ 01933 __STATIC_INLINE void LL_SPI_ClearFlag_MODF(SPI_TypeDef *SPIx) 01934 { 01935 SET_BIT(SPIx->IFCR, SPI_IFCR_MODFC); 01936 } 01937 01938 /** 01939 * @brief Clear Frame format error flag 01940 * @rmtoll IFCR TIFREC LL_SPI_ClearFlag_FRE 01941 * @param SPIx SPI Instance 01942 * @retval None 01943 */ 01944 __STATIC_INLINE void LL_SPI_ClearFlag_FRE(SPI_TypeDef *SPIx) 01945 { 01946 SET_BIT(SPIx->IFCR, SPI_IFCR_TIFREC); 01947 } 01948 01949 /** 01950 * @brief Clear TSER flag 01951 * @rmtoll IFCR TSERFC LL_SPI_ClearFlag_TSER 01952 * @param SPIx SPI Instance 01953 * @retval None 01954 */ 01955 __STATIC_INLINE void LL_SPI_ClearFlag_TSER(SPI_TypeDef *SPIx) 01956 { 01957 SET_BIT(SPIx->IFCR, SPI_IFCR_TSERFC); 01958 } 01959 01960 /** 01961 * @brief Clear SUSP flag 01962 * @rmtoll IFCR SUSPC LL_SPI_ClearFlag_SUSP 01963 * @param SPIx SPI Instance 01964 * @retval None 01965 */ 01966 __STATIC_INLINE void LL_SPI_ClearFlag_SUSP(SPI_TypeDef *SPIx) 01967 { 01968 SET_BIT(SPIx->IFCR, SPI_IFCR_SUSPC); 01969 } 01970 01971 /** 01972 * @} 01973 */ 01974 01975 /** @defgroup SPI_LL_EF_IT_Management IT_Management 01976 * @{ 01977 */ 01978 01979 /** 01980 * @brief Enable Rx Packet available IT 01981 * @rmtoll IER RXPIE LL_SPI_EnableIT_RXP 01982 * @param SPIx SPI Instance 01983 * @retval None 01984 */ 01985 __STATIC_INLINE void LL_SPI_EnableIT_RXP(SPI_TypeDef *SPIx) 01986 { 01987 SET_BIT(SPIx->IER, SPI_IER_RXPIE); 01988 } 01989 01990 /** 01991 * @brief Enable Tx Packet space available IT 01992 * @rmtoll IER TXPIE LL_SPI_EnableIT_TXP 01993 * @param SPIx SPI Instance 01994 * @retval None 01995 */ 01996 __STATIC_INLINE void LL_SPI_EnableIT_TXP(SPI_TypeDef *SPIx) 01997 { 01998 SET_BIT(SPIx->IER, SPI_IER_TXPIE); 01999 } 02000 02001 /** 02002 * @brief Enable Duplex Packet available IT 02003 * @rmtoll IER DXPIE LL_SPI_EnableIT_DXP 02004 * @param SPIx SPI Instance 02005 * @retval None 02006 */ 02007 __STATIC_INLINE void LL_SPI_EnableIT_DXP(SPI_TypeDef *SPIx) 02008 { 02009 SET_BIT(SPIx->IER, SPI_IER_DXPIE); 02010 } 02011 02012 /** 02013 * @brief Enable End Of Transfer IT 02014 * @rmtoll IER EOTIE LL_SPI_EnableIT_EOT 02015 * @param SPIx SPI Instance 02016 * @retval None 02017 */ 02018 __STATIC_INLINE void LL_SPI_EnableIT_EOT(SPI_TypeDef *SPIx) 02019 { 02020 SET_BIT(SPIx->IER, SPI_IER_EOTIE); 02021 } 02022 02023 /** 02024 * @brief Enable TXTF IT 02025 * @rmtoll IER TXTFIE LL_SPI_EnableIT_TXTF 02026 * @param SPIx SPI Instance 02027 * @retval None 02028 */ 02029 __STATIC_INLINE void LL_SPI_EnableIT_TXTF(SPI_TypeDef *SPIx) 02030 { 02031 SET_BIT(SPIx->IER, SPI_IER_TXTFIE); 02032 } 02033 02034 /** 02035 * @brief Enable Underrun IT 02036 * @rmtoll IER UDRIE LL_SPI_EnableIT_UDR 02037 * @param SPIx SPI Instance 02038 * @retval None 02039 */ 02040 __STATIC_INLINE void LL_SPI_EnableIT_UDR(SPI_TypeDef *SPIx) 02041 { 02042 SET_BIT(SPIx->IER, SPI_IER_UDRIE); 02043 } 02044 02045 /** 02046 * @brief Enable Overrun IT 02047 * @rmtoll IER OVRIE LL_SPI_EnableIT_OVR 02048 * @param SPIx SPI Instance 02049 * @retval None 02050 */ 02051 __STATIC_INLINE void LL_SPI_EnableIT_OVR(SPI_TypeDef *SPIx) 02052 { 02053 SET_BIT(SPIx->IER, SPI_IER_OVRIE); 02054 } 02055 02056 /** 02057 * @brief Enable CRC Error IT 02058 * @rmtoll IER CRCEIE LL_SPI_EnableIT_CRCERR 02059 * @param SPIx SPI Instance 02060 * @retval None 02061 */ 02062 __STATIC_INLINE void LL_SPI_EnableIT_CRCERR(SPI_TypeDef *SPIx) 02063 { 02064 SET_BIT(SPIx->IER, SPI_IER_CRCEIE); 02065 } 02066 02067 /** 02068 * @brief Enable TI Frame Format Error IT 02069 * @rmtoll IER TIFREIE LL_SPI_EnableIT_FRE 02070 * @param SPIx SPI Instance 02071 * @retval None 02072 */ 02073 __STATIC_INLINE void LL_SPI_EnableIT_FRE(SPI_TypeDef *SPIx) 02074 { 02075 SET_BIT(SPIx->IER, SPI_IER_TIFREIE); 02076 } 02077 02078 /** 02079 * @brief Enable MODF IT 02080 * @rmtoll IER MODFIE LL_SPI_EnableIT_MODF 02081 * @param SPIx SPI Instance 02082 * @retval None 02083 */ 02084 __STATIC_INLINE void LL_SPI_EnableIT_MODF(SPI_TypeDef *SPIx) 02085 { 02086 SET_BIT(SPIx->IER, SPI_IER_MODFIE); 02087 } 02088 02089 /** 02090 * @brief Enable TSER reload IT 02091 * @rmtoll IER TSERFIE LL_SPI_EnableIT_TSER 02092 * @param SPIx SPI Instance 02093 * @retval None 02094 */ 02095 __STATIC_INLINE void LL_SPI_EnableIT_TSER(SPI_TypeDef *SPIx) 02096 { 02097 SET_BIT(SPIx->IER, SPI_IER_TSERFIE); 02098 } 02099 02100 /** 02101 * @brief Disable Rx Packet available IT 02102 * @rmtoll IER RXPIE LL_SPI_DisableIT_RXP 02103 * @param SPIx SPI Instance 02104 * @retval None 02105 */ 02106 __STATIC_INLINE void LL_SPI_DisableIT_RXP(SPI_TypeDef *SPIx) 02107 { 02108 CLEAR_BIT(SPIx->IER, SPI_IER_RXPIE); 02109 } 02110 02111 /** 02112 * @brief Disable Tx Packet space available IT 02113 * @rmtoll IER TXPIE LL_SPI_DisableIT_TXP 02114 * @param SPIx SPI Instance 02115 * @retval None 02116 */ 02117 __STATIC_INLINE void LL_SPI_DisableIT_TXP(SPI_TypeDef *SPIx) 02118 { 02119 CLEAR_BIT(SPIx->IER, SPI_IER_TXPIE); 02120 } 02121 02122 /** 02123 * @brief Disable Duplex Packet available IT 02124 * @rmtoll IER DXPIE LL_SPI_DisableIT_DXP 02125 * @param SPIx SPI Instance 02126 * @retval None 02127 */ 02128 __STATIC_INLINE void LL_SPI_DisableIT_DXP(SPI_TypeDef *SPIx) 02129 { 02130 CLEAR_BIT(SPIx->IER, SPI_IER_DXPIE); 02131 } 02132 02133 /** 02134 * @brief Disable End Of Transfer IT 02135 * @rmtoll IER EOTIE LL_SPI_DisableIT_EOT 02136 * @param SPIx SPI Instance 02137 * @retval None 02138 */ 02139 __STATIC_INLINE void LL_SPI_DisableIT_EOT(SPI_TypeDef *SPIx) 02140 { 02141 CLEAR_BIT(SPIx->IER, SPI_IER_EOTIE); 02142 } 02143 02144 /** 02145 * @brief Disable TXTF IT 02146 * @rmtoll IER TXTFIE LL_SPI_DisableIT_TXTF 02147 * @param SPIx SPI Instance 02148 * @retval None 02149 */ 02150 __STATIC_INLINE void LL_SPI_DisableIT_TXTF(SPI_TypeDef *SPIx) 02151 { 02152 CLEAR_BIT(SPIx->IER, SPI_IER_TXTFIE); 02153 } 02154 02155 /** 02156 * @brief Disable Underrun IT 02157 * @rmtoll IER UDRIE LL_SPI_DisableIT_UDR 02158 * @param SPIx SPI Instance 02159 * @retval None 02160 */ 02161 __STATIC_INLINE void LL_SPI_DisableIT_UDR(SPI_TypeDef *SPIx) 02162 { 02163 CLEAR_BIT(SPIx->IER, SPI_IER_UDRIE); 02164 } 02165 02166 /** 02167 * @brief Disable Overrun IT 02168 * @rmtoll IER OVRIE LL_SPI_DisableIT_OVR 02169 * @param SPIx SPI Instance 02170 * @retval None 02171 */ 02172 __STATIC_INLINE void LL_SPI_DisableIT_OVR(SPI_TypeDef *SPIx) 02173 { 02174 CLEAR_BIT(SPIx->IER, SPI_IER_OVRIE); 02175 } 02176 02177 /** 02178 * @brief Disable CRC Error IT 02179 * @rmtoll IER CRCEIE LL_SPI_DisableIT_CRCERR 02180 * @param SPIx SPI Instance 02181 * @retval None 02182 */ 02183 __STATIC_INLINE void LL_SPI_DisableIT_CRCERR(SPI_TypeDef *SPIx) 02184 { 02185 CLEAR_BIT(SPIx->IER, SPI_IER_CRCEIE); 02186 } 02187 02188 /** 02189 * @brief Disable TI Frame Format Error IT 02190 * @rmtoll IER TIFREIE LL_SPI_DisableIT_FRE 02191 * @param SPIx SPI Instance 02192 * @retval None 02193 */ 02194 __STATIC_INLINE void LL_SPI_DisableIT_FRE(SPI_TypeDef *SPIx) 02195 { 02196 CLEAR_BIT(SPIx->IER, SPI_IER_TIFREIE); 02197 } 02198 02199 /** 02200 * @brief Disable MODF IT 02201 * @rmtoll IER MODFIE LL_SPI_DisableIT_MODF 02202 * @param SPIx SPI Instance 02203 * @retval None 02204 */ 02205 __STATIC_INLINE void LL_SPI_DisableIT_MODF(SPI_TypeDef *SPIx) 02206 { 02207 CLEAR_BIT(SPIx->IER, SPI_IER_MODFIE); 02208 } 02209 02210 /** 02211 * @brief Disable TSER reload IT 02212 * @rmtoll IER TSERFIE LL_SPI_DisableIT_TSER 02213 * @param SPIx SPI Instance 02214 * @retval None 02215 */ 02216 __STATIC_INLINE void LL_SPI_DisableIT_TSER(SPI_TypeDef *SPIx) 02217 { 02218 CLEAR_BIT(SPIx->IER, SPI_IER_TSERFIE); 02219 } 02220 02221 /** 02222 * @brief Check if Rx Packet available IT is enabled 02223 * @rmtoll IER RXPIE LL_SPI_IsEnabledIT_RXP 02224 * @param SPIx SPI Instance 02225 * @retval State of bit (1 or 0) 02226 */ 02227 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_RXP(SPI_TypeDef *SPIx) 02228 { 02229 return ((READ_BIT(SPIx->IER, SPI_IER_RXPIE) == (SPI_IER_RXPIE)) ? 1UL : 0UL); 02230 } 02231 02232 /** 02233 * @brief Check if Tx Packet space available IT is enabled 02234 * @rmtoll IER TXPIE LL_SPI_IsEnabledIT_TXP 02235 * @param SPIx SPI Instance 02236 * @retval State of bit (1 or 0) 02237 */ 02238 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TXP(SPI_TypeDef *SPIx) 02239 { 02240 return ((READ_BIT(SPIx->IER, SPI_IER_TXPIE) == (SPI_IER_TXPIE)) ? 1UL : 0UL); 02241 } 02242 02243 /** 02244 * @brief Check if Duplex Packet available IT is enabled 02245 * @rmtoll IER DXPIE LL_SPI_IsEnabledIT_DXP 02246 * @param SPIx SPI Instance 02247 * @retval State of bit (1 or 0) 02248 */ 02249 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_DXP(SPI_TypeDef *SPIx) 02250 { 02251 return ((READ_BIT(SPIx->IER, SPI_IER_DXPIE) == (SPI_IER_DXPIE)) ? 1UL : 0UL); 02252 } 02253 02254 /** 02255 * @brief Check if End Of Transfer IT is enabled 02256 * @rmtoll IER EOTIE LL_SPI_IsEnabledIT_EOT 02257 * @param SPIx SPI Instance 02258 * @retval State of bit (1 or 0) 02259 */ 02260 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_EOT(SPI_TypeDef *SPIx) 02261 { 02262 return ((READ_BIT(SPIx->IER, SPI_IER_EOTIE) == (SPI_IER_EOTIE)) ? 1UL : 0UL); 02263 } 02264 02265 /** 02266 * @brief Check if TXTF IT is enabled 02267 * @rmtoll IER TXTFIE LL_SPI_IsEnabledIT_TXTF 02268 * @param SPIx SPI Instance 02269 * @retval State of bit (1 or 0) 02270 */ 02271 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TXTF(SPI_TypeDef *SPIx) 02272 { 02273 return ((READ_BIT(SPIx->IER, SPI_IER_TXTFIE) == (SPI_IER_TXTFIE)) ? 1UL : 0UL); 02274 } 02275 02276 /** 02277 * @brief Check if Underrun IT is enabled 02278 * @rmtoll IER UDRIE LL_SPI_IsEnabledIT_UDR 02279 * @param SPIx SPI Instance 02280 * @retval State of bit (1 or 0) 02281 */ 02282 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_UDR(SPI_TypeDef *SPIx) 02283 { 02284 return ((READ_BIT(SPIx->IER, SPI_IER_UDRIE) == (SPI_IER_UDRIE)) ? 1UL : 0UL); 02285 } 02286 02287 /** 02288 * @brief Check if Overrun IT is enabled 02289 * @rmtoll IER OVRIE LL_SPI_IsEnabledIT_OVR 02290 * @param SPIx SPI Instance 02291 * @retval State of bit (1 or 0) 02292 */ 02293 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_OVR(SPI_TypeDef *SPIx) 02294 { 02295 return ((READ_BIT(SPIx->IER, SPI_IER_OVRIE) == (SPI_IER_OVRIE)) ? 1UL : 0UL); 02296 } 02297 02298 /** 02299 * @brief Check if CRC Error IT is enabled 02300 * @rmtoll IER CRCEIE LL_SPI_IsEnabledIT_CRCERR 02301 * @param SPIx SPI Instance 02302 * @retval State of bit (1 or 0) 02303 */ 02304 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_CRCERR(SPI_TypeDef *SPIx) 02305 { 02306 return ((READ_BIT(SPIx->IER, SPI_IER_CRCEIE) == (SPI_IER_CRCEIE)) ? 1UL : 0UL); 02307 } 02308 02309 /** 02310 * @brief Check if TI Frame Format Error IT is enabled 02311 * @rmtoll IER TIFREIE LL_SPI_IsEnabledIT_FRE 02312 * @param SPIx SPI Instance 02313 * @retval State of bit (1 or 0) 02314 */ 02315 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_FRE(SPI_TypeDef *SPIx) 02316 { 02317 return ((READ_BIT(SPIx->IER, SPI_IER_TIFREIE) == (SPI_IER_TIFREIE)) ? 1UL : 0UL); 02318 } 02319 02320 /** 02321 * @brief Check if MODF IT is enabled 02322 * @rmtoll IER MODFIE LL_SPI_IsEnabledIT_MODF 02323 * @param SPIx SPI Instance 02324 * @retval State of bit (1 or 0) 02325 */ 02326 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_MODF(SPI_TypeDef *SPIx) 02327 { 02328 return ((READ_BIT(SPIx->IER, SPI_IER_MODFIE) == (SPI_IER_MODFIE)) ? 1UL : 0UL); 02329 } 02330 02331 /** 02332 * @brief Check if TSER reload IT is enabled 02333 * @rmtoll IER TSERFIE LL_SPI_IsEnabledIT_TSER 02334 * @param SPIx SPI Instance 02335 * @retval State of bit (1 or 0) 02336 */ 02337 __STATIC_INLINE uint32_t LL_SPI_IsEnabledIT_TSER(SPI_TypeDef *SPIx) 02338 { 02339 return ((READ_BIT(SPIx->IER, SPI_IER_TSERFIE) == (SPI_IER_TSERFIE)) ? 1UL : 0UL); 02340 } 02341 02342 /** 02343 * @} 02344 */ 02345 02346 /** @defgroup SPI_LL_EF_DMA_Management DMA Management 02347 * @{ 02348 */ 02349 02350 /** 02351 * @brief Enable DMA Rx 02352 * @rmtoll CFG1 RXDMAEN LL_SPI_EnableDMAReq_RX 02353 * @param SPIx SPI Instance 02354 * @retval None 02355 */ 02356 __STATIC_INLINE void LL_SPI_EnableDMAReq_RX(SPI_TypeDef *SPIx) 02357 { 02358 SET_BIT(SPIx->CFG1, SPI_CFG1_RXDMAEN); 02359 } 02360 02361 /** 02362 * @brief Disable DMA Rx 02363 * @rmtoll CFG1 RXDMAEN LL_SPI_DisableDMAReq_RX 02364 * @param SPIx SPI Instance 02365 * @retval None 02366 */ 02367 __STATIC_INLINE void LL_SPI_DisableDMAReq_RX(SPI_TypeDef *SPIx) 02368 { 02369 CLEAR_BIT(SPIx->CFG1, SPI_CFG1_RXDMAEN); 02370 } 02371 02372 /** 02373 * @brief Check if DMA Rx is enabled 02374 * @rmtoll CFG1 RXDMAEN LL_SPI_IsEnabledDMAReq_RX 02375 * @param SPIx SPI Instance 02376 * @retval State of bit (1 or 0) 02377 */ 02378 __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_RX(SPI_TypeDef *SPIx) 02379 { 02380 return ((READ_BIT(SPIx->CFG1, SPI_CFG1_RXDMAEN) == (SPI_CFG1_RXDMAEN)) ? 1UL : 0UL); 02381 } 02382 02383 /** 02384 * @brief Enable DMA Tx 02385 * @rmtoll CFG1 TXDMAEN LL_SPI_EnableDMAReq_TX 02386 * @param SPIx SPI Instance 02387 * @retval None 02388 */ 02389 __STATIC_INLINE void LL_SPI_EnableDMAReq_TX(SPI_TypeDef *SPIx) 02390 { 02391 SET_BIT(SPIx->CFG1, SPI_CFG1_TXDMAEN); 02392 } 02393 02394 /** 02395 * @brief Disable DMA Tx 02396 * @rmtoll CFG1 TXDMAEN LL_SPI_DisableDMAReq_TX 02397 * @param SPIx SPI Instance 02398 * @retval None 02399 */ 02400 __STATIC_INLINE void LL_SPI_DisableDMAReq_TX(SPI_TypeDef *SPIx) 02401 { 02402 CLEAR_BIT(SPIx->CFG1, SPI_CFG1_TXDMAEN); 02403 } 02404 02405 /** 02406 * @brief Check if DMA Tx is enabled 02407 * @rmtoll CFG1 TXDMAEN LL_SPI_IsEnabledDMAReq_TX 02408 * @param SPIx SPI Instance 02409 * @retval State of bit (1 or 0) 02410 */ 02411 __STATIC_INLINE uint32_t LL_SPI_IsEnabledDMAReq_TX(SPI_TypeDef *SPIx) 02412 { 02413 return ((READ_BIT(SPIx->CFG1, SPI_CFG1_TXDMAEN) == (SPI_CFG1_TXDMAEN)) ? 1UL : 0UL); 02414 } 02415 02416 /** 02417 * @} 02418 */ 02419 02420 /** @defgroup SPI_LL_EF_DATA_Management DATA_Management 02421 * @{ 02422 */ 02423 02424 /** 02425 * @brief Read Data Register 02426 * @rmtoll RXDR . LL_SPI_ReceiveData8 02427 * @param SPIx SPI Instance 02428 * @retval 0..0xFF 02429 */ 02430 __STATIC_INLINE uint8_t LL_SPI_ReceiveData8(SPI_TypeDef *SPIx) 02431 { 02432 return (*((__IO uint8_t *)&SPIx->RXDR)); 02433 } 02434 02435 /** 02436 * @brief Read Data Register 02437 * @rmtoll RXDR . LL_SPI_ReceiveData16 02438 * @param SPIx SPI Instance 02439 * @retval 0..0xFFFF 02440 */ 02441 __STATIC_INLINE uint16_t LL_SPI_ReceiveData16(SPI_TypeDef *SPIx) 02442 { 02443 return (uint16_t)(READ_REG(SPIx->RXDR)); 02444 } 02445 02446 /** 02447 * @brief Read Data Register 02448 * @rmtoll RXDR . LL_SPI_ReceiveData32 02449 * @param SPIx SPI Instance 02450 * @retval 0..0xFFFFFFFF 02451 */ 02452 __STATIC_INLINE uint32_t LL_SPI_ReceiveData32(SPI_TypeDef *SPIx) 02453 { 02454 return (*((__IO uint32_t *)&SPIx->RXDR)); 02455 } 02456 02457 /** 02458 * @brief Write Data Register 02459 * @rmtoll TXDR . LL_SPI_TransmitData8 02460 * @param SPIx SPI Instance 02461 * @param TxData 0..0xFF 02462 * @retval None 02463 */ 02464 __STATIC_INLINE void LL_SPI_TransmitData8(SPI_TypeDef *SPIx, uint8_t TxData) 02465 { 02466 *((__IO uint8_t *)&SPIx->TXDR) = TxData; 02467 } 02468 02469 /** 02470 * @brief Write Data Register 02471 * @rmtoll TXDR . LL_SPI_TransmitData16 02472 * @param SPIx SPI Instance 02473 * @param TxData 0..0xFFFF 02474 * @retval None 02475 */ 02476 __STATIC_INLINE void LL_SPI_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData) 02477 { 02478 #if defined (__GNUC__) 02479 __IO uint16_t *spitxdr = ((__IO uint16_t *)&SPIx->TXDR); 02480 *spitxdr = TxData; 02481 #else 02482 SPIx->TXDR = TxData; 02483 #endif /* __GNUC__ */ 02484 } 02485 02486 /** 02487 * @brief Write Data Register 02488 * @rmtoll TXDR . LL_SPI_TransmitData32 02489 * @param SPIx SPI Instance 02490 * @param TxData 0..0xFFFFFFFF 02491 * @retval None 02492 */ 02493 __STATIC_INLINE void LL_SPI_TransmitData32(SPI_TypeDef *SPIx, uint32_t TxData) 02494 { 02495 *((__IO uint32_t *)&SPIx->TXDR) = TxData; 02496 } 02497 02498 /** 02499 * @brief Set polynomial for CRC calcul 02500 * @rmtoll CRCPOLY CRCPOLY LL_SPI_SetCRCPolynomial 02501 * @param SPIx SPI Instance 02502 * @param CRCPoly 0..0xFFFFFFFF 02503 * @retval None 02504 */ 02505 __STATIC_INLINE void LL_SPI_SetCRCPolynomial(SPI_TypeDef *SPIx, uint32_t CRCPoly) 02506 { 02507 WRITE_REG(SPIx->CRCPOLY, CRCPoly); 02508 } 02509 02510 /** 02511 * @brief Get polynomial for CRC calcul 02512 * @rmtoll CRCPOLY CRCPOLY LL_SPI_GetCRCPolynomial 02513 * @param SPIx SPI Instance 02514 * @retval 0..0xFFFFFFFF 02515 */ 02516 __STATIC_INLINE uint32_t LL_SPI_GetCRCPolynomial(SPI_TypeDef *SPIx) 02517 { 02518 return (uint32_t)(READ_REG(SPIx->CRCPOLY)); 02519 } 02520 02521 /** 02522 * @brief Set the underrun pattern 02523 * @rmtoll UDRDR UDRDR LL_SPI_SetUDRPattern 02524 * @param SPIx SPI Instance 02525 * @param Pattern 0..0xFFFFFFFF 02526 * @retval None 02527 */ 02528 __STATIC_INLINE void LL_SPI_SetUDRPattern(SPI_TypeDef *SPIx, uint32_t Pattern) 02529 { 02530 WRITE_REG(SPIx->UDRDR, Pattern); 02531 } 02532 02533 /** 02534 * @brief Get the underrun pattern 02535 * @rmtoll UDRDR UDRDR LL_SPI_GetUDRPattern 02536 * @param SPIx SPI Instance 02537 * @retval 0..0xFFFFFFFF 02538 */ 02539 __STATIC_INLINE uint32_t LL_SPI_GetUDRPattern(SPI_TypeDef *SPIx) 02540 { 02541 return (uint32_t)(READ_REG(SPIx->UDRDR)); 02542 } 02543 02544 /** 02545 * @brief Get Rx CRC 02546 * @rmtoll RXCRCR RXCRC LL_SPI_GetRxCRC 02547 * @param SPIx SPI Instance 02548 * @retval 0..0xFFFFFFFF 02549 */ 02550 __STATIC_INLINE uint32_t LL_SPI_GetRxCRC(SPI_TypeDef *SPIx) 02551 { 02552 return (uint32_t)(READ_REG(SPIx->RXCRC)); 02553 } 02554 02555 /** 02556 * @brief Get Tx CRC 02557 * @rmtoll TXCRCR TXCRC LL_SPI_GetTxCRC 02558 * @param SPIx SPI Instance 02559 * @retval 0..0xFFFFFFFF 02560 */ 02561 __STATIC_INLINE uint32_t LL_SPI_GetTxCRC(SPI_TypeDef *SPIx) 02562 { 02563 return (uint32_t)(READ_REG(SPIx->TXCRC)); 02564 } 02565 02566 /** 02567 * @} 02568 */ 02569 02570 #if defined(USE_FULL_LL_DRIVER) 02571 /** @defgroup SPI_LL_EF_Init Initialization and de-initialization functions 02572 * @{ 02573 */ 02574 02575 ErrorStatus LL_SPI_DeInit(SPI_TypeDef *SPIx); 02576 ErrorStatus LL_SPI_Init(SPI_TypeDef *SPIx, LL_SPI_InitTypeDef *SPI_InitStruct); 02577 void LL_SPI_StructInit(LL_SPI_InitTypeDef *SPI_InitStruct); 02578 02579 /** 02580 * @} 02581 */ 02582 #endif /* USE_FULL_LL_DRIVER */ 02583 /** 02584 * @} 02585 */ 02586 02587 /** @defgroup I2S_LL I2S 02588 * @{ 02589 */ 02590 02591 /* Private variables ---------------------------------------------------------*/ 02592 /* Private constants ---------------------------------------------------------*/ 02593 /* Private macros ------------------------------------------------------------*/ 02594 02595 /* Exported types ------------------------------------------------------------*/ 02596 #if defined(USE_FULL_LL_DRIVER) 02597 /** @defgroup I2S_LL_ES_INIT I2S Exported Init structure 02598 * @{ 02599 */ 02600 02601 /** 02602 * @brief I2S Init structure definition 02603 */ 02604 02605 typedef struct 02606 { 02607 uint32_t Mode; /*!< Specifies the I2S operating mode. 02608 This parameter can be a value of @ref I2S_LL_EC_MODE 02609 02610 This feature can be modified afterwards using unitary function 02611 @ref LL_I2S_SetTransferMode().*/ 02612 02613 uint32_t Standard; /*!< Specifies the standard used for the I2S communication. 02614 This parameter can be a value of @ref I2S_LL_EC_STANDARD 02615 02616 This feature can be modified afterwards using unitary function 02617 @ref LL_I2S_SetStandard().*/ 02618 02619 02620 uint32_t DataFormat; /*!< Specifies the data format for the I2S communication. 02621 This parameter can be a value of @ref I2S_LL_EC_DATA_FORMAT 02622 02623 This feature can be modified afterwards using unitary function 02624 @ref LL_I2S_SetDataFormat().*/ 02625 02626 02627 uint32_t MCLKOutput; /*!< Specifies whether the I2S MCLK output is enabled or not. 02628 This parameter can be a value of @ref I2S_LL_EC_MCLK_OUTPUT 02629 02630 This feature can be modified afterwards using unitary functions 02631 @ref LL_I2S_EnableMasterClock() or @ref LL_I2S_DisableMasterClock.*/ 02632 02633 02634 uint32_t AudioFreq; /*!< Specifies the frequency selected for the I2S communication. 02635 This parameter can be a value of @ref I2S_LL_EC_AUDIO_FREQ 02636 02637 Audio Frequency can be modified afterwards using Reference manual formulas 02638 to calculate Prescaler Linear, Parity and unitary functions 02639 @ref LL_I2S_SetPrescalerLinear() and @ref LL_I2S_SetPrescalerParity() 02640 to set it.*/ 02641 02642 02643 uint32_t ClockPolarity; /*!< Specifies the idle state of the I2S clock. 02644 This parameter can be a value of @ref I2S_LL_EC_POLARITY 02645 02646 This feature can be modified afterwards using unitary function 02647 @ref LL_I2S_SetClockPolarity().*/ 02648 02649 } LL_I2S_InitTypeDef; 02650 02651 /** 02652 * @} 02653 */ 02654 #endif /*USE_FULL_LL_DRIVER*/ 02655 02656 /* Exported constants --------------------------------------------------------*/ 02657 /** @defgroup I2S_LL_Exported_Constants I2S Exported Constants 02658 * @{ 02659 */ 02660 02661 /** @defgroup I2S_LL_EC_DATA_FORMAT Data Format 02662 * @{ 02663 */ 02664 #define LL_I2S_DATAFORMAT_16B (0x00000000UL) 02665 #define LL_I2S_DATAFORMAT_16B_EXTENDED (SPI_I2SCFGR_CHLEN) 02666 #define LL_I2S_DATAFORMAT_24B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0) 02667 #define LL_I2S_DATAFORMAT_24B_LEFT_ALIGNED (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_0 | SPI_I2SCFGR_DATFMT) 02668 #define LL_I2S_DATAFORMAT_32B (SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATLEN_1) 02669 /** 02670 * @} 02671 */ 02672 02673 /** @defgroup I2S_LL_EC_CHANNEL_LENGTH_TYPE Type of Channel Length 02674 * @{ 02675 */ 02676 #define LL_I2S_SLAVE_VARIABLE_CH_LENGTH (0x00000000UL) 02677 #define LL_I2S_SLAVE_FIXED_CH_LENGTH (SPI_I2SCFGR_FIXCH) 02678 /** 02679 * @} 02680 */ 02681 02682 /** @defgroup I2S_LL_EC_POLARITY Clock Polarity 02683 * @{ 02684 */ 02685 #define LL_I2S_POLARITY_LOW (0x00000000UL) 02686 #define LL_I2S_POLARITY_HIGH (SPI_I2SCFGR_CKPOL) 02687 /** 02688 * @} 02689 */ 02690 02691 /** @defgroup I2S_LL_EC_STANDARD I2S Standard 02692 * @{ 02693 */ 02694 #define LL_I2S_STANDARD_PHILIPS (0x00000000UL) 02695 #define LL_I2S_STANDARD_MSB (SPI_I2SCFGR_I2SSTD_0) 02696 #define LL_I2S_STANDARD_LSB (SPI_I2SCFGR_I2SSTD_1) 02697 #define LL_I2S_STANDARD_PCM_SHORT (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1) 02698 #define LL_I2S_STANDARD_PCM_LONG (SPI_I2SCFGR_I2SSTD_0 | SPI_I2SCFGR_I2SSTD_1 | SPI_I2SCFGR_PCMSYNC) 02699 /** 02700 * @} 02701 */ 02702 02703 /** @defgroup I2S_LL_EC_MODE Operation Mode 02704 * @{ 02705 */ 02706 #define LL_I2S_MODE_SLAVE_TX (0x00000000UL) 02707 #define LL_I2S_MODE_SLAVE_RX (SPI_I2SCFGR_I2SCFG_0) 02708 #define LL_I2S_MODE_SLAVE_FULL_DUPLEX (SPI_I2SCFGR_I2SCFG_2) 02709 #define LL_I2S_MODE_MASTER_TX (SPI_I2SCFGR_I2SCFG_1) 02710 #define LL_I2S_MODE_MASTER_RX (SPI_I2SCFGR_I2SCFG_1 | SPI_I2SCFGR_I2SCFG_0) 02711 #define LL_I2S_MODE_MASTER_FULL_DUPLEX (SPI_I2SCFGR_I2SCFG_2 | SPI_I2SCFGR_I2SCFG_0) 02712 /** 02713 * @} 02714 */ 02715 02716 /** @defgroup I2S_LL_EC_PRESCALER_PARITY Prescaler Factor 02717 * @{ 02718 */ 02719 #define LL_I2S_PRESCALER_PARITY_EVEN (0x00000000UL) /*!< Odd factor: Real divider value is = I2SDIV * 2 */ 02720 #define LL_I2S_PRESCALER_PARITY_ODD (0x00000001UL) /*!< Odd factor: Real divider value is = (I2SDIV * 2)+1 */ 02721 /** 02722 * @} 02723 */ 02724 02725 /** @defgroup I2S_LL_EC_FIFO_TH FIFO Threshold Level 02726 * @{ 02727 */ 02728 #define LL_I2S_FIFO_TH_01DATA (LL_SPI_FIFO_TH_01DATA) 02729 #define LL_I2S_FIFO_TH_02DATA (LL_SPI_FIFO_TH_02DATA) 02730 #define LL_I2S_FIFO_TH_03DATA (LL_SPI_FIFO_TH_03DATA) 02731 #define LL_I2S_FIFO_TH_04DATA (LL_SPI_FIFO_TH_04DATA) 02732 #define LL_I2S_FIFO_TH_05DATA (LL_SPI_FIFO_TH_05DATA) 02733 #define LL_I2S_FIFO_TH_06DATA (LL_SPI_FIFO_TH_06DATA) 02734 #define LL_I2S_FIFO_TH_07DATA (LL_SPI_FIFO_TH_07DATA) 02735 #define LL_I2S_FIFO_TH_08DATA (LL_SPI_FIFO_TH_08DATA) 02736 /** 02737 * @} 02738 */ 02739 02740 /** @defgroup I2S_LL_EC_BIT_ORDER Transmission Bit Order 02741 * @{ 02742 */ 02743 #define LL_I2S_LSB_FIRST (LL_SPI_LSB_FIRST) 02744 #define LL_I2S_MSB_FIRST (LL_SPI_MSB_FIRST) 02745 /** 02746 * @} 02747 */ 02748 02749 #if defined(USE_FULL_LL_DRIVER) 02750 02751 /** @defgroup I2S_LL_EC_MCLK_OUTPUT MCLK Output 02752 * @{ 02753 */ 02754 #define LL_I2S_MCLK_OUTPUT_DISABLE (0x00000000UL) 02755 #define LL_I2S_MCLK_OUTPUT_ENABLE (SPI_I2SCFGR_MCKOE) 02756 /** 02757 * @} 02758 */ 02759 02760 /** @defgroup I2S_LL_EC_AUDIO_FREQ Audio Frequency 02761 * @{ 02762 */ 02763 02764 #define LL_I2S_AUDIOFREQ_192K 192000UL /*!< Audio Frequency configuration 192000 Hz */ 02765 #define LL_I2S_AUDIOFREQ_96K 96000UL /*!< Audio Frequency configuration 96000 Hz */ 02766 #define LL_I2S_AUDIOFREQ_48K 48000UL /*!< Audio Frequency configuration 48000 Hz */ 02767 #define LL_I2S_AUDIOFREQ_44K 44100UL /*!< Audio Frequency configuration 44100 Hz */ 02768 #define LL_I2S_AUDIOFREQ_32K 32000UL /*!< Audio Frequency configuration 32000 Hz */ 02769 #define LL_I2S_AUDIOFREQ_22K 22050UL /*!< Audio Frequency configuration 22050 Hz */ 02770 #define LL_I2S_AUDIOFREQ_16K 16000UL /*!< Audio Frequency configuration 16000 Hz */ 02771 #define LL_I2S_AUDIOFREQ_11K 11025UL /*!< Audio Frequency configuration 11025 Hz */ 02772 #define LL_I2S_AUDIOFREQ_8K 8000UL /*!< Audio Frequency configuration 8000 Hz */ 02773 #define LL_I2S_AUDIOFREQ_DEFAULT 0UL /*!< Audio Freq not specified. Register I2SDIV = 0 */ 02774 /** 02775 * @} 02776 */ 02777 #endif /* USE_FULL_LL_DRIVER */ 02778 02779 /** 02780 * @} 02781 */ 02782 02783 /* Exported macro ------------------------------------------------------------*/ 02784 /** @defgroup I2S_LL_Exported_Macros I2S Exported Macros 02785 * @{ 02786 */ 02787 02788 /** @defgroup I2S_LL_EM_WRITE_READ Common Write and read registers Macros 02789 * @{ 02790 */ 02791 02792 /** 02793 * @brief Write a value in I2S register 02794 * @param __INSTANCE__ I2S Instance 02795 * @param __REG__ Register to be written 02796 * @param __VALUE__ Value to be written in the register 02797 * @retval None 02798 */ 02799 #define LL_I2S_WriteReg(__INSTANCE__, __REG__, __VALUE__) WRITE_REG(__INSTANCE__->__REG__, (__VALUE__)) 02800 02801 /** 02802 * @brief Read a value in I2S register 02803 * @param __INSTANCE__ I2S Instance 02804 * @param __REG__ Register to be read 02805 * @retval Register value 02806 */ 02807 #define LL_I2S_ReadReg(__INSTANCE__, __REG__) READ_REG(__INSTANCE__->__REG__) 02808 /** 02809 * @} 02810 */ 02811 02812 /** 02813 * @} 02814 */ 02815 02816 02817 /* Exported functions --------------------------------------------------------*/ 02818 02819 /** @defgroup I2S_LL_Exported_Functions I2S Exported Functions 02820 * @{ 02821 */ 02822 02823 /** @defgroup I2S_LL_EF_Configuration Configuration 02824 * @{ 02825 */ 02826 02827 /** 02828 * @brief Set I2S Data frame format 02829 * @rmtoll I2SCFGR DATLEN LL_I2S_SetDataFormat\n 02830 * I2SCFGR CHLEN LL_I2S_SetDataFormat\n 02831 * I2SCFGR DATFMT LL_I2S_SetDataFormat 02832 * @param SPIx SPI Handle 02833 * @param DataLength This parameter can be one of the following values: 02834 * @arg @ref LL_I2S_DATAFORMAT_16B 02835 * @arg @ref LL_I2S_DATAFORMAT_16B_EXTENDED 02836 * @arg @ref LL_I2S_DATAFORMAT_24B 02837 * @arg @ref LL_I2S_DATAFORMAT_24B_LEFT_ALIGNED 02838 * @arg @ref LL_I2S_DATAFORMAT_32B 02839 * @retval None 02840 */ 02841 __STATIC_INLINE void LL_I2S_SetDataFormat(SPI_TypeDef *SPIx, uint32_t DataLength) 02842 { 02843 MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATFMT, DataLength); 02844 } 02845 02846 /** 02847 * @brief Get I2S Data frame format 02848 * @rmtoll I2SCFGR DATLEN LL_I2S_GetDataFormat\n 02849 * I2SCFGR CHLEN LL_I2S_GetDataFormat\n 02850 * I2SCFGR DATFMT LL_I2S_GetDataFormat 02851 * @param SPIx SPI Handle 02852 * @retval Return value can be one of the following values: 02853 * @arg @ref LL_I2S_DATAFORMAT_16B 02854 * @arg @ref LL_I2S_DATAFORMAT_16B_EXTENDED 02855 * @arg @ref LL_I2S_DATAFORMAT_24B 02856 * @arg @ref LL_I2S_DATAFORMAT_24B_LEFT_ALIGNED 02857 * @arg @ref LL_I2S_DATAFORMAT_32B 02858 */ 02859 __STATIC_INLINE uint32_t LL_I2S_GetDataFormat(SPI_TypeDef *SPIx) 02860 { 02861 return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_DATLEN | SPI_I2SCFGR_CHLEN | SPI_I2SCFGR_DATFMT)); 02862 } 02863 02864 /** 02865 * @brief Set I2S Channel Length Type 02866 * @note This feature is useful with SLAVE only 02867 * @rmtoll I2SCFGR FIXCH LL_I2S_SetChannelLengthType 02868 * @param SPIx SPI Handle 02869 * @param ChannelLengthType This parameter can be one of the following values: 02870 * @arg @ref LL_I2S_SLAVE_VARIABLE_CH_LENGTH 02871 * @arg @ref LL_I2S_SLAVE_FIXED_CH_LENGTH 02872 * @retval None 02873 */ 02874 __STATIC_INLINE void LL_I2S_SetChannelLengthType(SPI_TypeDef *SPIx, uint32_t ChannelLengthType) 02875 { 02876 MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_FIXCH, ChannelLengthType); 02877 } 02878 02879 /** 02880 * @brief Get I2S Channel Length Type 02881 * @note This feature is useful with SLAVE only 02882 * @rmtoll I2SCFGR FIXCH LL_I2S_GetChannelLengthType 02883 * @param SPIx SPI Handle 02884 * @retval Return value can be one of the following values: 02885 * @arg @ref LL_I2S_SLAVE_VARIABLE_CH_LENGTH 02886 * @arg @ref LL_I2S_SLAVE_FIXED_CH_LENGTH 02887 */ 02888 __STATIC_INLINE uint32_t LL_I2S_GetChannelLengthType(SPI_TypeDef *SPIx) 02889 { 02890 return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_FIXCH)); 02891 } 02892 02893 /** 02894 * @brief Invert the default polarity of WS signal 02895 * @rmtoll I2SCFGR WSINV LL_I2S_EnableWordSelectInversion 02896 * @param SPIx SPI Handle 02897 * @retval None 02898 */ 02899 __STATIC_INLINE void LL_I2S_EnableWordSelectInversion(SPI_TypeDef *SPIx) 02900 { 02901 SET_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_WSINV); 02902 } 02903 02904 /** 02905 * @brief Use the default polarity of WS signal 02906 * @rmtoll I2SCFGR WSINV LL_I2S_DisableWordSelectInversion 02907 * @param SPIx SPI Handle 02908 * @retval None 02909 */ 02910 __STATIC_INLINE void LL_I2S_DisableWordSelectInversion(SPI_TypeDef *SPIx) 02911 { 02912 CLEAR_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_WSINV); 02913 } 02914 02915 /** 02916 * @brief Check if polarity of WS signal is inverted 02917 * @rmtoll I2SCFGR WSINV LL_I2S_IsEnabledWordSelectInversion 02918 * @param SPIx SPI Handle 02919 * @retval State of bit (1 or 0) 02920 */ 02921 __STATIC_INLINE uint32_t LL_I2S_IsEnabledWordSelectInversion(SPI_TypeDef *SPIx) 02922 { 02923 return ((READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_WSINV) == (SPI_I2SCFGR_WSINV)) ? 1UL : 0UL); 02924 } 02925 02926 /** 02927 * @brief Set 2S Clock Polarity 02928 * @rmtoll I2SCFGR CKPOL LL_I2S_SetClockPolarity 02929 * @param SPIx SPI Handle 02930 * @param ClockPolarity This parameter can be one of the following values: 02931 * @arg @ref LL_I2S_POLARITY_LOW 02932 * @arg @ref LL_I2S_POLARITY_HIGH 02933 * @retval None 02934 */ 02935 __STATIC_INLINE void LL_I2S_SetClockPolarity(SPI_TypeDef *SPIx, uint32_t ClockPolarity) 02936 { 02937 MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_CKPOL, ClockPolarity); 02938 } 02939 02940 /** 02941 * @brief Get 2S Clock Polarity 02942 * @rmtoll I2SCFGR CKPOL LL_I2S_GetClockPolarity 02943 * @param SPIx SPI Handle 02944 * @retval Return value can be one of the following values: 02945 * @arg @ref LL_I2S_POLARITY_LOW 02946 * @arg @ref LL_I2S_POLARITY_HIGH 02947 */ 02948 __STATIC_INLINE uint32_t LL_I2S_GetClockPolarity(SPI_TypeDef *SPIx) 02949 { 02950 return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_CKPOL)); 02951 } 02952 02953 /** 02954 * @brief Set I2S standard 02955 * @rmtoll I2SCFGR I2SSTD LL_I2S_SetStandard\n 02956 * I2SCFGR PCMSYNC LL_I2S_SetStandard 02957 * @param SPIx SPI Handle 02958 * @param Standard This parameter can be one of the following values: 02959 * @arg @ref LL_I2S_STANDARD_PHILIPS 02960 * @arg @ref LL_I2S_STANDARD_MSB 02961 * @arg @ref LL_I2S_STANDARD_LSB 02962 * @arg @ref LL_I2S_STANDARD_PCM_SHORT 02963 * @arg @ref LL_I2S_STANDARD_PCM_LONG 02964 * @retval None 02965 */ 02966 __STATIC_INLINE void LL_I2S_SetStandard(SPI_TypeDef *SPIx, uint32_t Standard) 02967 { 02968 MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_I2SSTD | SPI_I2SCFGR_PCMSYNC, Standard); 02969 } 02970 02971 /** 02972 * @brief Get I2S standard 02973 * @rmtoll I2SCFGR I2SSTD LL_I2S_GetStandard\n 02974 * I2SCFGR PCMSYNC LL_I2S_GetStandard 02975 * @param SPIx SPI Handle 02976 * @retval Return value can be one of the following values: 02977 * @arg @ref LL_I2S_STANDARD_PHILIPS 02978 * @arg @ref LL_I2S_STANDARD_MSB 02979 * @arg @ref LL_I2S_STANDARD_LSB 02980 * @arg @ref LL_I2S_STANDARD_PCM_SHORT 02981 * @arg @ref LL_I2S_STANDARD_PCM_LONG 02982 */ 02983 __STATIC_INLINE uint32_t LL_I2S_GetStandard(SPI_TypeDef *SPIx) 02984 { 02985 return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SSTD | SPI_I2SCFGR_PCMSYNC)); 02986 } 02987 02988 /** 02989 * @brief Set I2S config 02990 * @rmtoll I2SCFGR I2SCFG LL_I2S_SetTransferMode 02991 * @param SPIx SPI Handle 02992 * @param Standard This parameter can be one of the following values: 02993 * @arg @ref LL_I2S_MODE_SLAVE_TX 02994 * @arg @ref LL_I2S_MODE_SLAVE_RX 02995 * @arg @ref LL_I2S_MODE_SLAVE_FULL_DUPLEX 02996 * @arg @ref LL_I2S_MODE_MASTER_TX 02997 * @arg @ref LL_I2S_MODE_MASTER_RX 02998 * @arg @ref LL_I2S_MODE_MASTER_FULL_DUPLEX 02999 * @retval None 03000 */ 03001 __STATIC_INLINE void LL_I2S_SetTransferMode(SPI_TypeDef *SPIx, uint32_t Standard) 03002 { 03003 MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_I2SCFG, Standard); 03004 } 03005 03006 /** 03007 * @brief Get I2S config 03008 * @rmtoll I2SCFGR I2SCFG LL_I2S_GetTransferMode 03009 * @param SPIx SPI Handle 03010 * @retval Return value can be one of the following values: 03011 * @arg @ref LL_I2S_MODE_SLAVE_TX 03012 * @arg @ref LL_I2S_MODE_SLAVE_RX 03013 * @arg @ref LL_I2S_MODE_SLAVE_FULL_DUPLEX 03014 * @arg @ref LL_I2S_MODE_MASTER_TX 03015 * @arg @ref LL_I2S_MODE_MASTER_RX 03016 * @arg @ref LL_I2S_MODE_MASTER_FULL_DUPLEX 03017 */ 03018 __STATIC_INLINE uint32_t LL_I2S_GetTransferMode(SPI_TypeDef *SPIx) 03019 { 03020 return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SCFG)); 03021 } 03022 03023 /** 03024 * @brief Select I2S mode and Enable I2S peripheral 03025 * @rmtoll I2SCFGR I2SMOD LL_I2S_Enable\n 03026 * CR1 SPE LL_I2S_Enable 03027 * @param SPIx SPI Handle 03028 * @retval None 03029 */ 03030 __STATIC_INLINE void LL_I2S_Enable(SPI_TypeDef *SPIx) 03031 { 03032 SET_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SMOD); 03033 SET_BIT(SPIx->CR1, SPI_CR1_SPE); 03034 } 03035 03036 /** 03037 * @brief Disable I2S peripheral and disable I2S mode 03038 * @rmtoll CR1 SPE LL_I2S_Disable\n 03039 * I2SCFGR I2SMOD LL_I2S_Disable 03040 * @param SPIx SPI Handle 03041 * @retval None 03042 */ 03043 __STATIC_INLINE void LL_I2S_Disable(SPI_TypeDef *SPIx) 03044 { 03045 CLEAR_BIT(SPIx->CR1, SPI_CR1_SPE); 03046 CLEAR_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SMOD); 03047 } 03048 03049 /** 03050 * @brief Swap the SDO and SDI pin 03051 * @note This configuration can not be changed when I2S is enabled. 03052 * @rmtoll CFG2 IOSWP LL_I2S_EnableIOSwap 03053 * @param SPIx SPI Instance 03054 * @retval None 03055 */ 03056 __STATIC_INLINE void LL_I2S_EnableIOSwap(SPI_TypeDef *SPIx) 03057 { 03058 LL_SPI_EnableIOSwap(SPIx); 03059 } 03060 03061 /** 03062 * @brief Restore default function for SDO and SDI pin 03063 * @note This configuration can not be changed when I2S is enabled. 03064 * @rmtoll CFG2 IOSWP LL_I2S_DisableIOSwap 03065 * @param SPIx SPI Instance 03066 * @retval None 03067 */ 03068 __STATIC_INLINE void LL_I2S_DisableIOSwap(SPI_TypeDef *SPIx) 03069 { 03070 LL_SPI_DisableIOSwap(SPIx); 03071 } 03072 03073 /** 03074 * @brief Check if SDO and SDI pin are swapped 03075 * @rmtoll CFG2 IOSWP LL_I2S_IsEnabledIOSwap 03076 * @param SPIx SPI Instance 03077 * @retval State of bit (1 or 0) 03078 */ 03079 __STATIC_INLINE uint32_t LL_I2S_IsEnabledIOSwap(SPI_TypeDef *SPIx) 03080 { 03081 return LL_SPI_IsEnabledIOSwap(SPIx); 03082 } 03083 03084 /** 03085 * @brief Enable GPIO control 03086 * @note This configuration can not be changed when I2S is enabled. 03087 * @rmtoll CFG2 AFCNTR LL_I2S_EnableGPIOControl 03088 * @param SPIx SPI Instance 03089 * @retval None 03090 */ 03091 __STATIC_INLINE void LL_I2S_EnableGPIOControl(SPI_TypeDef *SPIx) 03092 { 03093 LL_SPI_EnableGPIOControl(SPIx); 03094 } 03095 03096 /** 03097 * @brief Disable GPIO control 03098 * @note This configuration can not be changed when I2S is enabled. 03099 * @rmtoll CFG2 AFCNTR LL_I2S_DisableGPIOControl 03100 * @param SPIx SPI Instance 03101 * @retval None 03102 */ 03103 __STATIC_INLINE void LL_I2S_DisableGPIOControl(SPI_TypeDef *SPIx) 03104 { 03105 LL_SPI_DisableGPIOControl(SPIx); 03106 } 03107 03108 /** 03109 * @brief Check if GPIO control is active 03110 * @rmtoll CFG2 AFCNTR LL_I2S_IsEnabledGPIOControl 03111 * @param SPIx SPI Instance 03112 * @retval State of bit (1 or 0) 03113 */ 03114 __STATIC_INLINE uint32_t LL_I2S_IsEnabledGPIOControl(SPI_TypeDef *SPIx) 03115 { 03116 return LL_SPI_IsEnabledGPIOControl(SPIx); 03117 } 03118 03119 /** 03120 * @brief Lock the AF configuration of associated IOs 03121 * @note Once this bit is set, the SPI_CFG2 register content can not be modified until a hardware reset occurs. 03122 * The reset of the IOLock bit is done by hardware. for that, LL_SPI_DisableIOLock can not exist. 03123 * @rmtoll CR1 IOLOCK LL_SPI_EnableIOLock 03124 * @param SPIx SPI Instance 03125 * @retval None 03126 */ 03127 __STATIC_INLINE void LL_I2S_EnableIOLock(SPI_TypeDef *SPIx) 03128 { 03129 LL_SPI_EnableIOLock(SPIx); 03130 } 03131 03132 /** 03133 * @brief Check if the the SPI_CFG2 register is locked 03134 * @rmtoll CR1 IOLOCK LL_I2S_IsEnabledIOLock 03135 * @param SPIx SPI Instance 03136 * @retval State of bit (1 or 0) 03137 */ 03138 __STATIC_INLINE uint32_t LL_I2S_IsEnabledIOLock(SPI_TypeDef *SPIx) 03139 { 03140 return LL_SPI_IsEnabledIOLock(SPIx); 03141 } 03142 03143 /** 03144 * @brief Set Transfer Bit Order 03145 * @note This configuration can not be changed when I2S is enabled. 03146 * @rmtoll CFG2 LSBFRST LL_I2S_SetTransferBitOrder 03147 * @param SPIx SPI Instance 03148 * @param BitOrder This parameter can be one of the following values: 03149 * @arg @ref LL_I2S_LSB_FIRST 03150 * @arg @ref LL_I2S_MSB_FIRST 03151 * @retval None 03152 */ 03153 __STATIC_INLINE void LL_I2S_SetTransferBitOrder(SPI_TypeDef *SPIx, uint32_t BitOrder) 03154 { 03155 LL_SPI_SetTransferBitOrder(SPIx, BitOrder); 03156 } 03157 /** 03158 * @brief Get Transfer Bit Order 03159 * @rmtoll CFG2 LSBFRST LL_I2S_GetTransferBitOrder 03160 * @param SPIx SPI Instance 03161 * @retval Returned value can be one of the following values: 03162 * @arg @ref LL_I2S_LSB_FIRST 03163 * @arg @ref LL_I2S_MSB_FIRST 03164 */ 03165 __STATIC_INLINE uint32_t LL_I2S_GetTransferBitOrder(SPI_TypeDef *SPIx) 03166 { 03167 return LL_SPI_GetTransferBitOrder(SPIx); 03168 } 03169 03170 /** 03171 * @brief Start effective transfer on wire 03172 * @rmtoll CR1 CSTART LL_I2S_StartTransfer 03173 * @param SPIx SPI Instance 03174 * @retval None 03175 */ 03176 __STATIC_INLINE void LL_I2S_StartTransfer(SPI_TypeDef *SPIx) 03177 { 03178 LL_SPI_StartMasterTransfer(SPIx); 03179 } 03180 03181 /** 03182 * @brief Check if there is an unfinished transfer 03183 * @rmtoll CR1 CSTART LL_I2S_IsTransferActive 03184 * @param SPIx SPI Instance 03185 * @retval State of bit (1 or 0) 03186 */ 03187 __STATIC_INLINE uint32_t LL_I2S_IsActiveTransfer(SPI_TypeDef *SPIx) 03188 { 03189 return LL_SPI_IsActiveMasterTransfer(SPIx); 03190 } 03191 03192 /** 03193 * @brief Set threshold of FIFO that triggers a transfer event 03194 * @note This configuration can not be changed when I2S is enabled. 03195 * @rmtoll CFG1 FTHLV LL_I2S_SetFIFOThreshold 03196 * @param SPIx SPI Instance 03197 * @param Threshold This parameter can be one of the following values: 03198 * @arg @ref LL_I2S_FIFO_TH_01DATA 03199 * @arg @ref LL_I2S_FIFO_TH_02DATA 03200 * @arg @ref LL_I2S_FIFO_TH_03DATA 03201 * @arg @ref LL_I2S_FIFO_TH_04DATA 03202 * @arg @ref LL_I2S_FIFO_TH_05DATA 03203 * @arg @ref LL_I2S_FIFO_TH_06DATA 03204 * @arg @ref LL_I2S_FIFO_TH_07DATA 03205 * @arg @ref LL_I2S_FIFO_TH_08DATA 03206 * @retval None 03207 */ 03208 __STATIC_INLINE void LL_I2S_SetFIFOThreshold(SPI_TypeDef *SPIx, uint32_t Threshold) 03209 { 03210 LL_SPI_SetFIFOThreshold(SPIx, Threshold); 03211 } 03212 03213 /** 03214 * @brief Get threshold of FIFO that triggers a transfer event 03215 * @rmtoll CFG1 FTHLV LL_I2S_GetFIFOThreshold 03216 * @param SPIx SPI Instance 03217 * @retval Returned value can be one of the following values: 03218 * @arg @ref LL_I2S_FIFO_TH_01DATA 03219 * @arg @ref LL_I2S_FIFO_TH_02DATA 03220 * @arg @ref LL_I2S_FIFO_TH_03DATA 03221 * @arg @ref LL_I2S_FIFO_TH_04DATA 03222 * @arg @ref LL_I2S_FIFO_TH_05DATA 03223 * @arg @ref LL_I2S_FIFO_TH_06DATA 03224 * @arg @ref LL_I2S_FIFO_TH_07DATA 03225 * @arg @ref LL_I2S_FIFO_TH_08DATA 03226 */ 03227 __STATIC_INLINE uint32_t LL_I2S_GetFIFOThreshold(SPI_TypeDef *SPIx) 03228 { 03229 return LL_SPI_GetFIFOThreshold(SPIx); 03230 } 03231 03232 /** 03233 * @brief Set I2S linear prescaler 03234 * @rmtoll I2SCFGR I2SDIV LL_I2S_SetPrescalerLinear 03235 * @param SPIx SPI Instance 03236 * @param PrescalerLinear Value between Min_Data=0x00 and Max_Data=0xFF 03237 * @note PrescalerLinear '1' is not authorized with parity LL_I2S_PRESCALER_PARITY_ODD 03238 * @retval None 03239 */ 03240 __STATIC_INLINE void LL_I2S_SetPrescalerLinear(SPI_TypeDef *SPIx, uint32_t PrescalerLinear) 03241 { 03242 MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_I2SDIV, (PrescalerLinear << SPI_I2SCFGR_I2SDIV_Pos)); 03243 } 03244 03245 /** 03246 * @brief Get I2S linear prescaler 03247 * @rmtoll I2SCFGR I2SDIV LL_I2S_GetPrescalerLinear 03248 * @param SPIx SPI Instance 03249 * @retval PrescalerLinear Value between Min_Data=0x00 and Max_Data=0xFF 03250 */ 03251 __STATIC_INLINE uint32_t LL_I2S_GetPrescalerLinear(SPI_TypeDef *SPIx) 03252 { 03253 return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_I2SDIV) >> SPI_I2SCFGR_I2SDIV_Pos); 03254 } 03255 03256 /** 03257 * @brief Set I2S parity prescaler 03258 * @rmtoll I2SCFGR ODD LL_I2S_SetPrescalerParity 03259 * @param SPIx SPI Instance 03260 * @param PrescalerParity This parameter can be one of the following values: 03261 * @arg @ref LL_I2S_PRESCALER_PARITY_EVEN 03262 * @arg @ref LL_I2S_PRESCALER_PARITY_ODD 03263 * @retval None 03264 */ 03265 __STATIC_INLINE void LL_I2S_SetPrescalerParity(SPI_TypeDef *SPIx, uint32_t PrescalerParity) 03266 { 03267 MODIFY_REG(SPIx->I2SCFGR, SPI_I2SCFGR_ODD, PrescalerParity << SPI_I2SCFGR_ODD_Pos); 03268 } 03269 03270 /** 03271 * @brief Get I2S parity prescaler 03272 * @rmtoll I2SCFGR ODD LL_I2S_GetPrescalerParity 03273 * @param SPIx SPI Instance 03274 * @retval Returned value can be one of the following values: 03275 * @arg @ref LL_I2S_PRESCALER_PARITY_EVEN 03276 * @arg @ref LL_I2S_PRESCALER_PARITY_ODD 03277 */ 03278 __STATIC_INLINE uint32_t LL_I2S_GetPrescalerParity(SPI_TypeDef *SPIx) 03279 { 03280 return (uint32_t)(READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_ODD) >> SPI_I2SCFGR_ODD_Pos); 03281 } 03282 03283 /** 03284 * @brief Enable the Master Clock Output (Pin MCK) 03285 * @rmtoll I2SCFGR MCKOE LL_I2S_EnableMasterClock 03286 * @param SPIx SPI Handle 03287 * @retval None 03288 */ 03289 __STATIC_INLINE void LL_I2S_EnableMasterClock(SPI_TypeDef *SPIx) 03290 { 03291 SET_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_MCKOE); 03292 } 03293 03294 /** 03295 * @brief Disable the Master Clock Output (Pin MCK) 03296 * @rmtoll I2SCFGR MCKOE LL_I2S_DisableMasterClock 03297 * @param SPIx SPI Handle 03298 * @retval None 03299 */ 03300 __STATIC_INLINE void LL_I2S_DisableMasterClock(SPI_TypeDef *SPIx) 03301 { 03302 CLEAR_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_MCKOE); 03303 } 03304 03305 /** 03306 * @brief Check if the master clock output (Pin MCK) is enabled 03307 * @rmtoll I2SCFGR MCKOE LL_I2S_IsEnabledMasterClock 03308 * @param SPIx SPI Instance 03309 * @retval State of bit (1 or 0) 03310 */ 03311 __STATIC_INLINE uint32_t LL_I2S_IsEnabledMasterClock(SPI_TypeDef *SPIx) 03312 { 03313 return ((READ_BIT(SPIx->I2SCFGR, SPI_I2SCFGR_MCKOE) == (SPI_I2SCFGR_MCKOE)) ? 1UL : 0UL); 03314 } 03315 03316 /** 03317 * @} 03318 */ 03319 03320 03321 /** @defgroup I2S_LL_EF_FLAG_Management FLAG_Management 03322 * @{ 03323 */ 03324 03325 /** 03326 * @brief Check if there enough data in FIFO to read a full packet 03327 * @rmtoll SR RXP LL_I2S_IsActiveFlag_RXP 03328 * @param SPIx SPI Instance 03329 * @retval State of bit (1 or 0) 03330 */ 03331 __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_RXP(SPI_TypeDef *SPIx) 03332 { 03333 return LL_SPI_IsActiveFlag_RXP(SPIx); 03334 } 03335 03336 /** 03337 * @brief Check if there enough space in FIFO to hold a full packet 03338 * @rmtoll SR TXP LL_I2S_IsActiveFlag_TXP 03339 * @param SPIx SPI Instance 03340 * @retval State of bit (1 or 0) 03341 */ 03342 __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_TXP(SPI_TypeDef *SPIx) 03343 { 03344 return LL_SPI_IsActiveFlag_TXP(SPIx); 03345 } 03346 03347 /** 03348 * @brief Get Underrun error flag 03349 * @rmtoll SR UDR LL_I2S_IsActiveFlag_UDR 03350 * @param SPIx SPI Instance 03351 * @retval State of bit (1 or 0) 03352 */ 03353 __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_UDR(SPI_TypeDef *SPIx) 03354 { 03355 return LL_SPI_IsActiveFlag_UDR(SPIx); 03356 } 03357 03358 /** 03359 * @brief Get Overrun error flag 03360 * @rmtoll SR OVR LL_I2S_IsActiveFlag_OVR 03361 * @param SPIx SPI Instance 03362 * @retval State of bit (1 or 0). 03363 */ 03364 __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_OVR(SPI_TypeDef *SPIx) 03365 { 03366 return LL_SPI_IsActiveFlag_OVR(SPIx); 03367 } 03368 03369 /** 03370 * @brief Get TI Frame format error flag 03371 * @rmtoll SR TIFRE LL_I2S_IsActiveFlag_FRE 03372 * @param SPIx SPI Instance 03373 * @retval State of bit (1 or 0). 03374 */ 03375 __STATIC_INLINE uint32_t LL_I2S_IsActiveFlag_FRE(SPI_TypeDef *SPIx) 03376 { 03377 return LL_SPI_IsActiveFlag_FRE(SPIx); 03378 } 03379 03380 /** 03381 * @brief Clear Underrun error flag 03382 * @rmtoll IFCR UDRC LL_I2S_ClearFlag_UDR 03383 * @param SPIx SPI Instance 03384 * @retval None 03385 */ 03386 __STATIC_INLINE void LL_I2S_ClearFlag_UDR(SPI_TypeDef *SPIx) 03387 { 03388 LL_SPI_ClearFlag_UDR(SPIx); 03389 } 03390 03391 /** 03392 * @brief Clear Overrun error flag 03393 * @rmtoll IFCR OVRC LL_I2S_ClearFlag_OVR 03394 * @param SPIx SPI Instance 03395 * @retval None 03396 */ 03397 __STATIC_INLINE void LL_I2S_ClearFlag_OVR(SPI_TypeDef *SPIx) 03398 { 03399 LL_SPI_ClearFlag_OVR(SPIx); 03400 } 03401 03402 /** 03403 * @brief Clear Frame format error flag 03404 * @rmtoll IFCR TIFREC LL_I2S_ClearFlag_FRE 03405 * @param SPIx SPI Instance 03406 * @retval None 03407 */ 03408 __STATIC_INLINE void LL_I2S_ClearFlag_FRE(SPI_TypeDef *SPIx) 03409 { 03410 LL_SPI_ClearFlag_FRE(SPIx); 03411 } 03412 03413 /** 03414 * @} 03415 */ 03416 03417 /** @defgroup I2S_LL_EF_IT_Management IT_Management 03418 * @{ 03419 */ 03420 03421 /** 03422 * @brief Enable Rx Packet available IT 03423 * @rmtoll IER RXPIE LL_I2S_EnableIT_RXP 03424 * @param SPIx SPI Instance 03425 * @retval None 03426 */ 03427 __STATIC_INLINE void LL_I2S_EnableIT_RXP(SPI_TypeDef *SPIx) 03428 { 03429 LL_SPI_EnableIT_RXP(SPIx); 03430 } 03431 03432 /** 03433 * @brief Enable Tx Packet space available IT 03434 * @rmtoll IER TXPIE LL_I2S_EnableIT_TXP 03435 * @param SPIx SPI Instance 03436 * @retval None 03437 */ 03438 __STATIC_INLINE void LL_I2S_EnableIT_TXP(SPI_TypeDef *SPIx) 03439 { 03440 LL_SPI_EnableIT_TXP(SPIx); 03441 } 03442 03443 /** 03444 * @brief Enable Underrun IT 03445 * @rmtoll IER UDRIE LL_I2S_EnableIT_UDR 03446 * @param SPIx SPI Instance 03447 * @retval None 03448 */ 03449 __STATIC_INLINE void LL_I2S_EnableIT_UDR(SPI_TypeDef *SPIx) 03450 { 03451 LL_SPI_EnableIT_UDR(SPIx); 03452 } 03453 03454 /** 03455 * @brief Enable Overrun IT 03456 * @rmtoll IER OVRIE LL_I2S_EnableIT_OVR 03457 * @param SPIx SPI Instance 03458 * @retval None 03459 */ 03460 __STATIC_INLINE void LL_I2S_EnableIT_OVR(SPI_TypeDef *SPIx) 03461 { 03462 LL_SPI_EnableIT_OVR(SPIx); 03463 } 03464 03465 /** 03466 * @brief Enable TI Frame Format Error IT 03467 * @rmtoll IER TIFREIE LL_I2S_EnableIT_FRE 03468 * @param SPIx SPI Instance 03469 * @retval None 03470 */ 03471 __STATIC_INLINE void LL_I2S_EnableIT_FRE(SPI_TypeDef *SPIx) 03472 { 03473 LL_SPI_EnableIT_FRE(SPIx); 03474 } 03475 03476 /** 03477 * @brief Disable Rx Packet available IT 03478 * @rmtoll IER RXPIE LL_I2S_DisableIT_RXP 03479 * @param SPIx SPI Instance 03480 * @retval None 03481 */ 03482 __STATIC_INLINE void LL_I2S_DisableIT_RXP(SPI_TypeDef *SPIx) 03483 { 03484 LL_SPI_DisableIT_RXP(SPIx); 03485 } 03486 03487 /** 03488 * @brief Disable Tx Packet space available IT 03489 * @rmtoll IER TXPIE LL_I2S_DisableIT_TXP 03490 * @param SPIx SPI Instance 03491 * @retval None 03492 */ 03493 __STATIC_INLINE void LL_I2S_DisableIT_TXP(SPI_TypeDef *SPIx) 03494 { 03495 LL_SPI_DisableIT_TXP(SPIx); 03496 } 03497 03498 /** 03499 * @brief Disable Underrun IT 03500 * @rmtoll IER UDRIE LL_I2S_DisableIT_UDR 03501 * @param SPIx SPI Instance 03502 * @retval None 03503 */ 03504 __STATIC_INLINE void LL_I2S_DisableIT_UDR(SPI_TypeDef *SPIx) 03505 { 03506 LL_SPI_DisableIT_UDR(SPIx); 03507 } 03508 03509 /** 03510 * @brief Disable Overrun IT 03511 * @rmtoll IER OVRIE LL_I2S_DisableIT_OVR 03512 * @param SPIx SPI Instance 03513 * @retval None 03514 */ 03515 __STATIC_INLINE void LL_I2S_DisableIT_OVR(SPI_TypeDef *SPIx) 03516 { 03517 LL_SPI_DisableIT_OVR(SPIx); 03518 } 03519 03520 /** 03521 * @brief Disable TI Frame Format Error IT 03522 * @rmtoll IER TIFREIE LL_I2S_DisableIT_FRE 03523 * @param SPIx SPI Instance 03524 * @retval None 03525 */ 03526 __STATIC_INLINE void LL_I2S_DisableIT_FRE(SPI_TypeDef *SPIx) 03527 { 03528 LL_SPI_DisableIT_FRE(SPIx); 03529 } 03530 03531 /** 03532 * @brief Check if Rx Packet available IT is enabled 03533 * @rmtoll IER RXPIE LL_I2S_IsEnabledIT_RXP 03534 * @param SPIx SPI Instance 03535 * @retval State of bit (1 or 0) 03536 */ 03537 __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_RXP(SPI_TypeDef *SPIx) 03538 { 03539 return LL_SPI_IsEnabledIT_RXP(SPIx); 03540 } 03541 03542 /** 03543 * @brief Check if Tx Packet space available IT is enabled 03544 * @rmtoll IER TXPIE LL_I2S_IsEnabledIT_TXP 03545 * @param SPIx SPI Instance 03546 * @retval State of bit (1 or 0) 03547 */ 03548 __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_TXP(SPI_TypeDef *SPIx) 03549 { 03550 return LL_SPI_IsEnabledIT_TXP(SPIx); 03551 } 03552 03553 /** 03554 * @brief Check if Underrun IT is enabled 03555 * @rmtoll IER UDRIE LL_I2S_IsEnabledIT_UDR 03556 * @param SPIx SPI Instance 03557 * @retval State of bit (1 or 0) 03558 */ 03559 __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_UDR(SPI_TypeDef *SPIx) 03560 { 03561 return LL_SPI_IsEnabledIT_UDR(SPIx); 03562 } 03563 03564 /** 03565 * @brief Check if Overrun IT is enabled 03566 * @rmtoll IER OVRIE LL_I2S_IsEnabledIT_OVR 03567 * @param SPIx SPI Instance 03568 * @retval State of bit (1 or 0) 03569 */ 03570 __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_OVR(SPI_TypeDef *SPIx) 03571 { 03572 return LL_SPI_IsEnabledIT_OVR(SPIx); 03573 } 03574 03575 /** 03576 * @brief Check if TI Frame Format Error IT is enabled 03577 * @rmtoll IER TIFREIE LL_I2S_IsEnabledIT_FRE 03578 * @param SPIx SPI Instance 03579 * @retval State of bit (1 or 0) 03580 */ 03581 __STATIC_INLINE uint32_t LL_I2S_IsEnabledIT_FRE(SPI_TypeDef *SPIx) 03582 { 03583 return LL_SPI_IsEnabledIT_FRE(SPIx); 03584 } 03585 03586 /** 03587 * @} 03588 */ 03589 03590 /** @defgroup I2S_LL_EF_DMA_Management DMA_Management 03591 * @{ 03592 */ 03593 03594 /** 03595 * @brief Enable DMA Rx 03596 * @rmtoll CFG1 RXDMAEN LL_I2S_EnableDMAReq_RX 03597 * @param SPIx SPI Instance 03598 * @retval None 03599 */ 03600 __STATIC_INLINE void LL_I2S_EnableDMAReq_RX(SPI_TypeDef *SPIx) 03601 { 03602 LL_SPI_EnableDMAReq_RX(SPIx); 03603 } 03604 03605 /** 03606 * @brief Disable DMA Rx 03607 * @rmtoll CFG1 RXDMAEN LL_I2S_DisableDMAReq_RX 03608 * @param SPIx SPI Instance 03609 * @retval None 03610 */ 03611 __STATIC_INLINE void LL_I2S_DisableDMAReq_RX(SPI_TypeDef *SPIx) 03612 { 03613 LL_SPI_DisableDMAReq_RX(SPIx); 03614 } 03615 03616 /** 03617 * @brief Check if DMA Rx is enabled 03618 * @rmtoll CFG1 RXDMAEN LL_I2S_IsEnabledDMAReq_RX 03619 * @param SPIx SPI Instance 03620 * @retval State of bit (1 or 0) 03621 */ 03622 __STATIC_INLINE uint32_t LL_I2S_IsEnabledDMAReq_RX(SPI_TypeDef *SPIx) 03623 { 03624 return LL_SPI_IsEnabledDMAReq_RX(SPIx); 03625 } 03626 03627 /** 03628 * @brief Enable DMA Tx 03629 * @rmtoll CFG1 TXDMAEN LL_I2S_EnableDMAReq_TX 03630 * @param SPIx SPI Instance 03631 * @retval None 03632 */ 03633 __STATIC_INLINE void LL_I2S_EnableDMAReq_TX(SPI_TypeDef *SPIx) 03634 { 03635 LL_SPI_EnableDMAReq_TX(SPIx); 03636 } 03637 03638 /** 03639 * @brief Disable DMA Tx 03640 * @rmtoll CFG1 TXDMAEN LL_I2S_DisableDMAReq_TX 03641 * @param SPIx SPI Instance 03642 * @retval None 03643 */ 03644 __STATIC_INLINE void LL_I2S_DisableDMAReq_TX(SPI_TypeDef *SPIx) 03645 { 03646 LL_SPI_DisableDMAReq_TX(SPIx); 03647 } 03648 03649 /** 03650 * @brief Check if DMA Tx is enabled 03651 * @rmtoll CFG1 TXDMAEN LL_I2S_IsEnabledDMAReq_TX 03652 * @param SPIx SPI Instance 03653 * @retval State of bit (1 or 0) 03654 */ 03655 __STATIC_INLINE uint32_t LL_I2S_IsEnabledDMAReq_TX(SPI_TypeDef *SPIx) 03656 { 03657 return LL_SPI_IsEnabledDMAReq_TX(SPIx); 03658 } 03659 03660 /** 03661 * @} 03662 */ 03663 03664 /** @defgroup I2S_LL_EF_DATA_Management DATA_Management 03665 * @{ 03666 */ 03667 03668 /** 03669 * @brief Read Data Register 03670 * @rmtoll RXDR . LL_I2S_ReceiveData16 03671 * @param SPIx SPI Instance 03672 * @retval 0..0xFFFF 03673 */ 03674 __STATIC_INLINE uint16_t LL_I2S_ReceiveData16(SPI_TypeDef *SPIx) 03675 { 03676 return LL_SPI_ReceiveData16(SPIx); 03677 } 03678 03679 /** 03680 * @brief Read Data Register 03681 * @rmtoll RXDR . LL_I2S_ReceiveData32 03682 * @param SPIx SPI Instance 03683 * @retval 0..0xFFFFFFFF 03684 */ 03685 __STATIC_INLINE uint32_t LL_I2S_ReceiveData32(SPI_TypeDef *SPIx) 03686 { 03687 return LL_SPI_ReceiveData32(SPIx); 03688 } 03689 03690 /** 03691 * @brief Write Data Register 03692 * @rmtoll TXDR . LL_I2S_TransmitData16 03693 * @param SPIx SPI Instance 03694 * @param TxData 0..0xFFFF 03695 * @retval None 03696 */ 03697 __STATIC_INLINE void LL_I2S_TransmitData16(SPI_TypeDef *SPIx, uint16_t TxData) 03698 { 03699 LL_SPI_TransmitData16(SPIx, TxData); 03700 } 03701 03702 /** 03703 * @brief Write Data Register 03704 * @rmtoll TXDR . LL_I2S_TransmitData32 03705 * @param SPIx SPI Instance 03706 * @param TxData 0..0xFFFFFFFF 03707 * @retval None 03708 */ 03709 __STATIC_INLINE void LL_I2S_TransmitData32(SPI_TypeDef *SPIx, uint32_t TxData) 03710 { 03711 LL_SPI_TransmitData32(SPIx, TxData); 03712 } 03713 03714 /** 03715 * @} 03716 */ 03717 03718 03719 #if defined(USE_FULL_LL_DRIVER) 03720 /** @defgroup SPI_LL_EF_Init Initialization and de-initialization functions 03721 * @{ 03722 */ 03723 03724 ErrorStatus LL_I2S_DeInit(SPI_TypeDef *SPIx); 03725 ErrorStatus LL_I2S_Init(SPI_TypeDef *SPIx, LL_I2S_InitTypeDef *I2S_InitStruct); 03726 void LL_I2S_StructInit(LL_I2S_InitTypeDef *I2S_InitStruct); 03727 void LL_I2S_ConfigPrescaler(SPI_TypeDef *SPIx, uint32_t PrescalerLinear, uint32_t PrescalerParity); 03728 03729 /** 03730 * @} 03731 */ 03732 #endif /* USE_FULL_LL_DRIVER */ 03733 03734 /** 03735 * @} 03736 */ 03737 03738 /** 03739 * @} 03740 */ 03741 03742 #endif /* defined(SPI1) || defined(SPI2) || defined(SPI3) || defined(SPI4) || defined(SPI5) || defined(SPI6) */ 03743 03744 /** 03745 * @} 03746 */ 03747 03748 /** 03749 * @} 03750 */ 03751 #ifdef __cplusplus 03752 } 03753 #endif 03754 03755 #endif /* STM32H7xx_LL_SPI_H */