gh_pwm.h 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. /*!
  2. *******************************************************************************
  3. **
  4. ** \file gh_pwm.h
  5. **
  6. ** \brief Pulse Width Modulator.
  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_PWM_H
  18. #define _GH_PWM_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_PWM_ENABLE_DEBUG_PRINT 0
  30. #ifdef __LINUX__
  31. #define GH_PWM_DEBUG_PRINT_FUNCTION printk
  32. #else
  33. #define GH_PWM_DEBUG_PRINT_FUNCTION printf
  34. #endif
  35. #ifndef __LINUX__
  36. #if GH_PWM_ENABLE_DEBUG_PRINT
  37. #include <stdio.h>
  38. #endif
  39. #endif
  40. /*----------------------------------------------------------------------------*/
  41. /* bit group structures */
  42. /*----------------------------------------------------------------------------*/
  43. typedef union { /* PWM_Control */
  44. U32 all;
  45. struct {
  46. U32 xon : 16;
  47. U32 xoff : 16;
  48. } bitc;
  49. } GH_PWM_CONTROL_S;
  50. typedef union { /* PWM_Enable */
  51. U32 all;
  52. struct {
  53. U32 enb : 1;
  54. U32 : 31;
  55. } bitc;
  56. } GH_PWM_ENABLE_S;
  57. typedef union { /* PWM_Mode */
  58. U32 all;
  59. struct {
  60. U32 divider : 10;
  61. U32 mode : 1;
  62. U32 : 21;
  63. } bitc;
  64. } GH_PWM_MODE_S;
  65. typedef union { /* PWM_Control1 */
  66. U32 all;
  67. struct {
  68. U32 xon : 16;
  69. U32 xoff : 16;
  70. } bitc;
  71. } GH_PWM_CONTROL1_S;
  72. /*----------------------------------------------------------------------------*/
  73. /* mirror variables */
  74. /*----------------------------------------------------------------------------*/
  75. #ifdef __cplusplus
  76. extern "C" {
  77. #endif
  78. /*----------------------------------------------------------------------------*/
  79. /* register PWM_Control (read/write) */
  80. /*----------------------------------------------------------------------------*/
  81. /*! \brief Writes the register 'PWM_Control'. */
  82. void GH_PWM_set_Control(U8 index, U32 data);
  83. /*! \brief Reads the register 'PWM_Control'. */
  84. U32 GH_PWM_get_Control(U8 index);
  85. /*! \brief Writes the bit group 'xoff' of register 'PWM_Control'. */
  86. void GH_PWM_set_Control_xoff(U8 index, U16 data);
  87. /*! \brief Reads the bit group 'xoff' of register 'PWM_Control'. */
  88. U16 GH_PWM_get_Control_xoff(U8 index);
  89. /*! \brief Writes the bit group 'xon' of register 'PWM_Control'. */
  90. void GH_PWM_set_Control_xon(U8 index, U16 data);
  91. /*! \brief Reads the bit group 'xon' of register 'PWM_Control'. */
  92. U16 GH_PWM_get_Control_xon(U8 index);
  93. /*----------------------------------------------------------------------------*/
  94. /* register PWM_Enable (read/write) */
  95. /*----------------------------------------------------------------------------*/
  96. /*! \brief Writes the register 'PWM_Enable'. */
  97. void GH_PWM_set_Enable(U8 index, U32 data);
  98. /*! \brief Reads the register 'PWM_Enable'. */
  99. U32 GH_PWM_get_Enable(U8 index);
  100. /*! \brief Writes the bit group 'enb' of register 'PWM_Enable'. */
  101. void GH_PWM_set_Enable_enb(U8 index, U8 data);
  102. /*! \brief Reads the bit group 'enb' of register 'PWM_Enable'. */
  103. U8 GH_PWM_get_Enable_enb(U8 index);
  104. /*----------------------------------------------------------------------------*/
  105. /* register PWM_Mode (read/write) */
  106. /*----------------------------------------------------------------------------*/
  107. /*! \brief Writes the register 'PWM_Mode'. */
  108. void GH_PWM_set_Mode(U8 index, U32 data);
  109. /*! \brief Reads the register 'PWM_Mode'. */
  110. U32 GH_PWM_get_Mode(U8 index);
  111. /*! \brief Writes the bit group 'mode' of register 'PWM_Mode'. */
  112. void GH_PWM_set_Mode_mode(U8 index, U8 data);
  113. /*! \brief Reads the bit group 'mode' of register 'PWM_Mode'. */
  114. U8 GH_PWM_get_Mode_mode(U8 index);
  115. /*! \brief Writes the bit group 'divider' of register 'PWM_Mode'. */
  116. void GH_PWM_set_Mode_divider(U8 index, U16 data);
  117. /*! \brief Reads the bit group 'divider' of register 'PWM_Mode'. */
  118. U16 GH_PWM_get_Mode_divider(U8 index);
  119. /*----------------------------------------------------------------------------*/
  120. /* register PWM_Control1 (read/write) */
  121. /*----------------------------------------------------------------------------*/
  122. /*! \brief Writes the register 'PWM_Control1'. */
  123. void GH_PWM_set_Control1(U8 index, U32 data);
  124. /*! \brief Reads the register 'PWM_Control1'. */
  125. U32 GH_PWM_get_Control1(U8 index);
  126. /*! \brief Writes the bit group 'xoff' of register 'PWM_Control1'. */
  127. void GH_PWM_set_Control1_xoff(U8 index, U16 data);
  128. /*! \brief Reads the bit group 'xoff' of register 'PWM_Control1'. */
  129. U16 GH_PWM_get_Control1_xoff(U8 index);
  130. /*! \brief Writes the bit group 'xon' of register 'PWM_Control1'. */
  131. void GH_PWM_set_Control1_xon(U8 index, U16 data);
  132. /*! \brief Reads the bit group 'xon' of register 'PWM_Control1'. */
  133. U16 GH_PWM_get_Control1_xon(U8 index);
  134. /*----------------------------------------------------------------------------*/
  135. /* init function */
  136. /*----------------------------------------------------------------------------*/
  137. /*! \brief Initialises the registers and mirror variables. */
  138. void GH_PWM_init(void);
  139. #ifdef SRC_INLINE
  140. #define SRC_INC 1
  141. #include "gh_pwm.c"
  142. #undef SRC_INC
  143. #endif
  144. #ifdef __cplusplus
  145. }
  146. #endif
  147. #endif /* _GH_PWM_H */
  148. /*----------------------------------------------------------------------------*/
  149. /* end of file */
  150. /*----------------------------------------------------------------------------*/