Cascoda SDK
Cascoda SDK for building software to run with CA-821x transceivers

GPIO Hardware Abstraction Layer API Reference. More...

Collaboration diagram for GPIO HAL:

Functions

void hal_gpio_configure_pin (hal_gpio_pin_t *pin, hal_pin_name_t name, hal_gpio_direction_t direction)
 Configure pin. More...
 
void hal_gpio_deregister_pin (hal_gpio_pin_t *pin)
 De-register a 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

GPIO Hardware Abstraction Layer API Reference.

API for configuring and manipulating GPIO HAL module.

Function Documentation

◆ hal_gpio_clear_pin_output()

void hal_gpio_clear_pin_output ( hal_gpio_pin_t pin)

Set pin state low.

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).
void hal_gpio_clear_pin_output(hal_gpio_pin_t *pin)
Set pin state low.
Definition: hal_gpio.c:176
GPIO HAL context structure, consisted of the following fields :
Definition: hal_gpio.h:76

◆ 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.

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_pin_name_t is the module pin
void hal_gpio_configure_pin(hal_gpio_pin_t *pin, hal_pin_name_t name, hal_gpio_direction_t direction)
Configure pin.
Definition: hal_gpio.c:53
@ HAL_GPIO_DIGITAL_OUTPUT
GPIO as digital output.
Definition: hal_gpio.h:60

◆ 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.

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.
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.
Definition: hal_gpio.c:192
hal_ll_port_size_t hal_port_size_t
Port width, which is size dependant on the architecture.
Definition: hal_target.h:75

◆ hal_gpio_deregister_pin()

void hal_gpio_deregister_pin ( hal_gpio_pin_t pin)

De-register a pin.

De-register a pin that is configured.

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

Example

static hal_gpio_pin_t *pin;
// Deselect pin state.
void hal_gpio_deregister_pin(hal_gpio_pin_t *pin)
De-register a pin.
Definition: hal_gpio.c:80

◆ hal_gpio_read_pin_input()

uint8_t hal_gpio_read_pin_input ( hal_gpio_pin_t pin)

Read 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 input pin state.
value = hal_gpio_read_pin_input( &pin );
uint8_t hal_gpio_read_pin_input(hal_gpio_pin_t *pin)
Read pin.
Definition: hal_gpio.c:96

◆ hal_gpio_read_pin_output()

uint8_t hal_gpio_read_pin_output ( hal_gpio_pin_t pin)

Read 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 output pin state.
value = hal_gpio_read_pin_output( &pin );
uint8_t hal_gpio_read_pin_output(hal_gpio_pin_t *pin)
Read pin.
Definition: hal_gpio.c:111

◆ hal_gpio_read_port_input()

hal_port_size_t hal_gpio_read_port_input ( hal_gpio_port_t port)

Read 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_port_size_t hal_gpio_read_port_input(hal_gpio_port_t *port)
Read port.
Definition: hal_gpio.c:200

◆ hal_gpio_read_port_output()

hal_port_size_t hal_gpio_read_port_output ( hal_gpio_port_t port)

Read 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_port_size_t hal_gpio_read_port_output(hal_gpio_port_t *port)
Read port.
Definition: hal_gpio.c:205

◆ hal_gpio_set_pin_output()

void hal_gpio_set_pin_output ( hal_gpio_pin_t pin)

Set pin state high.

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).
void hal_gpio_set_pin_output(hal_gpio_pin_t *pin)
Set pin state high.
Definition: hal_gpio.c:160

◆ hal_gpio_toggle_pin_output()

void hal_gpio_toggle_pin_output ( hal_gpio_pin_t pin)

Toggle pin state.

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.
void hal_gpio_toggle_pin_output(hal_gpio_pin_t *pin)
Toggle pin state.
Definition: hal_gpio.c:140

◆ hal_gpio_write_pin_output()

void hal_gpio_write_pin_output ( hal_gpio_pin_t pin,
uint8_t  value 
)

Sets pin state.

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).
void hal_gpio_write_pin_output(hal_gpio_pin_t *pin, uint8_t value)
Sets pin state.
Definition: hal_gpio.c:127

◆ hal_gpio_write_port_output()

void hal_gpio_write_port_output ( hal_gpio_port_t port,
hal_port_size_t  value 
)

Sets port state.

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.
void hal_gpio_write_port_output(hal_gpio_port_t *port, hal_port_size_t value)
Sets port state.
Definition: hal_gpio.c:210