dcc.h 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. /** @file dcc.h
  2. * @brief DCC Driver Definition File
  3. * @date 29.May.2013
  4. * @version 03.05.02
  5. *
  6. */
  7. /* (c) Texas Instruments 2009-2013, All rights reserved. */
  8. #ifndef __DCC_H__
  9. #define __DCC_H__
  10. #include "reg_dcc.h"
  11. /* DCC General Definitions */
  12. /** @def dcc1CNT0_CLKSRC_HFLPO
  13. * @brief Alias name for DCC1 Counter 0 Clock Source HFLPO
  14. *
  15. * This is an alias name for the Clock Source HFLPO for DCC1 Counter 0.
  16. *
  17. * @note This value should be used for API argument @a cnt0_Clock_Source
  18. */
  19. #define dcc1CNT0_CLKSRC_HFLPO 0x00000005U
  20. /** @def dcc1CNT0_CLKSRC_TCK
  21. * @brief Alias name for DCC1 Counter 0 Clock Source TCK
  22. *
  23. * This is an alias name for the Clock Source TCK for DCC1 Counter 0.
  24. *
  25. * @note This value should be used for API argument @a cnt0_Clock_Source
  26. */
  27. #define dcc1CNT0_CLKSRC_TCK 0x0000000AU
  28. /** @def dcc1CNT0_CLKSRC_OSCIN
  29. * @brief Alias name for DCC1 Counter 0 Clock Source OSCIN
  30. *
  31. * This is an alias name for the Clock Source OSCIN for DCC1 Counter 0.
  32. *
  33. * @note This value should be used for API argument @a cnt0_Clock_Source
  34. */
  35. #define dcc1CNT0_CLKSRC_OSCIN 0x0000000FU
  36. /** @def dcc1CNT1_CLKSRC_PLL1
  37. * @brief Alias name for DCC1 Counter 1 Clock Source PLL1
  38. *
  39. * This is an alias name for the Clock Source PLL for DCC1 Counter 1.
  40. *
  41. * @note This value should be used for API argument @a cnt1_Clock_Source
  42. */
  43. #define dcc1CNT1_CLKSRC_PLL1 0x0000A0000U
  44. /** @def dcc1CNT1_CLKSRC_PLL2
  45. * @brief Alias name for DCC1 Counter 1 Clock Source PLL2
  46. *
  47. * This is an alias name for the Clock Source OSCIN for DCC1 Counter 1.
  48. *
  49. * @note This value should be used for API argument @a cnt1_Clock_Source
  50. */
  51. #define dcc1CNT1_CLKSRC_PLL2 0x0000A0001U
  52. /** @def dcc1CNT1_CLKSRC_LFLPO
  53. * @brief Alias name for DCC1 Counter 1 Clock Source LFLPO
  54. *
  55. * This is an alias name for the Clock Source LFLPO for DCC1 Counter 1.
  56. *
  57. * @note This value should be used for API argument @a cnt1_Clock_Source
  58. */
  59. #define dcc1CNT1_CLKSRC_LFLPO 0x0000A0002U
  60. /** @def dcc1CNT1_CLKSRC_HFLPO
  61. * @brief Alias name for DCC1 Counter 1 Clock Source HFLPO
  62. *
  63. * This is an alias name for the Clock Source HFLPO for DCC1 Counter 1.
  64. *
  65. * @note This value should be used for API argument @a cnt1_Clock_Source
  66. */
  67. #define dcc1CNT1_CLKSRC_HFLPO 0x0000A0003U
  68. /** @def dcc1CNT1_CLKSRC_EXTCLKIN1
  69. * @brief Alias name for DCC1 Counter 1 Clock Source EXTCLKIN1
  70. *
  71. * This is an alias name for the Clock Source EXTCLKIN1 for DCC1 Counter 1.
  72. *
  73. * @note This value should be used for API argument @a cnt1_Clock_Source
  74. */
  75. #define dcc1CNT1_CLKSRC_EXTCLKIN1 0x0000A0005U
  76. /** @def dcc1CNT1_CLKSRC_EXTCLKIN2
  77. * @brief Alias name for DCC1 Counter 1 Clock Source EXTCLKIN2
  78. *
  79. * This is an alias name for the Clock Source EXTCLKIN2 for DCC1 Counter 1.
  80. *
  81. * @note This value should be used for API argument @a cnt1_Clock_Source
  82. */
  83. #define dcc1CNT1_CLKSRC_EXTCLKIN2 0x0000A0006U
  84. /** @def dcc1CNT1_CLKSRC_VCLK
  85. * @brief Alias name for DCC1 Counter 1 Clock Source VCLK
  86. *
  87. * This is an alias name for the Clock Source VCLK for DCC1 Counter 1.
  88. *
  89. * @note This value should be used for API argument @a cnt1_Clock_Source
  90. */
  91. #define dcc1CNT1_CLKSRC_VCLK 0x0000A0008U
  92. /** @def dcc1CNT1_CLKSRC_N2HET1_31
  93. * @brief Alias name for DCC1 Counter 1 Clock Source N2HET1_31
  94. *
  95. * This is an alias name for the Clock Source N2HET1_31 for DCC1 Counter 1.
  96. *
  97. * @note This value should be used for API argument @a cnt1_Clock_Source
  98. */
  99. #define dcc1CNT1_CLKSRC_N2HET1_31 0x00005000FU
  100. /** @def dcc2CNT0_CLKSRC_TCK
  101. * @brief Alias name for DCC2 Counter 0 Clock Source TCK
  102. *
  103. * This is an alias name for the Clock Source TCK for DCC2 Counter 0.
  104. *
  105. * @note This value should be used for API argument @a cnt0_Clock_Source
  106. */
  107. #define dcc2CNT0_CLKSRC_TCK 0x0000000AU
  108. /** @def dcc1CNT0_CLKSRC_OSCIN
  109. * @brief Alias name for DCC1 Counter 0 Clock Source OSCIN
  110. *
  111. * This is an alias name for the Clock Source OSCIN for DCC2 Counter 0.
  112. *
  113. * @note This value should be used for API argument @a cnt0_Clock_Source
  114. */
  115. #define dcc2CNT0_CLKSRC_OSCIN 0x0000000FU
  116. /** @def dcc2CNT1_CLKSRC_VCLK
  117. * @brief Alias name for DCC2 Counter 1 Clock Source VCLK
  118. *
  119. * This is an alias name for the Clock Source VCLK for DCC2 Counter 1.
  120. *
  121. * @note This value should be used for API argument @a cnt1_Clock_Source
  122. */
  123. #define dcc2CNT1_CLKSRC_VCLK 0x0000A0008U
  124. /** @def dcc2CNT1_CLKSRC_N2HET1_0
  125. * @brief Alias name for DCC2 Counter 1 Clock Source N2HET2_0
  126. *
  127. * This is an alias name for the Clock Source N2HET2_0 for DCC2 Counter 1.
  128. *
  129. * @note This value should be used for API argument @a cnt1_Clock_Source
  130. */
  131. #define dcc2CNT1_CLKSRC_N2HET1_0 0x00005000FU
  132. /** @def dccNOTIFICATION_DONE
  133. * @brief Alias name for DCC Done notification
  134. *
  135. * This is an alias name for the DCC Done notification.
  136. *
  137. * @note This value should be used for API argument @a notification
  138. */
  139. #define dccNOTIFICATION_DONE 0x0000A000U
  140. /** @def dccNOTIFICATION_ERROR
  141. * @brief Alias name for DCC Error notification
  142. *
  143. * This is an alias name for the DCC Error notification.
  144. *
  145. * @note This value should be used for API argument @a notification
  146. */
  147. #define dccNOTIFICATION_ERROR 0x000000A0U
  148. /** @enum dcc1clocksource
  149. * @brief Alias names for dcc clock sources
  150. *
  151. * This enumeration is used to provide alias names for the clock sources:
  152. */
  153. enum dcc1clocksource
  154. {
  155. DCC1_CNT0_HF_LPO = 0x5U, /**< Alias for DCC1 CNT 0 CLOCK SOURCE 0*/
  156. DCC1_CNT0_TCK = 0xAU, /**< Alias for DCC1 CNT 0 CLOCK SOURCE 1*/
  157. DCC1_CNT0_OSCIN = 0xFU, /**< Alias for DCC1 CNT 0 CLOCK SOURCE 2*/
  158. DCC1_CNT1_PLL1 = 0x0U, /**< Alias for DCC1 CNT 1 CLOCK SOURCE 0*/
  159. DCC1_CNT1_PLL2 = 0x1U, /**< Alias for DCC1 CNT 1 CLOCK SOURCE 1*/
  160. DCC1_CNT1_LF_LPO = 0x2U, /**< Alias for DCC1 CNT 1 CLOCK SOURCE 2*/
  161. DCC1_CNT1_HF_LPO = 0x3U, /**< Alias for DCC1 CNT 1 CLOCK SOURCE 3*/
  162. DCC1_CNT1_EXTCLKIN1 = 0x5U, /**< Alias for DCC1 CNT 1 CLOCK SOURCE 4*/
  163. DCC1_CNT1_EXTCLKIN2 = 0x6U, /**< Alias for DCC1 CNT 1 CLOCK SOURCE 6*/
  164. DCC1_CNT1_VCLK = 0x8U, /**< Alias for DCC1 CNT 1 CLOCK SOURCE 8*/
  165. DCC1_CNT1_N2HET1_31 = 0xAU /**< Alias for DCC1 CNT 1 CLOCK SOURCE 9*/
  166. };
  167. /** @enum dcc2clocksource
  168. * @brief Alias names for dcc clock sources
  169. *
  170. * This enumeration is used to provide alias names for the clock sources:
  171. */
  172. enum dcc2clocksource
  173. {
  174. DCC2_CNT0_OSCIN = 0xFU, /**< Alias for DCC1 CNT 0 CLOCK SOURCE 0*/
  175. DCC2_CNT0_TCK = 0xAU, /**< Alias for DCC1 CNT 0 CLOCK SOURCE 2*/
  176. DCC2_CNT1_VCLK = 0x8U, /**< Alias for DCC1 CNT 1 CLOCK SOURCE 8*/
  177. DCC2_CNT1_N2HET2_0 = 0xAU /**< Alias for DCC1 CNT 1 CLOCK SOURCE 9*/
  178. };
  179. /* Configuration registers */
  180. typedef struct dcc_config_reg
  181. {
  182. uint32 CONFIG_GCTRL;
  183. uint32 CONFIG_CNT0SEED;
  184. uint32 CONFIG_VALID0SEED;
  185. uint32 CONFIG_CNT1SEED;
  186. uint32 CONFIG_CLKSRC1;
  187. uint32 CONFIG_CLKSRC0;
  188. } dcc_config_reg_t;
  189. /* Configuration registers initial value */
  190. #define DCC1_GCTRL_CONFIGVALUE 0xAU | (0xAU << 4U) | (0x5U << 8U) | (0xAU << 12U)
  191. #define DCC1_CNT0SEED_CONFIGVALUE 39204U
  192. #define DCC1_VALID0SEED_CONFIGVALUE 792U
  193. #define DCC1_CNT1SEED_CONFIGVALUE 495000U
  194. #define DCC1_CLKSRC1_CONFIGVALUE (10U << 12U) | DCC1_CNT1_PLL1
  195. /*SAFETYMCUSW 79 S MR:19.4 <REVIEWED> "Macro filled using GUI parameter cannot be avoided" */
  196. #define DCC1_CLKSRC0_CONFIGVALUE DCC1_CNT0_OSCIN
  197. #define DCC2_GCTRL_CONFIGVALUE 0xAU | (0xAU << 4U) | (0x5U << 8U) | (0xAU << 12U)
  198. #define DCC2_CNT0SEED_CONFIGVALUE 0U
  199. #define DCC2_VALID0SEED_CONFIGVALUE 0U
  200. #define DCC2_CNT1SEED_CONFIGVALUE 0U
  201. #define DCC2_CLKSRC1_CONFIGVALUE (0x5U << 12U) | DCC2_CNT1_VCLK
  202. /*SAFETYMCUSW 79 S MR:19.4 <REVIEWED> "Macro filled using GUI parameter cannot be avoided" */
  203. #define DCC2_CLKSRC0_CONFIGVALUE DCC2_CNT0_OSCIN
  204. /**
  205. * @defgroup DCC DCC
  206. * @brief Dual-Clock Comparator Module
  207. *
  208. * The primary purpose of a DCC module is to measure the frequency of a clock signal using a second
  209. * known clock signal as a reference. This capability can be used to ensure the correct frequency range for
  210. * several different device clock sources, thereby enhancing the system safety metrics.
  211. *
  212. * Related Files
  213. * - reg_dcc.h
  214. * - dcc.h
  215. * - dcc.c
  216. * @addtogroup DCC
  217. * @{
  218. */
  219. /* DCC Interface Functions */
  220. void dccInit(void);
  221. void dccSetCounter0Seed(dccBASE_t *dcc, uint32 cnt0seed);
  222. void dccSetTolerance(dccBASE_t *dcc, uint32 valid0seed);
  223. void dccSetCounter1Seed(dccBASE_t *dcc, uint32 cnt1seed);
  224. void dccSetSeed(dccBASE_t *dcc, uint32 cnt0seed, uint32 valid0seed, uint32 cnt1seed);
  225. void dccSelectClockSource(dccBASE_t *dcc, uint32 cnt0_Clock_Source, uint32 cnt1_Clock_Source);
  226. void dccEnable(dccBASE_t *dcc);
  227. void dccDisable(dccBASE_t *dcc);
  228. uint32 dccGetErrStatus(dccBASE_t *dcc);
  229. void dccEnableNotification(dccBASE_t *dcc, uint32 notification);
  230. void dccDisableNotification(dccBASE_t *dcc, uint32 notification);
  231. void dcc1GetConfigValue(dcc_config_reg_t *config_reg, config_value_type_t type);
  232. void dcc2GetConfigValue(dcc_config_reg_t *config_reg, config_value_type_t type);
  233. /** @fn void dccNotification(dccBASE_t *dcc,uint32 flags)
  234. * @brief Interrupt callback
  235. * @param[in] dcc - dcc module base address
  236. * @param[in] flags - status flags
  237. *
  238. * This is a callback function provided by the application. It is call when
  239. * a dcc is complete or detected error.
  240. */
  241. void dccNotification(dccBASE_t *dcc,uint32 flags);
  242. /**@}*/
  243. #endif