Demonstrating Layered Architecture in Embedded Systems with Code

This article takes the example of controlling an LED blinking.
Demonstrating Layered Architecture in Embedded Systems with Code

1 Two-Layer Structure

Hardware layer and software layer — the coarsest layered architecture:
Demonstrating Layered Architecture in Embedded Systems with Code

2 Three-Layer Structure

Hardware layer, driver layer, application layer:
Demonstrating Layered Architecture in Embedded Systems with Code

3 Four-Layer Structure

Hardware layer, driver layer, operating system layer, application layer:

Demonstrating Layered Architecture in Embedded Systems with Code

Demonstrating Layered Architecture in Embedded Systems with Code
From the above examples, it seems that the more layers there are, the more code there is in the system, and the greater the workload for developers. Is this really the case? The purpose of layering is mainly 1 to reduce the difficulty of system development; 2 to allow for reuse.
The driver layer and the intermediate operating system layer can be reused. When products are upgraded or replaced, although the total amount of code is large, a lot of code does not need to be redeveloped, and the workload of system development is relatively small. For example, if the IO port is adjusted, or even if the entire hardware board is replaced, the software only needs to adjust the driver.
Many embedded system courses in universities adopt a two-layer structure, mainly because the examples in textbooks are generally simpler, and the main purpose is to demonstrate how to use the chip and how to implement a certain function, with little consideration for reuse.
To clarify the operational methods, the code will be kept as simple as possible. Even if implementing a relatively complex function, it may just use abstraction into functions, with little consideration for engineering issues. Gradually, many people come to take the two-layer architecture for granted.
The specific layered structure adopted is related to the product. For example, everyone knows that flying is faster than walking, but which method is better for getting from a classroom to a dormitory on campus? Of course, it is walking. Conversely, from Nanjing to Beijing, taking a plane is definitely better than walking (of course, the best option is to take the high-speed train).
The third method seems to have the largest amount of code, but remember that the underlying code changes very little, so during development, you are just writing applications. How much code is that?! The advantages are evident!
Source: https://blog.csdn.net/wxg_wuchujie88/article/details/85992064

Leave a Comment

Your email address will not be published. Required fields are marked *