You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2022/03/02 12:30:39 UTC

[GitHub] [incubator-nuttx] gustavonihei opened a new pull request #5668: xtensa/esp32s3: Add support for Tickless kernel using Systimer

gustavonihei opened a new pull request #5668:
URL: https://github.com/apache/incubator-nuttx/pull/5668


   ## Summary
   This PR intends to add support for Tickless operation of the NuttX kernel using the Systimer component.
   
   ## Impact
   Extended OS support for `esp32s3-devkit` platform.
   
   ## Testing
   Tested using `esp32s3-devkit:tickless`.
   Boot into NSH and successful execution of `ostest`.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5668: xtensa/esp32s3: Add support for Tickless kernel using Systimer

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5668:
URL: https://github.com/apache/incubator-nuttx/pull/5668#discussion_r817666273



##########
File path: arch/xtensa/src/esp32s3/esp32s3_tickless.c
##########
@@ -0,0 +1,484 @@
+/****************************************************************************
+ * arch/xtensa/src/esp32s3/esp32s3_tickless.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Tickless OS Support.
+ *
+ * When CONFIG_SCHED_TICKLESS is enabled, all support for timer interrupts
+ * is suppressed and the platform specific code is expected to provide the
+ * following custom functions.
+ *
+ *   void up_timer_initialize(void): Initializes the timer facilities.
+ *     Called early in the initialization sequence (by up_initialize()).
+ *   int up_timer_gettime(struct timespec *ts):  Returns the current
+ *     time from the platform specific time source.
+ *   int up_timer_cancel(void):  Cancels the interval timer.
+ *   int up_timer_start(const struct timespec *ts): Start (or re-starts)
+ *     the interval timer.
+ *
+ * The RTOS will provide the following interfaces for use by the platform-
+ * specific interval timer implementation:
+ *
+ *   void sched_timer_expiration(void):  Called by the platform-specific
+ *     logic when the interval timer expires.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <time.h>
+#include <assert.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
+#include <nuttx/clock.h>
+#include <arch/board/board.h>
+#include <arch/irq.h>
+
+#include "xtensa.h"
+#include "chip.h"
+#include "esp32s3_irq.h"
+#include "hardware/esp32s3_systimer.h"
+#include "hardware/esp32s3_system.h"
+#include "hardware/esp32s3_soc.h"
+
+#ifdef CONFIG_SCHED_TICKLESS
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define ESP32S3_SYSTIMER_TICKS_PER_SEC  (16 * 1000 * 1000)
+
+#define CTICK_PER_SEC         (ESP32S3_SYSTIMER_TICKS_PER_SEC)
+#define CTICK_PER_USEC        (CTICK_PER_SEC / USEC_PER_SEC)
+
+#define SEC_2_CTICK(s)        ((s) * CTICK_PER_SEC)
+#define USEC_2_CTICK(us)      ((us) * CTICK_PER_USEC)
+#define NSEC_2_CTICK(nsec)    (((nsec) * CTICK_PER_USEC) / NSEC_PER_USEC)
+
+#define CTICK_2_SEC(tick)     ((tick) / CTICK_PER_SEC)
+#define CTICK_2_USEC(tick)    ((tick) / CTICK_PER_USEC)
+#define CTICK_2_NSEC(tick)    ((tick) * 1000 / CTICK_PER_USEC)
+
+#define CPU_TICKS_MAX         (UINT32_MAX / 4 * 3)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static inline uint64_t up_tmr_getcounter(void);
+static inline uint64_t up_tmr_getalarmvalue(void);
+static void IRAM_ATTR up_tmr_setcounter(uint64_t ticks);
+static int IRAM_ATTR up_timer_expire(int irq, void *context, void *arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_timer_started; /* Whether an interval timer is being started */
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_tmr_getcounter
+ *
+ * Description:
+ *   Return the total ticks of system since power-on.
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   Total system ticks.
+ *
+ ****************************************************************************/
+
+static inline uint64_t up_tmr_getcounter(void)

Review comment:
       Thank you




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] pkarashchenko commented on a change in pull request #5668: xtensa/esp32s3: Add support for Tickless kernel using Systimer

Posted by GitBox <gi...@apache.org>.
pkarashchenko commented on a change in pull request #5668:
URL: https://github.com/apache/incubator-nuttx/pull/5668#discussion_r817661244



##########
File path: arch/xtensa/src/esp32s3/esp32s3_tickless.c
##########
@@ -0,0 +1,484 @@
+/****************************************************************************
+ * arch/xtensa/src/esp32s3/esp32s3_tickless.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Tickless OS Support.
+ *
+ * When CONFIG_SCHED_TICKLESS is enabled, all support for timer interrupts
+ * is suppressed and the platform specific code is expected to provide the
+ * following custom functions.
+ *
+ *   void up_timer_initialize(void): Initializes the timer facilities.
+ *     Called early in the initialization sequence (by up_initialize()).
+ *   int up_timer_gettime(struct timespec *ts):  Returns the current
+ *     time from the platform specific time source.
+ *   int up_timer_cancel(void):  Cancels the interval timer.
+ *   int up_timer_start(const struct timespec *ts): Start (or re-starts)
+ *     the interval timer.
+ *
+ * The RTOS will provide the following interfaces for use by the platform-
+ * specific interval timer implementation:
+ *
+ *   void sched_timer_expiration(void):  Called by the platform-specific
+ *     logic when the interval timer expires.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <time.h>
+#include <assert.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
+#include <nuttx/clock.h>
+#include <arch/board/board.h>
+#include <arch/irq.h>
+
+#include "xtensa.h"
+#include "chip.h"
+#include "esp32s3_irq.h"
+#include "hardware/esp32s3_systimer.h"
+#include "hardware/esp32s3_system.h"
+#include "hardware/esp32s3_soc.h"
+
+#ifdef CONFIG_SCHED_TICKLESS
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define ESP32S3_SYSTIMER_TICKS_PER_SEC  (16 * 1000 * 1000)
+
+#define CTICK_PER_SEC         (ESP32S3_SYSTIMER_TICKS_PER_SEC)
+#define CTICK_PER_USEC        (CTICK_PER_SEC / USEC_PER_SEC)
+
+#define SEC_2_CTICK(s)        ((s) * CTICK_PER_SEC)
+#define USEC_2_CTICK(us)      ((us) * CTICK_PER_USEC)
+#define NSEC_2_CTICK(nsec)    (((nsec) * CTICK_PER_USEC) / NSEC_PER_USEC)
+
+#define CTICK_2_SEC(tick)     ((tick) / CTICK_PER_SEC)
+#define CTICK_2_USEC(tick)    ((tick) / CTICK_PER_USEC)
+#define CTICK_2_NSEC(tick)    ((tick) * 1000 / CTICK_PER_USEC)
+
+#define CPU_TICKS_MAX         (UINT32_MAX / 4 * 3)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static inline uint64_t up_tmr_getcounter(void);
+static inline uint64_t up_tmr_getalarmvalue(void);
+static void IRAM_ATTR up_tmr_setcounter(uint64_t ticks);
+static int IRAM_ATTR up_timer_expire(int irq, void *context, void *arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_timer_started; /* Whether an interval timer is being started */
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_tmr_getcounter
+ *
+ * Description:
+ *   Return the total ticks of system since power-on.
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   Total system ticks.
+ *
+ ****************************************************************************/
+
+static inline uint64_t up_tmr_getcounter(void)

Review comment:
       why do you use `up_` notation for local functions?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] pkarashchenko merged pull request #5668: xtensa/esp32s3: Add support for Tickless kernel using Systimer

Posted by GitBox <gi...@apache.org>.
pkarashchenko merged pull request #5668:
URL: https://github.com/apache/incubator-nuttx/pull/5668


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #5668: xtensa/esp32s3: Add support for Tickless kernel using Systimer

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #5668:
URL: https://github.com/apache/incubator-nuttx/pull/5668#discussion_r817665684



##########
File path: arch/xtensa/src/esp32s3/esp32s3_tickless.c
##########
@@ -0,0 +1,484 @@
+/****************************************************************************
+ * arch/xtensa/src/esp32s3/esp32s3_tickless.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Tickless OS Support.
+ *
+ * When CONFIG_SCHED_TICKLESS is enabled, all support for timer interrupts
+ * is suppressed and the platform specific code is expected to provide the
+ * following custom functions.
+ *
+ *   void up_timer_initialize(void): Initializes the timer facilities.
+ *     Called early in the initialization sequence (by up_initialize()).
+ *   int up_timer_gettime(struct timespec *ts):  Returns the current
+ *     time from the platform specific time source.
+ *   int up_timer_cancel(void):  Cancels the interval timer.
+ *   int up_timer_start(const struct timespec *ts): Start (or re-starts)
+ *     the interval timer.
+ *
+ * The RTOS will provide the following interfaces for use by the platform-
+ * specific interval timer implementation:
+ *
+ *   void sched_timer_expiration(void):  Called by the platform-specific
+ *     logic when the interval timer expires.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <time.h>
+#include <assert.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
+#include <nuttx/clock.h>
+#include <arch/board/board.h>
+#include <arch/irq.h>
+
+#include "xtensa.h"
+#include "chip.h"
+#include "esp32s3_irq.h"
+#include "hardware/esp32s3_systimer.h"
+#include "hardware/esp32s3_system.h"
+#include "hardware/esp32s3_soc.h"
+
+#ifdef CONFIG_SCHED_TICKLESS
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define ESP32S3_SYSTIMER_TICKS_PER_SEC  (16 * 1000 * 1000)
+
+#define CTICK_PER_SEC         (ESP32S3_SYSTIMER_TICKS_PER_SEC)
+#define CTICK_PER_USEC        (CTICK_PER_SEC / USEC_PER_SEC)
+
+#define SEC_2_CTICK(s)        ((s) * CTICK_PER_SEC)
+#define USEC_2_CTICK(us)      ((us) * CTICK_PER_USEC)
+#define NSEC_2_CTICK(nsec)    (((nsec) * CTICK_PER_USEC) / NSEC_PER_USEC)
+
+#define CTICK_2_SEC(tick)     ((tick) / CTICK_PER_SEC)
+#define CTICK_2_USEC(tick)    ((tick) / CTICK_PER_USEC)
+#define CTICK_2_NSEC(tick)    ((tick) * 1000 / CTICK_PER_USEC)
+
+#define CPU_TICKS_MAX         (UINT32_MAX / 4 * 3)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static inline uint64_t up_tmr_getcounter(void);
+static inline uint64_t up_tmr_getalarmvalue(void);
+static void IRAM_ATTR up_tmr_setcounter(uint64_t ticks);
+static int IRAM_ATTR up_timer_expire(int irq, void *context, void *arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_timer_started; /* Whether an interval timer is being started */
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_tmr_getcounter
+ *
+ * Description:
+ *   Return the total ticks of system since power-on.
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   Total system ticks.
+ *
+ ****************************************************************************/
+
+static inline uint64_t up_tmr_getcounter(void)

Review comment:
       Interesting question. This driver is a port from another ESP32 chip, the `up_` prefix didn't caught my attention before.
   It seems pointless for these internal functions to be prefixed with `up_`. I will rename them.
   Thanks.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #5668: xtensa/esp32s3: Add support for Tickless kernel using Systimer

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #5668:
URL: https://github.com/apache/incubator-nuttx/pull/5668#discussion_r817671140



##########
File path: arch/xtensa/src/esp32s3/esp32s3_tickless.c
##########
@@ -0,0 +1,484 @@
+/****************************************************************************
+ * arch/xtensa/src/esp32s3/esp32s3_tickless.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Tickless OS Support.
+ *
+ * When CONFIG_SCHED_TICKLESS is enabled, all support for timer interrupts
+ * is suppressed and the platform specific code is expected to provide the
+ * following custom functions.
+ *
+ *   void up_timer_initialize(void): Initializes the timer facilities.
+ *     Called early in the initialization sequence (by up_initialize()).
+ *   int up_timer_gettime(struct timespec *ts):  Returns the current
+ *     time from the platform specific time source.
+ *   int up_timer_cancel(void):  Cancels the interval timer.
+ *   int up_timer_start(const struct timespec *ts): Start (or re-starts)
+ *     the interval timer.
+ *
+ * The RTOS will provide the following interfaces for use by the platform-
+ * specific interval timer implementation:
+ *
+ *   void sched_timer_expiration(void):  Called by the platform-specific
+ *     logic when the interval timer expires.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <time.h>
+#include <assert.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
+#include <nuttx/clock.h>
+#include <arch/board/board.h>
+#include <arch/irq.h>
+
+#include "xtensa.h"
+#include "chip.h"
+#include "esp32s3_irq.h"
+#include "hardware/esp32s3_systimer.h"
+#include "hardware/esp32s3_system.h"
+#include "hardware/esp32s3_soc.h"
+
+#ifdef CONFIG_SCHED_TICKLESS
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define ESP32S3_SYSTIMER_TICKS_PER_SEC  (16 * 1000 * 1000)
+
+#define CTICK_PER_SEC         (ESP32S3_SYSTIMER_TICKS_PER_SEC)
+#define CTICK_PER_USEC        (CTICK_PER_SEC / USEC_PER_SEC)
+
+#define SEC_2_CTICK(s)        ((s) * CTICK_PER_SEC)
+#define USEC_2_CTICK(us)      ((us) * CTICK_PER_USEC)
+#define NSEC_2_CTICK(nsec)    (((nsec) * CTICK_PER_USEC) / NSEC_PER_USEC)
+
+#define CTICK_2_SEC(tick)     ((tick) / CTICK_PER_SEC)
+#define CTICK_2_USEC(tick)    ((tick) / CTICK_PER_USEC)
+#define CTICK_2_NSEC(tick)    ((tick) * 1000 / CTICK_PER_USEC)
+
+#define CPU_TICKS_MAX         (UINT32_MAX / 4 * 3)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static inline uint64_t up_tmr_getcounter(void);
+static inline uint64_t up_tmr_getalarmvalue(void);
+static void IRAM_ATTR up_tmr_setcounter(uint64_t ticks);
+static int IRAM_ATTR up_timer_expire(int irq, void *context, void *arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_timer_started; /* Whether an interval timer is being started */
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_tmr_getcounter
+ *
+ * Description:
+ *   Return the total ticks of system since power-on.
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   Total system ticks.
+ *
+ ****************************************************************************/
+
+static inline uint64_t up_tmr_getcounter(void)

Review comment:
       Done, renamed the private `up_tmr_` prefixed functions to `tickless_`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] gustavonihei commented on a change in pull request #5668: xtensa/esp32s3: Add support for Tickless kernel using Systimer

Posted by GitBox <gi...@apache.org>.
gustavonihei commented on a change in pull request #5668:
URL: https://github.com/apache/incubator-nuttx/pull/5668#discussion_r817671140



##########
File path: arch/xtensa/src/esp32s3/esp32s3_tickless.c
##########
@@ -0,0 +1,484 @@
+/****************************************************************************
+ * arch/xtensa/src/esp32s3/esp32s3_tickless.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Tickless OS Support.
+ *
+ * When CONFIG_SCHED_TICKLESS is enabled, all support for timer interrupts
+ * is suppressed and the platform specific code is expected to provide the
+ * following custom functions.
+ *
+ *   void up_timer_initialize(void): Initializes the timer facilities.
+ *     Called early in the initialization sequence (by up_initialize()).
+ *   int up_timer_gettime(struct timespec *ts):  Returns the current
+ *     time from the platform specific time source.
+ *   int up_timer_cancel(void):  Cancels the interval timer.
+ *   int up_timer_start(const struct timespec *ts): Start (or re-starts)
+ *     the interval timer.
+ *
+ * The RTOS will provide the following interfaces for use by the platform-
+ * specific interval timer implementation:
+ *
+ *   void sched_timer_expiration(void):  Called by the platform-specific
+ *     logic when the interval timer expires.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <stdint.h>
+#include <stdbool.h>
+#include <time.h>
+#include <assert.h>
+
+#include <nuttx/irq.h>
+#include <nuttx/arch.h>
+#include <nuttx/clock.h>
+#include <arch/board/board.h>
+#include <arch/irq.h>
+
+#include "xtensa.h"
+#include "chip.h"
+#include "esp32s3_irq.h"
+#include "hardware/esp32s3_systimer.h"
+#include "hardware/esp32s3_system.h"
+#include "hardware/esp32s3_soc.h"
+
+#ifdef CONFIG_SCHED_TICKLESS
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define ESP32S3_SYSTIMER_TICKS_PER_SEC  (16 * 1000 * 1000)
+
+#define CTICK_PER_SEC         (ESP32S3_SYSTIMER_TICKS_PER_SEC)
+#define CTICK_PER_USEC        (CTICK_PER_SEC / USEC_PER_SEC)
+
+#define SEC_2_CTICK(s)        ((s) * CTICK_PER_SEC)
+#define USEC_2_CTICK(us)      ((us) * CTICK_PER_USEC)
+#define NSEC_2_CTICK(nsec)    (((nsec) * CTICK_PER_USEC) / NSEC_PER_USEC)
+
+#define CTICK_2_SEC(tick)     ((tick) / CTICK_PER_SEC)
+#define CTICK_2_USEC(tick)    ((tick) / CTICK_PER_USEC)
+#define CTICK_2_NSEC(tick)    ((tick) * 1000 / CTICK_PER_USEC)
+
+#define CPU_TICKS_MAX         (UINT32_MAX / 4 * 3)
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static inline uint64_t up_tmr_getcounter(void);
+static inline uint64_t up_tmr_getalarmvalue(void);
+static void IRAM_ATTR up_tmr_setcounter(uint64_t ticks);
+static int IRAM_ATTR up_timer_expire(int irq, void *context, void *arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static bool g_timer_started; /* Whether an interval timer is being started */
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: up_tmr_getcounter
+ *
+ * Description:
+ *   Return the total ticks of system since power-on.
+ *
+ * Input Parameters:
+ *   None.
+ *
+ * Returned Value:
+ *   Total system ticks.
+ *
+ ****************************************************************************/
+
+static inline uint64_t up_tmr_getcounter(void)

Review comment:
       Done, renamed the private `up_` prefixed functions to `tickless_`.




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org