Contiki-NG
Data Structures | Macros | Typedefs

Header file for the GPIO HAL. More...

#include "contiki.h"
#include <stdint.h>

Go to the source code of this file.

Data Structures

struct  gpio_hal_event_handler_s
 Datatype for GPIO event handlers. More...
 

Macros

#define GPIO_HAL_ARCH_SW_TOGGLE   1
 Specifies whether software-based pin toggle is required. More...
 
#define GPIO_HAL_PIN_UNKNOWN   0xFF
 Unknown GPIO. More...
 

Typedefs

typedef uint8_t gpio_hal_pin_t
 GPIO pin number representation.
 
typedef uint32_t gpio_hal_pin_cfg_t
 GPIO pin configuration. More...
 
typedef uint32_t gpio_hal_pin_mask_t
 GPIO pin mask representation.
 
typedef struct gpio_hal_event_handler_s gpio_hal_event_handler_t
 Datatype for GPIO event handlers. More...
 

Functions

Functions to be provided by the platform

All the functions below must be provided by the platform's developer.

The HAL offers the developer a number of options of how to provide the required functionality.

  • The developer can provide a symbol. For example, the developer can create a .c file and implement a function called gpio_hal_arch_set_pin()
  • The developer can provide a function-like macro that has the same name as the function declared here. In this scenario, the declaration here will be removed by the pre-processor. For example, the developer can do something like:
#define gpio_hal_arch_write_pin(p, v) platform_sdk_function(p, v)
  • The developer can provide a static inline implementation. For this to work, the developer can do something like:
#define gpio_hal_arch_set_pin(p) set_pin(p)
static inline void set_pin(gpio_hal_pin_t pin) { ... }

In the latter two cases, the developer will likely provide implementations in a header file. In this scenario, one of the platform's configuration files must define GPIO_HAL_CONF_ARCH_HDR_PATH to the name of this header file. For example:

#define GPIO_HAL_CONF_ARCH_HDR_PATH "dev/gpio-hal-arch.h"
void gpio_hal_arch_init (void)
 Perform architecture specific gpio initaliaztion. More...
 
void gpio_hal_arch_interrupt_enable (gpio_hal_pin_t pin)
 Enable interrupts for a gpio pin. More...
 
void gpio_hal_arch_interrupt_disable (gpio_hal_pin_t pin)
 Disable interrupts for a gpio pin. More...
 
void gpio_hal_arch_pin_cfg_set (gpio_hal_pin_t pin, gpio_hal_pin_cfg_t cfg)
 Configure a gpio pin. More...
 
gpio_hal_pin_cfg_t gpio_hal_arch_pin_cfg_get (gpio_hal_pin_t pin)
 Read the configuration of a GPIO pin. More...
 
void gpio_hal_arch_pin_set_input (gpio_hal_pin_t pin)
 Configure a pin as GPIO input. More...
 
void gpio_hal_arch_pin_set_output (gpio_hal_pin_t pin)
 Configure a pin as GPIO output. More...
 
void gpio_hal_arch_set_pin (gpio_hal_pin_t pin)
 Set a GPIO pin to logical high. More...
 
void gpio_hal_arch_clear_pin (gpio_hal_pin_t pin)
 Clear a GPIO pin (logical low) More...
 
void gpio_hal_arch_toggle_pin (gpio_hal_pin_t pin)
 Toggle a GPIO pin. More...
 
uint8_t gpio_hal_arch_read_pin (gpio_hal_pin_t pin)
 Read a GPIO pin. More...
 
void gpio_hal_arch_write_pin (gpio_hal_pin_t pin, uint8_t value)
 Write a GPIO pin. More...
 
void gpio_hal_arch_set_pins (gpio_hal_pin_mask_t pins)
 Set multiple pins to logical high. More...
 
void gpio_hal_arch_clear_pins (gpio_hal_pin_mask_t pins)
 Clear multiple pins to logical low. More...
 
void gpio_hal_arch_toggle_pins (gpio_hal_pin_mask_t pins)
 Toggle multiple pins. More...
 
gpio_hal_pin_mask_t gpio_hal_arch_read_pins (gpio_hal_pin_mask_t pins)
 Read multiple pins. More...
 
void gpio_hal_arch_write_pins (gpio_hal_pin_mask_t pins, gpio_hal_pin_mask_t value)
 Write multiple pins. More...
 

Core GPIO functions

Functions implemented by the HAL itself

#define gpio_hal_pin_to_mask(pin)   ((gpio_hal_pin_mask_t)1 << (pin))
 Convert a pin to a pin mask. More...
 
void gpio_hal_init (void)
 Initialise the GPIO HAL.
 
void gpio_hal_register_handler (gpio_hal_event_handler_t *handler)
 Register a function to be called whenever a pin triggers an event. More...
 
void gpio_hal_event_handler (gpio_hal_pin_mask_t pins)
 The platform-independent GPIO event handler. More...
 

Detailed Description

Header file for the GPIO HAL.

Definition in file gpio-hal.h.