The function handle_mcucsr() uses two __attribute__ declarators to achieve specific goals. First, it will instruct the compiler to place the generated code into the .init3 section of the output. Thus, it will become part of the application initialization sequence. This is done in order to fetch (and clear) the reason of the last hardware reset from MCUCSR as early as possible. There is a short period of time where the next reset could already trigger before the current reason has been evaluated. This also explains why the variable mcucsr that mirrors the register's value needs to be placed into the .noinit section, because otherwise the default initialization (which happens after .init3) would blank the value again.

As the initialization code is not called using CALL/RET instructions but rather concatenated together, the compiler needs to be instructed to omit the entire function prologue and epilogue. This is performed by the naked attribute. So while syntactically, handle_mcucsr() is a function to the compiler, the compiler will just emit the instructions for it without setting up any stack frame, and not even a RET instruction at the end.

Function ioinit() centralizes all hardware setup. The very last part of that function demonstrates the use of the EEPROM variable ee_pwm to obtain an EEPROM address that can in turn be applied as an argument to eeprom_read_word().

The following functions handle UART character and string output. (UART input is handled by an ISR.) There are two string output functions, printstr() and printstr_p(). The latter function fetches the string from program memory. Both functions translate a newline character into a carriage return/newline sequence, so a simple \n can be used in the source code.

The function set_pwm() propagates the new PWM value to the PWM, performing range checking. When the value has been changed, the new percentage will be announced on the serial link. The current value is mirrored in the variable pwm so others can use it in calculations. In order to allow for a simple calculation of a percentage value without requiring floating-point mathematics, the maximal value of the PWM is restricted to 1000 rather than 1023, so a simple division by 10 can be used. Due to the nature of the human eye, the difference in LED brightness between 1000 and 1023 is not noticable anyway.