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

Modules

Types
Hardware GPIO data types.
 

Functions

zos_result_t zn_gpio_init (zos_gpio_t gpio, zos_gpio_direction_t direction, zos_bool_t init_val)
 Initialize GPIO as input or output. More...
 
zos_result_t zn_gpio_direct_init (zos_gpio_t gpio, zos_gpio_direction_t direction)
 Initialize GPIO as input or output. More...
 
zos_result_t zn_gpio_deinit (zos_gpio_t gpio)
 De-initialize a GPIO. More...
 
zos_result_t zn_gpio_set (zos_gpio_t gpio, zos_bool_t value)
 Set value of output GPIO (HIGH or LOW) More...
 
zos_result_t zn_gpio_direct_set (zos_gpio_t gpio, zos_bool_t value)
 Set value of output GPIO (HIGH or LOW) More...
 
zos_bool_t zn_gpio_get (zos_gpio_t gpio)
 Get value of GPIO. More...
 
zos_result_t zn_gpio_irq_enable (zos_gpio_t gpio, zos_gpio_irq_trigger_t edge, zos_gpio_irq_callback_t callback, void *arg)
 Execute the given callback when the specified edge event is detected on the GPIO. More...
 
zos_result_t zn_gpio_irq_disable (zos_gpio_t gpio)
 Disables an interrupt trigger for an input GPIO pin. More...
 
zos_result_t zn_gpio_mask_set (uint32_t gpio_mask)
 Set output GPIOs HIGH. More...
 
zos_result_t zn_gpio_mask_clear (uint32_t gpio_mask)
 Set output GPIOs LOW. More...
 
uint32_t zn_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

zos_result_t zn_gpio_deinit ( zos_gpio_t  gpio)

De-initialize a GPIO.

This is the equivalent of using the Command API function gpio_dir with argument none

See ZentriOS Command API documentation: gpio_dir.

Note
The GPIO must be initialized with zn_gpio_init() first.
zos_result_t zn_gpio_direct_init ( zos_gpio_t  gpio,
zos_gpio_direction_t  direction 
)

Initialize GPIO as input or output.

Note
This only initializes the GPIO at the hardware level. Use zn_gpio_init() for ZentriOS to be aware of this GPIO.
zos_result_t zn_gpio_direct_set ( zos_gpio_t  gpio,
zos_bool_t  value 
)

Set value of output GPIO (HIGH or LOW)

Note
This bypass ZentriOS and directly accesses the GPIO driver.
zos_bool_t zn_gpio_get ( zos_gpio_t  gpio)

Get value of GPIO.

See ZentriOS Command API documentation: gpio_set.

Note
The gpio need NOT be initialized as an input first.
Examples:
basic/gpio/gpio.c, basic/http_server/json_generator_request_processor.c, basic/http_stream/http_stream.c, and cloud/simplemq/main.c.
zos_result_t zn_gpio_irq_disable ( zos_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 zn_gpio_irq_enable() is undefined.

Parameters
gpio: the gpio pin which provided the interrupt trigger
Examples:
basic/gpio/gpio.c, basic/http_stream/http_stream.c, and sensors/accel_interrupt/main.c.
zos_result_t zn_gpio_irq_enable ( zos_gpio_t  gpio,
zos_gpio_irq_trigger_t  edge,
zos_gpio_irq_callback_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 ZAP.

Note
The corresponding GPIO need MUST be configured as an input first.
Examples:
basic/gpio/gpio.c, basic/http_stream/http_stream.c, and sensors/accel_interrupt/main.c.
zos_result_t zn_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.
uint32_t zn_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.
zos_result_t zn_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.