libpruio  0.6.8
Fast and easy Digital/Analog Input/Output for Beaglebones
GpioUdt Class Reference

Structure for GPIO subsystem features, containing all functions and variables to handle the subsystems. More...

Public Member Functions

 GpioUdt (BYVAL_AS_Pruio__PTR)
 The constructor for the GPIO features. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR initialize ()
 Initialize the register context after running the pasm_init.p instructions (private). More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR config (BYVAL_AS_UInt8, BYVAL_AS_UInt8)
 Configure a GPIO. More...
 
SUB_CDECL setGpioSs ()
 Set registers in GPIO subsystem. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR flush (BYVAL_AS_UInt8)
 Flush all output lines at a GPIO subsystem. More...
 
FUNCTION_CDECL_AS_Int32 Value (BYVAL_AS_UInt8)
 Get the state of a GPIO. More...
 
FUNCTION_CDECL_AS_ZSTRING_PTR setValue (BYVAL_AS_UInt8, BYVAL_AS_UInt8)
 Set the state of a GPIO. More...
 

Public Attributes

Pruio__PTR Top
 Pointer to the calling PruIo instance.
 
GpioSet_PTR Init [PRUIO_AZ_GPIO+1]
 Initial subsystem configuration, used in the destructor PruIo::~PruIo().
 
GpioSet_PTR Conf [PRUIO_AZ_GPIO+1]
 Current subsystem configuration, used in PruIo::config().
 
GpioArr_PTR Raw [PRUIO_AZ_GPIO+1]
 Pointer to current raw subsystem data (IO), all 32 bits.
 
UInt32 InitParA
 Offset to read data block offset.
 
UInt32 Mask
 The bit mask to manipulate.
 
UInt8 Mode
 The mode for pinmuxing.
 
UInt8 Indx
 The GPIO subsystem index.
 
UInt8 Fe1
 Future expansion.
 
UInt8 Fe2
 Future expansion.
 
ZSTRING_PTR E0 = "GPIO subsystem not enabled"
 Common error message.
 
ZSTRING_PTR E1 = "no GPIO mode"
 Common error message.
 
ZSTRING_PTR E2 = "no GPIO pin"
 Common error message.
 

Detailed Description

Structure for GPIO subsystem features, containing all functions and variables to handle the subsystems.

This UDT contains the member function to control the features in each of the four GPIO subsystems included in the TI AM335x CPU and the related variables.

Since
0.2

Definition at line 81 of file pruio_gpio.bi.

Constructor & Destructor Documentation

◆ GpioUdt()

GpioUdt::GpioUdt ( BYVAL_AS_Pruio__PTR  T)

The constructor for the GPIO features.

Parameters
TA pointer of the calling PruIo structure.

The constructor prepares the DRam parameters to run the pasm_init.p instructions. The adresses of the subsystems and the adresses of the clock registers get prepared, and the index of the last parameter gets stored to compute the offset in the Init and Conf data blocks.

Since
0.2

Definition at line 28 of file pruio_gpio.bas.

Here is the caller graph for this function:

Member Function Documentation

◆ config()

FUNCTION_CDECL_AS_ZSTRING_PTR GpioUdt::config ( BYVAL_AS_UInt8  Ball,
BYVAL_AS_UInt8  Mo = CAST(UInt8PRUIO_GPIO_IN_0) 
)

Configure a GPIO.

Parameters
BallThe CPU ball number to test.
MoThe modus to set (as Control Module pad register value).
Returns
Zero on success (otherwise a string with an error message).

This function is used to configure a digital pin for GPIO. Use the macros defined in pruio.bi to specify the pin number in parameter Ball for a pin on the Beaglebone headers (ie P8_03 selects pin 3 on header P8).

Parameter Modus specifies the pinmux mode for the ARM control module (see ARM Reference Guide, chapter 9 for details). By default the pin gets configured as input pin with pulldown resistor. Other configurations are prepared as enumerators PinMuxing :

macro name Description
PRUIO_GPIO_IN open input pin (no resistor)
PRUIO_GPIO_IN_0 low input pin (with pulldown resistor)
PRUIO_GPIO_IN_1 high input pin (with pullup resistor)
PRUIO_GPIO_OUT0 output pin set to low (no resistor)
PRUIO_GPIO_OUT1 output pin set to high (no resistor)
Note
In case of device tree pinmuxing it's not possible to set the state of a CPU ball (not connected to a header), because only header pins are prepared for pinmuxing in the libpruio device tree overlay.

Wrapper function (C or Python): pruio_gpio_config().

Since
0.2

Definition at line 130 of file pruio_gpio.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ flush()

FUNCTION_CDECL_AS_ZSTRING_PTR GpioUdt::flush ( BYVAL_AS_UInt8  Indx)

Flush all output lines at a GPIO subsystem.

Parameters
IndxThe subsystem index [0-3]
Returns
Zero on success (otherwise a pointer to an error message).

Transfer new data to the GPIO subsystem registers

  • OE (OutputEnable),
  • SETDATAOUT and
  • CLEARDATAOUT,

in order to set multiple output lines in a single step (no latency between the output transitions). First, modify the related member variables in the array PruIo::Gpio::Conf(Indx) and then flush those values to the hardware. Find example code in src/examples/stepper2.bas

Note
This function is designed to be used when the main loop is running (after the call to PruIo::config() ).
Since
0.6.8

Definition at line 208 of file pruio_gpio.bas.

◆ initialize()

FUNCTION_CDECL_AS_ZSTRING_PTR GpioUdt::initialize ( )

Initialize the register context after running the pasm_init.p instructions (private).

Returns
0 (zero) on success (may return an error string in future versions).

This is a private function, designed to be called from the main constructor PruIo::PruIo(). It sets the pointers to the Init and Conf structures in the data blocks. And it initializes some register context, if the subsystem woke up and is enabled.

Since
0.2

Definition at line 59 of file pruio_gpio.bas.

Here is the caller graph for this function:

◆ setGpioSs()

SUB GpioUdt::setGpioSs ( )

Set registers in GPIO subsystem.

This procedure writes new values to the related registers of the GPIO subsystem to specify the required direction (in or out), and in case of output the required state (low or high). It's low-level and private, not intended for public usage.

Since
0.6.4

Definition at line 158 of file pruio_gpio.bas.

Here is the caller graph for this function:

◆ setValue()

FUNCTION_CDECL_AS_ZSTRING_PTR GpioUdt::setValue ( BYVAL_AS_UInt8  Ball,
BYVAL_AS_UInt8  Mo = 0 
)

Set the state of a GPIO.

Parameters
BallThe CPU ball number to test.
MoThe state to set (0 = low, high otherwise).
Returns
Zero on success (otherwise a pointer to an error message).

This function is used to set the state of an output GPIO. Set parameter Ball to the required header pin (=CPU ball) by using the convenience macros defined in(ie. P8_03 selects pin 3 on header P8). Use pruio_pins_pocket.bi or pruio_pins_blue.bi for Pocket Beaglebone or Beaglebone Blue boards.

Parameter Mo specifies either the state to set (0 or 1). Or it specifies the pinmux mode to test and the state in the MSB.

Wrapper function (C or Python): pruio_gpio_setValue().

Since
0.2

Definition at line 242 of file pruio_gpio.bas.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Value()

FUNCTION_CDECL_AS_Int32 GpioUdt::Value ( BYVAL_AS_UInt8  Ball)

Get the state of a GPIO.

Parameters
BallThe CPU ball number to test.
Returns
The GPIO state (otherwise -1, check PruIo::Errr for an error message).

This function is used to get the state of a digital pin (GPIO). Use the macros defined in pruio.bi to specify the pin number in parameter Ball for a pin on the Beaglebone headers (ie P8_03 selects pin 3 on header P8).

It's possible to get the state of a CPU ball (not connected to a header), also. In this case you need to find the matching CPU ball number and pass it in as the parameter Ball.

The function returns the state of input and output pins. Return values are

Value Description
1 GPIO is in high state
0 GPIO is in low state
-1 error (undefined ball number)

Wrapper function (C or Python): pruio_gpio_Value().

Since
0.2

Definition at line 293 of file pruio_gpio.bas.

Here is the caller graph for this function:

The documentation for this class was generated from the following files: