libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
rtc.c
Go to the documentation of this file.
1/** @defgroup rtc_file RTC peripheral API
2 *
3 * @ingroup peripheral_apis
4 *
5 * @brief <b>libopencm3 STM32F4xx RTC</b>
6 *
7 * @version 1.0.0
8 *
9 * @date 4 March 2013
10 *
11 * LGPL License Terms @ref lgpl_license
12 */
13
14/*
15 * This file is part of the libopencm3 project.
16 *
17 * This library is free software: you can redistribute it and/or modify
18 * it under the terms of the GNU Lesser General Public License as published by
19 * the Free Software Foundation, either version 3 of the License, or
20 * (at your option) any later version.
21 *
22 * This library is distributed in the hope that it will be useful,
23 * but WITHOUT ANY WARRANTY; without even the implied warranty of
24 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
25 * GNU Lesser General Public License for more details.
26 *
27 * You should have received a copy of the GNU Lesser General Public License
28 * along with this library. If not, see <http://www.gnu.org/licenses/>.
29 */
30
32#include <libopencm3/cm3/nvic.h>
34
35/**@{*/
36
37/*---------------------------------------------------------------------------*/
38/** @brief Enable the wakeup timer
39 @warning You must unlock the registers before using this function
40
41*/
43{
46}
47
48/*---------------------------------------------------------------------------*/
49/** @brief Disable the wakeup timer
50 @warning You must unlock the registers before using this function
51
52*/
54{
55 RTC_CR &= ~RTC_CR_WUTE;
57}
58
59/*---------------------------------------------------------------------------*/
60/** @brief Enable the wakeup timer interrupt
61 @warning You must unlock the registers before using this function
62
63*/
65{
66 /* FTFM:
67 * To enable the RTC Wakeup interrupt, the following sequence is
68 * required:
69 * 1. Configure and enable the EXTI Line 22 in interrupt mode and
70 * select the rising edge sensitivity.
71 */
74
75 /* 2. Configure and enable the RTC_WKUP IRQ channel in the NVIC. */
78
79 /* 3. Configure the RTC to generate the RTC wakeup timer event. */
80 RTC_CR |= RTC_CR_WUTIE; /* Enable the interrupt */
81}
82
83/*---------------------------------------------------------------------------*/
84/** @brief Disable the wakeup timer interrupt
85 @warning You must unlock the registers before using this function
86
87*/
89{
90 /* 1. Disable EXTI Line 22 */
92
93 /* 2. Disable RTC_WKUP IRQ channel in the NVIC. */
95
96 /* 3. Disable RTC wakeup timer event. */
97 RTC_CR &= ~RTC_CR_WUTIE;
98}
99
100/**@}*/
#define NVIC_RTC_WKUP_IRQ
Definition: stm32/f4/nvic.h:19
void nvic_set_priority(uint8_t irqn, uint8_t priority)
NVIC Set Interrupt Priority.
Definition: nvic.c:152
void nvic_enable_irq(uint8_t irqn)
NVIC Enable Interrupt.
Definition: nvic.c:57
void nvic_disable_irq(uint8_t irqn)
NVIC Disable Interrupt.
Definition: nvic.c:70
#define EXTI22
void exti_disable_request(uint32_t extis)
void exti_set_trigger(uint32_t extis, enum exti_trigger_type trig)
void exti_enable_request(uint32_t extis)
@ EXTI_TRIGGER_RISING
#define RTC_CR_OSEL_WAKEUP
#define RTC_CR_WUTE
Wakeup timer enable.
#define RTC_CR_WUTIE
Wakeup timer interrupt enable.
#define RTC_CR_OSEL_SHIFT
void rtc_enable_wakeup_timer(void)
Enable the wakeup timer.
Definition: rtc.c:42
void rtc_disable_wakeup_timer(void)
Disable the wakeup timer.
Definition: rtc.c:53
void rtc_disable_wakeup_timer_interrupt(void)
Disable the wakeup timer interrupt.
Definition: rtc.c:88
void rtc_enable_wakeup_timer_interrupt(void)
Enable the wakeup timer interrupt.
Definition: rtc.c:64
#define RTC_CR
RTC control register (RTC_CR)