Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

GPIO HAL functions

GPIO HAL functions
[Hal]

# 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:
objThe GPIO object (must be connected)
directionThe pin direction to be set
void gpio_free ( gpio_t *  obj )

Releases the GPIO pin.

Parameters:
objThe 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:
objThe GPIO object to initialize
pinThe 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:
gpioThe GPIO object
pinThe 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:
gpioThe GPIO object
pinThe pin name (may be NC)
modeThe 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:
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

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:
gpioThe GPIO object
pinThe 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:
gpioThe GPIO object
pinThe pin name (may be NC)
valueThe 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:
objThe 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:
objThe GPIO object (must be connected)
modeThe 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:
objThe 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:
pinThe 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:
objThe GPIO object (must be connected)
valueThe value to be set