/src/platform/lm3s/adc.h

https://github.com/lanwan/elua · C Header · 216 lines · 144 code · 10 blank · 62 comment · 0 complexity · 9a054df44a27569c05b6b00541c98ea4 MD5 · raw file

  1. //*****************************************************************************
  2. //
  3. // adc.h - ADC headers for using the ADC driver functions.
  4. //
  5. // Copyright (c) 2005-2009 Luminary Micro, Inc. All rights reserved.
  6. // Software License Agreement
  7. //
  8. // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
  9. // exclusively on LMI's microcontroller products.
  10. //
  11. // The software is owned by LMI and/or its suppliers, and is protected under
  12. // applicable copyright laws. All rights are reserved. You may not combine
  13. // this software with "viral" open-source software in order to form a larger
  14. // program. Any use in violation of the foregoing restrictions may subject
  15. // the user to criminal sanctions under applicable laws, as well as to civil
  16. // liability for the breach of the terms and conditions of this license.
  17. //
  18. // THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
  19. // OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
  20. // MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
  21. // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
  22. // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
  23. //
  24. // This is part of revision 4781 of the Stellaris Peripheral Driver Library.
  25. //
  26. //*****************************************************************************
  27. #ifndef __ADC_H__
  28. #define __ADC_H__
  29. //*****************************************************************************
  30. //
  31. // If building with a C++ compiler, make all of the definitions in this header
  32. // have a C binding.
  33. //
  34. //*****************************************************************************
  35. #ifdef __cplusplus
  36. extern "C"
  37. {
  38. #endif
  39. //*****************************************************************************
  40. //
  41. // Values that can be passed to ADCSequenceConfigure as the ulTrigger
  42. // parameter.
  43. //
  44. //*****************************************************************************
  45. #define ADC_TRIGGER_PROCESSOR 0x00000000 // Processor event
  46. #define ADC_TRIGGER_COMP0 0x00000001 // Analog comparator 0 event
  47. #define ADC_TRIGGER_COMP1 0x00000002 // Analog comparator 1 event
  48. #define ADC_TRIGGER_COMP2 0x00000003 // Analog comparator 2 event
  49. #define ADC_TRIGGER_EXTERNAL 0x00000004 // External event
  50. #define ADC_TRIGGER_TIMER 0x00000005 // Timer event
  51. #define ADC_TRIGGER_PWM0 0x00000006 // PWM0 event
  52. #define ADC_TRIGGER_PWM1 0x00000007 // PWM1 event
  53. #define ADC_TRIGGER_PWM2 0x00000008 // PWM2 event
  54. #define ADC_TRIGGER_ALWAYS 0x0000000F // Always event
  55. //*****************************************************************************
  56. //
  57. // Values that can be passed to ADCSequenceStepConfigure as the ulConfig
  58. // parameter.
  59. //
  60. //*****************************************************************************
  61. #define ADC_CTL_TS 0x00000080 // Temperature sensor select
  62. #define ADC_CTL_IE 0x00000040 // Interrupt enable
  63. #define ADC_CTL_END 0x00000020 // Sequence end select
  64. #define ADC_CTL_D 0x00000010 // Differential select
  65. #define ADC_CTL_CH0 0x00000000 // Input channel 0
  66. #define ADC_CTL_CH1 0x00000001 // Input channel 1
  67. #define ADC_CTL_CH2 0x00000002 // Input channel 2
  68. #define ADC_CTL_CH3 0x00000003 // Input channel 3
  69. #define ADC_CTL_CH4 0x00000004 // Input channel 4
  70. #define ADC_CTL_CH5 0x00000005 // Input channel 5
  71. #define ADC_CTL_CH6 0x00000006 // Input channel 6
  72. #define ADC_CTL_CH7 0x00000007 // Input channel 7
  73. #define ADC_CTL_CH8 0x00000008 // Input channel 8
  74. #define ADC_CTL_CH9 0x00000009 // Input channel 9
  75. #define ADC_CTL_CH10 0x0000000A // Input channel 10
  76. #define ADC_CTL_CH11 0x0000000B // Input channel 11
  77. #define ADC_CTL_CH12 0x0000000C // Input channel 12
  78. #define ADC_CTL_CH13 0x0000000D // Input channel 13
  79. #define ADC_CTL_CH14 0x0000000E // Input channel 14
  80. #define ADC_CTL_CH15 0x0000000F // Input channel 15
  81. #define ADC_CTL_CMP0 0x00080000 // Select Comparator 0
  82. #define ADC_CTL_CMP1 0x00090000 // Select Comparator 1
  83. #define ADC_CTL_CMP2 0x000A0000 // Select Comparator 2
  84. #define ADC_CTL_CMP3 0x000B0000 // Select Comparator 3
  85. #define ADC_CTL_CMP4 0x000C0000 // Select Comparator 4
  86. #define ADC_CTL_CMP5 0x000D0000 // Select Comparator 5
  87. #define ADC_CTL_CMP6 0x000E0000 // Select Comparator 6
  88. #define ADC_CTL_CMP7 0x000F0000 // Select Comparator 7
  89. //*****************************************************************************
  90. //
  91. // Values that can be passed to ADCComparatorConfigure as part of the
  92. // ulConfig parameter.
  93. //
  94. //*****************************************************************************
  95. #define ADC_COMP_TRIG_NONE 0x00000000 // Trigger Disabled
  96. #define ADC_COMP_TRIG_LOW_ALWAYS \
  97. 0x00001000 // Trigger Low Always
  98. #define ADC_COMP_TRIG_LOW_ONCE 0x00001100 // Trigger Low Once
  99. #define ADC_COMP_TRIG_LOW_HALWAYS \
  100. 0x00001200 // Trigger Low Always (Hysteresis)
  101. #define ADC_COMP_TRIG_LOW_HONCE 0x00001300 // Trigger Low Once (Hysteresis)
  102. #define ADC_COMP_TRIG_MID_ALWAYS \
  103. 0x00001400 // Trigger Mid Always
  104. #define ADC_COMP_TRIG_MID_ONCE 0x00001500 // Trigger Mid Once
  105. #define ADC_COMP_TRIG_HIGH_ALWAYS \
  106. 0x00001C00 // Trigger High Always
  107. #define ADC_COMP_TRIG_HIGH_ONCE 0x00001D00 // Trigger High Once
  108. #define ADC_COMP_TRIG_HIGH_HALWAYS \
  109. 0x00001E00 // Trigger High Always (Hysteresis)
  110. #define ADC_COMP_TRIG_HIGH_HONCE \
  111. 0x00001F00 // Trigger High Once (Hysteresis)
  112. #define ADC_COMP_INT_NONE 0x00000000 // Interrupt Disabled
  113. #define ADC_COMP_INT_LOW_ALWAYS \
  114. 0x00000010 // Interrupt Low Always
  115. #define ADC_COMP_INT_LOW_ONCE 0x00000011 // Interrupt Low Once
  116. #define ADC_COMP_INT_LOW_HALWAYS \
  117. 0x00000012 // Interrupt Low Always
  118. // (Hysteresis)
  119. #define ADC_COMP_INT_LOW_HONCE 0x00000013 // Interrupt Low Once (Hysteresis)
  120. #define ADC_COMP_INT_MID_ALWAYS \
  121. 0x00000014 // Interrupt Mid Always
  122. #define ADC_COMP_INT_MID_ONCE 0x00000015 // Interrupt Mid Once
  123. #define ADC_COMP_INT_HIGH_ALWAYS \
  124. 0x0000001C // Interrupt High Always
  125. #define ADC_COMP_INT_HIGH_ONCE 0x0000001D // Interrupt High Once
  126. #define ADC_COMP_INT_HIGH_HALWAYS \
  127. 0x0000001E // Interrupt High Always
  128. // (Hysteresis)
  129. #define ADC_COMP_INT_HIGH_HONCE \
  130. 0x0000001F // Interrupt High Once (Hysteresis)
  131. //*****************************************************************************
  132. //
  133. // Prototypes for the APIs.
  134. //
  135. //*****************************************************************************
  136. extern void ADCIntRegister(unsigned long ulBase, unsigned long ulSequenceNum,
  137. void (*pfnHandler)(void));
  138. extern void ADCIntUnregister(unsigned long ulBase,
  139. unsigned long ulSequenceNum);
  140. extern void ADCIntDisable(unsigned long ulBase, unsigned long ulSequenceNum);
  141. extern void ADCIntEnable(unsigned long ulBase, unsigned long ulSequenceNum);
  142. extern unsigned long ADCIntStatus(unsigned long ulBase,
  143. unsigned long ulSequenceNum,
  144. tBoolean bMasked);
  145. extern void ADCIntClear(unsigned long ulBase, unsigned long ulSequenceNum);
  146. extern void ADCSequenceEnable(unsigned long ulBase,
  147. unsigned long ulSequenceNum);
  148. extern void ADCSequenceDisable(unsigned long ulBase,
  149. unsigned long ulSequenceNum);
  150. extern void ADCSequenceConfigure(unsigned long ulBase,
  151. unsigned long ulSequenceNum,
  152. unsigned long ulTrigger,
  153. unsigned long ulPriority);
  154. extern void ADCSequenceStepConfigure(unsigned long ulBase,
  155. unsigned long ulSequenceNum,
  156. unsigned long ulStep,
  157. unsigned long ulConfig);
  158. extern long ADCSequenceOverflow(unsigned long ulBase,
  159. unsigned long ulSequenceNum);
  160. extern void ADCSequenceOverflowClear(unsigned long ulBase,
  161. unsigned long ulSequenceNum);
  162. extern long ADCSequenceUnderflow(unsigned long ulBase,
  163. unsigned long ulSequenceNum);
  164. extern void ADCSequenceUnderflowClear(unsigned long ulBase,
  165. unsigned long ulSequenceNum);
  166. extern long ADCSequenceDataGet(unsigned long ulBase,
  167. unsigned long ulSequenceNum,
  168. unsigned long *pulBuffer);
  169. extern void ADCProcessorTrigger(unsigned long ulBase,
  170. unsigned long ulSequenceNum);
  171. extern void ADCSoftwareOversampleConfigure(unsigned long ulBase,
  172. unsigned long ulSequenceNum,
  173. unsigned long ulFactor);
  174. extern void ADCSoftwareOversampleStepConfigure(unsigned long ulBase,
  175. unsigned long ulSequenceNum,
  176. unsigned long ulStep,
  177. unsigned long ulConfig);
  178. extern void ADCSoftwareOversampleDataGet(unsigned long ulBase,
  179. unsigned long ulSequenceNum,
  180. unsigned long *pulBuffer,
  181. unsigned long ulCount);
  182. extern void ADCHardwareOversampleConfigure(unsigned long ulBase,
  183. unsigned long ulFactor);
  184. extern void ADCComparatorConfigure(unsigned long ulBase, unsigned long ulComp,
  185. unsigned long ulConfig);
  186. extern void ADCComparatorRegionSet(unsigned long ulBase, unsigned long ulComp,
  187. unsigned long ulLowRef,
  188. unsigned long ulHighRef);
  189. extern void ADCComparatorReset(unsigned long ulBase, unsigned long ulComp,
  190. tBoolean bTrigger, tBoolean bInterrupt);
  191. extern void ADCComparatorIntDisable(unsigned long ulBase,
  192. unsigned long ulSequenceNum);
  193. extern void ADCComparatorIntEnable(unsigned long ulBase,
  194. unsigned long ulSequenceNum);
  195. extern unsigned long ADCComparatorIntStatus(unsigned long ulBase);
  196. extern void ADCComparatorIntClear(unsigned long ulBase,
  197. unsigned long ulStatus);
  198. //*****************************************************************************
  199. //
  200. // Mark the end of the C bindings section for C++ compilers.
  201. //
  202. //*****************************************************************************
  203. #ifdef __cplusplus
  204. }
  205. #endif
  206. #endif // __ADC_H__