no-OS
adc_demo.h
Go to the documentation of this file.
1 /***************************************************************************/
34 #ifndef IIO_DEMO_ADC_
35 #define IIO_DEMO_ADC_
36 
37 /******************************************************************************/
38 /***************************** Include Files **********************************/
39 /******************************************************************************/
40 
41 #include <stdint.h>
42 #include "iio_types.h"
43 #include "no_os_irq.h"
44 
45 /******************************************************************************/
46 /*************************** Types Declarations *******************************/
47 /******************************************************************************/
48 
49 #define MAX_ADC_ADDR 16
50 /* For testing a maximum of 16 channels can be enabled */
51 #ifndef TOTAL_ADC_CHANNELS
52 #define TOTAL_ADC_CHANNELS 2
53 #endif
54 
59 struct adc_demo_desc {
61  uint8_t reg[MAX_ADC_ADDR];
63  uint32_t adc_global_attr;
67  uint32_t active_ch;
69  uint32_t ext_buff_len;
71  uint16_t **ext_buff;
72 };
73 
80  uint32_t dev_global_attr;
84  uint32_t ext_buff_len;
86  uint16_t **ext_buff;
87 };
88 
92 };
93 
94 extern const uint16_t sine_lut[128];
95 
96 /******************************************************************************/
97 /************************ Functions Declarations ******************************/
98 /******************************************************************************/
99 
100 int32_t adc_demo_init(struct adc_demo_desc **desc,
101  struct adc_demo_init_param *param);
102 
103 int32_t adc_demo_remove(struct adc_demo_desc *desc);
104 
105 int32_t update_adc_channels(void *dev, uint32_t mask);
106 
107 int32_t close_adc_channels(void* dev);
108 
109 int32_t adc_submit_samples(struct iio_device_data *dev_data);
110 
111 int32_t adc_demo_reg_read(struct adc_demo_desc *desc, uint8_t reg_index,
112  uint8_t *readval);
113 
114 int32_t adc_demo_reg_write(struct adc_demo_desc *desc, uint8_t reg_index,
115  uint8_t writeval);
116 
117 int32_t adc_demo_trigger_handler(struct iio_device_data *dev_data);
118 
119 #endif /*IIO_DEMO_ADC_*/
ADC_CHANNEL_ATTR
@ ADC_CHANNEL_ATTR
Definition: adc_demo.h:90
adc_demo_remove
int32_t adc_demo_remove(struct adc_demo_desc *desc)
free allocated resources
Definition: adc_demo.c:100
no_os_alloc.h
adc_demo_init
int32_t adc_demo_init(struct adc_demo_desc **desc, struct adc_demo_init_param *param)
init function for the adc demo driver
Definition: adc_demo.c:76
adc_demo_init_param::ext_buff_len
uint32_t ext_buff_len
Definition: adc_demo.h:84
no_os_irq.h
Header file of IRQ interface.
update_adc_channels
int32_t update_adc_channels(void *dev, uint32_t mask)
active adc channels
Definition: adc_demo.c:116
adc_demo_init_param::ext_buff
uint16_t ** ext_buff
Definition: adc_demo.h:86
adc_demo_desc::ext_buff
uint16_t ** ext_buff
Definition: adc_demo.h:71
no_os_calloc
void * no_os_calloc(size_t nitems, size_t size)
Allocate memory and return a pointer to it, set memory to 0.
Definition: chibios_alloc.c:54
NO_OS_ARRAY_SIZE
#define NO_OS_ARRAY_SIZE(x)
Definition: no_os_util.h:49
TOTAL_ADC_CHANNELS
#define TOTAL_ADC_CHANNELS
Definition: adc_demo.h:52
adc_demo_desc::adc_global_attr
uint32_t adc_global_attr
Definition: adc_demo.h:63
no_os_error.h
Error codes definition.
adc_demo_trigger_handler
int32_t adc_demo_trigger_handler(struct iio_device_data *dev_data)
Handles trigger: reads one data-set and writes it to the buffer.
Definition: iio_adc_demo.c:182
close_adc_channels
int32_t close_adc_channels(void *dev)
close all channels
Definition: adc_demo.c:136
ADC_GLOBAL_ATTR
@ ADC_GLOBAL_ATTR
Definition: adc_demo.h:91
adc_demo.h
Header file of ADC Demo Driver.
adc_demo_desc::adc_ch_attr
uint32_t adc_ch_attr[MAX_ADC_ADDR]
Definition: adc_demo.h:65
adc_demo_desc::active_ch
uint32_t active_ch
Definition: adc_demo.h:67
close_adc_channels
int32_t close_adc_channels(void *dev)
close all channels
Definition: adc_demo.c:136
adc_demo_desc::ext_buff_len
uint32_t ext_buff_len
Definition: adc_demo.h:69
adc_demo_reg_read
int32_t adc_demo_reg_read(struct adc_demo_desc *desc, uint8_t reg_index, uint8_t *readval)
read function for the adc demo driver
Definition: adc_demo.c:157
iio_adc_demo_attributes
iio_adc_demo_attributes
Definition: adc_demo.h:89
adc_demo_reg_read
int32_t adc_demo_reg_read(struct adc_demo_desc *desc, uint8_t reg_index, uint8_t *readval)
read function for the adc demo driver
Definition: adc_demo.c:157
iio_types.h
Header file for iio_types.
no_os_free
void no_os_free(void *ptr)
Deallocate memory previously allocated by a call to no_os_calloc or no_os_malloc.
Definition: chibios_alloc.c:69
adc_demo_init_param::dev_global_attr
uint32_t dev_global_attr
Definition: adc_demo.h:80
update_adc_channels
int32_t update_adc_channels(void *dev, uint32_t mask)
active adc channels
Definition: adc_demo.c:116
adc_demo_desc
Definition: adc_demo.h:59
adc_submit_samples
int32_t adc_submit_samples(struct iio_device_data *dev_data)
function for reading samples from the device.
Definition: iio_adc_demo.c:137
adc_demo_desc::reg
uint8_t reg[MAX_ADC_ADDR]
Definition: adc_demo.h:61
adc_demo_reg_write
int32_t adc_demo_reg_write(struct adc_demo_desc *desc, uint8_t reg_index, uint8_t writeval)
write function for the adc demo driver
Definition: adc_demo.c:175
adc_demo_init_param::dev_ch_attr
uint32_t dev_ch_attr[MAX_ADC_ADDR]
Definition: adc_demo.h:82
sine_lut
const uint16_t sine_lut[128]
Definition: adc_demo.c:47
adc_demo_reg_write
int32_t adc_demo_reg_write(struct adc_demo_desc *desc, uint8_t reg_index, uint8_t writeval)
write function for the adc demo driver
Definition: adc_demo.c:175
MAX_ADC_ADDR
#define MAX_ADC_ADDR
Definition: adc_demo.h:49
adc_demo_init
int32_t adc_demo_init(struct adc_demo_desc **desc, struct adc_demo_init_param *param)
init function for the adc demo driver
Definition: adc_demo.c:76
adc_demo_remove
int32_t adc_demo_remove(struct adc_demo_desc *desc)
free allocated resources
Definition: adc_demo.c:100
no_os_util.h
Header file of utility functions.
iio_device_data
Definition: iio_types.h:226
adc_demo_init_param
Definition: adc_demo.h:78
sine_lut
const uint16_t sine_lut[128]
Definition: adc_demo.c:47