You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

852 lines
47 KiB

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