libpruio  0.2
Input/Output driver for digital/analog lines on Beagleboard hardware
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pruio_adc.bi
Go to the documentation of this file.
1 /'* \file pruio_adc.bi
2 \brief FreeBASIC header file for ADC component of libpruio.
3 
4 Header file for including in to libpruio. It contains the declarations
5 for the ADC part of the library.
6 
7 '/
8 
9 
10 '* The default setting for avaraging.
11 #DEFINE PRUIO_DEF_AVRAGE 4
12 '* The default value for open delay in channel settings.
13 #DEFINE PRUIO_DEF_ODELAY 183
14 '* The default value for sample delay in channel settings.
15 #DEFINE PRUIO_DEF_SDELAY 0
16 '* The default number of samples to use (configures single mode).
17 #DEFINE PRUIO_DEF_SAMPLS 1
18 '* The default step mask (steps 1 to 8 for AIN-0 to AIN-7, no charge step).
19 #DEFINE PRUIO_DEF_STPMSK &b111111110
20 '* The default timer value (sampling rate).
21 #DEFINE PRUIO_DEF_TIMERV 0
22 '* The default bit mode (4 = 16 bit encoding).
23 #DEFINE PRUIO_DEF_LSLMOD 4
24 '* The default clock divisor (0 = full speed AFE = 2.4 MHz).
25 #DEFINE PRUIO_DEF_CLKDIV 0
26 
27 /'* \brief Structure for a single ADC step configuration, containing
28 config and delay registers context.
29 
30 This UDT contains the configuration of a single step. Up to 16 steps
31 can get configured for a measurement (index 1 to 16). A further step
32 (index 0) can get configured to charge a touch screen.
33 
34 Find further details in \ArmRef{12.5.1.17 ff.}.
35 
36 '/
37 TYPE AdcSteps
38  AS UInt32 _
39  Confg _ '*< Context for configuration register.
40  , Delay '*< Context for delay register.
41 END TYPE
42 
43 /'* \brief Structure for ADC subsystem registers.
44 
45 This UDT contains a set of all ADC subsystem registers. It's used to
46 store the initial configuration of the subsystem and to hold current
47 configuration for the next call to function PruIo::config().
48 
49 \since 0.2
50 '/
51 TYPE AdcSet
52  AS UInt32 _
53  DeAd _ '*< Device address.
54  , ClAd _ '*< Clock address.
55  , ClVa '*< Clock value (defaults to 2 = enabled, set to 0 = disabled).
56 
57  AS UInt32 _
58  REVISION _ '*< Register at offset 00h (see \ArmRef{12.5.1.1} ).
59  , SYSCONFIG _ '*< Register at offset 10h (see \ArmRef{12.5.1.2} ).
60  , IRQSTATUS_RAW _ '*< Register at offset 24h (see \ArmRef{12.5.1.3} ).
61  , IRQSTATUS _ '*< Register at offset 28h (see \ArmRef{12.5.1.4} ).
62  , IRQENABLE_SET _ '*< Register at offset 2Ch (see \ArmRef{12.5.1.5} ).
63  , IRQENABLE_CLR _ '*< Register at offset 30h (see \ArmRef{12.5.1.6} ).
64  , IRQWAKEUP _ '*< Register at offset 34h (see \ArmRef{12.5.1.7} ).
65  , DMAENABLE_SET _ '*< Register at offset 38h (see \ArmRef{12.5.1.8} ).
66  , DMAENABLE_CLR _ '*< Register at offset 3Ch (see \ArmRef{12.5.1.9} ).
67  , CTRL _ '*< Register at offset 40h (see \ArmRef{12.5.1.10} ).
68  , ADCSTAT _ '*< Register at offset 44h (see \ArmRef{12.5.1.11} ).
69  , ADCRANGE _ '*< Register at offset 48h (see \ArmRef{12.5.1.12} ).
70  , ADC_CLKDIV _ '*< Register at offset 4Ch (see \ArmRef{12.5.1.13} ).
71  , ADC_MISC _ '*< Register at offset 50h (see \ArmRef{12.5.1.14} ).
72  , STEPENABLE _ '*< Register at offset 54h (see \ArmRef{12.5.1.15} ).
73  , IDLECONFIG _ '*< Register at offset 58h (see \ArmRef{12.5.1.16} ).
74 
75  '* step configuration (see \ArmRef{12.5.1.17 ff}, charge step + 16 steps, by default steps 1 to 8 are used for AIN-0 to AIN-7).
76  AS AdcSteps St_p(16)
77 
78  AS UInt32 _
79  FIFO0COUNT _ '*< Register at offset E4h (see \ArmRef{12.5.1.51} ).
80  , FIFO0THRESHOLD _ '*< Register at offset E8h (see \ArmRef{12.5.1.52} ).
81  , DMA0REQ _ '*< Register at offset ECh (see \ArmRef{12.5.1.53} ).
82  , FIFO1COUNT _ '*< Register at offset F0h (see \ArmRef{12.5.1.54} ).
83  , FIFO1THRESHOLD _ '*< Register at offset F4h (see \ArmRef{12.5.1.55} ).
84  , DMA1REQ '*< Register at offset F8h (see \ArmRef{12.5.1.56} ).
85 END TYPE
86 
87 /'* \brief Structure for ADC subsystem features, containing all
88 functions and variables to handle the subsystem.
89 
90 This UDT contains the member function to control the ADC features and
91 the related variables.
92 
93 \since 0.2
94 '/
95 TYPE AdcUdt
96  AS Pruio_ PTR Top '*< Pointer to the calling PruIo instance.
97  AS AdcSet PTR _
98  Init _ '*< Initial subsystem configuration, used in the destructor PruIo::~PruIo.
99  , Conf '*< Current subsystem configuration, used in PruIo::config().
100  AS UInt32 _
101  Samples _ '*< Number of samples (specifies run mode: 0 = config, 1 = IO mode, >1 = MM mode).
102  , TimerVal _ '*< Timer value in [ns].
103  , InitParA '*< Offset to read data block offset.
104  AS UInt16 _
105  LslMode _ '*< Bit shift modus (0 to 4, for 12 to 16 bits).
106  , ChAz '*< The number of active steps.
107  AS UInt16 PTR _
108  Value '*< Fetched ADC samples.
109  AS ZSTRING PTR _
110  E0 = @"step number too big" _ '*< Common error message.
111  , E1 = @"channel number too big" _ '*< Common error message.
112  , E2 = @"too much values to skip" _ '*< Common error message.
113  , E3 = @"trigger step not configured" _ '*< Common error message.
114  , E4 = @"invalid step number" _ '*< Common error message.
115  , E5 = @!"ADC not enabled" '*< Common error message.
116 
117  DECLARE CONSTRUCTOR (BYVAL AS Pruio_ PTR )
118  DECLARE FUNCTION initialize CDECL( _
119  BYVAL AS UInt8 = PRUIO_DEF_AVRAGE _
120  , BYVAL AS UInt32 = PRUIO_DEF_ODELAY _
121  , BYVAL AS UInt8 = PRUIO_DEF_SDELAY) AS ZSTRING PTR
122  DECLARE FUNCTION configure CDECL( _
123  BYVAL AS UInt32 = PRUIO_DEF_SAMPLS _
124  , BYVAL AS UInt32 = PRUIO_DEF_STPMSK _
125  , BYVAL AS UInt32 = PRUIO_DEF_TIMERV _
126  , BYVAL AS UInt16 = PRUIO_DEF_LSLMOD) AS ZSTRING PTR
127  DECLARE FUNCTION setStep CDECL( _
128  BYVAL AS UInt8 _
129  , BYVAL AS UInt8 _
130  , BYVAL AS UInt8 = PRUIO_DEF_AVRAGE _
131  , BYVAL AS UInt8 = PRUIO_DEF_SDELAY _
132  , BYVAL AS UInt32 = PRUIO_DEF_ODELAY) AS ZSTRING PTR
133  DECLARE FUNCTION mm_trg_pin CDECL( _
134  BYVAL AS UInt8 _
135  , BYVAL AS UInt8 = 0 _
136  , BYVAL AS UInt16 = 0) AS UInt32
137  DECLARE FUNCTION mm_trg_ain CDECL( _
138  BYVAL AS UInt8 _
139  , BYVAL AS Int32 _
140  , BYVAL AS UInt8 = 0 _
141  , BYVAL AS UInt16 = 0) AS UInt32
142  DECLARE FUNCTION mm_trg_pre CDECL( _
143  BYVAL AS UInt8 _
144  , BYVAL AS Int32 _
145  , BYVAL AS UInt16 = 0 _
146  , BYVAL AS UInt8 = 0) AS UInt32
147 END TYPE
148