tae32f53xx_ll_ecu.h 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726
  1. /**
  2. ******************************************************************************
  3. * @file tae32f53xx_ll_ecu.h
  4. * @author MCD Application Team
  5. * @brief Header file of ECU 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_ECU_H_
  22. #define _TAE32F53XX_LL_ECU_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 ECU_LL
  32. * @{
  33. */
  34. /* Exported constants --------------------------------------------------------*/
  35. /** @defgroup ECU_LL_Exported_Constants ECU LL Exported Constants
  36. * @brief ECU LL Exported Constants
  37. * @{
  38. */
  39. /** @defgroup LL_ECU_ENABLE ECU enable define
  40. * @brief ECU Enable Bit Set and Bit Reset
  41. * @{
  42. */
  43. #define ECU_DISABLE (0x00000000U) /*!<ECU module disable */
  44. #define ECU_ENABLE (ECU_CON_ENABLE) /*!<ECU module enable */
  45. /**
  46. * @}
  47. */
  48. /** @defgroup LL_ECU_IT_ENABLE ECU enable interrupt define
  49. * @brief ECU Interrupt Enable Bit Set and Bit Reset
  50. * @{
  51. */
  52. #define ECU_IT_DISABLE (0x00000000U) /*!<ECU module disable */
  53. #define ECU_IT_ENABLE (ECU_CON_INTEN) /*!<ECU module interrupt enable */
  54. /**
  55. * @}
  56. */
  57. /**
  58. * @}
  59. */
  60. /* Exported types ------------------------------------------------------------*/
  61. /** @defgroup ECU_LL_Exported_Types ECU LL Exported Types
  62. * @brief ECU LL Exported Types
  63. * @{
  64. */
  65. /** @defgroup LL_ECU_AVERAGE ECU average period define
  66. * @brief ECU Enumerate the number of periods to be averaged
  67. * @{
  68. */
  69. typedef enum {
  70. ECU_AVERAGE_DISABLE = 0x0, /*!<Instead of averaging the results of the periodic data, one result is produced per period */
  71. ECU_AVERAGE_2PERIOD = ECU_CON_AVGSEL_0, /*!<Two cycles of data produce a result */
  72. ECU_AVERAGE_4PERIOD = ECU_CON_AVGSEL_1, /*!<Four cycles of data produce a result */
  73. ECU_AVERAGE_8PERIOD = ECU_CON_AVGSEL_1 | ECU_CON_AVGSEL_0, /*!<Eight cycles of data produce a result */
  74. } ECU_AverageETypedef;
  75. /**
  76. * @}
  77. */
  78. /** @defgroup LL_ECU_ACPOWER_LEFT_SHIFT ECU active power left shift define
  79. * @brief ECU Enumerate the left shift number of active power
  80. * @{
  81. */
  82. typedef enum {
  83. ECU_ACPOWER_LEFT_SHIFT_DISABLE = 0x0,
  84. ECU_ACPOWER_LEFT_SHIFT_1 = ECU_CON_ACSFT_0,
  85. ECU_ACPOWER_LEFT_SHIFT_2 = ECU_CON_ACSFT_1,
  86. ECU_ACPOWER_LEFT_SHIFT_3 = ECU_CON_ACSFT_1 | ECU_CON_ACSFT_0,
  87. ECU_ACPOWER_LEFT_SHIFT_4 = ECU_CON_ACSFT_2,
  88. ECU_ACPOWER_LEFT_SHIFT_5 = ECU_CON_ACSFT_2 | ECU_CON_ACSFT_0,
  89. ECU_ACPOWER_LEFT_SHIFT_6 = ECU_CON_ACSFT_2 | ECU_CON_ACSFT_1,
  90. ECU_ACPOWER_LEFT_SHIFT_7 = ECU_CON_ACSFT_2 | ECU_CON_ACSFT_1 | ECU_CON_ACSFT_0,
  91. ECU_ACPOWER_LEFT_SHIFT_8 = ECU_CON_ACSFT_3,
  92. ECU_ACPOWER_LEFT_SHIFT_9 = ECU_CON_ACSFT_3 | ECU_CON_ACSFT_0,
  93. ECU_ACPOWER_LEFT_SHIFT_10 = ECU_CON_ACSFT_3 | ECU_CON_ACSFT_1,
  94. ECU_ACPOWER_LEFT_SHIFT_11 = ECU_CON_ACSFT_3 | ECU_CON_ACSFT_1 | ECU_CON_ACSFT_0,
  95. ECU_ACPOWER_LEFT_SHIFT_12 = ECU_CON_ACSFT_3 | ECU_CON_ACSFT_2,
  96. ECU_ACPOWER_LEFT_SHIFT_13 = ECU_CON_ACSFT_3 | ECU_CON_ACSFT_2 | ECU_CON_ACSFT_0,
  97. ECU_ACPOWER_LEFT_SHIFT_14 = ECU_CON_ACSFT_3 | ECU_CON_ACSFT_2 | ECU_CON_ACSFT_1,
  98. ECU_ACPOWER_LEFT_SHIFT_15 = ECU_CON_ACSFT_3 | ECU_CON_ACSFT_2 | ECU_CON_ACSFT_1 | ECU_CON_ACSFT_0,
  99. ECU_ACPOWER_LEFT_SHIFT_16 = ECU_CON_ACSFT_4,
  100. } ECU_ACPowerLeftETypeDef;
  101. /**
  102. * @}
  103. */
  104. /** @defgroup LL_ECU_APPOWER_RIGHT_SHIFT ECU apparent power right shift define
  105. * @brief ECU Enumerate the right shift number of the apparent power
  106. * @{
  107. */
  108. typedef enum {
  109. ECU_APPOWER_RIGHT_SHIFT_DISABLE = 0x0,
  110. ECU_APPOWER_RIGHT_SHIFT_1 = ECU_CON_APSFT_0,
  111. ECU_APPOWER_RIGHT_SHIFT_2 = ECU_CON_APSFT_1,
  112. ECU_APPOWER_RIGHT_SHIFT_3 = ECU_CON_APSFT_1 | ECU_CON_APSFT_0,
  113. ECU_APPOWER_RIGHT_SHIFT_4 = ECU_CON_APSFT_2,
  114. ECU_APPOWER_RIGHT_SHIFT_5 = ECU_CON_APSFT_2 | ECU_CON_APSFT_0,
  115. ECU_APPOWER_RIGHT_SHIFT_6 = ECU_CON_APSFT_2 | ECU_CON_APSFT_1,
  116. ECU_APPOWER_RIGHT_SHIFT_7 = ECU_CON_APSFT_2 | ECU_CON_APSFT_1 | ECU_CON_APSFT_0,
  117. ECU_APPOWER_RIGHT_SHIFT_8 = ECU_CON_APSFT_3,
  118. ECU_APPOWER_RIGHT_SHIFT_9 = ECU_CON_APSFT_3 | ECU_CON_APSFT_0,
  119. ECU_APPOWER_RIGHT_SHIFT_10 = ECU_CON_APSFT_3 | ECU_CON_APSFT_1,
  120. ECU_APPOWER_RIGHT_SHIFT_11 = ECU_CON_APSFT_3 | ECU_CON_APSFT_1 | ECU_CON_APSFT_0,
  121. ECU_APPOWER_RIGHT_SHIFT_12 = ECU_CON_APSFT_3 | ECU_CON_APSFT_2,
  122. ECU_APPOWER_RIGHT_SHIFT_13 = ECU_CON_APSFT_3 | ECU_CON_APSFT_2 | ECU_CON_APSFT_0,
  123. ECU_APPOWER_RIGHT_SHIFT_14 = ECU_CON_APSFT_3 | ECU_CON_APSFT_2 | ECU_CON_APSFT_1,
  124. ECU_APPOWER_RIGHT_SHIFT_15 = ECU_CON_APSFT_3 | ECU_CON_APSFT_2 | ECU_CON_APSFT_1 | ECU_CON_APSFT_0,
  125. ECU_APPOWER_RIGHT_SHIFT_16 = ECU_CON_APSFT_4,
  126. } ECU_APPowerRightETypeDef;
  127. /**
  128. * @}
  129. */
  130. /** @defgroup LL_ECU_PSR_DATSEL ECU data external event define
  131. * @brief ECU Enumerate data event selection to select from 16 events
  132. * @note These three types of events must be selected in the same ECR register in the same ADC and cannot be mixed
  133. * @{
  134. */
  135. typedef enum {
  136. /*!<ECU Data trigger from external peripheral : ADC0_ECR[0]->ADDR_DATA_FLAG */
  137. ECU_PSR_DATSEL_ADC0_DTFLAG0 = 0x0,
  138. /*!<ECU Data trigger from external peripheral : ADC0_ECR[1]->ADDR_DATA_FLAG */
  139. ECU_PSR_DATSEL_ADC0_DTFLAG1 = ECU_PRC_DATSEL_0,
  140. /*!<ECU Data trigger from external peripheral : ADC0_ECR[2]->ADDR_DATA_FLAG */
  141. ECU_PSR_DATSEL_ADC0_DTFLAG2 = ECU_PRC_DATSEL_1,
  142. /*!<ECU Data trigger from external peripheral : ADC0_ECR[3]->ADDR_DATA_FLAG */
  143. ECU_PSR_DATSEL_ADC0_DTFLAG3 = ECU_PRC_DATSEL_1 | ECU_PRC_DATSEL_0,
  144. /*!<ECU Data trigger from external peripheral : ADC1_ECR[0]->ADDR_DATA_FLAG */
  145. ECU_PSR_DATSEL_ADC1_DTFLAG0 = ECU_PRC_DATSEL_2,
  146. /*!<ECU Data trigger from external peripheral : ADC1_ECR[1]->ADDR_DATA_FLAG */
  147. ECU_PSR_DATSEL_ADC1_DTFLAG1 = ECU_PRC_DATSEL_2 | ECU_PRC_DATSEL_0,
  148. /*!<ECU Data trigger from external peripheral : ADC1_ECR[2]->ADDR_DATA_FLAG */
  149. ECU_PSR_DATSEL_ADC1_DTFLAG2 = ECU_PRC_DATSEL_2 | ECU_PRC_DATSEL_1,
  150. /*!<ECU Data trigger from external peripheral : ADC1_ECR[3]->ADDR_DATA_FLAG */
  151. ECU_PSR_DATSEL_ADC1_DTFLAG3 = ECU_PRC_DATSEL_2 | ECU_PRC_DATSEL_1 | ECU_PRC_DATSEL_0,
  152. /*!<ECU Data trigger from external peripheral : TIM0_OC */
  153. ECU_PSR_DATSEL_TIM0_OC = ECU_PRC_DATSEL_3,
  154. /*!<ECU Data trigger from external peripheral : TIM1_OC */
  155. ECU_PSR_DATSEL_TIM1_OC = ECU_PRC_DATSEL_3 | ECU_PRC_DATSEL_0,
  156. /*!<ECU Data trigger from external peripheral : TIM2_OC */
  157. ECU_PSR_DATSEL_TIM2_OC = ECU_PRC_DATSEL_3 | ECU_PRC_DATSEL_1,
  158. /*!<ECU Data trigger from external peripheral : TIM3_OC */
  159. ECU_PSR_DATSEL_TIM3_OC = ECU_PRC_DATSEL_3 | ECU_PRC_DATSEL_1 | ECU_PRC_DATSEL_0,
  160. /*!<ECU Data trigger from external peripheral : TIM4_OC */
  161. ECU_PSR_DATSEL_TIM4_OC = ECU_PRC_DATSEL_3 | ECU_PRC_DATSEL_2,
  162. /*!<ECU Data trigger from external peripheral : TIM5_OC */
  163. ECU_PSR_DATSEL_TIM5_OC = ECU_PRC_DATSEL_3 | ECU_PRC_DATSEL_2 | ECU_PRC_DATSEL_0,
  164. /*!<ECU Data trigger from external peripheral : TIM6_OC */
  165. ECU_PSR_DATSEL_TIM6_OC = ECU_PRC_DATSEL_3 | ECU_PRC_DATSEL_2 | ECU_PRC_DATSEL_1,
  166. /*!<ECU Data trigger from external peripheral : TIM7_OC */
  167. ECU_PSR_DATSEL_TIM7_OC = ECU_PRC_DATSEL_3 | ECU_PRC_DATSEL_2 | ECU_PRC_DATSEL_1 | ECU_PRC_DATSEL_0,
  168. } ECU_DataSelETypeDef;
  169. /**
  170. * @}
  171. */
  172. /** @defgroup LL_ECU_PSR_ADRSEL ECU address external event define
  173. * @brief ECU Enumerate the address event (the channel for waveform data) to select from 16 events.
  174. * @note These three types of events must be selected in the same ECR register in the same ADC and cannot be mixed
  175. * @{
  176. */
  177. typedef enum {
  178. /*!<ECU Address trigger from external peripheral : ADC0_ECR[0]->ADDR_DATA_FLAG*/
  179. ECU_PSR_ADRSEL_ADC0_ADFLAG0 = 0x0,
  180. /*!<ECU Address trigger from external peripheral : ADC0_ECR[1]->ADDR_DATA_FLAG*/
  181. ECU_PSR_ADRSEL_ADC0_ADFLAG1 = ECU_PRC_ADRSEL_0,
  182. /*!<ECU Address trigger from external peripheral : ADC0_ECR[2]->ADDR_DATA_FLAG*/
  183. ECU_PSR_ADRSEL_ADC0_ADFLAG2 = ECU_PRC_ADRSEL_1,
  184. /*!<ECU Address trigger from external peripheral : ADC0_ECR[3]->ADDR_DATA_FLAG*/
  185. ECU_PSR_ADRSEL_ADC0_ADFLAG3 = ECU_PRC_ADRSEL_1 | ECU_PRC_ADRSEL_0,
  186. /*!<ECU Address trigger from external peripheral : ADC1_ECR[0]->ADDR_DATA_FLAG*/
  187. ECU_PSR_ADRSEL_ADC1_ADFLAG0 = ECU_PRC_ADRSEL_2,
  188. /*!<ECU Address trigger from external peripheral : ADC1_ECR[1]->ADDR_DATA_FLAG*/
  189. ECU_PSR_ADRSEL_ADC1_ADFLAG1 = ECU_PRC_ADRSEL_2 | ECU_PRC_ADRSEL_0,
  190. /*!<ECU Address trigger from external peripheral : ADC1_ECR[2]->ADDR_DATA_FLAG*/
  191. ECU_PSR_ADRSEL_ADC1_ADFLAG2 = ECU_PRC_ADRSEL_2 | ECU_PRC_ADRSEL_1,
  192. /*!<ECU Address trigger from external peripheral : ADC1_ECR[3]->ADDR_DATA_FLAG*/
  193. ECU_PSR_ADRSEL_ADC1_ADFLAG3 = ECU_PRC_ADRSEL_2 | ECU_PRC_ADRSEL_1 | ECU_PRC_ADRSEL_0,
  194. /*!<ECU Address trigger from external peripheral : TIM0_OC*/
  195. ECU_PSR_ADRSEL_TIM0_OC = ECU_PRC_ADRSEL_3,
  196. /*!<ECU Address trigger from external peripheral : TIM1_OC*/
  197. ECU_PSR_ADRSEL_TIM1_OC = ECU_PRC_ADRSEL_3 | ECU_PRC_ADRSEL_0,
  198. /*!<ECU Address trigger from external peripheral : TIM2_OC*/
  199. ECU_PSR_ADRSEL_TIM2_OC = ECU_PRC_ADRSEL_3 | ECU_PRC_ADRSEL_1,
  200. /*!<ECU Address trigger from external peripheral : TIM3_OC*/
  201. ECU_PSR_ADRSEL_TIM3_OC = ECU_PRC_ADRSEL_3 | ECU_PRC_ADRSEL_1 | ECU_PRC_ADRSEL_0,
  202. /*!<ECU Address trigger from external peripheral : TIM4_OC*/
  203. ECU_PSR_ADRSEL_TIM4_OC = ECU_PRC_ADRSEL_3 | ECU_PRC_ADRSEL_2,
  204. /*!<ECU Address trigger from external peripheral : TIM5_OC*/
  205. ECU_PSR_ADRSEL_TIM5_OC = ECU_PRC_ADRSEL_3 | ECU_PRC_ADRSEL_2 | ECU_PRC_ADRSEL_0,
  206. /*!<ECU Address trigger from external peripheral : TIM6_OC*/
  207. ECU_PSR_ADRSEL_TIM6_OC = ECU_PRC_ADRSEL_3 | ECU_PRC_ADRSEL_2 | ECU_PRC_ADRSEL_1,
  208. /*!<ECU Address trigger from external peripheral : TIM7_OC*/
  209. ECU_PSR_ADRSEL_TIM7_OC = ECU_PRC_ADRSEL_3 | ECU_PRC_ADRSEL_2 | ECU_PRC_ADRSEL_1 | ECU_PRC_ADRSEL_0,
  210. } ECU_AddrSelETypeDef;
  211. /**
  212. * @}
  213. */
  214. /** @defgroup LL_ECU_PSR_CRSSEL ECU cross zero external event define
  215. * @brief ECU Enumerate zero crossing events (monitoring events for sinusoidal waveform zero crossing) and select from 16 events.
  216. * @note These three types of events must be selected in the same ECR register in the same ADC and cannot be mixed
  217. * @{
  218. */
  219. typedef enum {
  220. /*!<ECU Crossing zero signal trigger from external peripheral : ADC0_ECR[0]->PSRCU/PSRCD */
  221. ECU_PSR_CRSSEL_ADC0_PPFLAG0 = 0x0,
  222. /*!<ECU Crossing zero signal trigger from external peripheral : ADC0_ECR[1]->PSRCU/PSRCD */
  223. ECU_PSR_CRSSEL_ADC0_PPFLAG1 = ECU_PRC_CRSSEL_0,
  224. /*!<ECU Crossing zero signal trigger from external peripheral : ADC0_ECR[2]->PSRCU/PSRCD */
  225. ECU_PSR_CRSSEL_ADC0_PPFLAG2 = ECU_PRC_CRSSEL_1,
  226. /*!<ECU Crossing zero signal trigger from external peripheral : ADC0_ECR[3]->PSRCU/PSRCD */
  227. ECU_PSR_CRSSEL_ADC0_PPFLAG3 = ECU_PRC_CRSSEL_1 | ECU_PRC_CRSSEL_0,
  228. /*!<ECU Crossing zero signal trigger from external peripheral : ADC1_ECR[0]->PSRCU/PSRCD */
  229. ECU_PSR_CRSSEL_ADC1_PPFLAG0 = ECU_PRC_CRSSEL_2,
  230. /*!<ECU Crossing zero signal trigger from external peripheral : ADC1_ECR[1]->PSRCU/PSRCD */
  231. ECU_PSR_CRSSEL_ADC1_PPFLAG1 = ECU_PRC_CRSSEL_2 | ECU_PRC_CRSSEL_0,
  232. /*!<ECU Crossing zero signal trigger from external peripheral : ADC1_ECR[2]->PSRCU/PSRCD */
  233. ECU_PSR_CRSSEL_ADC1_PPFLAG2 = ECU_PRC_CRSSEL_2 | ECU_PRC_CRSSEL_1,
  234. /*!<ECU Crossing zero signal trigger from external peripheral : ADC1_ECR[3]->PSRCU/PSRCD */
  235. ECU_PSR_CRSSEL_ADC1_PPFLAG3 = ECU_PRC_CRSSEL_2 | ECU_PRC_CRSSEL_1 | ECU_PRC_CRSSEL_0,
  236. /*!<ECU Crossing zero signal trigger from external peripheral : TIM0_OC */
  237. ECU_PSR_CRSSEL_TIM0_OC = ECU_PRC_CRSSEL_3,
  238. /*!<ECU Crossing zero signal trigger from external peripheral : TIM1_OC */
  239. ECU_PSR_CRSSEL_TIM1_OC = ECU_PRC_CRSSEL_3 | ECU_PRC_CRSSEL_0,
  240. /*!<ECU Crossing zero signal trigger from external peripheral : TIM2_OC */
  241. ECU_PSR_CRSSEL_TIM2_OC = ECU_PRC_CRSSEL_3 | ECU_PRC_CRSSEL_1,
  242. /*!<ECU Crossing zero signal trigger from external peripheral : TIM3_OC */
  243. ECU_PSR_CRSSEL_TIM3_OC = ECU_PRC_CRSSEL_3 | ECU_PRC_CRSSEL_1 | ECU_PRC_CRSSEL_0,
  244. /*!<ECU Crossing zero signal trigger from external peripheral : TIM4_OC */
  245. ECU_PSR_CRSSEL_TIM4_OC = ECU_PRC_CRSSEL_3 | ECU_PRC_CRSSEL_2,
  246. /*!<ECU Crossing zero signal trigger from external peripheral : TIM5_OC */
  247. ECU_PSR_CRSSEL_TIM5_OC = ECU_PRC_CRSSEL_3 | ECU_PRC_CRSSEL_2 | ECU_PRC_CRSSEL_0,
  248. /*!<ECU Crossing zero signal trigger from external peripheral : TIM6_OC */
  249. ECU_PSR_CRSSEL_TIM6_OC = ECU_PRC_CRSSEL_3 | ECU_PRC_CRSSEL_2 | ECU_PRC_CRSSEL_1,
  250. /*!<ECU Crossing zero signal trigger from external peripheral : TIM7_OC */
  251. ECU_PSR_CRSSEL_TIM7_OC = ECU_PRC_CRSSEL_3 | ECU_PRC_CRSSEL_2 | ECU_PRC_CRSSEL_1 | ECU_PRC_CRSSEL_0,
  252. } ECU_CrossZeroSelETypeDef;
  253. /**
  254. * @}
  255. */
  256. /**
  257. * @brief ECU Init structure definition
  258. */
  259. typedef struct __ECU_InitTypeDef {
  260. LL_FuncStatusETypeDef ModuleEnable; /*!< Specifies ECU module enablement Bit.
  261. This parameter can be any value of @ref ENABLE or DISABLE*/
  262. LL_FuncStatusETypeDef InterruptEn; /*!< Specifies ECU module enable interrupt.
  263. This parameter can be any value of @ref ENABLE or DISABLE */
  264. ECU_AverageETypedef AverageSel; /*!< Setting the result requires averaging the data over several cycles.
  265. This parameter can be a value of @ref LL_ECU_AVERAGE */
  266. ECU_APPowerRightETypeDef APRightShift; /*!< Set the number of right shifts of the ECU view Apparent power.
  267. This parameter can be a value of @ref LL_ECU_APPOWER_RIGHT_SHIFT */
  268. ECU_ACPowerLeftETypeDef ACLeftShift; /*!< Set the number of left shift of active power and the maximum left shift is 16 bits.
  269. This parameter can be a value of @ref LL_ECU_ACPOWER_LEFT_SHIFT*/
  270. ECU_CrossZeroSelETypeDef CrossZeroSel; /*!< Set zero crossing events (monitoring events for sinusoidal waveform zero crossing)
  271. and select from 16 events. This parameter can be a value of @ref LL_ECU_PSR_CRSSEL */
  272. ECU_AddrSelETypeDef AddressSel; /*!< Set the address event (the channel for waveform data) to select from 16 events.
  273. This parameter can be a value of @ref LL_ECU_PSR_ADRSEL */
  274. ECU_DataSelETypeDef DataSel; /*!< Set data event selection to select from 16 events.
  275. This parameter can be a value of @ref LL_ECU_PSR_DATSEL */
  276. uint32_t VStartAddr; /*!< Set the starting address for voltage (pingpong) data storage.*/
  277. uint32_t VOffsetAddr; /*!< Set voltage (pingpong) data to store offset address.*/
  278. uint32_t IStartAddr; /*!< Set the starting address for current (pingpong) data storage.*/
  279. uint32_t IOffsetAddr; /*!< Set current (pingpong) data to store offset address.*/
  280. } ECU_InitTypeDef;
  281. /**
  282. * @}
  283. */
  284. /* Exported macro ------------------------------------------------------------*/
  285. /** @defgroup ECU_LL_Exported_Macros ECU LL Exported Macros
  286. * @brief ECU LL Exported Macros
  287. * @{
  288. */
  289. /**
  290. * @brief Enable the ECU module.
  291. * @param __INSTANCE__ Specifies ECU peripheral
  292. * @return None
  293. */
  294. #define __LL_ECU_MODULE_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CON, ECU_CON_ENABLE)
  295. /**
  296. * @brief Disable the ECU module.
  297. * @param __INSTANCE__ Specifies ECU peripheral
  298. * @return None
  299. */
  300. #define __LL_ECU_MODULE_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CON, ECU_CON_ENABLE)
  301. /**
  302. * @brief Get the ECU module states.
  303. * @param __INSTANCE__ Specifies ECU peripheral
  304. * @return ENABLE : the module is enable
  305. * DISABLE : the module is disable
  306. */
  307. #define __LL_ECU_GET_STA(__INSTANCE__) ((((__INSTANCE__)->CON & (ECU_CON_ENABLE)) == 0x1UL) ? ENABLE : DISABLE)
  308. /**
  309. * @brief Enable the specified ECU Calculate complete interrupt.
  310. * @param __INSTANCE__ Specifies ECU peripheral
  311. * @return None
  312. */
  313. #define __LL_ECU_DONE_IT_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CON, ECU_CON_INTEN)
  314. /**
  315. * @brief Disable the specified ECU Calculate complete interrupt.
  316. * @param __INSTANCE__ Specifies ECU peripheral
  317. * @return None
  318. */
  319. #define __LL_ECU_DONE_IT_DISABLE(__INSTANCE__) CLEAR_BIT((__INSTANCE__)->CON, ECU_CON_INTEN)
  320. /**
  321. * @brief Check the ECU Calculate complete interrupts are enabled or disable.
  322. * @param __INSTANCE__ Specifies ECU peripheral
  323. * @return SET : the interrupt is enable
  324. * RESET : the interrupt is disable
  325. */
  326. #define __LL_ECU_DONE_GET_IT(__INSTANCE__) ((((__INSTANCE__)->CON & (ECU_CON_INTEN)) == 0x02UL) ? SET : RESET)
  327. /**
  328. * @brief Check whether the specified ECU Calculate complete pending flag is set or not.
  329. * @param __INSTANCE__ Specifies ECU peripheral
  330. * @return SET : the interrupt flag is set
  331. * RESET : the interrupt flag is reset
  332. */
  333. #define __LL_ECU_DONE_GET_FLAG(__INSTANCE__) ((((__INSTANCE__)->CON & (ECU_CON_INT)) == 0x8000UL) ? SET : RESET)
  334. /**
  335. * @brief Clear the specified ECU Calculate complete pending flags.
  336. * @param __INSTANCE__ Specifies ECU peripheral
  337. * @return None
  338. */
  339. #define __LL_ECU_DONE_CLEAR_FLAG(__INSTANCE__) SET_BIT((__INSTANCE__)->CON, ECU_CON_INT)
  340. /**
  341. * @brief Input data square enable, after the completion of the calculation automatically reset
  342. * @param __INSTANCE__ Specifies ECU peripheral
  343. * @return None
  344. */
  345. #define __LL_ECU_SQRT_ENABLE(__INSTANCE__) SET_BIT((__INSTANCE__)->CON, ECU_CON_SQRT)
  346. /**
  347. * @brief Gets the square root completion flag
  348. * @param __INSTANCE__ Specifies ECU peripheral
  349. * @return RESET That means the square root is complete
  350. * SET That means the square root is not complete
  351. */
  352. #define __LL_ECU_SQRT_DONE_FLAG(__INSTANCE__) ((((__INSTANCE__)->CON & (ECU_CON_SQRT)) == 0x4000UL) ? SET : RESET)
  353. /**
  354. * @brief Sets the zero crossing event that needs to be selected
  355. * @param __INSTANCE__ Specifies ECU peripheral
  356. * @param __EVENT__ cross zero event as follow:
  357. * @arg @ref ECU_PSR_CRSSEL_ADC0_PPFLAF0
  358. * @arg @ref ECU_PSR_CRSSEL_ADC0_PPFLAG1
  359. * @arg @ref ECU_PSR_CRSSEL_ADC0_PPFLAG2
  360. * @arg @ref ECU_PSR_CRSSEL_ADC0_PPFLAG3
  361. * @arg @ref ECU_PSR_CRSSEL_ADC1_PPFLAG0
  362. * @arg @ref ECU_PSR_CRSSEL_ADC1_PPFLAG1
  363. * @arg @ref ECU_PSR_CRSSEL_ADC1_PPFLAG2
  364. * @arg @ref ECU_PSR_CRSSEL_ADC1_PPFLAG3
  365. * @arg @ref ECU_PSR_CRSSEL_TIM0_OC
  366. * @arg @ref ECU_PSR_CRSSEL_TIM1_OC
  367. * @arg @ref ECU_PSR_CRSSEL_TIM2_OC
  368. * @arg @ref ECU_PSR_CRSSEL_TIM3_OC
  369. * @arg @ref ECU_PSR_CRSSEL_TIM4_OC
  370. * @arg @ref ECU_PSR_CRSSEL_TIM5_OC
  371. * @arg @ref ECU_PSR_CRSSEL_TIM6_OC
  372. * @arg @ref ECU_PSR_CRSSEL_TIM7_OC
  373. * @return None
  374. */
  375. #define __LL_ECU_CROSS_ZERO_EVENT(__INSTANCE__, __EVENT__) MODIFY_REG((__INSTANCE__)->PRC, ECU_PRC_CRSSEL, __EVENT__)
  376. /**
  377. * @brief Sets the data event that needs to be selected
  378. * @param __INSTANCE__ Specifies ECU peripheral
  379. * @param __EVENT__ cross zero event as follow:
  380. * @arg @ref ECU_PSR_DATSEL_ADC0_PPFLAF0
  381. * @arg @ref ECU_PSR_DATSEL_ADC0_PPFLAG1
  382. * @arg @ref ECU_PSR_DATSEL_ADC0_PPFLAG2
  383. * @arg @ref ECU_PSR_DATSEL_ADC0_PPFLAG3
  384. * @arg @ref ECU_PSR_DATSEL_ADC1_PPFLAG0
  385. * @arg @ref ECU_PSR_DATSEL_ADC1_PPFLAG1
  386. * @arg @ref ECU_PSR_DATSEL_ADC1_PPFLAG2
  387. * @arg @ref ECU_PSR_DATSEL_ADC1_PPFLAG3
  388. * @arg @ref ECU_PSR_DATSEL_TIM0_OC
  389. * @arg @ref ECU_PSR_DATSEL_TIM1_OC
  390. * @arg @ref ECU_PSR_DATSEL_TIM2_OC
  391. * @arg @ref ECU_PSR_DATSEL_TIM3_OC
  392. * @arg @ref ECU_PSR_DATSEL_TIM4_OC
  393. * @arg @ref ECU_PSR_DATSEL_TIM5_OC
  394. * @arg @ref ECU_PSR_DATSEL_TIM6_OC
  395. * @arg @ref ECU_PSR_DATSEL_TIM7_OC
  396. * @return None
  397. */
  398. #define __LL_ECU_DATA_FLAG_EVENT(__INSTANCE__, __EVENT__) MODIFY_REG((__INSTANCE__)->PRC, ECU_PRC_DATSEL, __EVENT__)
  399. /**
  400. * @brief Sets the addr_data flag event that needs to be selected
  401. * @param __INSTANCE__ Specifies ECU peripheral
  402. * @param __EVENT__ cross zero event as follow:
  403. * @arg @ref ECU_PSR_ADRSEL_ADC0_PPFLAF0
  404. * @arg @ref ECU_PSR_ADRSEL_ADC0_PPFLAG1
  405. * @arg @ref ECU_PSR_ADRSEL_ADC0_PPFLAG2
  406. * @arg @ref ECU_PSR_ADRSEL_ADC0_PPFLAG3
  407. * @arg @ref ECU_PSR_ADRSEL_ADC1_PPFLAG0
  408. * @arg @ref ECU_PSR_ADRSEL_ADC1_PPFLAG1
  409. * @arg @ref ECU_PSR_ADRSEL_ADC1_PPFLAG2
  410. * @arg @ref ECU_PSR_ADRSEL_ADC1_PPFLAG3
  411. * @arg @ref ECU_PSR_ADRSEL_TIM0_OC
  412. * @arg @ref ECU_PSR_ADRSEL_TIM1_OC
  413. * @arg @ref ECU_PSR_ADRSEL_TIM2_OC
  414. * @arg @ref ECU_PSR_ADRSEL_TIM3_OC
  415. * @arg @ref ECU_PSR_ADRSEL_TIM4_OC
  416. * @arg @ref ECU_PSR_ADRSEL_TIM5_OC
  417. * @arg @ref ECU_PSR_ADRSEL_TIM6_OC
  418. * @arg @ref ECU_PSR_ADRSEL_TIM7_OC
  419. * @return None
  420. */
  421. #define __LL_ECU_ADDR_FLAG_EVENT(__INSTANCE__, __EVENT__) MODIFY_REG((__INSTANCE__)->PRC, ECU_PRC_ADRSEL, __EVENT__)
  422. /**
  423. * @brief Get the average effective value of the voltage
  424. * @param __INSTANCE__ Specifies ECU peripheral
  425. * @return The result of the voltage
  426. */
  427. #define __LL_ECU_GET_VRMS(__INSTANCE__) READ_BIT((__INSTANCE__)->V, ECU_V_VRMS)
  428. /**
  429. * @brief Get the average effective value of the current
  430. * @param __INSTANCE__ Specifies ECU peripheral
  431. * @return The result of the current
  432. */
  433. #define __LL_ECU_GET_IRMS(__INSTANCE__) READ_BIT((__INSTANCE__)->I, ECU_I_IRMS)
  434. /**
  435. * @brief Get the average active power
  436. * @param __INSTANCE__ Specifies ECU peripheral
  437. * @return The result of average active power
  438. */
  439. #define __LL_ECU_P_PAVG(__INSTANCE__) READ_REG((__INSTANCE__)->P)
  440. /**
  441. * @brief Get the average reactive power
  442. * @param __INSTANCE__ Specifies ECU peripheral
  443. * @return The result of average reactive power
  444. */
  445. #define __LL_ECU_Q_QAVG(__INSTANCE__) READ_REG((__INSTANCE__)->Q)
  446. /**
  447. * @brief Get the apparent power value
  448. * @param __INSTANCE__ Specifies ECU peripheral
  449. * @return The result of apparent power
  450. */
  451. #define __LL_ECU_S_SCAL(__INSTANCE__) READ_REG((__INSTANCE__)->S)
  452. /**
  453. * @brief Get the power factor value
  454. * @param __INSTANCE__ Specifies ECU peripheral
  455. * @return The result of power factor
  456. */
  457. #define __LL_ECU_PF_PFCAL(__INSTANCE__) READ_REG((__INSTANCE__)->PF)
  458. /**
  459. * @brief Get the fundamental frequency value
  460. * @param __INSTANCE__ Specifies ECU peripheral
  461. * @return The result of fundamental frequency
  462. */
  463. #define __LL_ECU_F_FCNT(__INSTANCE__) READ_BIT((__INSTANCE__)->F, ECU_F_FCNT)
  464. /**
  465. * @}
  466. */
  467. /* Exported functions --------------------------------------------------------*/
  468. /** @addtogroup ECU_LL_Exported_Functions
  469. * @{
  470. */
  471. /** @addtogroup ECU_LL_Exported_Functions_Group1
  472. * @{
  473. */
  474. LL_StatusETypeDef LL_ECU_Init(ECU_TypeDef *Instance, ECU_InitTypeDef *ECU_Init);
  475. LL_StatusETypeDef LL_ECU_DeInit(ECU_TypeDef *Instance);
  476. void LL_ECU_MspInit(ECU_TypeDef *Instance);
  477. void LL_ECU_MspDeInit(ECU_TypeDef *Instance);
  478. /**
  479. * @}
  480. */
  481. /** @addtogroup ECU_LL_Exported_Functions_Group2
  482. * @{
  483. */
  484. void LL_ECU_WriteSqrtInData(ECU_TypeDef *Instance, uint32_t SqrtValue);
  485. uint32_t LL_ECU_ReadSqrtOutData(ECU_TypeDef *Instance);
  486. /**
  487. * @}
  488. */
  489. /** @addtogroup ECU_LL_Exported_Functions_Interrupt
  490. * @{
  491. */
  492. void LL_ECU_IRQHandler(ECU_TypeDef *Instance);
  493. void LL_ECU_CalDoneCallback(ECU_TypeDef *Instance);
  494. /**
  495. * @}
  496. */
  497. /**
  498. * @}
  499. */
  500. /* Private types -------------------------------------------------------------*/
  501. /* Private variables ---------------------------------------------------------*/
  502. /* Private constants ---------------------------------------------------------*/
  503. /* Private macros ------------------------------------------------------------*/
  504. /** @defgroup ECU_LL_Private_Macros ECU LL Private Macros
  505. * @brief ECU LL Private Macros
  506. * @{
  507. */
  508. /**
  509. * @brief Judge is ECU enable/disable mode or not
  510. * @param __MODE__ mode to judge
  511. * @retval 0 isn't ECU enable/disable mode
  512. * @retval 1 is ECU enable/disable mode
  513. */
  514. #define IS_ECU_MODULE(__MODE__) \
  515. ( ((__MODE__) == ECU_DISABLE) \
  516. || ((__MODE__) == ECU_ENABLE) \
  517. )
  518. /**
  519. * @brief Judge is ECU average or not
  520. * @param __AVERAGE__ average to judge
  521. * @retval 0 isn't ECU average
  522. * @retval 1 is ECU average
  523. */
  524. #define IS_ECU_AVERAGE(__AVERAGE__) \
  525. ( ((__AVERAGE__) == ECU_AVERAGE_DISABLE) \
  526. || ((__AVERAGE__) == ECU_AVERAGE_2PERIOD) \
  527. || ((__AVERAGE__) == ECU_AVERAGE_4PERIOD) \
  528. || ((__AVERAGE__) == ECU_AVERAGE_8PERIOD) \
  529. )
  530. /**
  531. * @brief Judge is ECU acsft or not
  532. * @param __ACSFT__ acsft to judge
  533. * @retval 0 isn't ECU acsft
  534. * @retval 1 is ECU acsft
  535. */
  536. #define IS_ECU_ACSFT(__ACSFT__) \
  537. ( ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_DISABLE) \
  538. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_1) \
  539. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_2) \
  540. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_3) \
  541. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_4) \
  542. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_5) \
  543. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_6) \
  544. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_7) \
  545. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_8) \
  546. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_9) \
  547. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_10) \
  548. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_11) \
  549. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_12) \
  550. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_13) \
  551. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_14) \
  552. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_15) \
  553. || ((__ACSFT__) == ECU_ACPOWER_LEFT_SHIFT_16) \
  554. )
  555. /**
  556. * @brief Judge is ECU apsft or not
  557. * @param __APSFT__ apsft to judge
  558. * @retval 0 isn't ECU apsft
  559. * @retval 1 is ECU apsft
  560. */
  561. #define IS_ECU_APSFT(__APSFT__) \
  562. ( ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_DISABLE) \
  563. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_1) \
  564. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_2) \
  565. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_3) \
  566. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_4) \
  567. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_5) \
  568. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_6) \
  569. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_7) \
  570. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_8) \
  571. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_9) \
  572. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_10) \
  573. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_11) \
  574. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_12) \
  575. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_13) \
  576. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_14) \
  577. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_15) \
  578. || ((__APSFT__) == ECU_APPOWER_RIGHT_SHIFT_16) \
  579. )
  580. /**
  581. * @brief Judge is ECU datsel or not
  582. * @param __DATSEL__ datsel to judge
  583. * @retval 0 isn't ECU datsel
  584. * @retval 1 is ECU datsel
  585. */
  586. #define IS_ECU_DATSEL(__DATSEL__) \
  587. ( ((__DATSEL__) == ECU_PSR_DATSEL_ADC0_DTFLAG0) \
  588. || ((__DATSEL__) == ECU_PSR_DATSEL_ADC0_DTFLAG1) \
  589. || ((__DATSEL__) == ECU_PSR_DATSEL_ADC0_DTFLAG2) \
  590. || ((__DATSEL__) == ECU_PSR_DATSEL_ADC0_DTFLAG3) \
  591. || ((__DATSEL__) == ECU_PSR_DATSEL_ADC1_DTFLAG0) \
  592. || ((__DATSEL__) == ECU_PSR_DATSEL_ADC1_DTFLAG1) \
  593. || ((__DATSEL__) == ECU_PSR_DATSEL_ADC1_DTFLAG2) \
  594. || ((__DATSEL__) == ECU_PSR_DATSEL_ADC1_DTFLAG3) \
  595. || ((__DATSEL__) == ECU_PSR_DATSEL_TIM0_OC) \
  596. || ((__DATSEL__) == ECU_PSR_DATSEL_TIM1_OC) \
  597. || ((__DATSEL__) == ECU_PSR_DATSEL_TIM2_OC) \
  598. || ((__DATSEL__) == ECU_PSR_DATSEL_TIM3_OC) \
  599. || ((__DATSEL__) == ECU_PSR_DATSEL_TIM4_OC) \
  600. || ((__DATSEL__) == ECU_PSR_DATSEL_TIM5_OC) \
  601. || ((__DATSEL__) == ECU_PSR_DATSEL_TIM6_OC) \
  602. || ((__DATSEL__) == ECU_PSR_DATSEL_TIM7_OC) \
  603. )
  604. /**
  605. * @brief Judge is ECU crssel or not
  606. * @param __CRSSEL__ crssel to judge
  607. * @retval 0 isn't ECU crssel
  608. * @retval 1 is ECU crssel
  609. */
  610. #define IS_ECU_CRSSEL(__CRSSEL__) \
  611. ( ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC0_PPFLAG0) \
  612. || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC0_PPFLAG1) \
  613. || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC0_PPFLAG2) \
  614. || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC0_PPFLAG3) \
  615. || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC1_PPFLAG0) \
  616. || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC1_PPFLAG1) \
  617. || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC1_PPFLAG2) \
  618. || ((__CRSSEL__) == ECU_PSR_CRSSEL_ADC1_PPFLAG3) \
  619. || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM0_OC) \
  620. || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM1_OC) \
  621. || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM2_OC) \
  622. || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM3_OC) \
  623. || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM4_OC) \
  624. || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM5_OC) \
  625. || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM6_OC) \
  626. || ((__CRSSEL__) == ECU_PSR_CRSSEL_TIM7_OC) \
  627. )
  628. /**
  629. * @}
  630. */
  631. /* Private functions ---------------------------------------------------------*/
  632. /**
  633. * @}
  634. */
  635. /**
  636. * @}
  637. */
  638. #ifdef __cplusplus
  639. }
  640. #endif /* __cplusplus */
  641. #endif /* _TAE32F53XX_LL_ECU_H_ */
  642. /************************* (C) COPYRIGHT Tai-Action *****END OF FILE***********/