SysIo  1.9.0
Embedded Library and tools
adc.h
1 
8 #ifndef _CHIPIO_ADC_H_
9 #define _CHIPIO_ADC_H_
10 
11 #include <chipio/chipio.h>
12 
13 #ifdef __cplusplus
14  extern "C" {
15 #endif
16 /* ========================================================================== */
17 
28 /* constants ================================================================ */
32 typedef enum {
33  eAdcRefExternal = 0x00,
34  eAdcRefVcc = 0x01,
35  eAdcRefInternal = 0x03,
36  eAdcRefUnknown = -1,
37 } eAdcRef;
38 
51 typedef enum {
52  eAdcDiv2 = 2,
53  eAdcDiv4 = 4,
54  eAdcDiv8 = 8,
55  eAdcDiv16 = 16,
56  eAdcDiv32 = 32,
57  eAdcDiv64 = 64,
58  eAdcDiv128 = 128,
59  eAdcDivUnknown = -1
60 } eAdcDiv;
61 
62 
63 /* structures =============================================================== */
64 
70 typedef struct xChipIoAdc xChipIoAdc;
71 
72 /* internal public functions ================================================ */
73 
84 
90 void vChipIoAdcClose (xChipIoAdc * xAdc);
91 
99 int iChipIoAdcRead (unsigned input, xChipIoAdc * xAdc);
100 
108 
117 
125 
134 
135 
136 #if defined(__DOXYGEN__)
137 /* macros =================================================================== */
145 #define ADC_VALUE(MEASUREMENT,FULL_SCALE)
146 
154 #define ADC_MEASUREMENT(VALUE,FULL_SCALE)
155 
161 #else /* __DOXYGEN__ not defined */
162 /* ========================================================================== */
163 
164 /* macros =================================================================== */
165 #define ADC_VALUE(_MEASUREMENT,_FULL_SCALE) \
166  ((uint16_t)(((_MEASUREMENT)*1024.0)/(_FULL_SCALE)))
167 
168 #define ADC_MEASUREMENT(_VALUE,_FULL_SCALE) \
169  ((((double)(_VALUE))*((double)(_FULL_SCALE)))/1024.0)
170 
171 #endif /* __DOXYGEN__ not defined */
172 
173 /* ========================================================================== */
174 #ifdef __cplusplus
175  }
176 #endif
177 #endif /* _CHIPIO_ADC_H_ */
struct xChipIoAdc xChipIoAdc
Definition: adc.h:70
int iChipIoAdcRead(unsigned input, xChipIoAdc *xAdc)
eAdcRef
Definition: adc.h:32
void vChipIoAdcClose(xChipIoAdc *xAdc)
eAdcDiv eChipIoAdcSetDiv(eAdcDiv eDiv, xChipIoAdc *xAdc)
struct xChipIo xChipIo
Definition: chipio.h:43
xChipIoAdc * xChipIoAdcOpen(xChipIo *xChip)
eAdcDiv
Definition: adc.h:51
Definition: adc.h:34
eAdcDiv eChipIoAdcDiv(xChipIoAdc *xAdc)
eAdcRef eChipIoAdcSetRef(eAdcRef eRef, xChipIoAdc *xAdc)
eAdcRef eChipIoAdcRef(xChipIoAdc *xAdc)