add TIM4 function and Variable Tick Timer
STM8: optimize idle handling