libopencm3
A free/libre/open-source firmware library for various ARM Cortex-M3 microcontrollers.
wdt.h
Go to the documentation of this file.
1/** @defgroup wdt_defines Watchdog Defines
2 *
3 * @brief <b>Defined Constants and Types for the SWM050 Watchdog</b>
4 *
5 * @ingroup SWM050_defines
6 *
7 * LGPL License Terms @ref lgpl_license
8 */
9/*
10 * This file is part of the libopencm3 project.
11 *
12 * Copyright (C) 2019 Caleb Szalacinski <contact@skiboy.net>
13 *
14 * This library is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU Lesser General Public License for more details.
23 *
24 * You should have received a copy of the GNU Lesser General Public License
25 * along with this library. If not, see <http://www.gnu.org/licenses/>.
26 */
27/**@{*/
28#ifndef LIBOPENCM3_WDT_H
29#define LIBOPENCM3_WDT_H
30
33
34/* Watchdog mode definitions */
35/** @defgroup wdt_modes Watchdog mode
36@{*/
38 /** On timeout, reset the system */
40 /** On timeout, generate an interrupt. If another timeout (time2) occurs without
41 the interrupt being cleared, reset the system. */
43};
44/**@}*/
45
46/** @defgroup wdt_registers Watchdog Registers
47@{*/
48#define WDT_CR MMIO32(WDT_BASE + 0x0)
49#define WDT_TORR MMIO32(WDT_BASE + 0x04)
50#define WDT_CCVR MMIO32(WDT_BASE + 0x08)
51#define WDT_CRR MMIO32(WDT_BASE + 0x0C)
52#define WDT_STAT MMIO32(WDT_BASE + 0x10)
53#define WDT_EOI MMIO32(WDT_BASE + 0x14)
54/**@}*/
55
57
58void wdt_setup(enum wdt_modes mode, uint8_t time1, uint8_t time2);
59void wdt_enable(bool en);
60void wdt_mode(enum wdt_modes mode);
61void wdt_reset(void);
62bool wdt_int_status(void);
63void wdt_clear_int(void);
64void wdt_clock_enable(bool en);
65uint32_t wdt_get_value(void);
66void wdt_set_time(uint8_t time1, uint8_t time2);
67
69
70#endif
71/**@}*/
#define END_DECLS
Definition: common.h:34
#define BEGIN_DECLS
Definition: common.h:33
void wdt_reset(void)
Reset the WDT's counter.
Definition: wdt.c:82
void wdt_mode(enum wdt_modes mode)
Sets the WDT's mode of operation.
Definition: wdt.c:68
void wdt_set_time(uint8_t time1, uint8_t time2)
Sets the WDT's initial counter values.
Definition: wdt.c:155
uint32_t wdt_get_value(void)
Gets the current WDT counter value.
Definition: wdt.c:130
void wdt_clear_int(void)
Clears the WDT's interrupt.
Definition: wdt.c:101
void wdt_enable(bool en)
Enables the WDT.
Definition: wdt.c:55
bool wdt_int_status(void)
Gets the WDT's interrupt status.
Definition: wdt.c:92
void wdt_clock_enable(bool en)
Enables the WDT's clock.
Definition: wdt.c:115
void wdt_setup(enum wdt_modes mode, uint8_t time1, uint8_t time2)
Sets up the WDT before the call to wdt_enable().
Definition: wdt.c:38
wdt_modes
Definition: wdt.h:37
@ WDT_MODE_RESET
On timeout, reset the system.
Definition: wdt.h:39
@ WDT_MODE_INT
On timeout, generate an interrupt.
Definition: wdt.h:42