tae32f53xx_ll_iir.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354
  1. /**
  2. ******************************************************************************
  3. * @file tae32f53xx_ll_iir.h
  4. * @author MCD Application Team
  5. * @brief Header file of IIR LL module.
  6. *
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2020 Tai-Action.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software is licensed by Tai-Action under BSD 3-Clause license,
  14. * the "License"; You may not use this file except in compliance with the
  15. * License. You may obtain a copy of the License at:
  16. * opensource.org/licenses/BSD-3-Clause
  17. *
  18. ******************************************************************************
  19. */
  20. /* Define to prevent recursive inclusion -------------------------------------*/
  21. #ifndef _TAE32F53XX_LL_IIR_H_
  22. #define _TAE32F53XX_LL_IIR_H_
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif /* __cplusplus */
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "tae32f53xx_ll_def.h"
  28. /** @addtogroup TAE32F53xx_LL_Driver
  29. * @{
  30. */
  31. /** @addtogroup IIR_LL
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /** @defgroup IIR_LL_Exported_Types IIR LL Exported Types
  36. * @brief IIR LL Exported Types
  37. * @{
  38. */
  39. /**
  40. * @brief IIR Order type definition
  41. */
  42. typedef enum {
  43. IIR_ORDER_1 = 0x00000000UL, /*!< Source Peripheral bus AHB Master1 */
  44. IIR_ORDER_2 = IIR_CR0_ORD_0, /*!< IIR order 2 */
  45. IIR_ORDER_3 = IIR_CR0_ORD_1, /*!< IIR order 3 */
  46. IIR_ORDER_4 = (IIR_CR0_ORD_0 | IIR_CR0_ORD_1), /*!< IIR order 4 */
  47. } IIR_OrderETypeDef;
  48. /*
  49. * @brief IIR internal data buffer reset or not
  50. */
  51. typedef enum {
  52. IIR_BUFFER_NO_RESET = 0x00000000UL, /*!< Do nothing to IIR Internal Data Buffer */
  53. IIR_BUFFER_RESET = IIR_CR0_IBRST, /*!< IIR Internal Data Buffer should reset */
  54. } IIR_BufferETypeDef;
  55. /**
  56. * @brief IIR Auto-Reload mode enable or disable
  57. */
  58. typedef enum {
  59. IIR_AUTORELOAD_DISABLE = 0x00000000UL, /*!< IIR Auto-Reload mode disable */
  60. IIR_AUTORELOAD_ENABLE = IIR_CR1_AREN, /*!< IIR Auto-Reload mode enable */
  61. } IIR_ATReloadETypeDef;
  62. /**
  63. * @brief IIR initialization structure definition
  64. */
  65. typedef struct __IIR_InitTypeDef {
  66. IIR_OrderETypeDef Order; /*!< Specifies the IIR order */
  67. IIR_BufferETypeDef BufferReset; /*!< Indicate to reset the internal data buffer or not */
  68. } IIR_InitTypeDef;
  69. /**
  70. * @brief IIR configuration structure definition
  71. */
  72. typedef struct __IIR_ConfigTypeDef {
  73. uint32_t InDataAddress; /*!< Specifies the input data address in memory area.
  74. The address must be aligned to 16-bit boundary in specifies memory areas(For
  75. more information, please see the documents of system architecture designs) */
  76. uint32_t InDataScale; /*!< Specifies magnify scale for the input data.
  77. This parameter can be a value between 0 to 16 which stand for the input data
  78. magnified 2^0 to 2^16 times */
  79. uint32_t FeedBackScale; /*!< Specifies the feekback narrow scale.
  80. This parameter can be a value between 0 to 31 which stand for feedback
  81. narrowed 2^0 to 2^31 times */
  82. uint32_t OutDataScale; /*!< Specifies narrow scale for the output data.
  83. This parameter can be a value between 0 to 31 which stand for the output data
  84. narrowed 2^0 to 2^31 times */
  85. int16_t AxCOEF[4]; /*!< Specifies the coefficient A.
  86. This parameter can be a value between -32768 to +32767 */
  87. int16_t BxCOEF[5]; /*!< Specifies the coefficient B.
  88. This parameter can be a value between -32768 to +32767 */
  89. } IIR_ConfigTypeDef;
  90. /**
  91. * @}
  92. */
  93. /* Exported constants --------------------------------------------------------*/
  94. /** @defgroup IIR_LL_Exported_Constants IIR LL Exported Constants
  95. * @brief IIR LL Exported Constants
  96. * @{
  97. */
  98. /** @defgroup IIR_Flag_definition IIR Flag Definition
  99. * @{
  100. */
  101. #define IIR_FLAG_FDIF IIR_ISR_FDIF /*!< IIR Filter Done Interrupt Flag */
  102. /**
  103. * @}
  104. */
  105. /** @defgroup IIR_Interrupt_definition IIR Interrupt Definition
  106. * @{
  107. */
  108. #define IIR_IT_FDIE IIR_IER_IE /*!< IIR Filter Done Interrupt Enable */
  109. /**
  110. * @}
  111. */
  112. /**
  113. * @}
  114. */
  115. /* Exported macro ------------------------------------------------------------*/
  116. /** @defgroup IIR_LL_Exported_Macros IIR LL Exported Macros
  117. * @brief IIR LL Exported Macros
  118. * @{
  119. */
  120. /**
  121. * @brief Enable the specified IIR interrupt.
  122. * @param __INSTANCE__ IIR peripheral
  123. * @param __INTERRUPT__ specifies the IIR interrupt source to enable.
  124. * This parameter can be one of the following values:
  125. * @arg IIR_IT_FDIE: Filiter Done Interrupt Enable
  126. * @return None
  127. */
  128. #define __LL_IIR_ENABLE_IT(__INSTANCE__, __INTERRUPT__) SET_BIT((__INSTANCE__)->IER, __INTERRUPT__)
  129. /**
  130. * @brief Disable the specified IIR interrupt.
  131. * @param __INSTANCE__ IIR peripheral
  132. * @param __INTERRUPT__ specifies the IIR interrupt source to disable.
  133. * This parameter can be one of the following values:
  134. * @arg IIR_IT_FDIE: Filiter Done Interrupt Enable
  135. * @return None
  136. */
  137. #define __LL_IIR_DISABLE_IT(__INSTANCE__, __INTERRUPT__) CLEAR_BIT((__INSTANCE__)->IER, __INTERRUPT__)
  138. /**
  139. * @brief Check whether the specified IIR interrupt source is enabled or not.
  140. * @param __INSTANCE__ IIR peripheral
  141. * @param __INTERRUPT__ specifies the IIR interrupt source to check.
  142. * This parameter can be one of the following values:
  143. * @arg IIR_IT_FDIE: Filiter Done Interrupt Enable
  144. * @return The state of __INTERRUPT__ (SET or RESET).
  145. */
  146. #define __LL_IIR_IT_CHECK_SOURCE(__INSTANCE__, __INTERRUPT__) \
  147. ((READ_BIT((__INSTANCE__)->IER, (__INTERRUPT__)) == (__INTERRUPT__)) ? SET : RESET)
  148. /** @brief Check whether the specified IIR status or interrupt flag is set or not.
  149. * @param __INSTANCE__ IIR peripheral
  150. * @param __FLAG__ specifies the IIR flag to check.
  151. * This parameter can be one of the following values:
  152. * @arg IIR_FLAG_FDIF: Filiter Done Interrupt Flag
  153. * @return The new state of __FLAG__ (SET or RESET).
  154. */
  155. #define __LL_IIR_GET_FLAG(__INSTANCE__, __FLAG__) \
  156. ((READ_BIT((__INSTANCE__)->ISR, (__FLAG__)) == (__FLAG__)) ? SET : RESET)
  157. /**
  158. * @brief Clear the specified IIR status or interrupt flag.
  159. * @param __INSTANCE__ IIR peripheral
  160. * @param __FLAG__ specifies the IIR flag to clear.
  161. * This parameter can be one of the following values:
  162. * @arg IIR_FLAG_FDIF: Filiter Done Interrupt Flag
  163. * @return None
  164. */
  165. #define __LL_IIR_CLEAR_FLAG(__INSTANCE__, __FLAG__) WRITE_REG((__INSTANCE__)->ISR, (__FLAG__))
  166. /**
  167. * @brief Enable the IIR AutoReload feature.
  168. * @param __INSTANCE__ IIR peripheral
  169. * @return None
  170. */
  171. #define __LL_IIR_AUTORELOAD_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CR1, IIR_CR1_AREN)
  172. /**
  173. * @brief Enable the IIR peripheral.
  174. * @param __INSTANCE__ IIR peripheral
  175. * @return None
  176. */
  177. #define __LL_IIR_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CR0, IIR_CR0_IIREN)
  178. /**
  179. * @brief Disable the IIR peripheral.
  180. * @param __INSTANCE__ IIR peripheral
  181. * @return None
  182. */
  183. #define __LL_IIR_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CR0, IIR_CR0_IIREN)
  184. /**
  185. * @brief Start IIR filter
  186. * @param __INSTANCE__ IIR peripheral
  187. * @return None
  188. */
  189. #define __LL_IIR_FILTER_START(__INSTANCE__) SET_BIT((__INSTANCE__)->CR1, IIR_CR1_START)
  190. /**
  191. * @brief Reset the IIR internal data buffer.
  192. * @param __INSTANCE__ IIR peripheral
  193. * @return None
  194. */
  195. #define __LL_IIR_FILTER_BUFFER_RESET(__INSTANCE__) SET_BIT((__INSTANCE__)->CR0, IIR_CR0_IBRST)
  196. /**
  197. * @}
  198. */
  199. /* Exported functions --------------------------------------------------------*/
  200. /** @addtogroup IIR_LL_Exported_functions
  201. * @{
  202. */
  203. /** @addtogroup IIR_LL_Exported_Functions_Group1
  204. * @{
  205. */
  206. LL_StatusETypeDef LL_IIR_Init(IIR_TypeDef *Instance, IIR_InitTypeDef *Init);
  207. LL_StatusETypeDef LL_IIR_DeInit(IIR_TypeDef *Instance);
  208. void LL_IIR_MspInit(IIR_TypeDef *Instance);
  209. void LL_IIR_MspDeInit(IIR_TypeDef *Instance);
  210. /**
  211. * @}
  212. */
  213. /** @addtogroup IIR_LL_Exported_Functions_Group2
  214. * @{
  215. */
  216. LL_StatusETypeDef LL_IIR_FilterConfig(IIR_TypeDef *Instance, IIR_ConfigTypeDef *Config);
  217. LL_StatusETypeDef LL_IIR_FilterConfig_Preload(IIR_TypeDef *Instance, IIR_ConfigTypeDef *Config);
  218. /**
  219. * @}
  220. */
  221. /** @addtogroup IIR_LL_Exported_Functions_Group3
  222. * @{
  223. */
  224. LL_StatusETypeDef LL_IIR_FilterStart(IIR_TypeDef *Instance, IIR_ATReloadETypeDef AutoReload);
  225. LL_StatusETypeDef LL_IIR_FilterStart_IT(IIR_TypeDef *Instance, IIR_ATReloadETypeDef AutoReload);
  226. LL_StatusETypeDef LL_IIR_FilterBufferReset(IIR_TypeDef *Instance);
  227. int16_t LL_IIR_FilterDataGet(IIR_TypeDef *Instance);
  228. /**
  229. * @}
  230. */
  231. /** @addtogroup IIR_LL_Exported_Functions_Interrupt
  232. * @{
  233. */
  234. void LL_IIR_IRQHandler(IIR_TypeDef *IIRx);
  235. void LL_IIR_FilterDoneCallBack(IIR_TypeDef *IIRx);
  236. /**
  237. * @}
  238. */
  239. /**
  240. * @}
  241. */
  242. /* Private types -------------------------------------------------------------*/
  243. /* Private variables ---------------------------------------------------------*/
  244. /* Private constants ---------------------------------------------------------*/
  245. /* Private macros ------------------------------------------------------------*/
  246. /** @addtogroup IIR_LL_Private_Macros IIR LL Private Macros
  247. * @brief IIR LL Private Macros
  248. * @{
  249. */
  250. /**
  251. * @brief Judge is IIR output data scale or not
  252. * @param __SCALE__ scale to judge
  253. * @retval 0 isn't IIR output data scale
  254. * @retval 1 is IIR output data scale
  255. */
  256. #define IS_IIR_OUTPUT_DATA_SCALE(__SCALE__) ((__SCALE__) <= 0x1FU)
  257. /**
  258. * @brief Judge is IIR input data scale or not
  259. * @param __SCALE__ scale to judge
  260. * @retval 0 isn't IIR input data scale
  261. * @retval 1 is IIR input data scale
  262. */
  263. #define IS_IIR_INPUT_DATA_SCALE(__SCALE__) ((__SCALE__) <= 0x10U)
  264. /**
  265. * @brief Judge is IIR feedback data scale or not
  266. * @param __SCALE__ scale to judge
  267. * @retval 0 isn't IIR feedback data scale
  268. * @retval 1 is IIR feedback data scale
  269. */
  270. #define IS_IIR_FEEDBACK_SCALE(__SCALE__) ((__SCALE__) <= 0x1FU)
  271. /**
  272. * @}
  273. */
  274. /* Private functions ---------------------------------------------------------*/
  275. /**
  276. * @}
  277. */
  278. /**
  279. * @}
  280. */
  281. #ifdef __cplusplus
  282. }
  283. #endif /* __cplusplus */
  284. #endif /* _TAE32F53XX_LL_IIR_H_ */
  285. /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/