3 Writing Bare Metal C-Code for AVR®
The following subsections focus on how to write C-code for AVR. The examples describe how to make the code readable and portable between different AVR devices. The examples can also be used as a guideline on how to write code that is easy to verify and maintain.
The microcontroller modules are located in dedicated and continuous blocks in the memory space and can be seen as encapsulated units. The modules are encapsulated in C structures, in which all module registers are contained.
This document introduces a naming convention and register access methods that are compliant with the AVR header files, providing readability and portability to the codes written in the C-code.