Layered Design in MCU Programming for Effective Decoupling

First, let’s demonstrate the effect.The host computer and the embedded system are decoupled through serial communication, meaning changes in the implementations of the host and embedded systems do not affect the interface programming.There is a term in object-oriented design called: “programming to an interface.” This suggests that programming based on class interfaces is less pure than interface programming, which allows for greater polymorphism and easier decoupling.After implementing layered design, as long as the interfaces of each layer remain unchanged, even if the internal implementation of a layer is restructured, it will not affect the original framework of the program. For teams with multiple developers, restructuring internal implementations is transparent and irrelevant to other programmers.In this example, serial communication serves as the interface, and I have restructured different implementations for the host and embedded systems. For instance, the embedded system uses both Arduino programming and AVR programming; the host computer uses JavaScript and C# programming (and even one host could be a client-server architecture while another is a browser-server architecture, or it could use tools like SSCOM for serial communication). However, the program interaction remains unchanged, still producing the original effect. This illustrates the advantages and appeal of software layering.Layered design is a design philosophy that applies not only to software design but also to hardware. The most famous example of layered design is the TCP/IP protocol stack (ISO International Organization for Standardization‘s Open System Interconnection seven-layer model), which corresponds to numerous interconnected devices on the internet, such as switches, routers, and computer hosts.

Leave a Comment