Change the time compare from while to exiting from while through if,

this is done because on some cases the compiler has no desired result on long long compare.
Add VBat and ResolutionBits, this is for controllers that provide the ADC resolution change and a input to read the RTC battery voltage like STM32F4.
Actualize the project to new conditions.