adc.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. //*****************************************************************************
  2. //
  3. // adc.h - ADC headers for using the ADC driver functions.
  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 __ADC_H__
  25. #define __ADC_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 ADCSequenceConfigure as the ulTrigger
  39. // parameter.
  40. //
  41. //*****************************************************************************
  42. #define ADC_TRIGGER_PROCESSOR 0x00000000 // Processor event
  43. #define ADC_TRIGGER_COMP0 0x00000001 // Analog comparator 0 event
  44. #define ADC_TRIGGER_COMP1 0x00000002 // Analog comparator 1 event
  45. #define ADC_TRIGGER_COMP2 0x00000003 // Analog comparator 2 event
  46. #define ADC_TRIGGER_EXTERNAL 0x00000004 // External event
  47. #define ADC_TRIGGER_TIMER 0x00000005 // Timer event
  48. #define ADC_TRIGGER_PWM0 0x00000006 // PWM0 event
  49. #define ADC_TRIGGER_PWM1 0x00000007 // PWM1 event
  50. #define ADC_TRIGGER_PWM2 0x00000008 // PWM2 event
  51. #define ADC_TRIGGER_PWM3 0x00000009 // PWM3 event
  52. #define ADC_TRIGGER_ALWAYS 0x0000000F // Always event
  53. //*****************************************************************************
  54. //
  55. // Values that can be passed to ADCSequenceStepConfigure as the ulConfig
  56. // parameter.
  57. //
  58. //*****************************************************************************
  59. #define ADC_CTL_TS 0x00000080 // Temperature sensor select
  60. #define ADC_CTL_IE 0x00000040 // Interrupt enable
  61. #define ADC_CTL_END 0x00000020 // Sequence end select
  62. #define ADC_CTL_D 0x00000010 // Differential select
  63. #define ADC_CTL_CH0 0x00000000 // Input channel 0
  64. #define ADC_CTL_CH1 0x00000001 // Input channel 1
  65. #define ADC_CTL_CH2 0x00000002 // Input channel 2
  66. #define ADC_CTL_CH3 0x00000003 // Input channel 3
  67. #define ADC_CTL_CH4 0x00000004 // Input channel 4
  68. #define ADC_CTL_CH5 0x00000005 // Input channel 5
  69. #define ADC_CTL_CH6 0x00000006 // Input channel 6
  70. #define ADC_CTL_CH7 0x00000007 // Input channel 7
  71. #define ADC_CTL_CH8 0x00000008 // Input channel 8
  72. #define ADC_CTL_CH9 0x00000009 // Input channel 9
  73. #define ADC_CTL_CH10 0x0000000A // Input channel 10
  74. #define ADC_CTL_CH11 0x0000000B // Input channel 11
  75. #define ADC_CTL_CH12 0x0000000C // Input channel 12
  76. #define ADC_CTL_CH13 0x0000000D // Input channel 13
  77. #define ADC_CTL_CH14 0x0000000E // Input channel 14
  78. #define ADC_CTL_CH15 0x0000000F // Input channel 15
  79. #define ADC_CTL_CH16 0x00000100 // Input channel 16
  80. #define ADC_CTL_CH17 0x00000101 // Input channel 17
  81. #define ADC_CTL_CH18 0x00000102 // Input channel 18
  82. #define ADC_CTL_CH19 0x00000103 // Input channel 19
  83. #define ADC_CTL_CH20 0x00000104 // Input channel 20
  84. #define ADC_CTL_CH21 0x00000105 // Input channel 21
  85. #define ADC_CTL_CH22 0x00000106 // Input channel 22
  86. #define ADC_CTL_CH23 0x00000107 // Input channel 23
  87. #define ADC_CTL_CMP0 0x00080000 // Select Comparator 0
  88. #define ADC_CTL_CMP1 0x00090000 // Select Comparator 1
  89. #define ADC_CTL_CMP2 0x000A0000 // Select Comparator 2
  90. #define ADC_CTL_CMP3 0x000B0000 // Select Comparator 3
  91. #define ADC_CTL_CMP4 0x000C0000 // Select Comparator 4
  92. #define ADC_CTL_CMP5 0x000D0000 // Select Comparator 5
  93. #define ADC_CTL_CMP6 0x000E0000 // Select Comparator 6
  94. #define ADC_CTL_CMP7 0x000F0000 // Select Comparator 7
  95. //*****************************************************************************
  96. //
  97. // Values that can be passed to ADCComparatorConfigure as part of the
  98. // ulConfig parameter.
  99. //
  100. //*****************************************************************************
  101. #define ADC_COMP_TRIG_NONE 0x00000000 // Trigger Disabled
  102. #define ADC_COMP_TRIG_LOW_ALWAYS \
  103. 0x00001000 // Trigger Low Always
  104. #define ADC_COMP_TRIG_LOW_ONCE 0x00001100 // Trigger Low Once
  105. #define ADC_COMP_TRIG_LOW_HALWAYS \
  106. 0x00001200 // Trigger Low Always (Hysteresis)
  107. #define ADC_COMP_TRIG_LOW_HONCE 0x00001300 // Trigger Low Once (Hysteresis)
  108. #define ADC_COMP_TRIG_MID_ALWAYS \
  109. 0x00001400 // Trigger Mid Always
  110. #define ADC_COMP_TRIG_MID_ONCE 0x00001500 // Trigger Mid Once
  111. #define ADC_COMP_TRIG_HIGH_ALWAYS \
  112. 0x00001C00 // Trigger High Always
  113. #define ADC_COMP_TRIG_HIGH_ONCE 0x00001D00 // Trigger High Once
  114. #define ADC_COMP_TRIG_HIGH_HALWAYS \
  115. 0x00001E00 // Trigger High Always (Hysteresis)
  116. #define ADC_COMP_TRIG_HIGH_HONCE \
  117. 0x00001F00 // Trigger High Once (Hysteresis)
  118. #define ADC_COMP_INT_NONE 0x00000000 // Interrupt Disabled
  119. #define ADC_COMP_INT_LOW_ALWAYS \
  120. 0x00000010 // Interrupt Low Always
  121. #define ADC_COMP_INT_LOW_ONCE 0x00000011 // Interrupt Low Once
  122. #define ADC_COMP_INT_LOW_HALWAYS \
  123. 0x00000012 // Interrupt Low Always
  124. // (Hysteresis)
  125. #define ADC_COMP_INT_LOW_HONCE 0x00000013 // Interrupt Low Once (Hysteresis)
  126. #define ADC_COMP_INT_MID_ALWAYS \
  127. 0x00000014 // Interrupt Mid Always
  128. #define ADC_COMP_INT_MID_ONCE 0x00000015 // Interrupt Mid Once
  129. #define ADC_COMP_INT_HIGH_ALWAYS \
  130. 0x0000001C // Interrupt High Always
  131. #define ADC_COMP_INT_HIGH_ONCE 0x0000001D // Interrupt High Once
  132. #define ADC_COMP_INT_HIGH_HALWAYS \
  133. 0x0000001E // Interrupt High Always
  134. // (Hysteresis)
  135. #define ADC_COMP_INT_HIGH_HONCE \
  136. 0x0000001F // Interrupt High Once (Hysteresis)
  137. //*****************************************************************************
  138. //
  139. // Values that can be used to modify the sequence number passed to
  140. // ADCProcessorTrigger in order to get cross-module synchronous processor
  141. // triggers.
  142. //
  143. //*****************************************************************************
  144. #define ADC_TRIGGER_WAIT 0x08000000 // Wait for the synchronous trigger
  145. #define ADC_TRIGGER_SIGNAL 0x80000000 // Signal the synchronous trigger
  146. //*****************************************************************************
  147. //
  148. // Values that can be passed to ADCPhaseDelaySet as the ulPhase parameter and
  149. // returned from ADCPhaseDelayGet.
  150. //
  151. //*****************************************************************************
  152. #define ADC_PHASE_0 0x00000000 // 0 degrees
  153. #define ADC_PHASE_22_5 0x00000001 // 22.5 degrees
  154. #define ADC_PHASE_45 0x00000002 // 45 degrees
  155. #define ADC_PHASE_67_5 0x00000003 // 67.5 degrees
  156. #define ADC_PHASE_90 0x00000004 // 90 degrees
  157. #define ADC_PHASE_112_5 0x00000005 // 112.5 degrees
  158. #define ADC_PHASE_135 0x00000006 // 135 degrees
  159. #define ADC_PHASE_157_5 0x00000007 // 157.5 degrees
  160. #define ADC_PHASE_180 0x00000008 // 180 degrees
  161. #define ADC_PHASE_202_5 0x00000009 // 202.5 degrees
  162. #define ADC_PHASE_225 0x0000000A // 225 degrees
  163. #define ADC_PHASE_247_5 0x0000000B // 247.5 degrees
  164. #define ADC_PHASE_270 0x0000000C // 270 degrees
  165. #define ADC_PHASE_292_5 0x0000000D // 292.5 degrees
  166. #define ADC_PHASE_315 0x0000000E // 315 degrees
  167. #define ADC_PHASE_337_5 0x0000000F // 337.5 degrees
  168. //*****************************************************************************
  169. //
  170. // Values that can be passed to ADCReferenceSet as the ulRef parameter.
  171. //
  172. //*****************************************************************************
  173. #define ADC_REF_INT 0x00000000 // Internal reference
  174. #define ADC_REF_EXT_3V 0x00000001 // External 3V reference
  175. #define ADC_REF_EXT_1V 0x00000003 // External 1V reference
  176. //*****************************************************************************
  177. //
  178. // Values that can be passed to ADCResolutionSet as the ulResolution parameter.
  179. //
  180. //*****************************************************************************
  181. #define ADC_RES_10BIT 0x00000000 // 10-bit resolution
  182. #define ADC_RES_12BIT 0x00000010 // 12-bit resolution
  183. //*****************************************************************************
  184. //
  185. // Prototypes for the APIs.
  186. //
  187. //*****************************************************************************
  188. extern void ADCIntRegister(unsigned long ulBase, unsigned long ulSequenceNum,
  189. void (*pfnHandler)(void));
  190. extern void ADCIntUnregister(unsigned long ulBase,
  191. unsigned long ulSequenceNum);
  192. extern void ADCIntDisable(unsigned long ulBase, unsigned long ulSequenceNum);
  193. extern void ADCIntEnable(unsigned long ulBase, unsigned long ulSequenceNum);
  194. extern unsigned long ADCIntStatus(unsigned long ulBase,
  195. unsigned long ulSequenceNum,
  196. tBoolean bMasked);
  197. extern void ADCIntClear(unsigned long ulBase, unsigned long ulSequenceNum);
  198. extern void ADCSequenceEnable(unsigned long ulBase,
  199. unsigned long ulSequenceNum);
  200. extern void ADCSequenceDisable(unsigned long ulBase,
  201. unsigned long ulSequenceNum);
  202. extern void ADCSequenceConfigure(unsigned long ulBase,
  203. unsigned long ulSequenceNum,
  204. unsigned long ulTrigger,
  205. unsigned long ulPriority);
  206. extern void ADCSequenceStepConfigure(unsigned long ulBase,
  207. unsigned long ulSequenceNum,
  208. unsigned long ulStep,
  209. unsigned long ulConfig);
  210. extern long ADCSequenceOverflow(unsigned long ulBase,
  211. unsigned long ulSequenceNum);
  212. extern void ADCSequenceOverflowClear(unsigned long ulBase,
  213. unsigned long ulSequenceNum);
  214. extern long ADCSequenceUnderflow(unsigned long ulBase,
  215. unsigned long ulSequenceNum);
  216. extern void ADCSequenceUnderflowClear(unsigned long ulBase,
  217. unsigned long ulSequenceNum);
  218. extern long ADCSequenceDataGet(unsigned long ulBase,
  219. unsigned long ulSequenceNum,
  220. unsigned long *pulBuffer);
  221. extern void ADCProcessorTrigger(unsigned long ulBase,
  222. unsigned long ulSequenceNum);
  223. extern void ADCSoftwareOversampleConfigure(unsigned long ulBase,
  224. unsigned long ulSequenceNum,
  225. unsigned long ulFactor);
  226. extern void ADCSoftwareOversampleStepConfigure(unsigned long ulBase,
  227. unsigned long ulSequenceNum,
  228. unsigned long ulStep,
  229. unsigned long ulConfig);
  230. extern void ADCSoftwareOversampleDataGet(unsigned long ulBase,
  231. unsigned long ulSequenceNum,
  232. unsigned long *pulBuffer,
  233. unsigned long ulCount);
  234. extern void ADCHardwareOversampleConfigure(unsigned long ulBase,
  235. unsigned long ulFactor);
  236. extern void ADCComparatorConfigure(unsigned long ulBase, unsigned long ulComp,
  237. unsigned long ulConfig);
  238. extern void ADCComparatorRegionSet(unsigned long ulBase, unsigned long ulComp,
  239. unsigned long ulLowRef,
  240. unsigned long ulHighRef);
  241. extern void ADCComparatorReset(unsigned long ulBase, unsigned long ulComp,
  242. tBoolean bTrigger, tBoolean bInterrupt);
  243. extern void ADCComparatorIntDisable(unsigned long ulBase,
  244. unsigned long ulSequenceNum);
  245. extern void ADCComparatorIntEnable(unsigned long ulBase,
  246. unsigned long ulSequenceNum);
  247. extern unsigned long ADCComparatorIntStatus(unsigned long ulBase);
  248. extern void ADCComparatorIntClear(unsigned long ulBase,
  249. unsigned long ulStatus);
  250. extern void ADCReferenceSet(unsigned long ulBase, unsigned long ulRef);
  251. extern unsigned long ADCReferenceGet(unsigned long ulBase);
  252. extern void ADCResolutionSet(unsigned long ulBase, unsigned long ulResolution);
  253. extern unsigned long ADCResolutionGet(unsigned long ulBase);
  254. extern void ADCPhaseDelaySet(unsigned long ulBase, unsigned long ulPhase);
  255. extern unsigned long ADCPhaseDelayGet(unsigned long ulBase);
  256. //*****************************************************************************
  257. //
  258. // Mark the end of the C bindings section for C++ compilers.
  259. //
  260. //*****************************************************************************
  261. #ifdef __cplusplus
  262. }
  263. #endif
  264. #endif // __ADC_H__