libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
button2.py
Go to the documentation of this file.
1 #!/usr/bin/python
2 
16 
17 from __future__ import print_function
18 from libpruio import *
19 
20 
21 PIN = P8_07
22 
23 
24 io = pruio_new(PRUIO_DEF_ACTIVE, 4, 0x98, 0)
25 try:
26 
27  IO = io.contents
28  if IO.Errr: raise AssertionError("pruio_new failed (%s)" % IO.Errr)
29  if pruio_gpio_config(io, PIN, PRUIO_GPIO_IN_0): # configure input pin
30  raise AssertionError("GPIO configuration failed (%s)" % IO.Errr)
31  if pruio_config(io, 1, 0x1FE, 0, 4): # upload settings, start IO mode
32  raise AssertionError("config failed (%s)" % IO.Errr)
33  # IO mode is running, you can control digital output, read digital or analog input
34  print("Press <Crtl>-C to stop")
35  try:
36  while True:
37  print("\r%1X" % pruio_gpio_Value(io, PIN), end="");
38  print(end="\r") # next line
39  except KeyboardInterrupt:
40  print("") # clear terminal
41 # The following line is optional, the DESTRUCTOR does the job by default
42  if pruio_gpio_config(io, PIN, PRUIO_PIN_RESET): # re-configure pin
43  raise AssertionError("GPIO re-configuration failed (%s)" % IO.Errr)
44 finally:
45  pruio_destroy(io)
char * pruio_config(pruIo *Io, uint32 Samp, uint32 Mask, uint32 Tmr, uint16 Mds)
Wrapper function for PruIo::config().
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_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().