F2837xD_eqep.h 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. //###########################################################################
  2. //
  3. // FILE: F2837xD_eqep.h
  4. //
  5. // TITLE: EQEP Register Definitions.
  6. //
  7. //###########################################################################
  8. // $TI Release: F2837xD Support Library v3.05.00.00 $
  9. // $Release Date: Tue Jun 26 03:15:23 CDT 2018 $
  10. // $Copyright:
  11. // Copyright (C) 2013-2018 Texas Instruments Incorporated - http://www.ti.com/
  12. //
  13. // Redistribution and use in source and binary forms, with or without
  14. // modification, are permitted provided that the following conditions
  15. // are met:
  16. //
  17. // Redistributions of source code must retain the above copyright
  18. // notice, this list of conditions and the following disclaimer.
  19. //
  20. // Redistributions in binary form must reproduce the above copyright
  21. // notice, this list of conditions and the following disclaimer in the
  22. // documentation and/or other materials provided with the
  23. // distribution.
  24. //
  25. // Neither the name of Texas Instruments Incorporated nor the names of
  26. // its contributors may be used to endorse or promote products derived
  27. // from this software without specific prior written permission.
  28. //
  29. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  30. // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  31. // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  32. // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  33. // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  34. // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  35. // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  36. // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  37. // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  38. // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  39. // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  40. // $
  41. //###########################################################################
  42. #ifndef __F2837xD_EQEP_H__
  43. #define __F2837xD_EQEP_H__
  44. #ifdef __cplusplus
  45. extern "C" {
  46. #endif
  47. //---------------------------------------------------------------------------
  48. // EQEP Individual Register Bit Definitions:
  49. struct QDECCTL_BITS { // bits description
  50. Uint16 rsvd1:5; // 4:0 Reserved
  51. Uint16 QSP:1; // 5 QEPS input polarity
  52. Uint16 QIP:1; // 6 QEPI input polarity
  53. Uint16 QBP:1; // 7 QEPB input polarity
  54. Uint16 QAP:1; // 8 QEPA input polarity
  55. Uint16 IGATE:1; // 9 Index pulse gating option
  56. Uint16 SWAP:1; // 10 CLK/DIR Signal Source for Position Counter
  57. Uint16 XCR:1; // 11 External Clock Rate
  58. Uint16 SPSEL:1; // 12 Sync output pin selection
  59. Uint16 SOEN:1; // 13 Sync output-enable
  60. Uint16 QSRC:2; // 15:14 Position-counter source selection
  61. };
  62. union QDECCTL_REG {
  63. Uint16 all;
  64. struct QDECCTL_BITS bit;
  65. };
  66. struct QEPCTL_BITS { // bits description
  67. Uint16 WDE:1; // 0 QEP watchdog enable
  68. Uint16 UTE:1; // 1 QEP unit timer enable
  69. Uint16 QCLM:1; // 2 QEP capture latch mode
  70. Uint16 QPEN:1; // 3 Quadrature postotion counter enable
  71. Uint16 IEL:2; // 5:4 Index event latch
  72. Uint16 SEL:1; // 6 Strobe event latch
  73. Uint16 SWI:1; // 7 Software init position counter
  74. Uint16 IEI:2; // 9:8 Index event init of position count
  75. Uint16 SEI:2; // 11:10 Strobe event init
  76. Uint16 PCRM:2; // 13:12 Postion counter reset
  77. Uint16 FREE_SOFT:2; // 15:14 Emulation mode
  78. };
  79. union QEPCTL_REG {
  80. Uint16 all;
  81. struct QEPCTL_BITS bit;
  82. };
  83. struct QCAPCTL_BITS { // bits description
  84. Uint16 UPPS:4; // 3:0 Unit position event prescaler
  85. Uint16 CCPS:3; // 6:4 eQEP capture timer clock prescaler
  86. Uint16 rsvd1:8; // 14:7 Reserved
  87. Uint16 CEN:1; // 15 Enable eQEP capture
  88. };
  89. union QCAPCTL_REG {
  90. Uint16 all;
  91. struct QCAPCTL_BITS bit;
  92. };
  93. struct QPOSCTL_BITS { // bits description
  94. Uint16 PCSPW:12; // 11:0 Position compare sync pulse width
  95. Uint16 PCE:1; // 12 Position compare enable/disable
  96. Uint16 PCPOL:1; // 13 Polarity of sync output
  97. Uint16 PCLOAD:1; // 14 Position compare of shadow load
  98. Uint16 PCSHDW:1; // 15 Position compare of shadow enable
  99. };
  100. union QPOSCTL_REG {
  101. Uint16 all;
  102. struct QPOSCTL_BITS bit;
  103. };
  104. struct QEINT_BITS { // bits description
  105. Uint16 rsvd1:1; // 0 Reserved
  106. Uint16 PCE:1; // 1 Position counter error interrupt enable
  107. Uint16 QPE:1; // 2 Quadrature phase error interrupt enable
  108. Uint16 QDC:1; // 3 Quadrature direction change interrupt enable
  109. Uint16 WTO:1; // 4 Watchdog time out interrupt enable
  110. Uint16 PCU:1; // 5 Position counter underflow interrupt enable
  111. Uint16 PCO:1; // 6 Position counter overflow interrupt enable
  112. Uint16 PCR:1; // 7 Position-compare ready interrupt enable
  113. Uint16 PCM:1; // 8 Position-compare match interrupt enable
  114. Uint16 SEL:1; // 9 Strobe event latch interrupt enable
  115. Uint16 IEL:1; // 10 Index event latch interrupt enable
  116. Uint16 UTO:1; // 11 Unit time out interrupt enable
  117. Uint16 rsvd2:4; // 15:12 Reserved
  118. };
  119. union QEINT_REG {
  120. Uint16 all;
  121. struct QEINT_BITS bit;
  122. };
  123. struct QFLG_BITS { // bits description
  124. Uint16 INT:1; // 0 Global interrupt status flag
  125. Uint16 PCE:1; // 1 Position counter error interrupt flag
  126. Uint16 PHE:1; // 2 Quadrature phase error interrupt flag
  127. Uint16 QDC:1; // 3 Quadrature direction change interrupt flag
  128. Uint16 WTO:1; // 4 Watchdog timeout interrupt flag
  129. Uint16 PCU:1; // 5 Position counter underflow interrupt flag
  130. Uint16 PCO:1; // 6 Position counter overflow interrupt flag
  131. Uint16 PCR:1; // 7 Position-compare ready interrupt flag
  132. Uint16 PCM:1; // 8 eQEP compare match event interrupt flag
  133. Uint16 SEL:1; // 9 Strobe event latch interrupt flag
  134. Uint16 IEL:1; // 10 Index event latch interrupt flag
  135. Uint16 UTO:1; // 11 Unit time out interrupt flag
  136. Uint16 rsvd1:4; // 15:12 Reserved
  137. };
  138. union QFLG_REG {
  139. Uint16 all;
  140. struct QFLG_BITS bit;
  141. };
  142. struct QCLR_BITS { // bits description
  143. Uint16 INT:1; // 0 Global interrupt clear flag
  144. Uint16 PCE:1; // 1 Clear position counter error interrupt flag
  145. Uint16 PHE:1; // 2 Clear quadrature phase error interrupt flag
  146. Uint16 QDC:1; // 3 Clear quadrature direction change interrupt flag
  147. Uint16 WTO:1; // 4 Clear watchdog timeout interrupt flag
  148. Uint16 PCU:1; // 5 Clear position counter underflow interrupt flag
  149. Uint16 PCO:1; // 6 Clear position counter overflow interrupt flag
  150. Uint16 PCR:1; // 7 Clear position-compare ready interrupt flag
  151. Uint16 PCM:1; // 8 Clear eQEP compare match event interrupt flag
  152. Uint16 SEL:1; // 9 Clear strobe event latch interrupt flag
  153. Uint16 IEL:1; // 10 Clear index event latch interrupt flag
  154. Uint16 UTO:1; // 11 Clear unit time out interrupt flag
  155. Uint16 rsvd1:4; // 15:12 Reserved
  156. };
  157. union QCLR_REG {
  158. Uint16 all;
  159. struct QCLR_BITS bit;
  160. };
  161. struct QFRC_BITS { // bits description
  162. Uint16 rsvd1:1; // 0 Reserved
  163. Uint16 PCE:1; // 1 Force position counter error interrupt
  164. Uint16 PHE:1; // 2 Force quadrature phase error interrupt
  165. Uint16 QDC:1; // 3 Force quadrature direction change interrupt
  166. Uint16 WTO:1; // 4 Force watchdog time out interrupt
  167. Uint16 PCU:1; // 5 Force position counter underflow interrupt
  168. Uint16 PCO:1; // 6 Force position counter overflow interrupt
  169. Uint16 PCR:1; // 7 Force position-compare ready interrupt
  170. Uint16 PCM:1; // 8 Force position-compare match interrupt
  171. Uint16 SEL:1; // 9 Force strobe event latch interrupt
  172. Uint16 IEL:1; // 10 Force index event latch interrupt
  173. Uint16 UTO:1; // 11 Force unit time out interrupt
  174. Uint16 rsvd2:4; // 15:12 Reserved
  175. };
  176. union QFRC_REG {
  177. Uint16 all;
  178. struct QFRC_BITS bit;
  179. };
  180. struct QEPSTS_BITS { // bits description
  181. Uint16 PCEF:1; // 0 Position counter error flag.
  182. Uint16 FIMF:1; // 1 First index marker flag
  183. Uint16 CDEF:1; // 2 Capture direction error flag
  184. Uint16 COEF:1; // 3 Capture overflow error flag
  185. Uint16 QDLF:1; // 4 eQEP direction latch flag
  186. Uint16 QDF:1; // 5 Quadrature direction flag
  187. Uint16 FIDF:1; // 6 The first index marker
  188. Uint16 UPEVNT:1; // 7 Unit position event flag
  189. Uint16 rsvd1:8; // 15:8 Reserved
  190. };
  191. union QEPSTS_REG {
  192. Uint16 all;
  193. struct QEPSTS_BITS bit;
  194. };
  195. struct EQEP_REGS {
  196. Uint32 QPOSCNT; // Position Counter
  197. Uint32 QPOSINIT; // Position Counter Init
  198. Uint32 QPOSMAX; // Maximum Position Count
  199. Uint32 QPOSCMP; // Position Compare
  200. Uint32 QPOSILAT; // Index Position Latch
  201. Uint32 QPOSSLAT; // Strobe Position Latch
  202. Uint32 QPOSLAT; // Position Latch
  203. Uint32 QUTMR; // QEP Unit Timer
  204. Uint32 QUPRD; // QEP Unit Period
  205. Uint16 QWDTMR; // QEP Watchdog Timer
  206. Uint16 QWDPRD; // QEP Watchdog Period
  207. union QDECCTL_REG QDECCTL; // Quadrature Decoder Control
  208. union QEPCTL_REG QEPCTL; // QEP Control
  209. union QCAPCTL_REG QCAPCTL; // Qaudrature Capture Control
  210. union QPOSCTL_REG QPOSCTL; // Position Compare Control
  211. union QEINT_REG QEINT; // QEP Interrupt Control
  212. union QFLG_REG QFLG; // QEP Interrupt Flag
  213. union QCLR_REG QCLR; // QEP Interrupt Clear
  214. union QFRC_REG QFRC; // QEP Interrupt Force
  215. union QEPSTS_REG QEPSTS; // QEP Status
  216. Uint16 QCTMR; // QEP Capture Timer
  217. Uint16 QCPRD; // QEP Capture Period
  218. Uint16 QCTMRLAT; // QEP Capture Latch
  219. Uint16 QCPRDLAT; // QEP Capture Period Latch
  220. Uint16 rsvd1; // Reserved
  221. };
  222. //---------------------------------------------------------------------------
  223. // EQEP External References & Function Declarations:
  224. //
  225. #ifdef CPU1
  226. extern volatile struct EQEP_REGS EQep1Regs;
  227. extern volatile struct EQEP_REGS EQep2Regs;
  228. extern volatile struct EQEP_REGS EQep3Regs;
  229. #endif
  230. #ifdef CPU2
  231. extern volatile struct EQEP_REGS EQep1Regs;
  232. extern volatile struct EQEP_REGS EQep2Regs;
  233. extern volatile struct EQEP_REGS EQep3Regs;
  234. #endif
  235. #ifdef __cplusplus
  236. }
  237. #endif /* extern "C" */
  238. #endif
  239. //===========================================================================
  240. // End of file.
  241. //===========================================================================