Mbed OS Reference
Loading...
Searching...
No Matches
GPIO HAL functions

Modules

 GPIO HAL tests
 The GPIO HAL tests ensure driver conformance to defined behaviour.
 

Data Structures

struct  gpio_capabilities_t
 GPIO capabilities for a given pin. More...
 

Functions

uint32_t gpio_set (PinName pin)
 Set the given pin as GPIO. More...
 
int gpio_is_connected (const gpio_t *obj)
 Checks if gpio object is connected (pin was not initialized with NC) More...
 
void gpio_init (gpio_t *obj, PinName pin)
 Initialize the GPIO pin. More...
 
void gpio_free (gpio_t *obj)
 Releases the GPIO pin. More...
 
void gpio_mode (gpio_t *obj, PinMode mode)
 Set the input pin mode. More...
 
void gpio_dir (gpio_t *obj, PinDirection direction)
 Set the pin direction. More...
 
void gpio_write (gpio_t *obj, int value)
 Set the output value. More...
 
int gpio_read (gpio_t *obj)
 Read the input value. More...
 
void gpio_init_in (gpio_t *gpio, PinName pin)
 Init the input pin and set mode to PullDefault. More...
 
void gpio_init_in_ex (gpio_t *gpio, PinName pin, PinMode mode)
 Init the input pin and set the mode. More...
 
void gpio_init_out (gpio_t *gpio, PinName pin)
 Init the output pin as an output, with predefined output value 0. More...
 
void gpio_init_out_ex (gpio_t *gpio, PinName pin, int value)
 Init the pin as an output and set the output value. More...
 
void gpio_init_inout (gpio_t *gpio, PinName pin, PinDirection direction, PinMode mode, int value)
 Init the pin to be in/out. More...
 
void gpio_get_capabilities (gpio_t *gpio, gpio_capabilities_t *cap)
 Fill the given gpio_capabilities_t instance according to pin capabilities. More...
 
const PinMapgpio_pinmap (void)
 Get the pins that support all GPIO tests. More...
 

Detailed Description

Defined behavior

Undefined behavior

Function Documentation

◆ gpio_set()

uint32_t gpio_set ( PinName  pin)

Set the given pin as GPIO.

Parameters
pinThe pin to be set as GPIO
Returns
The GPIO port mask for this pin

◆ gpio_is_connected()

int gpio_is_connected ( const gpio_t *  obj)

Checks if gpio object is connected (pin was not initialized with NC)

Parameters
objThe GPIO object
Returns
0 if object was initialized with NC
non-zero if object was initialized with a valid PinName

◆ gpio_init()

void gpio_init ( gpio_t *  obj,
PinName  pin 
)

Initialize the GPIO pin.

Parameters
objThe GPIO object to initialize
pinThe GPIO pin to initialize (may be NC)

◆ gpio_free()

void gpio_free ( gpio_t *  obj)

Releases the GPIO pin.

Parameters
objThe GPIO object to release

◆ gpio_mode()

void gpio_mode ( gpio_t *  obj,
PinMode  mode 
)

Set the input pin mode.

Parameters
objThe GPIO object (must be connected)
modeThe pin mode to be set

◆ gpio_dir()

void gpio_dir ( gpio_t *  obj,
PinDirection  direction 
)

Set the pin direction.

Parameters
objThe GPIO object (must be connected)
directionThe pin direction to be set

◆ gpio_write()

void gpio_write ( gpio_t *  obj,
int  value 
)

Set the output value.

Parameters
objThe GPIO object (must be connected)
valueThe value to be set

◆ gpio_read()

int gpio_read ( gpio_t *  obj)

Read the input value.

Parameters
objThe GPIO object (must be connected)
Returns
An integer value 1 or 0

◆ gpio_init_in()

void gpio_init_in ( gpio_t *  gpio,
PinName  pin 
)

Init the input pin and set mode to PullDefault.

Parameters
gpioThe GPIO object
pinThe pin name (may be NC)

◆ gpio_init_in_ex()

void gpio_init_in_ex ( gpio_t *  gpio,
PinName  pin,
PinMode  mode 
)

Init the input pin and set the mode.

Parameters
gpioThe GPIO object
pinThe pin name (may be NC)
modeThe pin mode to be set

◆ gpio_init_out()

void gpio_init_out ( gpio_t *  gpio,
PinName  pin 
)

Init the output pin as an output, with predefined output value 0.

Parameters
gpioThe GPIO object
pinThe pin name (may be NC)

◆ gpio_init_out_ex()

void gpio_init_out_ex ( gpio_t *  gpio,
PinName  pin,
int  value 
)

Init the pin as an output and set the output value.

Parameters
gpioThe GPIO object
pinThe pin name (may be NC)
valueThe value to be set

◆ gpio_init_inout()

void gpio_init_inout ( gpio_t *  gpio,
PinName  pin,
PinDirection  direction,
PinMode  mode,
int  value 
)

Init the pin to be in/out.

Parameters
gpioThe GPIO object
pinThe pin name (may be NC)
directionThe pin direction to be set
modeThe pin mode to be set
valueThe value to be set for an output pin

◆ gpio_get_capabilities()

void gpio_get_capabilities ( gpio_t *  gpio,
gpio_capabilities_t cap 
)

Fill the given gpio_capabilities_t instance according to pin capabilities.

◆ gpio_pinmap()

const PinMap * gpio_pinmap ( void  )

Get the pins that support all GPIO tests.

Return a PinMap array of pins that support GPIO. The array is terminated with {NC, NC, 0}.

Targets should override the weak implementation of this function to provide the actual pinmap for GPIO testing.

Returns
PinMap array