PageRenderTime 65ms CodeModel.GetById 25ms RepoModel.GetById 0ms app.codeStats 1ms

/src/platform/lm3s/driverlib/adc.h

https://github.com/mauriciobomfim/elua
C Header | 269 lines | 174 code | 13 blank | 82 comment | 0 complexity | 755b3e06358c3dde349fe30eb2b91551 MD5 | raw file
  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 7611 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_CMP0 0x00080000 // Select Comparator 0
  80. #define ADC_CTL_CMP1 0x00090000 // Select Comparator 1
  81. #define ADC_CTL_CMP2 0x000A0000 // Select Comparator 2
  82. #define ADC_CTL_CMP3 0x000B0000 // Select Comparator 3
  83. #define ADC_CTL_CMP4 0x000C0000 // Select Comparator 4
  84. #define ADC_CTL_CMP5 0x000D0000 // Select Comparator 5
  85. #define ADC_CTL_CMP6 0x000E0000 // Select Comparator 6
  86. #define ADC_CTL_CMP7 0x000F0000 // Select Comparator 7
  87. //*****************************************************************************
  88. //
  89. // Values that can be passed to ADCComparatorConfigure as part of the
  90. // ulConfig parameter.
  91. //
  92. //*****************************************************************************
  93. #define ADC_COMP_TRIG_NONE 0x00000000 // Trigger Disabled
  94. #define ADC_COMP_TRIG_LOW_ALWAYS \
  95. 0x00001000 // Trigger Low Always
  96. #define ADC_COMP_TRIG_LOW_ONCE 0x00001100 // Trigger Low Once
  97. #define ADC_COMP_TRIG_LOW_HALWAYS \
  98. 0x00001200 // Trigger Low Always (Hysteresis)
  99. #define ADC_COMP_TRIG_LOW_HONCE 0x00001300 // Trigger Low Once (Hysteresis)
  100. #define ADC_COMP_TRIG_MID_ALWAYS \
  101. 0x00001400 // Trigger Mid Always
  102. #define ADC_COMP_TRIG_MID_ONCE 0x00001500 // Trigger Mid Once
  103. #define ADC_COMP_TRIG_HIGH_ALWAYS \
  104. 0x00001C00 // Trigger High Always
  105. #define ADC_COMP_TRIG_HIGH_ONCE 0x00001D00 // Trigger High Once
  106. #define ADC_COMP_TRIG_HIGH_HALWAYS \
  107. 0x00001E00 // Trigger High Always (Hysteresis)
  108. #define ADC_COMP_TRIG_HIGH_HONCE \
  109. 0x00001F00 // Trigger High Once (Hysteresis)
  110. #define ADC_COMP_INT_NONE 0x00000000 // Interrupt Disabled
  111. #define ADC_COMP_INT_LOW_ALWAYS \
  112. 0x00000010 // Interrupt Low Always
  113. #define ADC_COMP_INT_LOW_ONCE 0x00000011 // Interrupt Low Once
  114. #define ADC_COMP_INT_LOW_HALWAYS \
  115. 0x00000012 // Interrupt Low Always
  116. // (Hysteresis)
  117. #define ADC_COMP_INT_LOW_HONCE 0x00000013 // Interrupt Low Once (Hysteresis)
  118. #define ADC_COMP_INT_MID_ALWAYS \
  119. 0x00000014 // Interrupt Mid Always
  120. #define ADC_COMP_INT_MID_ONCE 0x00000015 // Interrupt Mid Once
  121. #define ADC_COMP_INT_HIGH_ALWAYS \
  122. 0x0000001C // Interrupt High Always
  123. #define ADC_COMP_INT_HIGH_ONCE 0x0000001D // Interrupt High Once
  124. #define ADC_COMP_INT_HIGH_HALWAYS \
  125. 0x0000001E // Interrupt High Always
  126. // (Hysteresis)
  127. #define ADC_COMP_INT_HIGH_HONCE \
  128. 0x0000001F // Interrupt High Once (Hysteresis)
  129. //*****************************************************************************
  130. //
  131. // Values that can be used to modify the sequence number passed to
  132. // ADCProcessorTrigger in order to get cross-module synchronous processor
  133. // triggers.
  134. //
  135. //*****************************************************************************
  136. #define ADC_TRIGGER_WAIT 0x08000000 // Wait for the synchronous trigger
  137. #define ADC_TRIGGER_SIGNAL 0x80000000 // Signal the synchronous trigger
  138. //*****************************************************************************
  139. //
  140. // Values that can be passed to ADCPhaseDelaySet as the ulPhase parameter and
  141. // returned from ADCPhaseDelayGet.
  142. //
  143. //*****************************************************************************
  144. #define ADC_PHASE_0 0x00000000 // 0 degrees
  145. #define ADC_PHASE_22_5 0x00000001 // 22.5 degrees
  146. #define ADC_PHASE_45 0x00000002 // 45 degrees
  147. #define ADC_PHASE_67_5 0x00000003 // 67.5 degrees
  148. #define ADC_PHASE_90 0x00000004 // 90 degrees
  149. #define ADC_PHASE_112_5 0x00000005 // 112.5 degrees
  150. #define ADC_PHASE_135 0x00000006 // 135 degrees
  151. #define ADC_PHASE_157_5 0x00000007 // 157.5 degrees
  152. #define ADC_PHASE_180 0x00000008 // 180 degrees
  153. #define ADC_PHASE_202_5 0x00000009 // 202.5 degrees
  154. #define ADC_PHASE_225 0x0000000A // 225 degrees
  155. #define ADC_PHASE_247_5 0x0000000B // 247.5 degrees
  156. #define ADC_PHASE_270 0x0000000C // 270 degrees
  157. #define ADC_PHASE_292_5 0x0000000D // 292.5 degrees
  158. #define ADC_PHASE_315 0x0000000E // 315 degrees
  159. #define ADC_PHASE_337_5 0x0000000F // 337.5 degrees
  160. //*****************************************************************************
  161. //
  162. // Values that can be passed to ADCReferenceSet as the ulRef parameter.
  163. //
  164. //*****************************************************************************
  165. #define ADC_REF_INT 0x00000000 // Internal reference
  166. #define ADC_REF_EXT_3V 0x00000001 // External 3V reference
  167. #define ADC_REF_EXT_1V 0x00000003 // External 1V reference
  168. //*****************************************************************************
  169. //
  170. // Values that can be passed to ADCResolutionSet as the ulResolution parameter.
  171. //
  172. //*****************************************************************************
  173. #define ADC_RES_10BIT 0x00000000 // 10-bit resolution
  174. #define ADC_RES_12BIT 0x00000010 // 12-bit resolution
  175. //*****************************************************************************
  176. //
  177. // Prototypes for the APIs.
  178. //
  179. //*****************************************************************************
  180. extern void ADCIntRegister(unsigned long ulBase, unsigned long ulSequenceNum,
  181. void (*pfnHandler)(void));
  182. extern void ADCIntUnregister(unsigned long ulBase,
  183. unsigned long ulSequenceNum);
  184. extern void ADCIntDisable(unsigned long ulBase, unsigned long ulSequenceNum);
  185. extern void ADCIntEnable(unsigned long ulBase, unsigned long ulSequenceNum);
  186. extern unsigned long ADCIntStatus(unsigned long ulBase,
  187. unsigned long ulSequenceNum,
  188. tBoolean bMasked);
  189. extern void ADCIntClear(unsigned long ulBase, unsigned long ulSequenceNum);
  190. extern void ADCSequenceEnable(unsigned long ulBase,
  191. unsigned long ulSequenceNum);
  192. extern void ADCSequenceDisable(unsigned long ulBase,
  193. unsigned long ulSequenceNum);
  194. extern void ADCSequenceConfigure(unsigned long ulBase,
  195. unsigned long ulSequenceNum,
  196. unsigned long ulTrigger,
  197. unsigned long ulPriority);
  198. extern void ADCSequenceStepConfigure(unsigned long ulBase,
  199. unsigned long ulSequenceNum,
  200. unsigned long ulStep,
  201. unsigned long ulConfig);
  202. extern long ADCSequenceOverflow(unsigned long ulBase,
  203. unsigned long ulSequenceNum);
  204. extern void ADCSequenceOverflowClear(unsigned long ulBase,
  205. unsigned long ulSequenceNum);
  206. extern long ADCSequenceUnderflow(unsigned long ulBase,
  207. unsigned long ulSequenceNum);
  208. extern void ADCSequenceUnderflowClear(unsigned long ulBase,
  209. unsigned long ulSequenceNum);
  210. extern long ADCSequenceDataGet(unsigned long ulBase,
  211. unsigned long ulSequenceNum,
  212. unsigned long *pulBuffer);
  213. extern void ADCProcessorTrigger(unsigned long ulBase,
  214. unsigned long ulSequenceNum);
  215. extern void ADCSoftwareOversampleConfigure(unsigned long ulBase,
  216. unsigned long ulSequenceNum,
  217. unsigned long ulFactor);
  218. extern void ADCSoftwareOversampleStepConfigure(unsigned long ulBase,
  219. unsigned long ulSequenceNum,
  220. unsigned long ulStep,
  221. unsigned long ulConfig);
  222. extern void ADCSoftwareOversampleDataGet(unsigned long ulBase,
  223. unsigned long ulSequenceNum,
  224. unsigned long *pulBuffer,
  225. unsigned long ulCount);
  226. extern void ADCHardwareOversampleConfigure(unsigned long ulBase,
  227. unsigned long ulFactor);
  228. extern void ADCComparatorConfigure(unsigned long ulBase, unsigned long ulComp,
  229. unsigned long ulConfig);
  230. extern void ADCComparatorRegionSet(unsigned long ulBase, unsigned long ulComp,
  231. unsigned long ulLowRef,
  232. unsigned long ulHighRef);
  233. extern void ADCComparatorReset(unsigned long ulBase, unsigned long ulComp,
  234. tBoolean bTrigger, tBoolean bInterrupt);
  235. extern void ADCComparatorIntDisable(unsigned long ulBase,
  236. unsigned long ulSequenceNum);
  237. extern void ADCComparatorIntEnable(unsigned long ulBase,
  238. unsigned long ulSequenceNum);
  239. extern unsigned long ADCComparatorIntStatus(unsigned long ulBase);
  240. extern void ADCComparatorIntClear(unsigned long ulBase,
  241. unsigned long ulStatus);
  242. extern void ADCReferenceSet(unsigned long ulBase, unsigned long ulRef);
  243. extern unsigned long ADCReferenceGet(unsigned long ulBase);
  244. extern void ADCResolutionSet(unsigned long ulBase, unsigned long ulResolution);
  245. extern unsigned long ADCResolutionGet(unsigned long ulBase);
  246. extern void ADCPhaseDelaySet(unsigned long ulBase, unsigned long ulPhase);
  247. extern unsigned long ADCPhaseDelayGet(unsigned long ulBase);
  248. //*****************************************************************************
  249. //
  250. // Mark the end of the C bindings section for C++ compilers.
  251. //
  252. //*****************************************************************************
  253. #ifdef __cplusplus
  254. }
  255. #endif
  256. #endif // __ADC_H__