hc32f4a0_fmac.h 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. /**
  2. *******************************************************************************
  3. * @file hc32f4a0_fmac.h
  4. * @brief This file contains all the functions prototypes of the FMAC driver
  5. * library.
  6. @verbatim
  7. Change Logs:
  8. Date Author Notes
  9. 2020-06-12 Heqb First version
  10. @endverbatim
  11. *******************************************************************************
  12. * Copyright (C) 2020, Huada Semiconductor Co., Ltd. All rights reserved.
  13. *
  14. * This software component is licensed by HDSC under BSD 3-Clause license
  15. * (the "License"); You may not use this file except in compliance with the
  16. * License. You may obtain a copy of the License at:
  17. * opensource.org/licenses/BSD-3-Clause
  18. *
  19. *******************************************************************************
  20. */
  21. #ifndef __HC32F4A0_FMAC_H__
  22. #define __HC32F4A0_FMAC_H__
  23. /* C binding of definitions if building with C++ compiler */
  24. #ifdef __cplusplus
  25. extern "C"
  26. {
  27. #endif
  28. /*******************************************************************************
  29. * Include files
  30. ******************************************************************************/
  31. #include "hc32_common.h"
  32. #include "ddl_config.h"
  33. /**
  34. * @addtogroup HC32F4A0_DDL_Driver
  35. * @{
  36. */
  37. /**
  38. * @addtogroup DDL_FMAC
  39. * @{
  40. */
  41. #if (DDL_FMAC_ENABLE == DDL_ON)
  42. /*******************************************************************************
  43. * Global type definitions ('typedef')
  44. ******************************************************************************/
  45. /**
  46. * @defgroup FMAC_Global_Types FMAC Global Types
  47. * @{
  48. */
  49. /**
  50. * @brief FMAC configuration structure
  51. */
  52. typedef struct
  53. {
  54. uint32_t u32FiltStage; /*!< FMAC filter stage number config.
  55. This parameter can be a value of @ref FMAC_Filter_stage.*/
  56. uint32_t u32FiltShift; /*!< FMAC filter result right shift bits.
  57. This parameter can be a value of @ref FMAC_Filter_shift.*/
  58. int16_t i16FiltFactor; /*!< FMAC filter factor config.
  59. This parameter can be set -32768~32767 */
  60. uint32_t u32IntCmd; /*!< Enable or disable FMAC interrupt.
  61. This parameter can be a value of @ref FMAC_Interrupt_Definition.*/
  62. }stc_fmac_init_t;
  63. /**
  64. * @brief FMAC result definition
  65. */
  66. typedef struct
  67. {
  68. uint32_t u32ResultHigh; /*!< The high value of the result. */
  69. uint32_t u32ResultLow; /*!< The low value of the result. */
  70. } stc_fmac_result_t;
  71. /**
  72. * @}
  73. */
  74. /*******************************************************************************
  75. * Global pre-processor symbols/macros ('#define')
  76. ******************************************************************************/
  77. /**
  78. * @defgroup FMAC_Global_Macros FMAC Global Macros
  79. * @{
  80. */
  81. /**
  82. * @defgroup FMAC_ENABLE FMAC Enable or Disable
  83. * @{
  84. */
  85. #define FMAC_FUNC_ENABLE (FMAC_ENR_FMACEN)
  86. #define FMAC_FUNC_DISABLE (0x0UL)
  87. /**
  88. * @}
  89. */
  90. /**
  91. * @defgroup FMAC_Interrupt_Definition FMAC interrupt definition
  92. * @{
  93. */
  94. #define FMAC_INT_ENABLE (FMAC_IER_INTEN)
  95. #define FMAC_INT_DISABLE (0x0UL)
  96. /**
  97. * @}
  98. */
  99. /** @defgroup FMAC_Filter_shift FMAC filter shift times
  100. * @{
  101. */
  102. #define FMAC_FILTER_SHIFT_0BIT (0U)
  103. #define FMAC_FILTER_SHIFT_1BIT (1U)
  104. #define FMAC_FILTER_SHIFT_2BIT (2U)
  105. #define FMAC_FILTER_SHIFT_3BIT (3U)
  106. #define FMAC_FILTER_SHIFT_4BIT (4U)
  107. #define FMAC_FILTER_SHIFT_5BIT (5U)
  108. #define FMAC_FILTER_SHIFT_6BIT (6U)
  109. #define FMAC_FILTER_SHIFT_7BIT (7U)
  110. #define FMAC_FILTER_SHIFT_8BIT (8U)
  111. #define FMAC_FILTER_SHIFT_9BIT (9U)
  112. #define FMAC_FILTER_SHIFT_10BIT (10U)
  113. #define FMAC_FILTER_SHIFT_11BIT (11U)
  114. #define FMAC_FILTER_SHIFT_12BIT (12U)
  115. #define FMAC_FILTER_SHIFT_13BIT (13U)
  116. #define FMAC_FILTER_SHIFT_14BIT (14U)
  117. #define FMAC_FILTER_SHIFT_15BIT (15U)
  118. #define FMAC_FILTER_SHIFT_16BIT (16U)
  119. #define FMAC_FILTER_SHIFT_17BIT (17U)
  120. #define FMAC_FILTER_SHIFT_18BIT (18U)
  121. #define FMAC_FILTER_SHIFT_19BIT (19U)
  122. #define FMAC_FILTER_SHIFT_20BIT (20U)
  123. #define FMAC_FILTER_SHIFT_21BIT (21U)
  124. /**
  125. * @}
  126. */
  127. /** @defgroup FMAC_Filter_stage FMAC filter stage number
  128. * @{
  129. */
  130. #define FMAC_FILTER_STAGE_0 (0U)
  131. #define FMAC_FILTER_STAGE_1 (1U)
  132. #define FMAC_FILTER_STAGE_2 (2U)
  133. #define FMAC_FILTER_STAGE_3 (3U)
  134. #define FMAC_FILTER_STAGE_4 (4U)
  135. #define FMAC_FILTER_STAGE_5 (5U)
  136. #define FMAC_FILTER_STAGE_6 (6U)
  137. #define FMAC_FILTER_STAGE_7 (7U)
  138. #define FMAC_FILTER_STAGE_8 (8U)
  139. #define FMAC_FILTER_STAGE_9 (9U)
  140. #define FMAC_FILTER_STAGE_10 (10U)
  141. #define FMAC_FILTER_STAGE_11 (11U)
  142. #define FMAC_FILTER_STAGE_12 (12U)
  143. #define FMAC_FILTER_STAGE_13 (13U)
  144. #define FMAC_FILTER_STAGE_14 (14U)
  145. #define FMAC_FILTER_STAGE_15 (15U)
  146. #define FMAC_FILTER_STAGE_16 (16U)
  147. /**
  148. * @}
  149. */
  150. /**
  151. * @}
  152. */
  153. /*******************************************************************************
  154. * Global variable definitions ('extern')
  155. ******************************************************************************/
  156. /*******************************************************************************
  157. Global function prototypes (definition in C source)
  158. ******************************************************************************/
  159. /**
  160. * @addtogroup FMAC_Global_Functions
  161. * @{
  162. */
  163. en_result_t FMAC_StructInit(stc_fmac_init_t* pstcInitStruct);
  164. void FMAC_DeInit(M4_FMAC_TypeDef* FMACx);
  165. en_result_t FMAC_Init(M4_FMAC_TypeDef* FMACx, const stc_fmac_init_t *pstcFmacInit);
  166. void FMAC_Cmd(M4_FMAC_TypeDef* FMACx, en_functional_state_t enNewState);
  167. void FMAC_SetResultShift(M4_FMAC_TypeDef* FMACx, uint32_t u32ShiftNum);
  168. void FMAC_SetStageFactor(M4_FMAC_TypeDef* FMACx, uint32_t u32FilterStage, int16_t i16Factor);
  169. void FMAC_IntCmd(M4_FMAC_TypeDef* FMACx, en_functional_state_t enNewState);
  170. void FMAC_FIRInput(M4_FMAC_TypeDef* FMACx, int16_t i16Factor);
  171. en_flag_status_t FMAC_GetStatus(const M4_FMAC_TypeDef* FMACx);
  172. en_result_t FMAC_GetResult(const M4_FMAC_TypeDef* FMACx, stc_fmac_result_t *stcResult);
  173. /**
  174. * @}
  175. */
  176. #endif /* DDL_FMAC_ENABLE */
  177. /**
  178. * @}
  179. */
  180. /**
  181. * @}
  182. */
  183. #ifdef __cplusplus
  184. }
  185. #endif
  186. #endif /* __HC32F4A0_FMAC_H__ */
  187. /*******************************************************************************
  188. * EOF (not truncated)
  189. ******************************************************************************/