35 #include "libpruio/pruio.h"
36 #include "libpruio/pruio_pins.h"
47 if(pruio_cap_Value(Io, C_IN, &f0, NULL)) { \
48 printf("Cap->Value failed (%s)", Io->Errr); goto finish;} \
50 if(f0 < nf[_N_]) {nf[_N_] = f0;} \
51 if(f0 > xf[_N_]) {xf[_N_] = f0;} \
56 if(_O_){cd &= ~m0; sd |= m0;} else {sd &= ~m0; cd |= m0;} \
57 while(Io->DRam[1]){} \
62 Io->DRam[1] = PRUIO_COM_GPIO_CONF << 24;
66 if(pruio_gpio_setValue(Io, GOUT, _O_)) { \
67 printf("GPIO setValue failed (%s)", Io->Errr); goto finish;}
70 int main(
int argc,
char **argv)
75 printf(
"initialisation failed (%s)\n", Io->
Errr);
break;}
78 printf(
"GOUT configuration failed (%s)\n", Io->
Errr);
break;}
81 printf(
"G_IN configuration failed (%s)\n", Io->
Errr);
break;}
84 printf(
"C_IN configuration failed (%s)\n", Io->
Errr);
break;}
87 printf(
"ADC setStep failed (%s)\n", Io->
Errr);
break;}
90 printf(
"config failed (%s)\n", Io->
Errr);
break;}
92 const char *
desc[] = {
93 "Open loop, direct GPIO"
94 ,
"Open loop, function Gpio->Value"
95 ,
"Closed loop, direct GPIO to direct GPIO"
96 ,
"Closed loop, function Gpio->Value to direct GPIO"
97 ,
"Closed loop, function Gpio->Value to function Gpio->setValue"
98 ,
"Closed loop, Adc->Value to direct GPIO"
99 ,
"Closed loop, Adc->Value to function Gpio->Value"
108 ,
m1 = 1 << (
r1 & 31)
111 ,
m0 = 1 << (
r0 & 31)
122 for(
n = 0;
n < 7;
n++) {
128 struct timespec mSec;
130 mSec.tv_nsec=1000000;
132 for(
n = 0;
n < 50;
n++) {
133 nanosleep(&mSec,
NULL);
134 for(
i = 0;
i <=
c;
i++) {
140 nanosleep(&mSec,
NULL);
141 for(
i = 0;
i <=
c;
i++) {
147 nanosleep(&mSec,
NULL);
148 for(
i = 0;
i <=
c;
i++) {
157 nanosleep(&mSec,
NULL);
158 for(
i = 0;
i <=
c;
i++) {
167 nanosleep(&mSec,
NULL);
168 for(
i = 0;
i <=
c;
i++) {
177 nanosleep(&mSec,
NULL);
178 for(
i = 0;
i <=
c;
i++) {
180 while(Io->
Adc->
Value[1] <= 0x7FFF) {}
183 while(Io->
Adc->
Value[1] > 0x7FFF) {}
187 nanosleep(&mSec,
NULL);
188 for(
i = 0;
i <=
c;
i++) {
190 while(Io->
Adc->
Value[1] <= 0x7FFF) {}
193 while(Io->
Adc->
Value[1] > 0x7FFF) {}
198 printf(
"Results:\n");
199 for(
i = 0;
i < 7;
i++) {
200 printf(
"%s:\n",
desc[
i]);
201 printf(
" Minimum: %f\n",
nf[
i]);
202 printf(
" Avarage: %f\n", (
sf[
i] /
n));
203 printf(
" Maximum: %f\n",
xf[
i]);
205 printf(
"%X %X %X %X %X\n",
sd,
cd,
ad,
m0,
r0);
unsigned int uint32
32 bit unsigned integer data type.
char * pruio_config(pruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds)
Wrapper function for PruIo::config().
float float_t
float data type.
uint32 pruio_gpio_Value(pruIo *Io, uint8 Ball)
Wrapper function for GpioUdt::Value().
pruIo * pruio_new(uint16 Act, uint8 Av, uint32 OpD, uint8 SaD)
Wrapper function for the constructor PruIo::PruIo().
@ PRUIO_GPIO_IN
GPIO input (no resistor).
char * pruio_cap_config(pruIo *Io, uint8 Ball, float_t FLow)
Wrapper function for CapMod::config().
char * pruio_adc_setStep(pruIo *Io, uint8 Stp, uint8 ChN, uint8 Av, uint8 SaD, uint32 OpD)
Wrapper function for AdcUdt::setStep().
char * pruio_gpio_config(pruIo *Io, uint8 Ball, uint8 Modus)
Wrapper function for GpioUdt::config().
void pruio_destroy(pruIo *Io)
Wrapper function for the destructor PruIo::~PruIo().
@ PRUIO_DEF_ACTIVE
Activate all subsystems.
char * pruio_gpio_setValue(pruIo *Io, uint8 Ball, uint8 Modus)
Wrapper function for GpioUdt::setValue().
const ANY_PTR NULL
The NULL pointer.
uint16 * Value
Fetched ADC samples.
uint32 Mix
Current state of pins (IN&OUT mixed).
uint32 DeAd
Subsystem address.
uint32 OE
Register at offset 134h (chap. 25.4.1.16).
gpioSet * Conf[PRUIO_AZ_GPIO+1]
Current subsystem configuration, used in PruIo::config().
gpioArr * Raw[PRUIO_AZ_GPIO+1]
Pointer to current raw subsystem data (IO), all 32 bits.
Wrapper structure for PruIo.
char * Errr
Pointer for error messages.
uint8 BallGpio[PRUIO_AZ_BALL+1]
List of GPIO numbers, corresponding to ball index.
gpioUdt * Gpio
Pointer to GPIO subsystem structure.
adcUdt * Adc
Pointer to ADC subsystem structure.