You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/07/20 16:11:19 UTC

[incubator-nuttx] branch master updated (5ce8469 -> ba44a81)

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

aguettouche pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 5ce8469  tools/mksyscall: Fix warning: '__builtin_strncpy' specified bound 256 equals destination size
     new 4152193  arch/arm/src/nrf52: add support for TIMER lowerhalf
     new 8fe3a46  boards/arm/nrf52/nrf52840-dk: add timer example
     new ba44a81  fix nxstyle warnings

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/arm/src/nrf52/Make.defs                       |   3 +
 arch/arm/src/nrf52/nrf52_tim_lowerhalf.c           | 538 +++++++++++++++++++++
 .../sam_uid.h => nrf52/nrf52_tim_lowerhalf.h}      |  20 +-
 .../nrf52840-dk/configs/{nsh => timer}/defconfig   |   6 +
 boards/arm/nrf52/nrf52840-dk/src/Makefile          |   4 +
 boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h     |  23 +-
 boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c   |  18 +
 .../arm/nrf52/nrf52840-dk/src/nrf52_timer.c        |  33 +-
 8 files changed, 611 insertions(+), 34 deletions(-)
 create mode 100644 arch/arm/src/nrf52/nrf52_tim_lowerhalf.c
 copy arch/arm/src/{samv7/sam_uid.h => nrf52/nrf52_tim_lowerhalf.h} (80%)
 copy boards/arm/nrf52/nrf52840-dk/configs/{nsh => timer}/defconfig (91%)
 copy libs/libc/errno/lib_errno.c => boards/arm/nrf52/nrf52840-dk/src/nrf52_timer.c (72%)


[incubator-nuttx] 02/03: boards/arm/nrf52/nrf52840-dk: add timer example

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 8fe3a46dc0593dc9723e773d69ca5ed83ddc14bb
Author: raiden00pl <ra...@railab.me>
AuthorDate: Mon Jul 20 11:12:09 2020 +0200

    boards/arm/nrf52/nrf52840-dk: add timer example
---
 .../arm/nrf52/nrf52840-dk/configs/timer/defconfig  | 55 ++++++++++++++++++++
 boards/arm/nrf52/nrf52840-dk/src/Makefile          |  4 ++
 boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h     | 13 +++++
 boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c   | 18 +++++++
 boards/arm/nrf52/nrf52840-dk/src/nrf52_timer.c     | 58 ++++++++++++++++++++++
 5 files changed, 148 insertions(+)

diff --git a/boards/arm/nrf52/nrf52840-dk/configs/timer/defconfig b/boards/arm/nrf52/nrf52840-dk/configs/timer/defconfig
new file mode 100644
index 0000000..f9566ef
--- /dev/null
+++ b/boards/arm/nrf52/nrf52840-dk/configs/timer/defconfig
@@ -0,0 +1,55 @@
+#
+# This file is autogenerated: PLEASE DO NOT EDIT IT.
+#
+# You can use "make menuconfig" to make any modifications to the installed .config file.
+# You can then do "make savedefconfig" to generate a new defconfig file that includes your
+# modifications.
+#
+# CONFIG_ARCH_FPU is not set
+# CONFIG_NSH_DISABLE_IFCONFIG is not set
+# CONFIG_NSH_DISABLE_PS is not set
+CONFIG_ARCH="arm"
+CONFIG_ARCH_BOARD="nrf52840-dk"
+CONFIG_ARCH_BOARD_NRF52840_DK=y
+CONFIG_ARCH_CHIP="nrf52"
+CONFIG_ARCH_CHIP_NRF52840=y
+CONFIG_ARCH_CHIP_NRF52=y
+CONFIG_ARCH_STACKDUMP=y
+CONFIG_ARCH_STDARG_H=y
+CONFIG_BOARD_LOOPSPERMSEC=5500
+CONFIG_BUILTIN=y
+CONFIG_EXAMPLES_TIMER=y
+CONFIG_FAT_LCNAMES=y
+CONFIG_FAT_LFN=y
+CONFIG_FS_FAT=y
+CONFIG_MAX_TASKS=16
+CONFIG_MAX_WDOGPARMS=2
+CONFIG_MM_REGIONS=2
+CONFIG_NFILE_DESCRIPTORS=8
+CONFIG_NFILE_STREAMS=8
+CONFIG_NRF52_RTC0=y
+CONFIG_NRF52_TIMER0=y
+CONFIG_NRF52_UART0=y
+CONFIG_NSH_ARCHINIT=y
+CONFIG_NSH_BUILTIN_APPS=y
+CONFIG_NSH_FILEIOSIZE=512
+CONFIG_NSH_LINELEN=64
+CONFIG_NSH_READLINE=y
+CONFIG_PREALLOC_MQ_MSGS=4
+CONFIG_PREALLOC_TIMERS=4
+CONFIG_PREALLOC_WDOGS=4
+CONFIG_RAM_SIZE=65535
+CONFIG_RAM_START=0x20000000
+CONFIG_RAW_BINARY=y
+CONFIG_RR_INTERVAL=200
+CONFIG_SCHED_WAITPID=y
+CONFIG_SDCLONE_DISABLE=y
+CONFIG_START_DAY=26
+CONFIG_START_MONTH=3
+CONFIG_SYMTAB_ORDEREDBYNAME=y
+CONFIG_SYSTEM_NSH=y
+CONFIG_TASK_NAME_SIZE=0
+CONFIG_TIMER=y
+CONFIG_UART0_SERIAL_CONSOLE=y
+CONFIG_USER_ENTRYPOINT="nsh_main"
+CONFIG_WDOG_INTRESERVE=0
diff --git a/boards/arm/nrf52/nrf52840-dk/src/Makefile b/boards/arm/nrf52/nrf52840-dk/src/Makefile
index 08441a6..1f31b25 100644
--- a/boards/arm/nrf52/nrf52840-dk/src/Makefile
+++ b/boards/arm/nrf52/nrf52840-dk/src/Makefile
@@ -75,4 +75,8 @@ ifeq ($(CONFIG_NRF52840DK_HIGHPRI),y)
 CSRCS += nrf52_highpri.c
 endif
 
+ifeq ($(CONFIG_TIMER),y)
+CSRCS += nrf52_timer.c
+endif
+
 include $(TOPDIR)/boards/Board.mk
diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h b/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h
index 7db93cb..49aefd3 100644
--- a/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h
+++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h
@@ -161,11 +161,24 @@ int nrf52_hts221_initialize(char *devpath);
  *
  * Description:
  *   Initialize SX127X LPWAN interaface.
+ *
  ****************************************************************************/
 
 #ifdef CONFIG_LPWAN_SX127X
 int nrf52_lpwaninitialize(void);
 #endif
 
+/****************************************************************************
+ * Name: nrf52_timer_driver_setup
+ *
+ * Description:
+ *   Initialize TIMER driver.
+ *
+ ****************************************************************************/
+
+#ifdef CONFIG_TIMER
+int nrf52_timer_driver_setup(FAR const char *devpath, int timer);
+#endif
+
 #endif /* __ASSEMBLY__ */
 #endif /* __BOARDS_ARM_NRF52_NRF52840_DK_SRC_NRF52840_DK_H */
diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c
index 124c878..09bff16 100644
--- a/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c
+++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_bringup.c
@@ -49,6 +49,12 @@
 #include "nrf52840-dk.h"
 
 /****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define NRF52_TIMER (0)
+
+/****************************************************************************
  * Public Functions
  ****************************************************************************/
 
@@ -174,6 +180,18 @@ int nrf52_bringup(void)
     }
 #endif /* CONFIG_LPWAN_SX127X */
 
+#ifdef CONFIG_TIMER
+  /* Configure TIMER driver */
+
+  ret = nrf52_timer_driver_setup("/dev/timer0", NRF52_TIMER);
+  if (ret < 0)
+    {
+      syslog(LOG_ERR,
+             "ERROR: Failed to initialize timer driver: %d\n",
+             ret);
+    }
+#endif
+
   UNUSED(ret);
   return OK;
 }
diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52_timer.c b/boards/arm/nrf52/nrf52840-dk/src/nrf52_timer.c
new file mode 100644
index 0000000..183498e
--- /dev/null
+++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52_timer.c
@@ -0,0 +1,58 @@
+/****************************************************************************
+ * boards/arm/nrf52/nrf52840-dk/src/nrf52_timer.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/timers/timer.h>
+
+#include <debug.h>
+
+#include "nrf52_tim_lowerhalf.h"
+
+#include "nrf52840-dk.h"
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nrf52_timer_driver_setup
+ *
+ * Description:
+ *   Configure the timer driver.
+ *
+ * Input Parameters:
+ *   devpath - The full path to the timer device.  This should be of the
+ *             form /dev/timer0
+ *   timer   - The timer's number.
+ *
+ * Returned Value:
+ *   Zero (OK) is returned on success; A negated errno value is returned
+ *   to indicate the nature of any failure.
+ *
+ ****************************************************************************/
+
+int nrf52_timer_driver_setup(FAR const char *devpath, int timer)
+{
+  return nrf52_timer_initialize(devpath, timer);
+}


[incubator-nuttx] 03/03: fix nxstyle warnings

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit ba44a812bb5daf37087aacf88129906854c1de59
Author: raiden00pl <ra...@railab.me>
AuthorDate: Mon Jul 20 11:16:47 2020 +0200

    fix nxstyle warnings
---
 boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h b/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h
index 49aefd3..93f28ee 100644
--- a/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h
+++ b/boards/arm/nrf52/nrf52840-dk/src/nrf52840-dk.h
@@ -88,7 +88,7 @@
 #ifndef __ASSEMBLY__
 
 /****************************************************************************
- * Public Functions
+ * Public Functions Prototypes
  ****************************************************************************/
 
 /****************************************************************************
@@ -120,7 +120,7 @@ int nrf52_bringup(void);
 void nrf52_spidev_initialize(void);
 #endif
 
-/*****************************************************************************
+/****************************************************************************
  * Name: nrf52_lsm6dsl_initialize
  *
  * Description:
@@ -132,7 +132,7 @@ void nrf52_spidev_initialize(void);
 int nrf52_lsm6dsl_initialize(char *devpath);
 #endif
 
-/*****************************************************************************
+/****************************************************************************
  * Name: nrf52_lsm303agr_initialize
  *
  * Description:
@@ -144,7 +144,7 @@ int nrf52_lsm6dsl_initialize(char *devpath);
 int nrf52_lsm303agr_initialize(char *devpath);
 #endif
 
-/*****************************************************************************
+/****************************************************************************
  * Name: nrf52_hts221_initialize
  *
  * Description:
@@ -156,7 +156,7 @@ int nrf52_lsm303agr_initialize(char *devpath);
 int nrf52_hts221_initialize(char *devpath);
 #endif
 
-/*****************************************************************************
+/****************************************************************************
  * Name: nrf52_lpwaninitialize
  *
  * Description:


[incubator-nuttx] 01/03: arch/arm/src/nrf52: add support for TIMER lowerhalf

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 4152193e0ac085c64793511f710c85345e143f31
Author: raiden00pl <ra...@railab.me>
AuthorDate: Mon Jul 20 11:09:08 2020 +0200

    arch/arm/src/nrf52: add support for TIMER lowerhalf
---
 arch/arm/src/nrf52/Make.defs             |   3 +
 arch/arm/src/nrf52/nrf52_tim_lowerhalf.c | 538 +++++++++++++++++++++++++++++++
 arch/arm/src/nrf52/nrf52_tim_lowerhalf.h |  42 +++
 3 files changed, 583 insertions(+)

diff --git a/arch/arm/src/nrf52/Make.defs b/arch/arm/src/nrf52/Make.defs
index ecdfa7c..3cdcc30 100644
--- a/arch/arm/src/nrf52/Make.defs
+++ b/arch/arm/src/nrf52/Make.defs
@@ -132,6 +132,9 @@ endif
 
 ifeq ($(CONFIG_NRF52_TIMER),y)
 CHIP_CSRCS += nrf52_tim.c
+ifeq ($(CONFIG_TIMER),y)
+CHIP_CSRCS += nrf52_tim_lowerhalf.c
+endif
 endif
 
 ifeq ($(CONFIG_NRF52_RTC),y)
diff --git a/arch/arm/src/nrf52/nrf52_tim_lowerhalf.c b/arch/arm/src/nrf52/nrf52_tim_lowerhalf.c
new file mode 100644
index 0000000..ea857fb
--- /dev/null
+++ b/arch/arm/src/nrf52/nrf52_tim_lowerhalf.c
@@ -0,0 +1,538 @@
+/****************************************************************************
+ * arch/arm/src/nrf52/nrf52_tim_lowerhalf.h
+ *
+ * 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 <stdbool.h>
+#include <string.h>
+#include <errno.h>
+#include <debug.h>
+
+#include <nuttx/arch.h>
+#include <nuttx/timers/timer.h>
+
+#include "arm_arch.h"
+
+#include "nrf52_tim.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* TIMER configuration */
+
+#define NRF52_TIMER_CC  (NRF52_TIM_CC0)
+#define NRF52_TIMER_INT (NRF52_TIM_INT_COMPARE0)
+#define NRF52_TIMER_RES (NRF52_TIM_WIDTH_32B)
+#define NRF52_TIMER_MAX (0xffffffff)
+#define NRF52_TIMER_PRE (NRF52_TIM_PRE_1000000)
+#define NRF52_TIMER_PER (1000000)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct nrf52_timer_lowerhalf_s
+{
+  FAR const struct timer_ops_s *ops;        /* Lower half operations */
+  FAR struct nrf52_tim_dev_s   *tim;        /* nrf52 timer driver */
+  tccb_t                        callback;   /* Current user interrupt callback */
+  FAR void                     *arg;        /* Argument passed to upper half callback */
+  bool                          started;    /* True: Timer has been started */
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int nrf52_timer_handler(int irq, void *context, void *arg);
+
+/* "Lower half" driver methods **********************************************/
+
+static int nrf52_timer_start(FAR struct timer_lowerhalf_s *lower);
+static int nrf52_timer_stop(FAR struct timer_lowerhalf_s *lower);
+static int nrf52_timer_getstatus(FAR struct timer_lowerhalf_s *lower,
+                                  FAR struct timer_status_s *status);
+static int nrf52_timer_settimeout(FAR struct timer_lowerhalf_s *lower,
+                            uint32_t timeout);
+static void nrf52_timer_setcallback(FAR struct timer_lowerhalf_s *lower,
+                              tccb_t callback, FAR void *arg);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+/* "Lower half" driver methods */
+
+static const struct timer_ops_s g_nrf52_timer_ops =
+{
+  .start       = nrf52_timer_start,
+  .stop        = nrf52_timer_stop,
+  .getstatus   = nrf52_timer_getstatus,
+  .settimeout  = nrf52_timer_settimeout,
+  .setcallback = nrf52_timer_setcallback,
+  .ioctl       = NULL,
+};
+
+#ifdef CONFIG_NRF52_TIMER0
+/* TIMER0 lower-half */
+
+static struct nrf52_timer_lowerhalf_s g_nrf52_timer0_lowerhalf =
+{
+  .ops = &g_nrf52_timer_ops,
+};
+#endif
+
+#ifdef CONFIG_NRF52_TIMER1
+/* TIMER1 lower-half */
+
+static struct nrf52_timer_lowerhalf_s g_nrf52_timer1_lowerhalf =
+{
+  .ops = &g_nrf52_timer_ops,
+};
+#endif
+
+#ifdef CONFIG_NRF52_TIMER2
+/* TIMER2 lower-half */
+
+static struct nrf52_timer_lowerhalf_s g_nrf52_timer2_lowerhalf =
+{
+  .ops = &g_nrf52_timer_ops,
+};
+#endif
+
+#ifdef CONFIG_NRF52_TIMER3
+/* TIMER3 lower-half */
+
+static struct nrf52_timer_lowerhalf_s g_nrf52_timer3_lowerhalf =
+{
+  .ops = &g_nrf52_timer_ops,
+};
+#endif
+
+#ifdef CONFIG_NRF52_TIMER4
+/* TIMER4 lower-half */
+
+static struct nrf52_timer_lowerhalf_s g_nrf52_timer4_lowerhalf =
+{
+  .ops = &g_nrf52_timer_ops,
+};
+#endif
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nrf52_timer_handler
+ *
+ * Description:
+ *   Timer interrupt handler
+ *
+ * Input Parameters:
+ *
+ * Returned Value:
+ *
+ ****************************************************************************/
+
+static int nrf52_timer_handler(int irq, void *context, void *arg)
+{
+  FAR struct nrf52_timer_lowerhalf_s *priv =
+    (FAR struct nrf52_timer_lowerhalf_s *)arg;
+  uint32_t next_interval_us = 0;
+
+  NRF52_TIM_ACKINT(priv->tim, NRF52_TIMER_INT);
+
+  if (priv->callback(&next_interval_us, priv->arg))
+    {
+      if (next_interval_us > 0)
+        {
+          NRF52_TIM_SETCC(priv->tim, NRF52_TIMER_CC, next_interval_us);
+        }
+    }
+  else
+    {
+      nrf52_timer_stop((struct timer_lowerhalf_s *)priv);
+    }
+
+  return OK;
+}
+
+/****************************************************************************
+ * Name: nrf52_timer_start
+ *
+ * Description:
+ *   Start the timer, resetting the time to the current timeout,
+ *
+ * Input Parameters:
+ *   lower - A pointer the publicly visible representation of
+ *           the "lower-half" driver state structure.
+ *
+ * Returned Value:
+ *   Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+static int nrf52_timer_start(FAR struct timer_lowerhalf_s *lower)
+{
+  FAR struct nrf52_timer_lowerhalf_s *priv =
+    (FAR struct nrf52_timer_lowerhalf_s *)lower;
+  int ret = OK;
+
+  DEBUGASSERT(priv);
+
+  if (priv->started == true)
+    {
+      /* Return EBUSY to indicate that the timer was already running */
+
+      ret = -EBUSY;
+      goto errout;
+    }
+
+  /* Configure TIMER mode and resolution */
+
+  NRF52_TIM_CONFIGURE(priv->tim, NRF52_TIM_MODE_TIMER, NRF52_TIMER_RES);
+
+  /* Clear counter on COMPARE event */
+
+  NRF52_TIM_SHORTS(priv->tim, NRF52_TIM_SHORT_COMPARE_CLEAR,
+                   NRF52_TIMER_INT, true);
+
+  /* Configure prescaler */
+
+  NRF52_TIM_SETPRE(priv->tim, NRF52_TIMER_PRE);
+
+  /* Configure callback */
+
+  if (priv->callback != NULL)
+    {
+      NRF52_TIM_SETISR(priv->tim, nrf52_timer_handler, priv);
+      NRF52_TIM_ENABLEINT(priv->tim, NRF52_TIMER_INT);
+    }
+
+  NRF52_TIM_CLEAR(priv->tim);
+  NRF52_TIM_START(priv->tim);
+
+  priv->started = true;
+
+errout:
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nrf52_timer_stop
+ *
+ * Description:
+ *   Stop the timer
+ *
+ * Input Parameters:
+ *   lower - A pointer the publicly visible representation of
+ *           the "lower-half" driver state structure.
+ *
+ * Returned Value:
+ *   Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+static int nrf52_timer_stop(FAR struct timer_lowerhalf_s *lower)
+{
+  FAR struct nrf52_timer_lowerhalf_s *priv =
+    (FAR struct nrf52_timer_lowerhalf_s *)lower;
+  int ret = OK;
+
+  DEBUGASSERT(priv);
+
+  if (priv->started == false)
+    {
+      /* Return ENODEV to indicate that the timer was not running */
+
+      ret = -ENODEV;
+      goto errout;
+    }
+
+  NRF52_TIM_DISABLEINT(priv->tim, NRF52_TIMER_INT);
+  NRF52_TIM_SETISR(priv->tim, NULL, NULL);
+  NRF52_TIM_STOP(priv->tim);
+
+  priv->started = false;
+
+errout:
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nrf52_timer_getstatus
+ *
+ * Description:
+ *   get timer status
+ *
+ * Input Parameters:
+ *   lower  - A pointer the publicly visible representation of the "lower-
+ *            half" driver state structure.
+ *   status - The location to return the status information.
+ *
+ * Returned Value:
+ *   Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+static int nrf52_timer_getstatus(FAR struct timer_lowerhalf_s *lower,
+                                 FAR struct timer_status_s *status)
+{
+  FAR struct nrf52_timer_lowerhalf_s *priv =
+    (FAR struct nrf52_timer_lowerhalf_s *)lower;
+
+  DEBUGASSERT(priv);
+  DEBUGASSERT(status);
+
+  /* Return the status bit */
+
+  status->flags = 0;
+
+  if (priv->started == true)
+    {
+      status->flags |= TCFLAGS_ACTIVE;
+    }
+
+  if (priv->callback)
+    {
+      status->flags |= TCFLAGS_HANDLER;
+    }
+
+  /* TODO: timeout and time left */
+
+  status->timeout  = 0;
+  status->timeleft = 0;
+
+  return OK;
+}
+
+/****************************************************************************
+ * Name: nrf52_timer_settimeout
+ *
+ * Description:
+ *   Set a new timeout value (and reset the timer)
+ *
+ * Input Parameters:
+ *   lower   - A pointer the publicly visible representation of
+ *             the "lower-half" driver state structure.
+ *   timeout - The new timeout value in microseconds.
+ *
+ * Returned Value:
+ *   Zero on success; a negated errno value on failure.
+ *
+ ****************************************************************************/
+
+static int nrf52_timer_settimeout(FAR struct timer_lowerhalf_s *lower,
+                                  uint32_t timeout)
+{
+  FAR struct nrf52_timer_lowerhalf_s *priv =
+    (FAR struct nrf52_timer_lowerhalf_s *)lower;
+  uint64_t cc  = 0;
+  int      ret = OK;
+
+  DEBUGASSERT(priv);
+
+  if (priv->started == true)
+    {
+      ret = -EPERM;
+      goto errout;
+    }
+
+  if (timeout > NRF52_TIMER_MAX)
+    {
+      ret = -EINVAL;
+      goto errout;
+    }
+
+  cc = (timeout / 1000000) * NRF52_TIMER_PER;
+  NRF52_TIM_SETCC(priv->tim, NRF52_TIMER_CC, cc);
+
+errout:
+  return ret;
+}
+
+/****************************************************************************
+ * Name: nrf52_setcallback
+ *
+ * Description:
+ *   Call this user provided timeout handler.
+ *
+ * Input Parameters:
+ *   lower    - A pointer the publicly visible representation of
+ *              the "lower-half" driver state structure.
+ *   callback - The new timer expiration function pointer.  If this
+ *              function pointer is NULL, then the reset-on-expiration
+ *              behavior is restored,
+ *   arg      - Argument that will be provided in the callback
+ *
+ * Returned Value:
+ *   The previous timer expiration function pointer or NULL is there was
+ *   no previous function pointer.
+ *
+ ****************************************************************************/
+
+static void nrf52_timer_setcallback(FAR struct timer_lowerhalf_s *lower,
+                                    tccb_t callback, FAR void *arg)
+{
+  FAR struct nrf52_timer_lowerhalf_s *priv =
+    (FAR struct nrf52_timer_lowerhalf_s *)lower;
+  irqstate_t flags;
+
+  DEBUGASSERT(priv);
+
+  flags = enter_critical_section();
+
+  /* Save the new callback */
+
+  priv->callback = callback;
+  priv->arg      = arg;
+
+  if (callback != NULL && priv->started == true)
+    {
+      NRF52_TIM_SETISR(priv->tim, nrf52_timer_handler, priv);
+      NRF52_TIM_ENABLEINT(priv->tim, NRF52_TIMER_INT);
+    }
+  else
+    {
+      NRF52_TIM_DISABLEINT(priv->tim, NRF52_TIMER_INT);
+      NRF52_TIM_SETISR(priv->tim, NULL, NULL);
+    }
+
+  leave_critical_section(flags);
+}
+
+/****************************************************************************
+ * Public Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nrf52_timer_initialize
+ *
+ * Description:
+ *   Bind the configuration timer to a timer lower half instance and
+ *   register the timer drivers at 'devpath'
+ *
+ * Input Parameters:
+ *   devpath - The full path to the timer device.  This should be of the
+ *     form /dev/timer0
+ *   timer - the timer's number.
+ *
+ * Returned Value:
+ *   Zero (OK) is returned on success; A negated errno value is returned
+ *   to indicate the nature of any failure.
+ *
+ ****************************************************************************/
+
+int nrf52_timer_initialize(FAR const char *devpath, uint8_t timer)
+{
+  struct nrf52_timer_lowerhalf_s *lower = NULL;
+  FAR void                       *drvr  = NULL;
+  int                             ret   = OK;
+
+  DEBUGASSERT(devpath);
+
+  switch (timer)
+    {
+#ifdef CONFIG_NRF52_TIMER0
+      case 0:
+        {
+          lower = &g_nrf52_timer0_lowerhalf;
+          break;
+        }
+#endif
+
+#ifdef CONFIG_NRF52_TIMER1
+      case 1:
+        {
+          lower = &g_nrf52_timer1_lowerhalf;
+          break;
+        }
+#endif
+
+#ifdef CONFIG_NRF52_TIMER2
+      case 2:
+        {
+          lower = &g_nrf52_timer2_lowerhalf;
+          break;
+        }
+#endif
+
+#ifdef CONFIG_NRF52_TIMER3
+      case 3:
+        {
+          lower = &g_nrf52_timer3_lowerhalf;
+          break;
+        }
+#endif
+
+#ifdef CONFIG_NRF52_TIMER4
+      case 4:
+        {
+          lower = &g_nrf52_timer4_lowerhalf;
+          break;
+        }
+#endif
+
+      default:
+        {
+          ret = -ENODEV;
+          goto errout;
+        }
+    }
+
+  /* Initialize the elements of lower half state structure */
+
+  lower->started  = false;
+  lower->callback = NULL;
+  lower->tim      = nrf52_tim_init(timer);
+
+  if (lower->tim == NULL)
+    {
+      ret = -EINVAL;
+      goto errout;
+    }
+
+  /* Register the timer driver as /dev/timerX.  The returned value from
+   * timer_register is a handle that could be used with timer_unregister().
+   * REVISIT: The returned handle is discard here.
+   */
+
+  drvr = timer_register(devpath, (FAR struct timer_lowerhalf_s *)lower);
+  if (drvr == NULL)
+    {
+      /* The actual cause of the failure may have been a failure to allocate
+       * perhaps a failure to register the timer driver (such as if the
+       * 'depath' were not unique).  We know here but we return EEXIST to
+       * indicate the failure (implying the non-unique devpath).
+       */
+
+      ret = -EEXIST;
+      goto errout;
+    }
+
+errout:
+  return ret;
+}
diff --git a/arch/arm/src/nrf52/nrf52_tim_lowerhalf.h b/arch/arm/src/nrf52/nrf52_tim_lowerhalf.h
new file mode 100644
index 0000000..088a249
--- /dev/null
+++ b/arch/arm/src/nrf52/nrf52_tim_lowerhalf.h
@@ -0,0 +1,42 @@
+/****************************************************************************
+ * arch/arm/src/nrf52/nrf52_tim_lowerhalf.h
+ *
+ * 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_NRF52_NRF52_TIM_LOWERHALF_H
+#define __ARCH_ARM_SRC_NRF52_NRF52_TIM_LOWERHALF_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+
+#include <nrf52_tim.h>
+
+/****************************************************************************
+ * Public Function Prototypes
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: nrf52_timer_initialize
+ ****************************************************************************/
+
+int nrf52_timer_initialize(FAR const char *devpath, uint8_t timer);
+
+#endif /* __ARCH_ARM_SRC_NRF52_NRF52_TIM_LOWERHALF_H */