mikroSDK Reference Manual

Digital Input Pin Driver API Reference. More...

Functions list

err_t digital_in_init (digital_in_t *in, pin_name_t name)
 Initialize GPIO pin.
 
uint8_t digital_in_read (digital_in_t *in)
 Read GPIO pin.
 

Function Documentation

◆ digital_in_init()

err_t digital_in_init ( digital_in_t * in,
pin_name_t name )

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

Parameters
[in,out]inDigital input driver context structure. See digital_in_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 in structure has been declared. See digital_in_err_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 input driver context structure.
static digital_in_t input_pin;
// Initializes digital input driver context structure and individual GPIO pin as digital input.
if ( DIGITAL_IN_SUCCESS == digital_in_init( &input_pin, PB2 ) ) {
// No error
} else {
// Handle the error
}
@ DIGITAL_IN_SUCCESS
Definition drv_digital_in.h:59
err_t digital_in_init(digital_in_t *in, pin_name_t name)
Initialize GPIO pin.
Digital input driver context structure, consisted of the following fields :
Definition drv_digital_in.h:73

◆ digital_in_read()

uint8_t digital_in_read ( digital_in_t * in)

Reads the current input value of the individual GPIO pin.

Parameters
[in]inDigital input driver context structure. See digital_in_t structure definition for detailed explanation.
Returns
Function returns pin logical state (1 or 0).
Precondition
Make sure that in structure has been declared and initialized beforehand. See digital_in_t structure definition and digital_in_init for detailed explanation.
Note
Return value depends on signal being input to current pin.

Example

// GPIO value holder.
uint8_t value;
// Read digital input value.
value = digital_in_read( &input_pin );
uint8_t digital_in_read(digital_in_t *in)
Read GPIO pin.