mikroSDK Reference Manual

GPIO Port Driver API Reference. More...

Functions list

void port_init (port_t *port, port_name_t name, port_size_t mask, pin_direction_t direction)
 Initialize GPIO port. More...
 
void port_write (port_t *port, port_size_t value)
 Write to port. More...
 
port_size_t port_read (port_t *port)
 Read from port. More...
 

Detailed Description

Driver for configuring GPIO ports as digital output/input and setting/reading logical value.

Function Documentation

◆ port_init()

void port_init ( port_t port,
port_name_t  name,
port_size_t  mask,
pin_direction_t  direction 
)

Initializes port driver context structure and masked GPIO pins as digital output or digital input.

Parameters
[in,out]portPort driver context strucutre. See port_t structure definition for detailed explanation.
[in]namePort name. See port_name_t structure definition for detailed explanation.
[in]maskGPIO pin mask. See port_size_t structure definition for detailed explanation.
[in]directionGPIO pin direction. See pin_direction_t structure definition for detailed explanation.
Returns
Nothing.
Precondition
Make sure that port structure has been declared. See port_t structure definition for detailed explanation.
Warning
The following example includes pin mapping. Take into consideration that different hardware might not have the same pins. Make sure to accommodate pin name based on your hardware specifics.

Example

// Port driver context structure.
static port_t port;
// Initialize PORT_B as output.

◆ port_write()

void port_write ( port_t port,
port_size_t  value 
)

Writes value to beforehand initialized port.

Parameters
[in]portPort driver context strucutre. See port_t structure definition for detailed explanation.
[in]valueBit map to write on port. See port_size_t structure definition for detailed explanation.
Returns
Nothing.
Precondition
Make sure that port structure has been declared and initialized beforehand. See port_t structure definition and port_init for detailed explanation.

Example

// Write value to defined port.
port_write( &port, value );

◆ port_read()

port_size_t port_read ( port_t port)

Reads from beforehand initialized port.

Parameters
[in]portPort driver context strucutre. See port_t structure definition for detailed explanation.
Returns
Value read from port.
Precondition
Make sure that port structure has been declared and initialized beforehand. See port_t structure definition and port_init for detailed explanation.

Example

// Read value holder.
static port_size_t read_value;
// Read port and toggle value.
read_value = port_read( &port );
hal_gpio_t::mask
hal_gpio_mask_t mask
Definition: hal_gpio.h:73
port_read
port_size_t port_read(port_t *port)
Read from port.
PIN_DIRECTION_DIGITAL_OUTPUT
Definition: drv_port.h:59
port_size_t
hal_port_size_t port_size_t
Definition: drv_name.h:77
port_t
Port driver context structure, consisted of the following fields :
Definition: drv_port.h:71
port_write
void port_write(port_t *port, port_size_t value)
Write to port.
port_init
void port_init(port_t *port, port_name_t name, port_size_t mask, pin_direction_t direction)
Initialize GPIO port.