Timer driver updates from Bob Doiron

This commit is contained in:
Gregory Nutt 2014-05-05 14:40:19 -06:00
parent 84d28641b7
commit f06e9dbcaa
3 changed files with 26 additions and 44 deletions

View File

@ -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).
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).

View File

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

View File

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