Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
NuttX RTOS
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
NuttX RTOS
Commits
d897b4de
Commit
d897b4de
authored
11 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
Enhanced timer interface from Bob Doiron
parent
ae4584f0
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
drivers/timer.c
+8
-4
8 additions, 4 deletions
drivers/timer.c
include/nuttx/timer.h
+18
-8
18 additions, 8 deletions
include/nuttx/timer.h
with
26 additions
and
12 deletions
drivers/timer.c
+
8
−
4
View file @
d897b4de
...
...
@@ -372,12 +372,16 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
}
break
;
/* cmd: TCIOC_
CAPTURE
* Description: Call
ed
this handler on timeout
/* cmd: TCIOC_
SETHANDLER
* Description: Call this handler on timeout
* Argument: A pointer to struct timer_capture_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.
*/
case
TCIOC_CAPTURE
:
#ifndef CONFIG_NUTTX_KERNEL
case
TCIOC_SETHANDLER
:
{
FAR
struct
timer_capture_s
*
capture
;
...
...
@@ -406,7 +410,7 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
}
}
break
;
#endif
/* Any unrecognized IOCTL commands might be platform-specific ioctl commands */
...
...
This diff is collapsed.
Click to expand it.
include/nuttx/timer.h
+
18
−
8
View file @
d897b4de
...
...
@@ -55,7 +55,7 @@
/* The timer driver uses a standard character driver framework. However,
* since the timer driver is a device control interface and not a data
* transfer interface, the majority of the functionality is implemented in
* driver ioctl calls. The timer ioctl commands are lised below:
* driver ioctl calls. The timer ioctl commands are lis
t
ed below:
*
* These are detected and handled by the "upper half" timer driver.
*
...
...
@@ -67,18 +67,21 @@
* Argument: A writeable pointer to struct timer_status_s.
* TCIOC_SETTIMEOUT - Reset the timer timeout to this value
* Argument: A 32-bit timeout value in microseconds.
* TCIOC_
CAPTURE - Do not reset. Instead, c
all
ed
this handler
.
* TCIOC_
SETHANDLER - C
all this handler
on timer expiration
* Argument: A pointer to struct timer_capture_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.
*/
#define TCIOC_START _TCIOC(0x001)
#define TCIOC_STOP _TCIOC(0x002)
#define TCIOC_GETSTATUS _TCIOC(0x003)
#define TCIOC_SETTIMEOUT _TCIOC(0x004)
#define TCIOC_
CAPTURE
_TCIOC(0x005)
#define TCIOC_
SETHANDLER
_TCIOC(0x005)
/* Bit Settings *************************************************************/
/* Bit settings for the struct timer_status_s flags field */
...
...
@@ -90,12 +93,19 @@
/****************************************************************************
* Public Types
****************************************************************************/
/* This is the type of the argument passed to the TCIOC_CAPTURE ioctl */
/* User function prototype. Returns true to reload the timer, and the
* function can modify the next interval if desired.
*/
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
{
CODE
xcpt
_t
newhandler
;
/* The new timer capture handler */
CODE
xcpt
_t
oldhandler
;
/* The previous timer capture handler (if any) */
CODE
tccb
_t
newhandler
;
/* The new timer capture handler */
CODE
tccb
_t
oldhandler
;
/* The previous timer capture handler (if any) */
};
/* This is the type of the argument passed to the TCIOC_GETSTATUS ioctl and
...
...
@@ -140,8 +150,8 @@ struct timer_ops_s
* NOTE: Providing handler==NULL disable.
*/
CODE
xcpt
_t
(
*
capture
)(
FAR
struct
timer_lowerhalf_s
*
lower
,
CODE
xcpt
_t
handler
);
CODE
tccb
_t
(
*
capture
)(
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.
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment