Xenomai  3.0.8
analogy.h
Go to the documentation of this file.
1 
21 #ifndef _RTDM_ANALOGY_H
22 #define _RTDM_ANALOGY_H
23 
24 #include <stdio.h>
25 #include <sys/types.h>
26 #include <rtdm/uapi/analogy.h>
27 
28 #include "boilerplate/list.h"
29 
45 #define A4L_BSC_DESC 0x0
46 
51 #define A4L_CPLX_DESC 0x1
52 
55 /* --- Descriptor structure --- */
56 
63  char board_name[A4L_NAMELEN];
65  char driver_name[A4L_NAMELEN];
67  int nb_subd;
73  int fd;
75  unsigned int magic;
77  int sbsize;
79  void *sbdata;
81 };
82 typedef struct a4l_descriptor a4l_desc_t;
83 
86 #ifdef __cplusplus
87 extern "C" {
88 #endif
89 
90 #ifndef DOXYGEN_CPP
91 
92 /* --- Level 0 API (not supposed to be used) --- */
93 
94 int a4l_sys_open(const char *fname);
95 
96 int a4l_sys_close(int fd);
97 
98 int a4l_sys_read(int fd, void *buf, size_t nbyte);
99 
100 int a4l_sys_write(int fd, void *buf, size_t nbyte);
101 
102 int a4l_sys_attach(int fd, a4l_lnkdesc_t *arg);
103 
104 int a4l_sys_detach(int fd);
105 
106 int a4l_sys_bufcfg(int fd, unsigned int idx_subd, unsigned long size);
107 
108 int a4l_sys_desc(int fd, a4l_desc_t *dsc, int pass);
109 
110 int a4l_sys_devinfo(int fd, a4l_dvinfo_t *info);
111 
112 int a4l_sys_subdinfo(int fd, a4l_sbinfo_t *info);
113 
114 int a4l_sys_nbchaninfo(int fd, unsigned int idx_subd, unsigned int *nb);
115 
116 int a4l_sys_chaninfo(int fd,
117  unsigned int idx_subd, a4l_chinfo_t *info);
118 
119 int a4l_sys_nbrnginfo(int fd,
120  unsigned int idx_subd,
121  unsigned int idx_chan, unsigned int *nb);
122 
123 int a4l_sys_rnginfo(int fd,
124  unsigned int idx_subd,
125  unsigned int idx_chan, a4l_rnginfo_t *info);
126 
127 /* --- Level 1 API (supposed to be used) --- */
128 
129 int a4l_get_desc(int fd, a4l_desc_t *dsc, int pass);
130 
131 int a4l_open(a4l_desc_t *dsc, const char *fname);
132 
133 int a4l_close(a4l_desc_t *dsc);
134 
135 int a4l_fill_desc(a4l_desc_t *dsc);
136 
138  unsigned int subd, a4l_sbinfo_t **info);
139 
140 int a4l_get_chinfo(a4l_desc_t *dsc,
141  unsigned int subd,
142  unsigned int chan, a4l_chinfo_t **info);
143 
144 #define a4l_get_chan_max(x) (1ULL << (x)->nb_bits)
145 
146 #define a4l_is_chan_global(x) ((x)->chan_flags & A4L_CHAN_GLOBAL)
147 
148 int a4l_get_rnginfo(a4l_desc_t *dsc,
149  unsigned int subd,
150  unsigned int chan,
151  unsigned int rng, a4l_rnginfo_t **info);
152 
153 #define a4l_is_rng_global(x) ((x)->flags & A4L_RNG_GLOBAL)
154 
155 int a4l_snd_command(a4l_desc_t *dsc, struct a4l_cmd_desc *cmd);
156 
157 int a4l_snd_cancel(a4l_desc_t *dsc, unsigned int idx_subd);
158 
159 int a4l_set_bufsize(a4l_desc_t *dsc,
160  unsigned int idx_subd, unsigned long size);
161 
162 int a4l_get_bufsize(a4l_desc_t *dsc,
163  unsigned int idx_subd, unsigned long *size);
164 
165 int a4l_set_wakesize(a4l_desc_t *dsc, unsigned long size);
166 
167 int a4l_get_wakesize(a4l_desc_t *dsc, unsigned long *size);
168 
169 int a4l_mark_bufrw(a4l_desc_t *dsc,
170  unsigned int idx_subd,
171  unsigned long cur, unsigned long *newp);
172 
173 int a4l_poll(a4l_desc_t *dsc,
174  unsigned int idx_subd, unsigned long ms_timeout);
175 
176 int a4l_mmap(a4l_desc_t *dsc,
177  unsigned int idx_subd, unsigned long size, void **ptr);
178 
179 int a4l_async_read(a4l_desc_t *dsc,
180  void *buf, size_t nbyte, unsigned long ms_timeout);
181 
182 int a4l_async_write(a4l_desc_t *dsc,
183  void *buf, size_t nbyte, unsigned long ms_timeout);
184 
186 
187 int a4l_snd_insn(a4l_desc_t *dsc, a4l_insn_t *arg);
188 
189 /* --- Level 2 API (supposed to be used) --- */
190 
191 int a4l_sync_write(a4l_desc_t *dsc,
192  unsigned int idx_subd,
193  unsigned int chan_desc,
194  unsigned int delay, void *buf, size_t nbyte);
195 
196 int a4l_sync_read(a4l_desc_t *dsc,
197  unsigned int idx_subd,
198  unsigned int chan_desc,
199  unsigned int delay, void *buf, size_t nbyte);
200 
201 int a4l_config_subd(a4l_desc_t *dsc,
202  unsigned int idx_subd, unsigned int type, ...);
203 
204 int a4l_sync_dio(a4l_desc_t *dsc,
205  unsigned int idx_subd, void *mask, void *buf);
206 
207 int a4l_sizeof_chan(a4l_chinfo_t *chan);
208 
209 int a4l_sizeof_subd(a4l_sbinfo_t *subd);
210 
211 int a4l_find_range(a4l_desc_t *dsc,
212  unsigned int idx_subd,
213  unsigned int idx_chan,
214  unsigned long unit,
215  double min, double max, a4l_rnginfo_t **rng);
216 
217 int a4l_rawtoul(a4l_chinfo_t *chan, unsigned long *dst, void *src, int cnt);
218 
219 int a4l_rawtof(a4l_chinfo_t *chan,
220  a4l_rnginfo_t *rng, float *dst, void *src, int cnt);
221 
222 int a4l_rawtod(a4l_chinfo_t *chan,
223  a4l_rnginfo_t *rng, double *dst, void *src, int cnt);
224 
225 int a4l_ultoraw(a4l_chinfo_t *chan, void *dst, unsigned long *src, int cnt);
226 
227 int a4l_ftoraw(a4l_chinfo_t *chan,
228  a4l_rnginfo_t *rng, void *dst, float *src, int cnt);
229 
230 int a4l_dtoraw(a4l_chinfo_t *chan,
231  a4l_rnginfo_t *rng, void *dst, double *src, int cnt);
232 
233 int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data);
234 
235 int a4l_get_softcal_converter(struct a4l_polynomial *converter,
236  int subd, int chan, int range,
237  struct a4l_calibration_data *data );
238 
239 int a4l_rawtodcal(a4l_chinfo_t *chan, double *dst, void *src,
240  int cnt, struct a4l_polynomial *converter);
241 int a4l_dcaltoraw(a4l_chinfo_t * chan, void *dst, double *src, int cnt,
242  struct a4l_polynomial *converter);
243 
244 int a4l_math_polyfit(unsigned order, double *r,double orig,
245  const unsigned dim, double *x, double *y);
246 
247 void a4l_math_mean(double *pmean, double *val, unsigned nr);
248 
249 void a4l_math_stddev(double *pstddev,
250  double mean, double *val, unsigned nr);
251 
252 void a4l_math_stddev_of_mean(double *pstddevm,
253  double mean, double *val, unsigned nr);
254 
255 
256 
257 
258 #endif /* !DOXYGEN_CPP */
259 
260 #ifdef __cplusplus
261 }
262 #endif
263 
264 #endif /* !_RTDM_ANALOGY_H */
int a4l_rawtod(a4l_chinfo_t *chan, a4l_rnginfo_t *rng, double *dst, void *src, int cnt)
Convert raw data (from the driver) to double-typed samples.
Definition: range.c:381
int a4l_sys_write(int fd, void *buf, size_t nbyte)
Write to an Analogy device.
Definition: sys.c:121
int a4l_get_bufsize(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long *size)
Get the size of the asynchronous buffer.
Definition: async.c:184
int a4l_sys_open(const char *fname)
Open an Analogy device.
Definition: sys.c:58
Structure describing the asynchronous instruction.
Definition: analogy.h:289
int a4l_sizeof_subd(a4l_sbinfo_t *subd)
Get the size in memory of a digital acquired element.
Definition: range.c:121
char driver_name[A4L_NAMELEN]
Driver name.
Definition: analogy.h:65
void a4l_math_stddev_of_mean(double *pstddevm, double mean, double *val, unsigned nr)
Calculate the standard deviation of the mean.
Definition: math.c:450
int a4l_rawtof(a4l_chinfo_t *chan, a4l_rnginfo_t *rng, float *dst, void *src, int cnt)
Convert raw data (from the driver) to float-typed samples.
Definition: range.c:308
int a4l_sizeof_chan(a4l_chinfo_t *chan)
Get the size in memory of an acquired element.
Definition: range.c:85
unsigned int magic
Opaque field.
Definition: analogy.h:75
Structure containing device-information useful to users.
Definition: analogy.h:62
int a4l_set_bufsize(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long size)
Change the size of the asynchronous buffer.
Definition: async.c:121
int a4l_get_chinfo(a4l_desc_t *dsc, unsigned int subd, unsigned int chan, a4l_chinfo_t **info)
Get an information structure on a specified channel.
Definition: descriptor.c:427
int a4l_sync_write(a4l_desc_t *dsc, unsigned int idx_subd, unsigned int chan_desc, unsigned int ns_delay, void *buf, size_t nbyte)
Perform a synchronous acquisition write operation.
Definition: sync.c:130
int a4l_poll(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long ms_timeout)
Get the available data count.
Definition: async.c:286
int a4l_dcaltoraw(a4l_chinfo_t *chan, void *dst, double *src, int cnt, struct a4l_polynomial *converter)
Convert double values to raw calibrated data using polynomials.
Definition: calibration.c:420
int idx_read_subd
Input subdevice index.
Definition: analogy.h:69
int a4l_get_softcal_converter(struct a4l_polynomial *converter, int subd, int chan, int range, struct a4l_calibration_data *data)
Get the polynomial that will be use for the software calibration.
Definition: calibration.c:290
int a4l_sys_bufcfg(int fd, unsigned int idx_subd, unsigned long size)
Configure the buffer size.
Definition: sys.c:206
int nb_subd
Subdevices count.
Definition: analogy.h:67
int idx_write_subd
Output subdevice index.
Definition: analogy.h:71
int a4l_get_subdinfo(a4l_desc_t *dsc, unsigned int subd, a4l_sbinfo_t **info)
Get an information structure on a specified subdevice.
Definition: descriptor.c:390
int a4l_open(a4l_desc_t *dsc, const char *fname)
Open an Analogy device and basically fill the descriptor.
Definition: descriptor.c:294
int a4l_mark_bufrw(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long cur, unsigned long *new)
Update the asynchronous buffer state.
Definition: async.c:244
void a4l_math_mean(double *pmean, double *val, unsigned nr)
Calculate the aritmetic mean of an array of values.
Definition: math.c:407
int a4l_sync_read(a4l_desc_t *dsc, unsigned int idx_subd, unsigned int chan_desc, unsigned int ns_delay, void *buf, size_t nbyte)
Perform a synchronous acquisition read operation.
Definition: sync.c:203
int a4l_read_calibration_file(char *name, struct a4l_calibration_data *data)
Read the analogy generated calibration file.
Definition: calibration.c:203
int a4l_sys_detach(int fd)
Detach an Analogy device from a driver.
Definition: sys.c:175
int a4l_dtoraw(a4l_chinfo_t *chan, a4l_rnginfo_t *rng, void *dst, double *src, int cnt)
Convert double-typed samples to raw data (for the driver)
Definition: range.c:587
int a4l_sys_attach(int fd, a4l_lnkdesc_t *arg)
Attach an Analogy device to a driver.
Definition: sys.c:152
int a4l_get_rnginfo(a4l_desc_t *dsc, unsigned int subd, unsigned int chan, unsigned int rng, a4l_rnginfo_t **info)
Get an information structure on a specified range.
Definition: descriptor.c:471
int a4l_rawtodcal(a4l_chinfo_t *chan, double *dst, void *src, int cnt, struct a4l_polynomial *converter)
Convert raw data (from the driver) to calibrated double units.
Definition: calibration.c:348
int a4l_sys_desc(int fd, a4l_desc_t *dsc, int pass)
Get a descriptor on an attached device.
Definition: descriptor.c:234
int a4l_sync_dio(a4l_desc_t *dsc, unsigned int idx_subd, void *mask, void *buf)
Perform a synchronous acquisition digital acquisition.
Definition: sync.c:274
char board_name[A4L_NAMELEN]
Board name.
Definition: analogy.h:63
int a4l_rawtoul(a4l_chinfo_t *chan, unsigned long *dst, void *src, int cnt)
Unpack raw data (from the driver) into unsigned long values.
Definition: range.c:248
void * sbdata
Data buffer pointer.
Definition: analogy.h:79
int a4l_async_write(a4l_desc_t *dsc, void *buf, size_t nbyte, unsigned long ms_timeout)
Perform asynchronous write operation on the analog input subdevice.
Definition: async.c:441
Structure describing the synchronous instruction.
Definition: analogy.h:680
int a4l_ftoraw(a4l_chinfo_t *chan, a4l_rnginfo_t *rng, void *dst, float *src, int cnt)
Convert float-typed samples to raw data (for the driver)
Definition: range.c:517
int sbsize
Data buffer size.
Definition: analogy.h:77
int a4l_sys_read(int fd, void *buf, size_t nbyte)
Read from an Analogy device.
Definition: sys.c:96
int a4l_snd_command(a4l_desc_t *dsc, a4l_cmd_t *cmd)
Send a command to an Analoy device.
Definition: async.c:54
int a4l_ultoraw(a4l_chinfo_t *chan, void *dst, unsigned long *src, int cnt)
Pack unsigned long values into raw data (for the driver)
Definition: range.c:457
void a4l_math_stddev(double *pstddev, double mean, double *val, unsigned nr)
Calculate the standard deviation of an array of values.
Definition: math.c:427
int fd
File descriptor.
Definition: analogy.h:73
int a4l_snd_insn(a4l_desc_t *dsc, a4l_insn_t *arg)
Perform a synchronous acquisition misc operation.
Definition: sync.c:84
int a4l_fill_desc(a4l_desc_t *dsc)
Fill the descriptor with subdevices, channels and ranges data.
Definition: descriptor.c:361
int a4l_find_range(a4l_desc_t *dsc, unsigned int idx_subd, unsigned int idx_chan, unsigned long unit, double min, double max, a4l_rnginfo_t **rng)
Find the must suitable range.
Definition: range.c:166
int a4l_math_polyfit(unsigned r_dim, double *r, double orig, const unsigned dim, double *x, double *y)
Calculate the polynomial fit.
Definition: math.c:365
int a4l_snd_cancel(a4l_desc_t *dsc, unsigned int idx_subd)
Cancel an asynchronous acquisition.
Definition: async.c:81
int a4l_close(a4l_desc_t *dsc)
Close the Analogy device related with the descriptor.
Definition: descriptor.c:336
int a4l_async_read(a4l_desc_t *dsc, void *buf, size_t nbyte, unsigned long ms_timeout)
Perform asynchronous read operation on the analog input subdevice.
Definition: async.c:384
int a4l_mmap(a4l_desc_t *dsc, unsigned int idx_subd, unsigned long size, void **ptr)
Map the asynchronous ring-buffer into a user-space.
Definition: async.c:328
int a4l_sys_close(int fd)
Close an Analogy device.
Definition: sys.c:71
Analogy for Linux, UAPI bits.
int a4l_config_subd(a4l_desc_t *dsc, unsigned int idx_subd, unsigned int type,...)
Configure a subdevice.
Definition: sync.c:369
int a4l_snd_insnlist(a4l_desc_t *dsc, a4l_insnlst_t *arg)
Perform a list of synchronous acquisition misc operations.
Definition: sync.c:58
Structure describing the list of synchronous instructions.
Definition: analogy.h:699