stm32l4xx_hal_dfsdm.h 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798
  1. /**
  2. ******************************************************************************
  3. * @file stm32l4xx_hal_dfsdm.h
  4. * @author MCD Application Team
  5. * @brief Header file of DFSDM HAL module.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
  10. *
  11. * Redistribution and use in source and binary forms, with or without modification,
  12. * are permitted provided that the following conditions are met:
  13. * 1. Redistributions of source code must retain the above copyright notice,
  14. * this list of conditions and the following disclaimer.
  15. * 2. Redistributions in binary form must reproduce the above copyright notice,
  16. * this list of conditions and the following disclaimer in the documentation
  17. * and/or other materials provided with the distribution.
  18. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  19. * may be used to endorse or promote products derived from this software
  20. * without specific prior written permission.
  21. *
  22. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  23. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  24. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  25. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  26. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  27. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  28. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  29. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  30. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. *
  33. ******************************************************************************
  34. */
  35. /* Define to prevent recursive inclusion -------------------------------------*/
  36. #ifndef __STM32L4xx_HAL_DFSDM_H
  37. #define __STM32L4xx_HAL_DFSDM_H
  38. #ifdef __cplusplus
  39. extern "C" {
  40. #endif
  41. #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx) || \
  42. defined(STM32L471xx) || defined(STM32L475xx) || defined(STM32L476xx) || defined(STM32L485xx) || defined(STM32L486xx) || \
  43. defined(STM32L496xx) || defined(STM32L4A6xx) || \
  44. defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  45. /* Includes ------------------------------------------------------------------*/
  46. #include "stm32l4xx_hal_def.h"
  47. /** @addtogroup STM32L4xx_HAL_Driver
  48. * @{
  49. */
  50. /** @addtogroup DFSDM
  51. * @{
  52. */
  53. /* Exported types ------------------------------------------------------------*/
  54. /** @defgroup DFSDM_Exported_Types DFSDM Exported Types
  55. * @{
  56. */
  57. /**
  58. * @brief HAL DFSDM Channel states definition
  59. */
  60. typedef enum
  61. {
  62. HAL_DFSDM_CHANNEL_STATE_RESET = 0x00U, /*!< DFSDM channel not initialized */
  63. HAL_DFSDM_CHANNEL_STATE_READY = 0x01U, /*!< DFSDM channel initialized and ready for use */
  64. HAL_DFSDM_CHANNEL_STATE_ERROR = 0xFFU /*!< DFSDM channel state error */
  65. }HAL_DFSDM_Channel_StateTypeDef;
  66. /**
  67. * @brief DFSDM channel output clock structure definition
  68. */
  69. typedef struct
  70. {
  71. FunctionalState Activation; /*!< Output clock enable/disable */
  72. uint32_t Selection; /*!< Output clock is system clock or audio clock.
  73. This parameter can be a value of @ref DFSDM_Channel_OuputClock */
  74. uint32_t Divider; /*!< Output clock divider.
  75. This parameter must be a number between Min_Data = 2 and Max_Data = 256 */
  76. }DFSDM_Channel_OutputClockTypeDef;
  77. /**
  78. * @brief DFSDM channel input structure definition
  79. */
  80. typedef struct
  81. {
  82. uint32_t Multiplexer; /*!< Input is external serial inputs, internal register or ADC output.
  83. ADC output is available only on STM32L451xx, STM32L452xx, STM32L462xx,
  84. STM32L496xx, STM32L4A6xx, STM32L4R5xx, STM32L4R7xx, STM32L4R9xx,
  85. STM32L4S5xx, STM32L4S7xx and STM32L4S9xx products.
  86. This parameter can be a value of @ref DFSDM_Channel_InputMultiplexer */
  87. uint32_t DataPacking; /*!< Standard, interleaved or dual mode for internal register.
  88. This parameter can be a value of @ref DFSDM_Channel_DataPacking */
  89. uint32_t Pins; /*!< Input pins are taken from same or following channel.
  90. This parameter can be a value of @ref DFSDM_Channel_InputPins */
  91. }DFSDM_Channel_InputTypeDef;
  92. /**
  93. * @brief DFSDM channel serial interface structure definition
  94. */
  95. typedef struct
  96. {
  97. uint32_t Type; /*!< SPI or Manchester modes.
  98. This parameter can be a value of @ref DFSDM_Channel_SerialInterfaceType */
  99. uint32_t SpiClock; /*!< SPI clock select (external or internal with different sampling point).
  100. This parameter can be a value of @ref DFSDM_Channel_SpiClock */
  101. }DFSDM_Channel_SerialInterfaceTypeDef;
  102. /**
  103. * @brief DFSDM channel analog watchdog structure definition
  104. */
  105. typedef struct
  106. {
  107. uint32_t FilterOrder; /*!< Analog watchdog Sinc filter order.
  108. This parameter can be a value of @ref DFSDM_Channel_AwdFilterOrder */
  109. uint32_t Oversampling; /*!< Analog watchdog filter oversampling ratio.
  110. This parameter must be a number between Min_Data = 1 and Max_Data = 32 */
  111. }DFSDM_Channel_AwdTypeDef;
  112. /**
  113. * @brief DFSDM channel init structure definition
  114. */
  115. typedef struct
  116. {
  117. DFSDM_Channel_OutputClockTypeDef OutputClock; /*!< DFSDM channel output clock parameters */
  118. DFSDM_Channel_InputTypeDef Input; /*!< DFSDM channel input parameters */
  119. DFSDM_Channel_SerialInterfaceTypeDef SerialInterface; /*!< DFSDM channel serial interface parameters */
  120. DFSDM_Channel_AwdTypeDef Awd; /*!< DFSDM channel analog watchdog parameters */
  121. int32_t Offset; /*!< DFSDM channel offset.
  122. This parameter must be a number between Min_Data = -8388608 and Max_Data = 8388607 */
  123. uint32_t RightBitShift; /*!< DFSDM channel right bit shift.
  124. This parameter must be a number between Min_Data = 0x00 and Max_Data = 0x1F */
  125. }DFSDM_Channel_InitTypeDef;
  126. /**
  127. * @brief DFSDM channel handle structure definition
  128. */
  129. typedef struct
  130. {
  131. DFSDM_Channel_TypeDef *Instance; /*!< DFSDM channel instance */
  132. DFSDM_Channel_InitTypeDef Init; /*!< DFSDM channel init parameters */
  133. HAL_DFSDM_Channel_StateTypeDef State; /*!< DFSDM channel state */
  134. }DFSDM_Channel_HandleTypeDef;
  135. /**
  136. * @brief HAL DFSDM Filter states definition
  137. */
  138. typedef enum
  139. {
  140. HAL_DFSDM_FILTER_STATE_RESET = 0x00U, /*!< DFSDM filter not initialized */
  141. HAL_DFSDM_FILTER_STATE_READY = 0x01U, /*!< DFSDM filter initialized and ready for use */
  142. HAL_DFSDM_FILTER_STATE_REG = 0x02U, /*!< DFSDM filter regular conversion in progress */
  143. HAL_DFSDM_FILTER_STATE_INJ = 0x03U, /*!< DFSDM filter injected conversion in progress */
  144. HAL_DFSDM_FILTER_STATE_REG_INJ = 0x04U, /*!< DFSDM filter regular and injected conversions in progress */
  145. HAL_DFSDM_FILTER_STATE_ERROR = 0xFFU /*!< DFSDM filter state error */
  146. }HAL_DFSDM_Filter_StateTypeDef;
  147. /**
  148. * @brief DFSDM filter regular conversion parameters structure definition
  149. */
  150. typedef struct
  151. {
  152. uint32_t Trigger; /*!< Trigger used to start regular conversion: software or synchronous.
  153. This parameter can be a value of @ref DFSDM_Filter_Trigger */
  154. FunctionalState FastMode; /*!< Enable/disable fast mode for regular conversion */
  155. FunctionalState DmaMode; /*!< Enable/disable DMA for regular conversion */
  156. }DFSDM_Filter_RegularParamTypeDef;
  157. /**
  158. * @brief DFSDM filter injected conversion parameters structure definition
  159. */
  160. typedef struct
  161. {
  162. uint32_t Trigger; /*!< Trigger used to start injected conversion: software, external or synchronous.
  163. This parameter can be a value of @ref DFSDM_Filter_Trigger */
  164. FunctionalState ScanMode; /*!< Enable/disable scanning mode for injected conversion */
  165. FunctionalState DmaMode; /*!< Enable/disable DMA for injected conversion */
  166. uint32_t ExtTrigger; /*!< External trigger.
  167. This parameter can be a value of @ref DFSDM_Filter_ExtTrigger */
  168. uint32_t ExtTriggerEdge; /*!< External trigger edge: rising, falling or both.
  169. This parameter can be a value of @ref DFSDM_Filter_ExtTriggerEdge */
  170. }DFSDM_Filter_InjectedParamTypeDef;
  171. /**
  172. * @brief DFSDM filter parameters structure definition
  173. */
  174. typedef struct
  175. {
  176. uint32_t SincOrder; /*!< Sinc filter order.
  177. This parameter can be a value of @ref DFSDM_Filter_SincOrder */
  178. uint32_t Oversampling; /*!< Filter oversampling ratio.
  179. This parameter must be a number between Min_Data = 1 and Max_Data = 1024 */
  180. uint32_t IntOversampling; /*!< Integrator oversampling ratio.
  181. This parameter must be a number between Min_Data = 1 and Max_Data = 256 */
  182. }DFSDM_Filter_FilterParamTypeDef;
  183. /**
  184. * @brief DFSDM filter init structure definition
  185. */
  186. typedef struct
  187. {
  188. DFSDM_Filter_RegularParamTypeDef RegularParam; /*!< DFSDM regular conversion parameters */
  189. DFSDM_Filter_InjectedParamTypeDef InjectedParam; /*!< DFSDM injected conversion parameters */
  190. DFSDM_Filter_FilterParamTypeDef FilterParam; /*!< DFSDM filter parameters */
  191. }DFSDM_Filter_InitTypeDef;
  192. /**
  193. * @brief DFSDM filter handle structure definition
  194. */
  195. typedef struct
  196. {
  197. DFSDM_Filter_TypeDef *Instance; /*!< DFSDM filter instance */
  198. DFSDM_Filter_InitTypeDef Init; /*!< DFSDM filter init parameters */
  199. DMA_HandleTypeDef *hdmaReg; /*!< Pointer on DMA handler for regular conversions */
  200. DMA_HandleTypeDef *hdmaInj; /*!< Pointer on DMA handler for injected conversions */
  201. uint32_t RegularContMode; /*!< Regular conversion continuous mode */
  202. uint32_t RegularTrigger; /*!< Trigger used for regular conversion */
  203. uint32_t InjectedTrigger; /*!< Trigger used for injected conversion */
  204. uint32_t ExtTriggerEdge; /*!< Rising, falling or both edges selected */
  205. FunctionalState InjectedScanMode; /*!< Injected scanning mode */
  206. uint32_t InjectedChannelsNbr; /*!< Number of channels in injected sequence */
  207. uint32_t InjConvRemaining; /*!< Injected conversions remaining */
  208. HAL_DFSDM_Filter_StateTypeDef State; /*!< DFSDM filter state */
  209. uint32_t ErrorCode; /*!< DFSDM filter error code */
  210. }DFSDM_Filter_HandleTypeDef;
  211. /**
  212. * @brief DFSDM filter analog watchdog parameters structure definition
  213. */
  214. typedef struct
  215. {
  216. uint32_t DataSource; /*!< Values from digital filter or from channel watchdog filter.
  217. This parameter can be a value of @ref DFSDM_Filter_AwdDataSource */
  218. uint32_t Channel; /*!< Analog watchdog channel selection.
  219. This parameter can be a values combination of @ref DFSDM_Channel_Selection */
  220. int32_t HighThreshold; /*!< High threshold for the analog watchdog.
  221. This parameter must be a number between Min_Data = -8388608 and Max_Data = 8388607 */
  222. int32_t LowThreshold; /*!< Low threshold for the analog watchdog.
  223. This parameter must be a number between Min_Data = -8388608 and Max_Data = 8388607 */
  224. uint32_t HighBreakSignal; /*!< Break signal assigned to analog watchdog high threshold event.
  225. This parameter can be a values combination of @ref DFSDM_BreakSignals */
  226. uint32_t LowBreakSignal; /*!< Break signal assigned to analog watchdog low threshold event.
  227. This parameter can be a values combination of @ref DFSDM_BreakSignals */
  228. }DFSDM_Filter_AwdParamTypeDef;
  229. /**
  230. * @}
  231. */
  232. /* End of exported types -----------------------------------------------------*/
  233. /* Exported constants --------------------------------------------------------*/
  234. /** @defgroup DFSDM_Exported_Constants DFSDM Exported Constants
  235. * @{
  236. */
  237. /** @defgroup DFSDM_Channel_OuputClock DFSDM channel output clock selection
  238. * @{
  239. */
  240. #define DFSDM_CHANNEL_OUTPUT_CLOCK_SYSTEM ((uint32_t)0x00000000U) /*!< Source for ouput clock is system clock */
  241. #define DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO DFSDM_CHCFGR1_CKOUTSRC /*!< Source for ouput clock is audio clock */
  242. /**
  243. * @}
  244. */
  245. /** @defgroup DFSDM_Channel_InputMultiplexer DFSDM channel input multiplexer
  246. * @{
  247. */
  248. #define DFSDM_CHANNEL_EXTERNAL_INPUTS ((uint32_t)0x00000000U) /*!< Data are taken from external inputs */
  249. #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx) || \
  250. defined(STM32L496xx) || defined(STM32L4A6xx) || \
  251. defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  252. #define DFSDM_CHANNEL_ADC_OUTPUT DFSDM_CHCFGR1_DATMPX_0 /*!< Data are taken from ADC output */
  253. #endif /* STM32L451xx || STM32L452xx || STM32L462xx || STM32L496xx || STM32L4A6xx || STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  254. #define DFSDM_CHANNEL_INTERNAL_REGISTER DFSDM_CHCFGR1_DATMPX_1 /*!< Data are taken from internal register */
  255. /**
  256. * @}
  257. */
  258. /** @defgroup DFSDM_Channel_DataPacking DFSDM channel input data packing
  259. * @{
  260. */
  261. #define DFSDM_CHANNEL_STANDARD_MODE ((uint32_t)0x00000000U) /*!< Standard data packing mode */
  262. #define DFSDM_CHANNEL_INTERLEAVED_MODE DFSDM_CHCFGR1_DATPACK_0 /*!< Interleaved data packing mode */
  263. #define DFSDM_CHANNEL_DUAL_MODE DFSDM_CHCFGR1_DATPACK_1 /*!< Dual data packing mode */
  264. /**
  265. * @}
  266. */
  267. /** @defgroup DFSDM_Channel_InputPins DFSDM channel input pins
  268. * @{
  269. */
  270. #define DFSDM_CHANNEL_SAME_CHANNEL_PINS ((uint32_t)0x00000000U) /*!< Input from pins on same channel */
  271. #define DFSDM_CHANNEL_FOLLOWING_CHANNEL_PINS DFSDM_CHCFGR1_CHINSEL /*!< Input from pins on following channel */
  272. /**
  273. * @}
  274. */
  275. /** @defgroup DFSDM_Channel_SerialInterfaceType DFSDM channel serial interface type
  276. * @{
  277. */
  278. #define DFSDM_CHANNEL_SPI_RISING ((uint32_t)0x00000000U) /*!< SPI with rising edge */
  279. #define DFSDM_CHANNEL_SPI_FALLING DFSDM_CHCFGR1_SITP_0 /*!< SPI with falling edge */
  280. #define DFSDM_CHANNEL_MANCHESTER_RISING DFSDM_CHCFGR1_SITP_1 /*!< Manchester with rising edge */
  281. #define DFSDM_CHANNEL_MANCHESTER_FALLING DFSDM_CHCFGR1_SITP /*!< Manchester with falling edge */
  282. /**
  283. * @}
  284. */
  285. /** @defgroup DFSDM_Channel_SpiClock DFSDM channel SPI clock selection
  286. * @{
  287. */
  288. #define DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL ((uint32_t)0x00000000U) /*!< External SPI clock */
  289. #define DFSDM_CHANNEL_SPI_CLOCK_INTERNAL DFSDM_CHCFGR1_SPICKSEL_0 /*!< Internal SPI clock */
  290. #define DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING DFSDM_CHCFGR1_SPICKSEL_1 /*!< Internal SPI clock divided by 2, falling edge */
  291. #define DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING DFSDM_CHCFGR1_SPICKSEL /*!< Internal SPI clock divided by 2, rising edge */
  292. /**
  293. * @}
  294. */
  295. /** @defgroup DFSDM_Channel_AwdFilterOrder DFSDM channel analog watchdog filter order
  296. * @{
  297. */
  298. #define DFSDM_CHANNEL_FASTSINC_ORDER ((uint32_t)0x00000000U) /*!< FastSinc filter type */
  299. #define DFSDM_CHANNEL_SINC1_ORDER DFSDM_CHAWSCDR_AWFORD_0 /*!< Sinc 1 filter type */
  300. #define DFSDM_CHANNEL_SINC2_ORDER DFSDM_CHAWSCDR_AWFORD_1 /*!< Sinc 2 filter type */
  301. #define DFSDM_CHANNEL_SINC3_ORDER DFSDM_CHAWSCDR_AWFORD /*!< Sinc 3 filter type */
  302. /**
  303. * @}
  304. */
  305. /** @defgroup DFSDM_Filter_Trigger DFSDM filter conversion trigger
  306. * @{
  307. */
  308. #define DFSDM_FILTER_SW_TRIGGER ((uint32_t)0x00000000U) /*!< Software trigger */
  309. #define DFSDM_FILTER_SYNC_TRIGGER ((uint32_t)0x00000001U) /*!< Synchronous with DFSDM_FLT0 */
  310. #define DFSDM_FILTER_EXT_TRIGGER ((uint32_t)0x00000002U) /*!< External trigger (only for injected conversion) */
  311. /**
  312. * @}
  313. */
  314. /** @defgroup DFSDM_Filter_ExtTrigger DFSDM filter external trigger
  315. * @{
  316. */
  317. #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx)
  318. #define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO ((uint32_t)0x00000000U) /*!< For DFSDM filter 0, 1, 2 and 3 */
  319. #define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2 DFSDM_FLTCR1_JEXTSEL_0 /*!< For DFSDM filter 0, 1, 2 and 3 */
  320. #define DFSDM_FILTER_EXT_TRIG_TIM3_TRGO DFSDM_FLTCR1_JEXTSEL_1 /*!< For DFSDM filter 0, 1, 2 and 3 */
  321. #define DFSDM_FILTER_EXT_TRIG_TIM16_OC1 (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_1) /*!< For DFSDM filter 0, 1 and 2 */
  322. #define DFSDM_FILTER_EXT_TRIG_TIM6_TRGO (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_2) /*!< For DFSDM filter 0 and 1 */
  323. #define DFSDM_FILTER_EXT_TRIG_EXTI11 (DFSDM_FLTCR1_JEXTSEL_1 | DFSDM_FLTCR1_JEXTSEL_2) /*!< For DFSDM filter 0, 1, 2 and 3 */
  324. #define DFSDM_FILTER_EXT_TRIG_EXTI15 DFSDM_FLTCR1_JEXTSEL /*!< For DFSDM filter 0, 1, 2 and 3 */
  325. #elif defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  326. #define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO ((uint32_t)0x00000000U) /*!< For all DFSDM filters */
  327. #define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2 DFSDM_FLTCR1_JEXTSEL_0 /*!< For all DFSDM filters */
  328. #define DFSDM_FILTER_EXT_TRIG_TIM8_TRGO DFSDM_FLTCR1_JEXTSEL_1 /*!< For all DFSDM filters */
  329. #define DFSDM_FILTER_EXT_TRIG_TIM8_TRGO2 (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_1) /*!< For all DFSDM filters */
  330. #define DFSDM_FILTER_EXT_TRIG_TIM3_TRGO DFSDM_FLTCR1_JEXTSEL_2 /*!< For all DFSDM filters */
  331. #define DFSDM_FILTER_EXT_TRIG_TIM4_TRGO (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_2) /*!< For all DFSDM filters */
  332. #define DFSDM_FILTER_EXT_TRIG_TIM16_OC1 (DFSDM_FLTCR1_JEXTSEL_1 | DFSDM_FLTCR1_JEXTSEL_2) /*!< For all DFSDM filters */
  333. #define DFSDM_FILTER_EXT_TRIG_TIM6_TRGO (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_1 | \
  334. DFSDM_FLTCR1_JEXTSEL_2) /*!< For all DFSDM filters */
  335. #define DFSDM_FILTER_EXT_TRIG_TIM7_TRGO DFSDM_FLTCR1_JEXTSEL_3 /*!< For all DFSDM filters */
  336. #define DFSDM_FILTER_EXT_TRIG_EXTI11 (DFSDM_FLTCR1_JEXTSEL_3 | DFSDM_FLTCR1_JEXTSEL_4) /*!< For all DFSDM filters */
  337. #define DFSDM_FILTER_EXT_TRIG_EXTI15 (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_3 | \
  338. DFSDM_FLTCR1_JEXTSEL_4) /*!< For all DFSDM filters */
  339. #define DFSDM_FILTER_EXT_TRIG_LPTIM1_OUT (DFSDM_FLTCR1_JEXTSEL_1 | DFSDM_FLTCR1_JEXTSEL_3 | \
  340. DFSDM_FLTCR1_JEXTSEL_4) /*!< For all DFSDM filters */
  341. #else
  342. #define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO ((uint32_t)0x00000000U) /*!< For DFSDM filter 0, 1, 2 and 3 */
  343. #define DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2 DFSDM_FLTCR1_JEXTSEL_0 /*!< For DFSDM filter 0, 1, 2 and 3 */
  344. #define DFSDM_FILTER_EXT_TRIG_TIM8_TRGO DFSDM_FLTCR1_JEXTSEL_1 /*!< For DFSDM filter 0, 1, 2 and 3 */
  345. #define DFSDM_FILTER_EXT_TRIG_TIM8_TRGO2 (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_1) /*!< For DFSDM filter 0, 1 and 2 */
  346. #define DFSDM_FILTER_EXT_TRIG_TIM3_TRGO (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_1) /*!< For DFSDM filter 3 */
  347. #define DFSDM_FILTER_EXT_TRIG_TIM4_TRGO DFSDM_FLTCR1_JEXTSEL_2 /*!< For DFSDM filter 0, 1 and 2 */
  348. #define DFSDM_FILTER_EXT_TRIG_TIM16_OC1 DFSDM_FLTCR1_JEXTSEL_2 /*!< For DFSDM filter 3 */
  349. #define DFSDM_FILTER_EXT_TRIG_TIM6_TRGO (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_2) /*!< For DFSDM filter 0 and 1 */
  350. #define DFSDM_FILTER_EXT_TRIG_TIM7_TRGO (DFSDM_FLTCR1_JEXTSEL_0 | DFSDM_FLTCR1_JEXTSEL_2) /*!< For DFSDM filter 2 and 3 */
  351. #define DFSDM_FILTER_EXT_TRIG_EXTI11 (DFSDM_FLTCR1_JEXTSEL_1 | DFSDM_FLTCR1_JEXTSEL_2) /*!< For DFSDM filter 0, 1, 2 and 3 */
  352. #define DFSDM_FILTER_EXT_TRIG_EXTI15 DFSDM_FLTCR1_JEXTSEL /*!< For DFSDM filter 0, 1, 2 and 3 */
  353. #endif /* STM32L451xx || STM32L452xx || STM32L462xx */
  354. /**
  355. * @}
  356. */
  357. /** @defgroup DFSDM_Filter_ExtTriggerEdge DFSDM filter external trigger edge
  358. * @{
  359. */
  360. #define DFSDM_FILTER_EXT_TRIG_RISING_EDGE DFSDM_FLTCR1_JEXTEN_0 /*!< External rising edge */
  361. #define DFSDM_FILTER_EXT_TRIG_FALLING_EDGE DFSDM_FLTCR1_JEXTEN_1 /*!< External falling edge */
  362. #define DFSDM_FILTER_EXT_TRIG_BOTH_EDGES DFSDM_FLTCR1_JEXTEN /*!< External rising and falling edges */
  363. /**
  364. * @}
  365. */
  366. /** @defgroup DFSDM_Filter_SincOrder DFSDM filter sinc order
  367. * @{
  368. */
  369. #define DFSDM_FILTER_FASTSINC_ORDER ((uint32_t)0x00000000U) /*!< FastSinc filter type */
  370. #define DFSDM_FILTER_SINC1_ORDER DFSDM_FLTFCR_FORD_0 /*!< Sinc 1 filter type */
  371. #define DFSDM_FILTER_SINC2_ORDER DFSDM_FLTFCR_FORD_1 /*!< Sinc 2 filter type */
  372. #define DFSDM_FILTER_SINC3_ORDER (DFSDM_FLTFCR_FORD_0 | DFSDM_FLTFCR_FORD_1) /*!< Sinc 3 filter type */
  373. #define DFSDM_FILTER_SINC4_ORDER DFSDM_FLTFCR_FORD_2 /*!< Sinc 4 filter type */
  374. #define DFSDM_FILTER_SINC5_ORDER (DFSDM_FLTFCR_FORD_0 | DFSDM_FLTFCR_FORD_2) /*!< Sinc 5 filter type */
  375. /**
  376. * @}
  377. */
  378. /** @defgroup DFSDM_Filter_AwdDataSource DFSDM filter analog watchdog data source
  379. * @{
  380. */
  381. #define DFSDM_FILTER_AWD_FILTER_DATA ((uint32_t)0x00000000U) /*!< From digital filter */
  382. #define DFSDM_FILTER_AWD_CHANNEL_DATA DFSDM_FLTCR1_AWFSEL /*!< From analog watchdog channel */
  383. /**
  384. * @}
  385. */
  386. /** @defgroup DFSDM_Filter_ErrorCode DFSDM filter error code
  387. * @{
  388. */
  389. #define DFSDM_FILTER_ERROR_NONE ((uint32_t)0x00000000U) /*!< No error */
  390. #define DFSDM_FILTER_ERROR_REGULAR_OVERRUN ((uint32_t)0x00000001U) /*!< Overrun occurs during regular conversion */
  391. #define DFSDM_FILTER_ERROR_INJECTED_OVERRUN ((uint32_t)0x00000002U) /*!< Overrun occurs during injected conversion */
  392. #define DFSDM_FILTER_ERROR_DMA ((uint32_t)0x00000003U) /*!< DMA error occurs */
  393. /**
  394. * @}
  395. */
  396. /** @defgroup DFSDM_BreakSignals DFSDM break signals
  397. * @{
  398. */
  399. #define DFSDM_NO_BREAK_SIGNAL ((uint32_t)0x00000000U) /*!< No break signal */
  400. #define DFSDM_BREAK_SIGNAL_0 ((uint32_t)0x00000001U) /*!< Break signal 0 */
  401. #define DFSDM_BREAK_SIGNAL_1 ((uint32_t)0x00000002U) /*!< Break signal 1 */
  402. #define DFSDM_BREAK_SIGNAL_2 ((uint32_t)0x00000004U) /*!< Break signal 2 */
  403. #define DFSDM_BREAK_SIGNAL_3 ((uint32_t)0x00000008U) /*!< Break signal 3 */
  404. /**
  405. * @}
  406. */
  407. /** @defgroup DFSDM_Channel_Selection DFSDM Channel Selection
  408. * @{
  409. */
  410. /* DFSDM Channels ------------------------------------------------------------*/
  411. /* The DFSDM channels are defined as follows:
  412. - in 16-bit LSB the channel mask is set
  413. - in 16-bit MSB the channel number is set
  414. e.g. for channel 5 definition:
  415. - the channel mask is 0x00000020 (bit 5 is set)
  416. - the channel number 5 is 0x00050000
  417. --> Consequently, channel 5 definition is 0x00000020 | 0x00050000 = 0x00050020 */
  418. #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx)
  419. #define DFSDM_CHANNEL_0 ((uint32_t)0x00000001U)
  420. #define DFSDM_CHANNEL_1 ((uint32_t)0x00010002U)
  421. #define DFSDM_CHANNEL_2 ((uint32_t)0x00020004U)
  422. #define DFSDM_CHANNEL_3 ((uint32_t)0x00030008U)
  423. #else
  424. #define DFSDM_CHANNEL_0 ((uint32_t)0x00000001U)
  425. #define DFSDM_CHANNEL_1 ((uint32_t)0x00010002U)
  426. #define DFSDM_CHANNEL_2 ((uint32_t)0x00020004U)
  427. #define DFSDM_CHANNEL_3 ((uint32_t)0x00030008U)
  428. #define DFSDM_CHANNEL_4 ((uint32_t)0x00040010U)
  429. #define DFSDM_CHANNEL_5 ((uint32_t)0x00050020U)
  430. #define DFSDM_CHANNEL_6 ((uint32_t)0x00060040U)
  431. #define DFSDM_CHANNEL_7 ((uint32_t)0x00070080U)
  432. #endif /* STM32L451xx || STM32L452xx || STM32L462xx */
  433. /**
  434. * @}
  435. */
  436. /** @defgroup DFSDM_ContinuousMode DFSDM Continuous Mode
  437. * @{
  438. */
  439. #define DFSDM_CONTINUOUS_CONV_OFF ((uint32_t)0x00000000U) /*!< Conversion are not continuous */
  440. #define DFSDM_CONTINUOUS_CONV_ON ((uint32_t)0x00000001U) /*!< Conversion are continuous */
  441. /**
  442. * @}
  443. */
  444. /** @defgroup DFSDM_AwdThreshold DFSDM analog watchdog threshold
  445. * @{
  446. */
  447. #define DFSDM_AWD_HIGH_THRESHOLD ((uint32_t)0x00000000U) /*!< Analog watchdog high threshold */
  448. #define DFSDM_AWD_LOW_THRESHOLD ((uint32_t)0x00000001U) /*!< Analog watchdog low threshold */
  449. /**
  450. * @}
  451. */
  452. /**
  453. * @}
  454. */
  455. /* End of exported constants -------------------------------------------------*/
  456. /* Exported macros -----------------------------------------------------------*/
  457. /** @defgroup DFSDM_Exported_Macros DFSDM Exported Macros
  458. * @{
  459. */
  460. /** @brief Reset DFSDM channel handle state.
  461. * @param __HANDLE__ DFSDM channel handle.
  462. * @retval None
  463. */
  464. #define __HAL_DFSDM_CHANNEL_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DFSDM_CHANNEL_STATE_RESET)
  465. /** @brief Reset DFSDM filter handle state.
  466. * @param __HANDLE__ DFSDM filter handle.
  467. * @retval None
  468. */
  469. #define __HAL_DFSDM_FILTER_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->State = HAL_DFSDM_FILTER_STATE_RESET)
  470. /**
  471. * @}
  472. */
  473. /* End of exported macros ----------------------------------------------------*/
  474. #if defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  475. /* Include DFSDM HAL Extension module */
  476. #include "stm32l4xx_hal_dfsdm_ex.h"
  477. #endif /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  478. /* Exported functions --------------------------------------------------------*/
  479. /** @addtogroup DFSDM_Exported_Functions DFSDM Exported Functions
  480. * @{
  481. */
  482. /** @addtogroup DFSDM_Exported_Functions_Group1_Channel Channel initialization and de-initialization functions
  483. * @{
  484. */
  485. /* Channel initialization and de-initialization functions *********************/
  486. HAL_StatusTypeDef HAL_DFSDM_ChannelInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  487. HAL_StatusTypeDef HAL_DFSDM_ChannelDeInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  488. void HAL_DFSDM_ChannelMspInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  489. void HAL_DFSDM_ChannelMspDeInit(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  490. /**
  491. * @}
  492. */
  493. /** @addtogroup DFSDM_Exported_Functions_Group2_Channel Channel operation functions
  494. * @{
  495. */
  496. /* Channel operation functions ************************************************/
  497. HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStart(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  498. HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStart_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  499. HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStop(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  500. HAL_StatusTypeDef HAL_DFSDM_ChannelCkabStop_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  501. HAL_StatusTypeDef HAL_DFSDM_ChannelScdStart(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Threshold, uint32_t BreakSignal);
  502. HAL_StatusTypeDef HAL_DFSDM_ChannelScdStart_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Threshold, uint32_t BreakSignal);
  503. HAL_StatusTypeDef HAL_DFSDM_ChannelScdStop(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  504. HAL_StatusTypeDef HAL_DFSDM_ChannelScdStop_IT(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  505. int16_t HAL_DFSDM_ChannelGetAwdValue(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  506. HAL_StatusTypeDef HAL_DFSDM_ChannelModifyOffset(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, int32_t Offset);
  507. HAL_StatusTypeDef HAL_DFSDM_ChannelPollForCkab(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Timeout);
  508. HAL_StatusTypeDef HAL_DFSDM_ChannelPollForScd(DFSDM_Channel_HandleTypeDef *hdfsdm_channel, uint32_t Timeout);
  509. void HAL_DFSDM_ChannelCkabCallback(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  510. void HAL_DFSDM_ChannelScdCallback(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  511. /**
  512. * @}
  513. */
  514. /** @defgroup DFSDM_Exported_Functions_Group3_Channel Channel state function
  515. * @{
  516. */
  517. /* Channel state function *****************************************************/
  518. HAL_DFSDM_Channel_StateTypeDef HAL_DFSDM_ChannelGetState(DFSDM_Channel_HandleTypeDef *hdfsdm_channel);
  519. /**
  520. * @}
  521. */
  522. /** @addtogroup DFSDM_Exported_Functions_Group1_Filter Filter initialization and de-initialization functions
  523. * @{
  524. */
  525. /* Filter initialization and de-initialization functions *********************/
  526. HAL_StatusTypeDef HAL_DFSDM_FilterInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  527. HAL_StatusTypeDef HAL_DFSDM_FilterDeInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  528. void HAL_DFSDM_FilterMspInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  529. void HAL_DFSDM_FilterMspDeInit(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  530. /**
  531. * @}
  532. */
  533. /** @addtogroup DFSDM_Exported_Functions_Group2_Filter Filter control functions
  534. * @{
  535. */
  536. /* Filter control functions *********************/
  537. HAL_StatusTypeDef HAL_DFSDM_FilterConfigRegChannel(DFSDM_Filter_HandleTypeDef *hdfsdm_filter,
  538. uint32_t Channel,
  539. uint32_t ContinuousMode);
  540. HAL_StatusTypeDef HAL_DFSDM_FilterConfigInjChannel(DFSDM_Filter_HandleTypeDef *hdfsdm_filter,
  541. uint32_t Channel);
  542. /**
  543. * @}
  544. */
  545. /** @addtogroup DFSDM_Exported_Functions_Group3_Filter Filter operation functions
  546. * @{
  547. */
  548. /* Filter operation functions *********************/
  549. HAL_StatusTypeDef HAL_DFSDM_FilterRegularStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  550. HAL_StatusTypeDef HAL_DFSDM_FilterRegularStart_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  551. HAL_StatusTypeDef HAL_DFSDM_FilterRegularStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int32_t *pData, uint32_t Length);
  552. HAL_StatusTypeDef HAL_DFSDM_FilterRegularMsbStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int16_t *pData, uint32_t Length);
  553. HAL_StatusTypeDef HAL_DFSDM_FilterRegularStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  554. HAL_StatusTypeDef HAL_DFSDM_FilterRegularStop_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  555. HAL_StatusTypeDef HAL_DFSDM_FilterRegularStop_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  556. HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  557. HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStart_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  558. HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int32_t *pData, uint32_t Length);
  559. HAL_StatusTypeDef HAL_DFSDM_FilterInjectedMsbStart_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, int16_t *pData, uint32_t Length);
  560. HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  561. HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStop_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  562. HAL_StatusTypeDef HAL_DFSDM_FilterInjectedStop_DMA(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  563. HAL_StatusTypeDef HAL_DFSDM_FilterAwdStart_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter,
  564. DFSDM_Filter_AwdParamTypeDef* awdParam);
  565. HAL_StatusTypeDef HAL_DFSDM_FilterAwdStop_IT(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  566. HAL_StatusTypeDef HAL_DFSDM_FilterExdStart(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel);
  567. HAL_StatusTypeDef HAL_DFSDM_FilterExdStop(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  568. int32_t HAL_DFSDM_FilterGetRegularValue(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t* Channel);
  569. int32_t HAL_DFSDM_FilterGetInjectedValue(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t* Channel);
  570. int32_t HAL_DFSDM_FilterGetExdMaxValue(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t* Channel);
  571. int32_t HAL_DFSDM_FilterGetExdMinValue(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t* Channel);
  572. uint32_t HAL_DFSDM_FilterGetConvTimeValue(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  573. void HAL_DFSDM_IRQHandler(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  574. HAL_StatusTypeDef HAL_DFSDM_FilterPollForRegConversion(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Timeout);
  575. HAL_StatusTypeDef HAL_DFSDM_FilterPollForInjConversion(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Timeout);
  576. void HAL_DFSDM_FilterRegConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  577. void HAL_DFSDM_FilterRegConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  578. void HAL_DFSDM_FilterInjConvCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  579. void HAL_DFSDM_FilterInjConvHalfCpltCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  580. void HAL_DFSDM_FilterAwdCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter, uint32_t Channel, uint32_t Threshold);
  581. void HAL_DFSDM_FilterErrorCallback(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  582. /**
  583. * @}
  584. */
  585. /** @defgroup DFSDM_Exported_Functions_Group4_Filter Filter state functions
  586. * @{
  587. */
  588. /* Filter state functions *****************************************************/
  589. HAL_DFSDM_Filter_StateTypeDef HAL_DFSDM_FilterGetState(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  590. uint32_t HAL_DFSDM_FilterGetError(DFSDM_Filter_HandleTypeDef *hdfsdm_filter);
  591. /**
  592. * @}
  593. */
  594. /**
  595. * @}
  596. */
  597. /* End of exported functions -------------------------------------------------*/
  598. /* Private macros ------------------------------------------------------------*/
  599. /** @defgroup DFSDM_Private_Macros DFSDM Private Macros
  600. * @{
  601. */
  602. #define IS_DFSDM_CHANNEL_OUTPUT_CLOCK(CLOCK) (((CLOCK) == DFSDM_CHANNEL_OUTPUT_CLOCK_SYSTEM) || \
  603. ((CLOCK) == DFSDM_CHANNEL_OUTPUT_CLOCK_AUDIO))
  604. #define IS_DFSDM_CHANNEL_OUTPUT_CLOCK_DIVIDER(DIVIDER) ((2 <= (DIVIDER)) && ((DIVIDER) <= 256))
  605. #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx) || \
  606. defined(STM32L496xx) || defined(STM32L4A6xx) || \
  607. defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  608. #define IS_DFSDM_CHANNEL_INPUT(INPUT) (((INPUT) == DFSDM_CHANNEL_EXTERNAL_INPUTS) || \
  609. ((INPUT) == DFSDM_CHANNEL_ADC_OUTPUT) || \
  610. ((INPUT) == DFSDM_CHANNEL_INTERNAL_REGISTER))
  611. #else
  612. #define IS_DFSDM_CHANNEL_INPUT(INPUT) (((INPUT) == DFSDM_CHANNEL_EXTERNAL_INPUTS) || \
  613. ((INPUT) == DFSDM_CHANNEL_INTERNAL_REGISTER))
  614. #endif /* STM32L451xx || STM32L452xx || STM32L462xx || */
  615. /* STM32L496xx || STM32L4A6xx || */
  616. /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  617. #define IS_DFSDM_CHANNEL_DATA_PACKING(MODE) (((MODE) == DFSDM_CHANNEL_STANDARD_MODE) || \
  618. ((MODE) == DFSDM_CHANNEL_INTERLEAVED_MODE) || \
  619. ((MODE) == DFSDM_CHANNEL_DUAL_MODE))
  620. #define IS_DFSDM_CHANNEL_INPUT_PINS(PINS) (((PINS) == DFSDM_CHANNEL_SAME_CHANNEL_PINS) || \
  621. ((PINS) == DFSDM_CHANNEL_FOLLOWING_CHANNEL_PINS))
  622. #define IS_DFSDM_CHANNEL_SERIAL_INTERFACE_TYPE(MODE) (((MODE) == DFSDM_CHANNEL_SPI_RISING) || \
  623. ((MODE) == DFSDM_CHANNEL_SPI_FALLING) || \
  624. ((MODE) == DFSDM_CHANNEL_MANCHESTER_RISING) || \
  625. ((MODE) == DFSDM_CHANNEL_MANCHESTER_FALLING))
  626. #define IS_DFSDM_CHANNEL_SPI_CLOCK(TYPE) (((TYPE) == DFSDM_CHANNEL_SPI_CLOCK_EXTERNAL) || \
  627. ((TYPE) == DFSDM_CHANNEL_SPI_CLOCK_INTERNAL) || \
  628. ((TYPE) == DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_FALLING) || \
  629. ((TYPE) == DFSDM_CHANNEL_SPI_CLOCK_INTERNAL_DIV2_RISING))
  630. #define IS_DFSDM_CHANNEL_FILTER_ORDER(ORDER) (((ORDER) == DFSDM_CHANNEL_FASTSINC_ORDER) || \
  631. ((ORDER) == DFSDM_CHANNEL_SINC1_ORDER) || \
  632. ((ORDER) == DFSDM_CHANNEL_SINC2_ORDER) || \
  633. ((ORDER) == DFSDM_CHANNEL_SINC3_ORDER))
  634. #define IS_DFSDM_CHANNEL_FILTER_OVS_RATIO(RATIO) ((1 <= (RATIO)) && ((RATIO) <= 32))
  635. #define IS_DFSDM_CHANNEL_OFFSET(VALUE) ((-8388608 <= (VALUE)) && ((VALUE) <= 8388607))
  636. #define IS_DFSDM_CHANNEL_RIGHT_BIT_SHIFT(VALUE) ((VALUE) <= 0x1F)
  637. #define IS_DFSDM_CHANNEL_SCD_THRESHOLD(VALUE) ((VALUE) <= 0xFF)
  638. #define IS_DFSDM_FILTER_REG_TRIGGER(TRIG) (((TRIG) == DFSDM_FILTER_SW_TRIGGER) || \
  639. ((TRIG) == DFSDM_FILTER_SYNC_TRIGGER))
  640. #define IS_DFSDM_FILTER_INJ_TRIGGER(TRIG) (((TRIG) == DFSDM_FILTER_SW_TRIGGER) || \
  641. ((TRIG) == DFSDM_FILTER_SYNC_TRIGGER) || \
  642. ((TRIG) == DFSDM_FILTER_EXT_TRIGGER))
  643. #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx)
  644. #define IS_DFSDM_FILTER_EXT_TRIG(TRIG) (((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO) || \
  645. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2) || \
  646. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM3_TRGO) || \
  647. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM16_OC1) || \
  648. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM6_TRGO) || \
  649. ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI11) || \
  650. ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI15))
  651. #elif defined(STM32L4R5xx) || defined(STM32L4R7xx) || defined(STM32L4R9xx) || defined(STM32L4S5xx) || defined(STM32L4S7xx) || defined(STM32L4S9xx)
  652. #define IS_DFSDM_FILTER_EXT_TRIG(TRIG) (((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO) || \
  653. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2) || \
  654. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM8_TRGO) || \
  655. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM8_TRGO2) || \
  656. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM3_TRGO) || \
  657. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM4_TRGO) || \
  658. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM16_OC1) || \
  659. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM6_TRGO) || \
  660. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM7_TRGO) || \
  661. ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI11) || \
  662. ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI15) || \
  663. ((TRIG) == DFSDM_FILTER_EXT_TRIG_LPTIM1_OUT))
  664. #else
  665. #define IS_DFSDM_FILTER_EXT_TRIG(TRIG) (((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO) || \
  666. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM1_TRGO2) || \
  667. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM8_TRGO) || \
  668. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM8_TRGO2) || \
  669. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM3_TRGO) || \
  670. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM4_TRGO) || \
  671. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM16_OC1) || \
  672. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM6_TRGO) || \
  673. ((TRIG) == DFSDM_FILTER_EXT_TRIG_TIM7_TRGO) || \
  674. ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI11) || \
  675. ((TRIG) == DFSDM_FILTER_EXT_TRIG_EXTI15))
  676. #endif /* STM32L451xx || STM32L452xx || STM32L462xx */
  677. #define IS_DFSDM_FILTER_EXT_TRIG_EDGE(EDGE) (((EDGE) == DFSDM_FILTER_EXT_TRIG_RISING_EDGE) || \
  678. ((EDGE) == DFSDM_FILTER_EXT_TRIG_FALLING_EDGE) || \
  679. ((EDGE) == DFSDM_FILTER_EXT_TRIG_BOTH_EDGES))
  680. #define IS_DFSDM_FILTER_SINC_ORDER(ORDER) (((ORDER) == DFSDM_FILTER_FASTSINC_ORDER) || \
  681. ((ORDER) == DFSDM_FILTER_SINC1_ORDER) || \
  682. ((ORDER) == DFSDM_FILTER_SINC2_ORDER) || \
  683. ((ORDER) == DFSDM_FILTER_SINC3_ORDER) || \
  684. ((ORDER) == DFSDM_FILTER_SINC4_ORDER) || \
  685. ((ORDER) == DFSDM_FILTER_SINC5_ORDER))
  686. #define IS_DFSDM_FILTER_OVS_RATIO(RATIO) ((1 <= (RATIO)) && ((RATIO) <= 1024))
  687. #define IS_DFSDM_FILTER_INTEGRATOR_OVS_RATIO(RATIO) ((1 <= (RATIO)) && ((RATIO) <= 256))
  688. #define IS_DFSDM_FILTER_AWD_DATA_SOURCE(DATA) (((DATA) == DFSDM_FILTER_AWD_FILTER_DATA) || \
  689. ((DATA) == DFSDM_FILTER_AWD_CHANNEL_DATA))
  690. #define IS_DFSDM_FILTER_AWD_THRESHOLD(VALUE) ((-8388608 <= (VALUE)) && ((VALUE) <= 8388607))
  691. #define IS_DFSDM_BREAK_SIGNALS(VALUE) ((VALUE) <= 0xFU)
  692. #if defined(STM32L451xx) || defined(STM32L452xx) || defined(STM32L462xx)
  693. #define IS_DFSDM_REGULAR_CHANNEL(CHANNEL) (((CHANNEL) == DFSDM_CHANNEL_0) || \
  694. ((CHANNEL) == DFSDM_CHANNEL_1) || \
  695. ((CHANNEL) == DFSDM_CHANNEL_2) || \
  696. ((CHANNEL) == DFSDM_CHANNEL_3))
  697. #define IS_DFSDM_INJECTED_CHANNEL(CHANNEL) (((CHANNEL) != 0) && ((CHANNEL) <= 0x0003000FU))
  698. #else
  699. #define IS_DFSDM_REGULAR_CHANNEL(CHANNEL) (((CHANNEL) == DFSDM_CHANNEL_0) || \
  700. ((CHANNEL) == DFSDM_CHANNEL_1) || \
  701. ((CHANNEL) == DFSDM_CHANNEL_2) || \
  702. ((CHANNEL) == DFSDM_CHANNEL_3) || \
  703. ((CHANNEL) == DFSDM_CHANNEL_4) || \
  704. ((CHANNEL) == DFSDM_CHANNEL_5) || \
  705. ((CHANNEL) == DFSDM_CHANNEL_6) || \
  706. ((CHANNEL) == DFSDM_CHANNEL_7))
  707. #define IS_DFSDM_INJECTED_CHANNEL(CHANNEL) (((CHANNEL) != 0) && ((CHANNEL) <= 0x000F00FFU))
  708. #endif /* STM32L451xx || STM32L452xx || STM32L462xx */
  709. #define IS_DFSDM_CONTINUOUS_MODE(MODE) (((MODE) == DFSDM_CONTINUOUS_CONV_OFF) || \
  710. ((MODE) == DFSDM_CONTINUOUS_CONV_ON))
  711. /**
  712. * @}
  713. */
  714. /* End of private macros -----------------------------------------------------*/
  715. /**
  716. * @}
  717. */
  718. /**
  719. * @}
  720. */
  721. #endif /* STM32L451xx || STM32L452xx || STM32L462xx || */
  722. /* STM32L471xx || STM32L475xx || STM32L476xx || STM32L485xx || STM32L486xx || */
  723. /* STM32L496xx || STM32L4A6xx || */
  724. /* STM32L4R5xx || STM32L4R7xx || STM32L4R9xx || STM32L4S5xx || STM32L4S7xx || STM32L4S9xx */
  725. #ifdef __cplusplus
  726. }
  727. #endif
  728. #endif /* __STM32L4xx_HAL_DFSDM_H */
  729. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/