RTC: Further simplications of the RTC driver interface; Add sample implem.
This commit is contained in:
parent
58d6624f29
commit
0723226bda
2
arch
2
arch
@ -1 +1 @@
|
||||
Subproject commit 97812e3a3e124c579a66b07a79a5595c84123d5d
|
||||
Subproject commit fcd1c6ab800ebf8ac14e00cea9ab62c23c3df457
|
@ -349,43 +349,6 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
break;
|
||||
|
||||
#ifdef CONFIG_RTC_ALARM
|
||||
/* RTC_RD_ALARM reads the alarm time
|
||||
*
|
||||
* Argument: A writeable reference to struct rtc_rdalarm_s to receive the
|
||||
* current alarm settings.
|
||||
*/
|
||||
|
||||
case RTC_RD_ALARM:
|
||||
{
|
||||
FAR struct rtc_rdalarm_s *alarminfo =
|
||||
(FAR struct rtc_rdalarm_s *)((uintptr_t)arg);
|
||||
int alarmid;
|
||||
|
||||
DEBUGASSERT(alarminfo != NULL);
|
||||
alarmid = alarminfo->id;
|
||||
DEBUGASSERT(alarmid >= 0 && alarmid < RTC_NALARMS);
|
||||
|
||||
/* Is the alarm active? */
|
||||
|
||||
if (upper->alarminfo[alarmid].active)
|
||||
{
|
||||
/* Yes, read the alarm */
|
||||
|
||||
if (ops->rdalarm)
|
||||
{
|
||||
ret = ops->rdalarm(upper->lower, alarminfo);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
/* No.. decline the request to return the time. */
|
||||
|
||||
alarminfo->active = false;
|
||||
ret = OK;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
/* RTC_SET_ALARM sets the alarm time.
|
||||
*
|
||||
* Argument: A read-only reference to a struct rtc_time containing the
|
||||
@ -413,17 +376,19 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
|
||||
if (ops->cancelalarm)
|
||||
{
|
||||
ret = ops->cancelalarm(upper->lower, alarmid);
|
||||
(void)ops->cancelalarm(upper->lower, alarmid);
|
||||
}
|
||||
|
||||
upperinfo->active = false;
|
||||
}
|
||||
|
||||
upperinfo->active = false;
|
||||
if (ops->setalarm)
|
||||
{
|
||||
/* Save the signal info to be used to notify the caller when the
|
||||
* alarm expires.
|
||||
*/
|
||||
|
||||
upperinfo->active = true;
|
||||
upperinfo->signo = alarminfo->signo;
|
||||
upperinfo->pid = alarminfo->pid;
|
||||
upperinfo->sigvalue = alarminfo->sigvalue;
|
||||
@ -438,9 +403,9 @@ static int rtc_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
|
||||
/* Then set the alarm */
|
||||
|
||||
ret = ops->setalarm(upper->lower, &lowerinfo);
|
||||
if (ret >= 0)
|
||||
if (ret < 0)
|
||||
{
|
||||
upperinfo->active = true;
|
||||
upperinfo->active = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -143,28 +143,20 @@
|
||||
|
||||
#define RTC_SET_TIME _RTCIOC(0x0002)
|
||||
|
||||
/* RTC_RD_ALARM reads the alarm time (for RTCs that support alarms)
|
||||
*
|
||||
* Argument: A writeable reference to a struct rtc_rdalarm_s to receive the RTC's
|
||||
* alarm time.
|
||||
*/
|
||||
|
||||
#define RTC_RD_ALARM _RTCIOC(0x0003)
|
||||
|
||||
/* RTC_SET_ALARM sets the alarm time (for RTCs that support alarms).
|
||||
*
|
||||
* Argument: A read-only reference to a struct rtc_setalarm_s containing the
|
||||
* new alarm time to be set.
|
||||
*/
|
||||
|
||||
#define RTC_SET_ALARM _RTCIOC(0x0004)
|
||||
#define RTC_SET_ALARM _RTCIOC(0x0003)
|
||||
|
||||
/* RTC_WKALRM_CANCEL cancel the alarm.
|
||||
*
|
||||
* Argument: An ALARM ID value that indicates which alarm should be canceled.
|
||||
*/
|
||||
|
||||
#define RTC_CANCEL_ALARM _RTCIOC(0x005)
|
||||
#define RTC_CANCEL_ALARM _RTCIOC(0x004)
|
||||
|
||||
/* Architecture-specific RTC IOCTLS should begin at RTC_USER_IOCBASE. For
|
||||
* example:
|
||||
@ -174,7 +166,7 @@
|
||||
* etc.
|
||||
*/
|
||||
|
||||
#define RTC_USER_IOCBASE 0x0006
|
||||
#define RTC_USER_IOCBASE 0x0005
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
@ -269,17 +261,12 @@ struct rtc_ops_s
|
||||
FAR const struct rtc_time *rtctime);
|
||||
|
||||
#ifdef CONFIG_RTC_ALARM
|
||||
/* rdalarm reads the current alarm time */
|
||||
|
||||
CODE int (*rdalarm)(FAR struct rtc_lowerhalf_s *lower,
|
||||
FAR struct rtc_rdalarm_s *alarminfo);
|
||||
|
||||
/* setalarm sets up a new alarm. */
|
||||
|
||||
CODE int (*setalarm)(FAR struct rtc_lowerhalf_s *lower,
|
||||
FAR const struct lower_setalarm_s *alarminfo);
|
||||
|
||||
/* cancelalarm cancels the alarm. */
|
||||
/* cancelalarm cancels the current alarm. */
|
||||
|
||||
CODE int (*cancelalarm)(FAR struct rtc_lowerhalf_s *lower, int alarmid);
|
||||
#endif
|
||||
|
Loading…
Reference in New Issue
Block a user