hw_qei.h 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. //*****************************************************************************
  2. //
  3. // hw_qei.h - Macros used when accessing the QEI hardware.
  4. //
  5. // Copyright (c) 2005-2009 Luminary Micro, Inc. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
  9. // exclusively on LMI's microcontroller products.
  10. //
  11. // The software is owned by LMI and/or its suppliers, and is protected under
  12. // applicable copyright laws. All rights are reserved. You may not combine
  13. // this software with "viral" open-source software in order to form a larger
  14. // program. Any use in violation of the foregoing restrictions may subject
  15. // the user to criminal sanctions under applicable laws, as well as to civil
  16. // liability for the breach of the terms and conditions of this license.
  17. //
  18. // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
  19. // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  20. // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
  21. // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
  22. // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
  23. //
  24. // This is part of revision 4694 of the Stellaris Firmware Development Package.
  25. //
  26. //*****************************************************************************
  27. #ifndef __HW_QEI_H__
  28. #define __HW_QEI_H__
  29. //*****************************************************************************
  30. //
  31. // The following are defines for the QEI register offsets.
  32. //
  33. //*****************************************************************************
  34. #define QEI_O_CTL 0x00000000 // Configuration and control reg.
  35. #define QEI_O_STAT 0x00000004 // Status register
  36. #define QEI_O_POS 0x00000008 // Current position register
  37. #define QEI_O_MAXPOS 0x0000000C // Maximum position register
  38. #define QEI_O_LOAD 0x00000010 // Velocity timer load register
  39. #define QEI_O_TIME 0x00000014 // Velocity timer register
  40. #define QEI_O_COUNT 0x00000018 // Velocity pulse count register
  41. #define QEI_O_SPEED 0x0000001C // Velocity speed register
  42. #define QEI_O_INTEN 0x00000020 // Interrupt enable register
  43. #define QEI_O_RIS 0x00000024 // Raw interrupt status register
  44. #define QEI_O_ISC 0x00000028 // Interrupt status register
  45. //*****************************************************************************
  46. //
  47. // The following are defines for the bit fields in the QEI_CTL register.
  48. //
  49. //*****************************************************************************
  50. #define QEI_CTL_FILTCNT_M 0x000F0000 // Input Filter Pre-Scale Count.
  51. #define QEI_CTL_FILTEN 0x00002000 // Enable Input Filter.
  52. #define QEI_CTL_STALLEN 0x00001000 // Stall enable
  53. #define QEI_CTL_INVI 0x00000800 // Invert Index input
  54. #define QEI_CTL_INVB 0x00000400 // Invert PhB input
  55. #define QEI_CTL_INVA 0x00000200 // Invert PhA input
  56. #define QEI_CTL_VELDIV_M 0x000001C0 // Velocity predivider mask
  57. #define QEI_CTL_VELDIV_1 0x00000000 // Predivide by 1
  58. #define QEI_CTL_VELDIV_2 0x00000040 // Predivide by 2
  59. #define QEI_CTL_VELDIV_4 0x00000080 // Predivide by 4
  60. #define QEI_CTL_VELDIV_8 0x000000C0 // Predivide by 8
  61. #define QEI_CTL_VELDIV_16 0x00000100 // Predivide by 16
  62. #define QEI_CTL_VELDIV_32 0x00000140 // Predivide by 32
  63. #define QEI_CTL_VELDIV_64 0x00000180 // Predivide by 64
  64. #define QEI_CTL_VELDIV_128 0x000001C0 // Predivide by 128
  65. #define QEI_CTL_VELEN 0x00000020 // Velocity enable
  66. #define QEI_CTL_RESMODE 0x00000010 // Position counter reset mode
  67. #define QEI_CTL_CAPMODE 0x00000008 // Edge capture mode
  68. #define QEI_CTL_SIGMODE 0x00000004 // Encoder signaling mode
  69. #define QEI_CTL_SWAP 0x00000002 // Swap input signals
  70. #define QEI_CTL_ENABLE 0x00000001 // QEI enable
  71. #define QEI_CTL_FILTCNT_S 16
  72. //*****************************************************************************
  73. //
  74. // The following are defines for the bit fields in the QEI_STAT register.
  75. //
  76. //*****************************************************************************
  77. #define QEI_STAT_DIRECTION 0x00000002 // Direction of rotation
  78. #define QEI_STAT_ERROR 0x00000001 // Signalling error detected
  79. //*****************************************************************************
  80. //
  81. // The following are defines for the bit fields in the QEI_POS register.
  82. //
  83. //*****************************************************************************
  84. #define QEI_POS_M 0xFFFFFFFF // Current encoder position
  85. #define QEI_POS_S 0
  86. //*****************************************************************************
  87. //
  88. // The following are defines for the bit fields in the QEI_MAXPOS register.
  89. //
  90. //*****************************************************************************
  91. #define QEI_MAXPOS_M 0xFFFFFFFF // Maximum encoder position
  92. #define QEI_MAXPOS_S 0
  93. //*****************************************************************************
  94. //
  95. // The following are defines for the bit fields in the QEI_LOAD register.
  96. //
  97. //*****************************************************************************
  98. #define QEI_LOAD_M 0xFFFFFFFF // Velocity timer load value
  99. #define QEI_LOAD_S 0
  100. //*****************************************************************************
  101. //
  102. // The following are defines for the bit fields in the QEI_TIME register.
  103. //
  104. //*****************************************************************************
  105. #define QEI_TIME_M 0xFFFFFFFF // Velocity timer current value
  106. #define QEI_TIME_S 0
  107. //*****************************************************************************
  108. //
  109. // The following are defines for the bit fields in the QEI_COUNT register.
  110. //
  111. //*****************************************************************************
  112. #define QEI_COUNT_M 0xFFFFFFFF // Encoder running pulse count
  113. #define QEI_COUNT_S 0
  114. //*****************************************************************************
  115. //
  116. // The following are defines for the bit fields in the QEI_SPEED register.
  117. //
  118. //*****************************************************************************
  119. #define QEI_SPEED_M 0xFFFFFFFF // Encoder pulse count
  120. #define QEI_SPEED_S 0
  121. //*****************************************************************************
  122. //
  123. // The following are defines for the bit fields in the QEI_INTEN register.
  124. //
  125. //*****************************************************************************
  126. #define QEI_INTEN_ERROR 0x00000008 // Phase error detected
  127. #define QEI_INTEN_DIR 0x00000004 // Direction change
  128. #define QEI_INTEN_TIMER 0x00000002 // Velocity timer expired
  129. #define QEI_INTEN_INDEX 0x00000001 // Index pulse detected
  130. //*****************************************************************************
  131. //
  132. // The following are defines for the bit fields in the QEI_RIS register.
  133. //
  134. //*****************************************************************************
  135. #define QEI_RIS_ERROR 0x00000008 // Phase error detected
  136. #define QEI_RIS_DIR 0x00000004 // Direction change
  137. #define QEI_RIS_TIMER 0x00000002 // Velocity timer expired
  138. #define QEI_RIS_INDEX 0x00000001 // Index pulse detected
  139. //*****************************************************************************
  140. //
  141. // The following are defines for the bit fields in the QEI_O_ISC register.
  142. //
  143. //*****************************************************************************
  144. #define QEI_ISC_ERROR 0x00000008 // Phase Error Interrupt.
  145. #define QEI_ISC_DIR 0x00000004 // Direction Change Interrupt.
  146. #define QEI_ISC_TIMER 0x00000002 // Velocity Timer Expired
  147. // 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__