gh_timer.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file gh_timer.h
  5. **
  6. ** \brief TIMER.
  7. **
  8. ** Copyright: 2012 - 2013 (C) GoKe Microelectronics ShangHai Branch
  9. **
  10. ** \attention THIS SAMPLE CODE IS PROVIDED AS IS. GOKE MICROELECTRONICS
  11. ** ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR
  12. ** OMMISSIONS.
  13. **
  14. ** \note Do not modify this file as it is generated automatically.
  15. **
  16. ******************************************************************************/
  17. #ifndef _GH_TIMER_H
  18. #define _GH_TIMER_H
  19. #ifdef __LINUX__
  20. #include "reg4linux.h"
  21. #else
  22. #define FIO_ADDRESS(block,address) (address)
  23. #define FIO_MOFFSET(block,moffset) (moffset)
  24. #endif
  25. #ifndef __LINUX__
  26. #include "gtypes.h" /* global type definitions */
  27. #include "gh_lib_cfg.h" /* configuration */
  28. #endif
  29. #define GH_TIMER_ENABLE_DEBUG_PRINT 0
  30. #ifdef __LINUX__
  31. #define GH_TIMER_DEBUG_PRINT_FUNCTION printk
  32. #else
  33. #define GH_TIMER_DEBUG_PRINT_FUNCTION printf
  34. #endif
  35. #ifndef __LINUX__
  36. #if GH_TIMER_ENABLE_DEBUG_PRINT
  37. #include <stdio.h>
  38. #endif
  39. #endif
  40. /* check configuration */
  41. #ifndef GH_INLINE_LEVEL
  42. #error "GH_INLINE_LEVEL is not defined!"
  43. #endif
  44. #if GH_INLINE_LEVEL > 2
  45. #error "GH_INLINE_LEVEL must be set 0, 1 or 2!"
  46. #endif
  47. #ifndef GH_INLINE
  48. #error "GH_INLINE is not defined!"
  49. #endif
  50. /* disable inlining for debugging */
  51. #ifdef DEBUG
  52. #undef GH_INLINE_LEVEL
  53. #define GH_INLINE_LEVEL 0
  54. #endif
  55. /*----------------------------------------------------------------------------*/
  56. /* registers */
  57. /*----------------------------------------------------------------------------*/
  58. #define REG_TIMER_T1CNTNSTS FIO_ADDRESS(TIMER,0xA0000000) /* read/write */
  59. #define REG_TIMER_T1MATCH1 FIO_ADDRESS(TIMER,0xA0000004) /* read/write */
  60. #define REG_TIMER_T1MATCH2 FIO_ADDRESS(TIMER,0xA0000008) /* read/write */
  61. #define REG_TIMER_CONTROL FIO_ADDRESS(TIMER,0xA000000C) /* read/write */
  62. #define REG_TIMER_T2CNTNSTS FIO_ADDRESS(TIMER,0xA0000014) /* read/write */
  63. #define REG_TIMER_T2MATCH1 FIO_ADDRESS(TIMER,0xA0000018) /* read/write */
  64. #define REG_TIMER_T2MATCH2 FIO_ADDRESS(TIMER,0xA000001C) /* read/write */
  65. #define REG_TIMER_T3CNTNSTS FIO_ADDRESS(TIMER,0xA0000020) /* read/write */
  66. #define REG_TIMER_T3MATCH1 FIO_ADDRESS(TIMER,0xA0000024) /* read/write */
  67. #define REG_TIMER_T3MATCH2 FIO_ADDRESS(TIMER,0xA0000028) /* read/write */
  68. #define REG_TIMER_T1RELOADN FIO_ADDRESS(TIMER,0xA0000030) /* read/write */
  69. #define REG_TIMER_T2RELOADN FIO_ADDRESS(TIMER,0xA0000034) /* read/write */
  70. #define REG_TIMER_T3RELOADN FIO_ADDRESS(TIMER,0xA0000038) /* read/write */
  71. /*----------------------------------------------------------------------------*/
  72. /* bit group structures */
  73. /*----------------------------------------------------------------------------*/
  74. typedef union { /* TIMER_Control */
  75. U32 all;
  76. struct {
  77. U32 clksel3 : 1;
  78. U32 clksel2 : 1;
  79. U32 clksel1 : 1;
  80. U32 : 1;
  81. U32 of3 : 1;
  82. U32 of2 : 1;
  83. U32 of1 : 1;
  84. U32 : 1;
  85. U32 enable3 : 1;
  86. U32 enable2 : 1;
  87. U32 enable1 : 1;
  88. U32 : 21;
  89. } bitc;
  90. } GH_TIMER_CONTROL_S;
  91. /*----------------------------------------------------------------------------*/
  92. /* mirror variables */
  93. /*----------------------------------------------------------------------------*/
  94. #ifdef __cplusplus
  95. extern "C" {
  96. #endif
  97. /*----------------------------------------------------------------------------*/
  98. /* register TIMER_T1CntnSts (read/write) */
  99. /*----------------------------------------------------------------------------*/
  100. #if GH_INLINE_LEVEL == 0
  101. /*! \brief Writes the register 'TIMER_T1CntnSts'. */
  102. void GH_TIMER_set_T1CntnSts(U32 data);
  103. /*! \brief Reads the register 'TIMER_T1CntnSts'. */
  104. U32 GH_TIMER_get_T1CntnSts(void);
  105. #else /* GH_INLINE_LEVEL == 0 */
  106. GH_INLINE void GH_TIMER_set_T1CntnSts(U32 data)
  107. {
  108. *(volatile U32 *)REG_TIMER_T1CNTNSTS = data;
  109. #if GH_TIMER_ENABLE_DEBUG_PRINT
  110. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T1CntnSts] <-- 0x%08x\n",
  111. REG_TIMER_T1CNTNSTS,data,data);
  112. #endif
  113. }
  114. GH_INLINE U32 GH_TIMER_get_T1CntnSts(void)
  115. {
  116. U32 value = (*(volatile U32 *)REG_TIMER_T1CNTNSTS);
  117. #if GH_TIMER_ENABLE_DEBUG_PRINT
  118. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T1CntnSts] --> 0x%08x\n",
  119. REG_TIMER_T1CNTNSTS,value);
  120. #endif
  121. return value;
  122. }
  123. #endif /* GH_INLINE_LEVEL == 0 */
  124. /*----------------------------------------------------------------------------*/
  125. /* register TIMER_T1Match1 (read/write) */
  126. /*----------------------------------------------------------------------------*/
  127. #if GH_INLINE_LEVEL == 0
  128. /*! \brief Writes the register 'TIMER_T1Match1'. */
  129. void GH_TIMER_set_T1Match1(U32 data);
  130. /*! \brief Reads the register 'TIMER_T1Match1'. */
  131. U32 GH_TIMER_get_T1Match1(void);
  132. #else /* GH_INLINE_LEVEL == 0 */
  133. GH_INLINE void GH_TIMER_set_T1Match1(U32 data)
  134. {
  135. *(volatile U32 *)REG_TIMER_T1MATCH1 = data;
  136. #if GH_TIMER_ENABLE_DEBUG_PRINT
  137. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T1Match1] <-- 0x%08x\n",
  138. REG_TIMER_T1MATCH1,data,data);
  139. #endif
  140. }
  141. GH_INLINE U32 GH_TIMER_get_T1Match1(void)
  142. {
  143. U32 value = (*(volatile U32 *)REG_TIMER_T1MATCH1);
  144. #if GH_TIMER_ENABLE_DEBUG_PRINT
  145. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T1Match1] --> 0x%08x\n",
  146. REG_TIMER_T1MATCH1,value);
  147. #endif
  148. return value;
  149. }
  150. #endif /* GH_INLINE_LEVEL == 0 */
  151. /*----------------------------------------------------------------------------*/
  152. /* register TIMER_T1Match2 (read/write) */
  153. /*----------------------------------------------------------------------------*/
  154. #if GH_INLINE_LEVEL == 0
  155. /*! \brief Writes the register 'TIMER_T1Match2'. */
  156. void GH_TIMER_set_T1Match2(U32 data);
  157. /*! \brief Reads the register 'TIMER_T1Match2'. */
  158. U32 GH_TIMER_get_T1Match2(void);
  159. #else /* GH_INLINE_LEVEL == 0 */
  160. GH_INLINE void GH_TIMER_set_T1Match2(U32 data)
  161. {
  162. *(volatile U32 *)REG_TIMER_T1MATCH2 = data;
  163. #if GH_TIMER_ENABLE_DEBUG_PRINT
  164. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T1Match2] <-- 0x%08x\n",
  165. REG_TIMER_T1MATCH2,data,data);
  166. #endif
  167. }
  168. GH_INLINE U32 GH_TIMER_get_T1Match2(void)
  169. {
  170. U32 value = (*(volatile U32 *)REG_TIMER_T1MATCH2);
  171. #if GH_TIMER_ENABLE_DEBUG_PRINT
  172. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T1Match2] --> 0x%08x\n",
  173. REG_TIMER_T1MATCH2,value);
  174. #endif
  175. return value;
  176. }
  177. #endif /* GH_INLINE_LEVEL == 0 */
  178. /*----------------------------------------------------------------------------*/
  179. /* register TIMER_Control (read/write) */
  180. /*----------------------------------------------------------------------------*/
  181. #if GH_INLINE_LEVEL == 0
  182. /*! \brief Writes the register 'TIMER_Control'. */
  183. void GH_TIMER_set_Control(U32 data);
  184. /*! \brief Reads the register 'TIMER_Control'. */
  185. U32 GH_TIMER_get_Control(void);
  186. /*! \brief Writes the bit group 'ClkSel3' of register 'TIMER_Control'. */
  187. void GH_TIMER_set_Control_ClkSel3(U8 data);
  188. /*! \brief Reads the bit group 'ClkSel3' of register 'TIMER_Control'. */
  189. U8 GH_TIMER_get_Control_ClkSel3(void);
  190. /*! \brief Writes the bit group 'ClkSel2' of register 'TIMER_Control'. */
  191. void GH_TIMER_set_Control_ClkSel2(U8 data);
  192. /*! \brief Reads the bit group 'ClkSel2' of register 'TIMER_Control'. */
  193. U8 GH_TIMER_get_Control_ClkSel2(void);
  194. /*! \brief Writes the bit group 'ClkSel1' of register 'TIMER_Control'. */
  195. void GH_TIMER_set_Control_ClkSel1(U8 data);
  196. /*! \brief Reads the bit group 'ClkSel1' of register 'TIMER_Control'. */
  197. U8 GH_TIMER_get_Control_ClkSel1(void);
  198. /*! \brief Writes the bit group 'OF3' of register 'TIMER_Control'. */
  199. void GH_TIMER_set_Control_OF3(U8 data);
  200. /*! \brief Reads the bit group 'OF3' of register 'TIMER_Control'. */
  201. U8 GH_TIMER_get_Control_OF3(void);
  202. /*! \brief Writes the bit group 'OF2' of register 'TIMER_Control'. */
  203. void GH_TIMER_set_Control_OF2(U8 data);
  204. /*! \brief Reads the bit group 'OF2' of register 'TIMER_Control'. */
  205. U8 GH_TIMER_get_Control_OF2(void);
  206. /*! \brief Writes the bit group 'OF1' of register 'TIMER_Control'. */
  207. void GH_TIMER_set_Control_OF1(U8 data);
  208. /*! \brief Reads the bit group 'OF1' of register 'TIMER_Control'. */
  209. U8 GH_TIMER_get_Control_OF1(void);
  210. /*! \brief Writes the bit group 'Enable3' of register 'TIMER_Control'. */
  211. void GH_TIMER_set_Control_Enable3(U8 data);
  212. /*! \brief Reads the bit group 'Enable3' of register 'TIMER_Control'. */
  213. U8 GH_TIMER_get_Control_Enable3(void);
  214. /*! \brief Writes the bit group 'Enable2' of register 'TIMER_Control'. */
  215. void GH_TIMER_set_Control_Enable2(U8 data);
  216. /*! \brief Reads the bit group 'Enable2' of register 'TIMER_Control'. */
  217. U8 GH_TIMER_get_Control_Enable2(void);
  218. /*! \brief Writes the bit group 'Enable1' of register 'TIMER_Control'. */
  219. void GH_TIMER_set_Control_Enable1(U8 data);
  220. /*! \brief Reads the bit group 'Enable1' of register 'TIMER_Control'. */
  221. U8 GH_TIMER_get_Control_Enable1(void);
  222. #else /* GH_INLINE_LEVEL == 0 */
  223. GH_INLINE void GH_TIMER_set_Control(U32 data)
  224. {
  225. *(volatile U32 *)REG_TIMER_CONTROL = data;
  226. #if GH_TIMER_ENABLE_DEBUG_PRINT
  227. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_Control] <-- 0x%08x\n",
  228. REG_TIMER_CONTROL,data,data);
  229. #endif
  230. }
  231. GH_INLINE U32 GH_TIMER_get_Control(void)
  232. {
  233. U32 value = (*(volatile U32 *)REG_TIMER_CONTROL);
  234. #if GH_TIMER_ENABLE_DEBUG_PRINT
  235. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_Control] --> 0x%08x\n",
  236. REG_TIMER_CONTROL,value);
  237. #endif
  238. return value;
  239. }
  240. GH_INLINE void GH_TIMER_set_Control_ClkSel3(U8 data)
  241. {
  242. GH_TIMER_CONTROL_S d;
  243. d.all = *(volatile U32 *)REG_TIMER_CONTROL;
  244. d.bitc.clksel3 = data;
  245. *(volatile U32 *)REG_TIMER_CONTROL = d.all;
  246. #if GH_TIMER_ENABLE_DEBUG_PRINT
  247. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_Control_ClkSel3] <-- 0x%08x\n",
  248. REG_TIMER_CONTROL,d.all,d.all);
  249. #endif
  250. }
  251. GH_INLINE U8 GH_TIMER_get_Control_ClkSel3(void)
  252. {
  253. GH_TIMER_CONTROL_S tmp_value;
  254. U32 value = (*(volatile U32 *)REG_TIMER_CONTROL);
  255. tmp_value.all = value;
  256. #if GH_TIMER_ENABLE_DEBUG_PRINT
  257. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_Control_ClkSel3] --> 0x%08x\n",
  258. REG_TIMER_CONTROL,value);
  259. #endif
  260. return tmp_value.bitc.clksel3;
  261. }
  262. GH_INLINE void GH_TIMER_set_Control_ClkSel2(U8 data)
  263. {
  264. GH_TIMER_CONTROL_S d;
  265. d.all = *(volatile U32 *)REG_TIMER_CONTROL;
  266. d.bitc.clksel2 = data;
  267. *(volatile U32 *)REG_TIMER_CONTROL = d.all;
  268. #if GH_TIMER_ENABLE_DEBUG_PRINT
  269. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_Control_ClkSel2] <-- 0x%08x\n",
  270. REG_TIMER_CONTROL,d.all,d.all);
  271. #endif
  272. }
  273. GH_INLINE U8 GH_TIMER_get_Control_ClkSel2(void)
  274. {
  275. GH_TIMER_CONTROL_S tmp_value;
  276. U32 value = (*(volatile U32 *)REG_TIMER_CONTROL);
  277. tmp_value.all = value;
  278. #if GH_TIMER_ENABLE_DEBUG_PRINT
  279. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_Control_ClkSel2] --> 0x%08x\n",
  280. REG_TIMER_CONTROL,value);
  281. #endif
  282. return tmp_value.bitc.clksel2;
  283. }
  284. GH_INLINE void GH_TIMER_set_Control_ClkSel1(U8 data)
  285. {
  286. GH_TIMER_CONTROL_S d;
  287. d.all = *(volatile U32 *)REG_TIMER_CONTROL;
  288. d.bitc.clksel1 = data;
  289. *(volatile U32 *)REG_TIMER_CONTROL = d.all;
  290. #if GH_TIMER_ENABLE_DEBUG_PRINT
  291. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_Control_ClkSel1] <-- 0x%08x\n",
  292. REG_TIMER_CONTROL,d.all,d.all);
  293. #endif
  294. }
  295. GH_INLINE U8 GH_TIMER_get_Control_ClkSel1(void)
  296. {
  297. GH_TIMER_CONTROL_S tmp_value;
  298. U32 value = (*(volatile U32 *)REG_TIMER_CONTROL);
  299. tmp_value.all = value;
  300. #if GH_TIMER_ENABLE_DEBUG_PRINT
  301. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_Control_ClkSel1] --> 0x%08x\n",
  302. REG_TIMER_CONTROL,value);
  303. #endif
  304. return tmp_value.bitc.clksel1;
  305. }
  306. GH_INLINE void GH_TIMER_set_Control_OF3(U8 data)
  307. {
  308. GH_TIMER_CONTROL_S d;
  309. d.all = *(volatile U32 *)REG_TIMER_CONTROL;
  310. d.bitc.of3 = data;
  311. *(volatile U32 *)REG_TIMER_CONTROL = d.all;
  312. #if GH_TIMER_ENABLE_DEBUG_PRINT
  313. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_Control_OF3] <-- 0x%08x\n",
  314. REG_TIMER_CONTROL,d.all,d.all);
  315. #endif
  316. }
  317. GH_INLINE U8 GH_TIMER_get_Control_OF3(void)
  318. {
  319. GH_TIMER_CONTROL_S tmp_value;
  320. U32 value = (*(volatile U32 *)REG_TIMER_CONTROL);
  321. tmp_value.all = value;
  322. #if GH_TIMER_ENABLE_DEBUG_PRINT
  323. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_Control_OF3] --> 0x%08x\n",
  324. REG_TIMER_CONTROL,value);
  325. #endif
  326. return tmp_value.bitc.of3;
  327. }
  328. GH_INLINE void GH_TIMER_set_Control_OF2(U8 data)
  329. {
  330. GH_TIMER_CONTROL_S d;
  331. d.all = *(volatile U32 *)REG_TIMER_CONTROL;
  332. d.bitc.of2 = data;
  333. *(volatile U32 *)REG_TIMER_CONTROL = d.all;
  334. #if GH_TIMER_ENABLE_DEBUG_PRINT
  335. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_Control_OF2] <-- 0x%08x\n",
  336. REG_TIMER_CONTROL,d.all,d.all);
  337. #endif
  338. }
  339. GH_INLINE U8 GH_TIMER_get_Control_OF2(void)
  340. {
  341. GH_TIMER_CONTROL_S tmp_value;
  342. U32 value = (*(volatile U32 *)REG_TIMER_CONTROL);
  343. tmp_value.all = value;
  344. #if GH_TIMER_ENABLE_DEBUG_PRINT
  345. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_Control_OF2] --> 0x%08x\n",
  346. REG_TIMER_CONTROL,value);
  347. #endif
  348. return tmp_value.bitc.of2;
  349. }
  350. GH_INLINE void GH_TIMER_set_Control_OF1(U8 data)
  351. {
  352. GH_TIMER_CONTROL_S d;
  353. d.all = *(volatile U32 *)REG_TIMER_CONTROL;
  354. d.bitc.of1 = data;
  355. *(volatile U32 *)REG_TIMER_CONTROL = d.all;
  356. #if GH_TIMER_ENABLE_DEBUG_PRINT
  357. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_Control_OF1] <-- 0x%08x\n",
  358. REG_TIMER_CONTROL,d.all,d.all);
  359. #endif
  360. }
  361. GH_INLINE U8 GH_TIMER_get_Control_OF1(void)
  362. {
  363. GH_TIMER_CONTROL_S tmp_value;
  364. U32 value = (*(volatile U32 *)REG_TIMER_CONTROL);
  365. tmp_value.all = value;
  366. #if GH_TIMER_ENABLE_DEBUG_PRINT
  367. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_Control_OF1] --> 0x%08x\n",
  368. REG_TIMER_CONTROL,value);
  369. #endif
  370. return tmp_value.bitc.of1;
  371. }
  372. GH_INLINE void GH_TIMER_set_Control_Enable3(U8 data)
  373. {
  374. GH_TIMER_CONTROL_S d;
  375. d.all = *(volatile U32 *)REG_TIMER_CONTROL;
  376. d.bitc.enable3 = data;
  377. *(volatile U32 *)REG_TIMER_CONTROL = d.all;
  378. #if GH_TIMER_ENABLE_DEBUG_PRINT
  379. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_Control_Enable3] <-- 0x%08x\n",
  380. REG_TIMER_CONTROL,d.all,d.all);
  381. #endif
  382. }
  383. GH_INLINE U8 GH_TIMER_get_Control_Enable3(void)
  384. {
  385. GH_TIMER_CONTROL_S tmp_value;
  386. U32 value = (*(volatile U32 *)REG_TIMER_CONTROL);
  387. tmp_value.all = value;
  388. #if GH_TIMER_ENABLE_DEBUG_PRINT
  389. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_Control_Enable3] --> 0x%08x\n",
  390. REG_TIMER_CONTROL,value);
  391. #endif
  392. return tmp_value.bitc.enable3;
  393. }
  394. GH_INLINE void GH_TIMER_set_Control_Enable2(U8 data)
  395. {
  396. GH_TIMER_CONTROL_S d;
  397. d.all = *(volatile U32 *)REG_TIMER_CONTROL;
  398. d.bitc.enable2 = data;
  399. *(volatile U32 *)REG_TIMER_CONTROL = d.all;
  400. #if GH_TIMER_ENABLE_DEBUG_PRINT
  401. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_Control_Enable2] <-- 0x%08x\n",
  402. REG_TIMER_CONTROL,d.all,d.all);
  403. #endif
  404. }
  405. GH_INLINE U8 GH_TIMER_get_Control_Enable2(void)
  406. {
  407. GH_TIMER_CONTROL_S tmp_value;
  408. U32 value = (*(volatile U32 *)REG_TIMER_CONTROL);
  409. tmp_value.all = value;
  410. #if GH_TIMER_ENABLE_DEBUG_PRINT
  411. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_Control_Enable2] --> 0x%08x\n",
  412. REG_TIMER_CONTROL,value);
  413. #endif
  414. return tmp_value.bitc.enable2;
  415. }
  416. GH_INLINE void GH_TIMER_set_Control_Enable1(U8 data)
  417. {
  418. GH_TIMER_CONTROL_S d;
  419. d.all = *(volatile U32 *)REG_TIMER_CONTROL;
  420. d.bitc.enable1 = data;
  421. *(volatile U32 *)REG_TIMER_CONTROL = d.all;
  422. #if GH_TIMER_ENABLE_DEBUG_PRINT
  423. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_Control_Enable1] <-- 0x%08x\n",
  424. REG_TIMER_CONTROL,d.all,d.all);
  425. #endif
  426. }
  427. GH_INLINE U8 GH_TIMER_get_Control_Enable1(void)
  428. {
  429. GH_TIMER_CONTROL_S tmp_value;
  430. U32 value = (*(volatile U32 *)REG_TIMER_CONTROL);
  431. tmp_value.all = value;
  432. #if GH_TIMER_ENABLE_DEBUG_PRINT
  433. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_Control_Enable1] --> 0x%08x\n",
  434. REG_TIMER_CONTROL,value);
  435. #endif
  436. return tmp_value.bitc.enable1;
  437. }
  438. #endif /* GH_INLINE_LEVEL == 0 */
  439. /*----------------------------------------------------------------------------*/
  440. /* register TIMER_T2CntnSts (read/write) */
  441. /*----------------------------------------------------------------------------*/
  442. #if GH_INLINE_LEVEL == 0
  443. /*! \brief Writes the register 'TIMER_T2CntnSts'. */
  444. void GH_TIMER_set_T2CntnSts(U32 data);
  445. /*! \brief Reads the register 'TIMER_T2CntnSts'. */
  446. U32 GH_TIMER_get_T2CntnSts(void);
  447. #else /* GH_INLINE_LEVEL == 0 */
  448. GH_INLINE void GH_TIMER_set_T2CntnSts(U32 data)
  449. {
  450. *(volatile U32 *)REG_TIMER_T2CNTNSTS = data;
  451. #if GH_TIMER_ENABLE_DEBUG_PRINT
  452. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T2CntnSts] <-- 0x%08x\n",
  453. REG_TIMER_T2CNTNSTS,data,data);
  454. #endif
  455. }
  456. GH_INLINE U32 GH_TIMER_get_T2CntnSts(void)
  457. {
  458. U32 value = (*(volatile U32 *)REG_TIMER_T2CNTNSTS);
  459. #if GH_TIMER_ENABLE_DEBUG_PRINT
  460. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T2CntnSts] --> 0x%08x\n",
  461. REG_TIMER_T2CNTNSTS,value);
  462. #endif
  463. return value;
  464. }
  465. #endif /* GH_INLINE_LEVEL == 0 */
  466. /*----------------------------------------------------------------------------*/
  467. /* register TIMER_T2Match1 (read/write) */
  468. /*----------------------------------------------------------------------------*/
  469. #if GH_INLINE_LEVEL == 0
  470. /*! \brief Writes the register 'TIMER_T2Match1'. */
  471. void GH_TIMER_set_T2Match1(U32 data);
  472. /*! \brief Reads the register 'TIMER_T2Match1'. */
  473. U32 GH_TIMER_get_T2Match1(void);
  474. #else /* GH_INLINE_LEVEL == 0 */
  475. GH_INLINE void GH_TIMER_set_T2Match1(U32 data)
  476. {
  477. *(volatile U32 *)REG_TIMER_T2MATCH1 = data;
  478. #if GH_TIMER_ENABLE_DEBUG_PRINT
  479. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T2Match1] <-- 0x%08x\n",
  480. REG_TIMER_T2MATCH1,data,data);
  481. #endif
  482. }
  483. GH_INLINE U32 GH_TIMER_get_T2Match1(void)
  484. {
  485. U32 value = (*(volatile U32 *)REG_TIMER_T2MATCH1);
  486. #if GH_TIMER_ENABLE_DEBUG_PRINT
  487. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T2Match1] --> 0x%08x\n",
  488. REG_TIMER_T2MATCH1,value);
  489. #endif
  490. return value;
  491. }
  492. #endif /* GH_INLINE_LEVEL == 0 */
  493. /*----------------------------------------------------------------------------*/
  494. /* register TIMER_T2Match2 (read/write) */
  495. /*----------------------------------------------------------------------------*/
  496. #if GH_INLINE_LEVEL == 0
  497. /*! \brief Writes the register 'TIMER_T2Match2'. */
  498. void GH_TIMER_set_T2Match2(U32 data);
  499. /*! \brief Reads the register 'TIMER_T2Match2'. */
  500. U32 GH_TIMER_get_T2Match2(void);
  501. #else /* GH_INLINE_LEVEL == 0 */
  502. GH_INLINE void GH_TIMER_set_T2Match2(U32 data)
  503. {
  504. *(volatile U32 *)REG_TIMER_T2MATCH2 = data;
  505. #if GH_TIMER_ENABLE_DEBUG_PRINT
  506. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T2Match2] <-- 0x%08x\n",
  507. REG_TIMER_T2MATCH2,data,data);
  508. #endif
  509. }
  510. GH_INLINE U32 GH_TIMER_get_T2Match2(void)
  511. {
  512. U32 value = (*(volatile U32 *)REG_TIMER_T2MATCH2);
  513. #if GH_TIMER_ENABLE_DEBUG_PRINT
  514. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T2Match2] --> 0x%08x\n",
  515. REG_TIMER_T2MATCH2,value);
  516. #endif
  517. return value;
  518. }
  519. #endif /* GH_INLINE_LEVEL == 0 */
  520. /*----------------------------------------------------------------------------*/
  521. /* register TIMER_T3CntnSts (read/write) */
  522. /*----------------------------------------------------------------------------*/
  523. #if GH_INLINE_LEVEL == 0
  524. /*! \brief Writes the register 'TIMER_T3CntnSts'. */
  525. void GH_TIMER_set_T3CntnSts(U32 data);
  526. /*! \brief Reads the register 'TIMER_T3CntnSts'. */
  527. U32 GH_TIMER_get_T3CntnSts(void);
  528. #else /* GH_INLINE_LEVEL == 0 */
  529. GH_INLINE void GH_TIMER_set_T3CntnSts(U32 data)
  530. {
  531. *(volatile U32 *)REG_TIMER_T3CNTNSTS = data;
  532. #if GH_TIMER_ENABLE_DEBUG_PRINT
  533. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T3CntnSts] <-- 0x%08x\n",
  534. REG_TIMER_T3CNTNSTS,data,data);
  535. #endif
  536. }
  537. GH_INLINE U32 GH_TIMER_get_T3CntnSts(void)
  538. {
  539. U32 value = (*(volatile U32 *)REG_TIMER_T3CNTNSTS);
  540. #if GH_TIMER_ENABLE_DEBUG_PRINT
  541. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T3CntnSts] --> 0x%08x\n",
  542. REG_TIMER_T3CNTNSTS,value);
  543. #endif
  544. return value;
  545. }
  546. #endif /* GH_INLINE_LEVEL == 0 */
  547. /*----------------------------------------------------------------------------*/
  548. /* register TIMER_T3Match1 (read/write) */
  549. /*----------------------------------------------------------------------------*/
  550. #if GH_INLINE_LEVEL == 0
  551. /*! \brief Writes the register 'TIMER_T3Match1'. */
  552. void GH_TIMER_set_T3Match1(U32 data);
  553. /*! \brief Reads the register 'TIMER_T3Match1'. */
  554. U32 GH_TIMER_get_T3Match1(void);
  555. #else /* GH_INLINE_LEVEL == 0 */
  556. GH_INLINE void GH_TIMER_set_T3Match1(U32 data)
  557. {
  558. *(volatile U32 *)REG_TIMER_T3MATCH1 = data;
  559. #if GH_TIMER_ENABLE_DEBUG_PRINT
  560. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T3Match1] <-- 0x%08x\n",
  561. REG_TIMER_T3MATCH1,data,data);
  562. #endif
  563. }
  564. GH_INLINE U32 GH_TIMER_get_T3Match1(void)
  565. {
  566. U32 value = (*(volatile U32 *)REG_TIMER_T3MATCH1);
  567. #if GH_TIMER_ENABLE_DEBUG_PRINT
  568. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T3Match1] --> 0x%08x\n",
  569. REG_TIMER_T3MATCH1,value);
  570. #endif
  571. return value;
  572. }
  573. #endif /* GH_INLINE_LEVEL == 0 */
  574. /*----------------------------------------------------------------------------*/
  575. /* register TIMER_T3Match2 (read/write) */
  576. /*----------------------------------------------------------------------------*/
  577. #if GH_INLINE_LEVEL == 0
  578. /*! \brief Writes the register 'TIMER_T3Match2'. */
  579. void GH_TIMER_set_T3Match2(U32 data);
  580. /*! \brief Reads the register 'TIMER_T3Match2'. */
  581. U32 GH_TIMER_get_T3Match2(void);
  582. #else /* GH_INLINE_LEVEL == 0 */
  583. GH_INLINE void GH_TIMER_set_T3Match2(U32 data)
  584. {
  585. *(volatile U32 *)REG_TIMER_T3MATCH2 = data;
  586. #if GH_TIMER_ENABLE_DEBUG_PRINT
  587. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T3Match2] <-- 0x%08x\n",
  588. REG_TIMER_T3MATCH2,data,data);
  589. #endif
  590. }
  591. GH_INLINE U32 GH_TIMER_get_T3Match2(void)
  592. {
  593. U32 value = (*(volatile U32 *)REG_TIMER_T3MATCH2);
  594. #if GH_TIMER_ENABLE_DEBUG_PRINT
  595. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T3Match2] --> 0x%08x\n",
  596. REG_TIMER_T3MATCH2,value);
  597. #endif
  598. return value;
  599. }
  600. #endif /* GH_INLINE_LEVEL == 0 */
  601. /*----------------------------------------------------------------------------*/
  602. /* register TIMER_T1Reloadn (read/write) */
  603. /*----------------------------------------------------------------------------*/
  604. #if GH_INLINE_LEVEL == 0
  605. /*! \brief Writes the register 'TIMER_T1Reloadn'. */
  606. void GH_TIMER_set_T1Reloadn(U32 data);
  607. /*! \brief Reads the register 'TIMER_T1Reloadn'. */
  608. U32 GH_TIMER_get_T1Reloadn(void);
  609. #else /* GH_INLINE_LEVEL == 0 */
  610. GH_INLINE void GH_TIMER_set_T1Reloadn(U32 data)
  611. {
  612. *(volatile U32 *)REG_TIMER_T1RELOADN = data;
  613. #if GH_TIMER_ENABLE_DEBUG_PRINT
  614. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T1Reloadn] <-- 0x%08x\n",
  615. REG_TIMER_T1RELOADN,data,data);
  616. #endif
  617. }
  618. GH_INLINE U32 GH_TIMER_get_T1Reloadn(void)
  619. {
  620. U32 value = (*(volatile U32 *)REG_TIMER_T1RELOADN);
  621. #if GH_TIMER_ENABLE_DEBUG_PRINT
  622. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T1Reloadn] --> 0x%08x\n",
  623. REG_TIMER_T1RELOADN,value);
  624. #endif
  625. return value;
  626. }
  627. #endif /* GH_INLINE_LEVEL == 0 */
  628. /*----------------------------------------------------------------------------*/
  629. /* register TIMER_T2Reloadn (read/write) */
  630. /*----------------------------------------------------------------------------*/
  631. #if GH_INLINE_LEVEL == 0
  632. /*! \brief Writes the register 'TIMER_T2Reloadn'. */
  633. void GH_TIMER_set_T2Reloadn(U32 data);
  634. /*! \brief Reads the register 'TIMER_T2Reloadn'. */
  635. U32 GH_TIMER_get_T2Reloadn(void);
  636. #else /* GH_INLINE_LEVEL == 0 */
  637. GH_INLINE void GH_TIMER_set_T2Reloadn(U32 data)
  638. {
  639. *(volatile U32 *)REG_TIMER_T2RELOADN = data;
  640. #if GH_TIMER_ENABLE_DEBUG_PRINT
  641. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T2Reloadn] <-- 0x%08x\n",
  642. REG_TIMER_T2RELOADN,data,data);
  643. #endif
  644. }
  645. GH_INLINE U32 GH_TIMER_get_T2Reloadn(void)
  646. {
  647. U32 value = (*(volatile U32 *)REG_TIMER_T2RELOADN);
  648. #if GH_TIMER_ENABLE_DEBUG_PRINT
  649. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T2Reloadn] --> 0x%08x\n",
  650. REG_TIMER_T2RELOADN,value);
  651. #endif
  652. return value;
  653. }
  654. #endif /* GH_INLINE_LEVEL == 0 */
  655. /*----------------------------------------------------------------------------*/
  656. /* register TIMER_T3Reloadn (read/write) */
  657. /*----------------------------------------------------------------------------*/
  658. #if GH_INLINE_LEVEL == 0
  659. /*! \brief Writes the register 'TIMER_T3Reloadn'. */
  660. void GH_TIMER_set_T3Reloadn(U32 data);
  661. /*! \brief Reads the register 'TIMER_T3Reloadn'. */
  662. U32 GH_TIMER_get_T3Reloadn(void);
  663. #else /* GH_INLINE_LEVEL == 0 */
  664. GH_INLINE void GH_TIMER_set_T3Reloadn(U32 data)
  665. {
  666. *(volatile U32 *)REG_TIMER_T3RELOADN = data;
  667. #if GH_TIMER_ENABLE_DEBUG_PRINT
  668. GH_TIMER_DEBUG_PRINT_FUNCTION( "WRREG(0x%08x,0x%08x); \\\\ [GH_TIMER_set_T3Reloadn] <-- 0x%08x\n",
  669. REG_TIMER_T3RELOADN,data,data);
  670. #endif
  671. }
  672. GH_INLINE U32 GH_TIMER_get_T3Reloadn(void)
  673. {
  674. U32 value = (*(volatile U32 *)REG_TIMER_T3RELOADN);
  675. #if GH_TIMER_ENABLE_DEBUG_PRINT
  676. GH_TIMER_DEBUG_PRINT_FUNCTION( "value = RDREG(0x%08x); \\\\ [GH_TIMER_get_T3Reloadn] --> 0x%08x\n",
  677. REG_TIMER_T3RELOADN,value);
  678. #endif
  679. return value;
  680. }
  681. #endif /* GH_INLINE_LEVEL == 0 */
  682. /*----------------------------------------------------------------------------*/
  683. /* init function */
  684. /*----------------------------------------------------------------------------*/
  685. /*! \brief Initialises the registers and mirror variables. */
  686. void GH_TIMER_init(void);
  687. #ifdef __cplusplus
  688. }
  689. #endif
  690. #endif /* _GH_TIMER_H */
  691. /*----------------------------------------------------------------------------*/
  692. /* end of file */
  693. /*----------------------------------------------------------------------------*/