SmartSnippets DA1459x SDK
Files | Macros | Enumerations | Functions | Variables

General Purpose I/O Controller. More...

Files

file  hw_gpio.h
 Definition of API for the GPIO Low Level Driver.
 

Macros

#define HW_GPIO_SET_PIN_FUNCTION(X)   hw_gpio_set_pin_function(X##_PORT, X##_PIN, X##_MODE, X##_FUNC);
 
#define HW_GPIO_NUM_PORTS   (2)
 
#define HW_GPIO_NUM_PINS   (HW_GPIO_PORT_0_NUM_PINS + HW_GPIO_PORT_1_NUM_PINS)
 
#define HW_GPIO_PIN_BITS   (4)
 
#define HW_GPIO_PORT_0_NUM_PINS   (16)
 
#define HW_GPIO_PORT_1_NUM_PINS   (16)
 
#define HW_GPIO_PORT_NONE   (HW_GPIO_PORT_MAX)
 
#define HW_GPIO_PIN_NONE   (HW_GPIO_PIN_MAX)
 
#define HW_GPIO_MODE_NONE   (HW_GPIO_MODE_INVALID)
 
#define HW_GPIO_PINCONFIG(xport, xpin, xmode, xfunc, xhigh)
 GPIO pin configuration for gpio_config. More...
 
#define HW_GPIO_PINCONFIG_RESERVE(xport, xpin, xmode, xfunc, xhigh)
 GPIO pin configuration and reservation for gpio_config. More...
 
#define HW_GPIO_PINCONFIG_END
 Macro to properly terminate array of gpio_config definition. More...
 

Enumerations

enum  HW_GPIO_MODE {
  HW_GPIO_MODE_INPUT = 0, HW_GPIO_MODE_INPUT_PULLUP = 0x100, HW_GPIO_MODE_INPUT_PULLDOWN = 0x200, HW_GPIO_MODE_OUTPUT = 0x300,
  HW_GPIO_MODE_OUTPUT_PUSH_PULL = 0x300, HW_GPIO_MODE_OUTPUT_OPEN_DRAIN = 0x700, HW_GPIO_MODE_INVALID = 0xFFF
}
 GPIO input/output mode. More...
 
enum  HW_GPIO_PORT { HW_GPIO_PORT_0 = 0, HW_GPIO_PORT_1 = 1, HW_GPIO_PORT_MAX }
 GPIO port number. More...
 
enum  HW_GPIO_PIN {
  HW_GPIO_PIN_0 = 0, HW_GPIO_PIN_1 = 1, HW_GPIO_PIN_2 = 2, HW_GPIO_PIN_3 = 3,
  HW_GPIO_PIN_4 = 4, HW_GPIO_PIN_5 = 5, HW_GPIO_PIN_6 = 6, HW_GPIO_PIN_7 = 7,
  HW_GPIO_PIN_8 = 8, HW_GPIO_PIN_9 = 9, HW_GPIO_PIN_10 = 10, HW_GPIO_PIN_11 = 11,
  HW_GPIO_PIN_12 = 12, HW_GPIO_PIN_13 = 13, HW_GPIO_PIN_14 = 14, HW_GPIO_PIN_15 = 15,
  HW_GPIO_PIN_MAX
}
 GPIO pin number. More...
 
enum  HW_GPIO_FUNC {
  HW_GPIO_FUNC_GPIO = 0, HW_GPIO_FUNC_UART_RX = 1, HW_GPIO_FUNC_UART_TX = 2, HW_GPIO_FUNC_UART2_RX = 3,
  HW_GPIO_FUNC_UART2_TX = 4, HW_GPIO_FUNC_UART2_CTSN = 5, HW_GPIO_FUNC_UART2_RTSN = 6, HW_GPIO_FUNC_ISO_CLK = 7,
  HW_GPIO_FUNC_ISO_DATA = 8, HW_GPIO_FUNC_SPI_DI = 9, HW_GPIO_FUNC_SPI_DO = 10, HW_GPIO_FUNC_SPI_CLK = 11,
  HW_GPIO_FUNC_SPI_EN = 12, HW_GPIO_FUNC_SPI_EN2 = 13, HW_GPIO_FUNC_I2C_SCL = 14, HW_GPIO_FUNC_I2C_SDA = 15,
  HW_GPIO_FUNC_ADC = 16, HW_GPIO_FUNC_PCM_DI = 17, HW_GPIO_FUNC_PCM_DO = 18, HW_GPIO_FUNC_PCM_FSC = 19,
  HW_GPIO_FUNC_PCM_CLK = 20, HW_GPIO_FUNC_PDM_DATA = 21, HW_GPIO_FUNC_PDM_CLK = 22, HW_GPIO_FUNC_CLOCK = 23,
  HW_GPIO_FUNC_TIM_PWM = 24, HW_GPIO_FUNC_TIM2_PWM = 25, HW_GPIO_FUNC_TIM_1SHOT = 26, HW_GPIO_FUNC_TIM2_1SHOT = 27,
  HW_GPIO_FUNC_TIM3_PWM = 28, HW_GPIO_FUNC_TIM4_PWM = 29, HW_GPIO_FUNC_COEX_EXT_ACT = 30, HW_GPIO_FUNC_COEX_SMART_ACT = 31,
  HW_GPIO_FUNC_COEX_SMART_PRI = 32, HW_GPIO_FUNC_PORT0_DCF = 33, HW_GPIO_FUNC_PORT1_DCF = 34, HW_GPIO_FUNC_PORT2_DCF = 35,
  HW_GPIO_FUNC_PORT3_DCF = 36, HW_GPIO_FUNC_PORT4_DCF = 37, HW_GPIO_FUNC_CMAC_DIAG0 = 38, HW_GPIO_FUNC_CMAC_DIAG1 = 39,
  HW_GPIO_FUNC_CMAC_DIAG2 = 40, HW_GPIO_FUNC_CMAC_DIAG3 = 41, HW_GPIO_FUNC_CMAC_DIAG4 = 42, HW_GPIO_FUNC_CMAC_DIAG5 = 43,
  HW_GPIO_FUNC_CMAC_DIAG6 = 44, HW_GPIO_FUNC_CMAC_DIAG7 = 45, HW_GPIO_FUNC_CMAC_DIAG8 = 46, HW_GPIO_FUNC_CMAC_DIAG9 = 47,
  HW_GPIO_FUNC_CMAC_DIAG10 = 48, HW_GPIO_FUNC_CMAC_DIAG11 = 49, HW_GPIO_FUNC_CMAC_DIAG12 = 50, HW_GPIO_FUNC_CMAC_DIAG13 = 51,
  HW_GPIO_FUNC_CMAC_DIAG14 = 52, HW_GPIO_FUNC_CMAC_DIAG15 = 53
}
 GPIO function. More...
 
enum  HW_GPIO_CLK
 Clocks that can be mapped to GPIOs. More...
 
enum  HW_GPIO_DRIVE_STRENGTH { HW_GPIO_DRIVE_STRENGTH_NORMAL = 0, HW_GPIO_DRIVE_STRENGTH_WEAK }
 GPIOs Drive Strength. More...
 

Functions

void hw_gpio_configure (const gpio_config cfg[])
 GPIO configuration. More...
 
bool hw_gpio_reserve_pin (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Reserve GPIO pin. More...
 
bool hw_gpio_reserve_and_configure_pin (HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_GPIO_MODE mode, HW_GPIO_FUNC function, bool high)
 Reserve GPIO pin and set pin function. More...
 
void hw_gpio_unreserve_pin (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Unreserve GPIO pin. More...
 
void hw_gpio_set_pin_function (HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_GPIO_MODE mode, HW_GPIO_FUNC function)
 Set the pin type and mode. More...
 
void hw_gpio_get_pin_function (HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_GPIO_MODE *mode, HW_GPIO_FUNC *function)
 Get the pin type and mode. More...
 
void hw_gpio_set_pin_drive_strength (HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_GPIO_DRIVE_STRENGTH strength)
 Set the pin drive strength. More...
 
HW_GPIO_DRIVE_STRENGTH hw_gpio_get_pin_drive_strength (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Get the pin drive strength. More...
 
void hw_gpio_configure_pin (HW_GPIO_PORT port, HW_GPIO_PIN pin, HW_GPIO_MODE mode, HW_GPIO_FUNC function, const bool high)
 Combined function to set the state and the type and mode of the GPIO pin. More...
 
void hw_gpio_set_active (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Set a GPIO in high state. More...
 
void hw_gpio_set_inactive (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Set a GPIO in low state. More...
 
bool hw_gpio_get_pin_status (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Get the GPIO status. More...
 
void hw_gpio_toggle (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Toggle GPIO pin state. More...
 
int hw_gpio_get_pins_with_function (HW_GPIO_FUNC func, uint8_t *buf, int buf_size)
 Find pins with specific function. More...
 
__STATIC_FORCEINLINE void hw_gpio_pad_latch_disable_all (void)
 Disables the latches of all gpios. More...
 
__STATIC_FORCEINLINE void hw_gpio_pad_latch_enable_all (void)
 Enables the latches of all gpios. More...
 
__STATIC_FORCEINLINE void hw_gpio_pad_latch_enable (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Enables the latch for the specific gpio. More...
 
__STATIC_FORCEINLINE void hw_gpio_pad_latch_disable (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Disables the latch for the specific gpio. More...
 
__STATIC_FORCEINLINE bool hw_gpio_pad_latch_is_enabled (HW_GPIO_PORT port, HW_GPIO_PIN pin)
 Checks if the specific GPIO is latched or not. More...
 
bool hw_gpio_get_pin_with_function (HW_GPIO_FUNC func, HW_GPIO_PORT *port, HW_GPIO_PIN *pin)
 Find GPIO with specific function. More...
 
__STATIC_INLINE void hw_gpio_clk_output_enable (HW_GPIO_CLK clk)
 Enable mapping of selected clock to the respective GPIO. More...
 
__STATIC_INLINE void hw_gpio_clk_output_disable (HW_GPIO_CLK clk)
 Disable mapping of selected clock to the respective GPIO. More...
 
__STATIC_INLINE void hw_gpio_clk_func_enable (void)
 Enable the mapping of the selected clock signal, according to FUNC_CLOCK_SEL bit-field. More...
 
__STATIC_INLINE void hw_gpio_clk_func_disable (void)
 Disable the mapping of the selected clock signal, according to FUNC_CLOCK_SEL bit-field. More...
 
__STATIC_INLINE void hw_gpio_clk_func_sel (HW_GPIO_CLK clk_src)
 Select which clock to map when GPIO function is FUNC_CLOCK. More...
 
__STATIC_INLINE void hw_gpio_configure_por_pin (HW_GPIO_PORT port, HW_GPIO_PIN pin, bool polarity)
 Select a pin as a POR trigger source. More...
 

Variables

typedef __PACKED_STRUCT
 GPIO pin configuration. More...
 
HW_GPIO_MODE mode
 
HW_GPIO_FUNC func
 
bool high
 

Detailed Description

General Purpose I/O Controller.

Macro Definition Documentation

◆ HW_GPIO_MODE_NONE

#define HW_GPIO_MODE_NONE   (HW_GPIO_MODE_INVALID)

Definition for invalid GPIO mode

◆ HW_GPIO_NUM_PINS

#define HW_GPIO_NUM_PINS   (HW_GPIO_PORT_0_NUM_PINS + HW_GPIO_PORT_1_NUM_PINS)

Number of GPIO pins available (cumulative)

◆ HW_GPIO_NUM_PORTS

#define HW_GPIO_NUM_PORTS   (2)

Number of GPIO ports available

◆ HW_GPIO_PIN_BITS

#define HW_GPIO_PIN_BITS   (4)

Number of bits required to store any pin number

◆ HW_GPIO_PIN_NONE

#define HW_GPIO_PIN_NONE   (HW_GPIO_PIN_MAX)

Definition for invalid GPIO pin

◆ HW_GPIO_PINCONFIG

#define HW_GPIO_PINCONFIG (   xport,
  xpin,
  xmode,
  xfunc,
  xhigh 
)
Value:
{ \
.pin = (xport << HW_GPIO_PIN_BITS) | (xpin & ((1 << HW_GPIO_PIN_BITS) - 1)), \
.mode = HW_GPIO_MODE_ ## xmode, \
.func = HW_GPIO_FUNC_ ## xfunc, \
.high = xhigh, \
.reserve = false, \
}

GPIO pin configuration for gpio_config.

xport and xpin are specified as symbols from HW_GPIO_PORT and HW_GPIO_PIN enums respectively or more conveniently as plain numeric values. xmode and xfunc have the same values as defined in HW_GPIO_MODE and HW_GPIO_FUNC enums respectively, except they have prefix stripped.

Parameters
[in]xportport number
[in]xpinpin number
[in]xmodepin mode
[in]xfuncpin function
[in]xhightrue for high state, false otherwise

◆ HW_GPIO_PINCONFIG_END

#define HW_GPIO_PINCONFIG_END
Value:
{ \
.pin = 0xFF, \
}

Macro to properly terminate array of gpio_config definition.

◆ HW_GPIO_PINCONFIG_RESERVE

#define HW_GPIO_PINCONFIG_RESERVE (   xport,
  xpin,
  xmode,
  xfunc,
  xhigh 
)
Value:
{ \
.pin = (xport << HW_GPIO_PIN_BITS) | (xpin & ((1 << HW_GPIO_PIN_BITS) - 1)), \
.mode = HW_GPIO_MODE_ ## xmode, \
.func = HW_GPIO_FUNC_ ## xfunc, \
.high = xhigh, \
.reserve = true, \
}

GPIO pin configuration and reservation for gpio_config.

This macro is virtually identical to HW_GPIO_PINCONFIG, except it also reserves pin.

Parameters
[in]xportport number
[in]xpinpin number
[in]xmodepin mode
[in]xfuncpin function
[in]xhightrue for high state, false otherwise
See also
HW_GPIO_PINCONFIG

◆ HW_GPIO_PORT_0_NUM_PINS

#define HW_GPIO_PORT_0_NUM_PINS   (16)

Number of GPIO pins available in port 0

◆ HW_GPIO_PORT_1_NUM_PINS

#define HW_GPIO_PORT_1_NUM_PINS   (16)

Number of GPIO pins available in port 1

◆ HW_GPIO_PORT_NONE

#define HW_GPIO_PORT_NONE   (HW_GPIO_PORT_MAX)

Definition for invalid GPIO port

◆ HW_GPIO_SET_PIN_FUNCTION

#define HW_GPIO_SET_PIN_FUNCTION (   X)    hw_gpio_set_pin_function(X##_PORT, X##_PIN, X##_MODE, X##_FUNC);

Definitions of boards UART retarget GPIO pins, mode and function

Enumeration Type Documentation

◆ HW_GPIO_CLK

Clocks that can be mapped to GPIOs.

◆ HW_GPIO_DRIVE_STRENGTH

GPIOs Drive Strength.

Enumerator
HW_GPIO_DRIVE_STRENGTH_NORMAL 

pin configured with normal (full) drive strength (default)

HW_GPIO_DRIVE_STRENGTH_WEAK 

pin configured with weak (reduced) drive strength

◆ HW_GPIO_FUNC

GPIO function.

Enumerator
HW_GPIO_FUNC_GPIO 

GPIO

HW_GPIO_FUNC_UART_RX 

GPIO as UART RX

HW_GPIO_FUNC_UART_TX 

GPIO as UART TX

HW_GPIO_FUNC_UART2_RX 

GPIO as UART2 RX

HW_GPIO_FUNC_UART2_TX 

GPIO as UART2 TX

HW_GPIO_FUNC_UART2_CTSN 

GPIO as UART2 CTSN

HW_GPIO_FUNC_UART2_RTSN 

GPIO as UART2 RTSN

HW_GPIO_FUNC_ISO_CLK 

GPIO as ISO CLK

HW_GPIO_FUNC_ISO_DATA 

GPIO as ISO DATA

HW_GPIO_FUNC_SPI_DI 

GPIO as SPI DI

HW_GPIO_FUNC_SPI_DO 

GPIO as SPI DO

HW_GPIO_FUNC_SPI_CLK 

GPIO as SPI CLK

HW_GPIO_FUNC_SPI_EN 

GPIO as SPI EN

HW_GPIO_FUNC_SPI_EN2 

GPIO as SPI EN

HW_GPIO_FUNC_I2C_SCL 

GPIO as I2C2 SCL

HW_GPIO_FUNC_I2C_SDA 

GPIO as I2C2 SDA

HW_GPIO_FUNC_ADC 

GPIO as ADC (dedicated pin)

HW_GPIO_FUNC_PCM_DI 

GPIO as PCM DI

HW_GPIO_FUNC_PCM_DO 

GPIO as PCM DO

HW_GPIO_FUNC_PCM_FSC 

GPIO as PCM FSC

HW_GPIO_FUNC_PCM_CLK 

GPIO as PCM CLK

HW_GPIO_FUNC_PDM_DATA 

GPIO as PDM DATA

HW_GPIO_FUNC_PDM_CLK 

GPIO as PDM CLK

HW_GPIO_FUNC_CLOCK 

GPIO as CLOCK

HW_GPIO_FUNC_TIM_PWM 

GPIO as TIM PWM

HW_GPIO_FUNC_TIM2_PWM 

GPIO as TIM2 PWM

HW_GPIO_FUNC_TIM_1SHOT 

GPIO as TIM 1SHOT

HW_GPIO_FUNC_TIM2_1SHOT 

GPIO as TIM2 1SHOT

HW_GPIO_FUNC_TIM3_PWM 

GPIO as TIM3 PWM

HW_GPIO_FUNC_TIM4_PWM 

GPIO as TIM4 PWM

HW_GPIO_FUNC_COEX_EXT_ACT 

GPIO as COEX EXT ACT0

HW_GPIO_FUNC_COEX_SMART_ACT 

GPIO as COEX SMART ACT

HW_GPIO_FUNC_COEX_SMART_PRI 

GPIO as COEX SMART PRI

HW_GPIO_FUNC_PORT0_DCF 

GPIO as PORT0 DCF

HW_GPIO_FUNC_PORT1_DCF 

GPIO as PORT1 DCF

HW_GPIO_FUNC_PORT2_DCF 

GPIO as PORT2 DCF

HW_GPIO_FUNC_PORT3_DCF 

GPIO as PORT3 DCF

HW_GPIO_FUNC_PORT4_DCF 

GPIO as PORT4 DCF

HW_GPIO_FUNC_CMAC_DIAG0 

GPIO as CMAC DIAG0

HW_GPIO_FUNC_CMAC_DIAG1 

GPIO as CMAC DIAG1

HW_GPIO_FUNC_CMAC_DIAG2 

GPIO as CMAC DIAG2

HW_GPIO_FUNC_CMAC_DIAG3 

GPIO as CMAC DIAG3

HW_GPIO_FUNC_CMAC_DIAG4 

GPIO as CMAC DIAG4

HW_GPIO_FUNC_CMAC_DIAG5 

GPIO as CMAC DIAG5

HW_GPIO_FUNC_CMAC_DIAG6 

GPIO as CMAC DIAG6

HW_GPIO_FUNC_CMAC_DIAG7 

GPIO as CMAC DIAG7

HW_GPIO_FUNC_CMAC_DIAG8 

GPIO as CMAC DIAG8

HW_GPIO_FUNC_CMAC_DIAG9 

GPIO as CMAC DIAG9

HW_GPIO_FUNC_CMAC_DIAG10 

GPIO as CMAC DIAG10

HW_GPIO_FUNC_CMAC_DIAG11 

GPIO as CMAC DIAG11

HW_GPIO_FUNC_CMAC_DIAG12 

GPIO as CMAC DIAG12

HW_GPIO_FUNC_CMAC_DIAG13 

GPIO as CMAC DIAG13

HW_GPIO_FUNC_CMAC_DIAG14 

GPIO as CMAC DIAG14

HW_GPIO_FUNC_CMAC_DIAG15 

GPIO as CMAC DIAG15

◆ HW_GPIO_MODE

GPIO input/output mode.

Enumerator
HW_GPIO_MODE_INPUT 

GPIO as an input

HW_GPIO_MODE_INPUT_PULLUP 

GPIO as an input with pull-up

HW_GPIO_MODE_INPUT_PULLDOWN 

GPIO as an input with pull-down

HW_GPIO_MODE_OUTPUT 

GPIO as an (implicitly push-pull) output

HW_GPIO_MODE_OUTPUT_PUSH_PULL 

GPIO as an (explicitly push-pull) output

HW_GPIO_MODE_OUTPUT_OPEN_DRAIN 

GPIO as an open-drain output

HW_GPIO_MODE_INVALID 

GPIO configured as nothing

◆ HW_GPIO_PIN

GPIO pin number.

Enumerator
HW_GPIO_PIN_0 

GPIO Pin 0

HW_GPIO_PIN_1 

GPIO Pin 1

HW_GPIO_PIN_2 

GPIO Pin 2

HW_GPIO_PIN_3 

GPIO Pin 3

HW_GPIO_PIN_4 

GPIO Pin 4

HW_GPIO_PIN_5 

GPIO Pin 5

HW_GPIO_PIN_6 

GPIO Pin 6

HW_GPIO_PIN_7 

GPIO Pin 7

HW_GPIO_PIN_8 

GPIO Pin 8

HW_GPIO_PIN_9 

GPIO Pin 9

HW_GPIO_PIN_10 

GPIO Pin 10

HW_GPIO_PIN_11 

GPIO Pin 11

HW_GPIO_PIN_12 

GPIO Pin 12

HW_GPIO_PIN_13 

GPIO Pin 13

HW_GPIO_PIN_14 

GPIO Pin 14

HW_GPIO_PIN_15 

GPIO Pin 15

HW_GPIO_PIN_MAX 

GPIO Pin max

◆ HW_GPIO_PORT

GPIO port number.

Enumerator
HW_GPIO_PORT_0 

GPIO Port 0

HW_GPIO_PORT_1 

GPIO Port 1

HW_GPIO_PORT_MAX 

GPIO Port max

Function Documentation

◆ hw_gpio_clk_func_disable()

__STATIC_INLINE void hw_gpio_clk_func_disable ( void  )

Disable the mapping of the selected clock signal, according to FUNC_CLOCK_SEL bit-field.

◆ hw_gpio_clk_func_enable()

__STATIC_INLINE void hw_gpio_clk_func_enable ( void  )

Enable the mapping of the selected clock signal, according to FUNC_CLOCK_SEL bit-field.

◆ hw_gpio_clk_func_sel()

__STATIC_INLINE void hw_gpio_clk_func_sel ( HW_GPIO_CLK  clk_src)

Select which clock to map when GPIO function is FUNC_CLOCK.

◆ hw_gpio_clk_output_disable()

__STATIC_INLINE void hw_gpio_clk_output_disable ( HW_GPIO_CLK  clk)

Disable mapping of selected clock to the respective GPIO.

Parameters
[in]clkThe clock that will no longer be mapped to a GPIO

◆ hw_gpio_clk_output_enable()

__STATIC_INLINE void hw_gpio_clk_output_enable ( HW_GPIO_CLK  clk)

Enable mapping of selected clock to the respective GPIO.

DIVN is mapped to GPIO P0_8 XTAL32M is mapped to GPIO P0_11 RC32M is mapped to GPIO P1_02

Parameters
[in]clkThe clock that will be mapped to a GPIO

◆ hw_gpio_configure()

void hw_gpio_configure ( const gpio_config  cfg[])

GPIO configuration.

This is a shortcut to configure multiple GPIOs in one call. cfg is an array of GPIO pins configuration, it should be terminated by dummy element with pin member set to 0xFF (macro HW_GPIO_PINCONFIG can be used for this purpose).

Parameters
[in]cfgGPIO pins configuration
See also
hw_gpio_configure_pin
hw_gpio_set_pin_function

◆ hw_gpio_configure_pin()

void hw_gpio_configure_pin ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin,
HW_GPIO_MODE  mode,
HW_GPIO_FUNC  function,
const bool  high 
)

Combined function to set the state and the type and mode of the GPIO pin.

Parameters
[in]portGPIO port
[in]pinGPIO pin
[in]modeGPIO pin mode
[in]functionGPIO pin usage
[in]highset to TRUE to set the pin into high else low

◆ hw_gpio_configure_por_pin()

__STATIC_INLINE void hw_gpio_configure_por_pin ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin,
bool  polarity 
)

Select a pin as a POR trigger source.

This function configures a GPIO pin as capable of triggering a Power-On Reset (POR) of the system, if asserted with a certain, configurable, polarity.

Parameters
[in]portGPIO port number
[in]pinGPIO pin number
[in]polarity0: Active Low, 1: Active High
Note
Use hw_sys_set_por_timer() to set the desired POR time threshold (unless the default value is used).
Only one GPIO pin can be selected (selecting a new GPIO pin cancels any existing selection). Similarly, specifying an invalid set of port/pin numbers (i.e. corresponding to a non-existing pin) cancels any existing selection and, in that case (which is the default), no GPIO pin can trigger a POR. (The nRST pin can still be used though.)
See also
hw_sys_set_por_timer()

◆ hw_gpio_get_pin_drive_strength()

HW_GPIO_DRIVE_STRENGTH hw_gpio_get_pin_drive_strength ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Get the pin drive strength.

Parameters
[in]portGPIO port
[in]pinGPIO pin
Returns
HW_GPIO_DRIVE_STRENGTH the GPIO Drive Strength

◆ hw_gpio_get_pin_function()

void hw_gpio_get_pin_function ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin,
HW_GPIO_MODE mode,
HW_GPIO_FUNC function 
)

Get the pin type and mode.

Parameters
[in]portGPIO port
[in]pinGPIO pin
[out]modeGPIO pin mode
[out]functionGPIO pin usage

◆ hw_gpio_get_pin_status()

bool hw_gpio_get_pin_status ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Get the GPIO status.

The GPIO should have been previously configured as input!

Parameters
[in]portGPIO port
[in]pinGPIO pin
Returns
true if the pin is high, false if low

◆ hw_gpio_get_pin_with_function()

bool hw_gpio_get_pin_with_function ( HW_GPIO_FUNC  func,
HW_GPIO_PORT port,
HW_GPIO_PIN pin 
)

Find GPIO with specific function.

Parameters
[in]funcfunction to lookup
[out]portThe GPIO port of the gpio configured with the specific function
[out]pinThe GPIO pin of the gpio configured with the specific function
Returns
true if the port / pin pair for the specific function was found, else false.

◆ hw_gpio_get_pins_with_function()

int hw_gpio_get_pins_with_function ( HW_GPIO_FUNC  func,
uint8_t *  buf,
int  buf_size 
)

Find pins with specific function.

Function searches for pins configured for specific function. If buf is not NULL and buf_size is greater than 0 pins are stored in buf high-nibble is port number and low-nibble is pin. If number of pins found is greater then buf_size only buf_size entries are filled, though the returned number of found pins is correct.

Parameters
[in]funcfunction to lookup
[out]bufbuffer for port-pin pairs that are configured for specific function
[in]buf_sizesize of buf
Returns
number of pins with specific function put in buf 0 - no pin is configured for this function

◆ hw_gpio_pad_latch_disable()

__STATIC_FORCEINLINE void hw_gpio_pad_latch_disable ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Disables the latch for the specific gpio.

Parameters
[in]portThe GPIO port to unlatch
[in]pinThe GPIO pin to unlatch

◆ hw_gpio_pad_latch_disable_all()

__STATIC_FORCEINLINE void hw_gpio_pad_latch_disable_all ( void  )

Disables the latches of all gpios.

◆ hw_gpio_pad_latch_enable()

__STATIC_FORCEINLINE void hw_gpio_pad_latch_enable ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Enables the latch for the specific gpio.

Parameters
[in]portThe GPIO port to latch
[in]pinThe GPIO pin to latch

◆ hw_gpio_pad_latch_enable_all()

__STATIC_FORCEINLINE void hw_gpio_pad_latch_enable_all ( void  )

Enables the latches of all gpios.

◆ hw_gpio_pad_latch_is_enabled()

__STATIC_FORCEINLINE bool hw_gpio_pad_latch_is_enabled ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Checks if the specific GPIO is latched or not.

Parameters
[in]portThe GPIO port to check latch status for
[in]pinThe GPIO pin to check latch status for

◆ hw_gpio_reserve_and_configure_pin()

bool hw_gpio_reserve_and_configure_pin ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin,
HW_GPIO_MODE  mode,
HW_GPIO_FUNC  function,
bool  high 
)

Reserve GPIO pin and set pin function.

Reserve pin and set up it function. If pin was already reserved do nothing.

Parameters
[in]portGPIO port number
[in]pinGPIO pin number
[in]modeGPIO access mode
[in]functionGPIO function
[in]highin case of PID_GPIO and OUTPUT value to set on pin
Returns
true if pin was successfully reserved and setup, false if pin was already reserved

◆ hw_gpio_reserve_pin()

bool hw_gpio_reserve_pin ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Reserve GPIO pin.

Reserve pin for exclusive usage. This macro can be used in application peripheral_setup function to detect usage of same GPIO pin by different applications.

Parameters
[in]portGPIO port number
[in]pinGPIO pin number
Returns
true if pin was successfully reserved and setup, false if pin was already reserved

◆ hw_gpio_set_active()

void hw_gpio_set_active ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Set a GPIO in high state.

The GPIO should have been previously configured as an output!

Parameters
[in]portGPIO port
[in]pinGPIO pin

◆ hw_gpio_set_inactive()

void hw_gpio_set_inactive ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Set a GPIO in low state.

The GPIO should have been previously configured as an output!

Parameters
[in]portGPIO port
[in]pinGPIO pin

◆ hw_gpio_set_pin_drive_strength()

void hw_gpio_set_pin_drive_strength ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin,
HW_GPIO_DRIVE_STRENGTH  strength 
)

Set the pin drive strength.

Note
The Drive Strength is pad (GPIO) related featured. The default setting is the Normal Drive Strength. The pads P0_0 .. P0_5 do not support the weak drive strength function. Using the function of weak drive on P0_0 .. P0_5 pads has no effect
Parameters
[in]portGPIO port
[in]pinGPIO pin
[in]strengthGPIO Drive Strength

◆ hw_gpio_set_pin_function()

void hw_gpio_set_pin_function ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin,
HW_GPIO_MODE  mode,
HW_GPIO_FUNC  function 
)

Set the pin type and mode.

Parameters
[in]portGPIO port
[in]pinGPIO pin
[in]modeGPIO pin mode
[in]functionGPIO pin usage

◆ hw_gpio_toggle()

void hw_gpio_toggle ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Toggle GPIO pin state.

Parameters
[in]portGPIO port
[in]pinGPIO pin

◆ hw_gpio_unreserve_pin()

void hw_gpio_unreserve_pin ( HW_GPIO_PORT  port,
HW_GPIO_PIN  pin 
)

Unreserve GPIO pin.

Free reserved pin. If pin was not reserved do nothing. Configuration of pin does not change just reservation.

Note
If pin was reserved using RESERVE_GPIO it will also be unreserved. If RESERVE_GPIO was not enabled by compile time flags call to this function may cause unexpected result.
Parameters
[in]portGPIO port number
[in]pinGPIO pin number
See also
hw_gpio_reserve_and_configure_pin
hw_gpio_reserve_pin
RESERVE_GPIO

Variable Documentation

◆ __PACKED_STRUCT

typedef __PACKED_STRUCT
Initial value:
{
uint8_t pin

GPIO pin configuration.

It's recommended to use HW_GPIO_PINCONFIG and HW_GPIO_PINCONFIG_RESERVE to set pin entries. Each configuration must be terminated using HW_GPIO_PINCONFIG_END macro. pin name, high-nibble is port number and low-nibble is pin

◆ func

pin function

◆ high

bool high

initial pin state, true for high and false for low

◆ mode

pin mode

HW_GPIO_PIN_BITS
#define HW_GPIO_PIN_BITS
Definition: hw_gpio.h:64
func
HW_GPIO_FUNC func
Definition: hw_gpio.h:212
mode
HW_GPIO_MODE mode
Definition: hw_gpio.h:211
high
bool high
Definition: hw_gpio.h:213