summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-05-05 14:40:19 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-05-05 14:40:19 -0600
commitaf24bfcaf370f42bd6e1273575f9e74a0ec0fcd1 (patch)
tree7184d404a233c02577658b2cfc344bb9a92134fa
parent03a7ce0f604530c31f9716533103b4a2288c857b (diff)
downloadnuttx-af24bfcaf370f42bd6e1273575f9e74a0ec0fcd1.tar.gz
nuttx-af24bfcaf370f42bd6e1273575f9e74a0ec0fcd1.tar.bz2
nuttx-af24bfcaf370f42bd6e1273575f9e74a0ec0fcd1.zip
Timer driver updates from Bob Doiron
-rw-r--r--nuttx/ChangeLog4
-rw-r--r--nuttx/drivers/timer.c14
-rw-r--r--nuttx/include/nuttx/timer.h52
3 files changed, 26 insertions, 44 deletions
diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog
index 68cbd07a4..806f1cfc0 100644
--- a/nuttx/ChangeLog
+++ b/nuttx/ChangeLog
@@ -7289,4 +7289,6 @@
added high resolution RTC emulation using the RTT for the sub-second
counter (2014-5-5).
* configs/sam4s-xplained-pro: Clean-up of LED usage and also some
- integration of new timer features. From Bob Doiron (2014-5-5). \ No newline at end of file
+ integration of new timer features. From Bob Doiron (2014-5-5).
+ * drivers/timer.c and include/nuttx/timer.h: Timer driver updates from
+ Bob Doiron (2014-5-5).
diff --git a/nuttx/drivers/timer.c b/nuttx/drivers/timer.c
index 45581f3be..dde059ae0 100644
--- a/nuttx/drivers/timer.c
+++ b/nuttx/drivers/timer.c
@@ -374,7 +374,7 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
/* cmd: TCIOC_SETHANDLER
* Description: Call this handler on timeout
- * Argument: A pointer to struct timer_capture_s.
+ * Argument: A pointer to struct timer_sethandler_s.
*
* NOTE: This ioctl cannot be support in the kernel build mode. In that
* case direct callbacks from kernel space into user space is forbidden.
@@ -383,20 +383,20 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
#ifndef CONFIG_NUTTX_KERNEL
case TCIOC_SETHANDLER:
{
- FAR struct timer_capture_s *capture;
+ FAR struct timer_sethandler_s *sethandler;
/* Don't reset on timer timeout; instead, call this user
* provider timeout handler. NOTE: Providing handler==NULL will
* restore the reset behavior.
*/
- if (lower->ops->capture) /* Optional */
+ if (lower->ops->sethandler) /* Optional */
{
- capture = (FAR struct timer_capture_s *)((uintptr_t)arg);
- if (capture)
+ sethandler = (FAR struct timer_sethandler_s *)((uintptr_t)arg);
+ if (sethandler)
{
- capture->oldhandler =
- lower->ops->capture(lower, capture->newhandler);
+ sethandler->oldhandler =
+ lower->ops->sethandler(lower, sethandler->newhandler);
ret = OK;
}
else
diff --git a/nuttx/include/nuttx/timer.h b/nuttx/include/nuttx/timer.h
index a5e9dca8e..bc090f365 100644
--- a/nuttx/include/nuttx/timer.h
+++ b/nuttx/include/nuttx/timer.h
@@ -68,13 +68,14 @@
* TCIOC_SETTIMEOUT - Reset the timer timeout to this value
* Argument: A 32-bit timeout value in microseconds.
* TCIOC_SETHANDLER - Call this handler on timer expiration
- * Argument: A pointer to struct timer_capture_s.
+ * Argument: A pointer to struct timer_sethandler_s.
*
* WARNING: May change TCIOC_SETTIMEOUT to pass pointer to 64bit nanoseconds
* or timespec structure.
*
- * NOTE: This ioctl cannot be support in the kernel build mode. In that
- * case direct callbacks from kernel space into user space is forbidden.
+ * NOTE: The TCIOC_SETHANDLER ioctl cannot be supported in the kernel build
+ * mode. In that case direct callbacks from kernel space into user space is
+ * forbidden.
*/
#define TCIOC_START _TCIOC(0x001)
@@ -87,7 +88,7 @@
/* Bit settings for the struct timer_status_s flags field */
#define TCFLAGS_ACTIVE (1 << 0) /* 1=The timer is running */
-#define TCFLAGS_CAPTURE (1 << 1) /* 1=Call the user function when the
+#define TCFLAGS_HANDLER (1 << 1) /* 1=Call the user function when the
* timer expires */
/****************************************************************************
@@ -102,22 +103,22 @@ typedef bool (*tccb_t)(FAR uint32_t *next_interval_us);
/* This is the type of the argument passed to the TCIOC_SETHANDLER ioctl */
-struct timer_capture_s
+struct timer_sethandler_s
{
- CODE tccb_t newhandler; /* The new timer capture handler */
- CODE tccb_t oldhandler; /* The previous timer capture handler (if any) */
+ CODE tccb_t newhandler; /* The new timer interrupt handler */
+ CODE tccb_t oldhandler; /* The previous timer interrupt handler (if any) */
};
/* This is the type of the argument passed to the TCIOC_GETSTATUS ioctl and
* and returned by the "lower half" getstatus() method.
*/
-struct timer_status_s
+struct timer_status_s
{
uint32_t flags; /* See TCFLAGS_* definitions above */
- uint32_t timeout; /* The current timeout setting (in milliseconds) */
+ uint32_t timeout; /* The current timeout setting (in microseconds) */
uint32_t timeleft; /* Time left until the timer expiration
- * (in milliseconds) */
+ * (in microseconds) */
};
/* This structure provides the "lower-half" driver operations available to
@@ -125,7 +126,7 @@ struct timer_status_s
*/
struct timer_lowerhalf_s;
-struct timer_ops_s
+struct timer_ops_s
{
/* Required methods ********************************************************/
/* Start the timer, resetting the time to the current timeout */
@@ -146,12 +147,12 @@ struct timer_ops_s
CODE int (*settimeout)(FAR struct timer_lowerhalf_s *lower,
uint32_t timeout);
- /* Call this user provider timeout handler on timeout.
+ /* Call this user provider timeout handler on timeout.
* NOTE: Providing handler==NULL disable.
*/
- CODE tccb_t (*capture)(FAR struct timer_lowerhalf_s *lower,
- CODE tccb_t handler);
+ CODE tccb_t (*sethandler)(FAR struct timer_lowerhalf_s *lower,
+ CODE tccb_t handler);
/* Any ioctl commands that are not recognized by the "upper-half" driver
* are forwarded to the lower half driver through this method.
@@ -210,7 +211,7 @@ extern "C"
*
* NOTE: Normally, this function would not be called by application code.
* Rather it is called indirectly through the architecture-specific
- * interface up_timerinitialize() described below.
+ * initialization.
*
* Input parameters:
* dev path - The full path to the driver to be registers in the NuttX
@@ -255,27 +256,6 @@ void timer_unregister(FAR void *handle);
* Architecture-specific Application Interfaces
****************************************************************************/
-/****************************************************************************
- * Name: up_timerinitialize()
- *
- * Description:
- * Perform architecture-specific initialization of the timer hardware.
- * This interface should be provided by all configurations using
- * to avoid exposed platform-dependent logic.
- *
- * At a minimum, this function should call timer_register() which is
- * described above.
- *
- * Input parameters:
- * None
- *
- * Returned Value:
- * Zero on success; a negated errno value on failure.
- *
- ****************************************************************************/
-
-int up_timerinitialize(void);
-
#undef EXTERN
#ifdef __cplusplus
}