nidas v1.2.3
ncar_a2d.h
Go to the documentation of this file.
1/* -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8; -*- */
2/* vim: set shiftwidth=8 softtabstop=8 expandtab: */
3/*
4 ********************************************************************
5 ** NIDAS: NCAR In-situ Data Acquistion Software
6 **
7 ** 2007, Copyright University Corporation for Atmospheric Research
8 **
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** The LICENSE.txt file accompanying this software contains
20 ** a copy of the GNU General Public License. If it is not found,
21 ** write to the Free Software Foundation, Inc.,
22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 **
24 ********************************************************************
25*/
26/* ncar_a2d.h
27
28*/
29
30/*
31 * This header is shared from user-side code that wants to get the
32 * values of the ioctl commands.
33 */
34
35#ifndef NCAR_A2D_H
36#define NCAR_A2D_H
37
38#include "types.h" // get nidas typedefs
39#include "a2d.h"
40
41/*
42 * User programs need these for the _IO macros, but kernel modules get
43 * theirs elsewhere.
44 */
45#ifndef __KERNEL__
46# include <sys/ioctl.h>
47# include <sys/types.h>
48#endif
49
50/*
51 * Board temperature samples will have this index value.
52 */
53#define NCAR_A2D_TEMPERATURE_INDEX 255
54
55#define NUM_NCAR_A2D_CHANNELS 8 // Number of A/D's per card
56
57/*
58 * A/D filter configuration
59 */
60#define CONFBLOCKS 12 // 12 blocks as described below
61#define CONFBLLEN 43 // 42 data words plus 1 CRCC
62
67{
68 unsigned short filter[CONFBLOCKS*CONFBLLEN+1]; // Filter data
69};
70
71/* A2D status info */
73{
74 // fifoLevel indices 0-5 correspond to:
75 // 0: empty
76 // 1: <= 1/4 full
77 // 2: < 1/2 full
78 // 3: < 3/4 full
79 // 4: < full
80 // 5: full
81 unsigned int preFifoLevel[6]; // counters for fifo level, pre-read
82
83 unsigned short goodval[NUM_NCAR_A2D_CHANNELS]; // value of last good status word
84
85 unsigned short ser_num; // A/D card serial number
86
87 unsigned int skippedSamples; // discarded samples because of slow RTL fifo
88 int resets; // number of board resets since last open
89
90 // following members are used only by RTLinux version
91 unsigned int postFifoLevel[6]; // counters for fifo level, post-read
92 unsigned int nbad[NUM_NCAR_A2D_CHANNELS]; // number of bad status words in last 100 scans
93 unsigned short badval[NUM_NCAR_A2D_CHANNELS]; // value of last bad status word
94 unsigned int nbadFifoLevel; // #times hw fifo not at expected level pre-read
95 unsigned int fifoNotEmpty; // #times hw fifo not empty post-read
96
97};
98
99/* This structure is used to copy a brief description of the current board
100 * configuration back to user space via the NCAR_A2D_GET_SETUP ioctl.
101 */
103{
104 int gain[NUM_NCAR_A2D_CHANNELS]; // gain settings
105 int offset[NUM_NCAR_A2D_CHANNELS]; // Offset flags
106 int calset[NUM_NCAR_A2D_CHANNELS]; // cal voltage channels
107 int vcal; // cal voltage
108};
109
110/* Calibration structure
111 */
113{
115 int state; // off: 0 on: 1
116 int vcal; // voltage
117};
118
119/* Pick a character as the magic number of your driver.
120 * It isn't strictly necessary that it be distinct between
121 * all modules on the system, but is a good idea. With
122 * distinct magic numbers one can catch a user sending
123 * an ioctl to the wrong device.
124 */
125#define A2D_MAGIC 'A'
126
127/*
128 * IOCTLs that this driver supports.
129 */
130#define NCAR_A2D_GET_STATUS _IOR(A2D_MAGIC, 0, struct ncar_a2d_status)
131#define NCAR_A2D_SET_OCFILTER _IOW(A2D_MAGIC, 1, struct ncar_a2d_ocfilter_config)
132#define NCAR_A2D_GET_SETUP _IOR(A2D_MAGIC, 2, struct ncar_a2d_setup)
133#define NCAR_A2D_SET_CAL _IOW(A2D_MAGIC, 3, struct ncar_a2d_cal_config)
134#define NCAR_A2D_RUN _IO(A2D_MAGIC, 4)
135#define NCAR_A2D_STOP _IO(A2D_MAGIC, 5)
136#define NCAR_A2D_GET_TEMP _IOR(A2D_MAGIC, 6, short)
137#define NCAR_A2D_SET_TEMPRATE _IOW(A2D_MAGIC, 7, int)
138
139#endif
#define NUM_NCAR_A2D_CHANNELS
Definition ncar_a2d.h:55
#define CONFBLOCKS
Definition ncar_a2d.h:60
#define CONFBLLEN
Definition ncar_a2d.h:61
Definition ncar_a2d.h:113
int vcal
Definition ncar_a2d.h:116
int state
Definition ncar_a2d.h:115
int calset[NUM_NCAR_A2D_CHANNELS]
Definition ncar_a2d.h:114
Data used to configure on-chip filters.
Definition ncar_a2d.h:67
unsigned short filter[CONFBLOCKS *CONFBLLEN+1]
Definition ncar_a2d.h:68
Definition ncar_a2d.h:103
int gain[NUM_NCAR_A2D_CHANNELS]
Definition ncar_a2d.h:104
int calset[NUM_NCAR_A2D_CHANNELS]
Definition ncar_a2d.h:106
int vcal
Definition ncar_a2d.h:107
int offset[NUM_NCAR_A2D_CHANNELS]
Definition ncar_a2d.h:105
Definition ncar_a2d.h:73
int resets
Definition ncar_a2d.h:88
unsigned int nbadFifoLevel
Definition ncar_a2d.h:94
unsigned int skippedSamples
Definition ncar_a2d.h:87
unsigned int postFifoLevel[6]
Definition ncar_a2d.h:91
unsigned short goodval[NUM_NCAR_A2D_CHANNELS]
Definition ncar_a2d.h:83
unsigned int nbad[NUM_NCAR_A2D_CHANNELS]
Definition ncar_a2d.h:92
unsigned short badval[NUM_NCAR_A2D_CHANNELS]
Definition ncar_a2d.h:93
unsigned int preFifoLevel[6]
Definition ncar_a2d.h:81
unsigned short ser_num
Definition ncar_a2d.h:85
unsigned int fifoNotEmpty
Definition ncar_a2d.h:95