All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
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...
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.
ZSTRING_PTR | E0 = "GPIO subsystem not enabled"
| Common error message.
ZSTRING_PTR | E1 = "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 AM33xx CPU and the related variables.

Since
  0.2

Definition at line 79 of file pruio_gpio.bi.

## Constructor & Destructor Documentation

GpioUdt::GpioUdt | ( | BYVAL_AS_Pruio__PTR | T | ) |

The constructor for the GPIO features.

Parameters

  T | A 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 19 of file pruio_gpio.bas.

Here is the caller graph for this function:

## Member Function Documentation

FUNCTION_CDECL_AS_ZSTRING_PTR GpioUdt::config | ( | BYVAL_AS_UInt8 | Ball,
|  | BYVAL_AS_UInt8 | Mo = `CAST(UInt8, PRUIO_GPIO_IN_0)`
| ) |  |

Configure a GPIO.

Parameters

  Ball | The CPU ball number to test.
  Mo | The 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).

Its 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.

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 PruIo::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)

Definition at line 110 of file pruio_gpio.bas.

Here is the caller graph for this function:

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 50 of file pruio_gpio.bas.

Here is the caller graph for this function:

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

Set the state of a GPIO.

Parameters

  Ball | The CPU ball number to test.
  Mo | The 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 pruio_pins.bi (ie. P8_03 selects pin 3 on header P8).

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

< the pinmux mode

Definition at line 167 of file pruio_gpio.bas.

Here is the caller graph for this function:

FUNCTION_CDECL_AS_Int32 GpioUdt::Value | ( | BYVAL_AS_UInt8 | Ball | ) |

Get the state of a GPIO.

Parameters

  Ball | The 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)

Definition at line 225 of file pruio_gpio.bas.

Here is the caller graph for this function:

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

- src/pruio/pruio_gpio.bi
- src/pruio/pruio_gpio.bas