There is another valuable level of architecture/design in there, one which has lead to "model driven" concepts.
To put it simply, there is a mismatch between the application domain concepts and the hardware. You will find domain experts can express themselves in terms of application domain concepts; they will understand what the system is doing in those terms only. It is thus a very good idea to have software constructs that directly mirror the application domain concepts. That will greatly simplify requirements gathering and signoff, acceptance testing, and later system enhancements. So far that is true for all software development.
For real-time embedded systems, it is highly advantageous to think in terms of FSMs, states and events. When understanding the application domain, "nouns" map onto the model's states or model's data, and "verbs" map onto the model's events. Use the standard Design Patterns to implement the FSMs, states and events.
For a door controller, the states might be OpenState, ClosedState, OpeningState, ClosingState, EmergencyState, FailedState, the events might be OpenRequest, CloseRequest, Timeout, CloseCompleted, OpenCompleted, and the data might be MotorOpen, MotorClose, MotorOff, MotorDisconnected.
Then the hardware adaptation layer simply maps inputs into the model's events, and model's data changes into outputs. Thus when bit 4 of PIO register changes from 0 to 1, create a new CloseRequest object and send it to the FSM; the FSM will change MotorClose to True which causes bit 13 in PIO register 22 to be set to 0.
You can debug/test the application domain model without the hardware: all you do is have your test framework create the model's events instead of the hardware, etc.