{"docs":[{"id":141,"title":"Embedded Software Architecture: Layers, HAL and Drivers","heading":"Embedded Software Architecture: Layers, HAL and Drivers","subheading":null,"category":"Embedded Software","body":{"root":{"type":"root","children":[{"type":"heading","tag":"h3","version":1,"children":[{"type":"text","text":"Where to draw the lines","version":1}]},{"type":"paragraph","version":1,"children":[{"type":"text","text":"The lowest layer is the hardware abstraction layer: vendor or in-house code that configures clocks, pins and peripherals. Above it, drivers handle external devices such as a temperature sensor or flash chip, written against a small bus interface so they work with any I2C or SPI implementation. Services such as logging, storage and communication protocols sit above the drivers, and the application sits on top.","version":1}]},{"type":"paragraph","version":1,"children":[{"type":"text","text":"Keep the interfaces narrow and named for what they do, such as read temperature, rather than how they do it. Board-specific facts, such as which pin drives which LED, belong in a single board configuration file.","version":1}]}],"direction":"ltr","format":"","indent":0,"version":1}},"tags":"Embedded Software, Architecture, Firmware","cardCta":{"label":null,"link":null},"pageCta":{"label":"Talk to AAVICO engineering","link":"/contact"},"excerpt":"Firmware that mixes register access with application logic works once and resists every change after. A layered structure keeps hardware details where they belong.","featuredImage":null,"type":"Blog","readTime":"3 min read","publishedAt":"2026-11-15T20:40:00.000Z","heroImage":null,"introText":"Most firmware starts as a vendor example and grows. Register writes end up in the middle of application logic, a sensor driver assumes one particular I2C peripheral, and moving to a different microcontroller means touching almost every file. A layered architecture separates what the product does from how the hardware does it. This article describes the usual layers, the rules that keep them separate and what they cost.","metrics":[{"id":"embedded-software-architecture-layers-hal-and-dr-metric-1","value":"4 layers","label":"Hardware access, drivers, services and application: a common and workable split.","icon":null},{"id":"embedded-software-architecture-layers-hal-and-dr-metric-2","value":"CMSIS","label":"Arm’s standard software interface for Cortex-M cores, used by most vendor libraries.","icon":null},{"id":"embedded-software-architecture-layers-hal-and-dr-metric-3","value":"Downward","label":"Each layer calls only the layers beneath it. Nothing low-level knows about the application.","icon":null},{"id":"embedded-software-architecture-layers-hal-and-dr-metric-4","value":"Interfaces","label":"Drivers depend on abstract bus functions, not on one vendor’s peripheral.","icon":null}],"gallery":[],"challenge":{"root":{"type":"root","children":[{"type":"paragraph","version":1,"children":[{"type":"text","text":"When the application calls hardware directly, every change in hardware ripples upward. A pin moved on the next board revision, a sensor replaced because of a shortage, or a new microcontroller family each turns into a search through the whole codebase.","version":1}]},{"type":"paragraph","version":1,"children":[{"type":"text","text":"Tight coupling also blocks testing. Logic that cannot run without real registers can only be tested on a board, one slow cycle at a time, so it tends not to be tested at all.","version":1}]}],"direction":"ltr","format":"","indent":0,"version":1}},"blockquote":{"quote":"Put each hardware detail in exactly one place. Then a hardware change becomes a local edit rather than a project.","author":"","role":"AAVICO Engineering"},"supportImage1":null,"deliverables":{"root":{"type":"root","children":[{"type":"paragraph","version":1,"children":[{"type":"text","text":"Draw the layers and the allowed dependencies before writing code, and decide which vendor libraries sit at the bottom.","version":1}]},{"type":"paragraph","version":1,"children":[{"type":"text","text":"Define the interface each driver needs from the layer below, and write drivers against that interface instead of a specific peripheral.","version":1}]},{"type":"paragraph","version":1,"children":[{"type":"text","text":"Check the rules in review or with a dependency check in the build, so that shortcuts across layers are caught early.","version":1}]}],"direction":"ltr","format":"","indent":0,"version":1}},"results":[{"id":"embedded-software-architecture-layers-hal-and-dr-result-1","title":"Portability","description":"Changing microcontroller replaces the lower layers and leaves the application intact."},{"id":"embedded-software-architecture-layers-hal-and-dr-result-2","title":"Testability","description":"Logic above the hardware layer can be built and tested on a PC."},{"id":"embedded-software-architecture-layers-hal-and-dr-result-3","title":"Supply Resilience","description":"Swapping a sensor or memory for an alternative part touches one driver."},{"id":"embedded-software-architecture-layers-hal-and-dr-result-4","title":"Team Scaling","description":"Engineers can work on separate layers in parallel against agreed interfaces."}],"lookingAhead":{"root":{"type":"root","children":[{"type":"paragraph","version":1,"children":[{"type":"text","text":"Do not over-abstract. A layer that wraps a single register write in three function calls adds code and confusion without making anything easier to change.","version":1}]},{"type":"paragraph","version":1,"children":[{"type":"text","text":"Where timing is critical, such as a motor control loop, allow a documented exception that accesses hardware directly, and keep it small.","version":1}]}],"direction":"ltr","format":"","indent":0,"version":1}},"supportImage2":null,"testimonial":{"quote":null,"author":null,"role":null,"photo":null},"challengesSolved":[{"id":"embedded-software-architecture-layers-hal-and-dr-challenge-1","title":"Register writes scattered through application code","description":null,"icon":null},{"id":"embedded-software-architecture-layers-hal-and-dr-challenge-2","title":"A sensor change that touches dozens of files","description":null,"icon":null},{"id":"embedded-software-architecture-layers-hal-and-dr-challenge-3","title":"Logic that can only be tested on a board","description":null,"icon":null},{"id":"embedded-software-architecture-layers-hal-and-dr-challenge-4","title":"Abstraction layers that add code but no flexibility","description":null,"icon":null}],"relatedPosts":[],"contactUs":{"show":true},"updatedAt":"2026-11-15T17:32:32.682Z","createdAt":"2026-11-15T17:32:32.682Z"}],"hasNextPage":false,"hasPrevPage":false,"limit":10,"nextPage":null,"page":1,"pagingCounter":1,"prevPage":null,"totalDocs":1,"totalPages":1}