Reputation: 13
I have been reading the autosar documentation to better understand the autosar architecture. So, in the implementation of autosar classic, I have doubts regarding the construction of the code, as I am not able to understand the clear difference between Port Driver and Dio Driver.
See what I understand, in my implementation, I developed a function called Dio_Write(channelID, Level) and the function Port_Write(ChannelId, Level). So, should I place the port function inside the Dio function to be called or does the Dio function have another function other than calling the Port functions?
For example, I developed the initializations with Port_Init and to write a Channel I use the following
void Dio_WriteChannel (Dio_ChannelType ChannelId,Dio_LevelType Level){
Port_WriteChannel(ChannelId, Level);
}
void Port_WriteChannel (Dio_ChannelType ChannelId,Dio_LevelType Level){
//for example: Arduino registered PORTS set STD_HIGH in bit x
}
Upvotes: 0
Views: 348
Reputation: 178
DIO has a dependency on the PORT module. This means that PORT should be initialized first to be able to use DIO APIs e.g. Dio_Write.
The DIO module is basically an abstraction of the microcontroller hardware pins, where it assigns pins to groups but it does not configure the pin mode. Pin mode is configured via PORT using the Port_Init API.
For pin configuration, normally you would use an Autosar configuration tool, then go to PORT module and configure every pin as needed, eventually the tool generates dynamic code that is then compiled and linked in to the binary. At runtime, when Port_Init gets called during initialization it uses the configuration from the dynamic/generated code to properly set microcontroller registers to configure the mode.
This means that if you would like to use a micro pin as a digital output, and control this output via Dio_Write, first you will need to configure the pin in GPIO mode. Again, pin configuration is done in the PORT module.
About the code implementation of Dio, when you use Dio_Write it assumes that the pin is configured with the proper mode, GPIO normally, and eventually accesses directly a microcontroller register to be able to change the pin level. So from what I've seen DIO does not use a PORT API directly but is needs PORT initialization and configuration to able to function properly.
Hopefully this would explain a little more.
Upvotes: 2