Want to make your application software more reusable? Don't change the hardware, operating system, or your tools. Instead change the architectural framework within which you do your design.
By Dinu P. Madau, Visteon Corporation
The objective is to develop the interface layer to translate the physical hardware signals into variables that can be directly used by the core software and vice versa. If the interface layer is designed correctly, it will take on the form of a hardware-software interface specification (HSIS). It should be designed for easy modification in the case that the systems' context diagram is altered (for example, if a sensor in the system is changed or the microcontroller is suddenly obsolete). The interface layer is the main component in the software that is modified so that the core software would require minimal changes, if any.
Interface-layer building blocks
Key to the operation of this software structure is the software interface, which has three essential components:
1. Microcontroller specification (ECU_HSIS.H).
2. I/O signals interface specification (I/O Signal #1, #2, #n).
3. I/O interface macros. (Interface.h, Interface.c)
One implementation of the interface layer would be to define three separate header files for each of the components. Figure 3 illustrates the partitioning of the software interface layer and how it relates to the overall system.
The ecu_hsis.h defines the low level interfaces to the microcontroller that both the interface and the signal header file reference. Other microcontroller specifications are also captured in this header file such as timing parameters that may be used for example in driving pulse-width-modulated outputs. The signal and interface header files become microcontroller independent because the ecu_hsis.h file encapsulates the peripheral level I/O into higher level references through macros.
The signal.h files encapsulates the data further by taking into account the raw sensor specification and provide the raw integer signal. The signal.h file provides a method for interface.h to access sensor independent signal types. The interface.h file modifies the raw signals that it receives from signal.h by applying the appropriate integer scaling/resolution and zero point offset required for the hardware independent functions. The basis of the interface.h file is to provide a means of getting data from the real world and putting data out there.
Ideally if the microcontroller changes, one would only need to modify the ech_hsis.h file. If the sensors in the system are changed, only modification to the appropriate signal.h file is required to take into account the new sensor specification.
By explicitly designing an interface layer that is hardware dependent, the core software layer can be engineered to be hardware independent. Both layers are reusable; the interface layer would be reused on other projects that implement the identical hardware. By design, the core software layer, which is independent of hardware, consists of reusable software modules.
The recommendations made in this article are not all encompassing but should be considered as a starting point for software architectures. To provide a guide to developers, more information will be available online in two additional articles in a series. They will provide more details of the structure of the building blocks in this architecture as well as some guidelines to its implementation.
Next, in Part 2: The portable code software structure building blocks.
Dinu P. Madau is a software technical fellow with Visteon. He has been developing software for embedded systems for over 22 years. He has an MSE in computer and electrical control systems engineering from Wayne State University and a BSE in computer engineering. Dinu has developed safety-critical software for anti-lock brakes, vehicle stability control, and suspension controls and is currently working in Advanced Cockpit Electronics and Driver Awareness Systems at Visteon, developing systems leveraging vision and radar technologies. He can be reached by e-mail at dmadau@visteon.com.