From 207eb07d4c0c6a05fbcbfa289f232ba5667ec278 Mon Sep 17 00:00:00 2001 From: Guillaume Revaillot Date: Wed, 28 Mar 2018 13:34:51 +0200 Subject: [PATCH] stm32: centralize additionnal iwdg window register definition into iwdg-v2. stm32f0, l3, l4 are currently sharing the same duplicated header, and stm32l0 uses the same peripheral. Stop copy-pasting stuff and centralize definitions into a iwdg_common_v2.h header. --- .../libopencm3/stm32/common/iwdg_common_v2.h | 82 +++++++++++++++++++ include/libopencm3/stm32/f0/iwdg.h | 34 +------- include/libopencm3/stm32/f3/iwdg.h | 17 +--- include/libopencm3/stm32/l4/iwdg.h | 17 +--- 4 files changed, 85 insertions(+), 65 deletions(-) create mode 100644 include/libopencm3/stm32/common/iwdg_common_v2.h diff --git a/include/libopencm3/stm32/common/iwdg_common_v2.h b/include/libopencm3/stm32/common/iwdg_common_v2.h new file mode 100644 index 00000000..5c111624 --- /dev/null +++ b/include/libopencm3/stm32/common/iwdg_common_v2.h @@ -0,0 +1,82 @@ +/** @addtogroup iwdg_defines + + @author @htmlonly © @endhtmlonly 2018 Guillame Revaillot + + */ +/* + * This file is part of the libopencm3 project. + * + * Copyright (C) 2018 Guillaume Revaillot + * Copyright (C) 2010 Thomas Otto + * + * This library is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this library. If not, see . + */ + +/* THIS FILE SHOULD NOT BE INCLUDED DIRECTLY, BUT ONLY VIA IWDG.H +The order of header inclusion is important. iwdg.h includes the device +specific memorymap.h header before including this header file.*/ + +/** @cond */ +#ifdef LIBOPENCM3_IWDG_H +/** @endcond */ +#pragma once + +/**@{*/ + +#include + +/*****************************************************************************/ +/* Module definitions */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* Register definitions */ +/*****************************************************************************/ + +/* Key Register (IWDG_WINR) */ +#define IWDG_WINR MMIO32(IWDG_BASE + 0x10) + +/*****************************************************************************/ +/* Register values */ +/*****************************************************************************/ +/** @{*/ + +/* --- IWDG_SR values ------------------------------------------------------ */ + +/* WVU: Watchdog counter window value update */ +#define IWDG_SR_WVU (1 << 2) + +/**@}*/ + +/*****************************************************************************/ +/* API definitions */ +/*****************************************************************************/ + +/*****************************************************************************/ +/* API Functions */ +/*****************************************************************************/ + + +BEGIN_DECLS + +END_DECLS + +/**@}*/ + +/** @cond */ +#else +#warning "iwdg_common_v2.h should not be included explicitly, only via iwdg.h" +#endif +/** @endcond */ + diff --git a/include/libopencm3/stm32/f0/iwdg.h b/include/libopencm3/stm32/f0/iwdg.h index be9dc5ab..be7b6e92 100644 --- a/include/libopencm3/stm32/f0/iwdg.h +++ b/include/libopencm3/stm32/f0/iwdg.h @@ -33,38 +33,6 @@ #ifndef LIBOPENCM3_IWDG_H #define LIBOPENCM3_IWDG_H -#include - -/*****************************************************************************/ -/* Module definitions */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* Register definitions */ -/*****************************************************************************/ - -/* Key Register (IWDG_WINR) */ -#define IWDG_WINR MMIO32(IWDG_BASE + 0x10) - -/*****************************************************************************/ -/* Register values */ -/*****************************************************************************/ - -/* --- IWDG_SR values ------------------------------------------------------ */ - -/* WVU: Watchdog counter window value update */ -#define IWDG_SR_WVU (1 << 2) - -/*****************************************************************************/ -/* API definitions */ -/*****************************************************************************/ - -/*****************************************************************************/ -/* API Functions */ -/*****************************************************************************/ - -BEGIN_DECLS - -END_DECLS +#include #endif diff --git a/include/libopencm3/stm32/f3/iwdg.h b/include/libopencm3/stm32/f3/iwdg.h index 56d3a892..cf5b197f 100644 --- a/include/libopencm3/stm32/f3/iwdg.h +++ b/include/libopencm3/stm32/f3/iwdg.h @@ -33,21 +33,6 @@ #ifndef LIBOPENCM3_IWDG_H #define LIBOPENCM3_IWDG_H -#include - -/* --- IWDG registers ------------------------------------------------------ */ - -/* Window register (IWDG_WINR) */ -#define IWDG_WINR MMIO32(IWDG_BASE + 0x10) - -/* --- IWDG_SR values ------------------------------------------------------ */ - -/* WVU: Watchdog counter window value update */ -#define IWDG_SR_WVU (1 << 2) - -/* --- IWDG_WIN values ----------------------------------------------------- */ - -/* Bits 11:0 WIN[11:0]: Watchdog counter window value */ +#include #endif - diff --git a/include/libopencm3/stm32/l4/iwdg.h b/include/libopencm3/stm32/l4/iwdg.h index 7be0dbb4..e96cfd5d 100644 --- a/include/libopencm3/stm32/l4/iwdg.h +++ b/include/libopencm3/stm32/l4/iwdg.h @@ -32,21 +32,6 @@ #ifndef LIBOPENCM3_IWDG_H #define LIBOPENCM3_IWDG_H -#include - -/* --- IWDG registers ------------------------------------------------------ */ - -/* Window register (IWDG_WINR) */ -#define IWDG_WINR MMIO32(IWDG_BASE + 0x10) - -/* --- IWDG_SR values ------------------------------------------------------ */ - -/* WVU: Watchdog counter window value update */ -#define IWDG_SR_WVU (1 << 2) - -/* --- IWDG_WIN values ----------------------------------------------------- */ - -/* Bits 11:0 WIN[11:0]: Watchdog counter window value */ +#include #endif -