PM update

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4932 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo
2012-07-11 23:21:16 +00:00
parent a4426d194e
commit 4f1e53b492
4 changed files with 135 additions and 16 deletions
@@ -607,6 +607,7 @@ int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
{
struct rtc_regvals_s regvals;
irqstate_t flags;
uint16_t cr;
int ret = -EBUSY;
/* Is there already something waiting on the ALARM? */
@@ -621,6 +622,12 @@ int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
up_rtc_breakout(tp, &regvals);
/* Enable RTC alarm */
cr = getreg16(STM32_RTC_CRH);
cr |= RTC_CRH_ALRIE;
putreg16(cr, STM32_RTC_CRH);
/* The set the alarm */
flags = irqsave();
@@ -635,3 +642,44 @@ int up_rtc_setalarm(FAR const struct timespec *tp, alarmcb_t callback)
return ret;
}
#endif
/************************************************************************************
* Name: up_rtc_cancelalarm
*
* Description:
* Cancel a pending alarm alarm
*
* Input Parameters:
* none
*
* Returned Value:
* Zero (OK) on success; a negated errno on failure
*
************************************************************************************/
#ifdef CONFIG_RTC_ALARM
int up_rtc_cancelalarm(void)
{
irqstate_t flags;
int ret = -ENODATA;
if (g_alarmcb != NULL)
{
/* Cancel the global callback function */
g_alarmcb = NULL;
/* Unset the alarm */
flags = irqsave();
stm32_rtc_beginwr();
putreg16(0xffff, STM32_RTC_ALRH);
putreg16(0xffff, STM32_RTC_ALRL);
stm32_rtc_endwr();
irqrestore(flags);
ret = OK;
}
return ret;
}
#endif