stm32f4xx_hal_dfsdm.h 47 KB

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