Kamcho Library 02.00.03  lib.kamcho.02.00.03.287
adc_device.h
Go to the documentation of this file.
1 
12 #ifndef __ADC_DEVICE_H__
13 #define __ADC_DEVICE_H__
14 
15 #include <stdint.h>
16 #include "hdf.h"
17 
21 typedef const struct ADC_Device_t {
22  void (*SelectChannel)(uint8_t channel);
23  void (*ClkDiv)(uint8_t div);
24  void (*SampleCycle)(uint8_t val);
25  uint8_t (*Read)(void);
26  void (*Start)(void);
27  void (*SetReferenceHigh)(uint8_t val);
28  void (*SetReferenceLow)(uint8_t val);
29  void (*SetReferenceGain)(uint8_t val);
30  uint8_t (*ConversionInProgress)(void);
31  void (*SetRefSourceVDD)(void);
32  void (*SetRefSourceBandGap)(void);
33  void (*SetStreamingMode)(void);
34  void (*SetSingleMode)(void);
35  void (*SetCalibrationMode)(void);
36  void (*SetNormalMode)(void);
37  const char *Name;
38 } ADC_Device_t;
39 
43 #define ADC_MODE_STREAM ((uint32_t)(1<<0))
44 #define ADC_MODE_SINGLE ((uint32_t)(1<<1))
45 #define ADC_MODE_NORMAL ((uint32_t)(1<<2))
46 #define ADC_MODE_CALIBRATION ((uint32_t)(1<<3))
47 #define ADC_MODE_REF_VDD ((uint32_t)(1<<4))
48 #define ADC_MODE_REF_BANDGAP ((uint32_t)(1<<5))
49 
57 int32_t ADC_devSelectChannel(ADC_Device_t *dev, uint8_t channel);
58 
66 int32_t ADC_devRead(ADC_Device_t *dev, uint8_t *val);
67 
76 int32_t ADC_devTake(ADC_Device_t *dev, uint8_t channel, uint8_t *val);
77 
84 int32_t ADC_devStart(ADC_Device_t *dev);
85 
93 
103 int32_t ADC_devConfigReference(ADC_Device_t *dev, uint8_t refh, uint8_t refl, uint8_t refg);
104 
114 int32_t ADC_devInit(ADC_Device_t *dev, uint8_t div, uint8_t cycle, uint32_t mode);
115 
122 ADC_Device_t *ADC_devRequest(const char *name);
123 
124 #endif /* __ADC_DEVICE_H__ */
ADC_Device_t * ADC_devRequest(const char *name)
ADC Request Device.
Definition: adc_device.c:136
int32_t ADC_devStart(ADC_Device_t *dev)
Start a ADC conversion.
Definition: adc_device.c:69
void(* SetReferenceGain)(uint8_t val)
Definition: adc_device.h:29
void(* SetCalibrationMode)(void)
Definition: adc_device.h:35
void(* SetRefSourceVDD)(void)
Definition: adc_device.h:31
const char * Name
Definition: adc_device.h:37
void(* SampleCycle)(uint8_t val)
Definition: adc_device.h:24
void(* SetReferenceLow)(uint8_t val)
Definition: adc_device.h:28
int32_t ADC_devInit(ADC_Device_t *dev, uint8_t div, uint8_t cycle, uint32_t mode)
Initialize ADC device.
Definition: adc_device.c:97
void(* SetRefSourceBandGap)(void)
Definition: adc_device.h:32
void(* SelectChannel)(uint8_t channel)
Definition: adc_device.h:22
void(* SetNormalMode)(void)
Definition: adc_device.h:36
int32_t ADC_devConfigReference(ADC_Device_t *dev, uint8_t refh, uint8_t refl, uint8_t refg)
Initialize ADC reference settings. It sets the dynamic range and the gain.
Definition: adc_device.c:126
const struct ADC_Device_t ADC_Device_t
A structure to represent ADC device.
void(* SetStreamingMode)(void)
Definition: adc_device.h:33
void(* SetReferenceHigh)(uint8_t val)
Definition: adc_device.h:27
uint8_t(* Read)(void)
Definition: adc_device.h:25
A structure to represent ADC device.
Definition: adc_device.h:21
int32_t ADC_devRead(ADC_Device_t *dev, uint8_t *val)
Read ADC result from a ADC device.
Definition: adc_device.c:61
void(* Start)(void)
Definition: adc_device.h:26
int32_t ADC_devSelectChannel(ADC_Device_t *dev, uint8_t channel)
Select ADC channel for a ADC device.
Definition: adc_device.c:53
int32_t ADC_devTake(ADC_Device_t *dev, uint8_t channel, uint8_t *val)
Start a ADC conversion, wait for its completion and read result back.
Definition: adc_device.c:85
uint8_t(* ConversionInProgress)(void)
Definition: adc_device.h:30
int32_t ADC_devConversionInProgress(ADC_Device_t *dev)
Check status of a ADC conversion.
Definition: adc_device.c:78
void(* ClkDiv)(uint8_t div)
Definition: adc_device.h:23
void(* SetSingleMode)(void)
Definition: adc_device.h:34