Skip to main content

Module gpio

Module gpio 

Source
Expand description

The C ABI for on-board bus addressing and pin logic.

These functions wrap [pamoja_gpio] for callers that reach the SDK through the flat C boundary: I2C addressing per NXP UM10204, the four SPI clock modes, the pin model that maps a logical “asserted” onto a physical level, and a line opened on a Linux board.

The addressing and the pin model allocate nothing and hold no state. An I2C address is two scalars and crosses by value as PamojaI2cAddress; the rest are enumerations and small pure functions over them. A PamojaGpioLine is the one handle: a line on a Linux board’s GPIO chip, opened with pamoja_gpio_line_open_output or pamoja_gpio_line_open_input and let go with pamoja_gpio_line_free. On any other platform opening one returns PamojaStatus::Unsupported with a message saying why.

Structs§

PamojaGpioLine
A GPIO line opened on a Linux board. Opaque; let it go with pamoja_gpio_line_free, which hands the line back to the kernel.
PamojaI2cAddress
A validated I2C device address.

Enums§

PamojaI2cDirection
Which direction an I2C transfer runs, as the read/write bit encodes it.
PamojaPinEdge
The signal transition that triggers a pin interrupt.
PamojaPinLevel
The physical voltage level on a pin.
PamojaPinPolarity
Whether a signal is asserted by a high or a low physical level.

Constants§

PAMOJA_I2C_FRAME_MAX
The largest I2C address frame, in bytes: the two a 10-bit address needs.
PAMOJA_I2C_RESERVED_BELOW
The first 7-bit address above the reserved block at the bottom of the range.
PAMOJA_I2C_RESERVED_FROM
The lowest 7-bit address the I2C specification keeps for itself.

Functions§

pamoja_gpio_line_drive⚠
Drives an output line to a level.
pamoja_gpio_line_free⚠
Lets a line go, handing it back to the kernel. A null pointer is ignored.
pamoja_gpio_line_open_input⚠
Opens a line on a Linux board as an input.
pamoja_gpio_line_open_output⚠
Opens a line on a Linux board as an output, driving initial from the moment it is taken.
pamoja_gpio_line_read⚠
Reads the level on a line now.
pamoja_i2c_address_frame⚠
Writes the address bytes a controller puts on the bus for a transfer.
pamoja_i2c_address_frame_len
Returns how many bytes an address frame occupies.
pamoja_i2c_address_is_general_call
Reports whether an address is the general call address 0x00.
pamoja_i2c_address_is_reserved
Reports whether a 7-bit address falls in a range the I2C specification reserves.
pamoja_i2c_address_seven_bit⚠
Validates a 7-bit I2C address.
pamoja_i2c_address_ten_bit⚠
Validates a 10-bit I2C address.
pamoja_pin_edge_triggered_by
Reports whether a change from one level to another fires an interrupt trigger.
pamoja_pin_level_from_bool
Returns the level a boolean names.
pamoja_pin_level_inverted
Returns the opposite level.
pamoja_pin_polarity_is_asserted
Reports whether a physical level means the signal is asserted.
pamoja_pin_polarity_level
Returns the physical level that represents a logical state under a polarity.
pamoja_spi_mode_cpol_cpha⚠
Returns the (CPOL, CPHA) pair an SPI mode number names.
pamoja_spi_mode_from_cpol_cpha
Returns the SPI mode number a (CPOL, CPHA) pair names.