libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
iwdg_common_all.h
Go to the documentation of this file.
1/** @addtogroup iwdg_defines
2
3@author @htmlonly &copy; @endhtmlonly 2010 Thomas Otto <tommi@viadmin.org>
4
5*/
6/*
7 * This file is part of the libopencm3 project.
8 *
9 * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
10 *
11 * This library is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as published by
13 * the Free Software Foundation, either version 3 of the License, or
14 * (at your option) any later version.
15 *
16 * This library is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public License
22 * along with this library. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA IWDG.H
26The order of header inclusion is important. iwdg.h includes the device
27specific memorymap.h header before including this header file.*/
28
29/** @cond */
30#ifdef LIBOPENCM3_IWDG_H
31/** @endcond */
32#ifndef LIBOPENCM3_IWDG_COMMON_ALL_H
33#define LIBOPENCM3_IWDG_COMMON_ALL_H
34
35/**@{*/
36
37/* --- IWDG registers ------------------------------------------------------ */
38
39/** Key Register (IWDG_KR) */
40#define IWDG_KR MMIO32(IWDG_BASE + 0x00)
41
42/** Prescaler register (IWDG_PR) */
43#define IWDG_PR MMIO32(IWDG_BASE + 0x04)
44
45/** Reload register (IWDG_RLR) */
46#define IWDG_RLR MMIO32(IWDG_BASE + 0x08)
47
48/** Status register (IWDG_SR) */
49#define IWDG_SR MMIO32(IWDG_BASE + 0x0c)
50
51/* --- IWDG_KR values ------------------------------------------------------ */
52
53/* Bits [31:16]: Reserved. */
54
55/* KEY[15:0]: Key value (write-only, reads as 0x0000) */
56/** @defgroup iwdg_key IWDG Key Values
57@ingroup iwdg_defines
58
59@{*/
60#define IWDG_KR_RESET 0xaaaa
61#define IWDG_KR_UNLOCK 0x5555
62#define IWDG_KR_START 0xcccc
63/**@}*/
64
65/* --- IWDG_PR values ------------------------------------------------------ */
66
67/* Bits [31:3]: Reserved. */
68
69/* PR[2:0]: Prescaler divider */
70#define IWDG_PR_LSB 0
71/** @defgroup iwdg_prediv IWDG prescaler divider
72@ingroup iwdg_defines
73
74@{*/
75#define IWDG_PR_DIV4 0x0
76#define IWDG_PR_DIV8 0x1
77#define IWDG_PR_DIV16 0x2
78#define IWDG_PR_DIV32 0x3
79#define IWDG_PR_DIV64 0x4
80#define IWDG_PR_DIV128 0x5
81#define IWDG_PR_DIV256 0x6
82/**@}*/
83/* Double definition: 0x06 and 0x07 both mean DIV256 as per datasheet. */
84/* #define IWDG_PR_DIV256 0x7 */
85
86/* --- IWDG_RLR values ----------------------------------------------------- */
87
88/* Bits [31:12]: Reserved. */
89
90/* RL[11:0]: Watchdog counter reload value */
91
92/** @defgroup iwdg_sr_values IWDG Status Register Values
93@ingroup iwdg_defines
94@{*/
95/** RVU: Watchdog counter reload value update */
96#define IWDG_SR_RVU (1 << 1)
97
98/** PVU: Watchdog prescaler value update */
99#define IWDG_SR_PVU (1 << 0)
100/**@}*/
101
102/* --- IWDG function prototypes---------------------------------------------- */
103
105
106void iwdg_start(void);
107void iwdg_set_period_ms(uint32_t period);
108bool iwdg_reload_busy(void);
109bool iwdg_prescaler_busy(void);
110void iwdg_reset(void);
111
113
114#endif
115/** @cond */
116#else
117#warning "iwdg_common_all.h should not be included explicitly, only via iwdg.h"
118#endif
119/** @endcond */
120/**@}*/
121
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void iwdg_start(void)
IWDG Enable Watchdog Timer.
void iwdg_set_period_ms(uint32_t period)
IWDG Set Period in Milliseconds.
bool iwdg_reload_busy(void)
IWDG Get Reload Register Status.
bool iwdg_prescaler_busy(void)
IWDG Get Prescaler Register Status.
void iwdg_reset(void)
IWDG reset Watchdog Timer.