summaryrefslogtreecommitdiffstats
path: root/libopencm3/include/libopencm3/stm32/f1
diff options
context:
space:
mode:
Diffstat (limited to 'libopencm3/include/libopencm3/stm32/f1')
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/adc.h420
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/bkp.h205
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/crc.h38
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/dac.h37
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/dma.h37
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/doc-stm32f1.h32
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/ethernet.h210
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/exti.h41
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/flash.h120
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/gpio.h955
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/i2c.h37
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/irq.json75
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/iwdg.h39
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/memorymap.h127
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/pwr.h37
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/rcc.h718
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/rtc.h170
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/spi.h37
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/timer.h56
-rw-r--r--libopencm3/include/libopencm3/stm32/f1/usart.h37
20 files changed, 3428 insertions, 0 deletions
diff --git a/libopencm3/include/libopencm3/stm32/f1/adc.h b/libopencm3/include/libopencm3/stm32/f1/adc.h
new file mode 100644
index 0000000..ec7cabc
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/adc.h
@@ -0,0 +1,420 @@
+/** @defgroup adc_defines ADC Defines
+
+@brief <b>Defined Constants and Types for the STM32F1xx Analog to Digital
+Converters</b>
+
+@ingroup STM32F1xx_defines
+
+@version 1.0.0
+
+@author @htmlonly &copy; @endhtmlonly 2009
+Edward Cheeseman <evbuilder@users.sourceforge.net>
+
+@date 18 August 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2009 Edward Cheeseman <evbuilder@users.sourceforge.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**@{*/
+
+#ifndef LIBOPENCM3_ADC_H
+#define LIBOPENCM3_ADC_H
+
+#include <libopencm3/stm32/common/adc_common_v1.h>
+
+/* --- Convenience macros -------------------------------------------------- */
+
+/* ADC injected channel data offset register x (ADC_JOFRx) (x=1..4) */
+#define ADC_JOFR1(block) MMIO32(block + 0x14)
+#define ADC_JOFR2(block) MMIO32(block + 0x18)
+#define ADC_JOFR3(block) MMIO32(block + 0x1c)
+#define ADC_JOFR4(block) MMIO32(block + 0x20)
+
+/* ADC watchdog high threshold register (ADC_HTR) */
+#define ADC_HTR(block) MMIO32(block + 0x24)
+
+/* ADC watchdog low threshold register (ADC_LTR) */
+#define ADC_LTR(block) MMIO32(block + 0x28)
+
+/* ADC regular sequence register 1 (ADC_SQR1) */
+#define ADC_SQR1(block) MMIO32(block + 0x2c)
+
+/* ADC regular sequence register 2 (ADC_SQR2) */
+#define ADC_SQR2(block) MMIO32(block + 0x30)
+
+/* ADC regular sequence register 3 (ADC_SQR3) */
+#define ADC_SQR3(block) MMIO32(block + 0x34)
+
+/* ADC injected sequence register (ADC_JSQR) */
+#define ADC_JSQR(block) MMIO32(block + 0x38)
+
+/* ADC injected data register x (ADC_JDRx) (x=1..4) */
+#define ADC_JDR1(block) MMIO32(block + 0x3c)
+#define ADC_JDR2(block) MMIO32(block + 0x40)
+#define ADC_JDR3(block) MMIO32(block + 0x44)
+#define ADC_JDR4(block) MMIO32(block + 0x48)
+
+/* ADC regular data register (ADC_DR) */
+#define ADC_DR(block) MMIO32(block + 0x4c)
+
+/* --- ADC Channels ------------------------------------------------------- */
+#define ADC_CHANNEL_TEMP ADC_CHANNEL16
+#define ADC_CHANNEL_VREFINT ADC_CHANNEL17
+
+
+/* --- ADC_CR1 values ------------------------------------------------------ */
+
+/* Note: Bits [21:20] are reserved, and must be kept at reset value. */
+
+/* DUALMOD[3:0]: Dual mode selection. (ADC1 only) */
+/* Legend:
+ * IND: Independent mode.
+ * CRSISM: Combined regular simultaneous + injected simultaneous mode.
+ * CRSATM: Combined regular simultaneous + alternate trigger mode.
+ * CISFIM: Combined injected simultaneous + fast interleaved mode.
+ * CISSIM: Combined injected simultaneous + slow interleaved mode.
+ * ISM: Injected simultaneous mode only.
+ * RSM: Regular simultaneous mode only.
+ * FIM: Fast interleaved mode only.
+ * SIM: Slow interleaved mode only.
+ * ATM: Alternate trigger mode only.
+ */
+/****************************************************************************/
+/* ADC_CR1 DUALMOD[3:0] ADC Mode Selection */
+/** @defgroup adc_cr1_dualmod ADC Mode Selection
+@ingroup adc_defines
+
+@{*/
+/** Independent (non-dual) mode */
+#define ADC_CR1_DUALMOD_IND (0x0 << 16)
+/** Combined regular simultaneous + injected simultaneous mode. */
+#define ADC_CR1_DUALMOD_CRSISM (0x1 << 16)
+/** Combined regular simultaneous + alternate trigger mode. */
+#define ADC_CR1_DUALMOD_CRSATM (0x2 << 16)
+/** Combined injected simultaneous + fast interleaved mode. */
+#define ADC_CR1_DUALMOD_CISFIM (0x3 << 16)
+/** Combined injected simultaneous + slow interleaved mode. */
+#define ADC_CR1_DUALMOD_CISSIM (0x4 << 16)
+/** Injected simultaneous mode only. */
+#define ADC_CR1_DUALMOD_ISM (0x5 << 16)
+/** Regular simultaneous mode only. */
+#define ADC_CR1_DUALMOD_RSM (0x6 << 16)
+/** Fast interleaved mode only. */
+#define ADC_CR1_DUALMOD_FIM (0x7 << 16)
+/** Slow interleaved mode only. */
+#define ADC_CR1_DUALMOD_SIM (0x8 << 16)
+/** Alternate trigger mode only. */
+#define ADC_CR1_DUALMOD_ATM (0x9 << 16)
+/**@}*/
+#define ADC_CR1_DUALMOD_MASK (0xF << 16)
+#define ADC_CR1_DUALMOD_SHIFT 16
+
+#define ADC_CR1_AWDCH_MAX 17
+
+/* --- ADC_CR2 values ------------------------------------------------------ */
+
+/* TSVREFE: */ /** Temperature sensor and V_REFINT enable. (ADC1 only!) */
+#define ADC_CR2_TSVREFE (1 << 23)
+
+/* SWSTART: */ /** Start conversion of regular channels. */
+#define ADC_CR2_SWSTART (1 << 22)
+
+/* JSWSTART: */ /** Start conversion of injected channels. */
+#define ADC_CR2_JSWSTART (1 << 21)
+
+/* EXTTRIG: */ /** External trigger conversion mode for regular channels. */
+#define ADC_CR2_EXTTRIG (1 << 20)
+
+/* EXTSEL[2:0]: External event select for regular group. */
+/* The following are only valid for ADC1 and ADC2. */
+/****************************************************************************/
+/* ADC_CR2 EXTSEL[2:0] ADC Trigger Identifier for ADC1 and ADC2 */
+/** @defgroup adc_trigger_regular_12 ADC Trigger Identifier for ADC1 and ADC2
+@ingroup adc_defines
+
+@{*/
+/** Timer 1 Compare Output 1 */
+#define ADC_CR2_EXTSEL_TIM1_CC1 (0x0 << 17)
+/** Timer 1 Compare Output 2 */
+#define ADC_CR2_EXTSEL_TIM1_CC2 (0x1 << 17)
+/** Timer 1 Compare Output 3 */
+#define ADC_CR2_EXTSEL_TIM1_CC3 (0x2 << 17)
+/** Timer 2 Compare Output 2 */
+#define ADC_CR2_EXTSEL_TIM2_CC2 (0x3 << 17)
+/** Timer 3 Trigger Output */
+#define ADC_CR2_EXTSEL_TIM3_TRGO (0x4 << 17)
+/** Timer 4 Compare Output 4 */
+#define ADC_CR2_EXTSEL_TIM4_CC4 (0x5 << 17)
+/** External Interrupt 11 */
+#define ADC_CR2_EXTSEL_EXTI11 (0x6 << 17)
+/** Software Trigger */
+#define ADC_CR2_EXTSEL_SWSTART (0x7 << 17)
+/**@}*/
+
+/* The following are only valid for ADC3 */
+/****************************************************************************/
+/* ADC_CR2 EXTSEL[2:0] ADC Trigger Identifier for ADC3 */
+/** @defgroup adc_trigger_regular_3 ADC Trigger Identifier for ADC3
+@ingroup adc_defines
+
+@{*/
+/** Timer 2 Compare Output 1 */
+#define ADC_CR2_EXTSEL_TIM3_CC1 (0x0 << 17)
+/** Timer 2 Compare Output 3 */
+#define ADC_CR2_EXTSEL_TIM2_CC3 (0x1 << 17)
+/** Timer 1 Compare Output 3 */
+#define ADC_CR2_EXTSEL_TIM1_CC3 (0x2 << 17)
+/** Timer 8 Compare Output 1 */
+#define ADC_CR2_EXTSEL_TIM8_CC1 (0x3 << 17)
+/** Timer 8 Trigger Output */
+#define ADC_CR2_EXTSEL_TIM8_TRGO (0x4 << 17)
+/** Timer 5 Compare Output 1 */
+#define ADC_CR2_EXTSEL_TIM5_CC1 (0x5 << 17)
+/** Timer 5 Compare Output 3 */
+#define ADC_CR2_EXTSEL_TIM5_CC3 (0x6 << 17)
+/**@}*/
+
+#define ADC_CR2_EXTSEL_MASK (0x7 << 17)
+#define ADC_CR2_EXTSEL_SHIFT 17
+
+/* Note: Bit 16 is reserved, must be kept at reset value. */
+
+/* JEXTTRIG: External trigger conversion mode for injected channels. */
+#define ADC_CR2_JEXTTRIG (1 << 15)
+
+/* JEXTSEL[2:0]: External event selection for injected group. */
+/* The following are only valid for ADC1 and ADC2. */
+/****************************************************************************/
+/* ADC_CR2 JEXTSEL[2:0] ADC Injected Trigger Identifier for ADC1 and ADC2 */
+/** @defgroup adc_trigger_injected_12 ADC Injected Trigger Identifier for ADC1
+and ADC2
+@ingroup adc_defines
+
+@{*/
+/** Timer 1 Trigger Output */
+#define ADC_CR2_JEXTSEL_TIM1_TRGO (0x0 << 12)
+/** Timer 1 Compare Output 4 */
+#define ADC_CR2_JEXTSEL_TIM1_CC4 (0x1 << 12)
+/** Timer 2 Trigger Output */
+#define ADC_CR2_JEXTSEL_TIM2_TRGO (0x2 << 12)
+/** Timer 2 Compare Output 1 */
+#define ADC_CR2_JEXTSEL_TIM2_CC1 (0x3 << 12)
+/** Timer 3 Compare Output 4 */
+#define ADC_CR2_JEXTSEL_TIM3_CC4 (0x4 << 12)
+/** Timer 4 Trigger Output */
+#define ADC_CR2_JEXTSEL_TIM4_TRGO (0x5 << 12)
+/** External Interrupt 15 */
+#define ADC_CR2_JEXTSEL_EXTI15 (0x6 << 12)
+/** Injected Software Trigger */
+#define ADC_CR2_JEXTSEL_JSWSTART (0x7 << 12) /* Software start. */
+/**@}*/
+
+/* The following are the different meanings for ADC3 only. */
+/****************************************************************************/
+/* ADC_CR2 JEXTSEL[2:0] ADC Injected Trigger Identifier for ADC3 */
+/** @defgroup adc_trigger_injected_3 ADC Injected Trigger Identifier for ADC3
+@ingroup adc_defines
+
+@{*/
+/** Timer 1 Trigger Output */
+#define ADC_CR2_JEXTSEL_TIM1_TRGO (0x0 << 12)
+/** Timer 1 Compare Output 4 */
+#define ADC_CR2_JEXTSEL_TIM1_CC4 (0x1 << 12)
+/** Timer 4 Compare Output 3 */
+#define ADC_CR2_JEXTSEL_TIM4_CC3 (0x2 << 12)
+/** Timer 8 Compare Output 2 */
+#define ADC_CR2_JEXTSEL_TIM8_CC2 (0x3 << 12)
+/** Timer 8 Compare Output 4 */
+#define ADC_CR2_JEXTSEL_TIM8_CC4 (0x4 << 12)
+/** Timer 5 Trigger Output */
+#define ADC_CR2_JEXTSEL_TIM5_TRGO (0x5 << 12)
+/** Timer 5 Compare Output 4 */
+#define ADC_CR2_JEXTSEL_TIM5_CC4 (0x6 << 12)
+/** Injected Software Trigger */
+#define ADC_CR2_JEXTSEL_JSWSTART (0x7 << 12) /* Software start. */
+/**@}*/
+
+#define ADC_CR2_JEXTSEL_MASK (0x7 << 12)
+#define ADC_CR2_JEXTSEL_SHIFT 12
+
+/* ALIGN: Data alignment. */
+#define ADC_CR2_ALIGN_RIGHT (0 << 11)
+#define ADC_CR2_ALIGN_LEFT (1 << 11)
+#define ADC_CR2_ALIGN (1 << 11)
+
+/* Note: Bits [10:9] are reserved and must be kept at reset value. */
+
+/* DMA: Direct memory access mode. (ADC1 and ADC3 only!) */
+#define ADC_CR2_DMA (1 << 8)
+
+/* Note: Bits [7:4] are reserved and must be kept at reset value. */
+
+/* RSTCAL: Reset calibration. */
+#define ADC_CR2_RSTCAL (1 << 3)
+
+/* CAL: A/D Calibration. */
+#define ADC_CR2_CAL (1 << 2)
+
+/* CONT: Continous conversion. */
+#define ADC_CR2_CONT (1 << 1)
+
+/* ADON: A/D converter On/Off. */
+/* Note: If any other bit in this register apart from ADON is changed at the
+ * same time, then conversion is not triggered. This is to prevent triggering
+ * an erroneous conversion.
+ * Conclusion: Must be separately written.
+ */
+#define ADC_CR2_ADON (1 << 0)
+
+/* --- ADC_SMPR1 values ---------------------------------------------------- */
+#define ADC_SMPR1_SMP17_LSB 21
+#define ADC_SMPR1_SMP16_LSB 18
+#define ADC_SMPR1_SMP15_LSB 15
+#define ADC_SMPR1_SMP14_LSB 12
+#define ADC_SMPR1_SMP13_LSB 9
+#define ADC_SMPR1_SMP12_LSB 6
+#define ADC_SMPR1_SMP11_LSB 3
+#define ADC_SMPR1_SMP10_LSB 0
+#define ADC_SMPR1_SMP17_MSK (0x7 << ADC_SMP17_LSB)
+#define ADC_SMPR1_SMP16_MSK (0x7 << ADC_SMP16_LSB)
+#define ADC_SMPR1_SMP15_MSK (0x7 << ADC_SMP15_LSB)
+#define ADC_SMPR1_SMP14_MSK (0x7 << ADC_SMP14_LSB)
+#define ADC_SMPR1_SMP13_MSK (0x7 << ADC_SMP13_LSB)
+#define ADC_SMPR1_SMP12_MSK (0x7 << ADC_SMP12_LSB)
+#define ADC_SMPR1_SMP11_MSK (0x7 << ADC_SMP11_LSB)
+#define ADC_SMPR1_SMP10_MSK (0x7 << ADC_SMP10_LSB)
+
+/* --- ADC_SMPR2 values ---------------------------------------------------- */
+
+#define ADC_SMPR2_SMP9_LSB 27
+#define ADC_SMPR2_SMP8_LSB 24
+#define ADC_SMPR2_SMP7_LSB 21
+#define ADC_SMPR2_SMP6_LSB 18
+#define ADC_SMPR2_SMP5_LSB 15
+#define ADC_SMPR2_SMP4_LSB 12
+#define ADC_SMPR2_SMP3_LSB 9
+#define ADC_SMPR2_SMP2_LSB 6
+#define ADC_SMPR2_SMP1_LSB 3
+#define ADC_SMPR2_SMP0_LSB 0
+#define ADC_SMPR2_SMP9_MSK (0x7 << ADC_SMP9_LSB)
+#define ADC_SMPR2_SMP8_MSK (0x7 << ADC_SMP8_LSB)
+#define ADC_SMPR2_SMP7_MSK (0x7 << ADC_SMP7_LSB)
+#define ADC_SMPR2_SMP6_MSK (0x7 << ADC_SMP6_LSB)
+#define ADC_SMPR2_SMP5_MSK (0x7 << ADC_SMP5_LSB)
+#define ADC_SMPR2_SMP4_MSK (0x7 << ADC_SMP4_LSB)
+#define ADC_SMPR2_SMP3_MSK (0x7 << ADC_SMP3_LSB)
+#define ADC_SMPR2_SMP2_MSK (0x7 << ADC_SMP2_LSB)
+#define ADC_SMPR2_SMP1_MSK (0x7 << ADC_SMP1_LSB)
+#define ADC_SMPR2_SMP0_MSK (0x7 << ADC_SMP0_LSB)
+
+/* --- ADC_SMPRx values --------------------------------------------------- */
+/****************************************************************************/
+/* ADC_SMPRG ADC Sample Time Selection for Channels */
+/** @defgroup adc_sample_rg ADC Sample Time Selection for All Channels
+@ingroup adc_defines
+
+@{*/
+#define ADC_SMPR_SMP_1DOT5CYC 0x0
+#define ADC_SMPR_SMP_7DOT5CYC 0x1
+#define ADC_SMPR_SMP_13DOT5CYC 0x2
+#define ADC_SMPR_SMP_28DOT5CYC 0x3
+#define ADC_SMPR_SMP_41DOT5CYC 0x4
+#define ADC_SMPR_SMP_55DOT5CYC 0x5
+#define ADC_SMPR_SMP_71DOT5CYC 0x6
+#define ADC_SMPR_SMP_239DOT5CYC 0x7
+/**@}*/
+
+
+/* --- ADC_SQR1 values ----------------------------------------------------- */
+
+#define ADC_SQR_MAX_CHANNELS_REGULAR 16
+
+#define ADC_SQR1_SQ16_LSB 15
+#define ADC_SQR1_SQ15_LSB 10
+#define ADC_SQR1_SQ14_LSB 5
+#define ADC_SQR1_SQ13_LSB 0
+#define ADC_SQR1_L_MSK (0xf << ADC_SQR1_L_LSB)
+#define ADC_SQR1_SQ16_MSK (0x1f << ADC_SQR1_SQ16_LSB)
+#define ADC_SQR1_SQ15_MSK (0x1f << ADC_SQR1_SQ15_LSB)
+#define ADC_SQR1_SQ14_MSK (0x1f << ADC_SQR1_SQ14_LSB)
+#define ADC_SQR1_SQ13_MSK (0x1f << ADC_SQR1_SQ13_LSB)
+
+/* --- ADC_SQR2 values ----------------------------------------------------- */
+
+#define ADC_SQR2_SQ12_LSB 25
+#define ADC_SQR2_SQ11_LSB 20
+#define ADC_SQR2_SQ10_LSB 15
+#define ADC_SQR2_SQ9_LSB 10
+#define ADC_SQR2_SQ8_LSB 5
+#define ADC_SQR2_SQ7_LSB 0
+#define ADC_SQR2_SQ12_MSK (0x1f << ADC_SQR2_SQ12_LSB)
+#define ADC_SQR2_SQ11_MSK (0x1f << ADC_SQR2_SQ11_LSB)
+#define ADC_SQR2_SQ10_MSK (0x1f << ADC_SQR2_SQ10_LSB)
+#define ADC_SQR2_SQ9_MSK (0x1f << ADC_SQR2_SQ9_LSB)
+#define ADC_SQR2_SQ8_MSK (0x1f << ADC_SQR2_SQ8_LSB)
+#define ADC_SQR2_SQ7_MSK (0x1f << ADC_SQR2_SQ7_LSB)
+
+/* --- ADC_SQR3 values ----------------------------------------------------- */
+
+#define ADC_SQR3_SQ6_LSB 25
+#define ADC_SQR3_SQ5_LSB 20
+#define ADC_SQR3_SQ4_LSB 15
+#define ADC_SQR3_SQ3_LSB 10
+#define ADC_SQR3_SQ2_LSB 5
+#define ADC_SQR3_SQ1_LSB 0
+#define ADC_SQR3_SQ6_MSK (0x1f << ADC_SQR3_SQ6_LSB)
+#define ADC_SQR3_SQ5_MSK (0x1f << ADC_SQR3_SQ5_LSB)
+#define ADC_SQR3_SQ4_MSK (0x1f << ADC_SQR3_SQ4_LSB)
+#define ADC_SQR3_SQ3_MSK (0x1f << ADC_SQR3_SQ3_LSB)
+#define ADC_SQR3_SQ2_MSK (0x1f << ADC_SQR3_SQ2_LSB)
+#define ADC_SQR3_SQ1_MSK (0x1f << ADC_SQR3_SQ1_LSB)
+
+/* --- ADC_JDRx, ADC_DR values --------------------------------------------- */
+
+#define ADC_JDATA_LSB 0
+#define ADC_DATA_LSB 0
+#define ADC_ADC2DATA_LSB 16 /* ADC1 only (dual mode) */
+#define ADC_JDATA_MSK (0xffff << ADC_JDATA_LSB)
+#define ADC_DATA_MSK (0xffff << ADC_DA)
+#define ADC_ADC2DATA_MSK (0xffff << ADC_ADC2DATA_LSB)
+ /* ADC1 only (dual mode) */
+
+/* --- Function prototypes ------------------------------------------------- */
+
+BEGIN_DECLS
+
+void adc_start_conversion_direct(uint32_t adc);
+void adc_set_single_channel(uint32_t adc, uint8_t channel);
+void adc_set_dual_mode(uint32_t mode);
+void adc_enable_temperature_sensor(uint32_t adc);
+void adc_disable_temperature_sensor(uint32_t adc);
+void adc_enable_external_trigger_regular(uint32_t adc, uint32_t trigger);
+void adc_enable_external_trigger_injected(uint32_t adc, uint32_t trigger);
+void adc_reset_calibration(uint32_t adc);
+void adc_calibration(uint32_t adc);
+void adc_on(uint32_t adc)
+ LIBOPENCM3_DEPRECATED("will be removed in the first release");
+
+END_DECLS
+
+#endif
+/**@}*/
+
diff --git a/libopencm3/include/libopencm3/stm32/f1/bkp.h b/libopencm3/include/libopencm3/stm32/f1/bkp.h
new file mode 100644
index 0000000..3d36a1f
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/bkp.h
@@ -0,0 +1,205 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_BKP_H
+#define LIBOPENCM3_BKP_H
+
+/* --- BKP registers ------------------------------------------------------- */
+
+/* Backup data register 1 (BKP_DR1) */
+#define BKP_DR1 MMIO32(BACKUP_REGS_BASE + 0x04)
+
+/* Backup data register 2 (BKP_DR2) */
+#define BKP_DR2 MMIO32(BACKUP_REGS_BASE + 0x08)
+
+/* Backup data register 3 (BKP_DR3) */
+#define BKP_DR3 MMIO32(BACKUP_REGS_BASE + 0x0C)
+
+/* Backup data register 4 (BKP_DR4) */
+#define BKP_DR4 MMIO32(BACKUP_REGS_BASE + 0x10)
+
+/* Backup data register 5 (BKP_DR5) */
+#define BKP_DR5 MMIO32(BACKUP_REGS_BASE + 0x14)
+
+/* Backup data register 6 (BKP_DR6) */
+#define BKP_DR6 MMIO32(BACKUP_REGS_BASE + 0x18)
+
+/* Backup data register 7 (BKP_DR7) */
+#define BKP_DR7 MMIO32(BACKUP_REGS_BASE + 0x1C)
+
+/* Backup data register 8 (BKP_DR8) */
+#define BKP_DR8 MMIO32(BACKUP_REGS_BASE + 0x20)
+
+/* Backup data register 9 (BKP_DR9) */
+#define BKP_DR9 MMIO32(BACKUP_REGS_BASE + 0x24)
+
+/* Backup data register 10 (BKP_DR10) */
+#define BKP_DR10 MMIO32(BACKUP_REGS_BASE + 0x28)
+
+/* RTC clock calibration register (BKP_RTCCR) */
+#define BKP_RTCCR MMIO32(BACKUP_REGS_BASE + 0x2C)
+
+/* Backup control register (BKP_CR) */
+#define BKP_CR MMIO32(BACKUP_REGS_BASE + 0x30)
+
+/* Backup control/status register (BKP_CSR) */
+#define BKP_CSR MMIO32(BACKUP_REGS_BASE + 0x34)
+
+/* Backup data register 11 (BKP_DR11) */
+#define BKP_DR11 MMIO32(BACKUP_REGS_BASE + 0x40)
+
+/* Backup data register 12 (BKP_DR12) */
+#define BKP_DR12 MMIO32(BACKUP_REGS_BASE + 0x44)
+
+/* Backup data register 13 (BKP_DR13) */
+#define BKP_DR13 MMIO32(BACKUP_REGS_BASE + 0x48)
+
+/* Backup data register 14 (BKP_DR14) */
+#define BKP_DR14 MMIO32(BACKUP_REGS_BASE + 0x4C)
+
+/* Backup data register 15 (BKP_DR15) */
+#define BKP_DR15 MMIO32(BACKUP_REGS_BASE + 0x50)
+
+/* Backup data register 16 (BKP_DR16) */
+#define BKP_DR16 MMIO32(BACKUP_REGS_BASE + 0x54)
+
+/* Backup data register 17 (BKP_DR17) */
+#define BKP_DR17 MMIO32(BACKUP_REGS_BASE + 0x58)
+
+/* Backup data register 18 (BKP_DR18) */
+#define BKP_DR18 MMIO32(BACKUP_REGS_BASE + 0x5C)
+
+/* Backup data register 19 (BKP_DR19) */
+#define BKP_DR19 MMIO32(BACKUP_REGS_BASE + 0x60)
+
+/* Backup data register 20 (BKP_DR20) */
+#define BKP_DR20 MMIO32(BACKUP_REGS_BASE + 0x64)
+
+/* Backup data register 21 (BKP_DR21) */
+#define BKP_DR21 MMIO32(BACKUP_REGS_BASE + 0x68)
+
+/* Backup data register 22 (BKP_DR22) */
+#define BKP_DR22 MMIO32(BACKUP_REGS_BASE + 0x6C)
+
+/* Backup data register 23 (BKP_DR23) */
+#define BKP_DR23 MMIO32(BACKUP_REGS_BASE + 0x70)
+
+/* Backup data register 24 (BKP_DR24) */
+#define BKP_DR24 MMIO32(BACKUP_REGS_BASE + 0x74)
+
+/* Backup data register 25 (BKP_DR25) */
+#define BKP_DR25 MMIO32(BACKUP_REGS_BASE + 0x78)
+
+/* Backup data register 26 (BKP_DR26) */
+#define BKP_DR26 MMIO32(BACKUP_REGS_BASE + 0x7C)
+
+/* Backup data register 27 (BKP_DR27) */
+#define BKP_DR27 MMIO32(BACKUP_REGS_BASE + 0x80)
+
+/* Backup data register 28 (BKP_DR28) */
+#define BKP_DR28 MMIO32(BACKUP_REGS_BASE + 0x84)
+
+/* Backup data register 29 (BKP_DR29) */
+#define BKP_DR29 MMIO32(BACKUP_REGS_BASE + 0x88)
+
+/* Backup data register 30 (BKP_DR30) */
+#define BKP_DR30 MMIO32(BACKUP_REGS_BASE + 0x8C)
+
+/* Backup data register 31 (BKP_DR31) */
+#define BKP_DR31 MMIO32(BACKUP_REGS_BASE + 0x90)
+
+/* Backup data register 32 (BKP_DR32) */
+#define BKP_DR32 MMIO32(BACKUP_REGS_BASE + 0x94)
+
+/* Backup data register 33 (BKP_DR33) */
+#define BKP_DR33 MMIO32(BACKUP_REGS_BASE + 0x98)
+
+/* Backup data register 34 (BKP_DR34) */
+#define BKP_DR34 MMIO32(BACKUP_REGS_BASE + 0x9C)
+
+/* Backup data register 35 (BKP_DR35) */
+#define BKP_DR35 MMIO32(BACKUP_REGS_BASE + 0xA0)
+
+/* Backup data register 36 (BKP_DR36) */
+#define BKP_DR36 MMIO32(BACKUP_REGS_BASE + 0xA4)
+
+/* Backup data register 37 (BKP_DR37) */
+#define BKP_DR37 MMIO32(BACKUP_REGS_BASE + 0xA8)
+
+/* Backup data register 38 (BKP_DR38) */
+#define BKP_DR38 MMIO32(BACKUP_REGS_BASE + 0xAC)
+
+/* Backup data register 39 (BKP_DR39) */
+#define BKP_DR39 MMIO32(BACKUP_REGS_BASE + 0xB0)
+
+/* Backup data register 40 (BKP_DR40) */
+#define BKP_DR40 MMIO32(BACKUP_REGS_BASE + 0xB4)
+
+/* Backup data register 41 (BKP_DR41) */
+#define BKP_DR41 MMIO32(BACKUP_REGS_BASE + 0xB8)
+
+/* Backup data register 42 (BKP_DR42) */
+#define BKP_DR42 MMIO32(BACKUP_REGS_BASE + 0xBC)
+
+/* --- BKP_RTCCR values ---------------------------------------------------- */
+
+/* ASOS: Alarm or second output selection */
+#define BKP_RTCCR_ASOS (1 << 9)
+
+/* ASOE: Alarm or second output enable */
+#define BKP_RTCCR_ASOE (1 << 8)
+
+/* CCO: Calibration clock output */
+#define BKP_RTCCR_CCO (1 << 7)
+
+/* CAL[6:0]: Calibration value */
+#define BKP_RTCCR_CAL_LSB 0
+
+/* --- BKP_CR values ------------------------------------------------------- */
+
+/* TPAL: TAMPER pin active level */
+#define BKP_CR_TAL (1 << 1)
+
+/* TPE: TAMPER pin enable */
+#define BKP_CR_TPE (1 << 0)
+
+/* --- BKP_CSR values ------------------------------------------------------ */
+
+/* TIF: Tamper interrupt flag */
+#define BKP_CSR_TIF (1 << 9)
+
+/* TEF: Tamper event flag */
+#define BKP_CSR_TEF (1 << 8)
+
+/* TPIE: TAMPER pin interrupt enable */
+#define BKP_CSR_TPIE (1 << 2)
+
+/* CTI: Clear tamper interrupt */
+#define BKP_CSR_CTI (1 << 1)
+
+/* CTE: Clear tamper event */
+#define BKP_CSR_CTE (1 << 0)
+
+/* --- BKP_DRx values ------------------------------------------------------ */
+
+/* Bits[15:0]: Backup data */
+
+/* --- BKP function prototypes --------------------------------------------- */
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/f1/crc.h b/libopencm3/include/libopencm3/stm32/f1/crc.h
new file mode 100644
index 0000000..a35bf49
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/crc.h
@@ -0,0 +1,38 @@
+/** @defgroup crc_defines CRC Defines
+
+@brief <b>libopencm3 Defined Constants and Types for the STM32F1xx CRC
+Generator </b>
+
+@ingroup STM32F1xx_defines
+
+@version 1.0.0
+
+@date 18 August 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_CRC_H
+#define LIBOPENCM3_CRC_H
+
+#include <libopencm3/stm32/common/crc_common_all.h>
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/f1/dac.h b/libopencm3/include/libopencm3/stm32/f1/dac.h
new file mode 100644
index 0000000..145df73
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/dac.h
@@ -0,0 +1,37 @@
+/** @defgroup dac_defines DAC Defines
+
+@brief <b>Defined Constants and Types for the STM32F1xx DAC</b>
+
+@ingroup STM32F1xx_defines
+
+@version 1.0.0
+
+@date 5 December 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_DAC_H
+#define LIBOPENCM3_DAC_H
+
+#include <libopencm3/stm32/common/dac_common_all.h>
+
+#endif
+
diff --git a/libopencm3/include/libopencm3/stm32/f1/dma.h b/libopencm3/include/libopencm3/stm32/f1/dma.h
new file mode 100644
index 0000000..ac73090
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/dma.h
@@ -0,0 +1,37 @@
+/** @defgroup dma_defines DMA Defines
+
+@ingroup STM32F1xx_defines
+
+@brief Defined Constants and Types for the STM32F1xx DMA Controller
+
+@version 1.0.0
+
+@date 30 November 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_DMA_H
+#define LIBOPENCM3_DMA_H
+
+#include <libopencm3/stm32/common/dma_common_l1f013.h>
+
+#endif
+
diff --git a/libopencm3/include/libopencm3/stm32/f1/doc-stm32f1.h b/libopencm3/include/libopencm3/stm32/f1/doc-stm32f1.h
new file mode 100644
index 0000000..4e1407e
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/doc-stm32f1.h
@@ -0,0 +1,32 @@
+/** @mainpage libopencm3 STM32F1
+
+@version 1.0.0
+
+@date 7 September 2012
+
+API documentation for ST Microelectronics STM32F1 Cortex M3 series.
+
+LGPL License Terms @ref lgpl_license
+*/
+
+/** @defgroup STM32F1xx STM32F1xx
+Libraries for ST Microelectronics STM32F1xx series.
+
+@version 1.0.0
+
+@date 7 September 2012
+
+LGPL License Terms @ref lgpl_license
+*/
+
+/** @defgroup STM32F1xx_defines STM32F1xx Defines
+
+@brief Defined Constants and Types for the STM32F1xx series
+
+@version 1.0.0
+
+@date 7 September 2012
+
+LGPL License Terms @ref lgpl_license
+*/
+
diff --git a/libopencm3/include/libopencm3/stm32/f1/ethernet.h b/libopencm3/include/libopencm3/stm32/f1/ethernet.h
new file mode 100644
index 0000000..5598cce
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/ethernet.h
@@ -0,0 +1,210 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Gareth McMullin <gareth@blacksphere.co.nz>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#include <libopencm3/cm3/common.h>
+#include <libopencm3/stm32/memorymap.h>
+
+#ifndef LIBOPENCM3_ETHERNET_H
+#define LIBOPENCM3_ETHERNET_H
+
+/* Ethernet MAC registers */
+#define ETH_MACCR MMIO32(ETHERNET_BASE + 0x00)
+#define ETH_MACFFR MMIO32(ETHERNET_BASE + 0x04)
+#define ETH_MACHTHR MMIO32(ETHERNET_BASE + 0x08)
+#define ETH_MACHTLR MMIO32(ETHERNET_BASE + 0x0C)
+#define ETH_MACMIIAR MMIO32(ETHERNET_BASE + 0x10)
+#define ETH_MACMIIDR MMIO32(ETHERNET_BASE + 0x14)
+#define ETH_MACFCR MMIO32(ETHERNET_BASE + 0x18)
+#define ETH_MACVLANTR MMIO32(ETHERNET_BASE + 0x1C)
+#define ETH_MACRWUFFR MMIO32(ETHERNET_BASE + 0x28)
+#define ETH_MACPMTCSR MMIO32(ETHERNET_BASE + 0x2C)
+#define ETH_MACSR MMIO32(ETHERNET_BASE + 0x38)
+#define ETH_MACIMR MMIO32(ETHERNET_BASE + 0x3C)
+#define ETH_MACA0HR MMIO32(ETHERNET_BASE + 0x40)
+#define ETH_MACA0LR MMIO32(ETHERNET_BASE + 0x44)
+#define ETH_MACA1HR MMIO32(ETHERNET_BASE + 0x48)
+#define ETH_MACA1LR MMIO32(ETHERNET_BASE + 0x4C)
+#define ETH_MACA2HR MMIO32(ETHERNET_BASE + 0x50)
+#define ETH_MACA2LR MMIO32(ETHERNET_BASE + 0x54)
+#define ETH_MACA3HR MMIO32(ETHERNET_BASE + 0x58)
+#define ETH_MACA3LR MMIO32(ETHERNET_BASE + 0x5C)
+
+/* Ethernet MMC registers */
+#define ETH_MMCCR MMIO32(ETHERNET_BASE + 0x100)
+#define ETH_MMCRIR MMIO32(ETHERNET_BASE + 0x104)
+#define ETH_MMCTIR MMIO32(ETHERNET_BASE + 0x108)
+#define ETH_MMCRIMR MMIO32(ETHERNET_BASE + 0x10C)
+#define ETH_MMCTIMR MMIO32(ETHERNET_BASE + 0x110)
+#define ETH_MMCTGFSCCR MMIO32(ETHERNET_BASE + 0x14C)
+#define ETH_MMCTGFMSCCR MMIO32(ETHERNET_BASE + 0x150)
+#define ETH_MMCTGFCR MMIO32(ETHERNET_BASE + 0x168)
+#define ETH_MMCRFCECR MMIO32(ETHERNET_BASE + 0x194)
+#define ETH_MMCRFAECR MMIO32(ETHERNET_BASE + 0x198)
+#define ETH_MMCRGUFCR MMIO32(ETHERNET_BASE + 0x1C4)
+
+/* Ethrenet IEEE 1588 time stamp registers */
+#define ETH_PTPTSCR MMIO32(ETHERNET_BASE + 0x700)
+#define ETH_PTPSSIR MMIO32(ETHERNET_BASE + 0x704)
+#define ETH_PTPTSHR MMIO32(ETHERNET_BASE + 0x708)
+#define ETH_PTPTSLR MMIO32(ETHERNET_BASE + 0x70C)
+#define ETH_PTPTSHUR MMIO32(ETHERNET_BASE + 0x710)
+#define ETH_PTPTSLUR MMIO32(ETHERNET_BASE + 0x714)
+#define ETH_PTPTSAR MMIO32(ETHERNET_BASE + 0x718)
+#define ETH_PTPTTHR MMIO32(ETHERNET_BASE + 0x71C)
+#define ETH_PTPTTLR MMIO32(ETHERNET_BASE + 0x720)
+
+/* Ethernet DMA registers */
+#define ETH_DMABMR MMIO32(ETHERNET_BASE + 0x1000)
+#define ETH_DMATPDR MMIO32(ETHERNET_BASE + 0x1004)
+#define ETH_DMARPDR MMIO32(ETHERNET_BASE + 0x1008)
+#define ETH_DMARDLAR MMIO32(ETHERNET_BASE + 0x100C)
+#define ETH_DMATDLAR MMIO32(ETHERNET_BASE + 0x1010)
+#define ETH_DMATDLAR MMIO32(ETHERNET_BASE + 0x1010)
+#define ETH_DMASR MMIO32(ETHERNET_BASE + 0x1014)
+#define ETH_DMAOMR MMIO32(ETHERNET_BASE + 0x1018)
+#define ETH_DMAIER MMIO32(ETHERNET_BASE + 0x101C)
+#define ETH_DMAMFBOCR MMIO32(ETHERNET_BASE + 0x1020)
+#define ETH_DMACHTDR MMIO32(ETHERNET_BASE + 0x1048)
+#define ETH_DMACHRDR MMIO32(ETHERNET_BASE + 0x104C)
+#define ETH_DMACHTBAR MMIO32(ETHERNET_BASE + 0x1050)
+#define ETH_DMACHRBAR MMIO32(ETHERNET_BASE + 0x1054)
+
+/* Ethernet MAC Register bit definitions */
+/* Ethernet MAC configuration register ETH_MACCR bits */
+#define ETH_MACCR_RE 0x00000004
+#define ETH_MACCR_TE 0x00000008
+#define ETH_MACCR_DC 0x00000010
+#define ETH_MACCR_BL 0x00000060
+#define ETH_MACCR_APCS 0x00000080
+#define ETH_MACCR_RD 0x00000200
+#define ETH_MACCR_IPCO 0x00000400
+#define ETH_MACCR_DM 0x00000800
+#define ETH_MACCR_LM 0x00001000
+#define ETH_MACCR_ROD 0x00002000
+#define ETH_MACCR_FES 0x00004000
+#define ETH_MACCR_CSD 0x00010000
+#define ETH_MACCR_IFG 0x000E0000
+#define ETH_MACCR_JD 0x00400000
+#define ETH_MACCR_WD 0x00800000
+
+/* Ethernet MAC frame filter register ETH_MACFFR bits */
+#define ETH_MACFFR_PM 0x00000001
+#define ETH_MACFFR_HU 0x00000002
+#define ETH_MACFFR_HM 0x00000004
+#define ETH_MACFFR_DAIF 0x00000008
+#define ETH_MACFFR_PAM 0x00000010
+#define ETH_MACFFR_BFD 0x00000020
+#define ETH_MACFFR_PCF 0x000000C0
+#define ETH_MACFFR_SAIF 0x00000100
+#define ETH_MACFFR_SAF 0x00000200
+#define ETH_MACFFR_HPF 0x00000400
+#define ETH_MACFFR_PA 0x80000000
+
+/* Ethernet MAC MII address register ETH_MACMIIAR bits */
+#define ETH_MACMIIAR_MB 0x0001
+#define ETH_MACMIIAR_MW 0x0002
+/* Clock Range for MDC frequency */
+#define ETH_MACMIIAR_CR_MASK 0x001C
+#define ETH_MACMIIAR_CR_HCLK_DIV_42 0x0000 /* For HCLK 60-72 MHz */
+#define ETH_MACMIIAR_CR_HCLK_DIV_16 0x0008 /* For HCLK 20-35 MHz */
+#define ETH_MACMIIAR_CR_HCLK_DIV_24 0x000C /* For HCLK 35-60 MHz */
+#define ETH_MACMIIAR_MR 0x07C0
+#define ETH_MACMIIAR_PA 0xF800
+
+/* Ethernet MAC flow control register ETH_MACFCR bits */
+#define ETH_MACFCR_FCB 0x00000001
+#define ETH_MACFCR_BPA 0x00000001
+#define ETH_MACFCR_TFCE 0x00000002
+#define ETH_MACFCR_RFCE 0x00000004
+#define ETH_MACFCR_UPFD 0x00000008
+#define ETH_MACFCR_PLT 0x00000030
+#define ETH_MACFCR_ZQPD 0x00000080
+#define ETH_MACFCR_PT 0xFFFF0000
+
+/* Ethernet MAC interrupt status register ETH_MACSR bits */
+#define ETH_MACSR_PMTS 0x0008
+#define ETH_MACSR_MMCS 0x0010
+#define ETH_MACSR_MMCRS 0x0020
+#define ETH_MACSR_MMCTS 0x0040
+#define ETH_MACSR_TSTS 0x0200
+
+/* Ethernet MAC interrupt mask register ETH_MACIMR bits */
+#define ETH_MACIMR_PMTIM 0x0008
+#define ETH_MACIMR_TSTIM 0x0200
+
+/* Ethernet DMA Register bit definitions */
+/* Ethernet DMA bus mode register ETH_DMABMR bits */
+#define ETH_DMABMR_SR 0x00000001
+#define ETH_DMABMR_DA 0x00000002
+#define ETH_DMABMR_DSL_MASK 0x0000007C
+#define ETH_DMABMR_PBL_MASK 0x00003F00
+#define ETH_DMABMR_RTPR_MASK 0x0000C000
+#define ETH_DMABMR_RTPR_1TO1 0x00000000
+#define ETH_DMABMR_RTPR_2TO1 0x00004000
+#define ETH_DMABMR_RTPR_3TO1 0x00008000
+#define ETH_DMABMR_RTPR_4TO1 0x0000C000
+#define ETH_DMABMR_FB 0x00010000
+#define ETH_DMABMR_RDP_MASK 0x007E0000
+#define ETH_DMABMR_USP 0x00800000
+#define ETH_DMABMR_FPM 0x01000000
+#define ETH_DMABMR_AAB 0x02000000
+
+/* Ethernet DMA operation mode register ETH_DMAOMR bits */
+#define ETH_DMAOMR_SR 0x00000002
+#define ETH_DMAOMR_OSF 0x00000004
+#define ETH_DMAOMR_RTC_MASK 0x00000018
+#define ETH_DMAOMR_RTC_64 0x00000000
+#define ETH_DMAOMR_RTC_32 0x00000008
+#define ETH_DMAOMR_RTC_96 0x00000010
+#define ETH_DMAOMR_RTC_128 0x00000018
+#define ETH_DMAOMR_FUGF 0x00000040
+#define ETH_DMAOMR_FEF 0x00000080
+#define ETH_DMAOMR_ST 0x00002000
+#define ETH_DMAOMR_TTC_MASK 0x0001C000
+#define ETH_DMAOMR_FTF 0x00100000
+#define ETH_DMAOMR_TSF 0x00200000
+#define ETH_DMAOMR_DFRF 0x01000000
+#define ETH_DMAOMR_RSF 0x02000000
+#define ETH_DMAOMR_DTCEFD 0x04000000
+
+/* Ethernet DMA interrupt enable register ETH_DMAIER bits */
+#define ETH_DMAIER_TIE 0x00000001
+#define ETH_DMAIER_TPSIE 0x00000002
+#define ETH_DMAIER_TBUIE 0x00000004
+#define ETH_DMAIER_TJTIE 0x00000008
+#define ETH_DMAIER_ROIE 0x00000010
+#define ETH_DMAIER_TUIE 0x00000020
+#define ETH_DMAIER_RIE 0x00000040
+#define ETH_DMAIER_RBUIE 0x00000080
+#define ETH_DMAIER_RPSIE 0x00000100
+#define ETH_DMAIER_RWTIE 0x00000200
+#define ETH_DMAIER_ETIE 0x00000400
+#define ETH_DMAIER_FBEIE 0x00002000
+#define ETH_DMAIER_ERIE 0x00004000
+#define ETH_DMAIER_AISE 0x00008000
+#define ETH_DMAIER_NSIE 0x00010000
+
+BEGIN_DECLS
+
+void eth_smi_write(uint8_t phy, uint8_t reg, uint16_t data);
+uint16_t eth_smi_read(uint8_t phy, uint8_t reg);
+
+END_DECLS
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/f1/exti.h b/libopencm3/include/libopencm3/stm32/f1/exti.h
new file mode 100644
index 0000000..1088210
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/exti.h
@@ -0,0 +1,41 @@
+/** @defgroup exti_defines EXTI Defines
+ *
+ * @brief <b>Defined Constants and Types for the STM32F1xx External Interrupts
+ * </b>
+ *
+ * @ingroup STM32F1xx_defines
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2013
+ * Piotr Esden-Tempski <piotr@esden.net>
+ *
+ * @version 1.0.0
+ *
+ * @date 14 January 2014
+ *
+ * LGPL License Terms @ref lgpl_license
+ */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2013 Piotr Esden-Tempski <piotr@esden.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_EXTI_H
+#define LIBOPENCM3_EXTI_H
+
+#include <libopencm3/stm32/common/exti_common_all.h>
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/f1/flash.h b/libopencm3/include/libopencm3/stm32/f1/flash.h
new file mode 100644
index 0000000..f7ba402
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/flash.h
@@ -0,0 +1,120 @@
+/** @defgroup flash_defines FLASH Defines
+ *
+ * @ingroup STM32F1xx_defines
+ *
+ * @brief Defined Constants and Types for the STM32F1xx FLASH Memory
+ *
+ * @version 1.0.0
+ *
+ * @date 14 January 2014
+ *
+ * LGPL License Terms @ref lgpl_license
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
+ * Copyright (C) 2010 Mark Butler <mbutler@physics.otago.ac.nz>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * For details see:
+ * PM0075 programming manual: STM32F10xxx Flash programming
+ * August 2010, Doc ID 17863 Rev 1
+ * https://github.com/libopencm3/libopencm3-archive/blob/master/st_micro/CD00283419.pdf
+ */
+
+#ifndef LIBOPENCM3_FLASH_H
+#define LIBOPENCM3_FLASH_H
+
+/**@{*/
+
+#include <libopencm3/stm32/common/flash_common_f01.h>
+
+/* --- FLASH_OPTION bytes ------------------------------------------------- */
+
+/** @defgroup flash_options Option Byte Addresses
+@ingroup flash_defines
+@{*/
+#define FLASH_OPTION_BYTE_0 FLASH_OPTION_BYTE(0)
+#define FLASH_OPTION_BYTE_1 FLASH_OPTION_BYTE(1)
+#define FLASH_OPTION_BYTE_2 FLASH_OPTION_BYTE(2)
+#define FLASH_OPTION_BYTE_3 FLASH_OPTION_BYTE(3)
+#define FLASH_OPTION_BYTE_4 FLASH_OPTION_BYTE(4)
+#define FLASH_OPTION_BYTE_5 FLASH_OPTION_BYTE(5)
+#define FLASH_OPTION_BYTE_6 FLASH_OPTION_BYTE(6)
+#define FLASH_OPTION_BYTE_7 FLASH_OPTION_BYTE(7)
+/**@}*/
+
+/*****************************************************************************/
+/* Register values */
+/*****************************************************************************/
+
+/* --- FLASH_ACR values ---------------------------------------------------- */
+
+/** @defgroup flash_latency FLASH Wait States
+@ingroup flash_defines
+@{*/
+#define FLASH_ACR_LATENCY_0WS 0x00
+#define FLASH_ACR_LATENCY_1WS 0x01
+#define FLASH_ACR_LATENCY_2WS 0x02
+/**@}*/
+#define FLASH_ACR_HLFCYA (1 << 3)
+
+/* --- FLASH_SR values ----------------------------------------------------- */
+
+#define FLASH_SR_EOP (1 << 5)
+#define FLASH_SR_WRPRTERR (1 << 4)
+#define FLASH_SR_PGERR (1 << 2)
+#define FLASH_SR_BSY (1 << 0)
+
+/* --- FLASH_CR values ----------------------------------------------------- */
+
+/* --- FLASH_OBR values ---------------------------------------------------- */
+
+/* FLASH_OBR[25:18]: Data1 */
+/* FLASH_OBR[17:10]: Data0 */
+#define FLASH_OBR_NRST_STDBY (1 << 4)
+#define FLASH_OBR_NRST_STOP (1 << 3)
+#define FLASH_OBR_WDG_SW (1 << 2)
+#define FLASH_OBR_RDPRT_EN (1 << FLASH_OBR_RDPRT_SHIFT)
+
+/*****************************************************************************/
+/* API definitions */
+/*****************************************************************************/
+
+/* Read protection option byte protection enable key */
+#define FLASH_RDP_KEY ((uint16_t)0x00a5)
+
+/* --- Function prototypes ------------------------------------------------- */
+
+BEGIN_DECLS
+
+void flash_halfcycle_enable(void);
+void flash_halfcycle_disable(void);
+void flash_unlock_upper(void);
+void flash_lock_upper(void);
+void flash_clear_pgerr_flag_upper(void);
+void flash_clear_eop_flag_upper(void);
+void flash_clear_wrprterr_flag_upper(void);
+void flash_clear_bsy_flag_upper(void);
+
+END_DECLS
+
+/**@}*/
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/f1/gpio.h b/libopencm3/include/libopencm3/stm32/f1/gpio.h
new file mode 100644
index 0000000..9fc8990
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/gpio.h
@@ -0,0 +1,955 @@
+/** @defgroup gpio_defines GPIO Defines
+
+@brief <b>Defined Constants and Types for the STM32F1xx General Purpose I/O</b>
+
+@ingroup STM32F1xx_defines
+
+@version 1.0.0
+
+@date 1 July 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2012 Piotr Esden-Tempski <piotr@esden.net>
+ * Copyright (C) 2012 Ken Sarkies <ksarkies@internode.on.net>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+/**@{*/
+
+#ifndef LIBOPENCM3_GPIO_H
+#define LIBOPENCM3_GPIO_H
+
+#include <libopencm3/stm32/common/gpio_common_all.h>
+
+/* --- Convenience macros -------------------------------------------------- */
+
+/* GPIO port base addresses (for convenience) */
+/** @defgroup gpio_port_id GPIO Port IDs
+@ingroup gpio_defines
+
+@{*/
+/* GPIO port base addresses (for convenience) */
+#define GPIOA GPIO_PORT_A_BASE
+#define GPIOB GPIO_PORT_B_BASE
+#define GPIOC GPIO_PORT_C_BASE
+#define GPIOD GPIO_PORT_D_BASE
+#define GPIOE GPIO_PORT_E_BASE
+#define GPIOF GPIO_PORT_F_BASE
+#define GPIOG GPIO_PORT_G_BASE
+/**@}*/
+
+/* --- Alternate function GPIOs -------------------------------------------- */
+
+/* Default alternate functions of some pins (with and without remapping) */
+
+/* CAN1 / CAN GPIO */
+#define GPIO_CAN1_RX GPIO11 /* PA11 */
+#define GPIO_CAN1_TX GPIO12 /* PA12 */
+#define GPIO_CAN_RX GPIO_CAN1_RX /* Alias */
+#define GPIO_CAN_TX GPIO_CAN1_TX /* Alias */
+
+#define GPIO_CAN_PB_RX GPIO8 /* PB8 */
+#define GPIO_CAN_PB_TX GPIO9 /* PB9 */
+#define GPIO_CAN1_PB_RX GPIO_CAN_PB_RX /* Alias */
+#define GPIO_CAN1_PB_TX GPIO_CAN_PB_TX /* Alias */
+
+#define GPIO_CAN_PD_RX GPIO0 /* PD0 */
+#define GPIO_CAN_PD_TX GPIO1 /* PD1 */
+#define GPIO_CAN1_PD_RX GPIO_CAN_PD_RX /* Alias */
+#define GPIO_CAN1_PD_TX GPIO_CAN_PD_TX /* Alias */
+
+/* CAN1 / CAN BANK */
+#define GPIO_BANK_CAN1_RX GPIOA /* PA11 */
+#define GPIO_BANK_CAN1_TX GPIOA /* PA12 */
+#define GPIO_BANK_CAN_RX GPIO_BANK_CAN1_RX /* Alias */
+#define GPIO_BANK_CAN_TX GPIO_BANK_CAN1_TX /* Alias */
+
+#define GPIO_BANK_CAN_PB_RX GPIOB /* PB8 */
+#define GPIO_BANK_CAN_PB_TX GPIOB /* PB9 */
+#define GPIO_BANK_CAN1_PB_RX GPIO_BANK_CAN_PB_RX /* Alias */
+#define GPIO_BANK_CAN1_PB_TX GPIO_BANK_CAN_PB_TX /* Alias */
+
+#define GPIO_BANK_CAN_PD_RX GPIOD /* PD0 */
+#define GPIO_BANK_CAN_PD_TX GPIOD /* PD1 */
+#define GPIO_BANK_CAN1_PD_RX GPIO_BANK_CAN_PD_RX /* Alias */
+#define GPIO_BANK_CAN1_PD_TX GPIO_BANK_CAN_PD_TX /* Alias */
+
+/* CAN2 GPIO */
+#define GPIO_CAN2_RX GPIO12 /* PB12 */
+#define GPIO_CAN2_TX GPIO13 /* PB13 */
+
+#define GPIO_CAN2_RE_RX GPIO5 /* PB5 */
+#define GPIO_CAN2_RE_TX GPIO6 /* PB6 */
+
+/* CAN2 BANK */
+#define GPIO_BANK_CAN2_RX GPIOB /* PB12 */
+#define GPIO_BANK_CAN2_TX GPIOB /* PB13 */
+
+#define GPIO_BANK_CAN2_RE_RX GPIOB /* PB5 */
+#define GPIO_BANK_CAN2_RE_TX GPIOB /* PB6 */
+
+/* JTAG/SWD GPIO */
+#define GPIO_JTMS_SWDIO GPIO13 /* PA13 */
+#define GPIO_JTCK_SWCLK GPIO14 /* PA14 */
+#define GPIO_JTDI GPIO15 /* PA15 */
+#define GPIO_JTDO_TRACESWO GPIO3 /* PB3 */
+#define GPIO_JNTRST GPIO4 /* PB4 */
+#define GPIO_TRACECK GPIO2 /* PE2 */
+#define GPIO_TRACED0 GPIO3 /* PE3 */
+#define GPIO_TRACED1 GPIO4 /* PE4 */
+#define GPIO_TRACED2 GPIO5 /* PE5 */
+#define GPIO_TRACED3 GPIO6 /* PE6 */
+
+/* JTAG/SWD BANK */
+#define GPIO_BANK_JTMS_SWDIO GPIOA /* PA13 */
+#define GPIO_BANK_JTCK_SWCLK GPIOA /* PA14 */
+#define GPIO_BANK_JTDI GPIOA /* PA15 */
+#define GPIO_BANK_JTDO_TRACESWO GPIOB /* PB3 */
+#define GPIO_BANK_JNTRST GPIOB /* PB4 */
+#define GPIO_BANK_TRACECK GPIOE /* PE2 */
+#define GPIO_BANK_TRACED0 GPIOE /* PE3 */
+#define GPIO_BANK_TRACED1 GPIOE /* PE4 */
+#define GPIO_BANK_TRACED2 GPIOE /* PE5 */
+#define GPIO_BANK_TRACED3 GPIOE /* PE6 */
+
+/* Timer5 GPIO */
+#define GPIO_TIM5_CH1 GPIO0 /* PA0 */
+#define GPIO_TIM5_CH2 GPIO1 /* PA1 */
+#define GPIO_TIM5_CH3 GPIO2 /* PA2 */
+#define GPIO_TIM5_CH4 GPIO3 /* PA3 */
+
+/* Timer5 BANK */
+#define GPIO_BANK_TIM5_CH1 GPIOA /* PA0 */
+#define GPIO_BANK_TIM5_CH2 GPIOA /* PA1 */
+#define GPIO_BANK_TIM5_CH3 GPIOA /* PA2 */
+#define GPIO_BANK_TIM5_CH4 GPIOA /* PA3 */
+#define GPIO_BANK_TIM5 GPIOA
+
+/* Timer4 GPIO */
+#define GPIO_TIM4_CH1 GPIO6 /* PB6 */
+#define GPIO_TIM4_CH2 GPIO7 /* PB7 */
+#define GPIO_TIM4_CH3 GPIO8 /* PB8 */
+#define GPIO_TIM4_CH4 GPIO9 /* PB9 */
+
+#define GPIO_TIM4_RE_CH1 GPIO12 /* PD12 */
+#define GPIO_TIM4_RE_CH2 GPIO13 /* PD13 */
+#define GPIO_TIM4_RE_CH3 GPIO14 /* PD14 */
+#define GPIO_TIM4_RE_CH4 GPIO15 /* PD15 */
+
+/* Timer4 BANK */
+#define GPIO_BANK_TIM4_CH1 GPIOB /* PB6 */
+#define GPIO_BANK_TIM4_CH2 GPIOB /* PB7 */
+#define GPIO_BANK_TIM4_CH3 GPIOB /* PB8 */
+#define GPIO_BANK_TIM4_CH4 GPIOB /* PB9 */
+#define GPIO_BANK_TIM4 GPIOB
+
+#define GPIO_BANK_TIM4_RE_CH1 GPIOD /* PD12 */
+#define GPIO_BANK_TIM4_RE_CH2 GPIOD /* PD13 */
+#define GPIO_BANK_TIM4_RE_CH3 GPIOD /* PD14 */
+#define GPIO_BANK_TIM4_RE_CH4 GPIOD /* PD15 */
+#define GPIO_BANK_TIM4_RE GPIOD
+
+/* Timer3 GPIO */
+#define GPIO_TIM3_CH1 GPIO6 /* PA6 */
+#define GPIO_TIM3_CH2 GPIO7 /* PA7 */
+#define GPIO_TIM3_CH3 GPIO0 /* PB0 */
+#define GPIO_TIM3_CH4 GPIO1 /* PB1 */
+
+#define GPIO_TIM3_PR_CH1 GPIO4 /* PB4 */
+#define GPIO_TIM3_PR_CH2 GPIO5 /* PB5 */
+#define GPIO_TIM3_PR_CH3 GPIO0 /* PB0 */
+#define GPIO_TIM3_PR_CH4 GPIO1 /* PB1 */
+
+#define GPIO_TIM3_FR_CH1 GPIO6 /* PC6 */
+#define GPIO_TIM3_FR_CH2 GPIO7 /* PC7 */
+#define GPIO_TIM3_FR_CH3 GPIO8 /* PC8 */
+#define GPIO_TIM3_FR_CH4 GPIO9 /* PC9 */
+
+/* Timer3 BANK */
+#define GPIO_BANK_TIM3_CH1 GPIOA /* PA6 */
+#define GPIO_BANK_TIM3_CH2 GPIOA /* PA7 */
+#define GPIO_BANK_TIM3_CH3 GPIOB /* PB0 */
+#define GPIO_BANK_TIM3_CH4 GPIOB /* PB1 */
+#define GPIO_BANK_TIM3_CH12 GPIOA
+#define GPIO_BANK_TIM3_CH34 GPIOB
+
+#define GPIO_BANK_TIM3_PR_CH1 GPIOB /* PB4 */
+#define GPIO_BANK_TIM3_PR_CH2 GPIOB /* PB5 */
+#define GPIO_BANK_TIM3_PR_CH3 GPIOB /* PB0 */
+#define GPIO_BANK_TIM3_PR_CH4 GPIOB /* PB1 */
+#define GPIO_BANK_TIM3_PR GPIOB
+
+#define GPIO_BANK_TIM3_FR_CH1 GPIOC /* PC6 */
+#define GPIO_BANK_TIM3_FR_CH2 GPIOC /* PC7 */
+#define GPIO_BANK_TIM3_FR_CH3 GPIOC /* PC8 */
+#define GPIO_BANK_TIM3_FR_CH4 GPIOC /* PC9 */
+#define GPIO_BANK_TIM3_FR GPIOC
+
+/* Timer2 GPIO */
+#define GPIO_TIM2_CH1_ETR GPIO0 /* PA0 */
+#define GPIO_TIM2_CH2 GPIO1 /* PA1 */
+#define GPIO_TIM2_CH3 GPIO2 /* PA2 */
+#define GPIO_TIM2_CH4 GPIO3 /* PA3 */
+
+#define GPIO_TIM2_PR1_CH1_ETR GPIO15 /* PA15 */
+#define GPIO_TIM2_PR1_CH2 GPIO3 /* PB3 */
+#define GPIO_TIM2_PR1_CH3 GPIO2 /* PA2 */
+#define GPIO_TIM2_PR1_CH4 GPIO3 /* PA3 */
+
+#define GPIO_TIM2_PR2_CH1_ETR GPIO0 /* PA0 */
+#define GPIO_TIM2_PR2_CH2 GPIO1 /* PA1 */
+#define GPIO_TIM2_PR2_CH3 GPIO10 /* PB10 */
+#define GPIO_TIM2_PR2_CH4 GPIO11 /* PB11 */
+
+#define GPIO_TIM2_FR_CH1_ETR GPIO15 /* PA15 */
+#define GPIO_TIM2_FR_CH2 GPIO3 /* PB3 */
+#define GPIO_TIM2_FR_CH3 GPIO10 /* PB10 */
+#define GPIO_TIM2_FR_CH4 GPIO11 /* PB11 */
+
+/* Timer2 BANK */
+#define GPIO_BANK_TIM2_CH1_ETR GPIOA /* PA0 */
+#define GPIO_BANK_TIM2_CH2 GPIOA /* PA1 */
+#define GPIO_BANK_TIM2_CH3 GPIOA /* PA2 */
+#define GPIO_BANK_TIM2_CH4 GPIOA /* PA3 */
+#define GPIO_BANK_TIM2 GPIOA
+
+#define GPIO_BANK_TIM2_PR1_CH1_ETR GPIOA /* PA15 */
+#define GPIO_BANK_TIM2_PR1_CH2 GPIOB /* PB3 */
+#define GPIO_BANK_TIM2_PR1_CH3 GPIOA /* PA2 */
+#define GPIO_BANK_TIM2_PR1_CH4 GPIOA /* PA3 */
+#define GPIO_BANK_TIM2_PR1_CH134 GPIOA
+
+#define GPIO_BANK_TIM2_PR2_CH1_ETR GPIOA /* PA0 */
+#define GPIO_BANK_TIM2_PR2_CH2 GPIOA /* PA1 */
+#define GPIO_BANK_TIM2_PR2_CH3 GPIOB /* PB10 */
+#define GPIO_BANK_TIM2_PR2_CH4 GPIOB /* PB11 */
+#define GPIO_BANK_TIM2_PR2_CH12 GPIOA
+#define GPIO_BANK_TIM2_PR2_CH34 GPIOB
+
+#define GPIO_BANK_TIM2_FR_CH1_ETR GPIOA /* PA15 */
+#define GPIO_BANK_TIM2_FR_CH2 GPIOB /* PB3 */
+#define GPIO_BANK_TIM2_FR_CH3 GPIOB /* PB10 */
+#define GPIO_BANK_TIM2_FR_CH4 GPIOB /* PB11 */
+#define GPIO_BANK_TIM2_FR_CH234 GPIOB
+
+/* Timer1 GPIO */
+#define GPIO_TIM1_ETR GPIO12 /* PA12 */
+#define GPIO_TIM1_CH1 GPIO8 /* PA8 */
+#define GPIO_TIM1_CH2 GPIO9 /* PA9 */
+#define GPIO_TIM1_CH3 GPIO10 /* PA10 */
+#define GPIO_TIM1_CH4 GPIO11 /* PA11 */
+#define GPIO_TIM1_BKIN GPIO12 /* PB12 */
+#define GPIO_TIM1_CH1N GPIO13 /* PB13 */
+#define GPIO_TIM1_CH2N GPIO14 /* PB14 */
+#define GPIO_TIM1_CH3N GPIO15 /* PB15 */
+
+#define GPIO_TIM1_PR_ETR GPIO12 /* PA12 */
+#define GPIO_TIM1_PR_CH1 GPIO8 /* PA8 */
+#define GPIO_TIM1_PR_CH2 GPIO9 /* PA9 */
+#define GPIO_TIM1_PR_CH3 GPIO10 /* PA10 */
+#define GPIO_TIM1_PR_CH4 GPIO11 /* PA11 */
+#define GPIO_TIM1_PR_BKIN GPIO6 /* PA6 */
+#define GPIO_TIM1_PR_CH1N GPIO7 /* PA7 */
+#define GPIO_TIM1_PR_CH2N GPIO0 /* PB0 */
+#define GPIO_TIM1_PR_CH3N GPIO1 /* PB1 */
+
+#define GPIO_TIM1_FR_ETR GPIO7 /* PE7 */
+#define GPIO_TIM1_FR_CH1 GPIO9 /* PE9 */
+#define GPIO_TIM1_FR_CH2 GPIO11 /* PE11 */
+#define GPIO_TIM1_FR_CH3 GPIO13 /* PE13 */
+#define GPIO_TIM1_FR_CH4 GPIO14 /* PE14 */
+#define GPIO_TIM1_FR_BKIN GPIO15 /* PE15 */
+#define GPIO_TIM1_FR_CH1N GPIO8 /* PE8 */
+#define GPIO_TIM1_FR_CH2N GPIO10 /* PE10 */
+#define GPIO_TIM1_FR_CH3N GPIO12 /* PE12 */
+
+/* Timer1 BANK */
+#define GPIO_BANK_TIM1_ETR GPIOA /* PA12 */
+#define GPIO_BANK_TIM1_CH1 GPIOA /* PA8 */
+#define GPIO_BANK_TIM1_CH2 GPIOA /* PA9 */
+#define GPIO_BANK_TIM1_CH3 GPIOA /* PA10 */
+#define GPIO_BANK_TIM1_CH4 GPIOA /* PA11 */
+#define GPIO_BANK_TIM1_BKIN GPIOB /* PB12 */
+#define GPIO_BANK_TIM1_CH1N GPIOB /* PB13 */
+#define GPIO_BANK_TIM1_CH2N GPIOB /* PB14 */
+#define GPIO_BANK_TIM1_CH3N GPIOB /* PB15 */
+#define GPIO_BANK_TIM1_ETR_CH1234 GPIOA
+#define GPIO_BANK_TIM1_BKIN_CH123N GPIOB
+
+#define GPIO_BANK_TIM1_PR_ETR GPIOA /* PA12 */
+#define GPIO_BANK_TIM1_PR_CH1 GPIOA /* PA8 */
+#define GPIO_BANK_TIM1_PR_CH2 GPIOA /* PA9 */
+#define GPIO_BANK_TIM1_PR_CH3 GPIOA /* PA10 */
+#define GPIO_BANK_TIM1_PR_CH4 GPIOA /* PA11 */
+#define GPIO_BANK_TIM1_PR_BKIN GPIOA /* PA6 */
+#define GPIO_BANK_TIM1_PR_CH1N GPIOA /* PA7 */
+#define GPIO_BANK_TIM1_PR_CH2N GPIOB /* PB0 */
+#define GPIO_BANK_TIM1_PR_CH3N GPIOB /* PB1 */
+#define GPIO_BANK_TIM1_PR_ETR_CH1234_BKIN_CH1N GPIOA
+#define GPIO_BANK_TIM1_PR_CH23N GPIOB
+
+#define GPIO_BANK_TIM1_FR_ETR GPIOE /* PE7 */
+#define GPIO_BANK_TIM1_FR_CH1 GPIOE /* PE9 */
+#define GPIO_BANK_TIM1_FR_CH2 GPIOE /* PE11 */
+#define GPIO_BANK_TIM1_FR_CH3 GPIOE /* PE13 */
+#define GPIO_BANK_TIM1_FR_CH4 GPIOE /* PE14 */
+#define GPIO_BANK_TIM1_FR_BKIN GPIOE /* PE15 */
+#define GPIO_BANK_TIM1_FR_CH1N GPIOE /* PE8 */
+#define GPIO_BANK_TIM1_FR_CH2N GPIOE /* PE10 */
+#define GPIO_BANK_TIM1_FR_CH3N GPIOE /* PE12 */
+#define GPIO_BANK_TIM1_FR GPIOE
+
+/* UART5 GPIO */
+#define GPIO_UART5_TX GPIO12 /* PC12 */
+#define GPIO_UART5_RX GPIO2 /* PD2 */
+
+/* UART5 BANK */
+#define GPIO_BANK_UART5_TX GPIOC /* PC12 */
+#define GPIO_BANK_UART5_RX GPIOD /* PD2 */
+
+/* UART4 GPIO */
+#define GPIO_UART4_TX GPIO10 /* PC10 */
+#define GPIO_UART4_RX GPIO11 /* PC11 */
+
+/* UART4 BANK */
+#define GPIO_BANK_UART4_TX GPIOC /* PC10 */
+#define GPIO_BANK_UART4_RX GPIOC /* PC11 */
+
+/* USART3 GPIO */
+#define GPIO_USART3_TX GPIO10 /* PB10 */
+#define GPIO_USART3_RX GPIO11 /* PB11 */
+#define GPIO_USART3_CK GPIO12 /* PB12 */
+#define GPIO_USART3_CTS GPIO13 /* PB13 */
+#define GPIO_USART3_RTS GPIO14 /* PB14 */
+
+#define GPIO_USART3_PR_TX GPIO10 /* PC10 */
+#define GPIO_USART3_PR_RX GPIO11 /* PC11 */
+#define GPIO_USART3_PR_CK GPIO12 /* PC12 */
+#define GPIO_USART3_PR_CTS GPIO13 /* PB13 */
+#define GPIO_USART3_PR_RTS GPIO14 /* PB14 */
+
+#define GPIO_USART3_FR_TX GPIO8 /* PD8 */
+#define GPIO_USART3_FR_RX GPIO9 /* PD9 */
+#define GPIO_USART3_FR_CK GPIO10 /* PD10 */
+#define GPIO_USART3_FR_CTS GPIO11 /* PD11 */
+#define GPIO_USART3_FR_RTS GPIO12 /* PD12 */
+
+/* USART3 BANK */
+#define GPIO_BANK_USART3_TX GPIOB /* PB10 */
+#define GPIO_BANK_USART3_RX GPIOB /* PB11 */
+#define GPIO_BANK_USART3_CK GPIOB /* PB12 */
+#define GPIO_BANK_USART3_CTS GPIOB /* PB13 */
+#define GPIO_BANK_USART3_RTS GPIOB /* PB14 */
+
+#define GPIO_BANK_USART3_PR_TX GPIOC /* PC10 */
+#define GPIO_BANK_USART3_PR_RX GPIOC /* PC11 */
+#define GPIO_BANK_USART3_PR_CK GPIOC /* PC12 */
+#define GPIO_BANK_USART3_PR_CTS GPIOB /* PB13 */
+#define GPIO_BANK_USART3_PR_RTS GPIOB /* PB14 */
+
+#define GPIO_BANK_USART3_FR_TX GPIOD /* PD8 */
+#define GPIO_BANK_USART3_FR_RX GPIOD /* PD9 */
+#define GPIO_BANK_USART3_FR_CK GPIOD /* PD10 */
+#define GPIO_BANK_USART3_FR_CTS GPIOD /* PD11 */
+#define GPIO_BANK_USART3_FR_RTS GPIOD /* PD12 */
+
+/* USART2 GPIO */
+#define GPIO_USART2_CTS GPIO0 /* PA0 */
+#define GPIO_USART2_RTS GPIO1 /* PA1 */
+#define GPIO_USART2_TX GPIO2 /* PA2 */
+#define GPIO_USART2_RX GPIO3 /* PA3 */
+#define GPIO_USART2_CK GPIO4 /* PA4 */
+
+#define GPIO_USART2_RE_CTS GPIO3 /* PD3 */
+#define GPIO_USART2_RE_RTS GPIO4 /* PD4 */
+#define GPIO_USART2_RE_TX GPIO5 /* PD5 */
+#define GPIO_USART2_RE_RX GPIO6 /* PD6 */
+#define GPIO_USART2_RE_CK GPIO7 /* PD7 */
+
+/* USART2 BANK */
+#define GPIO_BANK_USART2_CTS GPIOA /* PA0 */
+#define GPIO_BANK_USART2_RTS GPIOA /* PA1 */
+#define GPIO_BANK_USART2_TX GPIOA /* PA2 */
+#define GPIO_BANK_USART2_RX GPIOA /* PA3 */
+#define GPIO_BANK_USART2_CK GPIOA /* PA4 */
+
+#define GPIO_BANK_USART2_RE_CTS GPIOD /* PD3 */
+#define GPIO_BANK_USART2_RE_RTS GPIOD /* PD4 */
+#define GPIO_BANK_USART2_RE_TX GPIOD /* PD5 */
+#define GPIO_BANK_USART2_RE_RX GPIOD /* PD6 */
+#define GPIO_BANK_USART2_RE_CK GPIOD /* PD7 */
+
+/* USART1 GPIO */
+#define GPIO_USART1_TX GPIO9 /* PA9 */
+#define GPIO_USART1_RX GPIO10 /* PA10 */
+
+#define GPIO_USART1_RE_TX GPIO6 /* PB6 */
+#define GPIO_USART1_RE_RX GPIO7 /* PB7 */
+
+/* USART1 BANK */
+#define GPIO_BANK_USART1_TX GPIOA /* PA9 */
+#define GPIO_BANK_USART1_RX GPIOA /* PA10 */
+
+#define GPIO_BANK_USART1_RE_TX GPIOB /* PB6 */
+#define GPIO_BANK_USART1_RE_RX GPIOB /* PB7 */
+
+/* I2C1 GPIO */
+#define GPIO_I2C1_SMBAI GPIO5 /* PB5 */
+#define GPIO_I2C1_SCL GPIO6 /* PB6 */
+#define GPIO_I2C1_SDA GPIO7 /* PB7 */
+
+#define GPIO_I2C1_RE_SMBAI GPIO5 /* PB5 */
+#define GPIO_I2C1_RE_SCL GPIO8 /* PB8 */
+#define GPIO_I2C1_RE_SDA GPIO9 /* PB9 */
+
+/* I2C1 BANK */
+#define GPIO_BANK_I2C1_SMBAI GPIOB /* PB5 */
+#define GPIO_BANK_I2C1_SCL GPIOB /* PB6 */
+#define GPIO_BANK_I2C1_SDA GPIOB /* PB7 */
+
+#define GPIO_BANK_I2C1_RE_SMBAI GPIOB /* PB5 */
+#define GPIO_BANK_I2C1_RE_SCL GPIOB /* PB8 */
+#define GPIO_BANK_I2C1_RE_SDA GPIOB /* PB9 */
+
+/* I2C2 GPIO */
+#define GPIO_I2C2_SCL GPIO10 /* PB10 */
+#define GPIO_I2C2_SDA GPIO11 /* PB11 */
+#define GPIO_I2C2_SMBAI GPIO12 /* PB12 */
+
+/* I2C2 BANK */
+#define GPIO_BANK_I2C2_SCL GPIOB /* PB10 */
+#define GPIO_BANK_I2C2_SDA GPIOB /* PB11 */
+#define GPIO_BANK_I2C2_SMBAI GPIOB /* PB12 */
+
+/* SPI1 GPIO */
+#define GPIO_SPI1_NSS GPIO4 /* PA4 */
+#define GPIO_SPI1_SCK GPIO5 /* PA5 */
+#define GPIO_SPI1_MISO GPIO6 /* PA6 */
+#define GPIO_SPI1_MOSI GPIO7 /* PA7 */
+
+#define GPIO_SPI1_RE_NSS GPIO15 /* PA15 */
+#define GPIO_SPI1_RE_SCK GPIO3 /* PB3 */
+#define GPIO_SPI1_RE_MISO GPIO4 /* PB4 */
+#define GPIO_SPI1_RE_MOSI GPIO5 /* PB5 */
+
+/* SPI1 BANK */
+#define GPIO_BANK_SPI1_NSS GPIOA /* PA4 */
+#define GPIO_BANK_SPI1_SCK GPIOA /* PA5 */
+#define GPIO_BANK_SPI1_MISO GPIOA /* PA6 */
+#define GPIO_BANK_SPI1_MOSI GPIOA /* PA7 */
+
+#define GPIO_BANK_SPI1_RE_NSS GPIOA /* PA15 */
+#define GPIO_BANK_SPI1_RE_SCK GPIOB /* PB3 */
+#define GPIO_BANK_SPI1_RE_MISO GPIOB /* PB4 */
+#define GPIO_BANK_SPI1_RE_MOSI GPIOB /* PB5 */
+
+/* SPI2 GPIO */
+#define GPIO_SPI2_NSS GPIO12 /* PB12 */
+#define GPIO_SPI2_SCK GPIO13 /* PB13 */
+#define GPIO_SPI2_MISO GPIO14 /* PB14 */
+#define GPIO_SPI2_MOSI GPIO15 /* PB15 */
+
+/* SPI2 BANK */
+#define GPIO_BANK_SPI2_NSS GPIOB /* PB12 */
+#define GPIO_BANK_SPI2_SCK GPIOB /* PB13 */
+#define GPIO_BANK_SPI2_MISO GPIOB /* PB14 */
+#define GPIO_BANK_SPI2_MOSI GPIOB /* PB15 */
+
+/* SPI3 GPIO */
+#define GPIO_SPI3_NSS GPIO15 /* PA15 */
+#define GPIO_SPI3_SCK GPIO3 /* PB3 */
+#define GPIO_SPI3_MISO GPIO4 /* PB4 */
+#define GPIO_SPI3_MOSI GPIO5 /* PB5 */
+
+#define GPIO_SPI3_RE_NSS GPIO4 /* PA4 */
+#define GPIO_SPI3_RE_SCK GPIO10 /* PC10 */
+#define GPIO_SPI3_RE_MISO GPIO11 /* PC11 */
+#define GPIO_SPI3_RE_MOSI GPIO12 /* PC12 */
+
+/* SPI3 BANK */
+#define GPIO_BANK_SPI3_NSS GPIOA /* PA15 */
+#define GPIO_BANK_SPI3_SCK GPIOB /* PB3 */
+#define GPIO_BANK_SPI3_MISO GPIOB /* PB4 */
+#define GPIO_BANK_SPI3_MOSI GPIOB /* PB5 */
+
+#define GPIO_BANK_SPI3_RE_NSS GPIOA /* PA4 */
+#define GPIO_BANK_SPI3_RE_SCK GPIOC /* PC10 */
+#define GPIO_BANK_SPI3_RE_MISO GPIOC /* PC11 */
+#define GPIO_BANK_SPI3_RE_MOSI GPIOC /* PC12 */
+
+/* ETH GPIO */
+#define GPIO_ETH_RX_DV_CRS_DV GPIO7 /* PA7 */
+#define GPIO_ETH_RXD0 GPIO4 /* PC4 */
+#define GPIO_ETH_RXD1 GPIO5 /* PC5 */
+#define GPIO_ETH_RXD2 GPIO0 /* PB0 */
+#define GPIO_ETH_RXD3 GPIO1 /* PB1 */
+
+#define GPIO_ETH_RE_RX_DV_CRS_DV GPIO8 /* PD8 */
+#define GPIO_ETH_RE_RXD0 GPIO9 /* PD9 */
+#define GPIO_ETH_RE_RXD1 GPIO10 /* PD10 */
+#define GPIO_ETH_RE_RXD2 GPIO11 /* PD11 */
+#define GPIO_ETH_RE_RXD3 GPIO12 /* PD12 */
+
+/* ETH BANK */
+#define GPIO_BANK_ETH_RX_DV_CRS_DV GPIOA /* PA7 */
+#define GPIO_BANK_ETH_RXD0 GPIOC /* PC4 */
+#define GPIO_BANK_ETH_RXD1 GPIOC /* PC5 */
+#define GPIO_BANK_ETH_RXD2 GPIOB /* PB0 */
+#define GPIO_BANK_ETH_RXD3 GPIOB /* PB1 */
+
+#define GPIO_BANK_ETH_RE_RX_DV_CRS_DV GPIOD /* PD8 */
+#define GPIO_BANK_ETH_RE_RXD0 GPIOD /* PD9 */
+#define GPIO_BANK_ETH_RE_RXD1 GPIOD /* PD10 */
+#define GPIO_BANK_ETH_RE_RXD2 GPIOD /* PD11 */
+#define GPIO_BANK_ETH_RE_RXD3 GPIOD /* PD12 */
+
+/* --- GPIO registers ------------------------------------------------------ */
+
+/* Port configuration register low (GPIOx_CRL) */
+#define GPIO_CRL(port) MMIO32(port + 0x00)
+#define GPIOA_CRL GPIO_CRL(GPIOA)
+#define GPIOB_CRL GPIO_CRL(GPIOB)
+#define GPIOC_CRL GPIO_CRL(GPIOC)
+#define GPIOD_CRL GPIO_CRL(GPIOD)
+#define GPIOE_CRL GPIO_CRL(GPIOE)
+#define GPIOF_CRL GPIO_CRL(GPIOF)
+#define GPIOG_CRL GPIO_CRL(GPIOG)
+
+/* Port configuration register low (GPIOx_CRH) */
+#define GPIO_CRH(port) MMIO32(port + 0x04)
+#define GPIOA_CRH GPIO_CRH(GPIOA)
+#define GPIOB_CRH GPIO_CRH(GPIOB)
+#define GPIOC_CRH GPIO_CRH(GPIOC)
+#define GPIOD_CRH GPIO_CRH(GPIOD)
+#define GPIOE_CRH GPIO_CRH(GPIOE)
+#define GPIOF_CRH GPIO_CRH(GPIOF)
+#define GPIOG_CRH GPIO_CRH(GPIOG)
+
+/* Port input data register (GPIOx_IDR) */
+#define GPIO_IDR(port) MMIO32(port + 0x08)
+#define GPIOA_IDR GPIO_IDR(GPIOA)
+#define GPIOB_IDR GPIO_IDR(GPIOB)
+#define GPIOC_IDR GPIO_IDR(GPIOC)
+#define GPIOD_IDR GPIO_IDR(GPIOD)
+#define GPIOE_IDR GPIO_IDR(GPIOE)
+#define GPIOF_IDR GPIO_IDR(GPIOF)
+#define GPIOG_IDR GPIO_IDR(GPIOG)
+
+/* Port output data register (GPIOx_ODR) */
+#define GPIO_ODR(port) MMIO32(port + 0x0c)
+#define GPIOA_ODR GPIO_ODR(GPIOA)
+#define GPIOB_ODR GPIO_ODR(GPIOB)
+#define GPIOC_ODR GPIO_ODR(GPIOC)
+#define GPIOD_ODR GPIO_ODR(GPIOD)
+#define GPIOE_ODR GPIO_ODR(GPIOE)
+#define GPIOF_ODR GPIO_ODR(GPIOF)
+#define GPIOG_ODR GPIO_ODR(GPIOG)
+
+/* Port bit set/reset register (GPIOx_BSRR) */
+#define GPIO_BSRR(port) MMIO32(port + 0x10)
+#define GPIOA_BSRR GPIO_BSRR(GPIOA)
+#define GPIOB_BSRR GPIO_BSRR(GPIOB)
+#define GPIOC_BSRR GPIO_BSRR(GPIOC)
+#define GPIOD_BSRR GPIO_BSRR(GPIOD)
+#define GPIOE_BSRR GPIO_BSRR(GPIOE)
+#define GPIOF_BSRR GPIO_BSRR(GPIOF)
+#define GPIOG_BSRR GPIO_BSRR(GPIOG)
+
+/* Port bit reset register (GPIOx_BRR) */
+#define GPIO_BRR(port) MMIO16(port + 0x14)
+#define GPIOA_BRR GPIO_BRR(GPIOA)
+#define GPIOB_BRR GPIO_BRR(GPIOB)
+#define GPIOC_BRR GPIO_BRR(GPIOC)
+#define GPIOD_BRR GPIO_BRR(GPIOD)
+#define GPIOE_BRR GPIO_BRR(GPIOE)
+#define GPIOF_BRR GPIO_BRR(GPIOF)
+#define GPIOG_BRR GPIO_BRR(GPIOG)
+
+/* Port configuration lock register (GPIOx_LCKR) */
+#define GPIO_LCKR(port) MMIO32(port + 0x18)
+#define GPIOA_LCKR GPIO_LCKR(GPIOA)
+#define GPIOB_LCKR GPIO_LCKR(GPIOB)
+#define GPIOC_LCKR GPIO_LCKR(GPIOC)
+#define GPIOD_LCKR GPIO_LCKR(GPIOD)
+#define GPIOE_LCKR GPIO_LCKR(GPIOE)
+#define GPIOF_LCKR GPIO_LCKR(GPIOF)
+#define GPIOG_LCKR GPIO_LCKR(GPIOG)
+
+/* --- GPIO_CRL/GPIO_CRH values -------------------------------------------- */
+
+/** @defgroup gpio_cnf GPIO Pin Configuration
+@ingroup gpio_defines
+If mode specifies input, configuration can be
+@li Analog input
+@li Floating input
+@li Pull up/down input
+
+If mode specifies output, configuration can be
+@li Digital push-pull
+@li Digital open drain
+@li Alternate function push-pull or analog output
+@li Alternate function open drain or analog output
+@{*/
+/* CNF[1:0] values when MODE[1:0] is 00 (input mode) */
+/** Analog Input */
+#define GPIO_CNF_INPUT_ANALOG 0x00
+/** Digital Input Floating */
+#define GPIO_CNF_INPUT_FLOAT 0x01 /* Default */
+/** Digital Input Pull Up and Down */
+#define GPIO_CNF_INPUT_PULL_UPDOWN 0x02
+/* CNF[1:0] values when MODE[1:0] is != 00 (one of the output modes) */
+/** Digital Output Pushpull */
+#define GPIO_CNF_OUTPUT_PUSHPULL 0x00
+/** Digital Output Open Drain */
+#define GPIO_CNF_OUTPUT_OPENDRAIN 0x01
+/** Alternate Function Output Pushpull */
+#define GPIO_CNF_OUTPUT_ALTFN_PUSHPULL 0x02
+/** Alternate Function Output Open Drain */
+#define GPIO_CNF_OUTPUT_ALTFN_OPENDRAIN 0x03
+/**@}*/
+
+/* Pin mode (MODE[1:0]) values */
+/** @defgroup gpio_mode GPIO Pin Mode
+@ingroup gpio_defines
+@li Input (default after reset)
+@li Output mode at 10 MHz maximum speed
+@li Output mode at 2 MHz maximum speed
+@li Output mode at 50 MHz maximum speed
+@{*/
+#define GPIO_MODE_INPUT 0x00 /* Default */
+#define GPIO_MODE_OUTPUT_10_MHZ 0x01
+#define GPIO_MODE_OUTPUT_2_MHZ 0x02
+#define GPIO_MODE_OUTPUT_50_MHZ 0x03
+/**@}*/
+
+/* --- GPIO_IDR values ----------------------------------------------------- */
+
+/* GPIO_IDR[15:0]: IDRy[15:0]: Port input data (y = 0..15) */
+
+/* --- GPIO_ODR values ----------------------------------------------------- */
+
+/* GPIO_ODR[15:0]: ODRy[15:0]: Port output data (y = 0..15) */
+
+/* --- GPIO_BSRR values ---------------------------------------------------- */
+
+/* GPIO_BSRR[31:16]: BRy: Port x reset bit y (y = 0..15) */
+/* GPIO_BSRR[15:0]: BSy: Port x set bit y (y = 0..15) */
+
+/* --- GPIO_BRR values ----------------------------------------------------- */
+
+/* GPIO_BRR[15:0]: BRy: Port x reset bit y (y = 0..15) */
+
+/* --- AFIO registers ------------------------------------------------------ */
+
+/* Event control register (AFIO_EVCR) */
+#define AFIO_EVCR MMIO32(AFIO_BASE + 0x00)
+
+/* AF remap and debug I/O configuration register (AFIO_MAPR) */
+#define AFIO_MAPR MMIO32(AFIO_BASE + 0x04)
+
+/* External interrupt configuration register [0..3] (AFIO_EXTICR[1..4])*/
+#define AFIO_EXTICR(i) MMIO32(AFIO_BASE + 0x08 + (i)*4)
+#define AFIO_EXTICR1 AFIO_EXTICR(0)
+#define AFIO_EXTICR2 AFIO_EXTICR(1)
+#define AFIO_EXTICR3 AFIO_EXTICR(2)
+#define AFIO_EXTICR4 AFIO_EXTICR(3)
+
+/* AF remap and debug I/O configuration register (AFIO_MAPR) */
+#define AFIO_MAPR2 MMIO32(AFIO_BASE + 0x1C)
+
+/* --- AFIO_EVCR values ---------------------------------------------------- */
+
+/* EVOE: Event output enable */
+#define AFIO_EVCR_EVOE (1 << 7)
+
+/* PORT[2:0]: Port selection */
+/** @defgroup afio_evcr_port EVENTOUT Port selection
+@ingroup gpio_defines
+
+@{*/
+#define AFIO_EVCR_PORT_PA (0x0 << 4)
+#define AFIO_EVCR_PORT_PB (0x1 << 4)
+#define AFIO_EVCR_PORT_PC (0x2 << 4)
+#define AFIO_EVCR_PORT_PD (0x3 << 4)
+#define AFIO_EVCR_PORT_PE (0x4 << 4)
+/**@}*/
+
+/* PIN[3:0]: Pin selection */
+/** @defgroup afio_evcr_pin EVENTOUT Pin selection
+@ingroup gpio_defines
+
+@{*/
+#define AFIO_EVCR_PIN_Px0 (0x0 << 0)
+#define AFIO_EVCR_PIN_Px1 (0x1 << 0)
+#define AFIO_EVCR_PIN_Px2 (0x2 << 0)
+#define AFIO_EVCR_PIN_Px3 (0x3 << 0)
+#define AFIO_EVCR_PIN_Px4 (0x4 << 0)
+#define AFIO_EVCR_PIN_Px5 (0x5 << 0)
+#define AFIO_EVCR_PIN_Px6 (0x6 << 0)
+#define AFIO_EVCR_PIN_Px7 (0x7 << 0)
+#define AFIO_EVCR_PIN_Px8 (0x8 << 0)
+#define AFIO_EVCR_PIN_Px9 (0x9 << 0)
+#define AFIO_EVCR_PIN_Px10 (0xA << 0)
+#define AFIO_EVCR_PIN_Px11 (0xB << 0)
+#define AFIO_EVCR_PIN_Px12 (0xC << 0)
+#define AFIO_EVCR_PIN_Px13 (0xD << 0)
+#define AFIO_EVCR_PIN_Px14 (0xE << 0)
+#define AFIO_EVCR_PIN_Px15 (0xF << 0)
+/**@}*/
+
+/* --- AFIO_MAPR values ---------------------------------------------------- */
+
+/* 31 reserved */
+
+/** @defgroup afio_remap_cld Alternate Function Remap Controls for Connectivity
+Line Devices only
+@ingroup gpio_defines
+
+@{*/
+/* PTP_PPS_REMAP: */
+/** Ethernet PTP PPS remapping (only connectivity line devices) */
+#define AFIO_MAPR_PTP_PPS_REMAP (1 << 30)
+
+/* TIM2ITR1_IREMAP: */
+/** TIM2 internal trigger 1 remapping (only connectivity line devices) */
+#define AFIO_MAPR_TIM2ITR1_IREMAP (1 << 29)
+
+/* SPI3_REMAP: */
+/** SPI3/I2S3 remapping (only connectivity line devices) */
+#define AFIO_MAPR_SPI3_REMAP (1 << 28)
+
+/* MII_REMAP: */
+/** MII or RMII selection (only connectivity line devices) */
+#define AFIO_MAPR_MII_RMII_SEL (1 << 23)
+
+/* CAN2_REMAP: */
+/** CAN2 I/O remapping (only connectivity line devices) */
+#define AFIO_MAPR_CAN2_REMAP (1 << 22)
+
+/* ETH_REMAP: */
+/** Ethernet MAC I/O remapping (only connectivity line devices) */
+#define AFIO_MAPR_ETH_REMAP (1 << 21)
+
+/**@}*/
+
+/* 27 reserved */
+
+/* SWJ_CFG[2:0]: Serial wire JTAG configuration */
+/** @defgroup afio_swj_disable Serial Wire JTAG disables
+@ingroup gpio_defines
+
+@{*/
+#define AFIO_MAPR_SWJ_MASK (0x7 << 24)
+/** Full Serial Wire JTAG capability */
+#define AFIO_MAPR_SWJ_CFG_FULL_SWJ (0x0 << 24)
+/** Full Serial Wire JTAG capability without JNTRST */
+#define AFIO_MAPR_SWJ_CFG_FULL_SWJ_NO_JNTRST (0x1 << 24)
+/** JTAG-DP disabled with SW-DP enabled */
+#define AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_ON (0x2 << 24)
+/** JTAG-DP disabled and SW-DP disabled */
+#define AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_OFF (0x4 << 24)
+/**@}*/
+
+/** @defgroup afio_remap Alternate Function Remap Controls
+@ingroup gpio_defines
+
+@{*/
+/* ADC2_ETRGREG_REMAP: */
+/**
+ * ADC2 external trigger regulator conversion remapping
+ * (only low-, medium-, high- and XL-density devices)
+ */
+#define AFIO_MAPR_ADC2_ETRGREG_REMAP (1 << 20)
+
+/* ADC2_ETRGINJ_REMAP: */
+/**
+ * ADC2 external trigger injected conversion remapping
+ * (only low-, medium-, high- and XL-density devices)
+ */
+#define AFIO_MAPR_ADC2_ETRGINJ_REMAP (1 << 19)
+
+/* ADC1_ETRGREG_REMAP: */
+/**
+ * ADC1 external trigger regulator conversion remapping
+ * (only low-, medium-, high- and XL-density devices)
+ */
+#define AFIO_MAPR_ADC1_ETRGREG_REMAP (1 << 18)
+
+/* ADC1_ETRGINJ_REMAP: */
+/**
+ * ADC1 external trigger injected conversion remapping
+ * (only low-, medium-, high- and XL-density devices)
+ */
+#define AFIO_MAPR_ADC1_ETRGINJ_REMAP (1 << 17)
+
+/* TIM5CH4_IREMAP: */
+/** TIM5 channel 4 internal remap */
+#define AFIO_MAPR_TIM5CH4_IREMAP (1 << 16)
+
+/* PD01_REMAP: */
+/** Port D0/Port D1 mapping on OSC_IN/OSC_OUT */
+#define AFIO_MAPR_PD01_REMAP (1 << 15)
+
+/* TIM4_REMAP: */
+/** TIM4 remapping */
+#define AFIO_MAPR_TIM4_REMAP (1 << 12)
+
+/* USART2_REMAP[1:0]: */
+/** USART2 remapping */
+#define AFIO_MAPR_USART2_REMAP (1 << 3)
+
+/* USART1_REMAP[1:0]: */
+/** USART1 remapping */
+#define AFIO_MAPR_USART1_REMAP (1 << 2)
+
+/* I2C1_REMAP[1:0]: */
+/** I2C1 remapping */
+#define AFIO_MAPR_I2C1_REMAP (1 << 1)
+
+/* SPI1_REMAP[1:0]: */
+/** SPI1 remapping */
+#define AFIO_MAPR_SPI1_REMAP (1 << 0)
+/**@}*/
+
+/* CAN_REMAP[1:0]: CAN1 alternate function remapping */
+/** @defgroup afio_remap_can1 Alternate Function Remap Controls for CAN 1
+@ingroup gpio_defines
+
+@{*/
+#define AFIO_MAPR_CAN1_REMAP_PORTA (0x0 << 13)
+#define AFIO_MAPR_CAN1_REMAP_PORTB (0x2 << 13) /* Not 36pin pkg */
+#define AFIO_MAPR_CAN1_REMAP_PORTD (0x3 << 13)
+/**@}*/
+
+/* TIM3_REMAP[1:0]: TIM3 remapping */
+/** @defgroup afio_remap_tim3 Alternate Function Remap Controls for Timer 3
+@ingroup gpio_defines
+
+@{*/
+#define AFIO_MAPR_TIM3_REMAP_NO_REMAP (0x0 << 10)
+#define AFIO_MAPR_TIM3_REMAP_PARTIAL_REMAP (0x2 << 10)
+#define AFIO_MAPR_TIM3_REMAP_FULL_REMAP (0x3 << 10)
+/**@}*/
+
+/* TIM2_REMAP[1:0]: TIM2 remapping */
+/** @defgroup afio_remap_tim2 Alternate Function Remap Controls for Timer 2
+@ingroup gpio_defines
+
+@{*/
+#define AFIO_MAPR_TIM2_REMAP_NO_REMAP (0x0 << 8)
+#define AFIO_MAPR_TIM2_REMAP_PARTIAL_REMAP1 (0x1 << 8)
+#define AFIO_MAPR_TIM2_REMAP_PARTIAL_REMAP2 (0x2 << 8)
+#define AFIO_MAPR_TIM2_REMAP_FULL_REMAP (0x3 << 8)
+/**@}*/
+
+/* TIM1_REMAP[1:0]: TIM1 remapping */
+/** @defgroup afio_remap_tim1 Alternate Function Remap Controls for Timer 1
+@ingroup gpio_defines
+
+@{*/
+#define AFIO_MAPR_TIM1_REMAP_NO_REMAP (0x0 << 6)
+#define AFIO_MAPR_TIM1_REMAP_PARTIAL_REMAP (0x1 << 6)
+#define AFIO_MAPR_TIM1_REMAP_FULL_REMAP (0x3 << 6)
+/**@}*/
+
+/* USART3_REMAP[1:0]: USART3 remapping */
+/** @defgroup afio_remap_usart3 Alternate Function Remap Controls for USART 3
+@ingroup gpio_defines
+
+@{*/
+#define AFIO_MAPR_USART3_REMAP_NO_REMAP (0x0 << 4)
+#define AFIO_MAPR_USART3_REMAP_PARTIAL_REMAP (0x1 << 4)
+#define AFIO_MAPR_USART3_REMAP_FULL_REMAP (0x3 << 4)
+/**@}*/
+
+/** @defgroup afio_remap2 Alternate Function Remap Controls Secondary Set
+@ingroup gpio_defines
+
+@{*/
+/* FSMC_NADV_DISCONNECT: */
+/** The NADV is disconnected from its allocated pin */
+#define AFIO_MAPR2_FSMC_NADV_DISCONNECT (1 << 10)
+
+/* TIM14_REMAP: */
+/** TIM14 remapping */
+#define AFIO_MAPR2_TIM14_REMAP (1 << 9)
+
+/* TIM13_REMAP: */
+/** TIM13 remapping */
+#define AFIO_MAPR2_TIM13_REMAP (1 << 8)
+
+/* TIM11_REMAP: */
+/** TIM11 remapping */
+#define AFIO_MAPR2_TIM11_REMAP (1 << 7)
+
+/* TIM10_REMAP: */
+/** TIM10 remapping */
+#define AFIO_MAPR2_TIM10_REMAP (1 << 6)
+
+/* TIM9_REMAP: */
+/** TIM9 remapping */
+#define AFIO_MAPR2_TIM9_REMAP (1 << 5)
+
+/**@}*/
+
+/* --- AFIO_EXTICR1 values ------------------------------------------------- */
+/* --- AFIO_EXTICR2 values ------------------------------------------------- */
+/* --- AFIO_EXTICR3 values ------------------------------------------------- */
+/* --- AFIO_EXTICR4 values ------------------------------------------------- */
+
+/** @defgroup afio_exti Alternate Function EXTI pin number
+@ingroup gpio_defines
+
+@{*/
+
+#define AFIO_EXTI0 0
+#define AFIO_EXTI1 1
+#define AFIO_EXTI2 2
+#define AFIO_EXTI3 3
+#define AFIO_EXTI4 4
+#define AFIO_EXTI5 5
+#define AFIO_EXTI6 6
+#define AFIO_EXTI7 7
+#define AFIO_EXTI8 8
+#define AFIO_EXTI9 9
+#define AFIO_EXTI10 10
+#define AFIO_EXTI11 11
+#define AFIO_EXTI12 12
+#define AFIO_EXTI13 13
+#define AFIO_EXTI14 14
+#define AFIO_EXTI15 15
+
+/**@}*/
+
+/* --- Function prototypes ------------------------------------------------- */
+
+BEGIN_DECLS
+
+void gpio_set_mode(uint32_t gpioport, uint8_t mode, uint8_t cnf,
+ uint16_t gpios);
+void gpio_set_eventout(uint8_t evoutport, uint8_t evoutpin);
+void gpio_primary_remap(uint32_t swjenable, uint32_t maps);
+void gpio_secondary_remap(uint32_t maps);
+
+END_DECLS
+
+#endif
+/**@}*/
+
diff --git a/libopencm3/include/libopencm3/stm32/f1/i2c.h b/libopencm3/include/libopencm3/stm32/f1/i2c.h
new file mode 100644
index 0000000..19c26a3
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/i2c.h
@@ -0,0 +1,37 @@
+/** @defgroup i2c_defines I2C Defines
+
+@brief <b>Defined Constants and Types for the STM32F1xx I2C </b>
+
+@ingroup STM32F1xx_defines
+
+@version 1.0.0
+
+@date 12 October 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_I2C_H
+#define LIBOPENCM3_I2C_H
+
+#include <libopencm3/stm32/common/i2c_common_all.h>
+
+#endif
+
diff --git a/libopencm3/include/libopencm3/stm32/f1/irq.json b/libopencm3/include/libopencm3/stm32/f1/irq.json
new file mode 100644
index 0000000..20bf00c
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/irq.json
@@ -0,0 +1,75 @@
+{
+ "irqs": [
+ "wwdg",
+ "pvd",
+ "tamper",
+ "rtc",
+ "flash",
+ "rcc",
+ "exti0",
+ "exti1",
+ "exti2",
+ "exti3",
+ "exti4",
+ "dma1_channel1",
+ "dma1_channel2",
+ "dma1_channel3",
+ "dma1_channel4",
+ "dma1_channel5",
+ "dma1_channel6",
+ "dma1_channel7",
+ "adc1_2",
+ "usb_hp_can_tx",
+ "usb_lp_can_rx0",
+ "can_rx1",
+ "can_sce",
+ "exti9_5",
+ "tim1_brk",
+ "tim1_up",
+ "tim1_trg_com",
+ "tim1_cc",
+ "tim2",
+ "tim3",
+ "tim4",
+ "i2c1_ev",
+ "i2c1_er",
+ "i2c2_ev",
+ "i2c2_er",
+ "spi1",
+ "spi2",
+ "usart1",
+ "usart2",
+ "usart3",
+ "exti15_10",
+ "rtc_alarm",
+ "usb_wakeup",
+ "tim8_brk",
+ "tim8_up",
+ "tim8_trg_com",
+ "tim8_cc",
+ "adc3",
+ "fsmc",
+ "sdio",
+ "tim5",
+ "spi3",
+ "uart4",
+ "uart5",
+ "tim6",
+ "tim7",
+ "dma2_channel1",
+ "dma2_channel2",
+ "dma2_channel3",
+ "dma2_channel4_5",
+ "dma2_channel5",
+ "eth",
+ "eth_wkup",
+ "can2_tx",
+ "can2_rx0",
+ "can2_rx1",
+ "can2_sce",
+ "otg_fs"
+ ],
+ "partname_humanreadable": "STM32 F1 series",
+ "partname_doxygen": "STM32F1",
+ "includeguard": "LIBOPENCM3_STM32_F1_NVIC_H"
+} \ No newline at end of file
diff --git a/libopencm3/include/libopencm3/stm32/f1/iwdg.h b/libopencm3/include/libopencm3/stm32/f1/iwdg.h
new file mode 100644
index 0000000..cdb5115
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/iwdg.h
@@ -0,0 +1,39 @@
+/** @defgroup iwdg_defines IWDG Defines
+
+@brief <b>Defined Constants and Types for the STM32F1xx Independent Watchdog
+Timer</b>
+
+@ingroup STM32F1xx_defines
+
+@version 1.0.0
+
+@date 18 August 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Thomas Otto <tommi@viadmin.org>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_IWDG_H
+#define LIBOPENCM3_IWDG_H
+
+#include <libopencm3/stm32/common/iwdg_common_all.h>
+
+#endif
+
diff --git a/libopencm3/include/libopencm3/stm32/f1/memorymap.h b/libopencm3/include/libopencm3/stm32/f1/memorymap.h
new file mode 100644
index 0000000..046335e
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/memorymap.h
@@ -0,0 +1,127 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_MEMORYMAP_H
+#define LIBOPENCM3_MEMORYMAP_H
+
+#include <libopencm3/cm3/memorymap.h>
+
+/* --- STM32 specific peripheral definitions ------------------------------- */
+
+/* Memory map for all buses */
+#define FLASH_BASE (0x08000000U)
+#define PERIPH_BASE (0x40000000U)
+#define INFO_BASE (0x1ffff000U)
+#define PERIPH_BASE_APB1 (PERIPH_BASE + 0x00000)
+#define PERIPH_BASE_APB2 (PERIPH_BASE + 0x10000)
+#define PERIPH_BASE_AHB (PERIPH_BASE + 0x18000)
+
+/* Register boundary addresses */
+
+/* APB1 */
+#define TIM2_BASE (PERIPH_BASE_APB1 + 0x0000)
+#define TIM3_BASE (PERIPH_BASE_APB1 + 0x0400)
+#define TIM4_BASE (PERIPH_BASE_APB1 + 0x0800)
+#define TIM5_BASE (PERIPH_BASE_APB1 + 0x0c00)
+#define TIM6_BASE (PERIPH_BASE_APB1 + 0x1000)
+#define TIM7_BASE (PERIPH_BASE_APB1 + 0x1400)
+#define TIM12_BASE (PERIPH_BASE_APB1 + 0x1800)
+#define TIM13_BASE (PERIPH_BASE_APB1 + 0x1c00)
+#define TIM14_BASE (PERIPH_BASE_APB1 + 0x2000)
+/* PERIPH_BASE_APB1 + 0x2400 (0x4000 2400 - 0x4000 27FF): Reserved */
+#define RTC_BASE (PERIPH_BASE_APB1 + 0x2800)
+#define WWDG_BASE (PERIPH_BASE_APB1 + 0x2c00)
+#define IWDG_BASE (PERIPH_BASE_APB1 + 0x3000)
+/* PERIPH_BASE_APB1 + 0x3400 (0x4000 3400 - 0x4000 37FF): Reserved */
+#define SPI2_I2S_BASE (PERIPH_BASE_APB1 + 0x3800)
+#define SPI3_I2S_BASE (PERIPH_BASE_APB1 + 0x3c00)
+/* PERIPH_BASE_APB1 + 0x4000 (0x4000 4000 - 0x4000 3FFF): Reserved */
+#define USART2_BASE (PERIPH_BASE_APB1 + 0x4400)
+#define USART3_BASE (PERIPH_BASE_APB1 + 0x4800)
+#define UART4_BASE (PERIPH_BASE_APB1 + 0x4c00)
+#define UART5_BASE (PERIPH_BASE_APB1 + 0x5000)
+#define I2C1_BASE (PERIPH_BASE_APB1 + 0x5400)
+#define I2C2_BASE (PERIPH_BASE_APB1 + 0x5800)
+#define USB_DEV_FS_BASE (PERIPH_BASE_APB1 + 0x5c00)
+#define USB_CAN_SRAM_BASE (PERIPH_BASE_APB1 + 0x6000)
+#define BX_CAN1_BASE (PERIPH_BASE_APB1 + 0x6400)
+#define BX_CAN2_BASE (PERIPH_BASE_APB1 + 0x6800)
+/* PERIPH_BASE_APB1 + 0x6800 (0x4000 6800 - 0x4000 6BFF): Reserved? Typo? */
+#define BACKUP_REGS_BASE (PERIPH_BASE_APB1 + 0x6c00)
+#define POWER_CONTROL_BASE (PERIPH_BASE_APB1 + 0x7000)
+#define DAC_BASE (PERIPH_BASE_APB1 + 0x7400)
+#define CEC_BASE (PERIPH_BASE_APB1 + 0x7800)
+/* PERIPH_BASE_APB1 + 0x7c00 (0x4000 7c00 - 0x4000 FFFF): Reserved */
+
+/* APB2 */
+#define AFIO_BASE (PERIPH_BASE_APB2 + 0x0000)
+#define EXTI_BASE (PERIPH_BASE_APB2 + 0x0400)
+#define GPIO_PORT_A_BASE (PERIPH_BASE_APB2 + 0x0800)
+#define GPIO_PORT_B_BASE (PERIPH_BASE_APB2 + 0x0c00)
+#define GPIO_PORT_C_BASE (PERIPH_BASE_APB2 + 0x1000)
+#define GPIO_PORT_D_BASE (PERIPH_BASE_APB2 + 0x1400)
+#define GPIO_PORT_E_BASE (PERIPH_BASE_APB2 + 0x1800)
+#define GPIO_PORT_F_BASE (PERIPH_BASE_APB2 + 0x1c00)
+#define GPIO_PORT_G_BASE (PERIPH_BASE_APB2 + 0x2000)
+#define ADC1_BASE (PERIPH_BASE_APB2 + 0x2400)
+#define ADC2_BASE (PERIPH_BASE_APB2 + 0x2800)
+#define TIM1_BASE (PERIPH_BASE_APB2 + 0x2c00)
+#define SPI1_BASE (PERIPH_BASE_APB2 + 0x3000)
+#define TIM8_BASE (PERIPH_BASE_APB2 + 0x3400)
+#define USART1_BASE (PERIPH_BASE_APB2 + 0x3800)
+#define ADC3_BASE (PERIPH_BASE_APB2 + 0x3c00)
+#define TIM15_BASE (PERIPH_BASE_APB2 + 0x4000)
+#define TIM16_BASE (PERIPH_BASE_APB2 + 0x4400)
+#define TIM17_BASE (PERIPH_BASE_APB2 + 0x4800)
+#define TIM9_BASE (PERIPH_BASE_APB2 + 0x4c00)
+#define TIM10_BASE (PERIPH_BASE_APB2 + 0x5000)
+#define TIM11_BASE (PERIPH_BASE_APB2 + 0x5400)
+/* PERIPH_BASE_APB2 + 0x5800 (0x4001 5800 - 0x4001 7FFF): Reserved */
+
+/* AHB */
+#define SDIO_BASE (PERIPH_BASE_AHB + 0x00000)
+/* PERIPH_BASE_AHB + 0x0400 (0x4001 8400 - 0x4001 7FFF): Reserved */
+#define DMA1_BASE (PERIPH_BASE_AHB + 0x08000)
+#define DMA2_BASE (PERIPH_BASE_AHB + 0x08400)
+/* PERIPH_BASE_AHB + 0x8800 (0x4002 0800 - 0x4002 0FFF): Reserved */
+#define RCC_BASE (PERIPH_BASE_AHB + 0x09000)
+/* PERIPH_BASE_AHB + 0x9400 (0x4002 1400 - 0x4002 1FFF): Reserved */
+#define FLASH_MEM_INTERFACE_BASE (PERIPH_BASE_AHB + 0x0a000)
+#define CRC_BASE (PERIPH_BASE_AHB + 0x0b000)
+/* PERIPH_BASE_AHB + 0xb400 (0x4002 3400 - 0x4002 7FFF): Reserved */
+#define ETHERNET_BASE (PERIPH_BASE_AHB + 0x10000)
+/* PERIPH_BASE_AHB + 0x18000 (0x4003 0000 - 0x4FFF FFFF): Reserved */
+#define USB_OTG_FS_BASE (PERIPH_BASE_AHB + 0xffe8000)
+
+/* PPIB */
+#define DBGMCU_BASE (PPBI_BASE + 0x00042000)
+
+/* FSMC */
+#define FSMC_BASE (PERIPH_BASE + 0x60000000)
+
+/* Device Electronic Signature */
+#define DESIG_FLASH_SIZE_BASE (INFO_BASE + 0x7e0)
+#define DESIG_UNIQUE_ID_BASE (INFO_BASE + 0x7e8)
+/* Ignore the "reserved for future use" half of the first word */
+#define DESIG_UNIQUE_ID0 MMIO32(DESIG_UNIQUE_ID_BASE)
+#define DESIG_UNIQUE_ID1 MMIO32(DESIG_UNIQUE_ID_BASE + 4)
+#define DESIG_UNIQUE_ID2 MMIO32(DESIG_UNIQUE_ID_BASE + 8)
+
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/f1/pwr.h b/libopencm3/include/libopencm3/stm32/f1/pwr.h
new file mode 100644
index 0000000..51b3977
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/pwr.h
@@ -0,0 +1,37 @@
+/** @defgroup pwr_defines PWR Defines
+
+@brief <b>Defined Constants and Types for the STM32F1xx PWR Control</b>
+
+@ingroup STM32F1xx_defines
+
+@version 1.0.0
+
+@date 5 December 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_PWR_H
+#define LIBOPENCM3_PWR_H
+
+#include <libopencm3/stm32/common/pwr_common_all.h>
+
+#endif
+
diff --git a/libopencm3/include/libopencm3/stm32/f1/rcc.h b/libopencm3/include/libopencm3/stm32/f1/rcc.h
new file mode 100644
index 0000000..799b8c2
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/rcc.h
@@ -0,0 +1,718 @@
+/** @defgroup rcc_defines RCC Defines
+ *
+ * @brief <b>Defined Constants and Types for the STM32F1xx Reset and Clock
+ * Control</b>
+ *
+ * @ingroup STM32F1xx_defines
+ *
+ * @version 1.0.0
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2009
+ * Federico Ruiz-Ugalde \<memeruiz at gmail dot com\>
+ * @author @htmlonly &copy; @endhtmlonly 2009
+ * Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * @date 18 August 2012
+ *
+ * LGPL License Terms @ref lgpl_license
+ * */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2009 Federico Ruiz-Ugalde <memeruiz at gmail dot com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+/**@{*/
+
+#ifndef LIBOPENCM3_RCC_H
+#define LIBOPENCM3_RCC_H
+
+/* Note: Regs/bits marked (**) only exist in "connectivity line" STM32s. */
+/* Note: Regs/bits marked (XX) do NOT exist in "connectivity line" STM32s. */
+
+/* --- RCC registers ------------------------------------------------------- */
+
+#define RCC_CR MMIO32(RCC_BASE + 0x00)
+#define RCC_CFGR MMIO32(RCC_BASE + 0x04)
+#define RCC_CIR MMIO32(RCC_BASE + 0x08)
+#define RCC_APB2RSTR MMIO32(RCC_BASE + 0x0c)
+#define RCC_APB1RSTR MMIO32(RCC_BASE + 0x10)
+#define RCC_AHBENR MMIO32(RCC_BASE + 0x14)
+#define RCC_APB2ENR MMIO32(RCC_BASE + 0x18)
+#define RCC_APB1ENR MMIO32(RCC_BASE + 0x1c)
+#define RCC_BDCR MMIO32(RCC_BASE + 0x20)
+#define RCC_CSR MMIO32(RCC_BASE + 0x24)
+#define RCC_AHBRSTR MMIO32(RCC_BASE + 0x28) /*(**)*/
+#define RCC_CFGR2 MMIO32(RCC_BASE + 0x2c) /*(**)*/
+
+/* --- RCC_CR values ------------------------------------------------------- */
+
+#define RCC_CR_PLL3RDY (1 << 29) /* (**) */
+#define RCC_CR_PLL3ON (1 << 28) /* (**) */
+#define RCC_CR_PLL2RDY (1 << 27) /* (**) */
+#define RCC_CR_PLL2ON (1 << 26) /* (**) */
+#define RCC_CR_PLLRDY (1 << 25)
+#define RCC_CR_PLLON (1 << 24)
+#define RCC_CR_CSSON (1 << 19)
+#define RCC_CR_HSEBYP (1 << 18)
+#define RCC_CR_HSERDY (1 << 17)
+#define RCC_CR_HSEON (1 << 16)
+/* HSICAL: [15:8] */
+/* HSITRIM: [7:3] */
+#define RCC_CR_HSIRDY (1 << 1)
+#define RCC_CR_HSION (1 << 0)
+
+/* --- RCC_CFGR values ----------------------------------------------------- */
+
+#define RCC_CFGR_MCO_SHIFT 24
+#define RCC_CFGR_MCO (0xF << RCC_CFGR_MCO_SHIFT)
+
+#define RCC_CFGR_OTGFSPRE (1 << 22) /* Connectivity line */
+#define RCC_CFGR_USBPRE (1 << 22) /* LD,MD, HD, XL */
+
+#define RCC_CFGR_PLLMUL_SHIFT 18
+#define RCC_CFGR_PLLMUL (0xF << RCC_CFGR_PLLMUL_SHIFT)
+
+#define RCC_CFGR_PLLXTPRE (1 << 17)
+#define RCC_CFGR_PLLSRC (1 << 16)
+
+#define RCC_CFGR_ADCPRE_SHIFT 14
+#define RCC_CFGR_ADCPRE (3 << RCC_CFGR_ADCPRE_SHIFT)
+
+#define RCC_CFGR_PPRE2_SHIFT 11
+#define RCC_CFGR_PPRE2 (7 << RCC_CFGR_PPRE2_SHIFT)
+
+#define RCC_CFGR_PPRE1_SHIFT 8
+#define RCC_CFGR_PPRE1 (7 << RCC_CFGR_PPRE1_SHIFT)
+
+#define RCC_CFGR_HPRE_SHIFT 4
+#define RCC_CFGR_HPRE (0xF << RCC_CFGR_HPRE_SHIFT)
+
+#define RCC_CFGR_SWS_SHIFT 2
+#define RCC_CFGR_SWS (3 << RCC_CFGR_SWS_SHIFT)
+
+#define RCC_CFGR_SW_SHIFT 0
+#define RCC_CFGR_SW (3 << RCC_CFGR_SW_SHIFT)
+
+/* MCO: Microcontroller clock output */
+/** @defgroup rcc_cfgr_co RCC_CFGR Microcontroller Clock Output Source
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_CFGR_MCO_NOCLK 0x0
+#define RCC_CFGR_MCO_SYSCLK 0x4
+#define RCC_CFGR_MCO_HSICLK 0x5
+#define RCC_CFGR_MCO_HSECLK 0x6
+#define RCC_CFGR_MCO_PLLCLK_DIV2 0x7
+#define RCC_CFGR_MCO_PLL2CLK 0x8 /* (**) */
+#define RCC_CFGR_MCO_PLL3CLK_DIV2 0x9 /* (**) */
+#define RCC_CFGR_MCO_XT1 0xa /* (**) */
+#define RCC_CFGR_MCO_PLL3 0xb /* (**) */
+/**@}*/
+
+/* USBPRE: USB prescaler (RCC_CFGR[22]) */
+/** @defgroup rcc_cfgr_usbpre RCC_CFGR USB prescale Factors
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_CFGR_USBPRE_PLL_CLK_DIV1_5 0x0
+#define RCC_CFGR_USBPRE_PLL_CLK_NODIV 0x1
+/**@}*/
+
+/* OTGFSPRE: USB OTG FS prescaler (RCC_CFGR[22]; only in conn. line STM32s) */
+#define RCC_CFGR_USBPRE_PLL_VCO_CLK_DIV3 0x0
+#define RCC_CFGR_USBPRE_PLL_VCO_CLK_DIV2 0x1
+
+/* PLLMUL: PLL multiplication factor */
+/** @defgroup rcc_cfgr_pmf RCC_CFGR PLL Multiplication Factor
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL2 0x0 /* (XX) */
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL3 0x1 /* (XX) */
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL4 0x2
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL5 0x3
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL6 0x4
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL7 0x5
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL8 0x6
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL9 0x7
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL10 0x8 /* (XX) */
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL11 0x9 /* (XX) */
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL12 0xa /* (XX) */
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL13 0xb /* (XX) */
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL14 0xc /* (XX) */
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL15 0xd /* 0xd: PLL x 15 */
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL6_5 0xd /* 0xd: PLL x 6.5 for conn.
+ line */
+#define RCC_CFGR_PLLMUL_PLL_CLK_MUL16 0xe /* (XX) */
+/* #define PLLMUL_PLL_CLK_MUL16 0xf */ /* (XX) */ /* Errata? 17? */
+/**@}*/
+
+/* TODO: conn. line differs. */
+/* PLLXTPRE: HSE divider for PLL entry */
+/** @defgroup rcc_cfgr_hsepre RCC_CFGR HSE Divider for PLL
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_CFGR_PLLXTPRE_HSE_CLK 0x0
+#define RCC_CFGR_PLLXTPRE_HSE_CLK_DIV2 0x1
+/**@}*/
+
+/* PLLSRC: PLL entry clock source */
+/** @defgroup rcc_cfgr_pcs RCC_CFGR PLL Clock Source
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_CFGR_PLLSRC_HSI_CLK_DIV2 0x0
+#define RCC_CFGR_PLLSRC_HSE_CLK 0x1
+#define RCC_CFGR_PLLSRC_PREDIV1_CLK 0x1 /* On conn. line */
+/**@}*/
+
+/* ADCPRE: ADC prescaler */
+/****************************************************************************/
+/** @defgroup rcc_cfgr_adcpre RCC ADC clock prescaler enable values
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_CFGR_ADCPRE_PCLK2_DIV2 0x0
+#define RCC_CFGR_ADCPRE_PCLK2_DIV4 0x1
+#define RCC_CFGR_ADCPRE_PCLK2_DIV6 0x2
+#define RCC_CFGR_ADCPRE_PCLK2_DIV8 0x3
+/**@}*/
+
+/* PPRE2: APB high-speed prescaler (APB2) */
+/** @defgroup rcc_cfgr_apb2pre RCC_CFGR APB2 prescale Factors
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_CFGR_PPRE2_HCLK_NODIV 0x0
+#define RCC_CFGR_PPRE2_HCLK_DIV2 0x4
+#define RCC_CFGR_PPRE2_HCLK_DIV4 0x5
+#define RCC_CFGR_PPRE2_HCLK_DIV8 0x6
+#define RCC_CFGR_PPRE2_HCLK_DIV16 0x7
+/**@}*/
+
+/* PPRE1: APB low-speed prescaler (APB1) */
+/** @defgroup rcc_cfgr_apb1pre RCC_CFGR APB1 prescale Factors
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_CFGR_PPRE1_HCLK_NODIV 0x0
+#define RCC_CFGR_PPRE1_HCLK_DIV2 0x4
+#define RCC_CFGR_PPRE1_HCLK_DIV4 0x5
+#define RCC_CFGR_PPRE1_HCLK_DIV8 0x6
+#define RCC_CFGR_PPRE1_HCLK_DIV16 0x7
+/**@}*/
+
+/* HPRE: AHB prescaler */
+/** @defgroup rcc_cfgr_ahbpre RCC_CFGR AHB prescale Factors
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_CFGR_HPRE_SYSCLK_NODIV 0x0
+#define RCC_CFGR_HPRE_SYSCLK_DIV2 0x8
+#define RCC_CFGR_HPRE_SYSCLK_DIV4 0x9
+#define RCC_CFGR_HPRE_SYSCLK_DIV8 0xa
+#define RCC_CFGR_HPRE_SYSCLK_DIV16 0xb
+#define RCC_CFGR_HPRE_SYSCLK_DIV64 0xc
+#define RCC_CFGR_HPRE_SYSCLK_DIV128 0xd
+#define RCC_CFGR_HPRE_SYSCLK_DIV256 0xe
+#define RCC_CFGR_HPRE_SYSCLK_DIV512 0xf
+/**@}*/
+
+/* SWS: System clock switch status */
+#define RCC_CFGR_SWS_SYSCLKSEL_HSICLK 0x0
+#define RCC_CFGR_SWS_SYSCLKSEL_HSECLK 0x1
+#define RCC_CFGR_SWS_SYSCLKSEL_PLLCLK 0x2
+
+/* SW: System clock switch */
+/** @defgroup rcc_cfgr_scs RCC_CFGR System Clock Selection
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_CFGR_SW_SYSCLKSEL_HSICLK 0x0
+#define RCC_CFGR_SW_SYSCLKSEL_HSECLK 0x1
+#define RCC_CFGR_SW_SYSCLKSEL_PLLCLK 0x2
+/**@}*/
+
+/* --- RCC_CIR values ------------------------------------------------------ */
+
+/* Clock security system interrupt clear bit */
+#define RCC_CIR_CSSC (1 << 23)
+
+/* OSC ready interrupt clear bits */
+#define RCC_CIR_PLL3RDYC (1 << 22) /* (**) */
+#define RCC_CIR_PLL2RDYC (1 << 21) /* (**) */
+#define RCC_CIR_PLLRDYC (1 << 20)
+#define RCC_CIR_HSERDYC (1 << 19)
+#define RCC_CIR_HSIRDYC (1 << 18)
+#define RCC_CIR_LSERDYC (1 << 17)
+#define RCC_CIR_LSIRDYC (1 << 16)
+
+/* OSC ready interrupt enable bits */
+#define RCC_CIR_PLL3RDYIE (1 << 14) /* (**) */
+#define RCC_CIR_PLL2RDYIE (1 << 13) /* (**) */
+#define RCC_CIR_PLLRDYIE (1 << 12)
+#define RCC_CIR_HSERDYIE (1 << 11)
+#define RCC_CIR_HSIRDYIE (1 << 10)
+#define RCC_CIR_LSERDYIE (1 << 9)
+#define RCC_CIR_LSIRDYIE (1 << 8)
+
+/* Clock security system interrupt flag bit */
+#define RCC_CIR_CSSF (1 << 7)
+
+/* OSC ready interrupt flag bits */
+#define RCC_CIR_PLL3RDYF (1 << 6) /* (**) */
+#define RCC_CIR_PLL2RDYF (1 << 5) /* (**) */
+#define RCC_CIR_PLLRDYF (1 << 4)
+#define RCC_CIR_HSERDYF (1 << 3)
+#define RCC_CIR_HSIRDYF (1 << 2)
+#define RCC_CIR_LSERDYF (1 << 1)
+#define RCC_CIR_LSIRDYF (1 << 0)
+
+/* --- RCC_APB2RSTR values ------------------------------------------------- */
+
+/** @defgroup rcc_apb2rstr_rst RCC_APB2RSTR reset values
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_APB2RSTR_ADC3RST (1 << 15) /* (XX) */
+#define RCC_APB2RSTR_USART1RST (1 << 14)
+#define RCC_APB2RSTR_TIM8RST (1 << 13) /* (XX) */
+#define RCC_APB2RSTR_SPI1RST (1 << 12)
+#define RCC_APB2RSTR_TIM1RST (1 << 11)
+#define RCC_APB2RSTR_ADC2RST (1 << 10)
+#define RCC_APB2RSTR_ADC1RST (1 << 9)
+#define RCC_APB2RSTR_IOPGRST (1 << 8) /* (XX) */
+#define RCC_APB2RSTR_IOPFRST (1 << 7) /* (XX) */
+#define RCC_APB2RSTR_IOPERST (1 << 6)
+#define RCC_APB2RSTR_IOPDRST (1 << 5)
+#define RCC_APB2RSTR_IOPCRST (1 << 4)
+#define RCC_APB2RSTR_IOPBRST (1 << 3)
+#define RCC_APB2RSTR_IOPARST (1 << 2)
+#define RCC_APB2RSTR_AFIORST (1 << 0)
+/**@}*/
+
+/* --- RCC_APB1RSTR values ------------------------------------------------- */
+
+/** @defgroup rcc_apb1rstr_rst RCC_APB1RSTR reset values
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_APB1RSTR_DACRST (1 << 29)
+#define RCC_APB1RSTR_PWRRST (1 << 28)
+#define RCC_APB1RSTR_BKPRST (1 << 27)
+#define RCC_APB1RSTR_CAN2RST (1 << 26) /* (**) */
+#define RCC_APB1RSTR_CAN1RST (1 << 25) /* (**) */
+#define RCC_APB1RSTR_CANRST (1 << 25) /* (XX) Alias for
+ CAN1RST */
+#define RCC_APB1RSTR_USBRST (1 << 23) /* (XX) */
+#define RCC_APB1RSTR_I2C2RST (1 << 22)
+#define RCC_APB1RSTR_I2C1RST (1 << 21)
+#define RCC_APB1RSTR_UART5RST (1 << 20)
+#define RCC_APB1RSTR_UART4RST (1 << 19)
+#define RCC_APB1RSTR_USART3RST (1 << 18)
+#define RCC_APB1RSTR_USART2RST (1 << 17)
+#define RCC_APB1RSTR_SPI3RST (1 << 15)
+#define RCC_APB1RSTR_SPI2RST (1 << 14)
+#define RCC_APB1RSTR_WWDGRST (1 << 11)
+#define RCC_APB1RSTR_TIM7RST (1 << 5)
+#define RCC_APB1RSTR_TIM6RST (1 << 4)
+#define RCC_APB1RSTR_TIM5RST (1 << 3)
+#define RCC_APB1RSTR_TIM4RST (1 << 2)
+#define RCC_APB1RSTR_TIM3RST (1 << 1)
+#define RCC_APB1RSTR_TIM2RST (1 << 0)
+/**@}*/
+
+/* --- RCC_AHBENR values --------------------------------------------------- */
+
+/** @defgroup rcc_ahbenr_en RCC_AHBENR enable values
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_AHBENR_ETHMACENRX (1 << 16)
+#define RCC_AHBENR_ETHMACENTX (1 << 15)
+#define RCC_AHBENR_ETHMACEN (1 << 14)
+#define RCC_AHBENR_OTGFSEN (1 << 12)
+#define RCC_AHBENR_SDIOEN (1 << 10)
+#define RCC_AHBENR_FSMCEN (1 << 8)
+#define RCC_AHBENR_CRCEN (1 << 6)
+#define RCC_AHBENR_FLITFEN (1 << 4)
+#define RCC_AHBENR_SRAMEN (1 << 2)
+#define RCC_AHBENR_DMA2EN (1 << 1)
+#define RCC_AHBENR_DMA1EN (1 << 0)
+/**@}*/
+
+/* --- RCC_APB2ENR values -------------------------------------------------- */
+
+/** @defgroup rcc_apb2enr_en RCC_APB2ENR enable values
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_APB2ENR_ADC3EN (1 << 15) /* (XX) */
+#define RCC_APB2ENR_USART1EN (1 << 14)
+#define RCC_APB2ENR_TIM8EN (1 << 13) /* (XX) */
+#define RCC_APB2ENR_SPI1EN (1 << 12)
+#define RCC_APB2ENR_TIM1EN (1 << 11)
+#define RCC_APB2ENR_ADC2EN (1 << 10)
+#define RCC_APB2ENR_ADC1EN (1 << 9)
+#define RCC_APB2ENR_IOPGEN (1 << 8) /* (XX) */
+#define RCC_APB2ENR_IOPFEN (1 << 7) /* (XX) */
+#define RCC_APB2ENR_IOPEEN (1 << 6)
+#define RCC_APB2ENR_IOPDEN (1 << 5)
+#define RCC_APB2ENR_IOPCEN (1 << 4)
+#define RCC_APB2ENR_IOPBEN (1 << 3)
+#define RCC_APB2ENR_IOPAEN (1 << 2)
+#define RCC_APB2ENR_AFIOEN (1 << 0)
+/**@}*/
+
+/* --- RCC_APB1ENR values -------------------------------------------------- */
+
+/** @defgroup rcc_apb1enr_en RCC_APB1ENR enable values
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_APB1ENR_DACEN (1 << 29)
+#define RCC_APB1ENR_PWREN (1 << 28)
+#define RCC_APB1ENR_BKPEN (1 << 27)
+#define RCC_APB1ENR_CAN2EN (1 << 26) /* (**) */
+#define RCC_APB1ENR_CAN1EN (1 << 25) /* (**) */
+#define RCC_APB1ENR_CANEN (1 << 25) /* (XX) Alias for
+ CAN1EN */
+#define RCC_APB1ENR_USBEN (1 << 23) /* (XX) */
+#define RCC_APB1ENR_I2C2EN (1 << 22)
+#define RCC_APB1ENR_I2C1EN (1 << 21)
+#define RCC_APB1ENR_UART5EN (1 << 20)
+#define RCC_APB1ENR_UART4EN (1 << 19)
+#define RCC_APB1ENR_USART3EN (1 << 18)
+#define RCC_APB1ENR_USART2EN (1 << 17)
+#define RCC_APB1ENR_SPI3EN (1 << 15)
+#define RCC_APB1ENR_SPI2EN (1 << 14)
+#define RCC_APB1ENR_WWDGEN (1 << 11)
+#define RCC_APB1ENR_TIM7EN (1 << 5)
+#define RCC_APB1ENR_TIM6EN (1 << 4)
+#define RCC_APB1ENR_TIM5EN (1 << 3)
+#define RCC_APB1ENR_TIM4EN (1 << 2)
+#define RCC_APB1ENR_TIM3EN (1 << 1)
+#define RCC_APB1ENR_TIM2EN (1 << 0)
+/**@}*/
+
+/* --- RCC_BDCR values ----------------------------------------------------- */
+
+#define RCC_BDCR_BDRST (1 << 16)
+#define RCC_BDCR_RTCEN (1 << 15)
+/* RCC_BDCR[9:8]: RTCSEL */
+#define RCC_BDCR_LSEBYP (1 << 2)
+#define RCC_BDCR_LSERDY (1 << 1)
+#define RCC_BDCR_LSEON (1 << 0)
+
+/* --- RCC_CSR values ------------------------------------------------------ */
+
+#define RCC_CSR_LPWRRSTF (1 << 31)
+#define RCC_CSR_WWDGRSTF (1 << 30)
+#define RCC_CSR_IWDGRSTF (1 << 29)
+#define RCC_CSR_SFTRSTF (1 << 28)
+#define RCC_CSR_PORRSTF (1 << 27)
+#define RCC_CSR_PINRSTF (1 << 26)
+#define RCC_CSR_RMVF (1 << 24)
+#define RCC_CSR_LSIRDY (1 << 1)
+#define RCC_CSR_LSION (1 << 0)
+
+/* --- RCC_AHBRSTR values -------------------------------------------------- */
+
+/** @defgroup rcc_ahbrstr_rst RCC_AHBRSTR reset values
+@ingroup STM32F1xx_rcc_defines
+
+@{*/
+#define RCC_AHBRSTR_ETHMACRST (1 << 14)
+#define RCC_AHBRSTR_OTGFSRST (1 << 12)
+/**@}*/
+
+/* --- RCC_CFGR2 values ---------------------------------------------------- */
+
+/* I2S3SRC: I2S3 clock source */
+#define RCC_CFGR2_I2S3SRC_SYSCLK 0x0
+#define RCC_CFGR2_I2S3SRC_PLL3_VCO_CLK 0x1
+
+/* I2S2SRC: I2S2 clock source */
+#define RCC_CFGR2_I2S2SRC_SYSCLK 0x0
+#define RCC_CFGR2_I2S2SRC_PLL3_VCO_CLK 0x1
+#define RCC_CFGR2_I2S2SRC (1 << 17)
+
+/* PREDIV1SRC: PREDIV1 entry clock source */
+#define RCC_CFGR2_PREDIV1SRC_HSE_CLK 0x0
+#define RCC_CFGR2_PREDIV1SRC_PLL2_CLK 0x1
+#define RCC_CFGR2_PREDIV1SRC (1 << 16)
+
+#define RCC_CFGR2_PLL3MUL_SHIFT 12
+#define RCC_CFGR2_PLL3MUL (0xF << RCC_CFGR2_PLL3MUL_SHIFT)
+
+#define RCC_CFGR2_PLL2MUL_SHIFT 8
+#define RCC_CFGR2_PLL2MUL (0xF << RCC_CFGR2_PLL2MUL_SHIFT)
+
+#define RCC_CFGR2_PREDIV2_SHIFT 4
+#define RCC_CFGR2_PREDIV2 (0xF << RCC_CFGR2_PREDIV2_SHIFT)
+
+#define RCC_CFGR2_PREDIV1_SHIFT 0
+#define RCC_CFGR2_PREDIV1 (0xF << RCC_CFGR2_PREDIV1_SHIFT)
+
+/* PLL3MUL: PLL3 multiplication factor */
+#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL8 0x6
+#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL9 0x7
+#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL10 0x8
+#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL11 0x9
+#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL12 0xa
+#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL13 0xb
+#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL14 0xc
+#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL16 0xe
+#define RCC_CFGR2_PLL3MUL_PLL3_CLK_MUL20 0xf
+
+/* PLL2MUL: PLL2 multiplication factor */
+#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL8 0x6
+#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL9 0x7
+#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL10 0x8
+#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL11 0x9
+#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL12 0xa
+#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL13 0xb
+#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL14 0xc
+#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL16 0xe
+#define RCC_CFGR2_PLL2MUL_PLL2_CLK_MUL20 0xf
+
+/* PREDIV: PREDIV division factor */
+#define RCC_CFGR2_PREDIV_NODIV 0x0
+#define RCC_CFGR2_PREDIV_DIV2 0x1
+#define RCC_CFGR2_PREDIV_DIV3 0x2
+#define RCC_CFGR2_PREDIV_DIV4 0x3
+#define RCC_CFGR2_PREDIV_DIV5 0x4
+#define RCC_CFGR2_PREDIV_DIV6 0x5
+#define RCC_CFGR2_PREDIV_DIV7 0x6
+#define RCC_CFGR2_PREDIV_DIV8 0x7
+#define RCC_CFGR2_PREDIV_DIV9 0x8
+#define RCC_CFGR2_PREDIV_DIV10 0x9
+#define RCC_CFGR2_PREDIV_DIV11 0xa
+#define RCC_CFGR2_PREDIV_DIV12 0xb
+#define RCC_CFGR2_PREDIV_DIV13 0xc
+#define RCC_CFGR2_PREDIV_DIV14 0xd
+#define RCC_CFGR2_PREDIV_DIV15 0xe
+#define RCC_CFGR2_PREDIV_DIV16 0xf
+
+/* PREDIV2: PREDIV2 division factor */
+#define RCC_CFGR2_PREDIV2_NODIV 0x0
+#define RCC_CFGR2_PREDIV2_DIV2 0x1
+#define RCC_CFGR2_PREDIV2_DIV3 0x2
+#define RCC_CFGR2_PREDIV2_DIV4 0x3
+#define RCC_CFGR2_PREDIV2_DIV5 0x4
+#define RCC_CFGR2_PREDIV2_DIV6 0x5
+#define RCC_CFGR2_PREDIV2_DIV7 0x6
+#define RCC_CFGR2_PREDIV2_DIV8 0x7
+#define RCC_CFGR2_PREDIV2_DIV9 0x8
+#define RCC_CFGR2_PREDIV2_DIV10 0x9
+#define RCC_CFGR2_PREDIV2_DIV11 0xa
+#define RCC_CFGR2_PREDIV2_DIV12 0xb
+#define RCC_CFGR2_PREDIV2_DIV13 0xc
+#define RCC_CFGR2_PREDIV2_DIV14 0xd
+#define RCC_CFGR2_PREDIV2_DIV15 0xe
+#define RCC_CFGR2_PREDIV2_DIV16 0xf
+
+/* --- Variable definitions ------------------------------------------------ */
+extern uint32_t rcc_ppre1_frequency;
+extern uint32_t rcc_ppre2_frequency;
+
+/* --- Function prototypes ------------------------------------------------- */
+
+enum rcc_osc {
+ PLL, PLL2, PLL3, HSE, HSI, LSE, LSI
+};
+
+#define _REG_BIT(base, bit) (((base) << 5) + (bit))
+
+/* V = value line F100
+ * N = standard line F101, F102, F103
+ * C = communication line F105, F107
+ */
+enum rcc_periph_clken {
+
+ /* AHB peripherals */
+ RCC_DMA1 = _REG_BIT(0x14, 0),/*VNC*/
+ RCC_DMA2 = _REG_BIT(0x14, 1),/*VNC*/
+ RCC_SRAM = _REG_BIT(0x14, 2),/*VNC*/
+ RCC_FLTF = _REG_BIT(0x14, 4),/*VNC*/
+ RCC_CRC = _REG_BIT(0x14, 6),/*VNC*/
+ RCC_FSMC = _REG_BIT(0x14, 8),/*VN-*/
+ RCC_SDIO = _REG_BIT(0x14, 10),/*-N-*/
+ RCC_OTGFS = _REG_BIT(0x14, 12),/*--C*/
+ RCC_ETHMAC = _REG_BIT(0x14, 14),/*--C*/
+ RCC_ETHMACTX = _REG_BIT(0x14, 15),/*--C*/
+ RCC_ETHMACRX = _REG_BIT(0x14, 16),/*--C*/
+
+ /* APB2 peripherals */
+ RCC_AFIO = _REG_BIT(0x18, 0),/*VNC*/
+ RCC_GPIOA = _REG_BIT(0x18, 2),/*VNC*/
+ RCC_GPIOB = _REG_BIT(0x18, 3),/*VNC*/
+ RCC_GPIOC = _REG_BIT(0x18, 4),/*VNC*/
+ RCC_GPIOD = _REG_BIT(0x18, 5),/*VNC*/
+ RCC_GPIOE = _REG_BIT(0x18, 6),/*VNC*/
+ RCC_GPIOF = _REG_BIT(0x18, 7),/*VN-*/
+ RCC_GPIOG = _REG_BIT(0x18, 8),/*VN-*/
+ RCC_ADC1 = _REG_BIT(0x18, 9),/*VNC*/
+ RCC_ADC2 = _REG_BIT(0x18, 10),/*-NC*/
+ RCC_TIM1 = _REG_BIT(0x18, 11),/*VNC*/
+ RCC_SPI1 = _REG_BIT(0x18, 12),/*VNC*/
+ RCC_TIM8 = _REG_BIT(0x18, 13),/*-N-*/
+ RCC_USART1 = _REG_BIT(0x18, 14),/*VNC*/
+ RCC_ADC3 = _REG_BIT(0x18, 15),/*-N-*/
+ RCC_TIM15 = _REG_BIT(0x18, 16),/*V--*/
+ RCC_TIM16 = _REG_BIT(0x18, 17),/*V--*/
+ RCC_TIM17 = _REG_BIT(0x18, 18),/*V--*/
+ RCC_TIM9 = _REG_BIT(0x18, 19),/*-N-*/
+ RCC_TIM10 = _REG_BIT(0x18, 20),/*-N-*/
+ RCC_TIM11 = _REG_BIT(0x18, 21),/*-N-*/
+
+ /* APB1 peripherals */
+ RCC_TIM2 = _REG_BIT(0x1C, 0),/*VNC*/
+ RCC_TIM3 = _REG_BIT(0x1C, 1),/*VNC*/
+ RCC_TIM4 = _REG_BIT(0x1C, 2),/*VNC*/
+ RCC_TIM5 = _REG_BIT(0x1C, 3),/*VNC*/
+ RCC_TIM6 = _REG_BIT(0x1C, 4),/*VNC*/
+ RCC_TIM7 = _REG_BIT(0x1C, 5),/*VNC*/
+ RCC_TIM12 = _REG_BIT(0x1C, 6),/*VN-*/
+ RCC_TIM13 = _REG_BIT(0x1C, 7),/*VN-*/
+ RCC_TIM14 = _REG_BIT(0x1C, 8),/*VN-*/
+ RCC_WWDG = _REG_BIT(0x1C, 11),/*VNC*/
+ RCC_SPI2 = _REG_BIT(0x1C, 14),/*VNC*/
+ RCC_SPI3 = _REG_BIT(0x1C, 15),/*VNC*/
+ RCC_USART2 = _REG_BIT(0x1C, 17),/*VNC*/
+ RCC_USART3 = _REG_BIT(0x1C, 18),/*VNC*/
+ RCC_UART4 = _REG_BIT(0x1C, 19),/*VNC*/
+ RCC_UART5 = _REG_BIT(0x1C, 20),/*VNC*/
+ RCC_I2C1 = _REG_BIT(0x1C, 21),/*VNC*/
+ RCC_I2C2 = _REG_BIT(0x1C, 22),/*VNC*/
+ RCC_USB = _REG_BIT(0x1C, 23),/*-N-*/
+ RCC_CAN = _REG_BIT(0x1C, 25),/*-N-*/
+ RCC_CAN1 = _REG_BIT(0x1C, 25),/*--C*/
+ RCC_CAN2 = _REG_BIT(0x1C, 26),/*--C*/
+ RCC_BKP = _REG_BIT(0x1C, 27),/*VNC*/
+ RCC_PWR = _REG_BIT(0x1C, 28),/*VNC*/
+ RCC_DAC = _REG_BIT(0x1C, 29),/*VNC*/
+ RCC_CEC = _REG_BIT(0x1C, 30),/*V--*/
+};
+
+enum rcc_periph_rst {
+
+ /* AHB peripherals */
+ RST_OTGFS = _REG_BIT(0x28, 12),/*--C*/
+ RST_ETHMAC = _REG_BIT(0x28, 14),/*--C*/
+
+ /* APB2 peripherals */
+ RST_AFIO = _REG_BIT(0x0c, 0),/*VNC*/
+ RST_GPIOA = _REG_BIT(0x0c, 2),/*VNC*/
+ RST_GPIOB = _REG_BIT(0x0c, 3),/*VNC*/
+ RST_GPIOC = _REG_BIT(0x0c, 4),/*VNC*/
+ RST_GPIOD = _REG_BIT(0x0c, 5),/*VNC*/
+ RST_GPIOE = _REG_BIT(0x0c, 6),/*VNC*/
+ RST_GPIOF = _REG_BIT(0x0c, 7),/*VN-*/
+ RST_GPIOG = _REG_BIT(0x0c, 8),/*VN-*/
+ RST_ADC1 = _REG_BIT(0x0c, 9),/*VNC*/
+ RST_ADC2 = _REG_BIT(0x0c, 10),/*-NC*/
+ RST_TIM1 = _REG_BIT(0x0c, 11),/*VNC*/
+ RST_SPI1 = _REG_BIT(0x0c, 12),/*VNC*/
+ RST_TIM8 = _REG_BIT(0x0c, 13),/*-N-*/
+ RST_USART1 = _REG_BIT(0x0c, 14),/*VNC*/
+ RST_ADC3 = _REG_BIT(0x0c, 15),/*-N-*/
+ RST_TIM15 = _REG_BIT(0x0c, 16),/*V--*/
+ RST_TIM16 = _REG_BIT(0x0c, 17),/*V--*/
+ RST_TIM17 = _REG_BIT(0x0c, 18),/*V--*/
+ RST_TIM9 = _REG_BIT(0x0c, 19),/*-N-*/
+ RST_TIM10 = _REG_BIT(0x0c, 20),/*-N-*/
+ RST_TIM11 = _REG_BIT(0x0c, 21),/*-N-*/
+
+ /* APB1 peripherals */
+ RST_TIM2 = _REG_BIT(0x10, 0),/*VNC*/
+ RST_TIM3 = _REG_BIT(0x10, 1),/*VNC*/
+ RST_TIM4 = _REG_BIT(0x10, 2),/*VNC*/
+ RST_TIM5 = _REG_BIT(0x10, 3),/*VNC*/
+ RST_TIM6 = _REG_BIT(0x10, 4),/*VNC*/
+ RST_TIM7 = _REG_BIT(0x10, 5),/*VNC*/
+ RST_TIM12 = _REG_BIT(0x10, 6),/*VN-*/
+ RST_TIM13 = _REG_BIT(0x10, 7),/*VN-*/
+ RST_TIM14 = _REG_BIT(0x10, 8),/*VN-*/
+ RST_WWDG = _REG_BIT(0x10, 11),/*VNC*/
+ RST_SPI2 = _REG_BIT(0x10, 14),/*VNC*/
+ RST_SPI3 = _REG_BIT(0x10, 15),/*VNC*/
+ RST_USART2 = _REG_BIT(0x10, 17),/*VNC*/
+ RST_USART3 = _REG_BIT(0x10, 18),/*VNC*/
+ RST_UART4 = _REG_BIT(0x10, 19),/*VNC*/
+ RST_UART5 = _REG_BIT(0x10, 20),/*VNC*/
+ RST_I2C1 = _REG_BIT(0x10, 21),/*VNC*/
+ RST_I2C2 = _REG_BIT(0x10, 22),/*VNC*/
+ RST_USB = _REG_BIT(0x10, 23),/*-N-*/
+ RST_CAN = _REG_BIT(0x10, 24),/*-N-*/
+ RST_CAN1 = _REG_BIT(0x10, 24),/*--C*/
+ RST_CAN2 = _REG_BIT(0x10, 25),/*--C*/
+ RST_BKP = _REG_BIT(0x10, 27),/*VNC*/
+ RST_PWR = _REG_BIT(0x10, 28),/*VNC*/
+ RST_DAC = _REG_BIT(0x10, 29),/*VNC*/
+ RST_CEC = _REG_BIT(0x10, 30),/*V--*/
+};
+
+#include <libopencm3/stm32/common/rcc_common_all.h>
+
+BEGIN_DECLS
+
+void rcc_osc_ready_int_clear(enum rcc_osc osc);
+void rcc_osc_ready_int_enable(enum rcc_osc osc);
+void rcc_osc_ready_int_disable(enum rcc_osc osc);
+int rcc_osc_ready_int_flag(enum rcc_osc osc);
+void rcc_css_int_clear(void);
+int rcc_css_int_flag(void);
+void rcc_wait_for_osc_ready(enum rcc_osc osc);
+void rcc_osc_on(enum rcc_osc osc);
+void rcc_osc_off(enum rcc_osc osc);
+void rcc_css_enable(void);
+void rcc_css_disable(void);
+void rcc_set_mco(uint32_t mcosrc);
+void rcc_osc_bypass_enable(enum rcc_osc osc);
+void rcc_osc_bypass_disable(enum rcc_osc osc);
+void rcc_set_sysclk_source(uint32_t clk);
+void rcc_set_pll_multiplication_factor(uint32_t mul);
+void rcc_set_pll2_multiplication_factor(uint32_t mul);
+void rcc_set_pll3_multiplication_factor(uint32_t mul);
+void rcc_set_pll_source(uint32_t pllsrc);
+void rcc_set_pllxtpre(uint32_t pllxtpre);
+void rcc_set_adcpre(uint32_t adcpre);
+void rcc_set_ppre2(uint32_t ppre2);
+void rcc_set_ppre1(uint32_t ppre1);
+void rcc_set_hpre(uint32_t hpre);
+void rcc_set_usbpre(uint32_t usbpre);
+void rcc_set_prediv1(uint32_t prediv);
+void rcc_set_prediv2(uint32_t prediv);
+void rcc_set_prediv1_source(uint32_t rccsrc);
+uint32_t rcc_system_clock_source(void);
+void rcc_clock_setup_in_hsi_out_64mhz(void);
+void rcc_clock_setup_in_hsi_out_48mhz(void);
+void rcc_clock_setup_in_hsi_out_24mhz(void);
+void rcc_clock_setup_in_hse_8mhz_out_24mhz(void);
+void rcc_clock_setup_in_hse_8mhz_out_72mhz(void);
+void rcc_clock_setup_in_hse_12mhz_out_72mhz(void);
+void rcc_clock_setup_in_hse_16mhz_out_72mhz(void);
+void rcc_clock_setup_in_hse_25mhz_out_72mhz(void);
+void rcc_backupdomain_reset(void);
+
+END_DECLS
+
+#endif
+/**@}*/
+
diff --git a/libopencm3/include/libopencm3/stm32/f1/rtc.h b/libopencm3/include/libopencm3/stm32/f1/rtc.h
new file mode 100644
index 0000000..3a60fca
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/rtc.h
@@ -0,0 +1,170 @@
+/** @defgroup rtc_defines RTC Defines
+ *
+ * @brief <b>Defined Constants and Types for the STM32F1xx Real Time Clock</b>
+ *
+ * @ingroup STM32F1xx_defines
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2010 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * @version 1.0.0
+ *
+ * @date 4 March 2013
+ *
+ * LGPL License Terms @ref lgpl_license
+ * */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2010 Uwe Hermann <uwe@hermann-uwe.de>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+/*
+ * The F1 RTC is a straight time stamp, a completely different peripheral to
+ * that found in the F2, F3, F4, L1 and F0.
+ */
+
+#ifndef LIBOPENCM3_RTC_H
+#define LIBOPENCM3_RTC_H
+/**@{*/
+
+#include <libopencm3/stm32/pwr.h>
+#include <libopencm3/stm32/rcc.h>
+
+/* --- RTC registers ------------------------------------------------------- */
+
+/* RTC control register high (RTC_CRH) */
+#define RTC_CRH MMIO32(RTC_BASE + 0x00)
+
+/* RTC control register low (RTC_CRL) */
+#define RTC_CRL MMIO32(RTC_BASE + 0x04)
+
+/* RTC prescaler load register (RTC_PRLH / RTC_PRLL) */
+#define RTC_PRLH MMIO32(RTC_BASE + 0x08)
+#define RTC_PRLL MMIO32(RTC_BASE + 0x0c)
+
+/* RTC prescaler divider register (RTC_DIVH / RTC_DIVL) */
+#define RTC_DIVH MMIO32(RTC_BASE + 0x10)
+#define RTC_DIVL MMIO32(RTC_BASE + 0x14)
+
+/* RTC counter register (RTC_CNTH / RTC_CNTL) */
+#define RTC_CNTH MMIO32(RTC_BASE + 0x18)
+#define RTC_CNTL MMIO32(RTC_BASE + 0x1c)
+
+/* RTC alarm register high (RTC_ALRH / RTC_ALRL) */
+#define RTC_ALRH MMIO32(RTC_BASE + 0x20)
+#define RTC_ALRL MMIO32(RTC_BASE + 0x24)
+
+/* --- RTC_CRH values -------------------------------------------------------*/
+
+/* Note: Bits [15:3] are reserved, and forced to 0 by hardware. */
+
+/* OWIE: Overflow interrupt enable */
+#define RTC_CRH_OWIE (1 << 2)
+
+/* ALRIE: Alarm interrupt enable */
+#define RTC_CRH_ALRIE (1 << 1)
+
+/* SECIE: Second interrupt enable */
+#define RTC_CRH_SECIE (1 << 0)
+
+/* --- RTC_CRL values -------------------------------------------------------*/
+
+/* Note: Bits [15:6] are reserved, and forced to 0 by hardware. */
+
+/* RTOFF: RTC operation OFF */
+#define RTC_CRL_RTOFF (1 << 5)
+
+/* CNF: Configuration flag */
+#define RTC_CRL_CNF (1 << 4)
+
+/* RSF: Registers synchronized flag */
+#define RTC_CRL_RSF (1 << 3)
+
+/* OWF: Overflow flag */
+#define RTC_CRL_OWF (1 << 2)
+
+/* ALRF: Alarm flag */
+#define RTC_CRL_ALRF (1 << 1)
+
+/* SECF: Second flag */
+#define RTC_CRL_SECF (1 << 0)
+
+/* --- RTC_PRLH values ------------------------------------------------------*/
+
+/* Note: Bits [15:4] are reserved, and forced to 0 by hardware. */
+
+/* TODO */
+
+/* --- RTC_PRLL values ------------------------------------------------------*/
+
+/* TODO */
+
+/* --- RTC_DIVH values ------------------------------------------------------*/
+
+/* Bits [15:4] are reserved. */
+
+/* TODO */
+
+/* --- RTC_DIVL values ------------------------------------------------------*/
+
+/* TODO */
+
+/* --- RTC_CNTH values ------------------------------------------------------*/
+
+/* TODO */
+
+/* --- RTC_CNTL values ------------------------------------------------------*/
+
+/* TODO */
+
+/* --- RTC_ALRH values ------------------------------------------------------*/
+
+/* TODO */
+
+/* --- RTC_ALRL values ------------------------------------------------------*/
+
+/* TODO */
+
+/* --- Function prototypes --------------------------------------------------*/
+
+typedef enum {
+ RTC_SEC, RTC_ALR, RTC_OW,
+} rtcflag_t;
+
+BEGIN_DECLS
+
+void rtc_awake_from_off(enum rcc_osc clock_source);
+void rtc_enter_config_mode(void);
+void rtc_exit_config_mode(void);
+void rtc_set_alarm_time(uint32_t alarm_time);
+void rtc_enable_alarm(void);
+void rtc_disable_alarm(void);
+void rtc_set_prescale_val(uint32_t prescale_val);
+uint32_t rtc_get_counter_val(void);
+uint32_t rtc_get_prescale_div_val(void);
+uint32_t rtc_get_alarm_val(void);
+void rtc_set_counter_val(uint32_t counter_val);
+void rtc_interrupt_enable(rtcflag_t flag_val);
+void rtc_interrupt_disable(rtcflag_t flag_val);
+void rtc_clear_flag(rtcflag_t flag_val);
+uint32_t rtc_check_flag(rtcflag_t flag_val);
+void rtc_awake_from_standby(void);
+void rtc_auto_awake(enum rcc_osc clock_source, uint32_t prescale_val);
+
+END_DECLS
+/**@}*/
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/f1/spi.h b/libopencm3/include/libopencm3/stm32/f1/spi.h
new file mode 100644
index 0000000..8513454
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/spi.h
@@ -0,0 +1,37 @@
+/** @defgroup spi_defines SPI Defines
+
+@brief <b>Defined Constants and Types for the STM32F1xx SPI</b>
+
+@ingroup STM32F1xx_defines
+
+@version 1.0.0
+
+@date 5 December 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_SPI_H
+#define LIBOPENCM3_SPI_H
+
+#include <libopencm3/stm32/common/spi_common_l1f124.h>
+
+#endif
+
diff --git a/libopencm3/include/libopencm3/stm32/f1/timer.h b/libopencm3/include/libopencm3/stm32/f1/timer.h
new file mode 100644
index 0000000..6046d79
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/timer.h
@@ -0,0 +1,56 @@
+/** @defgroup timer_defines Timer Defines
+
+@brief <b>libopencm3 Defined Constants and Types for the STM32F1xx Timers</b>
+
+@ingroup STM32F1xx_defines
+
+@version 1.0.0
+
+@date 8 March 2013
+
+@author @htmlonly &copy; @endhtmlonly 2011 Fergus Noble <fergusnoble@gmail.com>
+
+LGPL License Terms @ref lgpl_license
+*/
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2011 Fergus Noble <fergusnoble@gmail.com>
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_TIMER_H
+#define LIBOPENCM3_TIMER_H
+
+#include <libopencm3/stm32/common/timer_common_all.h>
+
+/** Input Capture input polarity */
+enum tim_ic_pol {
+ TIM_IC_RISING,
+ TIM_IC_FALLING,
+};
+
+/* --- Function prototypes ------------------------------------------------- */
+
+BEGIN_DECLS
+
+void timer_ic_set_polarity(uint32_t timer,
+ enum tim_ic_id ic,
+ enum tim_ic_pol pol);
+
+END_DECLS
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/f1/usart.h b/libopencm3/include/libopencm3/stm32/f1/usart.h
new file mode 100644
index 0000000..324d78e
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/f1/usart.h
@@ -0,0 +1,37 @@
+/** @defgroup usart_defines USART Defines
+
+@brief <b>Defined Constants and Types for the STM32F1xx USART</b>
+
+@ingroup STM32F1xx_defines
+
+@version 1.0.0
+
+@date 5 December 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * 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 <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef LIBOPENCM3_USART_H
+#define LIBOPENCM3_USART_H
+
+#include <libopencm3/stm32/common/usart_common_f124.h>
+
+#endif
+