qei.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. //*****************************************************************************
  2. //
  3. // qei.h - Prototypes for the Quadrature Encoder Driver.
  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 Peripheral Driver Library.
  22. //
  23. //*****************************************************************************
  24. #ifndef __QEI_H__
  25. #define __QEI_H__
  26. //*****************************************************************************
  27. //
  28. // If building with a C++ compiler, make all of the definitions in this header
  29. // have a C binding.
  30. //
  31. //*****************************************************************************
  32. #ifdef __cplusplus
  33. extern "C"
  34. {
  35. #endif
  36. //*****************************************************************************
  37. //
  38. // Values that can be passed to QEIConfigure as the ulConfig paramater.
  39. //
  40. //*****************************************************************************
  41. #define QEI_CONFIG_CAPTURE_A 0x00000000 // Count on ChA edges only
  42. #define QEI_CONFIG_CAPTURE_A_B 0x00000008 // Count on ChA and ChB edges
  43. #define QEI_CONFIG_NO_RESET 0x00000000 // Do not reset on index pulse
  44. #define QEI_CONFIG_RESET_IDX 0x00000010 // Reset position on index pulse
  45. #define QEI_CONFIG_QUADRATURE 0x00000000 // ChA and ChB are quadrature
  46. #define QEI_CONFIG_CLOCK_DIR 0x00000004 // ChA and ChB are clock and dir
  47. #define QEI_CONFIG_NO_SWAP 0x00000000 // Do not swap ChA and ChB
  48. #define QEI_CONFIG_SWAP 0x00000002 // Swap ChA and ChB
  49. //*****************************************************************************
  50. //
  51. // Values that can be passed to QEIVelocityConfigure as the ulPreDiv parameter.
  52. //
  53. //*****************************************************************************
  54. #define QEI_VELDIV_1 0x00000000 // Predivide by 1
  55. #define QEI_VELDIV_2 0x00000040 // Predivide by 2
  56. #define QEI_VELDIV_4 0x00000080 // Predivide by 4
  57. #define QEI_VELDIV_8 0x000000C0 // Predivide by 8
  58. #define QEI_VELDIV_16 0x00000100 // Predivide by 16
  59. #define QEI_VELDIV_32 0x00000140 // Predivide by 32
  60. #define QEI_VELDIV_64 0x00000180 // Predivide by 64
  61. #define QEI_VELDIV_128 0x000001C0 // Predivide by 128
  62. //*****************************************************************************
  63. //
  64. // Values that can be passed to QEIEnableInts, QEIDisableInts, and QEIClearInts
  65. // as the ulIntFlags parameter, and returned by QEIGetIntStatus.
  66. //
  67. //*****************************************************************************
  68. #define QEI_INTERROR 0x00000008 // Phase error detected
  69. #define QEI_INTDIR 0x00000004 // Direction change
  70. #define QEI_INTTIMER 0x00000002 // Velocity timer expired
  71. #define QEI_INTINDEX 0x00000001 // Index pulse detected
  72. //*****************************************************************************
  73. //
  74. // Prototypes for the APIs.
  75. //
  76. //*****************************************************************************
  77. extern void QEIEnable(unsigned long ulBase);
  78. extern void QEIDisable(unsigned long ulBase);
  79. extern void QEIConfigure(unsigned long ulBase, unsigned long ulConfig,
  80. unsigned long ulMaxPosition);
  81. extern unsigned long QEIPositionGet(unsigned long ulBase);
  82. extern void QEIPositionSet(unsigned long ulBase, unsigned long ulPosition);
  83. extern long QEIDirectionGet(unsigned long ulBase);
  84. extern tBoolean QEIErrorGet(unsigned long ulBase);
  85. extern void QEIVelocityEnable(unsigned long ulBase);
  86. extern void QEIVelocityDisable(unsigned long ulBase);
  87. extern void QEIVelocityConfigure(unsigned long ulBase, unsigned long ulPreDiv,
  88. unsigned long ulPeriod);
  89. extern unsigned long QEIVelocityGet(unsigned long ulBase);
  90. extern void QEIIntRegister(unsigned long ulBase, void (*pfnHandler)(void));
  91. extern void QEIIntUnregister(unsigned long ulBase);
  92. extern void QEIIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
  93. extern void QEIIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
  94. extern unsigned long QEIIntStatus(unsigned long ulBase, tBoolean bMasked);
  95. extern void QEIIntClear(unsigned long ulBase, unsigned long ulIntFlags);
  96. //*****************************************************************************
  97. //
  98. // Mark the end of the C bindings section for C++ compilers.
  99. //
  100. //*****************************************************************************
  101. #ifdef __cplusplus
  102. }
  103. #endif
  104. #endif // __QEI_H__