How important is the embedded architecture?

                                                                             How important is the embedded architecture?


The purpose of the architectural design:

1. The logic of the application code is clear, and avoid reinventing the wheel.
2. If there is no good architecture, porting will be a very painful thing, so a good architecture design is convenient for software porting.
3. Maximum reuse.
4. High cohesion and low coupling.

Design ideas:

In principle, it is not possible to write functional statements directly in the main program (except for the dog feed instruction). A good main program structure should call specific function modules through subprograms, which is the requirement of program modularization. In this modular program structure, the main program is only to perform the scheduling function and is responsible for calling the function module program in turn. All function modules are called once every cycle of the main program (see Figure 3.2: Modular program structure). Obviously, after adopting this structure, the mutual independence between the various modules is strong. We can easily increase or decrease the modules called by the main program like building blocks, that is, functional modular design and layered design.

 

 Modular design: classify, summarize and analyze the collected requirements, summarize these requirements into individual functions, and make each function a separate function module

The layered design is not easy to express directly. It is mainly reflected in the following aspects:

1. The function module externally calls the module into an API, and the underlying driver is used as an API for the function module to call. (Each function module can be compiled independently (such as the communication module is pure ANSI C, which can be reused on any platform), or call the driver layer interface (the log library module calls the driver to read and write Flash). In short, in short, encapsulate each function Independent reusable functional modules.)
2. API is divided into driver layer API and application layer API, not all programs call the driver layer API. (Calling the driver layer API throughout the application will cause driver calls to be seen everywhere in the application, which cannot be transplanted and reused to the maximum.) The

overall is divided into the hardware driver layer-> function module layer-> business logic layer-> application layer

Schematic block diagram of the overall structure:

 

Note:

1. Cross-layer calls cannot be made between layers.
2. Modules and modules are independent and have no dependencies.
3. The module provides a unified interface for the upper layer to call, and the internal and external interfaces of the module are distinct.
4. The function of the module can only be increased, not changed.
5. Each functional module layer can also be further layered, such as the interface layer, the driver layer, and the hardware layer.

(3) Module level description

 

Hardware driver layer The

hardware driver layer contains all the drivers necessary for the on-board hardware resources to function properly and provides APIs for function module calls.

 

Function module layer The

function module layer includes functions that implement specific functions. The corresponding functions are realized by calling the driver layer API, and at the same time, the callable API is provided to the business logic layer.

 

Business

logic layer The business logic layer includes various business processes of the overall function of the product, and is implemented by calling the API of the function module layer.

 

Application layer The

application layer integrates and calls various business logics to complete the functions of the entire product.

(4) Advantages

If the driver changes, or if you change to a different platform, you only need to change the driver layer, and the application layer is not affected.

If the functional module changes, only the corresponding functional module needs to be upgraded, the other modules are not affected, and the application layer is not affected.

After designing according to this logic, the main job is at the business logic layer. The application layer is the overall process and framework of the program, mainly calling the business logic layer to achieve different functions.

Published 13 original articles · Liked4 · Visits 765

Guess you like

Origin blog.csdn.net/yuechifanfan/article/details/105570728