> -----Original Message-----
> From: Matias N. <mat...@imap.cc>
> Sent: Thursday, September 3, 2020 6:31 AM
> To: dev@nuttx.apache.org
> Subject: supporting tickless and non-tickless using arch_timer/alarm/rtc
> 
> 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.

We can auto select TIMER_ARCH under config ARCH_CHIP_NRF52, so we don't need 
provide two implementation.

> 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?
> 

Yes, it doesn't make sense to provide two implementation with the same 
functionality. The chip owner should select one and stick
with that approach. Selecting by Kconfig just make the code hard to maintain.

> 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
> 

Yes, we can do the conversion step by step. Once the work is done, arch_timer.c 
can be compiled by default and remove TIMER_ARCH
Kconfig. 

> Best,
> Matias

Reply via email to