timer.h 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. //*****************************************************************************
  2. //
  3. // timer.h - Prototypes for the timer module
  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 __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_ONE_SHOT 0x00000021 // Full-width one-shot timer
  42. #define TIMER_CFG_ONE_SHOT_UP 0x00000031 // Full-width one-shot up-count
  43. // timer
  44. #define TIMER_CFG_PERIODIC 0x00000022 // Full-width periodic timer
  45. #define TIMER_CFG_PERIODIC_UP 0x00000032 // Full-width periodic up-count
  46. // timer
  47. #define TIMER_CFG_RTC 0x01000000 // Full-width RTC timer
  48. #define TIMER_CFG_SPLIT_PAIR 0x04000000 // Two half-width timers
  49. #define TIMER_CFG_A_ONE_SHOT 0x00000021 // Timer A one-shot timer
  50. #define TIMER_CFG_A_ONE_SHOT_UP 0x00000031 // Timer A one-shot up-count timer
  51. #define TIMER_CFG_A_PERIODIC 0x00000022 // Timer A periodic timer
  52. #define TIMER_CFG_A_PERIODIC_UP 0x00000032 // Timer A periodic up-count timer
  53. #define TIMER_CFG_A_CAP_COUNT 0x00000003 // Timer A event counter
  54. #define TIMER_CFG_A_CAP_COUNT_UP 0x00000013 // Timer A event up-counter
  55. #define TIMER_CFG_A_CAP_TIME 0x00000007 // Timer A event timer
  56. #define TIMER_CFG_A_CAP_TIME_UP 0x00000017 // Timer A event up-count timer
  57. #define TIMER_CFG_A_PWM 0x0000000A // Timer A PWM output
  58. #define TIMER_CFG_B_ONE_SHOT 0x00002100 // Timer B one-shot timer
  59. #define TIMER_CFG_B_ONE_SHOT_UP 0x00003100 // Timer B one-shot up-count timer
  60. #define TIMER_CFG_B_PERIODIC 0x00002200 // Timer B periodic timer
  61. #define TIMER_CFG_B_PERIODIC_UP 0x00003200 // Timer B periodic up-count timer
  62. #define TIMER_CFG_B_CAP_COUNT 0x00000300 // Timer B event counter
  63. #define TIMER_CFG_B_CAP_COUNT_UP 0x00001300 // Timer B event up-counter
  64. #define TIMER_CFG_B_CAP_TIME 0x00000700 // Timer B event timer
  65. #define TIMER_CFG_B_CAP_TIME_UP 0x00001700 // Timer B event up-count timer
  66. #define TIMER_CFG_B_PWM 0x00000A00 // Timer B PWM output
  67. //*****************************************************************************
  68. //
  69. // Values that can be passed to TimerIntEnable, TimerIntDisable, and
  70. // TimerIntClear as the ulIntFlags parameter, and returned from TimerIntStatus.
  71. //
  72. //*****************************************************************************
  73. #define TIMER_TIMB_MATCH 0x00000800 // TimerB match interrupt
  74. #define TIMER_CAPB_EVENT 0x00000400 // CaptureB event interrupt
  75. #define TIMER_CAPB_MATCH 0x00000200 // CaptureB match interrupt
  76. #define TIMER_TIMB_TIMEOUT 0x00000100 // TimerB time out interrupt
  77. #define TIMER_TIMA_MATCH 0x00000010 // TimerA match interrupt
  78. #define TIMER_RTC_MATCH 0x00000008 // RTC interrupt mask
  79. #define TIMER_CAPA_EVENT 0x00000004 // CaptureA event interrupt
  80. #define TIMER_CAPA_MATCH 0x00000002 // CaptureA match interrupt
  81. #define TIMER_TIMA_TIMEOUT 0x00000001 // TimerA time out interrupt
  82. //*****************************************************************************
  83. //
  84. // Values that can be passed to TimerControlEvent as the ulEvent parameter.
  85. //
  86. //*****************************************************************************
  87. #define TIMER_EVENT_POS_EDGE 0x00000000 // Count positive edges
  88. #define TIMER_EVENT_NEG_EDGE 0x00000404 // Count negative edges
  89. #define TIMER_EVENT_BOTH_EDGES 0x00000C0C // Count both edges
  90. //*****************************************************************************
  91. //
  92. // Values that can be passed to most of the timer APIs as the ulTimer
  93. // parameter.
  94. //
  95. //*****************************************************************************
  96. #define TIMER_A 0x000000ff // Timer A
  97. #define TIMER_B 0x0000ff00 // Timer B
  98. #define TIMER_BOTH 0x0000ffff // Timer Both
  99. //*****************************************************************************
  100. //
  101. // Values that can be passed to TimerSynchronize as the ulTimers parameter.
  102. //
  103. //*****************************************************************************
  104. #define TIMER_0A_SYNC 0x00000001 // Synchronize Timer 0A
  105. #define TIMER_0B_SYNC 0x00000002 // Synchronize Timer 0B
  106. #define TIMER_1A_SYNC 0x00000004 // Synchronize Timer 1A
  107. #define TIMER_1B_SYNC 0x00000008 // Synchronize Timer 1B
  108. #define TIMER_2A_SYNC 0x00000010 // Synchronize Timer 2A
  109. #define TIMER_2B_SYNC 0x00000020 // Synchronize Timer 2B
  110. #define TIMER_3A_SYNC 0x00000040 // Synchronize Timer 3A
  111. #define TIMER_3B_SYNC 0x00000080 // Synchronize Timer 3B
  112. #define TIMER_4A_SYNC 0x00000100 // Synchronize Timer 4A
  113. #define TIMER_4B_SYNC 0x00000200 // Synchronize Timer 4B
  114. #define TIMER_5A_SYNC 0x00000400 // Synchronize Timer 5A
  115. #define TIMER_5B_SYNC 0x00000800 // Synchronize Timer 5B
  116. #define WTIMER_0A_SYNC 0x00001000 // Synchronize Wide Timer 0A
  117. #define WTIMER_0B_SYNC 0x00002000 // Synchronize Wide Timer 0B
  118. #define WTIMER_1A_SYNC 0x00004000 // Synchronize Wide Timer 1A
  119. #define WTIMER_1B_SYNC 0x00008000 // Synchronize Wide Timer 1B
  120. #define WTIMER_2A_SYNC 0x00010000 // Synchronize Wide Timer 2A
  121. #define WTIMER_2B_SYNC 0x00020000 // Synchronize Wide Timer 2B
  122. #define WTIMER_3A_SYNC 0x00040000 // Synchronize Wide Timer 3A
  123. #define WTIMER_3B_SYNC 0x00080000 // Synchronize Wide Timer 3B
  124. #define WTIMER_4A_SYNC 0x00100000 // Synchronize Wide Timer 4A
  125. #define WTIMER_4B_SYNC 0x00200000 // Synchronize Wide Timer 4B
  126. #define WTIMER_5A_SYNC 0x00400000 // Synchronize Wide Timer 5A
  127. #define WTIMER_5B_SYNC 0x00800000 // Synchronize Wide Timer 5B
  128. //*****************************************************************************
  129. //
  130. // Prototypes for the APIs.
  131. //
  132. //*****************************************************************************
  133. extern void TimerEnable(unsigned long ulBase, unsigned long ulTimer);
  134. extern void TimerDisable(unsigned long ulBase, unsigned long ulTimer);
  135. extern void TimerConfigure(unsigned long ulBase, unsigned long ulConfig);
  136. extern void TimerControlLevel(unsigned long ulBase, unsigned long ulTimer,
  137. tBoolean bInvert);
  138. extern void TimerControlTrigger(unsigned long ulBase, unsigned long ulTimer,
  139. tBoolean bEnable);
  140. extern void TimerControlEvent(unsigned long ulBase, unsigned long ulTimer,
  141. unsigned long ulEvent);
  142. extern void TimerControlStall(unsigned long ulBase, unsigned long ulTimer,
  143. tBoolean bStall);
  144. extern void TimerControlWaitOnTrigger(unsigned long ulBase,
  145. unsigned long ulTimer,
  146. tBoolean bWait);
  147. extern void TimerRTCEnable(unsigned long ulBase);
  148. extern void TimerRTCDisable(unsigned long ulBase);
  149. extern void TimerPrescaleSet(unsigned long ulBase, unsigned long ulTimer,
  150. unsigned long ulValue);
  151. extern unsigned long TimerPrescaleGet(unsigned long ulBase,
  152. unsigned long ulTimer);
  153. extern void TimerPrescaleMatchSet(unsigned long ulBase, unsigned long ulTimer,
  154. unsigned long ulValue);
  155. extern unsigned long TimerPrescaleMatchGet(unsigned long ulBase,
  156. unsigned long ulTimer);
  157. extern void TimerLoadSet(unsigned long ulBase, unsigned long ulTimer,
  158. unsigned long ulValue);
  159. extern unsigned long TimerLoadGet(unsigned long ulBase, unsigned long ulTimer);
  160. extern void TimerLoadSet64(unsigned long ulBase, unsigned long long ullValue);
  161. extern unsigned long long TimerLoadGet64(unsigned long ulBase);
  162. extern unsigned long TimerValueGet(unsigned long ulBase,
  163. unsigned long ulTimer);
  164. extern unsigned long long TimerValueGet64(unsigned long ulBase);
  165. extern void TimerMatchSet(unsigned long ulBase, unsigned long ulTimer,
  166. unsigned long ulValue);
  167. extern unsigned long TimerMatchGet(unsigned long ulBase,
  168. unsigned long ulTimer);
  169. extern void TimerMatchSet64(unsigned long ulBase, unsigned long long ullValue);
  170. extern unsigned long long TimerMatchGet64(unsigned long ulBase);
  171. extern void TimerIntRegister(unsigned long ulBase, unsigned long ulTimer,
  172. void (*pfnHandler)(void));
  173. extern void TimerIntUnregister(unsigned long ulBase, unsigned long ulTimer);
  174. extern void TimerIntEnable(unsigned long ulBase, unsigned long ulIntFlags);
  175. extern void TimerIntDisable(unsigned long ulBase, unsigned long ulIntFlags);
  176. extern unsigned long TimerIntStatus(unsigned long ulBase, tBoolean bMasked);
  177. extern void TimerIntClear(unsigned long ulBase, unsigned long ulIntFlags);
  178. extern void TimerSynchronize(unsigned long ulBase, unsigned long ulTimers);
  179. //*****************************************************************************
  180. //
  181. // TimerQuiesce() has been deprecated. SysCtlPeripheralReset() should be used
  182. // instead to return the timer to its reset state.
  183. //
  184. //*****************************************************************************
  185. #ifndef DEPRECATED
  186. extern void TimerQuiesce(unsigned long ulBase);
  187. #endif
  188. //*****************************************************************************
  189. //
  190. // These values for TimerConfigure have been deprecated.
  191. //
  192. //*****************************************************************************
  193. #ifndef DEPRECATED
  194. #define TIMER_CFG_32_BIT_OS 0x00000021 // 32-bit one-shot timer
  195. #define TIMER_CFG_32_BIT_OS_UP 0x00000031 // 32-bit one-shot up-count timer
  196. #define TIMER_CFG_32_BIT_PER 0x00000022 // 32-bit periodic timer
  197. #define TIMER_CFG_32_BIT_PER_UP 0x00000032 // 32-bit periodic up-count timer
  198. #define TIMER_CFG_32_RTC 0x01000000 // 32-bit RTC timer
  199. #define TIMER_CFG_16_BIT_PAIR 0x04000000 // Two 16-bit timers
  200. #endif
  201. //*****************************************************************************
  202. //
  203. // Mark the end of the C bindings section for C++ compilers.
  204. //
  205. //*****************************************************************************
  206. #ifdef __cplusplus
  207. }
  208. #endif
  209. #endif // __TIMER_H__