Functions for using General Purpose Input/Output (GPIO) peripheral. More...

Modules

Types
Hardware GPIO data types.
 

Functions

gos_result_t gos_gpio_init (gos_gpio_t gpio, gos_gpio_config_t direction, bool init_val)
 Initialize GPIO as input or output. More...
 
gos_result_t gos_gpio_direct_init (gos_gpio_t gpio, gos_gpio_config_t direction)
 Initialize GPIO as input or output. More...
 
gos_result_t gos_gpio_deinit (gos_gpio_t gpio)
 De-initialize a GPIO. This is the equivalent of using the Command API function gpio_dir with argument none More...
 
gos_result_t gos_gpio_set (gos_gpio_t gpio, bool value)
 Set value of output GPIO (HIGH or LOW) More...
 
gos_result_t gos_gpio_direct_set (gos_gpio_t gpio, bool value)
 Set value of output GPIO (HIGH or LOW) More...
 
bool gos_gpio_get (gos_gpio_t gpio)
 Get value of GPIO. More...
 
gos_result_t gos_gpio_irq_enable (gos_gpio_t gpio, gos_gpio_irq_trigger_t edge, gos_handler_t callback, void *arg)
 Execute the given callback when the specified edge event is detected on the GPIO. More...
 
gos_result_t gos_gpio_irq_disable (gos_gpio_t gpio)
 Disables an interrupt trigger for an input GPIO pin. More...
 
gos_result_t gos_gpio_mask_set (uint32_t gpio_mask)
 Set output GPIOs HIGH. More...
 
gos_result_t gos_gpio_mask_clear (uint32_t gpio_mask)
 Set output GPIOs LOW. More...
 
uint32_t gos_gpio_mask_get (uint32_t gpio_mask)
 Return value of GPIOs. More...
 

Detailed Description

Functions for using General Purpose Input/Output (GPIO) peripheral.

Function Documentation

◆ gos_gpio_deinit()

gos_result_t gos_gpio_deinit ( gos_gpio_t  gpio)

De-initialize a GPIO. This is the equivalent of using the Command API function gpio_dir with argument none

See Gecko OS Command API documentation: gpio_dir.

Note
The GPIO must be initialized with gos_gpio_init() first.

◆ gos_gpio_direct_init()

gos_result_t gos_gpio_direct_init ( gos_gpio_t  gpio,
gos_gpio_config_t  direction 
)

Initialize GPIO as input or output.

Note
This only initializes the GPIO at the hardware level. Use gos_gpio_init() for Gecko OS to be aware of this GPIO.

◆ gos_gpio_direct_set()

gos_result_t gos_gpio_direct_set ( gos_gpio_t  gpio,
bool  value 
)

Set value of output GPIO (HIGH or LOW)

Note
This bypass Gecko OS and directly accesses the GPIO driver.

◆ gos_gpio_get()

bool gos_gpio_get ( gos_gpio_t  gpio)

Get value of GPIO.

See Gecko OS Command API documentation: gpio_set.

Note
The gpio need NOT be initialized as an input first.
Examples:
dms/messages/main.c, dms/telemetry/main.c, network/http_server/requests/json_generator.c, peripheral/gpio_irq/main.c, utility/msgpack/read_write_buffer.c, and utility/msgpack/read_write_stream.c.

◆ gos_gpio_init()

gos_result_t gos_gpio_init ( gos_gpio_t  gpio,
gos_gpio_config_t  direction,
bool  init_val 
)

Initialize GPIO as input or output.

See Gecko OS Command API documentation: gpio_dir.

Examples:
dms/messages/main.c, dms/telemetry/main.c, intro/blinky/main.c, network/http_server/main.c, and peripheral/gpio_irq/main.c.

◆ gos_gpio_irq_disable()

gos_result_t gos_gpio_irq_disable ( gos_gpio_t  gpio)

Disables an interrupt trigger for an input GPIO pin.

Disables an interrupt trigger for an input GPIO pin. Using this function on a gpio pin which has not been set up using gos_gpio_irq_enable() is undefined.

Parameters
gpio: the gpio pin which provided the interrupt trigger

◆ gos_gpio_irq_enable()

gos_result_t gos_gpio_irq_enable ( gos_gpio_t  gpio,
gos_gpio_irq_trigger_t  edge,
gos_handler_t  callback,
void *  arg 
)

Execute the given callback when the specified edge event is detected on the GPIO.

The callback is executed in the IRQ context and MUST be very light-weight. All heavy processing should be deferred to the app thread.

Note
The corresponding GPIO need MUST be configured as an input first.
Examples:
peripheral/gpio_irq/main.c.

◆ gos_gpio_mask_clear()

gos_result_t gos_gpio_mask_clear ( uint32_t  gpio_mask)

Set output GPIOs LOW.

For any bit in the mask that's '1', the corresponding GPIO's value is driven LOW ('0' valued bits are ignored)

Note
The corresponding GPIO must be configured as an OUTPUT first.

◆ gos_gpio_mask_get()

uint32_t gos_gpio_mask_get ( uint32_t  gpio_mask)

Return value of GPIOs.

For any bit in the mask that's '1', the corresponding GPIO's value is read and returned in the value mask.

Note
The corresponding GPIO need NOT be configured as an input first.
Examples:
file/log_file/main.c, file/log_file_encrypted/main.c, network/tcp_client/main.c, network/udp_client/main.c, network/udp_hello_gpio/main.c, and network/websocket_client/main.c.

◆ gos_gpio_mask_set()

gos_result_t gos_gpio_mask_set ( uint32_t  gpio_mask)

Set output GPIOs HIGH.

For any bit in the mask that's '1', the corresponding GPIO's value is driven HIGH ('0' valued bits are ignored)

Note
The corresponding GPIO must be configured as an OUTPUT first.

◆ gos_gpio_set()

gos_result_t gos_gpio_set ( gos_gpio_t  gpio,
bool  value 
)