libpruio  0.0
AM33xx-PRU driver for digital input / output and analog input
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
pruio_c_wrapper.h
Go to the documentation of this file.
1 /** \file pruio_c_wrapper.h
2 \brief The main header code of the C wrapper for libpruio.
3 
4 This file provides the declarations of the \ref PruIo class member
5 functions in C syntax. It also can be used to create language bindings
6 for non-C languages to use libpruio in polyglot applications.
7 
8 \note The includes pruio.h and pruio_pins.h are not shown in this
9  documentation because they confuse Doxygen. It mixes up
10  references with the original headers pruio/pruio.bi and
11  pruio/pruio_pins.bi.
12 
13 Licence: LGPLv2
14 
15 Copyright 2014 by Thomas{ dOt ]Freiherr[ At ]gmx[ DoT }net
16 
17 */
18 
19 #include "pruio.h"
20 #include "pruio.hp"
21 
22 /** \brief C wrapper to create a \ref PruIo instance.
23 \param Av avaraging for default steps (0 to 16, defaults to 0)
24 \param OpD open delay for default steps (0 to 0x3FFFF, defaults to 0x98)
25 \param SaD sample delay for default steps (0 to 255, defaults to 0)
26 \param Pru number of PRU subsystem to use (0 or 1, defaults to 1)
27 \returns A pointer for the new instance.
28 
29 This function wraps the constructor, check \ref PruIo::PruIo() for
30 details.
31 
32 Since the constructor reads the original devices configurations and the
33 destructor restores them, it's recommended to create and use just one
34 \ref PruIo instance at the same time.
35 
36 */
37 PruIo* pruio_new(uint8 Av, uint32 OpD, uint8 SaD, uint8 Pru);
38 
39 /** \brief C wrapper to destroy a \ref PruIo instance.
40 \param Io The pointer of the instance.
41 
42 This function wraps the destructor, check \ref PruIo::~PruIo() for
43 details. (Doxygen should create a link here?!)
44 
45 */
46 void pruio_destroy(PruIo* Io);
47 
48 /** \brief C wrapper for function \ref PruIo::config().
49 \param Io The pointer of the \ref PruIo instance
50 \param Samp number of samples to fetch (defaults to zero)
51 \param Mask mask for active steps (defaults to all 8 channels active in steps 1 to 8)
52 \param Tmr timer value in [ns] to specify the sampling rate (defaults to zero, MM only)
53 \param Mds modus for output (defaults to 4 = 16 bit)
54 \param ClDv divisor for ADC input clock (defaults to 0 = full speed = 2.4 MHz)
55 \returns zero on success (otherwise a string with an error message)
56 
57 This function wraps the member function config, check \ref
58 PruIo::config() for details.
59 
60 */
61 char* pruio_config(PruIo* Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds, uint16 ClDv);
62 
63 /** \brief C wrapper for function \ref PruIo::adc_step().
64 \param Io The pointer of the \ref PruIo instance
65 \param Stp step index (0 = step 0 => charge step, 1 = step 1 (=> AIN0 by default), ..., 17 = idle step)
66 \param ChN channel number to scan (0 = AIN0, 1 = AIN1, ...)
67 \param Av new value for avaraging (defaults to 4)
68 \param SaD new value for sample delay (defaults to 0)
69 \param OpD new value for open delay (defaults to 0x98)
70 \returns zero on success (otherwise a string with an error message)
71 
72 This function wraps the member function adc_step, check \ref
73 PruIo::adc_step() for details.
74 
75 */
76 char* pruio_adc_step(PruIo* Io, uint8 Stp, uint8 ChN, uint8 Av, uint8 SaD, uint32 OpD);
77 
78 /** \brief C wrapper for function \ref PruIo::gpio_get_config().
79 \param Io The pointer of the \ref PruIo instance
80 \param Ball the CPU ball number to describe
81 \returns a human-readable text string (internal string, never free it)
82 
83 This function wraps the member function adc_step, check \ref
84 PruIo::gpio_get_config() for details.
85 
86 */
87 char* pruio_gpio_get_config(PruIo* Io, uint8 Ball);
88 
89 /** \brief C wrapper for function \ref PruIo::gpio_set().
90 \param Io The pointer of the \ref PruIo instance
91 \param Ball the CPU ball number to set
92 \param Modus the mode for the GPIO
93 \param Lokk the locking specification
94 \returns zero on success (otherwise a pionter to an error message)
95 
96 This function wraps the member function adc_step, check \ref
97 PruIo::gpio_set() for details.
98 
99 */
100 char* pruio_gpio_set(PruIo* Io, uint8 Ball, uint8 Modus, uint8 Lokk);
101 
102 /** \brief C wrapper for function \ref PruIo::gpio_get().
103 \param Io The pointer of the \ref PruIo instance
104 \param Ball the CPU ball number to test
105 \returns GPIO state (otherwise -1, check \ref PruIo::Errr for an error message)
106 
107 This function wraps the member function adc_step, check \ref
108 PruIo::gpio_get() for details.
109 
110 */
111 uint32 pruio_gpio_get(PruIo* Io, uint8 Ball);
112 
113 /** \brief C wrapper for function \ref PruIo::gpio_out().
114 \param Io The pointer of the \ref PruIo instance
115 \param Ball the CPU ball number to test
116 \param Modus the state to set (0 = low, high otherwise)
117 \returns zero on success (otherwise a pointer to an error message)
118 
119 This function wraps the member function adc_step, check \ref
120 PruIo::gpio_out() for details.
121 
122 */
123 char* pruio_gpio_out(PruIo* Io, uint8 Ball, uint8 Modus);
124 
125 /** \brief C wrapper for function \ref PruIo::mm_trg_pin().
126 \param Io The pointer of the \ref PruIo instance
127 \param Ball the CPU ball number to test
128 \param GpioV the state to check (defaults to high = 1)
129 \param Skip the number of samples to skip (defaults to 0 = zero, max. 1023)
130 \returns the trigger configuration (or zero in case of an error, check \ref PruIo::Errr)
131 
132 This function wraps the member function adc_step, check \ref
133 PruIo::mm_trg_pin() for details.
134 
135 */
136 uint32 pruio_mm_trg_pin(PruIo* Io, uint8 Ball, uint8 GpioV, uint16 Skip);
137 
138 /** \brief C wrapper for function \ref PruIo::mm_trg_ain().
139 \param Io The pointer of the \ref PruIo instance
140 \param Stp the step number to use for trigger input
141 \param AdcV the sample value to match (positive check greater than, negative check less than)
142 \param Rela if AdcV is relative to the current input
143 \param Skip the number of samples to skip (defaults to 0 = zero, max. 1023)
144 \returns the trigger configuration (or zero in case of an error, check \ref PruIo::Errr)
145 
146 This function wraps the member function adc_step, check \ref
147 PruIo::mm_trg_ain() for details.
148 
149 */
150 uint32 pruio_mm_trg_ain(PruIo* Io, uint8 Stp, int32 AdcV, uint8 Rela, uint16 Skip);
151 
152 /** \brief C wrapper for function \ref PruIo::mm_trg_pre().
153 \param Io The pointer of the \ref PruIo instance
154 \param Stp the step number to use for trigger input
155 \param AdcV the sample value to match (positive check greater than, negative check less than)
156 \param Samp the number of samples for the pre-trigger
157 \param Rela if AdcV is relative to the current input
158 \returns the trigger configuration (or zero in case of an error, check \ref PruIo::Errr)
159 
160 This function wraps the member function adc_step, check \ref
161 PruIo::mm_trg_pre() for details.
162 
163 */
164 uint32 pruio_mm_trg_pre(PruIo* Io, uint8 Stp, int32 AdcV, uint16 Samp, uint8 Rela);
165 
166 /** \brief C wrapper for function \ref PruIo::mm_start().
167 \param Io The pointer of the \ref PruIo instance
168 \param Trg1 settings for first trigger (default = no trigger)
169 \param Trg2 settings for second trigger (default = no trigger)
170 \param Trg3 settings for third trigger (default = no trigger)
171 \param Trg4 settings for fourth trigger (default = no trigger)
172 \returns zero on success (otherwise a string with an error message)
173 
174 This function wraps the member function adc_step, check \ref
175 PruIo::mm_start() for details.
176 
177 */
178 char* pruio_mm_start(PruIo* Io, uint32 Trg1, uint32 Trg2, uint32 Trg3, uint32 Trg4);