Skip to content

Digital In Driver

The digital in driver provides abstraction for accessing GPIO individual pins as digital input. It provides functionality to read state of a digital input pin.

To use this library

Header: #include "drv_digital_in.h"

memake: MikroSDK.Driver

Initialization

Before using other driver functions, user needs to define driver context variable and initialize it, as shown in the example below:

digital_in_t in_pin;

digital_in_init(&out_in, PA12);

First parameter is the address of driver context structure, and second parameter is the name of the pin that will be configured as digital input. After the initialization, in_pin variable will be our handle for accessing the configured pin.

Reading pin state

For reading pin state, the driver provides a single function digital_in_read. Basic usage is shown below:

digital_in_data_t state;

state = digital_in_read(&in_pin);

Reference