scorrpeio
Full Member level 5
I am confused about implementation of software in Embedded C.
1. If I have a set of different functions used by different peripherals...which of the following software design is standard(for reusability, readability and ofcourse performance)
Approach for transferring calls and controls of execution -
Approach 1: -
Declare all the function associated with the peripheral as static so that no other file can see it. And create one function in that file which communicates with the external world.
For ex, In case of display interface, only UpdateDisplay() is not static while other functions like clearDisplay(), MsgDisplay() etc remain static.
The UpdateDisplay will take commands and calls from other files and pass on these calls to the static functions.
Approach 2: -
Making all the functions of any peripheral non static that is can be accessed by other files as and when required.
Approach for sharing data between files and function -
Approach 1: -
Declare maximum data as volatile, const (whichever is suitable) global and access it using different functions as and when required.
I have heard that declaring too many variables as global is a bad design....I dont know why
Further, instead of passing value as arguments in the function, the value is updated at global location as a variable or a flag which is accessed by other function.
I thought of this option because I think it will make functions modular since it doesnt have argument list, it can be called easily. It always looks for global database and flags for data and checks.
Approach 2: -
Declare maximum variables as local and use them as function arguments to pass the value to other function.
Only variables which are required through out the program and which has to be necessarily global should be made global otherwise mostly global variables are avoided.
My project is mostly related to the keypad operated graphics display where in which there are many
messages to be displayed.
I am at beginner level of Embedded Software Architecture design. There might be other approaches to design the s/w architecture (I know only 2 ). If possible please enlist the other approaches too.
Please suggest me the approach which one is standard.
1. If I have a set of different functions used by different peripherals...which of the following software design is standard(for reusability, readability and ofcourse performance)
Approach for transferring calls and controls of execution -
Approach 1: -
Declare all the function associated with the peripheral as static so that no other file can see it. And create one function in that file which communicates with the external world.
For ex, In case of display interface, only UpdateDisplay() is not static while other functions like clearDisplay(), MsgDisplay() etc remain static.
The UpdateDisplay will take commands and calls from other files and pass on these calls to the static functions.
Approach 2: -
Making all the functions of any peripheral non static that is can be accessed by other files as and when required.
Approach for sharing data between files and function -
Approach 1: -
Declare maximum data as volatile, const (whichever is suitable) global and access it using different functions as and when required.
I have heard that declaring too many variables as global is a bad design....I dont know why
Further, instead of passing value as arguments in the function, the value is updated at global location as a variable or a flag which is accessed by other function.
I thought of this option because I think it will make functions modular since it doesnt have argument list, it can be called easily. It always looks for global database and flags for data and checks.
Approach 2: -
Declare maximum variables as local and use them as function arguments to pass the value to other function.
Only variables which are required through out the program and which has to be necessarily global should be made global otherwise mostly global variables are avoided.
My project is mostly related to the keypad operated graphics display where in which there are many
messages to be displayed.
I am at beginner level of Embedded Software Architecture design. There might be other approaches to design the s/w architecture (I know only 2 ). If possible please enlist the other approaches too.
Please suggest me the approach which one is standard.