hw_qei.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. //*****************************************************************************
  2. //
  3. // hw_qei.h - Macros used when accessing the QEI hardware.
  4. //
  5. // Copyright (c) 2005-2011 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Texas Instruments (TI) is supplying this software for use solely and
  9. // exclusively on TI's microcontroller products. The software is owned by
  10. // TI and/or its suppliers, and is protected under applicable copyright
  11. // laws. You may not combine this software with "viral" open-source
  12. // software in order to form a larger program.
  13. //
  14. // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
  15. // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
  16. // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  17. // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
  18. // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
  19. // DAMAGES, FOR ANY REASON WHATSOEVER.
  20. //
  21. // This is part of revision 8264 of the Stellaris Firmware Development Package.
  22. //
  23. //*****************************************************************************
  24. #ifndef __HW_QEI_H__
  25. #define __HW_QEI_H__
  26. //*****************************************************************************
  27. //
  28. // The following are defines for the QEI register offsets.
  29. //
  30. //*****************************************************************************
  31. #define QEI_O_CTL 0x00000000 // QEI Control
  32. #define QEI_O_STAT 0x00000004 // QEI Status
  33. #define QEI_O_POS 0x00000008 // QEI Position
  34. #define QEI_O_MAXPOS 0x0000000C // QEI Maximum Position
  35. #define QEI_O_LOAD 0x00000010 // QEI Timer Load
  36. #define QEI_O_TIME 0x00000014 // QEI Timer
  37. #define QEI_O_COUNT 0x00000018 // QEI Velocity Counter
  38. #define QEI_O_SPEED 0x0000001C // QEI Velocity
  39. #define QEI_O_INTEN 0x00000020 // QEI Interrupt Enable
  40. #define QEI_O_RIS 0x00000024 // QEI Raw Interrupt Status
  41. #define QEI_O_ISC 0x00000028 // QEI Interrupt Status and Clear
  42. //*****************************************************************************
  43. //
  44. // The following are defines for the bit fields in the QEI_O_CTL register.
  45. //
  46. //*****************************************************************************
  47. #define QEI_CTL_FILTCNT_M 0x000F0000 // Input Filter Prescale Count
  48. #define QEI_CTL_FILTEN 0x00002000 // Enable Input Filter
  49. #define QEI_CTL_STALLEN 0x00001000 // Stall QEI
  50. #define QEI_CTL_INVI 0x00000800 // Invert Index Pulse
  51. #define QEI_CTL_INVB 0x00000400 // Invert PhB
  52. #define QEI_CTL_INVA 0x00000200 // Invert PhA
  53. #define QEI_CTL_VELDIV_M 0x000001C0 // Predivide Velocity
  54. #define QEI_CTL_VELDIV_1 0x00000000 // QEI clock /1
  55. #define QEI_CTL_VELDIV_2 0x00000040 // QEI clock /2
  56. #define QEI_CTL_VELDIV_4 0x00000080 // QEI clock /4
  57. #define QEI_CTL_VELDIV_8 0x000000C0 // QEI clock /8
  58. #define QEI_CTL_VELDIV_16 0x00000100 // QEI clock /16
  59. #define QEI_CTL_VELDIV_32 0x00000140 // QEI clock /32
  60. #define QEI_CTL_VELDIV_64 0x00000180 // QEI clock /64
  61. #define QEI_CTL_VELDIV_128 0x000001C0 // QEI clock /128
  62. #define QEI_CTL_VELEN 0x00000020 // Capture Velocity
  63. #define QEI_CTL_RESMODE 0x00000010 // Reset Mode
  64. #define QEI_CTL_CAPMODE 0x00000008 // Capture Mode
  65. #define QEI_CTL_SIGMODE 0x00000004 // Signal Mode
  66. #define QEI_CTL_SWAP 0x00000002 // Swap Signals
  67. #define QEI_CTL_ENABLE 0x00000001 // Enable QEI
  68. #define QEI_CTL_FILTCNT_S 16
  69. //*****************************************************************************
  70. //
  71. // The following are defines for the bit fields in the QEI_O_STAT register.
  72. //
  73. //*****************************************************************************
  74. #define QEI_STAT_DIRECTION 0x00000002 // Direction of Rotation
  75. #define QEI_STAT_ERROR 0x00000001 // Error Detected
  76. //*****************************************************************************
  77. //
  78. // The following are defines for the bit fields in the QEI_O_POS register.
  79. //
  80. //*****************************************************************************
  81. #define QEI_POS_M 0xFFFFFFFF // Current Position Integrator
  82. // Value
  83. #define QEI_POS_S 0
  84. //*****************************************************************************
  85. //
  86. // The following are defines for the bit fields in the QEI_O_MAXPOS register.
  87. //
  88. //*****************************************************************************
  89. #define QEI_MAXPOS_M 0xFFFFFFFF // Maximum Position Integrator
  90. // Value
  91. #define QEI_MAXPOS_S 0
  92. //*****************************************************************************
  93. //
  94. // The following are defines for the bit fields in the QEI_O_LOAD register.
  95. //
  96. //*****************************************************************************
  97. #define QEI_LOAD_M 0xFFFFFFFF // Velocity Timer Load Value
  98. #define QEI_LOAD_S 0
  99. //*****************************************************************************
  100. //
  101. // The following are defines for the bit fields in the QEI_O_TIME register.
  102. //
  103. //*****************************************************************************
  104. #define QEI_TIME_M 0xFFFFFFFF // Velocity Timer Current Value
  105. #define QEI_TIME_S 0
  106. //*****************************************************************************
  107. //
  108. // The following are defines for the bit fields in the QEI_O_COUNT register.
  109. //
  110. //*****************************************************************************
  111. #define QEI_COUNT_M 0xFFFFFFFF // Velocity Pulse Count
  112. #define QEI_COUNT_S 0
  113. //*****************************************************************************
  114. //
  115. // The following are defines for the bit fields in the QEI_O_SPEED register.
  116. //
  117. //*****************************************************************************
  118. #define QEI_SPEED_M 0xFFFFFFFF // Velocity
  119. #define QEI_SPEED_S 0
  120. //*****************************************************************************
  121. //
  122. // The following are defines for the bit fields in the QEI_O_INTEN register.
  123. //
  124. //*****************************************************************************
  125. #define QEI_INTEN_ERROR 0x00000008 // Phase Error Interrupt Enable
  126. #define QEI_INTEN_DIR 0x00000004 // Direction Change Interrupt
  127. // Enable
  128. #define QEI_INTEN_TIMER 0x00000002 // Timer Expires Interrupt Enable
  129. #define QEI_INTEN_INDEX 0x00000001 // Index Pulse Detected Interrupt
  130. // Enable
  131. //*****************************************************************************
  132. //
  133. // The following are defines for the bit fields in the QEI_O_RIS register.
  134. //
  135. //*****************************************************************************
  136. #define QEI_RIS_ERROR 0x00000008 // Phase Error Detected
  137. #define QEI_RIS_DIR 0x00000004 // Direction Change Detected
  138. #define QEI_RIS_TIMER 0x00000002 // Velocity Timer Expired
  139. #define QEI_RIS_INDEX 0x00000001 // Index Pulse Asserted
  140. //*****************************************************************************
  141. //
  142. // The following are defines for the bit fields in the QEI_O_ISC register.
  143. //
  144. //*****************************************************************************
  145. #define QEI_ISC_ERROR 0x00000008 // Phase Error Interrupt
  146. #define QEI_ISC_DIR 0x00000004 // Direction Change Interrupt
  147. #define QEI_ISC_TIMER 0x00000002 // Velocity Timer Expired Interrupt
  148. #define QEI_ISC_INDEX 0x00000001 // Index Pulse Interrupt
  149. //*****************************************************************************
  150. //
  151. // The following definitions are deprecated.
  152. //
  153. //*****************************************************************************
  154. #ifndef DEPRECATED
  155. //*****************************************************************************
  156. //
  157. // The following are deprecated defines for the bit fields in the QEI_ISC
  158. // register.
  159. //
  160. //*****************************************************************************
  161. #define QEI_INT_ERROR 0x00000008 // Phase error detected
  162. #define QEI_INT_DIR 0x00000004 // Direction change
  163. #define QEI_INT_TIMER 0x00000002 // Velocity timer expired
  164. #define QEI_INT_INDEX 0x00000001 // Index pulse detected
  165. //*****************************************************************************
  166. //
  167. // The following are deprecated defines for the reset values for the QEI
  168. // registers.
  169. //
  170. //*****************************************************************************
  171. #define QEI_RV_POS 0x00000000 // Current position register
  172. #define QEI_RV_LOAD 0x00000000 // Velocity timer load register
  173. #define QEI_RV_CTL 0x00000000 // Configuration and control reg
  174. #define QEI_RV_RIS 0x00000000 // Raw interrupt status register
  175. #define QEI_RV_ISC 0x00000000 // Interrupt status register
  176. #define QEI_RV_SPEED 0x00000000 // Velocity speed register
  177. #define QEI_RV_INTEN 0x00000000 // Interrupt enable register
  178. #define QEI_RV_STAT 0x00000000 // Status register
  179. #define QEI_RV_COUNT 0x00000000 // Velocity pulse count register
  180. #define QEI_RV_MAXPOS 0x00000000 // Maximum position register
  181. #define QEI_RV_TIME 0x00000000 // Velocity timer register
  182. #endif
  183. #endif // __HW_QEI_H__