summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-07-11 23:21:16 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-07-11 23:21:16 +0000
commitf2f04aeaa1ad971b4de143731e8a53912e638ffa (patch)
tree2fa53e1bfd0e4ea2254a5036f0e4936185c87cf0 /nuttx/arch/arm/src
parent25694ca4c649d667e7baa519434fae2d885cc6b7 (diff)
downloadpx4-nuttx-f2f04aeaa1ad971b4de143731e8a53912e638ffa.tar.gz
px4-nuttx-f2f04aeaa1ad971b4de143731e8a53912e638ffa.tar.bz2
px4-nuttx-f2f04aeaa1ad971b4de143731e8a53912e638ffa.zip
PM update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4932 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src')
-rw-r--r--nuttx/arch/arm/src/stm32/stm32f10xxx_rtc.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/nuttx/arch/arm/src/stm32/stm32f10xxx_rtc.c b/nuttx/arch/arm/src/stm32/stm32f10xxx_rtc.c
index 03be0ee3f..203f45450 100644
--- a/nuttx/arch/arm/src/stm32/stm32f10xxx_rtc.c
+++ b/nuttx/arch/arm/src/stm32/stm32f10xxx_rtc.c
@@ -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