Port driver provides abstraction for accessing and controlling an entire port of your microcontroller.
Using Port driver you can configure a port as digital input or output, write to a port and read from a port.
To use this library
Before using other driver functions, user has to define driver context variable and initialize it, as shown below:
port_t port; port_init( &port, PORT_A, 0xFFFF, GPIO_DIGITAL_OUTPUT );
||Actual MCU port|
||Determines which pins will be configured; in this case all|
Default state of the configured port is logical low, if pins are configured as digital output.
Writing to port¶
After configuring the port as digital output, you can use
function for writing desired value to the port, as shown below:
uint16_t value = 0xAAAA; port_write( &port, value );
Reading from port¶
After configuring the port as digital input, you can use
for reading from the port, as shown below:
uint16_t read_value; read_value = port_read( &port );