mikroSDK Reference Manual

Digital Output Pin Driver API Reference. More...

Functions list

err_t digital_out_init (digital_out_t *out, pin_name_t name)
 Initialize GPIO pin. More...
 
void digital_out_high (digital_out_t *out)
 Set pin state to logical high. More...
 
void digital_out_low (digital_out_t *out)
 Set pin state to logical low. More...
 
void digital_out_toggle (digital_out_t *out)
 Toggle pin state. More...
 
void digital_out_write (digital_out_t *out, uint8_t value)
 Set pin state. More...
 

Detailed Description

This driver provids functions for configuring GPIO pin as digital output and setting logical value to it.

Function Documentation

◆ digital_out_init()

err_t digital_out_init ( digital_out_t out,
pin_name_t  name 
)

Initializes digital output driver context structure and individual GPIO pin as digital output.

Parameters
[in,out]outDigital output driver context structure. See digital_out_t structure definition for detailed explanation.
[in]nameThe name of the GPIO pin. See pin_name_t structure definition for detailed explanation.
Returns
The function can return one of the values defined in the digital_out_err_t enum list.
Precondition
Make sure that out structure has been declared. See digital_out_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

// Digital output driver context structure.
static digital_out_t output_pin;
// Initializes digital output driver context structure and individual GPIO pin as digital output.
digital_out_init( &output_pin, PB2 );

◆ digital_out_high()

void digital_out_high ( digital_out_t out)

Sets digital output individual pin out->pin to logic 1.

Parameters
[in]outDigital output driver context structure. See digital_out_t structure definition for detailed explanation.
Returns
Nothing.
Precondition
Make sure that out structure has been declared and initialized beforehand. See digital_out_t structure definition and digital_out_init for detailed explanation.

Example

// Initializes output_pin to logical high state (1).
digital_out_high( &output_pin );

◆ digital_out_low()

void digital_out_low ( digital_out_t out)

Sets digital output individual pin out->pin to logic 0.

Parameters
[in]outDigital output driver context structure. See digital_out_t structure definition for detailed explanation.
Returns
Nothing.
Precondition
Make sure that out structure has been declared and initialized beforehand. See digital_out_t structure definition and digital_out_init for detailed explanation.

Example

// Initializes output_pin to logical low state (0).
digital_out_low( &output_pin );

◆ digital_out_toggle()

void digital_out_toggle ( digital_out_t out)

Toggles digital output individual pin out->pin logic state.

Parameters
[in]outDigital output driver context structure. See digital_out_t structure definition for detailed explanation.
Returns
Nothing.
Precondition
Make sure that out structure has been declared and initialized beforehand. See digital_out_t structure definition and digital_out_init for detailed explanation.

Example

// Toggle pin state.
digital_out_toggle( &output_pin );

◆ digital_out_write()

void digital_out_write ( digital_out_t out,
uint8_t  value 
)

Sets digital output individual pin out->pin to logic state declared by value .

Parameters
[in]outDigital output driver context structure. See digital_out_t structure definition for detailed explanation.
[in]valueLogic value to write.
Returns
Nothing.
Precondition
Make sure that out structure has been declared and initialized beforehand. See digital_out_t structure definition and digital_out_init for detailed explanation.

Example

// Write value to GPIO port.
digital_out_write( &output_pin, 1 );
digital_out_t
Digital output driver context structure, consisted of the following fields :
Definition: drv_digital_out.h:71
digital_out_toggle
void digital_out_toggle(digital_out_t *out)
Toggle pin state.
digital_out_write
void digital_out_write(digital_out_t *out, uint8_t value)
Set pin state.
digital_out_init
err_t digital_out_init(digital_out_t *out, pin_name_t name)
Initialize GPIO pin.
digital_out_high
void digital_out_high(digital_out_t *out)
Set pin state to logical high.
digital_out_low
void digital_out_low(digital_out_t *out)
Set pin state to logical low.