Skip to content

File syn_gpio.h

FileList > drivers > syn_gpio.h

Go to the source code of this file

GPIO driver — high-level convenience functions. More...

  • #include "../common/syn_defs.h"
  • #include "../port/syn_port_gpio.h"

Public Functions

Type Name
SYN_Status syn_gpio_init_multiple (const SYN_GPIO_Pin * pins, size_t count, SYN_GPIO_Mode mode)
Initialize multiple pins with the same mode.
SYN_Status syn_gpio_write_multiple (const SYN_GPIO_Pin * pins, size_t count, SYN_GPIO_State state)
Write the same state to multiple pins.

Public Static Functions

Type Name
SYN_Status syn_gpio_init (SYN_GPIO_Pin pin, SYN_GPIO_Mode mode)
Initialize a GPIO pin.
SYN_GPIO_State syn_gpio_read (SYN_GPIO_Pin pin)
Read a pin's logical state.
SYN_Status syn_gpio_toggle (SYN_GPIO_Pin pin)
Toggle a pin.
SYN_Status syn_gpio_write (SYN_GPIO_Pin pin, SYN_GPIO_State state)
Write a logical state to a pin.

Macros

Type Name
define SYN_GPIO_PIN (port_idx, pin_num) (((uint16\_t)(port\_idx) << 4) \| ((pin\_num) & 0x0F))
Helper macro to pack Port Index (0..15) and Pin Number (0..15) into a 16-bit SYN_GPIO_Pin.
define SYN_GPIO_PIN_NUM (pin) ((uint8\_t)((uint16\_t)(pin) & 0x0F))
Helper macro to extract Pin Number (0..15) from a packed SYN_GPIO_Pin.
define SYN_GPIO_PIN_PORT (pin) ((uint8\_t)(((uint16\_t)(pin) >> 4) & 0x0F))
Helper macro to extract Port Index (0..15) from a packed SYN_GPIO_Pin.

Detailed Description

This module builds on the port layer (syn_port_gpio.h) and adds convenience helpers like bulk operations. For simple use cases you can call the port functions directly — this module is optional.

Public Functions Documentation

function syn_gpio_init_multiple

Initialize multiple pins with the same mode.

SYN_Status syn_gpio_init_multiple (
    const SYN_GPIO_Pin * pins,
    size_t count,
    SYN_GPIO_Mode mode
) 

Parameters:

  • pins Array of pin identifiers.
  • count Number of pins.
  • mode Mode to apply to all pins.

Returns:

SYN_OK if all succeeded, or the first error encountered.


function syn_gpio_write_multiple

Write the same state to multiple pins.

SYN_Status syn_gpio_write_multiple (
    const SYN_GPIO_Pin * pins,
    size_t count,
    SYN_GPIO_State state
) 

Parameters:

  • pins Array of pin identifiers.
  • count Number of pins.
  • state State to write.

Returns:

SYN_OK if all succeeded, or the first error encountered.


Public Static Functions Documentation

function syn_gpio_init

Initialize a GPIO pin.

static inline SYN_Status syn_gpio_init (
    SYN_GPIO_Pin pin,
    SYN_GPIO_Mode mode
) 

Parameters:

  • pin Pin identifier.
  • mode Pin mode (input, output, etc.).

Returns:

SYN_OK on success.


function syn_gpio_read

Read a pin's logical state.

static inline SYN_GPIO_State syn_gpio_read (
    SYN_GPIO_Pin pin
) 

Parameters:

  • pin Pin identifier.

Returns:

Logical state.


function syn_gpio_toggle

Toggle a pin.

static inline SYN_Status syn_gpio_toggle (
    SYN_GPIO_Pin pin
) 

Parameters:

  • pin Pin identifier.

Returns:

SYN_OK on success.


function syn_gpio_write

Write a logical state to a pin.

static inline SYN_Status syn_gpio_write (
    SYN_GPIO_Pin pin,
    SYN_GPIO_State state
) 

Parameters:

  • pin Pin identifier.
  • state Logical state.

Returns:

SYN_OK on success.


Macro Definition Documentation

define SYN_GPIO_PIN

Helper macro to pack Port Index (0..15) and Pin Number (0..15) into a 16-bit SYN_GPIO_Pin.

#define SYN_GPIO_PIN (
    port_idx,
    pin_num
) `(((uint16_t)(port_idx) << 4) | ((pin_num) & 0x0F))`


define SYN_GPIO_PIN_NUM

Helper macro to extract Pin Number (0..15) from a packed SYN_GPIO_Pin.

#define SYN_GPIO_PIN_NUM (
    pin
) `((uint8_t)((uint16_t)(pin) & 0x0F))`


define SYN_GPIO_PIN_PORT

Helper macro to extract Port Index (0..15) from a packed SYN_GPIO_Pin.

#define SYN_GPIO_PIN_PORT (
    pin
) `((uint8_t)(((uint16_t)(pin) >> 4) & 0x0F))`



The documentation for this class was generated from the following file src/syntropic/drivers/syn_gpio.h