mikroSDK Reference Manual

GPIO Hardware Abstraction Layer API Reference. More...

Functions list

void hal_gpio_configure_pin (hal_gpio_pin_t *pin, hal_pin_name_t name, hal_gpio_direction_t direction)
 Configure pin. More...
 
uint8_t hal_gpio_read_pin_input (hal_gpio_pin_t *pin)
 Read pin. More...
 
uint8_t hal_gpio_read_pin_output (hal_gpio_pin_t *pin)
 Read pin. More...
 
void hal_gpio_write_pin_output (hal_gpio_pin_t *pin, uint8_t value)
 Sets pin state. More...
 
void hal_gpio_toggle_pin_output (hal_gpio_pin_t *pin)
 Toggle pin state. More...
 
void hal_gpio_set_pin_output (hal_gpio_pin_t *pin)
 Set pin state high. More...
 
void hal_gpio_clear_pin_output (hal_gpio_pin_t *pin)
 Set pin state low. More...
 
void hal_gpio_configure_port (hal_gpio_port_t *port, hal_port_name_t name, hal_gpio_mask_t mask, hal_gpio_direction_t direction)
 Configure port. More...
 
hal_port_size_t hal_gpio_read_port_input (hal_gpio_port_t *port)
 Read port. More...
 
hal_port_size_t hal_gpio_read_port_output (hal_gpio_port_t *port)
 Read port. More...
 
void hal_gpio_write_port_output (hal_gpio_port_t *port, hal_port_size_t value)
 Sets port state. More...
 

Detailed Description

API for configuring and manipulating GPIO HAL module.

Function Documentation

◆ hal_gpio_configure_pin()

void hal_gpio_configure_pin ( hal_gpio_pin_t pin,
hal_pin_name_t  name,
hal_gpio_direction_t  direction 
)

Configure pin as digital input or output.

Parameters
[in,out]pinGPIO HAL pin context structure. See hal_gpio_pin_t structure definition for detailed explanation.
[in]namePin name.
[in]directionGPIO pin direction. See hal_gpio_direction_t for valid values.
Returns
Nothing.

Predefined values for direction:

Function Default value
input HAL_GPIO_DIGITAL_INPUT
output HAL_GPIO_DIGITAL_OUTPUT
Precondition
Make sure that pin structure has been declared. See hal_gpio_pin_t structure definition for detailed explanation.
Warning
The following example includes pin mapping. Take into consideration that different hardware might not have the same pins. Make sure to accommodate pin name based on your hardware specifics.

Example

static hal_gpio_pin_t *pin;
// Configures pin as digital output.

◆ hal_gpio_read_pin_input()

uint8_t hal_gpio_read_pin_input ( hal_gpio_pin_t pin)

Reads the current pin input level.

Parameters
[in,out]pinGPIO HAL pin context structure. See hal_gpio_pin_t structure definition for detailed explanation.
Returns
Function returns pin input logic level.
Precondition
Make sure that pin structure has been configured. See hal_gpio_configure_pin for detailed explanation.

Example

uint8_t value;
static hal_gpio_pin_t *pin;
// Reads pin state.
value = hal_gpio_read_pin_input( &pin );

◆ hal_gpio_read_pin_output()

uint8_t hal_gpio_read_pin_output ( hal_gpio_pin_t pin)

Reads the current pin output level.

Parameters
[in,out]pinGPIO HAL pin context structure. See hal_gpio_pin_t structure definition for detailed explanation.
Returns
Function returns pin output logic level.
Precondition
Make sure that pin structure has been configured. See hal_gpio_configure_pin for detailed explanation.

Example

uint8_t value;
static hal_gpio_pin_t *pin;
// Reads pin state.
value = hal_gpio_read_pin_output( &pin );

◆ hal_gpio_write_pin_output()

void hal_gpio_write_pin_output ( hal_gpio_pin_t pin,
uint8_t  value 
)

Sets the current output logic of the GPIO pin to 0 or 1.

Parameters
[in,out]pinGPIO HAL pin context structure. See hal_gpio_pin_t structure definition for detailed explanation.
[in]valuePin state, 0 or 1.
Returns
Nothing.
Precondition
Make sure that pin structure has been configured. See hal_gpio_configure_pin for detailed explanation.

Example

static hal_gpio_pin_t *pin;
// Set pin logic state to high (1).

◆ hal_gpio_toggle_pin_output()

void hal_gpio_toggle_pin_output ( hal_gpio_pin_t pin)

Toggles the current output logic of the GPIO pin.

Parameters
[in,out]pinGPIO HAL pin context structure. See hal_gpio_pin_t structure definition for detailed explanation.
Returns
Nothing.
Precondition
Make sure that pin structure has been configured. See hal_gpio_configure_pin for detailed explanation.

Example

static hal_gpio_pin_t *pin;
// Toggle pin logic state.

◆ hal_gpio_set_pin_output()

void hal_gpio_set_pin_output ( hal_gpio_pin_t pin)

Sets the current output logic of the GPIO pin to 1.

Parameters
[in,out]pinGPIO HAL pin context structure. See hal_gpio_pin_t structure definition for detailed explanation.
Returns
Nothing.
Precondition
Make sure that pin structure has been configured. See hal_gpio_configure_pin for detailed explanation.

Example

static hal_gpio_pin_t *pin;
// Set pin logic state high (1).

◆ hal_gpio_clear_pin_output()

void hal_gpio_clear_pin_output ( hal_gpio_pin_t pin)

Sets the current output logic of the GPIO pin to 0.

Parameters
[in,out]pinGPIO HAL pin context structure. See hal_gpio_pin_t structure definition for detailed explanation.
Returns
Nothing.
Precondition
Make sure that pin structure has been configured. See hal_gpio_configure_pin for detailed explanation.

Example

static hal_gpio_pin_t *pin;
// Set pin logic state low (0).

◆ hal_gpio_configure_port()

void hal_gpio_configure_port ( hal_gpio_port_t port,
hal_port_name_t  name,
hal_gpio_mask_t  mask,
hal_gpio_direction_t  direction 
)

Configure port as digital input or output.

Parameters
[in,out]portGPIO HAL port context structure. See hal_gpio_port_t structure definition for detailed explanation.
[in]namePort name.
[in]maskPort bit mask. See hal_gpio_mask_t structure definition for detailed explanation.
[in]directionGPIO pin direction. See hal_gpio_direction_t structure definition for detailed explanation.
Returns
Nothing.

Predefined values for direction:

Function Default value
input HAL_GPIO_DIGITAL_INPUT
output HAL_GPIO_DIGITAL_OUTPUT
Precondition
Make sure that port structure has been declared. See hal_gpio_port_t structure definition for detailed explanation.
Warning
The following example includes pin mapping. Take into consideration that different hardware might not have the same pins. Make sure to accommodate pin name based on your hardware specifics.

Example

static hal_gpio_port_t *port;
// Configures PORTB pins 0..7 as digital output.

◆ hal_gpio_read_port_input()

hal_port_size_t hal_gpio_read_port_input ( hal_gpio_port_t port)

Reads the current input logic of the GPIO port.

Parameters
[in,out]portGPIO HAL port context structure. See hal_gpio_port_t structure definition for detailed explanation.
Returns
Function returns port output state depending on the MCU architecture.
Precondition
Make sure that port structure has been configured. See hal_gpio_configure_port for detailed explanation.

Example

static hal_gpio_port_t *port;
// Reads port state.
value = hal_gpio_read_port_input( &port );

◆ hal_gpio_read_port_output()

hal_port_size_t hal_gpio_read_port_output ( hal_gpio_port_t port)

Reads the current output logic of the GPIO port.

Parameters
[in,out]portGPIO HAL port context structure. See hal_gpio_port_t structure definition for detailed explanation.
Returns
Function returns port output state depending on the MCU architecture.
Precondition
Make sure that port structure has been configured. See hal_gpio_configure_port for detailed explanation.

Example

static hal_gpio_port_t *port;
// Reads port state.
value = hal_gpio_read_port_output( &port );

◆ hal_gpio_write_port_output()

void hal_gpio_write_port_output ( hal_gpio_port_t port,
hal_port_size_t  value 
)

Sets the current output logic of the GPIO port to 0.

Parameters
[in,out]portGPIO HAL port context structure. See hal_gpio_port_t structure definition for detailed explanation.
[in]valuePort state / mask. See hal_port_size_t structure definition for detailed explanation.
Returns
Nothing.
Precondition
Make sure that port structure has been configured. See hal_gpio_configure_port for detailed explanation.

Example

static hal_gpio_port_t *port;
// Set port logic state to 0xAA.
hal_gpio_read_port_output
hal_port_size_t hal_gpio_read_port_output(hal_gpio_port_t *port)
Read port.
hal_gpio_write_pin_output
void hal_gpio_write_pin_output(hal_gpio_pin_t *pin, uint8_t value)
Sets pin state.
hal_gpio_read_pin_output
uint8_t hal_gpio_read_pin_output(hal_gpio_pin_t *pin)
Read pin.
HAL_GPIO_DIGITAL_OUTPUT
Definition: hal_gpio.h:59
hal_gpio_read_port_input
hal_port_size_t hal_gpio_read_port_input(hal_gpio_port_t *port)
Read port.
hal_gpio_write_port_output
void hal_gpio_write_port_output(hal_gpio_port_t *port, hal_port_size_t value)
Sets port state.
hal_gpio_read_pin_input
uint8_t hal_gpio_read_pin_input(hal_gpio_pin_t *pin)
Read pin.
hal_gpio_configure_port
void hal_gpio_configure_port(hal_gpio_port_t *port, hal_port_name_t name, hal_gpio_mask_t mask, hal_gpio_direction_t direction)
Configure port.
hal_gpio_configure_pin
void hal_gpio_configure_pin(hal_gpio_pin_t *pin, hal_pin_name_t name, hal_gpio_direction_t direction)
Configure pin.
hal_gpio_toggle_pin_output
void hal_gpio_toggle_pin_output(hal_gpio_pin_t *pin)
Toggle pin state.
hal_gpio_clear_pin_output
void hal_gpio_clear_pin_output(hal_gpio_pin_t *pin)
Set pin state low.
hal_gpio_set_pin_output
void hal_gpio_set_pin_output(hal_gpio_pin_t *pin)
Set pin state high.
hal_gpio_t
GPIO HAL context structure, consisted of the following fields :
Definition: hal_gpio.h:74
hal_port_size_t
hal_ll_port_size_t hal_port_size_t
Definition: hal_target.h:61