This is an automated email from the ASF dual-hosted git repository.

acassis pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git

commit 996a321e3a068941dd44d7658fde56f49627009b
Author: raiden00pl <[email protected]>
AuthorDate: Fri Jun 5 16:12:08 2026 +0200

    arch/arm/src/stm32: unify TIM one-shot wrapper into common/stm32
    
    Merge the per-IP and per-family one-shot timer wrappers (driver + 
lower-half)
    into a single common/stm32/stm32_oneshot.c and stm32_oneshot_lowerhalf.c,
    following the timer-driver and free-run unification.
    
    - Rename stm32_oneshot_m3m4_v1{,_lowerhalf}.c -> common/stm32/stm32_oneshot
      {,_lowerhalf}.c (the most complete variant: full counter/period cancel
      logic).
    - Delete the stm32h7/stm32_oneshot*, stm32l4_oneshot* and stm32wb_oneshot*
      copies
    
    Signed-off-by: raiden00pl <[email protected]>
    Assisted-by: Claude Code
---
 .github/CODEOWNERS                                 |  13 +-
 arch/arm/src/common/stm32/CMakeLists.txt           |   8 +-
 arch/arm/src/common/stm32/Make.defs                |   8 +-
 .../{stm32_oneshot_m3m4_v1.c => stm32_oneshot.c}   |   2 +-
 .../stm32}/stm32_oneshot_lowerhalf.c               |   3 +-
 .../common/stm32/stm32_oneshot_m3m4_v1_lowerhalf.c | 309 --------------
 arch/arm/src/stm32h7/CMakeLists.txt                |   4 -
 arch/arm/src/stm32h7/Make.defs                     |   4 -
 arch/arm/src/stm32h7/stm32_oneshot.c               | 404 ------------------
 arch/arm/src/stm32h7/stm32_oneshot.h               | 197 ---------
 arch/arm/src/stm32l4/CMakeLists.txt                |   4 -
 arch/arm/src/stm32l4/Make.defs                     |   4 -
 arch/arm/src/stm32l4/stm32l4_oneshot.c             | 460 ---------------------
 arch/arm/src/stm32l4/stm32l4_oneshot.h             | 198 ---------
 arch/arm/src/stm32l4/stm32l4_oneshot_lowerhalf.c   | 310 --------------
 arch/arm/src/stm32l4/stm32l4_tickless.c            |   2 +-
 arch/arm/src/stm32wb/CMakeLists.txt                |   4 -
 arch/arm/src/stm32wb/Make.defs                     |   4 -
 arch/arm/src/stm32wb/stm32wb_oneshot.c             | 459 --------------------
 arch/arm/src/stm32wb/stm32wb_oneshot.h             | 198 ---------
 arch/arm/src/stm32wb/stm32wb_oneshot_lowerhalf.c   | 309 --------------
 21 files changed, 14 insertions(+), 2890 deletions(-)

diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index 80ae0e94770..e61c8d6edca 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -1800,9 +1800,9 @@ arch/arm/src/common/stm32/stm32_ltdc_m3m4_v1.c 
[email protected] xiaoxiang@x
 arch/arm/src/common/stm32/stm32_ltdc_m3m4_v1.h [email protected] 
[email protected] [email protected] 
[email protected] [email protected]
 arch/arm/src/common/stm32/stm32_mpuinit.h [email protected] 
[email protected] [email protected]
 arch/arm/src/common/stm32/stm32_mpuinit_m3m4_v1.c [email protected] 
[email protected] [email protected] 
[email protected] [email protected]
+arch/arm/src/common/stm32/stm32_oneshot.c [email protected] [email protected] 
[email protected] [email protected] [email protected]
 arch/arm/src/common/stm32/stm32_oneshot.h [email protected]
-arch/arm/src/common/stm32/stm32_oneshot_m3m4_v1.c [email protected] 
[email protected] [email protected] [email protected] [email protected]
-arch/arm/src/common/stm32/stm32_oneshot_m3m4_v1_lowerhalf.c [email protected] 
[email protected] [email protected] [email protected] 
[email protected]
+arch/arm/src/common/stm32/stm32_oneshot_lowerhalf.c [email protected] 
[email protected] [email protected] [email protected] 
[email protected]
 arch/arm/src/common/stm32/stm32_opamp.h [email protected] 
[email protected] [email protected] 
[email protected] [email protected]
 arch/arm/src/common/stm32/stm32_opamp_m3m4_v1.c [email protected] 
[email protected] [email protected] [email protected] 
[email protected]
 arch/arm/src/common/stm32/stm32_opamp_m3m4_v1.h [email protected] 
[email protected] [email protected] [email protected] 
[email protected]
@@ -4250,9 +4250,6 @@ arch/arm/src/stm32h7/stm32_ltdc.c [email protected] 
[email protected] liujp@
 arch/arm/src/stm32h7/stm32_ltdc.h [email protected] [email protected] 
[email protected]
 arch/arm/src/stm32h7/stm32_mpuinit.c [email protected] [email protected] 
[email protected] [email protected] [email protected]
 arch/arm/src/stm32h7/stm32_mpuinit.h [email protected] 
[email protected] [email protected] [email protected]
-arch/arm/src/stm32h7/stm32_oneshot.c [email protected] 
[email protected] [email protected] [email protected]
-arch/arm/src/stm32h7/stm32_oneshot.h [email protected] 
[email protected] [email protected] [email protected]
-arch/arm/src/stm32h7/stm32_oneshot_lowerhalf.c [email protected] 
[email protected] [email protected] [email protected]
 arch/arm/src/stm32h7/stm32_otg.h [email protected] [email protected] 
[email protected] [email protected] [email protected]
 arch/arm/src/stm32h7/stm32_otgdev.c [email protected] 
[email protected] [email protected] [email protected] 
[email protected]
 arch/arm/src/stm32h7/stm32_otghost.c [email protected] [email protected] 
[email protected] [email protected]
@@ -4433,9 +4430,6 @@ arch/arm/src/stm32l4/stm32l4_lptim.h 
[email protected] [email protected] x
 arch/arm/src/stm32l4/stm32l4_lse.c [email protected] 
[email protected] [email protected] [email protected]
 arch/arm/src/stm32l4/stm32l4_mpuinit.c [email protected] 
[email protected] [email protected] [email protected]
 arch/arm/src/stm32l4/stm32l4_mpuinit.h [email protected] 
[email protected]
-arch/arm/src/stm32l4/stm32l4_oneshot.c [email protected] [email protected] 
[email protected] [email protected]
-arch/arm/src/stm32l4/stm32l4_oneshot.h [email protected] 
[email protected] [email protected] [email protected]
-arch/arm/src/stm32l4/stm32l4_oneshot_lowerhalf.c [email protected] 
[email protected] [email protected]
 arch/arm/src/stm32l4/stm32l4_otgfs.h [email protected] 
[email protected] [email protected] [email protected]
 arch/arm/src/stm32l4/stm32l4_otgfsdev.c [email protected] 
[email protected] [email protected] [email protected]
 arch/arm/src/stm32l4/stm32l4_otgfshost.c [email protected] 
[email protected] [email protected] [email protected]
@@ -4645,9 +4639,6 @@ arch/arm/src/stm32wb/stm32wb_mbox_list.h 
[email protected] [email protected]
 arch/arm/src/stm32wb/stm32wb_mbox_shci.h [email protected] 
[email protected]
 arch/arm/src/stm32wb/stm32wb_mpuinit.c [email protected] 
[email protected] [email protected]
 arch/arm/src/stm32wb/stm32wb_mpuinit.h [email protected] 
[email protected]
-arch/arm/src/stm32wb/stm32wb_oneshot.c [email protected] 
[email protected] [email protected]
-arch/arm/src/stm32wb/stm32wb_oneshot.h [email protected] 
[email protected]
-arch/arm/src/stm32wb/stm32wb_oneshot_lowerhalf.c [email protected] 
[email protected]
 arch/arm/src/stm32wb/stm32wb_pm.h [email protected] [email protected]
 arch/arm/src/stm32wb/stm32wb_pminitialize.c [email protected] 
[email protected]
 arch/arm/src/stm32wb/stm32wb_pmlpr.c [email protected] [email protected]
diff --git a/arch/arm/src/common/stm32/CMakeLists.txt 
b/arch/arm/src/common/stm32/CMakeLists.txt
index 27a1d5d61c0..de3ee2d1239 100644
--- a/arch/arm/src/common/stm32/CMakeLists.txt
+++ b/arch/arm/src/common/stm32/CMakeLists.txt
@@ -77,6 +77,10 @@ if(CONFIG_STM32_FREERUN)
   list(APPEND SRCS stm32_freerun.c)
 endif()
 
+if(CONFIG_STM32_ONESHOT)
+  list(APPEND SRCS stm32_oneshot.c stm32_oneshot_lowerhalf.c)
+endif()
+
 if(CONFIG_STM32_PULSECOUNT)
   list(APPEND SRCS stm32_pulsecount.c)
 endif()
@@ -182,10 +186,6 @@ if(CONFIG_STM32_COMMON_LEGACY)
     endif()
   endif()
 
-  if(CONFIG_STM32_ONESHOT)
-    list(APPEND SRCS stm32_oneshot_m3m4_v1.c stm32_oneshot_m3m4_v1_lowerhalf.c)
-  endif()
-
 
   if(CONFIG_STM32_HAVE_IP_I2C_M3M4_V1)
     if(CONFIG_STM32_I2C_ALT)
diff --git a/arch/arm/src/common/stm32/Make.defs 
b/arch/arm/src/common/stm32/Make.defs
index 696a80cc4e4..4fc8e7853e4 100644
--- a/arch/arm/src/common/stm32/Make.defs
+++ b/arch/arm/src/common/stm32/Make.defs
@@ -87,6 +87,10 @@ endif
 ifeq ($(CONFIG_STM32_FREERUN),y)
 CHIP_CSRCS += stm32_freerun.c
 endif
+ifeq ($(CONFIG_STM32_ONESHOT),y)
+CHIP_CSRCS += stm32_oneshot.c
+CHIP_CSRCS += stm32_oneshot_lowerhalf.c
+endif
 
 ifeq ($(CONFIG_STM32_PULSECOUNT),y)
 CHIP_CSRCS += stm32_pulsecount.c
@@ -186,10 +190,6 @@ CHIP_CSRCS += stm32_dma_m3m4_v2_stream.c
 endif
 endif
 
-ifeq ($(CONFIG_STM32_ONESHOT),y)
-CHIP_CSRCS += stm32_oneshot_m3m4_v1.c
-CHIP_CSRCS += stm32_oneshot_m3m4_v1_lowerhalf.c
-endif
 
 
 ifeq ($(CONFIG_STM32_HAVE_IP_I2C_M3M4_V1),y)
diff --git a/arch/arm/src/common/stm32/stm32_oneshot_m3m4_v1.c 
b/arch/arm/src/common/stm32/stm32_oneshot.c
similarity index 99%
rename from arch/arm/src/common/stm32/stm32_oneshot_m3m4_v1.c
rename to arch/arm/src/common/stm32/stm32_oneshot.c
index e8ba155e9da..fa11cb6e246 100644
--- a/arch/arm/src/common/stm32/stm32_oneshot_m3m4_v1.c
+++ b/arch/arm/src/common/stm32/stm32_oneshot.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm/src/common/stm32/stm32_oneshot_m3m4_v1.c
+ * arch/arm/src/common/stm32/stm32_oneshot.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
diff --git a/arch/arm/src/stm32h7/stm32_oneshot_lowerhalf.c 
b/arch/arm/src/common/stm32/stm32_oneshot_lowerhalf.c
similarity index 99%
rename from arch/arm/src/stm32h7/stm32_oneshot_lowerhalf.c
rename to arch/arm/src/common/stm32/stm32_oneshot_lowerhalf.c
index edec93ec7ec..53d59fe8f55 100644
--- a/arch/arm/src/stm32h7/stm32_oneshot_lowerhalf.c
+++ b/arch/arm/src/common/stm32/stm32_oneshot_lowerhalf.c
@@ -1,5 +1,5 @@
 /****************************************************************************
- * arch/arm/src/stm32h7/stm32_oneshot_lowerhalf.c
+ * arch/arm/src/common/stm32/stm32_oneshot_lowerhalf.c
  *
  * SPDX-License-Identifier: Apache-2.0
  *
@@ -149,6 +149,7 @@ static int stm32_max_delay(struct oneshot_lowerhalf_s 
*lower,
   if (ret >= 0)
     {
       uint64_t sec = usecs / 1000000;
+
       usecs -= 1000000 * sec;
 
       ts->tv_sec  = sec;
diff --git a/arch/arm/src/common/stm32/stm32_oneshot_m3m4_v1_lowerhalf.c 
b/arch/arm/src/common/stm32/stm32_oneshot_m3m4_v1_lowerhalf.c
deleted file mode 100644
index 729adb4078c..00000000000
--- a/arch/arm/src/common/stm32/stm32_oneshot_m3m4_v1_lowerhalf.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/****************************************************************************
- * arch/arm/src/common/stm32/stm32_oneshot_m3m4_v1_lowerhalf.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <stdint.h>
-#include <time.h>
-#include <assert.h>
-
-#include <nuttx/debug.h>
-#include <nuttx/irq.h>
-#include <nuttx/kmalloc.h>
-#include <nuttx/timers/oneshot.h>
-
-#include "stm32_oneshot.h"
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/* This structure describes the state of the oneshot timer lower-half driver
- */
-
-struct stm32_oneshot_lowerhalf_s
-{
-  /* This is the part of the lower half driver that is visible to the upper-
-   * half client of the driver.  This must be the first thing in this
-   * structure so that pointers to struct oneshot_lowerhalf_s are cast
-   * compatible to struct stm32_oneshot_lowerhalf_s and vice versa.
-   */
-
-  struct oneshot_lowerhalf_s lh;  /* Common lower-half driver fields */
-
-  /* Private lower half data follows */
-
-  struct stm32_oneshot_s oneshot; /* STM32-specific oneshot state */
-};
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-static void stm32_oneshot_handler(void *arg);
-
-static int stm32_max_delay(struct oneshot_lowerhalf_s *lower,
-                           struct timespec *ts);
-static int stm32_start(struct oneshot_lowerhalf_s *lower,
-                       const struct timespec *ts);
-static int stm32_cancel(struct oneshot_lowerhalf_s *lower,
-                        struct timespec *ts);
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/* Lower half operations */
-
-static const struct oneshot_operations_s g_oneshot_ops =
-{
-  .max_delay = stm32_max_delay,
-  .start     = stm32_start,
-  .cancel    = stm32_cancel,
-};
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_handler
- *
- * Description:
- *   Timer expiration handler
- *
- * Input Parameters:
- *   arg - Should be the same argument provided when stm32_oneshot_start()
- *         was called.
- *
- * Returned Value:
- *   None
- *
- ****************************************************************************/
-
-static void stm32_oneshot_handler(void *arg)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)arg;
-
-  DEBUGASSERT(priv != NULL);
-
-  /* Perhaps the callback was nullified in a race condition with
-   * stm32_cancel?
-   */
-
-  oneshot_process_callback(&priv->lh);
-}
-
-/****************************************************************************
- * Name: stm32_max_delay
- *
- * Description:
- *   Determine the maximum delay of the one-shot timer (in microseconds)
- *
- * Input Parameters:
- *   lower   An instance of the lower-half oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           oneshot_initialize();
- *   ts      The location in which to return the maximum delay.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-static int stm32_max_delay(struct oneshot_lowerhalf_s *lower,
-                           struct timespec *ts)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)lower;
-  uint64_t usecs;
-  int ret;
-
-  DEBUGASSERT(priv != NULL && ts != NULL);
-  ret = stm32_oneshot_max_delay(&priv->oneshot, &usecs);
-  if (ret >= 0)
-    {
-      uint64_t sec = usecs / 1000000;
-      usecs -= 1000000 * sec;
-
-      ts->tv_sec  = sec;
-      ts->tv_nsec = usecs * 1000;
-    }
-
-  return ret;
-}
-
-/****************************************************************************
- * Name: stm32_start
- *
- * Description:
- *   Start the oneshot timer
- *
- * Input Parameters:
- *   lower   An instance of the lower-half oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           oneshot_initialize();
- *   handler The function to call when when the oneshot timer expires.
- *   arg     An opaque argument that will accompany the callback.
- *   ts      Provides the duration of the one shot timer.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-static int stm32_start(struct oneshot_lowerhalf_s *lower,
-                       const struct timespec *ts)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)lower;
-  irqstate_t flags;
-  int ret;
-
-  DEBUGASSERT(priv != NULL && ts != NULL);
-
-  /* Save the callback information and start the timer */
-
-  flags = enter_critical_section();
-  ret   = stm32_oneshot_start(&priv->oneshot,
-                              stm32_oneshot_handler, priv, ts);
-  leave_critical_section(flags);
-
-  if (ret < 0)
-    {
-      tmrerr("ERROR: stm32_oneshot_start failed: %d\n", flags);
-    }
-
-  return ret;
-}
-
-/****************************************************************************
- * Name: stm32_cancel
- *
- * Description:
- *   Cancel the oneshot timer and return the time remaining on the timer.
- *
- *   NOTE: This function may execute at a high rate with no timer running (as
- *   when pre-emption is enabled and disabled).
- *
- * Input Parameters:
- *   lower   Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           oneshot_initialize();
- *   ts      The location in which to return the time remaining on the
- *           oneshot timer.  A time of zero is returned if the timer is
- *           not running.
- *
- * Returned Value:
- *   Zero (OK) is returned on success.  A call to up_timer_cancel() when
- *   the timer is not active should also return success; a negated errno
- *   value is returned on any failure.
- *
- ****************************************************************************/
-
-static int stm32_cancel(struct oneshot_lowerhalf_s *lower,
-                        struct timespec *ts)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)lower;
-  irqstate_t flags;
-  int ret;
-
-  DEBUGASSERT(priv != NULL);
-
-  /* Cancel the timer */
-
-  flags = enter_critical_section();
-  ret   = stm32_oneshot_cancel(&priv->oneshot, ts);
-  leave_critical_section(flags);
-
-  if (ret < 0)
-    {
-      tmrerr("ERROR: stm32_oneshot_cancel failed: %d\n", flags);
-    }
-
-  return ret;
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: oneshot_initialize
- *
- * Description:
- *   Initialize the oneshot timer and return a oneshot lower half driver
- *   instance.
- *
- * Input Parameters:
- *   chan       Timer counter channel to be used.
- *   resolution The required resolution of the timer in units of
- *              microseconds.  NOTE that the range is restricted to the
- *              range of uint16_t (excluding zero).
- *
- * Returned Value:
- *   On success, a non-NULL instance of the oneshot lower-half driver is
- *   returned.  NULL is return on any failure.
- *
- ****************************************************************************/
-
-struct oneshot_lowerhalf_s *oneshot_initialize(int chan,
-                                               uint16_t resolution)
-{
-  struct stm32_oneshot_lowerhalf_s *priv;
-  int ret;
-
-  /* Allocate an instance of the lower half driver */
-
-  priv = (struct stm32_oneshot_lowerhalf_s *)
-    kmm_zalloc(sizeof(struct stm32_oneshot_lowerhalf_s));
-
-  if (priv == NULL)
-    {
-      tmrerr("ERROR: Failed to initialized state structure\n");
-      return NULL;
-    }
-
-  /* Initialize the lower-half driver structure */
-
-  priv->lh.ops = &g_oneshot_ops;
-
-  /* Initialize the contained STM32 oneshot timer */
-
-  ret = stm32_oneshot_initialize(&priv->oneshot, chan, resolution);
-  if (ret < 0)
-    {
-      tmrerr("ERROR: stm32_oneshot_initialize failed: %d\n", ret);
-      kmm_free(priv);
-      return NULL;
-    }
-
-  return &priv->lh;
-}
diff --git a/arch/arm/src/stm32h7/CMakeLists.txt 
b/arch/arm/src/stm32h7/CMakeLists.txt
index 7c91a950366..87de660cdd6 100644
--- a/arch/arm/src/stm32h7/CMakeLists.txt
+++ b/arch/arm/src/stm32h7/CMakeLists.txt
@@ -56,10 +56,6 @@ else()
   list(APPEND SRCS stm32_timerisr.c)
 endif()
 
-if(CONFIG_STM32_ONESHOT)
-  list(APPEND SRCS stm32_oneshot.c stm32_oneshot_lowerhalf.c)
-endif()
-
 if(CONFIG_ARM_MPU)
   list(APPEND SRCS stm32_mpuinit.c)
 endif()
diff --git a/arch/arm/src/stm32h7/Make.defs b/arch/arm/src/stm32h7/Make.defs
index 003f6d97372..5fdafa80928 100644
--- a/arch/arm/src/stm32h7/Make.defs
+++ b/arch/arm/src/stm32h7/Make.defs
@@ -55,10 +55,6 @@ else
 CHIP_CSRCS += stm32_timerisr.c
 endif
 
-ifeq ($(CONFIG_STM32_ONESHOT),y)
-CHIP_CSRCS += stm32_oneshot.c stm32_oneshot_lowerhalf.c
-endif
-
 ifeq ($(CONFIG_ARM_MPU),y)
 CHIP_CSRCS += stm32_mpuinit.c
 endif
diff --git a/arch/arm/src/stm32h7/stm32_oneshot.c 
b/arch/arm/src/stm32h7/stm32_oneshot.c
deleted file mode 100644
index e1fc56718ec..00000000000
--- a/arch/arm/src/stm32h7/stm32_oneshot.c
+++ /dev/null
@@ -1,404 +0,0 @@
-/****************************************************************************
- * arch/arm/src/stm32h7/stm32_oneshot.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <sys/types.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <sched.h>
-#include <assert.h>
-#include <errno.h>
-
-#include <nuttx/debug.h>
-#include <nuttx/irq.h>
-#include <nuttx/clock.h>
-
-#include "stm32_oneshot.h"
-
-#ifdef CONFIG_STM32_ONESHOT
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-static int stm32_oneshot_handler(int irg_num, void * context, void *arg);
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-static struct stm32_oneshot_s *g_oneshot[CONFIG_STM32_ONESHOT_MAXTIMERS];
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_handler
- *
- * Description:
- *   Common timer interrupt callback.  When any oneshot timer interrupt
- *   expires, this function will be called.  It will forward the call to
- *   the next level up.
- *
- * Input Parameters:
- *   oneshot - The state associated with the expired timer
- *
- * Returned Value:
- *   Always returns OK
- *
- ****************************************************************************/
-
-static int stm32_oneshot_handler(int irg_num, void * context, void *arg)
-{
-  struct stm32_oneshot_s * oneshot = (struct stm32_oneshot_s *) arg;
-  oneshot_handler_t oneshot_handler;
-  void *oneshot_arg;
-
-  tmrinfo("Expired (Interrupt)...\n");
-  DEBUGASSERT(oneshot != NULL && oneshot->handler);
-
-  /* The clock was stopped, but not disabled when the RC match occurred.
-   * Disable the TC now and disable any further interrupts.
-   */
-
-  STM32_TIM_SETISR(oneshot->tch, NULL, NULL, 0);
-  STM32_TIM_DISABLEINT(oneshot->tch, GTIM_DIER_UIE);
-  STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED);
-  STM32_TIM_ACKINT(oneshot->tch, GTIM_SR_UIF);
-
-  /* The timer is no longer running */
-
-  oneshot->running = false;
-
-  /* Forward the event, clearing out any vestiges */
-
-  oneshot_handler  = (oneshot_handler_t)oneshot->handler;
-  oneshot->handler = NULL;
-  oneshot_arg      = (void *)oneshot->arg;
-  oneshot->arg     = NULL;
-
-  oneshot_handler(oneshot_arg);
-  return OK;
-}
-
-/****************************************************************************
- * Name: stm32_allocate_handler
- *
- * Description:
- *   Allocate a timer callback handler for the oneshot instance.
- *
- * Input Parameters:
- *   oneshot - The state instance the new oneshot timer
- *
- * Returned Value:
- *   Returns zero (OK) on success.  This can only fail if the number of
- *   timers exceeds CONFIG_STM32_ONESHOT_MAXTIMERS.
- *
- ****************************************************************************/
-
-static inline int stm32_allocate_handler(struct stm32_oneshot_s *oneshot)
-{
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
-  int ret = -EBUSY;
-  int i;
-
-  /* Search for an unused handler */
-
-  for (i = 0; i < CONFIG_STM32_ONESHOT_MAXTIMERS; i++)
-    {
-      /* Is this handler available? */
-
-      if (g_oneshot[i] == NULL)
-        {
-          /* Yes... assign it to this oneshot */
-
-          g_oneshot[i]   = oneshot;
-          oneshot->cbndx = i;
-          ret            = OK;
-          break;
-        }
-    }
-
-  return ret;
-
-#else
-  if (g_oneshot[0] == NULL)
-    {
-      g_oneshot[0] = oneshot;
-      return OK;
-    }
-
-  return -EBUSY;
-#endif
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_initialize
- *
- * Description:
- *   Initialize the oneshot timer wrapper
- *
- * Input Parameters:
- *   oneshot    Caller allocated instance of the oneshot state structure
- *   chan       Timer counter channel to be used.
- *   resolution The required resolution of the timer in units of
- *              microseconds.  NOTE that the range is restricted to the
- *              range of uint16_t (excluding zero).
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_initialize(struct stm32_oneshot_s *oneshot, int chan,
-                             uint16_t resolution)
-{
-  uint32_t frequency;
-
-  tmrinfo("chan=%d resolution=%u usec, USEC_PER_SEC:%ld\n", chan, resolution,
-          USEC_PER_SEC);
-  DEBUGASSERT(oneshot && resolution > 0);
-
-  /* Get the TC frequency the corresponds to the requested resolution */
-
-  frequency = USEC_PER_SEC / (uint32_t)resolution;
-  tmrinfo("frequency: %" PRIu32 "\n", frequency);
-  oneshot->frequency = frequency;
-
-  oneshot->tch = stm32_tim_init(chan);
-  if (!oneshot->tch)
-    {
-      tmrerr("ERROR: Failed to allocate TIM%d\n", chan);
-      return -EBUSY;
-    }
-
-  STM32_TIM_SETCLOCK(oneshot->tch, frequency);
-
-  /* Initialize the remaining fields in the state structure. */
-
-  oneshot->chan       = chan;
-  oneshot->running    = false;
-  oneshot->handler    = NULL;
-  oneshot->arg        = NULL;
-
-  /* Assign a callback handler to the oneshot */
-
-  return stm32_allocate_handler(oneshot);
-}
-
-/****************************************************************************
- * Name: stm32_oneshot_max_delay
- *
- * Description:
- *   Determine the maximum delay of the one-shot timer (in microseconds)
- *
- ****************************************************************************/
-
-int stm32_oneshot_max_delay(struct stm32_oneshot_s *oneshot, uint64_t *usec)
-{
-  DEBUGASSERT(oneshot != NULL && usec != NULL);
-
-  tmrinfo("frequency: %" PRIu32 ", USEC_PER_SEC: %ld\n", oneshot->frequency,
-          USEC_PER_SEC);
-  *usec = (uint64_t)(UINT32_MAX / oneshot->frequency) *
-          (uint64_t)USEC_PER_SEC;
-  return OK;
-}
-
-/****************************************************************************
- * Name: stm32_oneshot_start
- *
- * Description:
- *   Start the oneshot timer
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   handler The function to call when when the oneshot timer expires.
- *   arg     An opaque argument that will accompany the callback.
- *   ts      Provides the duration of the one shot timer.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
-                        oneshot_handler_t handler, void *arg,
-                        const struct timespec *ts)
-{
-  uint64_t usec;
-  uint64_t period;
-  irqstate_t flags;
-
-  tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n", handler, arg,
-          (intmax_t)ts->tv_sec, ts->tv_nsec);
-  DEBUGASSERT(oneshot && handler && ts);
-  DEBUGASSERT(oneshot->tch);
-
-  /* Was the oneshot already running? */
-
-  flags = enter_critical_section();
-  if (oneshot->running)
-    {
-      /* Yes.. then cancel it */
-
-      tmrinfo("Already running... cancelling\n");
-      stm32_oneshot_cancel(oneshot, NULL);
-    }
-
-  /* Save the new handler and its argument */
-
-  oneshot->handler = handler;
-  oneshot->arg     = arg;
-
-  /* Express the delay in microseconds */
-
-  usec = ts->tv_sec * USEC_PER_SEC +
-         (ts->tv_nsec / NSEC_PER_USEC);
-
-  /* Get the timer counter frequency and determine the number of counts need
-   * to achieve the requested delay.
-   *
-   *   frequency = ticks / second
-   *   ticks     = seconds * frequency
-   *             = (usecs * frequency) / USEC_PER_SEC;
-   */
-
-  period = (usec * (uint64_t)oneshot->frequency) / USEC_PER_SEC;
-
-  tmrinfo("usec=%llu period=%08llx\n", usec, period);
-  DEBUGASSERT(period <= UINT32_MAX);
-
-  /* Set up to receive the callback when the interrupt occurs */
-
-  STM32_TIM_SETISR(oneshot->tch, stm32_oneshot_handler, oneshot, 0);
-
-  /* Set timer period */
-
-  oneshot->period = (uint32_t)period;
-  STM32_TIM_SETPERIOD(oneshot->tch, (uint32_t)period);
-
-  /* Start the counter */
-
-  STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_PULSE);
-
-  STM32_TIM_ACKINT(oneshot->tch, GTIM_SR_UIF);
-  STM32_TIM_ENABLEINT(oneshot->tch, GTIM_DIER_UIE);
-
-  /* Enable interrupts.  We should get the callback when the interrupt
-   * occurs.
-   */
-
-  oneshot->running = true;
-  leave_critical_section(flags);
-  return OK;
-}
-
-/****************************************************************************
- * Name: stm32_oneshot_cancel
- *
- * Description:
- *   Cancel the oneshot timer and return the time remaining on the timer.
- *
- *   NOTE: This function may execute at a high rate with no timer running (as
- *   when pre-emption is enabled and disabled).
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   ts      The location in which to return the time remaining on the
- *           oneshot timer.  A time of zero is returned if the timer is
- *           not running.  ts may be zero in which case the time remaining
- *           is not returned.
- *
- * Returned Value:
- *   Zero (OK) is returned on success.  A call to up_timer_cancel() when
- *   the timer is not active should also return success; a negated errno
- *   value is returned on any failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
-                         struct timespec *ts)
-{
-  irqstate_t flags;
-
-  /* Was the timer running? */
-
-  flags = enter_critical_section();
-  if (!oneshot->running)
-    {
-      /* No.. Just return zero timer remaining and successful cancellation.
-       * This function may execute at a high rate with no timer running
-       * (as when pre-emption is enabled and disabled).
-       */
-
-      ts->tv_sec  = 0;
-      ts->tv_nsec = 0;
-      leave_critical_section(flags);
-      return OK;
-    }
-
-  tmrinfo("Cancelling...\n");
-
-  /* Now we can disable the interrupt and stop the timer. */
-
-  STM32_TIM_DISABLEINT(oneshot->tch, GTIM_DIER_UIE);
-  STM32_TIM_SETISR(oneshot->tch, NULL, NULL, 0);
-  STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED);
-
-  oneshot->running = false;
-  oneshot->handler = NULL;
-  oneshot->arg     = NULL;
-  leave_critical_section(flags);
-
-  /* Did the caller provide us with a location to return the time
-   * remaining?
-   */
-
-  if (ts)
-    {
-      /* Not implemented */
-
-      ts->tv_sec  = 0;
-      ts->tv_nsec = 0;
-    }
-
-  return OK;
-}
-
-#endif /* CONFIG_STM32_ONESHOT */
diff --git a/arch/arm/src/stm32h7/stm32_oneshot.h 
b/arch/arm/src/stm32h7/stm32_oneshot.h
deleted file mode 100644
index f16523985ff..00000000000
--- a/arch/arm/src/stm32h7/stm32_oneshot.h
+++ /dev/null
@@ -1,197 +0,0 @@
-/****************************************************************************
- * arch/arm/src/stm32h7/stm32_oneshot.h
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- *
- ****************************************************************************/
-
-#ifndef __ARCH_ARM_SRC_STM32H7_STM32_ONESHOT_H
-#define __ARCH_ARM_SRC_STM32H7_STM32_ONESHOT_H
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <stdint.h>
-#include <time.h>
-
-#include <nuttx/irq.h>
-
-#include "stm32_tim.h"
-
-#ifdef CONFIG_STM32_ONESHOT
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#if !defined(CONFIG_STM32_ONESHOT_MAXTIMERS) || \
-    CONFIG_STM32_ONESHOT_MAXTIMERS < 1
-#  undef CONFIG_STM32_ONESHOT_MAXTIMERS
-#  define CONFIG_STM32_ONESHOT_MAXTIMERS 1
-#endif
-
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 8
-#  warning Additional logic required to handle more than 8 timers
-#  undef CONFIG_STM32_ONESHOT_MAXTIMERS
-#  define CONFIG_STM32_ONESHOT_MAXTIMERS 8
-#endif
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-/* This describes the callback function that will be invoked when the oneshot
- * timer expires.  The oneshot fires, the client will receive:
- *
- *   arg - The opaque argument provided when the interrupt was registered
- */
-
-typedef void (*oneshot_handler_t)(void *arg);
-
-/* The oneshot client must allocate an instance of this structure and called
- * stm32_oneshot_initialize() before using the oneshot facilities. The client
- * should not access the contents of this structure directly since the
- * contents are subject to change.
- */
-
-struct stm32_oneshot_s
-{
-  uint8_t chan;                       /* The timer/counter in use */
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
-  uint8_t cbndx;                      /* Timer callback handler index */
-#endif
-  volatile bool running;              /* True: the timer is running */
-  struct stm32_tim_dev_s *tch;        /* Pointer returned by
-                                       * stm32_tim_init() */
-  volatile oneshot_handler_t handler; /* Oneshot expiration callback */
-  volatile void *arg;                 /* The argument that will accompany
-                                       * the callback */
-  uint32_t frequency;
-  uint32_t period;
-};
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-#undef EXTERN
-#if defined(__cplusplus)
-#define EXTERN extern "C"
-extern "C"
-{
-#else
-#define EXTERN extern
-#endif
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_initialize
- *
- * Description:
- *   Initialize the oneshot timer wrapper
- *
- * Input Parameters:
- *   oneshot    Caller allocated instance of the oneshot state structure
- *   chan       Timer counter channel to be used.
- *   resolution The required resolution of the timer in units of
- *              microseconds.  NOTE that the range is restricted to the
- *              range of uint16_t (excluding zero).
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_initialize(struct stm32_oneshot_s *oneshot, int chan,
-                             uint16_t resolution);
-
-/****************************************************************************
- * Name: stm32_oneshot_max_delay
- *
- * Description:
- *   Determine the maximum delay of the one-shot timer (in microseconds)
- *
- ****************************************************************************/
-
-int stm32_oneshot_max_delay(struct stm32_oneshot_s *oneshot, uint64_t *usec);
-
-/****************************************************************************
- * Name: stm32_oneshot_start
- *
- * Description:
- *   Start the oneshot timer
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   handler The function to call when when the oneshot timer expires.
- *   arg     An opaque argument that will accompany the callback.
- *   ts      Provides the duration of the one shot timer.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
-                        oneshot_handler_t handler, void *arg,
-                        const struct timespec *ts);
-
-/****************************************************************************
- * Name: stm32_oneshot_cancel
- *
- * Description:
- *   Cancel the oneshot timer and return the time remaining on the timer.
- *
- *   NOTE: This function may execute at a high rate with no timer running (as
- *   when pre-emption is enabled and disabled).
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   ts      The location in which to return the time remaining on the
- *           oneshot timer.  A time of zero is returned if the timer is
- *           not running.
- *
- * Returned Value:
- *   Zero (OK) is returned on success.  A call to up_timer_cancel() when
- *   the timer is not active should also return success; a negated errno
- *   value is returned on any failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
-                         struct timespec *ts);
-
-#undef EXTERN
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CONFIG_STM32_ONESHOT */
-#endif /* __ARCH_ARM_SRC_STM32H7_STM32_ONESHOT_H */
diff --git a/arch/arm/src/stm32l4/CMakeLists.txt 
b/arch/arm/src/stm32l4/CMakeLists.txt
index aa0f20571c1..b72127024ed 100644
--- a/arch/arm/src/stm32l4/CMakeLists.txt
+++ b/arch/arm/src/stm32l4/CMakeLists.txt
@@ -50,10 +50,6 @@ else()
   list(APPEND SRCS stm32l4_tickless.c)
 endif()
 
-if(CONFIG_STM32_ONESHOT)
-  list(APPEND SRCS stm32l4_oneshot.c stm32l4_oneshot_lowerhalf.c)
-endif()
-
 if(CONFIG_BUILD_PROTECTED)
   list(APPEND SRCS stm32l4_userspace.c stm32l4_mpuinit.c)
 endif()
diff --git a/arch/arm/src/stm32l4/Make.defs b/arch/arm/src/stm32l4/Make.defs
index d4d7bed93cb..739983f9d5a 100644
--- a/arch/arm/src/stm32l4/Make.defs
+++ b/arch/arm/src/stm32l4/Make.defs
@@ -47,10 +47,6 @@ else
 CHIP_CSRCS += stm32l4_tickless.c
 endif
 
-ifeq ($(CONFIG_STM32_ONESHOT),y)
-CHIP_CSRCS += stm32l4_oneshot.c stm32l4_oneshot_lowerhalf.c
-endif
-
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CHIP_CSRCS += stm32l4_userspace.c stm32l4_mpuinit.c
 endif
diff --git a/arch/arm/src/stm32l4/stm32l4_oneshot.c 
b/arch/arm/src/stm32l4/stm32l4_oneshot.c
deleted file mode 100644
index 2b6186c1b04..00000000000
--- a/arch/arm/src/stm32l4/stm32l4_oneshot.c
+++ /dev/null
@@ -1,460 +0,0 @@
-/****************************************************************************
- * arch/arm/src/stm32l4/stm32l4_oneshot.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <sys/types.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <sched.h>
-#include <assert.h>
-#include <errno.h>
-
-#include <nuttx/debug.h>
-#include <nuttx/irq.h>
-#include <nuttx/clock.h>
-
-#include "stm32l4_oneshot.h"
-
-#ifdef CONFIG_STM32_ONESHOT
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-static int stm32_oneshot_handler(int irq, void *context, void *arg);
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-static struct stm32_oneshot_s *g_oneshot[CONFIG_STM32_ONESHOT_MAXTIMERS];
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_handler
- *
- * Description:
- *   Common timer interrupt callback.  When any oneshot timer interrupt
- *   expires, this function will be called.  It will forward the call to
- *   the next level up.
- *
- * Input Parameters:
- *   oneshot - The state associated with the expired timer
- *
- * Returned Value:
- *   Always returns OK
- *
- ****************************************************************************/
-
-static int stm32_oneshot_handler(int irq, void *context, void *arg)
-{
-  struct stm32_oneshot_s *oneshot = (struct stm32_oneshot_s *) arg;
-  oneshot_handler_t oneshot_handler;
-  void *oneshot_arg;
-
-  tmrinfo("Expired...\n");
-  DEBUGASSERT(oneshot != NULL && oneshot->handler);
-
-  /* The clock was stopped, but not disabled when the RC match occurred.
-   * Disable the TC now and disable any further interrupts.
-   */
-
-  STM32_TIM_SETISR(oneshot->tch, NULL, NULL, 0);
-  STM32_TIM_DISABLEINT(oneshot->tch, GTIM_DIER_UIE);
-  STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED);
-  STM32_TIM_ACKINT(oneshot->tch, GTIM_SR_UIF);
-
-  /* The timer is no longer running */
-
-  oneshot->running = false;
-
-  /* Forward the event, clearing out any vestiges */
-
-  oneshot_handler  = (oneshot_handler_t)oneshot->handler;
-  oneshot->handler = NULL;
-  oneshot_arg      = (void *)oneshot->arg;
-  oneshot->arg     = NULL;
-
-  oneshot_handler(oneshot_arg);
-  return OK;
-}
-
-/****************************************************************************
- * Name: stm32_allocate_handler
- *
- * Description:
- *   Allocate a timer callback handler for the oneshot instance.
- *
- * Input Parameters:
- *   oneshot - The state instance the new oneshot timer
- *
- * Returned Value:
- *   Returns zero (OK) on success.  This can only fail if the number of
- *   timers exceeds CONFIG_STM32_ONESHOT_MAXTIMERS.
- *
- ****************************************************************************/
-
-static inline int stm32_allocate_handler(struct stm32_oneshot_s *oneshot)
-{
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
-  int ret = -EBUSY;
-  int i;
-
-  /* Search for an unused handler */
-
-  for (i = 0; i < CONFIG_STM32_ONESHOT_MAXTIMERS; i++)
-    {
-      /* Is this handler available? */
-
-      if (g_oneshot[i] == NULL)
-        {
-          /* Yes... assign it to this oneshot */
-
-          g_oneshot[i]   = oneshot;
-          oneshot->cbndx = i;
-          ret            = OK;
-          break;
-        }
-    }
-
-  return ret;
-
-#else
-  if (g_oneshot[0] == NULL)
-    {
-      g_oneshot[0] = oneshot;
-      return OK;
-    }
-
-  return -EBUSY;
-#endif
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_initialize
- *
- * Description:
- *   Initialize the oneshot timer wrapper
- *
- * Input Parameters:
- *   oneshot    Caller allocated instance of the oneshot state structure
- *   chan       Timer counter channel to be used.
- *   resolution The required resolution of the timer in units of
- *              microseconds.  NOTE that the range is restricted to the
- *              range of uint16_t (excluding zero).
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_initialize(struct stm32_oneshot_s *oneshot,
-                               int chan, uint16_t resolution)
-{
-  uint32_t frequency;
-
-  tmrinfo("chan=%d resolution=%d usec\n", chan, resolution);
-  DEBUGASSERT(oneshot && resolution > 0);
-
-  /* Get the TC frequency the corresponds to the requested resolution */
-
-  frequency = USEC_PER_SEC / (uint32_t)resolution;
-  oneshot->frequency = frequency;
-
-  oneshot->tch = stm32_tim_init(chan);
-  if (!oneshot->tch)
-    {
-      tmrerr("ERROR: Failed to allocate TIM%d\n", chan);
-      return -EBUSY;
-    }
-
-  STM32_TIM_SETCLOCK(oneshot->tch, frequency);
-
-  /* Initialize the remaining fields in the state structure. */
-
-  oneshot->chan       = chan;
-  oneshot->running    = false;
-  oneshot->handler    = NULL;
-  oneshot->arg        = NULL;
-
-  /* Assign a callback handler to the oneshot */
-
-  return stm32_allocate_handler(oneshot);
-}
-
-/****************************************************************************
- * Name: stm32_oneshot_max_delay
- *
- * Description:
- *   Determine the maximum delay of the one-shot timer (in microseconds)
- *
- ****************************************************************************/
-
-int stm32_oneshot_max_delay(struct stm32_oneshot_s *oneshot,
-                              uint64_t *usec)
-{
-  DEBUGASSERT(oneshot != NULL && usec != NULL);
-
-  *usec = (uint64_t)(UINT32_MAX / oneshot->frequency) *
-          (uint64_t)USEC_PER_SEC;
-  return OK;
-}
-
-/****************************************************************************
- * Name: stm32_oneshot_start
- *
- * Description:
- *   Start the oneshot timer
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   handler The function to call when when the oneshot timer expires.
- *   arg     An opaque argument that will accompany the callback.
- *   ts      Provides the duration of the one shot timer.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
-                          oneshot_handler_t handler, void *arg,
-                          const struct timespec *ts)
-{
-  uint64_t usec;
-  uint64_t period;
-  irqstate_t flags;
-
-  tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
-         handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
-  DEBUGASSERT(oneshot && handler && ts);
-  DEBUGASSERT(oneshot->tch);
-
-  /* Was the oneshot already running? */
-
-  flags = enter_critical_section();
-  if (oneshot->running)
-    {
-      /* Yes.. then cancel it */
-
-      tmrinfo("Already running... cancelling\n");
-      stm32_oneshot_cancel(oneshot, NULL);
-    }
-
-  /* Save the new handler and its argument */
-
-  oneshot->handler = handler;
-  oneshot->arg     = arg;
-
-  /* Express the delay in microseconds */
-
-  usec = ts->tv_sec * USEC_PER_SEC +
-         (ts->tv_nsec / NSEC_PER_USEC);
-
-  /* Get the timer counter frequency and determine the number of counts need
-   * to achieve the requested delay.
-   *
-   *   frequency = ticks / second
-   *   ticks     = seconds * frequency
-   *             = (usecs * frequency) / USEC_PER_SEC;
-   */
-
-  period = (usec * (uint64_t)oneshot->frequency) / USEC_PER_SEC;
-
-  tmrinfo("usec=%llu period=%08llx\n", usec, period);
-  DEBUGASSERT(period > 0);
-  DEBUGASSERT(period <= UINT32_MAX);
-
-  /* Set up to receive the callback when the interrupt occurs */
-
-  STM32_TIM_SETISR(oneshot->tch, stm32_oneshot_handler, oneshot, 0);
-
-  /* Set timer period */
-
-  oneshot->period = (uint32_t)period;
-  STM32_TIM_SETPERIOD(oneshot->tch, (uint32_t)period);
-
-  /* Start the counter */
-
-  STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_PULSE);
-
-  STM32_TIM_ACKINT(oneshot->tch, GTIM_SR_UIF);
-  STM32_TIM_ENABLEINT(oneshot->tch, GTIM_DIER_UIE);
-
-  /* Enable interrupts.  We should get the callback when the interrupt
-   * occurs.
-   */
-
-  oneshot->running = true;
-  leave_critical_section(flags);
-  return OK;
-}
-
-/****************************************************************************
- * Name: stm32_oneshot_cancel
- *
- * Description:
- *   Cancel the oneshot timer and return the time remaining on the timer.
- *
- *   NOTE: This function may execute at a high rate with no timer running (as
- *   when pre-emption is enabled and disabled).
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   ts      The location in which to return the time remaining on the
- *           oneshot timer.  A time of zero is returned if the timer is
- *           not running.  ts may be zero in which case the time remaining
- *           is not returned.
- *
- * Returned Value:
- *   Zero (OK) is returned on success.  A call to up_timer_cancel() when
- *   the timer is not active should also return success; a negated errno
- *   value is returned on any failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
-                           struct timespec *ts)
-{
-  irqstate_t flags;
-  uint64_t usec;
-  uint64_t sec;
-  uint64_t nsec;
-  uint32_t count;
-  uint32_t period;
-
-  /* Was the timer running? */
-
-  flags = enter_critical_section();
-  if (!oneshot->running)
-    {
-      /* No.. Just return zero timer remaining and successful cancellation.
-       * This function may execute at a high rate with no timer running
-       * (as when pre-emption is enabled and disabled).
-       */
-
-      ts->tv_sec  = 0;
-      ts->tv_nsec = 0;
-      leave_critical_section(flags);
-      return OK;
-    }
-
-  /* Yes.. Get the timer counter and period registers and stop the counter.
-   * If the counter expires while we are doing this, the counter clock will
-   * be stopped, but the clock will not be disabled.
-   *
-   * The expected behavior is that the counter register will freezes at
-   * a value equal to the RC register when the timer expires.  The counter
-   * should have values between 0 and RC in all other cased.
-   *
-   * REVISIT:  This does not appear to be the case.
-   */
-
-  tmrinfo("Cancelling...\n");
-
-  count  = STM32_TIM_GETCOUNTER(oneshot->tch);
-  period = oneshot->period;
-
-  /* Now we can disable the interrupt and stop the timer. */
-
-  STM32_TIM_DISABLEINT(oneshot->tch, GTIM_DIER_UIE);
-  STM32_TIM_SETISR(oneshot->tch, NULL, NULL, 0);
-  STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED);
-
-  oneshot->running = false;
-  oneshot->handler = NULL;
-  oneshot->arg     = NULL;
-  leave_critical_section(flags);
-
-  /* Did the caller provide us with a location to return the time
-   * remaining?
-   */
-
-  if (ts)
-    {
-      /* Yes.. then calculate and return the time remaining on the
-       * oneshot timer.
-       */
-
-      tmrinfo("period=%lu count=%lu\n",
-             (unsigned long)period, (unsigned long)count);
-
-      /* REVISIT: I am not certain why the timer counter value sometimes
-       * exceeds RC.  Might be a bug, or perhaps the counter does not stop
-       * in all cases.
-       */
-
-      if (count >= period)
-        {
-          /* No time remaining (?) */
-
-          ts->tv_sec  = 0;
-          ts->tv_nsec = 0;
-        }
-      else
-        {
-          /* The total time remaining is the difference.  Convert that
-           * to units of microseconds.
-           *
-           *   frequency = ticks / second
-           *   seconds   = ticks * frequency
-           *   usecs     = (ticks * USEC_PER_SEC) / frequency;
-           */
-
-          usec        = (((uint64_t)(period - count)) * USEC_PER_SEC) /
-                        oneshot->frequency;
-
-          /* Return the time remaining in the correct form */
-
-          sec         = usec / USEC_PER_SEC;
-          nsec        = ((usec) - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
-
-          ts->tv_sec  = sec;
-          ts->tv_nsec = nsec;
-        }
-
-      tmrinfo("remaining (%jd, %ld)\n",
-              (intmax_t)ts->tv_sec, ts->tv_nsec);
-    }
-
-  return OK;
-}
-
-#endif /* CONFIG_STM32_ONESHOT */
diff --git a/arch/arm/src/stm32l4/stm32l4_oneshot.h 
b/arch/arm/src/stm32l4/stm32l4_oneshot.h
deleted file mode 100644
index 6fc35b5e7a7..00000000000
--- a/arch/arm/src/stm32l4/stm32l4_oneshot.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
- * arch/arm/src/stm32l4/stm32l4_oneshot.h
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- *
- ****************************************************************************/
-
-#ifndef __ARCH_ARM_SRC_STM32L4_STM32L4_ONESHOT_H
-#define __ARCH_ARM_SRC_STM32L4_STM32L4_ONESHOT_H
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <stdint.h>
-#include <time.h>
-
-#include <nuttx/irq.h>
-
-#include "stm32_tim.h"
-
-#ifdef CONFIG_STM32_ONESHOT
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#if !defined(CONFIG_STM32_ONESHOT_MAXTIMERS) || \
-    CONFIG_STM32_ONESHOT_MAXTIMERS < 1
-#  undef CONFIG_STM32_ONESHOT_MAXTIMERS
-#  define CONFIG_STM32_ONESHOT_MAXTIMERS 1
-#endif
-
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 8
-#  warning Additional logic required to handle more than 8 timers
-#  undef CONFIG_STM32_ONESHOT_MAXTIMERS
-#  define CONFIG_STM32_ONESHOT_MAXTIMERS 8
-#endif
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-/* This describes the callback function that will be invoked when the oneshot
- * timer expires.  The oneshot fires, the client will receive:
- *
- *   arg - The opaque argument provided when the interrupt was registered
- */
-
-typedef void (*oneshot_handler_t)(void *arg);
-
-/* The oneshot client must allocate an instance of this structure and called
- * stm32_oneshot_initialize() before using the oneshot facilities.  The
- * client should not access the contents of this structure directly since
- * the contents are subject to change.
- */
-
-struct stm32_oneshot_s
-{
-  uint8_t chan;                       /* The timer/counter in use */
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
-  uint8_t cbndx;                      /* Timer callback handler index */
-#endif
-  volatile bool running;              /* True: the timer is running */
-  struct stm32_tim_dev_s *tch;        /* Pointer returned by
-                                       * stm32_tim_init() */
-  volatile oneshot_handler_t handler; /* Oneshot expiration callback */
-  volatile void *arg;                 /* The argument that will accompany
-                                       * the callback */
-  uint32_t frequency;
-  uint32_t period;
-};
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-#undef EXTERN
-#if defined(__cplusplus)
-#define EXTERN extern "C"
-extern "C"
-{
-#else
-#define EXTERN extern
-#endif
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_initialize
- *
- * Description:
- *   Initialize the oneshot timer wrapper
- *
- * Input Parameters:
- *   oneshot    Caller allocated instance of the oneshot state structure
- *   chan       Timer counter channel to be used.
- *   resolution The required resolution of the timer in units of
- *              microseconds.  NOTE that the range is restricted to the
- *              range of uint16_t (excluding zero).
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_initialize(struct stm32_oneshot_s *oneshot, int chan,
-                               uint16_t resolution);
-
-/****************************************************************************
- * Name: stm32_oneshot_max_delay
- *
- * Description:
- *   Determine the maximum delay of the one-shot timer (in microseconds)
- *
- ****************************************************************************/
-
-int stm32_oneshot_max_delay(struct stm32_oneshot_s *oneshot,
-                              uint64_t *usec);
-
-/****************************************************************************
- * Name: stm32_oneshot_start
- *
- * Description:
- *   Start the oneshot timer
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   handler The function to call when when the oneshot timer expires.
- *   arg     An opaque argument that will accompany the callback.
- *   ts      Provides the duration of the one shot timer.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
-                          oneshot_handler_t handler, void *arg,
-                          const struct timespec *ts);
-
-/****************************************************************************
- * Name: stm32_oneshot_cancel
- *
- * Description:
- *   Cancel the oneshot timer and return the time remaining on the timer.
- *
- *   NOTE: This function may execute at a high rate with no timer running (as
- *   when pre-emption is enabled and disabled).
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   ts      The location in which to return the time remaining on the
- *           oneshot timer.  A time of zero is returned if the timer is
- *           not running.
- *
- * Returned Value:
- *   Zero (OK) is returned on success.  A call to up_timer_cancel() when
- *   the timer is not active should also return success; a negated errno
- *   value is returned on any failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
-                           struct timespec *ts);
-
-#undef EXTERN
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CONFIG_STM32_ONESHOT */
-#endif /* __ARCH_ARM_SRC_STM32L4_STM32L4_ONESHOT_H */
diff --git a/arch/arm/src/stm32l4/stm32l4_oneshot_lowerhalf.c 
b/arch/arm/src/stm32l4/stm32l4_oneshot_lowerhalf.c
deleted file mode 100644
index 12474e60807..00000000000
--- a/arch/arm/src/stm32l4/stm32l4_oneshot_lowerhalf.c
+++ /dev/null
@@ -1,310 +0,0 @@
-/****************************************************************************
- * arch/arm/src/stm32l4/stm32l4_oneshot_lowerhalf.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <stdint.h>
-#include <time.h>
-#include <assert.h>
-
-#include <nuttx/debug.h>
-#include <nuttx/irq.h>
-#include <nuttx/kmalloc.h>
-#include <nuttx/timers/oneshot.h>
-
-#include "stm32l4_oneshot.h"
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/* This structure describes the state of the oneshot timer lower-half
- * driver
- */
-
-struct stm32_oneshot_lowerhalf_s
-{
-  /* This is the part of the lower half driver that is visible to the upper-
-   * half client of the driver.  This must be the first thing in this
-   * structure so that pointers to struct oneshot_lowerhalf_s are cast
-   * compatible to struct stm32_oneshot_lowerhalf_s and vice versa.
-   */
-
-  struct oneshot_lowerhalf_s lh;    /* Common lower-half driver fields */
-
-  /* Private lower half data follows */
-
-  struct stm32_oneshot_s oneshot; /* STM32-specific oneshot state */
-};
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-static void stm32_oneshot_handler(void *arg);
-
-static int stm32_max_delay(struct oneshot_lowerhalf_s *lower,
-                             struct timespec *ts);
-static int stm32_start(struct oneshot_lowerhalf_s *lower,
-                         const struct timespec *ts);
-static int stm32_cancel(struct oneshot_lowerhalf_s *lower,
-                          struct timespec *ts);
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/* Lower half operations */
-
-static const struct oneshot_operations_s g_oneshot_ops =
-{
-  .max_delay = stm32_max_delay,
-  .start     = stm32_start,
-  .cancel    = stm32_cancel,
-};
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_handler
- *
- * Description:
- *   Timer expiration handler
- *
- * Input Parameters:
- *   arg - Should be the same argument provided when stm32_oneshot_start()
- *         was called.
- *
- * Returned Value:
- *   None
- *
- ****************************************************************************/
-
-static void stm32_oneshot_handler(void *arg)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)arg;
-
-  DEBUGASSERT(priv != NULL);
-
-  /* Perhaps the callback was nullified in a race condition with
-   * stm32_cancel?
-   */
-
-  oneshot_process_callback(&priv->lh);
-}
-
-/****************************************************************************
- * Name: stm32_max_delay
- *
- * Description:
- *   Determine the maximum delay of the one-shot timer (in microseconds)
- *
- * Input Parameters:
- *   lower   An instance of the lower-half oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           oneshot_initialize();
- *   ts      The location in which to return the maximum delay.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-static int stm32_max_delay(struct oneshot_lowerhalf_s *lower,
-                             struct timespec *ts)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)lower;
-  uint64_t usecs;
-  int ret;
-
-  DEBUGASSERT(priv != NULL && ts != NULL);
-  ret = stm32_oneshot_max_delay(&priv->oneshot, &usecs);
-  if (ret >= 0)
-    {
-      uint64_t sec = usecs / 1000000;
-      usecs -= 1000000 * sec;
-
-      ts->tv_sec  = sec;
-      ts->tv_nsec = usecs * 1000;
-    }
-
-  return ret;
-}
-
-/****************************************************************************
- * Name: stm32_start
- *
- * Description:
- *   Start the oneshot timer
- *
- * Input Parameters:
- *   lower   An instance of the lower-half oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           oneshot_initialize();
- *   handler The function to call when when the oneshot timer expires.
- *   arg     An opaque argument that will accompany the callback.
- *   ts      Provides the duration of the one shot timer.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-static int stm32_start(struct oneshot_lowerhalf_s *lower,
-                         const struct timespec *ts)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)lower;
-  irqstate_t flags;
-  int ret;
-
-  DEBUGASSERT(priv != NULL && ts != NULL);
-
-  /* Save the callback information and start the timer */
-
-  flags = enter_critical_section();
-  ret   = stm32_oneshot_start(&priv->oneshot,
-                                stm32_oneshot_handler, priv, ts);
-  leave_critical_section(flags);
-
-  if (ret < 0)
-    {
-      tmrerr("ERROR: stm32_oneshot_start failed: %d\n", flags);
-    }
-
-  return ret;
-}
-
-/****************************************************************************
- * Name: stm32_cancel
- *
- * Description:
- *   Cancel the oneshot timer and return the time remaining on the timer.
- *
- *   NOTE: This function may execute at a high rate with no timer running (as
- *   when pre-emption is enabled and disabled).
- *
- * Input Parameters:
- *   lower   Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           oneshot_initialize();
- *   ts      The location in which to return the time remaining on the
- *           oneshot timer.  A time of zero is returned if the timer is
- *           not running.
- *
- * Returned Value:
- *   Zero (OK) is returned on success.  A call to up_timer_cancel() when
- *   the timer is not active should also return success; a negated errno
- *   value is returned on any failure.
- *
- ****************************************************************************/
-
-static int stm32_cancel(struct oneshot_lowerhalf_s *lower,
-                          struct timespec *ts)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)lower;
-  irqstate_t flags;
-  int ret;
-
-  DEBUGASSERT(priv != NULL);
-
-  /* Cancel the timer */
-
-  flags = enter_critical_section();
-  ret   = stm32_oneshot_cancel(&priv->oneshot, ts);
-  leave_critical_section(flags);
-
-  if (ret < 0)
-    {
-      tmrerr("ERROR: stm32_oneshot_cancel failed: %d\n", flags);
-    }
-
-  return ret;
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: oneshot_initialize
- *
- * Description:
- *   Initialize the oneshot timer and return a oneshot lower half driver
- *   instance.
- *
- * Input Parameters:
- *   chan       Timer counter channel to be used.
- *   resolution The required resolution of the timer in units of
- *              microseconds.  NOTE that the range is restricted to the
- *              range of uint16_t (excluding zero).
- *
- * Returned Value:
- *   On success, a non-NULL instance of the oneshot lower-half driver is
- *   returned.  NULL is return on any failure.
- *
- ****************************************************************************/
-
-struct oneshot_lowerhalf_s *oneshot_initialize(int chan,
-                                               uint16_t resolution)
-{
-  struct stm32_oneshot_lowerhalf_s *priv;
-  int ret;
-
-  /* Allocate an instance of the lower half driver */
-
-  priv = (struct stm32_oneshot_lowerhalf_s *)
-    kmm_zalloc(sizeof(struct stm32_oneshot_lowerhalf_s));
-
-  if (priv == NULL)
-    {
-      tmrerr("ERROR: Failed to initialized state structure\n");
-      return NULL;
-    }
-
-  /* Initialize the lower-half driver structure */
-
-  priv->lh.ops = &g_oneshot_ops;
-
-  /* Initialize the contained STM32 oneshot timer */
-
-  ret = stm32_oneshot_initialize(&priv->oneshot, chan, resolution);
-  if (ret < 0)
-    {
-      tmrerr("ERROR: stm32_oneshot_initialize failed: %d\n", ret);
-      kmm_free(priv);
-      return NULL;
-    }
-
-  return &priv->lh;
-}
diff --git a/arch/arm/src/stm32l4/stm32l4_tickless.c 
b/arch/arm/src/stm32l4/stm32l4_tickless.c
index d89d00a753d..a10568f7107 100644
--- a/arch/arm/src/stm32l4/stm32l4_tickless.c
+++ b/arch/arm/src/stm32l4/stm32l4_tickless.c
@@ -78,7 +78,7 @@
 #include <assert.h>
 #include <nuttx/debug.h>
 
-#include "stm32l4_oneshot.h"
+#include "stm32_oneshot.h"
 #include "stm32_freerun.h"
 
 #ifdef CONFIG_SCHED_TICKLESS
diff --git a/arch/arm/src/stm32wb/CMakeLists.txt 
b/arch/arm/src/stm32wb/CMakeLists.txt
index 51e1fa267f7..37e7e6b2317 100644
--- a/arch/arm/src/stm32wb/CMakeLists.txt
+++ b/arch/arm/src/stm32wb/CMakeLists.txt
@@ -47,10 +47,6 @@ else()
   list(APPEND SRCS stm32wb_tickless.c)
 endif()
 
-if(CONFIG_STM32_ONESHOT)
-  list(APPEND SRCS stm32wb_oneshot.c stm32wb_oneshot_lowerhalf.c)
-endif()
-
 if(CONFIG_BUILD_PROTECTED)
   list(APPEND SRCS stm32wb_userspace.c stm32wb_mpuinit.c)
 endif()
diff --git a/arch/arm/src/stm32wb/Make.defs b/arch/arm/src/stm32wb/Make.defs
index 369d25f058d..e57486001ad 100644
--- a/arch/arm/src/stm32wb/Make.defs
+++ b/arch/arm/src/stm32wb/Make.defs
@@ -47,10 +47,6 @@ else
 CHIP_CSRCS += stm32wb_tickless.c
 endif
 
-ifeq ($(CONFIG_STM32_ONESHOT),y)
-CHIP_CSRCS += stm32wb_oneshot.c stm32wb_oneshot_lowerhalf.c
-endif
-
 ifeq ($(CONFIG_BUILD_PROTECTED),y)
 CHIP_CSRCS += stm32wb_userspace.c stm32wb_mpuinit.c
 endif
diff --git a/arch/arm/src/stm32wb/stm32wb_oneshot.c 
b/arch/arm/src/stm32wb/stm32wb_oneshot.c
deleted file mode 100644
index 80e63c4b4e9..00000000000
--- a/arch/arm/src/stm32wb/stm32wb_oneshot.c
+++ /dev/null
@@ -1,459 +0,0 @@
-/****************************************************************************
- * arch/arm/src/stm32wb/stm32wb_oneshot.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <sys/types.h>
-#include <stdint.h>
-#include <stdbool.h>
-#include <sched.h>
-#include <assert.h>
-#include <errno.h>
-
-#include <nuttx/debug.h>
-#include <nuttx/irq.h>
-#include <nuttx/clock.h>
-
-#include "stm32wb_oneshot.h"
-
-#ifdef CONFIG_STM32_ONESHOT
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-static int stm32_oneshot_handler(int irq, void *context, void *arg);
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-static struct stm32_oneshot_s *g_oneshot[CONFIG_STM32_ONESHOT_MAXTIMERS];
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_handler
- *
- * Description:
- *   Common timer interrupt callback.  When any oneshot timer interrupt
- *   expires, this function will be called.  It will forward the call to
- *   the next level up.
- *
- * Input Parameters:
- *   oneshot - The state associated with the expired timer
- *
- * Returned Value:
- *   Always returns OK
- *
- ****************************************************************************/
-
-static int stm32_oneshot_handler(int irq, void *context, void *arg)
-{
-  struct stm32_oneshot_s *oneshot = (struct stm32_oneshot_s *)arg;
-  oneshot_handler_t oneshot_handler;
-  void *oneshot_arg;
-
-  tmrinfo("Expired...\n");
-  DEBUGASSERT(oneshot != NULL && oneshot->handler);
-
-  /* The clock was stopped, but not disabled when the RC match occurred.
-   * Disable the TC now and disable any further interrupts.
-   */
-
-  STM32_TIM_SETISR(oneshot->tch, NULL, NULL, 0);
-  STM32_TIM_DISABLEINT(oneshot->tch, GTIM_DIER_UIE);
-  STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED);
-  STM32_TIM_ACKINT(oneshot->tch, GTIM_SR_UIF);
-
-  /* The timer is no longer running */
-
-  oneshot->running = false;
-
-  /* Forward the event, clearing out any vestiges */
-
-  oneshot_handler  = (oneshot_handler_t)oneshot->handler;
-  oneshot->handler = NULL;
-  oneshot_arg      = (void *)oneshot->arg;
-  oneshot->arg     = NULL;
-
-  oneshot_handler(oneshot_arg);
-  return OK;
-}
-
-/****************************************************************************
- * Name: stm32_allocate_handler
- *
- * Description:
- *   Allocate a timer callback handler for the oneshot instance.
- *
- * Input Parameters:
- *   oneshot - The state instance the new oneshot timer
- *
- * Returned Value:
- *   Returns zero (OK) on success.  This can only fail if the number of
- *   timers exceeds CONFIG_STM32_ONESHOT_MAXTIMERS.
- *
- ****************************************************************************/
-
-static inline int stm32_allocate_handler(struct stm32_oneshot_s *oneshot)
-{
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
-  int ret = -EBUSY;
-  int i;
-
-  /* Search for an unused handler */
-
-  for (i = 0; i < CONFIG_STM32_ONESHOT_MAXTIMERS; i++)
-    {
-      /* Is this handler available? */
-
-      if (g_oneshot[i] == NULL)
-        {
-          /* Yes... assign it to this oneshot */
-
-          g_oneshot[i]   = oneshot;
-          oneshot->cbndx = i;
-          ret            = OK;
-          break;
-        }
-    }
-
-  return ret;
-
-#else
-  if (g_oneshot[0] == NULL)
-    {
-      g_oneshot[0] = oneshot;
-      return OK;
-    }
-
-  return -EBUSY;
-#endif
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_initialize
- *
- * Description:
- *   Initialize the oneshot timer wrapper
- *
- * Input Parameters:
- *   oneshot    Caller allocated instance of the oneshot state structure
- *   chan       Timer counter channel to be used.
- *   resolution The required resolution of the timer in units of
- *              microseconds.  NOTE that the range is restricted to the
- *              range of uint16_t (excluding zero).
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_initialize(struct stm32_oneshot_s *oneshot,
-                               int chan, uint16_t resolution)
-{
-  uint32_t frequency;
-
-  tmrinfo("chan=%d resolution=%d usec\n", chan, resolution);
-  DEBUGASSERT(oneshot && resolution > 0);
-
-  /* Get the TC frequency the corresponds to the requested resolution */
-
-  frequency = USEC_PER_SEC / (uint32_t)resolution;
-  oneshot->frequency = frequency;
-
-  oneshot->tch = stm32_tim_init(chan);
-  if (!oneshot->tch)
-    {
-      tmrerr("ERROR: Failed to allocate TIM%d\n", chan);
-      return -EBUSY;
-    }
-
-  STM32_TIM_SETCLOCK(oneshot->tch, frequency);
-
-  /* Initialize the remaining fields in the state structure. */
-
-  oneshot->chan       = chan;
-  oneshot->running    = false;
-  oneshot->handler    = NULL;
-  oneshot->arg        = NULL;
-
-  /* Assign a callback handler to the oneshot */
-
-  return stm32_allocate_handler(oneshot);
-}
-
-/****************************************************************************
- * Name: stm32_oneshot_max_delay
- *
- * Description:
- *   Determine the maximum delay of the one-shot timer (in microseconds)
- *
- ****************************************************************************/
-
-int stm32_oneshot_max_delay(struct stm32_oneshot_s *oneshot,
-                              uint64_t *usec)
-{
-  DEBUGASSERT(oneshot != NULL && usec != NULL);
-
-  *usec = (uint64_t)(UINT32_MAX / oneshot->frequency) *
-          (uint64_t)USEC_PER_SEC;
-  return OK;
-}
-
-/****************************************************************************
- * Name: stm32_oneshot_start
- *
- * Description:
- *   Start the oneshot timer
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   handler The function to call when when the oneshot timer expires.
- *   arg     An opaque argument that will accompany the callback.
- *   ts      Provides the duration of the one shot timer.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
-                          oneshot_handler_t handler, void *arg,
-                          const struct timespec *ts)
-{
-  uint64_t usec;
-  uint64_t period;
-  irqstate_t flags;
-
-  tmrinfo("handler=%p arg=%p, ts=(%jd, %ld)\n",
-          handler, arg, (intmax_t)ts->tv_sec, ts->tv_nsec);
-  DEBUGASSERT(oneshot && handler && ts);
-  DEBUGASSERT(oneshot->tch);
-
-  /* Was the oneshot already running? */
-
-  flags = enter_critical_section();
-  if (oneshot->running)
-    {
-      /* Yes.. then cancel it */
-
-      tmrinfo("Already running... cancelling\n");
-      stm32_oneshot_cancel(oneshot, NULL);
-    }
-
-  /* Save the new handler and its argument */
-
-  oneshot->handler = handler;
-  oneshot->arg     = arg;
-
-  /* Express the delay in microseconds */
-
-  usec = ts->tv_sec * USEC_PER_SEC +
-         (ts->tv_nsec / NSEC_PER_USEC);
-
-  /* Get the timer counter frequency and determine the number of counts need
-   * to achieve the requested delay.
-   *
-   *   frequency = ticks / second
-   *   ticks     = seconds * frequency
-   *             = (usecs * frequency) / USEC_PER_SEC;
-   */
-
-  period = (usec * (uint64_t)oneshot->frequency) / USEC_PER_SEC;
-
-  tmrinfo("usec=%llu period=%08llx\n", usec, period);
-  DEBUGASSERT(period > 0 && period <= UINT32_MAX);
-
-  /* Set up to receive the callback when the interrupt occurs */
-
-  STM32_TIM_SETISR(oneshot->tch, stm32_oneshot_handler, oneshot, 0);
-
-  /* Set timer period */
-
-  oneshot->period = (uint32_t)period;
-  STM32_TIM_SETPERIOD(oneshot->tch, (uint32_t)period);
-
-  /* Start the counter */
-
-  STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_PULSE);
-
-  STM32_TIM_ACKINT(oneshot->tch, GTIM_SR_UIF);
-  STM32_TIM_ENABLEINT(oneshot->tch, GTIM_DIER_UIE);
-
-  /* Enable interrupts.  We should get the callback when the interrupt
-   * occurs.
-   */
-
-  oneshot->running = true;
-  leave_critical_section(flags);
-  return OK;
-}
-
-/****************************************************************************
- * Name: stm32_oneshot_cancel
- *
- * Description:
- *   Cancel the oneshot timer and return the time remaining on the timer.
- *
- *   NOTE: This function may execute at a high rate with no timer running (as
- *   when pre-emption is enabled and disabled).
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   ts      The location in which to return the time remaining on the
- *           oneshot timer.  A time of zero is returned if the timer is
- *           not running.  ts may be zero in which case the time remaining
- *           is not returned.
- *
- * Returned Value:
- *   Zero (OK) is returned on success.  A call to up_timer_cancel() when
- *   the timer is not active should also return success; a negated errno
- *   value is returned on any failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
-                           struct timespec *ts)
-{
-  irqstate_t flags;
-  uint64_t usec;
-  uint64_t sec;
-  uint64_t nsec;
-  uint32_t count;
-  uint32_t period;
-
-  /* Was the timer running? */
-
-  flags = enter_critical_section();
-  if (!oneshot->running)
-    {
-      /* No.. Just return zero timer remaining and successful cancellation.
-       * This function may execute at a high rate with no timer running
-       * (as when pre-emption is enabled and disabled).
-       */
-
-      ts->tv_sec  = 0;
-      ts->tv_nsec = 0;
-      leave_critical_section(flags);
-      return OK;
-    }
-
-  /* Yes.. Get the timer counter and period registers and stop the counter.
-   * If the counter expires while we are doing this, the counter clock will
-   * be stopped, but the clock will not be disabled.
-   *
-   * The expected behavior is that the counter register will freezes at
-   * a value equal to the RC register when the timer expires.  The counter
-   * should have values between 0 and RC in all other cased.
-   *
-   * REVISIT:  This does not appear to be the case.
-   */
-
-  tmrinfo("Cancelling...\n");
-
-  count  = STM32_TIM_GETCOUNTER(oneshot->tch);
-  period = oneshot->period;
-
-  /* Now we can disable the interrupt and stop the timer. */
-
-  STM32_TIM_DISABLEINT(oneshot->tch, GTIM_DIER_UIE);
-  STM32_TIM_SETISR(oneshot->tch, NULL, NULL, 0);
-  STM32_TIM_SETMODE(oneshot->tch, STM32_TIM_MODE_DISABLED);
-
-  oneshot->running = false;
-  oneshot->handler = NULL;
-  oneshot->arg     = NULL;
-  leave_critical_section(flags);
-
-  /* Did the caller provide us with a location to return the time
-   * remaining?
-   */
-
-  if (ts)
-    {
-      /* Yes.. then calculate and return the time remaining on the
-       * oneshot timer.
-       */
-
-      tmrinfo("period=%lu count=%lu\n",
-              (unsigned long)period, (unsigned long)count);
-
-      /* REVISIT: I am not certain why the timer counter value sometimes
-       * exceeds RC.  Might be a bug, or perhaps the counter does not stop
-       * in all cases.
-       */
-
-      if (count >= period)
-        {
-          /* No time remaining (?) */
-
-          ts->tv_sec  = 0;
-          ts->tv_nsec = 0;
-        }
-      else
-        {
-          /* The total time remaining is the difference.  Convert that
-           * to units of microseconds.
-           *
-           *   frequency = ticks / second
-           *   seconds   = ticks * frequency
-           *   usecs     = (ticks * USEC_PER_SEC) / frequency;
-           */
-
-          usec        = (((uint64_t)(period - count)) * USEC_PER_SEC) /
-                        oneshot->frequency;
-
-          /* Return the time remaining in the correct form */
-
-          sec         = usec / USEC_PER_SEC;
-          nsec        = (usec - (sec * USEC_PER_SEC)) * NSEC_PER_USEC;
-
-          ts->tv_sec  = sec;
-          ts->tv_nsec = nsec;
-        }
-
-      tmrinfo("remaining (%jd, %ld)\n",
-              (intmax_t)ts->tv_sec, ts->tv_nsec);
-    }
-
-  return OK;
-}
-
-#endif /* CONFIG_STM32_ONESHOT */
diff --git a/arch/arm/src/stm32wb/stm32wb_oneshot.h 
b/arch/arm/src/stm32wb/stm32wb_oneshot.h
deleted file mode 100644
index 1b427a11695..00000000000
--- a/arch/arm/src/stm32wb/stm32wb_oneshot.h
+++ /dev/null
@@ -1,198 +0,0 @@
-/****************************************************************************
- * arch/arm/src/stm32wb/stm32wb_oneshot.h
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- *
- ****************************************************************************/
-
-#ifndef __ARCH_ARM_SRC_STM32WB_STM32WB_ONESHOT_H
-#define __ARCH_ARM_SRC_STM32WB_STM32WB_ONESHOT_H
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <stdint.h>
-#include <time.h>
-
-#include <nuttx/irq.h>
-
-#include "stm32_tim.h"
-
-#ifdef CONFIG_STM32_ONESHOT
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-#if !defined(CONFIG_STM32_ONESHOT_MAXTIMERS) || \
-    CONFIG_STM32_ONESHOT_MAXTIMERS < 1
-#  undef CONFIG_STM32_ONESHOT_MAXTIMERS
-#  define CONFIG_STM32_ONESHOT_MAXTIMERS 1
-#endif
-
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 8
-#  warning Additional logic required to handle more than 8 timers
-#  undef CONFIG_STM32_ONESHOT_MAXTIMERS
-#  define CONFIG_STM32_ONESHOT_MAXTIMERS 8
-#endif
-
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-/* This describes the callback function that will be invoked when the oneshot
- * timer expires.  The oneshot fires, the client will receive:
- *
- *   arg - The opaque argument provided when the interrupt was registered
- */
-
-typedef void (*oneshot_handler_t)(void *arg);
-
-/* The oneshot client must allocate an instance of this structure and called
- * stm32_oneshot_initialize() before using the oneshot facilities.  The
- * client should not access the contents of this structure directly since
- * the contents are subject to change.
- */
-
-struct stm32_oneshot_s
-{
-  uint8_t chan;                       /* The timer/counter in use */
-#if CONFIG_STM32_ONESHOT_MAXTIMERS > 1
-  uint8_t cbndx;                      /* Timer callback handler index */
-#endif
-  volatile bool running;              /* True: the timer is running */
-  struct stm32_tim_dev_s *tch;        /* Pointer returned by
-                                       * stm32_tim_init() */
-  volatile oneshot_handler_t handler; /* Oneshot expiration callback */
-  volatile void *arg;                 /* The argument that will accompany
-                                       * the callback */
-  uint32_t frequency;
-  uint32_t period;
-};
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-#undef EXTERN
-#if defined(__cplusplus)
-#define EXTERN extern "C"
-extern "C"
-{
-#else
-#define EXTERN extern
-#endif
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_initialize
- *
- * Description:
- *   Initialize the oneshot timer wrapper
- *
- * Input Parameters:
- *   oneshot    Caller allocated instance of the oneshot state structure
- *   chan       Timer counter channel to be used.
- *   resolution The required resolution of the timer in units of
- *              microseconds.  NOTE that the range is restricted to the
- *              range of uint16_t (excluding zero).
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_initialize(struct stm32_oneshot_s *oneshot, int chan,
-                               uint16_t resolution);
-
-/****************************************************************************
- * Name: stm32_oneshot_max_delay
- *
- * Description:
- *   Determine the maximum delay of the one-shot timer (in microseconds)
- *
- ****************************************************************************/
-
-int stm32_oneshot_max_delay(struct stm32_oneshot_s *oneshot,
-                              uint64_t *usec);
-
-/****************************************************************************
- * Name: stm32_oneshot_start
- *
- * Description:
- *   Start the oneshot timer
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   handler The function to call when when the oneshot timer expires.
- *   arg     An opaque argument that will accompany the callback.
- *   ts      Provides the duration of the one shot timer.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_start(struct stm32_oneshot_s *oneshot,
-                          oneshot_handler_t handler, void *arg,
-                          const struct timespec *ts);
-
-/****************************************************************************
- * Name: stm32_oneshot_cancel
- *
- * Description:
- *   Cancel the oneshot timer and return the time remaining on the timer.
- *
- *   NOTE: This function may execute at a high rate with no timer running (as
- *   when pre-emption is enabled and disabled).
- *
- * Input Parameters:
- *   oneshot Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           stm32_oneshot_initialize();
- *   ts      The location in which to return the time remaining on the
- *           oneshot timer.  A time of zero is returned if the timer is
- *           not running.
- *
- * Returned Value:
- *   Zero (OK) is returned on success.  A call to up_timer_cancel() when
- *   the timer is not active should also return success; a negated errno
- *   value is returned on any failure.
- *
- ****************************************************************************/
-
-int stm32_oneshot_cancel(struct stm32_oneshot_s *oneshot,
-                           struct timespec *ts);
-
-#undef EXTERN
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* CONFIG_STM32_ONESHOT */
-#endif /* __ARCH_ARM_SRC_STM32WB_STM32WB_ONESHOT_H */
diff --git a/arch/arm/src/stm32wb/stm32wb_oneshot_lowerhalf.c 
b/arch/arm/src/stm32wb/stm32wb_oneshot_lowerhalf.c
deleted file mode 100644
index d98270362c4..00000000000
--- a/arch/arm/src/stm32wb/stm32wb_oneshot_lowerhalf.c
+++ /dev/null
@@ -1,309 +0,0 @@
-/****************************************************************************
- * arch/arm/src/stm32wb/stm32wb_oneshot_lowerhalf.c
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * 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.
- *
- ****************************************************************************/
-
-/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-#include <nuttx/config.h>
-
-#include <stdint.h>
-#include <time.h>
-#include <assert.h>
-
-#include <nuttx/debug.h>
-#include <nuttx/irq.h>
-#include <nuttx/kmalloc.h>
-#include <nuttx/timers/oneshot.h>
-
-#include "stm32wb_oneshot.h"
-
-/****************************************************************************
- * Private Types
- ****************************************************************************/
-
-/* This structure describes the state of the oneshot timer lower-half
- * driver
- */
-
-struct stm32_oneshot_lowerhalf_s
-{
-  /* This is the part of the lower half driver that is visible to the upper-
-   * half client of the driver.  This must be the first thing in this
-   * structure so that pointers to struct oneshot_lowerhalf_s are cast
-   * compatible to struct stm32_oneshot_lowerhalf_s and vice versa.
-   */
-
-  struct oneshot_lowerhalf_s lh;  /* Common lower-half driver fields */
-
-  /* Private lower half data follows */
-
-  struct stm32_oneshot_s oneshot; /* STM32-specific oneshot state */
-};
-
-/****************************************************************************
- * Private Function Prototypes
- ****************************************************************************/
-
-static void stm32_oneshot_handler(void *arg);
-
-static int stm32_max_delay(struct oneshot_lowerhalf_s *lower,
-                             struct timespec *ts);
-static int stm32_start(struct oneshot_lowerhalf_s *lower,
-                         const struct timespec *ts);
-static int stm32_cancel(struct oneshot_lowerhalf_s *lower,
-                          struct timespec *ts);
-
-/****************************************************************************
- * Private Data
- ****************************************************************************/
-
-/* Lower half operations */
-
-static const struct oneshot_operations_s g_oneshot_ops =
-{
-  .max_delay = stm32_max_delay,
-  .start     = stm32_start,
-  .cancel    = stm32_cancel,
-};
-
-/****************************************************************************
- * Private Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: stm32_oneshot_handler
- *
- * Description:
- *   Timer expiration handler
- *
- * Input Parameters:
- *   arg - Should be the same argument provided when stm32_oneshot_start()
- *         was called.
- *
- * Returned Value:
- *   None
- *
- ****************************************************************************/
-
-static void stm32_oneshot_handler(void *arg)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)arg;
-
-  DEBUGASSERT(priv != NULL);
-
-  /* Perhaps the callback was nullified in a race condition with
-   * stm32_cancel?
-   */
-
-  oneshot_process_callback(&priv->lh);
-}
-
-/****************************************************************************
- * Name: stm32_max_delay
- *
- * Description:
- *   Determine the maximum delay of the one-shot timer (in microseconds)
- *
- * Input Parameters:
- *   lower   An instance of the lower-half oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           oneshot_initialize();
- *   ts      The location in which to return the maximum delay.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-static int stm32_max_delay(struct oneshot_lowerhalf_s *lower,
-                             struct timespec *ts)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)lower;
-  uint64_t usecs;
-  int ret;
-
-  DEBUGASSERT(priv != NULL && ts != NULL);
-  ret = stm32_oneshot_max_delay(&priv->oneshot, &usecs);
-  if (ret >= 0)
-    {
-      uint64_t sec = usecs / 1000000;
-      usecs -= 1000000 * sec;
-
-      ts->tv_sec  = sec;
-      ts->tv_nsec = usecs * 1000;
-    }
-
-  return ret;
-}
-
-/****************************************************************************
- * Name: stm32_start
- *
- * Description:
- *   Start the oneshot timer
- *
- * Input Parameters:
- *   lower   An instance of the lower-half oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           oneshot_initialize();
- *   handler The function to call when when the oneshot timer expires.
- *   arg     An opaque argument that will accompany the callback.
- *   ts      Provides the duration of the one shot timer.
- *
- * Returned Value:
- *   Zero (OK) is returned on success; a negated errno value is returned
- *   on failure.
- *
- ****************************************************************************/
-
-static int stm32_start(struct oneshot_lowerhalf_s *lower,
-                         const struct timespec *ts)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)lower;
-  irqstate_t flags;
-  int ret;
-
-  DEBUGASSERT(priv != NULL && ts != NULL);
-
-  /* Save the callback information and start the timer */
-
-  flags = enter_critical_section();
-  ret   = stm32_oneshot_start(&priv->oneshot,
-                                stm32_oneshot_handler, priv, ts);
-  leave_critical_section(flags);
-
-  if (ret < 0)
-    {
-      tmrerr("ERROR: stm32_oneshot_start failed: %d\n", flags);
-    }
-
-  return ret;
-}
-
-/****************************************************************************
- * Name: stm32_cancel
- *
- * Description:
- *   Cancel the oneshot timer and return the time remaining on the timer.
- *
- *   NOTE: This function may execute at a high rate with no timer running (as
- *   when pre-emption is enabled and disabled).
- *
- * Input Parameters:
- *   lower   Caller allocated instance of the oneshot state structure.  This
- *           structure must have been previously initialized via a call to
- *           oneshot_initialize();
- *   ts      The location in which to return the time remaining on the
- *           oneshot timer.  A time of zero is returned if the timer is
- *           not running.
- *
- * Returned Value:
- *   Zero (OK) is returned on success.  A call to up_timer_cancel() when
- *   the timer is not active should also return success; a negated errno
- *   value is returned on any failure.
- *
- ****************************************************************************/
-
-static int stm32_cancel(struct oneshot_lowerhalf_s *lower,
-                          struct timespec *ts)
-{
-  struct stm32_oneshot_lowerhalf_s *priv =
-    (struct stm32_oneshot_lowerhalf_s *)lower;
-  irqstate_t flags;
-  int ret;
-
-  DEBUGASSERT(priv != NULL);
-
-  /* Cancel the timer */
-
-  flags = enter_critical_section();
-  ret   = stm32_oneshot_cancel(&priv->oneshot, ts);
-  leave_critical_section(flags);
-
-  if (ret < 0)
-    {
-      tmrerr("ERROR: stm32_oneshot_cancel failed: %d\n", flags);
-    }
-
-  return ret;
-}
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: oneshot_initialize
- *
- * Description:
- *   Initialize the oneshot timer and return a oneshot lower half driver
- *   instance.
- *
- * Input Parameters:
- *   chan       Timer counter channel to be used.
- *   resolution The required resolution of the timer in units of
- *              microseconds.  NOTE that the range is restricted to the
- *              range of uint16_t (excluding zero).
- *
- * Returned Value:
- *   On success, a non-NULL instance of the oneshot lower-half driver is
- *   returned.  NULL is return on any failure.
- *
- ****************************************************************************/
-
-struct oneshot_lowerhalf_s *oneshot_initialize(int chan, uint16_t resolution)
-{
-  struct stm32_oneshot_lowerhalf_s *priv;
-  int ret;
-
-  /* Allocate an instance of the lower half driver */
-
-  priv = (struct stm32_oneshot_lowerhalf_s *)
-    kmm_zalloc(sizeof(struct stm32_oneshot_lowerhalf_s));
-
-  if (priv == NULL)
-    {
-      tmrerr("ERROR: Failed to initialized state structure\n");
-      return NULL;
-    }
-
-  /* Initialize the lower-half driver structure */
-
-  priv->lh.ops = &g_oneshot_ops;
-
-  /* Initialize the contained STM32 oneshot timer */
-
-  ret = stm32_oneshot_initialize(&priv->oneshot, chan, resolution);
-  if (ret < 0)
-    {
-      tmrerr("ERROR: stm32_oneshot_initialize failed: %d\n", ret);
-      kmm_free(priv);
-      return NULL;
-    }
-
-  return &priv->lh;
-}

Reply via email to