stm32l4xx_hal_dfsdm.h 50 KB

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