Hi
Most professional written application are separated into application and BSP where BSP - (board support packge,low level driver software) and application can became a simple running main routine or an RTOS(Real Time Operating System)
It is the best way to write a software and to maintain it
from my point of view a good maintaind BSP is a very hard work to do since the programmer must have a good knowledge in hardware as well as software
All the best
Bobi