Contiki-NG
Files | Functions
nRF52840 GPIO HAL implementation

Files

file  gpio-hal-arch.c
 Implementation file for the nRF52840 GPIO HAL functions.
 
file  gpio-hal-arch.h
 Header file for the nRF52840 GPIO HAL functions.
 

Functions

void gpio_hal_arch_init (void)
 Perform architecture specific gpio initaliaztion. More...
 
void gpio_hal_arch_port_pin_cfg_set (gpio_hal_port_t port, gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
 Configure a gpio pin. More...
 
gpio_hal_pin_cfg_t gpio_hal_arch_port_pin_cfg_get (gpio_hal_port_t port, gpio_hal_pin_t pin)
 Read the configuration of a GPIO pin. More...
 
uint8_t gpio_hal_arch_port_read_pin (gpio_hal_port_t port, gpio_hal_pin_t pin)
 Read a GPIO pin. More...
 
void gpio_hal_arch_port_set_pins (gpio_hal_port_t port, gpio_hal_pin_mask_t pins)
 Set multiple pins to logical high. More...
 
void gpio_hal_arch_port_clear_pins (gpio_hal_port_t port, gpio_hal_pin_mask_t pins)
 Clear multiple pins to logical low. More...
 
void gpio_hal_arch_port_toggle_pins (gpio_hal_port_t port, gpio_hal_pin_mask_t pins)
 Toggle multiple pins. More...
 
gpio_hal_pin_mask_t gpio_hal_arch_port_read_pins (gpio_hal_port_t port, gpio_hal_pin_mask_t pins)
 Read multiple pins. More...
 
void gpio_hal_arch_port_write_pins (gpio_hal_port_t port, gpio_hal_pin_mask_t pins, gpio_hal_pin_mask_t value)
 Write multiple pins. More...
 

Detailed Description

Function Documentation

◆ gpio_hal_arch_init()

void gpio_hal_arch_init ( void  )

Perform architecture specific gpio initaliaztion.

It is the platform developer's responsibility to provide an implementation.

The implementation can be provided as a global symbol, an inline function or a function-like macro, as described above.

Definition at line 64 of file gpio-hal-arch.c.

◆ gpio_hal_arch_port_clear_pins()

void gpio_hal_arch_port_clear_pins ( gpio_hal_port_t  port,
gpio_hal_pin_mask_t  pins 
)

Clear multiple pins to logical low.

Parameters
portThe GPIO port
pinsAn ORd pin mask of the pins to clear

A pin will be set to logical low if its position in pins is set. For example you can clear pins 0 and 3 by passing 0x09.

It is the platform developer's responsibility to provide an implementation.

The implementation can be provided as a global symbol, an inline function or a function-like macro, as described above.

Note
Code should not call this function directly. Use GPIO manipulation macros instead.

Definition at line 184 of file gpio-hal-arch.c.

◆ gpio_hal_arch_port_pin_cfg_get()

gpio_hal_pin_cfg_t gpio_hal_arch_port_pin_cfg_get ( gpio_hal_port_t  port,
gpio_hal_pin_t  pin 
)

Read the configuration of a GPIO pin.

Parameters
portThe GPIO port
pinThe GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
Returns
An OR mask of GPIO_HAL_PIN_CFG_xyz

It is the platform developer's responsibility to provide an implementation.

The implementation can be provided as a global symbol, an inline function or a function-like macro, as described above.

Note
Code should not call this function directly. Use GPIO manipulation macros instead.

Definition at line 113 of file gpio-hal-arch.c.

◆ gpio_hal_arch_port_pin_cfg_set()

void gpio_hal_arch_port_pin_cfg_set ( gpio_hal_port_t  port,
gpio_hal_pin_t  pin,
gpio_hal_pin_cfg_t  cfg 
)

Configure a gpio pin.

Parameters
portThe GPIO port
pinThe GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
cfgThe configuration

cfg is an OR mask of GPIO_HAL_PIN_CFG_xyz

The implementation of this function also has to make sure that pin is configured as software-controlled GPIO.

It is the platform developer's responsibility to provide an implementation.

The implementation can be provided as a global symbol, an inline function or a function-like macro, as described above.

Note
Code should not call this function directly. Use GPIO manipulation macros instead.

Definition at line 72 of file gpio-hal-arch.c.

◆ gpio_hal_arch_port_read_pin()

uint8_t gpio_hal_arch_port_read_pin ( gpio_hal_port_t  port,
gpio_hal_pin_t  pin 
)

Read a GPIO pin.

Parameters
portThe GPIO port
pinThe GPIO pin number (0...GPIO_HAL_PIN_COUNT - 1)
Return values
0The pin is logical low
1The pin is logical high

It is the platform developer's responsibility to provide an implementation.

The implementation can be provided as a global symbol, an inline function or a function-like macro, as described above.

Note
Code should not call this function directly. Use GPIO manipulation macros instead.

Definition at line 167 of file gpio-hal-arch.c.

◆ gpio_hal_arch_port_read_pins()

gpio_hal_pin_mask_t gpio_hal_arch_port_read_pins ( gpio_hal_port_t  port,
gpio_hal_pin_mask_t  pins 
)

Read multiple pins.

Parameters
portThe GPIO port
pinsAn ORd pin mask of the pins to read
Return values
AnORd mask of the pins that are high

If the position of the pin in pins is set and the pin is logical high then the position of the pin in the return value will be set. For example, if you pass 0x09 as the value of pins and the return value is 0x08 then pin 3 is logical high and pin 0 is logical low.

It is the platform developer's responsibility to provide an implementation.

The implementation can be provided as a global symbol, an inline function or a function-like macro, as described above.

Note
Code should not call this function directly. Use GPIO manipulation macros instead.

Definition at line 205 of file gpio-hal-arch.c.

◆ gpio_hal_arch_port_set_pins()

void gpio_hal_arch_port_set_pins ( gpio_hal_port_t  port,
gpio_hal_pin_mask_t  pins 
)

Set multiple pins to logical high.

Parameters
portThe GPIO port
pinsAn ORd pin mask of the pins to set

A pin will be set to logical high if its position in pins is set. For example you can set pins 0 and 3 by passing 0x09.

It is the platform developer's responsibility to provide an implementation.

The implementation can be provided as a global symbol, an inline function or a function-like macro, as described above.

Note
Code should not call this function directly. Use GPIO manipulation macros instead.

Definition at line 172 of file gpio-hal-arch.c.

◆ gpio_hal_arch_port_toggle_pins()

void gpio_hal_arch_port_toggle_pins ( gpio_hal_port_t  port,
gpio_hal_pin_mask_t  pins 
)

Toggle multiple pins.

Parameters
portThe GPIO port
pinsAn ORd pin mask of the pins to toggle

A pin will be toggled if its position in pins is set. For example you can toggle pins 0 and 3 by passing 0x09.

Some MCUs allow GPIO pin toggling directly via register access. In this case, it is a good idea to provide an implementation of this function. However, a default, software-based implementation is also provided by the HAL and can be used if the MCU does not have a pin toggle register. To use the HAL function, define GPIO_HAL_ARCH_SW_TOGGLE as 1. To provide your own implementation, define GPIO_HAL_ARCH_SW_TOGGLE as 0.

The implementation can be provided as a global symbol, an inline function or a function-like macro, as described above.

Note
Code should not call this function directly. Use GPIO manipulation macros instead.

Definition at line 196 of file gpio-hal-arch.c.

◆ gpio_hal_arch_port_write_pins()

void gpio_hal_arch_port_write_pins ( gpio_hal_port_t  port,
gpio_hal_pin_mask_t  pins,
gpio_hal_pin_mask_t  value 
)

Write multiple pins.

Parameters
portThe GPIO port
pinsAn ORd pin mask of the pins to write
valueAn ORd mask of the value to write

The function will modify GPIO pins that have their position in the mask set. pins, the function will write the value specified in the corresponding position in value.

For example, you can set pin 3 and clear pin 0 by a single call to this function. To achieve this, pins must be 0x09 and value 0x08.

It is the platform developer's responsibility to provide an implementation.

There is no guarantee that this function will result in an atomic operation.

The implementation can be provided as a global symbol, an inline function or a function-like macro, as described above.

Note
Code should not call this function directly. Use GPIO manipulation macros instead.

Definition at line 217 of file gpio-hal-arch.c.