|
Digital Input/Output Reusable Driver v1.1
This project implements a GPIO reusable driver that can be adapted to various microcontrollers.
|
The implementation for the DIO driver. More...
#include "dio.h"
Functions | |
| void | DIO_init (const DioConfig_t *const Config, size_t configSize) |
| DioPinState_t | DIO_pinRead (const DioPinConfig_t *const PinConfig) |
| void | DIO_pinWrite (const DioPinConfig_t *const PinConfig, DioPinState_t State) |
| void | DIO_pinToggle (const DioPinConfig_t *const PinConfig) |
| void | DIO_registerWrite (uint32_t address, uint32_t value) |
| uint32_t | DIO_registerRead (uint32_t address) |
The implementation for the DIO driver.
| void DIO_init | ( | const DioConfig_t *const | Config, |
| size_t | configSize ) |
Description: This function is used to initialize the DIO based on the configuration
table defined in dio_cfg module.
PRE-CONDITION: The MCU clocks must be configured and enabled.
PRE-CONDITION: Configuration table needs to be populated (sizeof > 0)
PRE-CONDITION: NUMBER_OF_PORTS > 0
PRE-CONDITION: The setting is within the maximum values (DIO_MAX).
POST-CONDITION: The DIO peripheral is set up with the configuration settings.
| [in] | Config | is a pointer to the configuration table that contains the initialization for the peripheral. |
| [in] | configSize | is the size of the configuration table. |
Example:
| DioPinState_t DIO_pinRead | ( | const DioPinConfig_t *const | PinConfig | ) |
Description: This function is used to reads the state of a specified pin. This function reads the state of a digital input/output pin specified by the DioPinConfig_t structure, which contains the port and pin information.
PRE-CONDITION: The pin is configured as INPUT
PRE-CONDITION: The pin is configured as GPIO
PRE-CONDITION: DioPinConfig_t needs to be populated (sizeof > 0)
PRE-CONDITION: The Port is within the maximum DioPort_t.
PRE-CONDITION: The Pin is within the maximum DioPin_t. definition.
POST-CONDITION: The channel state is returned.
| [in] | PinConfig | A pointer to a structure containing the port and pin to be read. |
Example:
| void DIO_pinToggle | ( | const DioPinConfig_t *const | PinConfig | ) |
Description: This function is used to toggle the current state of a pin. This function reads the state of a digital input/output pin specified by the DioPinConfig_t structure, which contains the port and pin information.
PRE-CONDITION: The channel is configured as output
PRE-CONDITION: The channel is configured as GPIO
PRE-CONDITION: DioPinConfig_t needs to be populated (sizeof > 0)
PRE-CONDITION: The Port is within the maximum DioPort_t.
PRE-CONDITION: The Pin is within the maximum DioPin_t.
POST-CONDITION: The channel state is toggled.
| [in] | pinConfig | A pointer to a structure containing the port and pin to be toggled. |
Example:
| void DIO_pinWrite | ( | const DioPinConfig_t *const | PinConfig, |
| DioPinState_t | State ) |
Description: This function is used to write the state of a pin as either logic high or low. it reads the state of a digital input/output pin specified by the DioPinConfig_t structure and the DioPinState_t to define the desired state, which contains the port and pin information.
PRE-CONDITION: The pin is configured as OUTPUT
PRE-CONDITION: The pin is configured as GPIO
PRE-CONDITION: DioPinConfig_t needs to be populated (sizeof > 0)
PRE-CONDITION: The Port is within the maximum DioPort_t.
PRE-CONDITION: The Pin is within the maximum DioPin_t.
PRE-CONDITION: The State is within the maximum DioPinState_t.
POST-CONDITION: The channel state is Stated.
| [in] | pinConfig | A pointer to a structure containing the port and pin to be written. |
| [in] | State | is HIGH or LOW as defined in the DioPinState_t enum. |
Example:
| uint32_t DIO_registerRead | ( | uint32_t | address | ) |
Description: This function is used to directly address a Dio register. The function should be used to access specialized functionality in the Dio peripheral that is not exposed by any other function of the interface.
PRE-CONDITION: Address is within the boundaries of the Dio register address space.
POST-CONDITION: The value stored in the register is returned to the caller.
| [in] | address | is the address of the Dio register to read. |
Example:
| void DIO_registerWrite | ( | uint32_t | address, |
| uint32_t | value ) |
Description: This function is used to directly address and modify a GPIO register. The function should be used to access specialized functionality in the DIO peripheral that is not exposed by any other function of the interface.
PRE-CONDITION: Address is within the boundaries of the DIO register address space.
POST-CONDITION: The register located at address with be updated with value.
| [in] | address | is a register address within the DIO peripheral map. |
| [in] | value | is the value to set the DIO register. |
Example