Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
# Defined behavior * gpio_init and other init functions can be called with NC or a valid PinName for the target - Verified by gpio_nc_test * gpio_is_connected can be used to test whether a gpio_t object was initialized with NC - Verified by gpio_nc_test * gpio_init initializes the GPIO pin * gpio_free returns the pin owned by the GPIO object to its reset state * gpio_mode sets the mode of the given pin * gpio_dir sets the direction of the given pin * gpio_write sets the gpio output value * gpio_read reads the input value * gpio_init_in inits the input pin and sets mode to PullDefault * gpio_init_in_ex inits the input pin and sets the mode * gpio_init_out inits the pin as an output, with predefined output value 0 * gpio_init_out_ex inits the pin as an output and sets the output value * gpio_init_inout inits the pin to be input/output and set pin mode and value * The GPIO operations gpio_write, gpio_read take less than 20us to complete More...
Modules | |
GPIO HAL tests | |
The GPIO HAL tests ensure driver conformance to defined behaviour. | |
Functions | |
uint32_t | gpio_set (PinName pin) |
Set the given pin as GPIO. | |
int | gpio_is_connected (const gpio_t *obj) |
Checks if gpio object is connected (pin was not initialized with NC) | |
void | gpio_init (gpio_t *obj, PinName pin) |
Initialize the GPIO pin. | |
void | gpio_free (gpio_t *obj) |
Releases the GPIO pin. | |
void | gpio_mode (gpio_t *obj, PinMode mode) |
Set the input pin mode. | |
void | gpio_dir (gpio_t *obj, PinDirection direction) |
Set the pin direction. | |
void | gpio_write (gpio_t *obj, int value) |
Set the output value. | |
int | gpio_read (gpio_t *obj) |
Read the input value. | |
void | gpio_init_in (gpio_t *gpio, PinName pin) |
Init the input pin and set mode to PullDefault. | |
void | gpio_init_in_ex (gpio_t *gpio, PinName pin, PinMode mode) |
Init the input pin and set the mode. | |
void | gpio_init_out (gpio_t *gpio, PinName pin) |
Init the output pin as an output, with predefined output value 0. | |
void | gpio_init_out_ex (gpio_t *gpio, PinName pin, int value) |
Init the pin as an output and set the output value. | |
void | gpio_init_inout (gpio_t *gpio, PinName pin, PinDirection direction, PinMode mode, int value) |
Init the pin to be in/out. | |
const PinMap * | gpio_pinmap (void) |
Get the pins that support all GPIO tests. |
Detailed Description
# Defined behavior * gpio_init and other init functions can be called with NC or a valid PinName for the target - Verified by gpio_nc_test * gpio_is_connected can be used to test whether a gpio_t object was initialized with NC - Verified by gpio_nc_test * gpio_init initializes the GPIO pin * gpio_free returns the pin owned by the GPIO object to its reset state * gpio_mode sets the mode of the given pin * gpio_dir sets the direction of the given pin * gpio_write sets the gpio output value * gpio_read reads the input value * gpio_init_in inits the input pin and sets mode to PullDefault * gpio_init_in_ex inits the input pin and sets the mode * gpio_init_out inits the pin as an output, with predefined output value 0 * gpio_init_out_ex inits the pin as an output and sets the output value * gpio_init_inout inits the pin to be input/output and set pin mode and value * The GPIO operations gpio_write, gpio_read take less than 20us to complete
# Undefined behavior * Calling any gpio_mode, gpio_dir, gpio_write or gpio_read on a gpio_t object that was initialized with NC. * Calling gpio_set with NC.
Function Documentation
void gpio_dir | ( | gpio_t * | obj, |
PinDirection | direction | ||
) |
Set the pin direction.
- Parameters:
-
obj The GPIO object (must be connected) direction The pin direction to be set
void gpio_free | ( | gpio_t * | obj ) |
Releases the GPIO pin.
- Parameters:
-
obj The GPIO object to release
Definition at line 25 of file mbed_compat.c.
void gpio_init | ( | gpio_t * | obj, |
PinName | pin | ||
) |
Initialize the GPIO pin.
- Parameters:
-
obj The GPIO object to initialize pin The GPIO pin to initialize (may be NC)
void gpio_init_in | ( | gpio_t * | gpio, |
PinName | pin | ||
) |
Init the input pin and set mode to PullDefault.
- Parameters:
-
gpio The GPIO object pin The pin name (may be NC)
Definition at line 39 of file mbed_gpio.c.
void gpio_init_in_ex | ( | gpio_t * | gpio, |
PinName | pin, | ||
PinMode | mode | ||
) |
Init the input pin and set the mode.
- Parameters:
-
gpio The GPIO object pin The pin name (may be NC) mode The pin mode to be set
Definition at line 44 of file mbed_gpio.c.
void gpio_init_inout | ( | gpio_t * | gpio, |
PinName | pin, | ||
PinDirection | direction, | ||
PinMode | mode, | ||
int | value | ||
) |
Init the pin to be in/out.
- Parameters:
-
gpio The GPIO object pin The pin name (may be NC) direction The pin direction to be set mode The pin mode to be set value The value to be set for an output pin
Definition at line 59 of file mbed_gpio.c.
void gpio_init_out | ( | gpio_t * | gpio, |
PinName | pin | ||
) |
Init the output pin as an output, with predefined output value 0.
- Parameters:
-
gpio The GPIO object pin The pin name (may be NC)
- Returns:
- An integer value 1 or 0
Definition at line 49 of file mbed_gpio.c.
void gpio_init_out_ex | ( | gpio_t * | gpio, |
PinName | pin, | ||
int | value | ||
) |
Init the pin as an output and set the output value.
- Parameters:
-
gpio The GPIO object pin The pin name (may be NC) value The value to be set
Definition at line 54 of file mbed_gpio.c.
int gpio_is_connected | ( | const gpio_t * | obj ) |
Checks if gpio object is connected (pin was not initialized with NC)
- Parameters:
-
obj The GPIO object
- Returns:
- 0 if object was initialized with NC
- non-zero if object was initialized with a valid PinName
void gpio_mode | ( | gpio_t * | obj, |
PinMode | mode | ||
) |
Set the input pin mode.
- Parameters:
-
obj The GPIO object (must be connected) mode The pin mode to be set
MBED_WEAK 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
Definition at line 111 of file mbed_gpio.c.
int gpio_read | ( | gpio_t * | obj ) |
Read the input value.
- Parameters:
-
obj The GPIO object (must be connected)
- Returns:
- An integer value 1 or 0
uint32_t gpio_set | ( | PinName | pin ) |
Set the given pin as GPIO.
- Parameters:
-
pin The pin to be set as GPIO
- Returns:
- The GPIO port mask for this pin
void gpio_write | ( | gpio_t * | obj, |
int | value | ||
) |
Set the output value.
- Parameters:
-
obj The GPIO object (must be connected) value The value to be set
Generated on Tue Jul 12 2022 13:55:24 by
