STM32G0 MCAL 0.0.1
Tiny MCAL for educational purpose.
|
Port driver configuration More...
Macros | |
#define | Det_ReportError(ModuleId, InstanceId, ApiId, ErrorId) |
#define | MAX_PIN_MODES 4u |
#define | MAX_ALT_MODES 11u |
Functions | |
void | Port_Init (const Port_ConfigType *ConfigPtr) |
Initialize the GPIO pins to the configuration store on ConfigPTR. | |
void | Port_SetPinDirection (Port_PinType Pin, Port_PinDirectionType Direction) |
Set the direction of a GPIO during runtime. | |
void | Port_SetPinMode (Port_PinType Pin, Port_PinModeType Mode) |
Set the mode of a GPIO during runtime. | |
void | Port_GetVersionInfo (Std_VersionInfoType *versioninfo) |
Gets the current version. | |
void | Port_RefreshPortDirection (void) |
Refresh port direction. | |
Variables | |
static const Port_ConfigType * | Port_ConfigPtr = NULL_PTR |
Variable for the initial value of the port configuration array. | |
Port driver configuration
This PORT driver module control the overall configuration and initialization of the port structure which is used in the DIO driver module. Therefore, the DIO driver works on pins and ports which are configured by the PORT driver.
The PORT driver shall be initialized prior to the use of the DIO functions. Otherwise, DIO functions will exhibit undefined behavior. The diagram below identifies the PORT driver functions and the structure of the PORT driver and DIO driver within the MCAL software layer. To use some functions check the Port_Cfg.h file to configured the values.
#define Det_ReportError | ( | ModuleId, | |
InstanceId, | |||
ApiId, | |||
ErrorId ) |
ModuleId | module id number |
InstanceId | Instance Id |
ApiId | Pai id |
ErrorId | Error code |
void Port_GetVersionInfo | ( | Std_VersionInfoType * | versioninfo | ) |
Gets the current version.
The function gives the versioninfo struct the values of the current version. to eneable this function change the value of PORT_VERSION_INFO_API to STD_ON on the Port_Cfg file.
versioninfo | Pointer to Std_VersionInfoType struct. |
void Port_Init | ( | const Port_ConfigType * | ConfigPtr | ) |
Initialize the GPIO pins to the configuration store on ConfigPTR.
The function changes the registers values of the GPIOS depending on the values of the ConfigPtr struct, this function Initialize all pins and port of the ConfigPtr array, the length of the array is given by PORT_PIN_NUMBER_OF_PORTS, To configure the values of the struct use the symbols defined on the Port.h file.
ConfigPtr | Pointer to ConfigPtr struct array. |
void Port_RefreshPortDirection | ( | void | ) |
Refresh port direction.
The function refreshes the registers values of the GPIOS moder during runtime to the initial values only if they are configured as non changeables.
void Port_SetPinDirection | ( | Port_PinType | Pin, |
Port_PinDirectionType | Direction ) |
Set the direction of a GPIO during runtime.
The function changes the registers values of the GPIOS direction during runtime, to enable this function change the value of PORT_SET_PIN_DIRECTION_API to STD_ON on the Port_Cfg file. To change the direction use the symbols of PORT direction
Pin | Pin to change the direction. |
Direction | Direction to be changed. |
void Port_SetPinMode | ( | Port_PinType | Pin, |
Port_PinModeType | Mode ) |
Set the mode of a GPIO during runtime.
The function changes the registers values of the GPIOS mode during runtime, to eneable this function change the value of PORT_SET_PIN_MODE_API to STD_ON on the Port_Cfg file. To change the mode use the symbols of GPIO altern values.
Pin | Pin to change the direction. |
Mode | Mode to be changed. |
< get the four most significant nibble
< get the less significant bits
< Max values on pin modes
< Max values on altern modes
|
static |
Variable for the initial value of the port configuration array.
< Add static when no testing