diff --git a/drivers/timers/timer.c b/drivers/timers/timer.c index 6bb4edeb19..5c828873df 100644 --- a/drivers/timers/timer.c +++ b/drivers/timers/timer.c @@ -390,6 +390,26 @@ static int timer_ioctl(FAR struct file *filep, int cmd, unsigned long arg) } break; + /* cmd: TCIOC_MAXTIMEOUT + * Description: Get the maximum supported timeout value + * Argument: A 32-bit timeout value in microseconds. + */ + + case TCIOC_MAXTIMEOUT: + { + /* Get the maximum supported timeout value */ + + if (lower->ops->maxtimeout) /* Optional */ + { + ret = lower->ops->maxtimeout(lower, (uint32_t *)arg); + } + else + { + ret = -ENOSYS; + } + } + break; + /* Any unrecognized IOCTL commands might be platform-specific ioctl commands */ default: diff --git a/include/nuttx/timers/timer.h b/include/nuttx/timers/timer.h index db59e81819..420e8dfbb2 100644 --- a/include/nuttx/timers/timer.h +++ b/include/nuttx/timers/timer.h @@ -74,6 +74,8 @@ * the timer expires. * Argument: A read-only pointer to an instance of * stuct timer_notify_s. + * TCIOC_MAXTIMEOUT - Get the maximum supported timeout value + * Argument: A 32-bit timeout value in microseconds. * * WARNING: May change TCIOC_SETTIMEOUT to pass pointer to 64bit nanoseconds * or timespec structure. @@ -93,6 +95,7 @@ #define TCIOC_GETSTATUS _TCIOC(0x0003) #define TCIOC_SETTIMEOUT _TCIOC(0x0004) #define TCIOC_NOTIFICATION _TCIOC(0x0005) +#define TCIOC_MAXTIMEOUT _TCIOC(0x0006) /* Bit Settings *************************************************************/ /* Bit settings for the struct timer_status_s flags field */ @@ -172,6 +175,11 @@ struct timer_ops_s CODE int (*ioctl)(FAR struct timer_lowerhalf_s *lower, int cmd, unsigned long arg); + + /* Get the maximum supported timeout value */ + + CODE int (*maxtimeout)(FAR struct timer_lowerhalf_s *lower, + FAR uint32_t *maxtimeout); }; /* This structure provides the publicly visible representation of the