drivers/timers/timer: Add option for non-periodic notification
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
parent
b04447d066
commit
f30fa2fe57
@ -72,11 +72,11 @@ static bool timer_notifier(FAR uint32_t *next_interval_us, FAR void *arg);
|
|||||||
static int timer_open(FAR struct file *filep);
|
static int timer_open(FAR struct file *filep);
|
||||||
static int timer_close(FAR struct file *filep);
|
static int timer_close(FAR struct file *filep);
|
||||||
static ssize_t timer_read(FAR struct file *filep, FAR char *buffer,
|
static ssize_t timer_read(FAR struct file *filep, FAR char *buffer,
|
||||||
size_t buflen);
|
size_t buflen);
|
||||||
static ssize_t timer_write(FAR struct file *filep, FAR const char *buffer,
|
static ssize_t timer_write(FAR struct file *filep, FAR const char *buffer,
|
||||||
size_t buflen);
|
size_t buflen);
|
||||||
static int timer_ioctl(FAR struct file *filep, int cmd,
|
static int timer_ioctl(FAR struct file *filep, int cmd,
|
||||||
unsigned long arg);
|
unsigned long arg);
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Private Data
|
* Private Data
|
||||||
@ -119,10 +119,9 @@ static bool timer_notifier(FAR uint32_t *next_interval_us, FAR void *arg)
|
|||||||
|
|
||||||
/* Signal the waiter.. if there is one */
|
/* Signal the waiter.. if there is one */
|
||||||
|
|
||||||
nxsig_notification(notify->pid, ¬ify->event,
|
nxsig_notification(notify->pid, ¬ify->event, SI_QUEUE, &upper->work);
|
||||||
SI_QUEUE, &upper->work);
|
|
||||||
|
|
||||||
return true;
|
return !notify->oneshot;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@ -378,8 +377,8 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
if (notify != NULL)
|
if (notify != NULL)
|
||||||
{
|
{
|
||||||
memcpy(&upper->notify, notify, sizeof(*notify));
|
memcpy(&upper->notify, notify, sizeof(*notify));
|
||||||
ret = timer_setcallback((FAR void *)upper,
|
ret = timer_setcallback((FAR void *)upper, timer_notifier,
|
||||||
timer_notifier, upper);
|
(FAR void *)upper);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -399,7 +398,7 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
|||||||
|
|
||||||
if (lower->ops->maxtimeout) /* Optional */
|
if (lower->ops->maxtimeout) /* Optional */
|
||||||
{
|
{
|
||||||
ret = lower->ops->maxtimeout(lower, (uint32_t *)arg);
|
ret = lower->ops->maxtimeout(lower, (FAR uint32_t *)arg);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -116,6 +116,7 @@ struct timer_notify_s
|
|||||||
{
|
{
|
||||||
struct sigevent event; /* Describe the way a task is to be notified */
|
struct sigevent event; /* Describe the way a task is to be notified */
|
||||||
pid_t pid; /* The ID of the task/thread to receive the signal */
|
pid_t pid; /* The ID of the task/thread to receive the signal */
|
||||||
|
bool oneshot; /* Single notification or periodic notifications */
|
||||||
};
|
};
|
||||||
|
|
||||||
/* This structure provides the "lower-half" driver operations available to
|
/* This structure provides the "lower-half" driver operations available to
|
||||||
|
Loading…
Reference in New Issue
Block a user