31 from __future__
import print_function
32 from libpruio
import *
43 "Open loop, direct GPIO"
44 ,
"Open loop, function Gpio->Value"
45 ,
"Closed loop, direct GPIO to direct GPIO"
46 ,
"Closed loop, function Gpio->Value to direct GPIO"
47 ,
"Closed loop, function Gpio->Value to function Gpio->setValue"
48 ,
"Closed loop, Adc->Value to direct GPIO"
49 ,
"Closed loop, Adc->Value to function Gpio->Value"
55 nf = [100e6,100e6,100e6,100e6,100e6,100e6,100e6]
57 sf = [0.,0.,0.,0.,0.,0.,0.]
59 xf = [0.,0.,0.,0.,0.,0.,0.]
79 io =
pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0)
86 raise AssertionError(
"Cap->Value failed (%s)" % IO.Errr)
88 if f0.value < nf[_N_]: nf[_N_] = f0.value
89 if f0.value > xf[_N_]: xf[_N_] = f0.value
90 print(
"%f" % f0.value, end=
"\t")
94 if _O_: cd.value &= ~m0.value; sd.value |= m0.value
95 else: sd.value &= ~m0.value; cd.value |= m0.value
96 while IO.DRam[1]:
pass
100 IO.DRam[2] = ad.value
101 IO.DRam[1] = PRUIO_COM_GPIO_CONF << 24
104 if IO.Errr:
raise AssertionError(
"pruio_new failed (%s)" % IO.Errr)
107 raise AssertionError(
"GOUT configuration failed (%s)" % IO.Errr)
110 raise AssertionError(
"G_IN configuration failed (%s)" % IO.Errr)
113 raise AssertionError(
"C_IN configuration failed (%s)" % IO.Errr)
116 raise AssertionError(
"ADC setStep failed (%s)" % IO.Errr)
119 raise AssertionError(
"config failed (%s)" % IO.Errr)
121 r1.value = IO.BallGpio[G_IN]
122 m1.value = 1 << (r1.value & 31)
123 r0.value = IO.BallGpio[GOUT]
124 m0.value = 1 << (r0.value & 31)
127 ad.value = IO.Gpio.contents.Conf[g0].contents.DeAd + 0x100
128 oe.value = IO.Gpio.contents.Conf[g0].contents.OE
131 mi = IO.Gpio.contents.Raw[g1].contents
132 Adc = IO.Adc.contents.Value
133 for x
in range(0, n):
135 for i
in range(0, c):
141 for i
in range(0, c):
143 raise AssertionError(
"GPIO setValue failed (%s)" % Io.Errr)
145 raise AssertionError(
"GPIO setValue failed (%s)" % Io.Errr)
149 for i
in range(0, c):
151 while 0 == (m1.value & mi.Mix):
pass
154 while m1 == (m1.value & mi.Mix):
pass
158 for i
in range(0, c):
167 for i
in range(0, c):
169 raise AssertionError(
"GPIO setValue failed (%s)" % Io.Errr)
173 raise AssertionError(
"GPIO setValue failed (%s)" % Io.Errr)
178 for i
in range(0, c):
180 while Adc[1] <= 0x7FFF:
pass
183 while Adc[1] > 0x7FFF:
pass
187 for i
in range(0, c):
189 raise AssertionError(
"GPIO setValue failed (%s)" % Io.Errr)
190 while Adc[1] <= 0x7FFF:
pass
193 raise AssertionError(
"GPIO setValue failed (%s)" % Io.Errr)
194 while Adc[1] > 0x7FFF:
pass
198 for i
in range(0, 7):
199 print(
"%s:" % desc[i])
200 print(
" Minimum: %s" % nf[i])
201 print(
" Avarage: %s" % (sf[i] / n))
202 print(
" Maximum: %s" % xf[i])
char * pruio_config(pruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds)
Wrapper function for PruIo::config().
char * pruio_cap_Value(pruIo *Io, uint8 Ball, float_t *Hz, float_t *Du)
Wrapper function for CapMod::Value().
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().
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().
char * pruio_gpio_setValue(pruIo *Io, uint8 Ball, uint8 Modus)
Wrapper function for GpioUdt::setValue().