1
0

hw_qei.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. //*****************************************************************************
  2. //
  3. // hw_qei.h - Macros used when accessing the QEI hardware.
  4. //
  5. // Copyright (c) 2005-2014 Texas Instruments Incorporated. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Redistribution and use in source and binary forms, with or without
  9. // modification, are permitted provided that the following conditions
  10. // are met:
  11. //
  12. // Redistributions of source code must retain the above copyright
  13. // notice, this list of conditions and the following disclaimer.
  14. //
  15. // Redistributions in binary form must reproduce the above copyright
  16. // notice, this list of conditions and the following disclaimer in the
  17. // documentation and/or other materials provided with the
  18. // distribution.
  19. //
  20. // Neither the name of Texas Instruments Incorporated nor the names of
  21. // its contributors may be used to endorse or promote products derived
  22. // from this software without specific prior written permission.
  23. //
  24. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  25. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  26. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  27. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  28. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  29. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  30. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  31. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  32. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  33. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  34. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. // This is part of revision 2.1.0.12573 of the Tiva Firmware Development Package.
  37. //
  38. //*****************************************************************************
  39. #ifndef __HW_QEI_H__
  40. #define __HW_QEI_H__
  41. //*****************************************************************************
  42. //
  43. // The following are defines for the QEI register offsets.
  44. //
  45. //*****************************************************************************
  46. #define QEI_O_CTL 0x00000000 // QEI Control
  47. #define QEI_O_STAT 0x00000004 // QEI Status
  48. #define QEI_O_POS 0x00000008 // QEI Position
  49. #define QEI_O_MAXPOS 0x0000000C // QEI Maximum Position
  50. #define QEI_O_LOAD 0x00000010 // QEI Timer Load
  51. #define QEI_O_TIME 0x00000014 // QEI Timer
  52. #define QEI_O_COUNT 0x00000018 // QEI Velocity Counter
  53. #define QEI_O_SPEED 0x0000001C // QEI Velocity
  54. #define QEI_O_INTEN 0x00000020 // QEI Interrupt Enable
  55. #define QEI_O_RIS 0x00000024 // QEI Raw Interrupt Status
  56. #define QEI_O_ISC 0x00000028 // QEI Interrupt Status and Clear
  57. //*****************************************************************************
  58. //
  59. // The following are defines for the bit fields in the QEI_O_CTL register.
  60. //
  61. //*****************************************************************************
  62. #define QEI_CTL_FILTCNT_M 0x000F0000 // Input Filter Prescale Count
  63. #define QEI_CTL_FILTEN 0x00002000 // Enable Input Filter
  64. #define QEI_CTL_STALLEN 0x00001000 // Stall QEI
  65. #define QEI_CTL_INVI 0x00000800 // Invert Index Pulse
  66. #define QEI_CTL_INVB 0x00000400 // Invert PhB
  67. #define QEI_CTL_INVA 0x00000200 // Invert PhA
  68. #define QEI_CTL_VELDIV_M 0x000001C0 // Predivide Velocity
  69. #define QEI_CTL_VELDIV_1 0x00000000 // QEI clock /1
  70. #define QEI_CTL_VELDIV_2 0x00000040 // QEI clock /2
  71. #define QEI_CTL_VELDIV_4 0x00000080 // QEI clock /4
  72. #define QEI_CTL_VELDIV_8 0x000000C0 // QEI clock /8
  73. #define QEI_CTL_VELDIV_16 0x00000100 // QEI clock /16
  74. #define QEI_CTL_VELDIV_32 0x00000140 // QEI clock /32
  75. #define QEI_CTL_VELDIV_64 0x00000180 // QEI clock /64
  76. #define QEI_CTL_VELDIV_128 0x000001C0 // QEI clock /128
  77. #define QEI_CTL_VELEN 0x00000020 // Capture Velocity
  78. #define QEI_CTL_RESMODE 0x00000010 // Reset Mode
  79. #define QEI_CTL_CAPMODE 0x00000008 // Capture Mode
  80. #define QEI_CTL_SIGMODE 0x00000004 // Signal Mode
  81. #define QEI_CTL_SWAP 0x00000002 // Swap Signals
  82. #define QEI_CTL_ENABLE 0x00000001 // Enable QEI
  83. #define QEI_CTL_FILTCNT_S 16
  84. //*****************************************************************************
  85. //
  86. // The following are defines for the bit fields in the QEI_O_STAT register.
  87. //
  88. //*****************************************************************************
  89. #define QEI_STAT_DIRECTION 0x00000002 // Direction of Rotation
  90. #define QEI_STAT_ERROR 0x00000001 // Error Detected
  91. //*****************************************************************************
  92. //
  93. // The following are defines for the bit fields in the QEI_O_POS register.
  94. //
  95. //*****************************************************************************
  96. #define QEI_POS_M 0xFFFFFFFF // Current Position Integrator
  97. // Value
  98. #define QEI_POS_S 0
  99. //*****************************************************************************
  100. //
  101. // The following are defines for the bit fields in the QEI_O_MAXPOS register.
  102. //
  103. //*****************************************************************************
  104. #define QEI_MAXPOS_M 0xFFFFFFFF // Maximum Position Integrator
  105. // Value
  106. #define QEI_MAXPOS_S 0
  107. //*****************************************************************************
  108. //
  109. // The following are defines for the bit fields in the QEI_O_LOAD register.
  110. //
  111. //*****************************************************************************
  112. #define QEI_LOAD_M 0xFFFFFFFF // Velocity Timer Load Value
  113. #define QEI_LOAD_S 0
  114. //*****************************************************************************
  115. //
  116. // The following are defines for the bit fields in the QEI_O_TIME register.
  117. //
  118. //*****************************************************************************
  119. #define QEI_TIME_M 0xFFFFFFFF // Velocity Timer Current Value
  120. #define QEI_TIME_S 0
  121. //*****************************************************************************
  122. //
  123. // The following are defines for the bit fields in the QEI_O_COUNT register.
  124. //
  125. //*****************************************************************************
  126. #define QEI_COUNT_M 0xFFFFFFFF // Velocity Pulse Count
  127. #define QEI_COUNT_S 0
  128. //*****************************************************************************
  129. //
  130. // The following are defines for the bit fields in the QEI_O_SPEED register.
  131. //
  132. //*****************************************************************************
  133. #define QEI_SPEED_M 0xFFFFFFFF // Velocity
  134. #define QEI_SPEED_S 0
  135. //*****************************************************************************
  136. //
  137. // The following are defines for the bit fields in the QEI_O_INTEN register.
  138. //
  139. //*****************************************************************************
  140. #define QEI_INTEN_ERROR 0x00000008 // Phase Error Interrupt Enable
  141. #define QEI_INTEN_DIR 0x00000004 // Direction Change Interrupt
  142. // Enable
  143. #define QEI_INTEN_TIMER 0x00000002 // Timer Expires Interrupt Enable
  144. #define QEI_INTEN_INDEX 0x00000001 // Index Pulse Detected Interrupt
  145. // Enable
  146. //*****************************************************************************
  147. //
  148. // The following are defines for the bit fields in the QEI_O_RIS register.
  149. //
  150. //*****************************************************************************
  151. #define QEI_RIS_ERROR 0x00000008 // Phase Error Detected
  152. #define QEI_RIS_DIR 0x00000004 // Direction Change Detected
  153. #define QEI_RIS_TIMER 0x00000002 // Velocity Timer Expired
  154. #define QEI_RIS_INDEX 0x00000001 // Index Pulse Asserted
  155. //*****************************************************************************
  156. //
  157. // The following are defines for the bit fields in the QEI_O_ISC register.
  158. //
  159. //*****************************************************************************
  160. #define QEI_ISC_ERROR 0x00000008 // Phase Error Interrupt
  161. #define QEI_ISC_DIR 0x00000004 // Direction Change Interrupt
  162. #define QEI_ISC_TIMER 0x00000002 // Velocity Timer Expired Interrupt
  163. #define QEI_ISC_INDEX 0x00000001 // Index Pulse Interrupt
  164. #endif // __HW_QEI_H__