timer.h 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. //*****************************************************************************
  2. //
  3. // timer.h - Prototypes for the timer module
  4. //
  5. // Copyright (c) 2005-2010 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 6459 of the Stellaris Peripheral Driver Library.
  22. //
  23. //*****************************************************************************
  24. #ifndef __TIMER_H__
  25. #define __TIMER_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 TimerConfigure as the ulConfig parameter.
  39. //
  40. //*****************************************************************************
  41. #define TIMER_CFG_32_BIT_OS 0x00000001 // 32-bit one-shot timer
  42. #define TIMER_CFG_32_BIT_OS_UP 0x00000011 // 32-bit one-shot up-count timer
  43. #define TIMER_CFG_32_BIT_PER 0x00000002 // 32-bit periodic timer
  44. #define TIMER_CFG_32_BIT_PER_UP 0x00000012 // 32-bit periodic up-count timer
  45. #define TIMER_CFG_32_RTC 0x01000000 // 32-bit RTC timer
  46. #define TIMER_CFG_16_BIT_PAIR 0x04000000 // Two 16-bit timers
  47. #define TIMER_CFG_A_ONE_SHOT 0x00000001 // Timer A one-shot timer
  48. #define TIMER_CFG_A_ONE_SHOT_UP 0x00000011 // Timer A one-shot up-count timer
  49. #define TIMER_CFG_A_PERIODIC 0x00000002 // Timer A periodic timer
  50. #define TIMER_CFG_A_PERIODIC_UP 0x00000012 // Timer A periodic up-count timer
  51. #define TIMER_CFG_A_CAP_COUNT 0x00000003 // Timer A event counter
  52. #define TIMER_CFG_A_CAP_TIME 0x00000007 // Timer A event timer
  53. #define TIMER_CFG_A_PWM 0x0000000A // Timer A PWM output
  54. #define TIMER_CFG_B_ONE_SHOT 0x00000100 // Timer B one-shot timer
  55. #define TIMER_CFG_B_ONE_SHOT_UP 0x00001100 // Timer B one-shot up-count timer
  56. #define TIMER_CFG_B_PERIODIC 0x00000200 // Timer B periodic timer
  57. #define TIMER_CFG_B_PERIODIC_UP 0x00001200 // Timer B periodic up-count timer
  58. #define TIMER_CFG_B_CAP_COUNT 0x00000300 // Timer B event counter
  59. #define TIMER_CFG_B_CAP_TIME 0x00000700 // Timer B event timer
  60. #define TIMER_CFG_B_PWM 0x00000A00 // Timer B PWM output
  61. //*****************************************************************************
  62. //
  63. // Values that can be passed to TimerIntEnable, TimerIntDisable, and
  64. // TimerIntClear as the ulIntFlags parameter, and returned from TimerIntStatus.
  65. //
  66. //*****************************************************************************
  67. #define TIMER_TIMB_MATCH 0x00000800 // TimerB match interrupt
  68. #define TIMER_CAPB_EVENT 0x00000400 // CaptureB event interrupt
  69. #define TIMER_CAPB_MATCH 0x00000200 // CaptureB match interrupt
  70. #define TIMER_TIMB_TIMEOUT 0x00000100 // TimerB time out interrupt
  71. #define TIMER_TIMA_MATCH 0x00000010 // TimerA match interrupt
  72. #define TIMER_RTC_MATCH 0x00000008 // RTC interrupt mask
  73. #define TIMER_CAPA_EVENT 0x00000004 // CaptureA event interrupt
  74. #define TIMER_CAPA_MATCH 0x00000002 // CaptureA match interrupt
  75. #define TIMER_TIMA_TIMEOUT 0x00000001 // TimerA time out interrupt
  76. //*****************************************************************************
  77. //
  78. // Values that can be passed to TimerControlEvent as the ulEvent parameter.
  79. //
  80. //*****************************************************************************
  81. #define TIMER_EVENT_POS_EDGE 0x00000000 // Count positive edges
  82. #define TIMER_EVENT_NEG_EDGE 0x00000404 // Count negative edges
  83. #define TIMER_EVENT_BOTH_EDGES 0x00000C0C // Count both edges
  84. //*****************************************************************************
  85. //
  86. // Values that can be passed to most of the timer APIs as the ulTimer
  87. // parameter.
  88. //
  89. //*****************************************************************************
  90. #define TIMER_A 0x000000ff // Timer A
  91. #define TIMER_B 0x0000ff00 // Timer B
  92. #define TIMER_BOTH 0x0000ffff // Timer Both
  93. //*****************************************************************************
  94. //
  95. // Prototypes for the APIs.
  96. //
  97. //*****************************************************************************
  98. extern void TimerEnable(unsigned long ulBase, unsigned long ulTimer);
  99. extern void TimerDisable(unsigned long ulBase, unsigned long ulTimer);
  100. extern void TimerConfigure(unsigned long ulBase, unsigned long ulConfig);
  101. extern void TimerControlLevel(unsigned long ulBase, unsigned long ulTimer,
  102. tBoolean bInvert);
  103. extern void TimerControlTrigger(unsigned long ulBase, unsigned long ulTimer,
  104. tBoolean bEnable);
  105. extern void TimerControlEvent(unsigned long ulBase, unsigned long ulTimer,
  106. unsigned long ulEvent);
  107. extern void TimerControlStall(unsigned long ulBase, unsigned long ulTimer,
  108. tBoolean bStall);
  109. extern void TimerControlWaitOnTrigger(unsigned long ulBase,
  110. unsigned long ulTimer,
  111. tBoolean bWait);
  112. extern void TimerRTCEnable(unsigned long ulBase);
  113. extern void TimerRTCDisable(unsigned long ulBase);
  114. extern void TimerPrescaleSet(unsigned long ulBase, unsigned long ulTimer,
  115. unsigned long ulValue);
  116. extern unsigned long TimerPrescaleGet(unsigned long ulBase,
  117. unsigned long ulTimer);
  118. extern void TimerPrescaleMatchSet(unsigned long ulBase, unsigned long ulTimer,
  119. unsigned long ulValue);
  120. extern unsigned long TimerPrescaleMatchGet(unsigned long ulBase,
  121. unsigned long ulTimer);
  122. extern void TimerLoadSet(unsigned long ulBase, unsigned long ulTimer,
  123. unsigned long ulValue);
  124. extern unsigned long TimerLoadGet(unsigned long ulBase, unsigned long ulTimer);
  125. extern unsigned long TimerValueGet(unsigned long ulBase,
  126. unsigned long ulTimer);
  127. extern void TimerMatchSet(unsigned long ulBase, unsigned long ulTimer,
  128. unsigned long ulValue);
  129. extern unsigned long TimerMatchGet(unsigned long ulBase,
  130. unsigned long ulTimer);
  131. extern void TimerIntRegister(unsigned long ulBase, unsigned long ulTimer,
  132. void (*pfnHandler)(void));
  133. extern void TimerIntUnregister(unsigned long ulBase, unsigned long ulTimer);
  134. extern void TimerIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
  135. extern void TimerIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
  136. extern unsigned long TimerIntStatus(unsigned long ulBase, tBoolean bMasked);
  137. extern void TimerIntClear(unsigned long ulBase, unsigned long ulIntFlags);
  138. //*****************************************************************************
  139. //
  140. // TimerQuiesce() has been deprecated. SysCtlPeripheralReset() should be used
  141. // instead to return the timer to its reset state.
  142. //
  143. //*****************************************************************************
  144. #ifndef DEPRECATED
  145. extern void TimerQuiesce(unsigned long ulBase);
  146. #endif
  147. //*****************************************************************************
  148. //
  149. // Mark the end of the C bindings section for C++ compilers.
  150. //
  151. //*****************************************************************************
  152. #ifdef __cplusplus
  153. }
  154. #endif
  155. #endif // __TIMER_H__