Intel® Quark™ Microcontroller Software Interface  1.4.0
Intel® Quark™ Microcontroller BSP
GPIO

General Purpose IO. More...

Data Structures

struct  qm_gpio_port_config_t
 GPIO port configuration type. More...
 

Enumerations

enum  qm_gpio_state_t { QM_GPIO_LOW = 0, QM_GPIO_HIGH, QM_GPIO_STATE_NUM }
 GPIO pin states. More...
 

Functions

int qm_gpio_set_config (const qm_gpio_t gpio, const qm_gpio_port_config_t *const cfg)
 Set GPIO port configuration. More...
 
int qm_gpio_read_pin (const qm_gpio_t gpio, const uint8_t pin, qm_gpio_state_t *const state)
 Read the current state of a single pin on a given GPIO port. More...
 
int qm_gpio_set_pin (const qm_gpio_t gpio, const uint8_t pin)
 Set a single pin on a given GPIO port. More...
 
int qm_gpio_clear_pin (const qm_gpio_t gpio, const uint8_t pin)
 Clear a single pin on a given GPIO port. More...
 
int qm_gpio_set_pin_state (const qm_gpio_t gpio, const uint8_t pin, const qm_gpio_state_t state)
 Set or clear a single GPIO pin using a state variable. More...
 
int qm_gpio_read_port (const qm_gpio_t gpio, uint32_t *const port)
 Read the value of every pin on a GPIO port. More...
 
int qm_gpio_write_port (const qm_gpio_t gpio, const uint32_t val)
 Write a value to every pin on a GPIO port. More...
 
int qm_gpio_save_context (const qm_gpio_t gpio, qm_gpio_context_t *const ctx)
 Save GPIO context. More...
 
int qm_gpio_restore_context (const qm_gpio_t gpio, const qm_gpio_context_t *const ctx)
 Restore GPIO context. More...
 

Detailed Description

General Purpose IO.

Enumeration Type Documentation

GPIO pin states.

Enumerator
QM_GPIO_LOW 

GPIO low state.

QM_GPIO_HIGH 

GPIO high state.

QM_GPIO_STATE_NUM 

Number of GPIO states.

Definition at line 21 of file qm_gpio.h.

Function Documentation

int qm_gpio_clear_pin ( const qm_gpio_t  gpio,
const uint8_t  pin 
)

Clear a single pin on a given GPIO port.

Parameters
[in]gpioGPIO port index.
[in]pinPin of GPIO port to clear.
Returns
int 0 on success, error code otherwise.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 107 of file qm_gpio.c.

int qm_gpio_read_pin ( const qm_gpio_t  gpio,
const uint8_t  pin,
qm_gpio_state_t *const  state 
)

Read the current state of a single pin on a given GPIO port.

Parameters
[in]gpioGPIO port index.
[in]pinPin of GPIO port to read.
[out]stateCurrent state of the pin. This must not be NULL.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 85 of file qm_gpio.c.

int qm_gpio_read_port ( const qm_gpio_t  gpio,
uint32_t *const  port 
)

Read the value of every pin on a GPIO port.

Each bit of the val parameter is set to the current value of each pin on the port. Maximum 32 pins per port.

Parameters
[in]gpioGPIO port index.
[out]portState of every pin in a GPIO port. This must not be NULL.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 131 of file qm_gpio.c.

int qm_gpio_restore_context ( const qm_gpio_t  gpio,
const qm_gpio_context_t *const  ctx 
)
int qm_gpio_set_config ( const qm_gpio_t  gpio,
const qm_gpio_port_config_t *const  cfg 
)

Set GPIO port configuration.

This includes if interrupts are enabled or not, the level on which an interrupt is generated, the polarity of interrupts and if GPIO-debounce is enabled or not. If interrupts are enabled it also registers the user defined callback function.

Parameters
[in]gpioGPIO port index to configure.
[in]cfgNew configuration for GPIO port. This must not be NULL.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 59 of file qm_gpio.c.

References qm_gpio_port_config_t::callback, qm_gpio_port_config_t::callback_data, qm_gpio_port_config_t::direction, qm_gpio_reg_t::gpio_debounce, qm_gpio_reg_t::gpio_int_bothedge, qm_gpio_reg_t::gpio_int_polarity, qm_gpio_reg_t::gpio_inten, qm_gpio_reg_t::gpio_intmask, qm_gpio_reg_t::gpio_inttype_level, qm_gpio_reg_t::gpio_ls_sync, qm_gpio_reg_t::gpio_swporta_ddr, qm_gpio_port_config_t::int_bothedge, qm_gpio_port_config_t::int_debounce, qm_gpio_port_config_t::int_en, qm_gpio_port_config_t::int_polarity, and qm_gpio_port_config_t::int_type.

int qm_gpio_set_pin ( const qm_gpio_t  gpio,
const uint8_t  pin 
)

Set a single pin on a given GPIO port.

Parameters
[in]gpioGPIO port index.
[in]pinPin of GPIO port to set.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 97 of file qm_gpio.c.

int qm_gpio_set_pin_state ( const qm_gpio_t  gpio,
const uint8_t  pin,
const qm_gpio_state_t  state 
)

Set or clear a single GPIO pin using a state variable.

Parameters
[in]gpioGPIO port index.
[in]pinPin of GPIO port to update.
[in]stateQM_GPIO_LOW for low or QM_GPIO_HIGH for high.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 117 of file qm_gpio.c.

References QM_GPIO_STATE_NUM.

int qm_gpio_write_port ( const qm_gpio_t  gpio,
const uint32_t  val 
)

Write a value to every pin on a GPIO port.

Each pin on the GPIO port is set to the corresponding value set in the val parameter. Maximum 32 pins per port.

Parameters
[in]gpioGPIO port index.
[in]valValue of all pins on GPIO port.
Returns
Standard errno return type for QMSI.
Return values
0on success.
Negativeerrno for possible error codes.

Definition at line 141 of file qm_gpio.c.