Hi,
I'm looking into implementing tickless on nRF52 (first using systick, since it 
is an easy option, and then using a RTC timer, which works while CPU is 
asleep). My intention is to use the arch timer driver for this 
(drivers/timer/arch_timer.c) since it provides up_mdelay without using a busy 
loop and it supports both tickless and non-tickless. However, the code right now
turns up to be a bit akward since the arch timer is optional so you have to 
support the case for when it is off. This means that tickless mode needs to be 
separately supported. On STM32 you can see this in stm32_timerisr.c (where 
there are two implementations, depending on the arch timer being ON or not) and 
in stm32_tickless.c (which does not uses the arch timer, but provides tickless 
functionality on its own). 

I understand this is due to arch_timer/rtc/alarm being introduced more recently 
but I'm not sure if it makes sense to have them as optional instead of the 
standard way to provide both tickless and non-tickless modes. IMHO it would be 
cleaner and simpler (to implement and to configure the build for each case) to 
do the latter. Or is there a downside to this?

If you agree, I think the change would consist of: 
* deprecate the "old way" (maybe open an issue which lists which arch is not 
yet converted), only accept the "new way" in new ports
* convert each arch (by someone who is able to test it) by:
  - replace *_timerisr.c and *_tickless.c for each arch by one file 
(*_systime.c?) where the appropriate arch_timer/rtc/alarm interface is invoked, 
based on supported options for the arch (systick should be the basic option).
  - implement each possible system timer source as a arch_timer/rtc/alarm 
lowerhalf in its own file

Best,
Matias

Reply via email to