gh_timer.h 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file gh_timer.h
  5. **
  6. ** \brief TIMER.
  7. **
  8. ** Copyright: 2012 - 2016 (C) GoKe Microelectronics
  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. /*----------------------------------------------------------------------------*/
  41. /* registers */
  42. /*----------------------------------------------------------------------------*/
  43. #define REG_TIMER_CNTNSTS FIO_ADDRESS(TIMER,0xa000B000) /* read/write */
  44. #define REG_TIMER_RELOADN FIO_ADDRESS(TIMER,0xa000B004) /* read/write */
  45. #define REG_TIMER_MATCH1 FIO_ADDRESS(TIMER,0xa000B008) /* read/write */
  46. #define REG_TIMER_MATCH2 FIO_ADDRESS(TIMER,0xa000B00C) /* read/write */
  47. #define REG_TIMER_CONTROL FIO_ADDRESS(TIMER,0xa000B030) /* read/write */
  48. /*----------------------------------------------------------------------------*/
  49. /* bit group structures */
  50. /*----------------------------------------------------------------------------*/
  51. typedef union { /* TIMER_Control */
  52. U32 all;
  53. struct {
  54. U32 enable1 : 1;
  55. U32 clksel1 : 1;
  56. U32 of1 : 1;
  57. U32 : 1;
  58. U32 enable2 : 1;
  59. U32 clksel2 : 1;
  60. U32 of2 : 1;
  61. U32 : 1;
  62. U32 enable3 : 1;
  63. U32 clksel3 : 1;
  64. U32 of3 : 1;
  65. U32 : 21;
  66. } bitc;
  67. } GH_TIMER_CONTROL_S;
  68. /*----------------------------------------------------------------------------*/
  69. /* mirror variables */
  70. /*----------------------------------------------------------------------------*/
  71. #ifdef __cplusplus
  72. extern "C" {
  73. #endif
  74. /*----------------------------------------------------------------------------*/
  75. /* register TIMER_CntnSts (read/write) */
  76. /*----------------------------------------------------------------------------*/
  77. /*! \brief Writes the register 'TIMER_CntnSts'. */
  78. void GH_TIMER_set_CntnSts(U8 index, U32 data);
  79. /*! \brief Reads the register 'TIMER_CntnSts'. */
  80. U32 GH_TIMER_get_CntnSts(U8 index);
  81. /*----------------------------------------------------------------------------*/
  82. /* register TIMER_Reloadn (read/write) */
  83. /*----------------------------------------------------------------------------*/
  84. /*! \brief Writes the register 'TIMER_Reloadn'. */
  85. void GH_TIMER_set_Reloadn(U8 index, U32 data);
  86. /*! \brief Reads the register 'TIMER_Reloadn'. */
  87. U32 GH_TIMER_get_Reloadn(U8 index);
  88. /*----------------------------------------------------------------------------*/
  89. /* register TIMER_Match1 (read/write) */
  90. /*----------------------------------------------------------------------------*/
  91. /*! \brief Writes the register 'TIMER_Match1'. */
  92. void GH_TIMER_set_Match1(U8 index, U32 data);
  93. /*! \brief Reads the register 'TIMER_Match1'. */
  94. U32 GH_TIMER_get_Match1(U8 index);
  95. /*----------------------------------------------------------------------------*/
  96. /* register TIMER_Match2 (read/write) */
  97. /*----------------------------------------------------------------------------*/
  98. /*! \brief Writes the register 'TIMER_Match2'. */
  99. void GH_TIMER_set_Match2(U8 index, U32 data);
  100. /*! \brief Reads the register 'TIMER_Match2'. */
  101. U32 GH_TIMER_get_Match2(U8 index);
  102. /*----------------------------------------------------------------------------*/
  103. /* register TIMER_Control (read/write) */
  104. /*----------------------------------------------------------------------------*/
  105. /*! \brief Writes the register 'TIMER_Control'. */
  106. void GH_TIMER_set_Control(U32 data);
  107. /*! \brief Reads the register 'TIMER_Control'. */
  108. U32 GH_TIMER_get_Control(void);
  109. /*! \brief Writes the bit group 'Enable1' of register 'TIMER_Control'. */
  110. void GH_TIMER_set_Control_Enable1(U8 data);
  111. /*! \brief Reads the bit group 'Enable1' of register 'TIMER_Control'. */
  112. U8 GH_TIMER_get_Control_Enable1(void);
  113. /*! \brief Writes the bit group 'ClkSel1' of register 'TIMER_Control'. */
  114. void GH_TIMER_set_Control_ClkSel1(U8 data);
  115. /*! \brief Reads the bit group 'ClkSel1' of register 'TIMER_Control'. */
  116. U8 GH_TIMER_get_Control_ClkSel1(void);
  117. /*! \brief Writes the bit group 'OF1' of register 'TIMER_Control'. */
  118. void GH_TIMER_set_Control_OF1(U8 data);
  119. /*! \brief Reads the bit group 'OF1' of register 'TIMER_Control'. */
  120. U8 GH_TIMER_get_Control_OF1(void);
  121. /*! \brief Writes the bit group 'Enable2' of register 'TIMER_Control'. */
  122. void GH_TIMER_set_Control_Enable2(U8 data);
  123. /*! \brief Reads the bit group 'Enable2' of register 'TIMER_Control'. */
  124. U8 GH_TIMER_get_Control_Enable2(void);
  125. /*! \brief Writes the bit group 'ClkSel2' of register 'TIMER_Control'. */
  126. void GH_TIMER_set_Control_ClkSel2(U8 data);
  127. /*! \brief Reads the bit group 'ClkSel2' of register 'TIMER_Control'. */
  128. U8 GH_TIMER_get_Control_ClkSel2(void);
  129. /*! \brief Writes the bit group 'OF2' of register 'TIMER_Control'. */
  130. void GH_TIMER_set_Control_OF2(U8 data);
  131. /*! \brief Reads the bit group 'OF2' of register 'TIMER_Control'. */
  132. U8 GH_TIMER_get_Control_OF2(void);
  133. /*! \brief Writes the bit group 'Enable3' of register 'TIMER_Control'. */
  134. void GH_TIMER_set_Control_Enable3(U8 data);
  135. /*! \brief Reads the bit group 'Enable3' of register 'TIMER_Control'. */
  136. U8 GH_TIMER_get_Control_Enable3(void);
  137. /*! \brief Writes the bit group 'ClkSel3' of register 'TIMER_Control'. */
  138. void GH_TIMER_set_Control_ClkSel3(U8 data);
  139. /*! \brief Reads the bit group 'ClkSel3' of register 'TIMER_Control'. */
  140. U8 GH_TIMER_get_Control_ClkSel3(void);
  141. /*! \brief Writes the bit group 'OF3' of register 'TIMER_Control'. */
  142. void GH_TIMER_set_Control_OF3(U8 data);
  143. /*! \brief Reads the bit group 'OF3' of register 'TIMER_Control'. */
  144. U8 GH_TIMER_get_Control_OF3(void);
  145. /*----------------------------------------------------------------------------*/
  146. /* init function */
  147. /*----------------------------------------------------------------------------*/
  148. /*! \brief Initialises the registers and mirror variables. */
  149. void GH_TIMER_init(void);
  150. #ifdef SRC_INLINE
  151. #define SRC_INC 1
  152. #include "gh_timer.c"
  153. #undef SRC_INC
  154. #endif
  155. #ifdef __cplusplus
  156. }
  157. #endif
  158. #endif /* _GH_TIMER_H */
  159. /*----------------------------------------------------------------------------*/
  160. /* end of file */
  161. /*----------------------------------------------------------------------------*/