Design guidelines for embedded applications
I've been doing a lot of embedded coding lately. I'm not a very experienced developer and I have been trying to develop a set of design guidelines to help me up the learning curve. I'd appreciate hearing what experienced embedded developers use for guidelines.
The SOLID principles make a lot of sense to me but I've added a few more of my own. Any comments on these will also be appreciated. If they're dumb, I'll be happy to modify or drop them.
- My main goal it to make sure the code is reasonably easy to understand by a competent but not necessarily expert C/C++ developer.
- For most embedded applications, the code should be non-blocking. For example, all my UART drivers use DMA at this point. If I run out of DMA channels, I can use IT transfers to maintain a non-blocking approach.
- I'd prefer to use straight C. However, I have a basic understanding of Object Oriented programming. The other developers who may work with me on this project have an ever better understanding of OOP. But nobody sees OOP as the answer to all our needs. So, I'll use a C++ class if it make the code easier to understand or reduces cut and paste or some other good reason.
- Functions shouldn't be more than a screen full of lines.
- Files shouldn't be more than a couple of 100 lines long.
- Functions should be loosely coupled. Loosely coupled to me means for example: GPS receiver code shouldn't need to know very much, better yet nothing at all, about the details of the UART or I2C or whatever port it's using to communicate.
- I'm trying to stick to the STM low level drivers instead of the HAL drivers.
