summaryrefslogtreecommitdiffstats
path: root/libopencm3/include/libopencm3/stm32/l1
diff options
context:
space:
mode:
Diffstat (limited to 'libopencm3/include/libopencm3/stm32/l1')
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/adc.h227
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/crc.h38
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/dac.h37
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/dma.h42
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/doc-stm32l1.h32
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/exti.h41
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/flash.h156
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/gpio.h263
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/i2c.h37
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/irq.json64
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/iwdg.h39
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/lcd.h231
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/memorymap.h126
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/pwr.h111
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/rcc.h612
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/rtc.h36
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/spi.h37
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/syscfg.h41
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/timer.h89
-rw-r--r--libopencm3/include/libopencm3/stm32/l1/usart.h37
20 files changed, 2296 insertions, 0 deletions
diff --git a/libopencm3/include/libopencm3/stm32/l1/adc.h b/libopencm3/include/libopencm3/stm32/l1/adc.h
new file mode 100644
index 0000000..cd56d15
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/adc.h
@@ -0,0 +1,227 @@
+/** @defgroup adc_defines ADC Defines
+
+@brief <b>Defined Constants and Types for the STM32L1xx Analog to
+Digital Converters</b>
+
+@ingroup STM32L1xx_defines
+
+@version 1.0.0
+
+@author @htmlonly &copy; @endhtmlonly 2013 Karl Palsson <karlp@remake.is>
+
+LGPL License Terms @ref lgpl_license
+ */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2013 Karl Palsson <karlp@remake.is>
+ *
+ * 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>
+
+#define ADC_MAX_REGULAR_SEQUENCE 28
+/* 26 in L/M, but 32 in two banks for M+/H density */
+#define ADC_MAX_CHANNELS 32
+
+/* ADC sample time register 3 (ADC_SMPR3) */
+#define ADC_SMPR3(block) MMIO32(block + 0x14)
+#define ADC1_SMPR3 ADC_SMPR3(ADC1)
+
+/* ADC injected channel data offset register x (ADC_JOFRx) (x=1..4) */
+#define ADC_JOFR1(block) MMIO32(block + 0x18)
+#define ADC_JOFR2(block) MMIO32(block + 0x1c)
+#define ADC_JOFR3(block) MMIO32(block + 0x20)
+#define ADC_JOFR4(block) MMIO32(block + 0x24)
+
+/* ADC watchdog high threshold register (ADC_HTR) */
+#define ADC_HTR(block) MMIO32(block + 0x28)
+
+/* ADC watchdog low threshold register (ADC_LTR) */
+#define ADC_LTR(block) MMIO32(block + 0x2c)
+
+/* ADC regular sequence register 1 (ADC_SQR1) */
+#define ADC_SQR1(block) MMIO32(block + 0x30)
+
+/* ADC regular sequence register 2 (ADC_SQR2) */
+#define ADC_SQR2(block) MMIO32(block + 0x34)
+
+/* ADC regular sequence register 3 (ADC_SQR3) */
+#define ADC_SQR3(block) MMIO32(block + 0x38)
+
+/* ADC regular sequence register 4 (ADC_SQR4) */
+#define ADC_SQR4(block) MMIO32(block + 0x3c)
+#define ADC1_SQR4 ADC_SQR4(ADC1)
+
+/* ADC regular sequence register 5 (ADC_SQR5) */
+#define ADC_SQR5(block) MMIO32(block + 0x40)
+#define ADC1_SQR5 ADC_SQR5(ADC1)
+
+/* ADC injected sequence register (ADC_JSQR) */
+#define ADC_JSQR(block) MMIO32(block + 0x44)
+
+/* ADC injected data register x (ADC_JDRx) (x=1..4) */
+#define ADC_JDR1(block) MMIO32(block + 0x48)
+#define ADC_JDR2(block) MMIO32(block + 0x4c)
+#define ADC_JDR3(block) MMIO32(block + 0x50)
+#define ADC_JDR4(block) MMIO32(block + 0x54)
+
+/* ADC regular data register (ADC_DR) */
+#define ADC_DR(block) MMIO32(block + 0x58)
+
+/* ADC sample time register 0 (ADC_SMPR0) (high/med+ only) */
+#define ADC_SMPR0(block) MMIO32(block + 0x5c)
+#define ADC1_SMPR0 ADC_SMPR0(ADC1)
+
+#define ADC_CSR MMIO32(ADC1 + 0x300)
+#define ADC_CCR MMIO32(ADC1 + 0x304)
+
+
+/* These are _not_ consistent unfortunately! */
+#define ADC_CHANNEL_TEMP ADC_CHANNEL16
+#define ADC_CHANNEL_VREFINT ADC_CHANNEL17
+#define ADC_CHANNEL_VBAT ADC_CHANNEL18
+
+/* --- ADC_SR values ------------------------------------------------------- */
+#define ADC_SR_JCNR (1 << 9)
+#define ADC_SR_RCNR (1 << 8)
+#define ADC_SR_ADONS (1 << 6)
+#define ADC_SR_OVR (1 << 5)
+
+/* --- ADC_CR1 values ------------------------------------------------------- */
+#define ADC_CR1_OVRIE (1 << 28)
+/****************************************************************************/
+/** @defgroup adc_cr1_res ADC Resolution.
+@ingroup adc_defines
+@{*/
+#define ADC_CR1_RES_12_BIT 0
+#define ADC_CR1_RES_10_BIT 1
+#define ADC_CR1_RES_8_BIT 2
+#define ADC_CR1_RES_6_BIT 3
+/**@}*/
+#define ADC_CR1_RES_MASK (0x3)
+#define ADC_CR1_RES_SHIFT 24
+#define ADC_CR1_PDI (1 << 17)
+#define ADC_CR1_PDD (1 << 16)
+
+#define ADC_CR1_AWDCH_MAX 26
+
+/* --- ADC_CR2 values ------------------------------------------------------- */
+/* SWSTART: */ /** Start conversion of regular channels. */
+#define ADC_CR2_SWSTART (1 << 30)
+
+/* EXTEN[1:0]: External trigger enable for regular channels. */
+/****************************************************************************/
+#define ADC_CR2_EXTEN_SHIFT 28
+#define ADC_CR2_EXTEN_MASK (0x3 << ADC_CR2_EXTEN_SHIFT)
+/** @defgroup adc_trigger_polarity_regular ADC Trigger Polarity
+@ingroup adc_defines
+@{*/
+#define ADC_CR2_EXTEN_DISABLED (0x0 << ADC_CR2_EXTEN_SHIFT)
+#define ADC_CR2_EXTEN_RISING_EDGE (0x1 << ADC_CR2_EXTEN_SHIFT)
+#define ADC_CR2_EXTEN_FALLING_EDGE (0x2 << ADC_CR2_EXTEN_SHIFT)
+#define ADC_CR2_EXTEN_BOTH_EDGES (0x3 << ADC_CR2_EXTEN_SHIFT)
+/**@}*/
+
+/* EXTSEL[3:0]: External event selection for regular group. */
+/****************************************************************************/
+#define ADC_CR2_EXTSEL_SHIFT 24
+#define ADC_CR2_EXTSEL_MASK (0xf << ADC_CR2_EXTSEL_SHIFT)
+/** @defgroup adc_trigger_regular ADC Trigger Identifier for Regular group
+@ingroup adc_defines
+
+@{*/
+#define ADC_CR2_EXTSEL_TIM9_CC2 (0 << ADC_CR2_EXTSEL_SHIFT)
+#define ADC_CR2_EXTSEL_TIM9_TRGO (1 << ADC_CR2_EXTSEL_SHIFT)
+#define ADC_CR2_EXTSEL_TIM2_CC3 (2 << ADC_CR2_EXTSEL_SHIFT)
+#define ADC_CR2_EXTSEL_TIM2_CC2 (3 << ADC_CR2_EXTSEL_SHIFT)
+#define ADC_CR2_EXTSEL_TIM3_TRGO (4 << ADC_CR2_EXTSEL_SHIFT)
+#define ADC_CR2_EXTSEL_TIM4_CC4 (5 << ADC_CR2_EXTSEL_SHIFT)
+#define ADC_CR2_EXTSEL_TIM2_TRGO (6 << ADC_CR2_EXTSEL_SHIFT)
+#define ADC_CR2_EXTSEL_TIM3_CC1 (7 << ADC_CR2_EXTSEL_SHIFT)
+#define ADC_CR2_EXTSEL_TIM3_CC3 (8 << ADC_CR2_EXTSEL_SHIFT)
+#define ADC_CR2_EXTSEL_TIM4_TRGO (9 << ADC_CR2_EXTSEL_SHIFT)
+#define ADC_CR2_EXTSEL_TIM6_TRGO (10 << ADC_CR2_EXTSEL_SHIFT)
+/* reserved.... */
+#define ADC_CR2_EXTSEL_EXTI11 (15 << ADC_CR2_EXTSEL_SHIFT)
+/**@}*/
+
+#define ADC_CR2_JSWSTART (1 << 22)
+
+/* JEXTEN[1:0]: External trigger enable for injected channels. */
+/****************************************************************************/
+#define ADC_CR2_JEXTEN_SHIFT 20
+#define ADC_CR2_JEXTEN_MASK (0x3 << ADC_CR2_JEXTEN_SHIFT)
+/** @defgroup adc_trigger_polarity_injected ADC Injected Trigger Polarity
+@ingroup adc_defines
+@{*/
+#define ADC_CR2_JEXTEN_DISABLED (0x0 << ADC_CR2_JEXTEN_SHIFT)
+#define ADC_CR2_JEXTEN_RISING_EDGE (0x1 << ADC_CR2_JEXTEN_SHIFT)
+#define ADC_CR2_JEXTEN_FALLING_EDGE (0x2 << ADC_CR2_JEXTEN_SHIFT)
+#define ADC_CR2_JEXTEN_BOTH_EDGES (0x3 << ADC_CR2_JEXTEN_SHIFT)
+/**@}*/
+
+/* FIXME - add the values here */
+#define ADC_CR2_JEXTSEL_SHIFT 16
+#define ADC_CR2_JEXTSEL_MASK (0xf << ADC_CR2_JEXTSEL_SHIFT)
+
+#define ADC_CR2_EOCS (1 << 10)
+#define ADC_CR2_DDS (1 << 9)
+/* FIXME- add the values here */
+#define ADC_CR2_DELS_SHIFT 4
+#define ADC_CR2_DELS_MASK 0x7
+
+#define ADC_CR2_ADC_CFG (1 << 2)
+
+
+
+
+/* --- ADC_SMPRx generic 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_4CYC 0x0
+#define ADC_SMPR_SMP_9CYC 0x1
+#define ADC_SMPR_SMP_16CYC 0x2
+#define ADC_SMPR_SMP_24CYC 0x3
+#define ADC_SMPR_SMP_48CYC 0x4
+#define ADC_SMPR_SMP_96CYC 0x5
+#define ADC_SMPR_SMP_192CYC 0x6
+#define ADC_SMPR_SMP_384CYC 0x7
+/**@}*/
+
+#define ADC_SQR_MASK 0x1f
+#define ADC_SQR_MAX_CHANNELS_REGULAR 28 /* m+/h only, otherwise 27 */
+
+#define ADC_CCR_TSVREFE (1 << 23)
+
+BEGIN_DECLS
+ /* L1 specific, or not fully unified adc routines */
+void adc_enable_temperature_sensor(void);
+void adc_disable_temperature_sensor(void);
+void adc_enable_external_trigger_regular(uint32_t adc, uint32_t trigger,
+ uint32_t polarity);
+void adc_enable_external_trigger_injected(uint32_t adc, uint32_t trigger,
+ uint32_t polarity);
+
+END_DECLS
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/l1/crc.h b/libopencm3/include/libopencm3/stm32/l1/crc.h
new file mode 100644
index 0000000..e019c34
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/crc.h
@@ -0,0 +1,38 @@
+/** @defgroup crc_defines CRC Defines
+
+@brief <b>libopencm3 Defined Constants and Types for the STM32L1xx CRC
+Generator </b>
+
+@ingroup STM32L1xx_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/l1/dac.h b/libopencm3/include/libopencm3/stm32/l1/dac.h
new file mode 100644
index 0000000..207c59d
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/dac.h
@@ -0,0 +1,37 @@
+/** @defgroup dac_defines DAC Defines
+
+@brief <b>Defined Constants and Types for the STM32L1xx DAC</b>
+
+@ingroup STM32L1xx_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/l1/dma.h b/libopencm3/include/libopencm3/stm32/l1/dma.h
new file mode 100644
index 0000000..c1728d1
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/dma.h
@@ -0,0 +1,42 @@
+/** @defgroup dma_defines DMA Defines
+ *
+ * @ingroup STM32L1xx_defines
+ *
+ * @brief Defined Constants and Types for the STM32L1xx DMA Controller
+ *
+ * @version 1.0.0
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2011
+ * Fergus Noble <fergusnoble@gmail.com>
+ * @author @htmlonly &copy; @endhtmlonly 2012
+ * Ken Sarkies <ksarkies@internode.on.net>
+ *
+ * @date 18 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_DMA_H
+#define LIBOPENCM3_DMA_H
+
+#include <libopencm3/stm32/common/dma_common_l1f013.h>
+
+#endif
+
diff --git a/libopencm3/include/libopencm3/stm32/l1/doc-stm32l1.h b/libopencm3/include/libopencm3/stm32/l1/doc-stm32l1.h
new file mode 100644
index 0000000..96bea00
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/doc-stm32l1.h
@@ -0,0 +1,32 @@
+/** @mainpage libopencm3 STM32L1
+
+@version 1.0.0
+
+@date 12 November 2012
+
+API documentation for ST Microelectronics STM32L1 Cortex M3 series.
+
+LGPL License Terms @ref lgpl_license
+*/
+
+/** @defgroup STM32L1xx STM32L1xx
+Libraries for ST Microelectronics STM32L1xx series.
+
+@version 1.0.0
+
+@date 12 November 2012
+
+LGPL License Terms @ref lgpl_license
+*/
+
+/** @defgroup STM32L1xx_defines STM32L1xx Defines
+
+@brief Defined Constants and Types for the STM32L1xx series
+
+@version 1.0.0
+
+@date 12 November 2012
+
+LGPL License Terms @ref lgpl_license
+*/
+
diff --git a/libopencm3/include/libopencm3/stm32/l1/exti.h b/libopencm3/include/libopencm3/stm32/l1/exti.h
new file mode 100644
index 0000000..2c14c95
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/exti.h
@@ -0,0 +1,41 @@
+/** @defgroup exti_defines EXTI Defines
+ *
+ * @brief <b>Defined Constants and Types for the STM32L1xx External Interrupts
+ * </b>
+ *
+ * @ingroup STM32L1xx_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_l1f24.h>
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/l1/flash.h b/libopencm3/include/libopencm3/stm32/l1/flash.h
new file mode 100644
index 0000000..680de5c
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/flash.h
@@ -0,0 +1,156 @@
+/** @defgroup flash_defines FLASH Defines
+ *
+ * @ingroup STM32L1xx_defines
+ *
+ * @brief Defined Constants and Types for the STM32L1xx FLASH Memory
+ *
+ * @version 1.0.0
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2012
+ * Karl Palsson <karlp@tweak.net.au>
+ *
+ * @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>
+ * Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
+ *
+ * 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/>.
+ */
+
+/*
+ * All extracted from PM0062 rev2, L15xx and L16xx Flash/EEPROM programming
+ * manual.
+ */
+
+#ifndef LIBOPENCM3_FLASH_H
+#define LIBOPENCM3_FLASH_H
+/**@{*/
+
+/* --- FLASH registers ----------------------------------------------------- */
+
+#define FLASH_ACR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x00)
+#define FLASH_PECR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x04)
+#define FLASH_PDKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x08)
+#define FLASH_PEKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x0C)
+#define FLASH_PRGKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x10)
+#define FLASH_OPTKEYR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x14)
+#define FLASH_SR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x18)
+#define FLASH_OBR MMIO32(FLASH_MEM_INTERFACE_BASE + 0x1c)
+#define FLASH_WRPR1 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x20)
+#define FLASH_WRPR2 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x80)
+#define FLASH_WRPR3 MMIO32(FLASH_MEM_INTERFACE_BASE + 0x84)
+
+/* --- FLASH_ACR values ---------------------------------------------------- */
+
+#define FLASH_ACR_RUNPD (1 << 4)
+#define FLASH_ACR_SLEEPPD (1 << 3)
+#define FLASH_ACR_ACC64 (1 << 2)
+#define FLASH_ACR_PRFTEN (1 << 1)
+/** @defgroup flash_latency FLASH Wait States
+@ingroup flash_defines
+@{*/
+#define FLASH_ACR_LATENCY_0WS 0x00
+#define FLASH_ACR_LATENCY_1WS 0x01
+/**@}*/
+
+/* --- FLASH_PECR values. Program/erase control register */
+#define FLASH_PECR_OBL_LAUNCH (1 << 18)
+#define FLASH_PECR_ERRIE (1 << 17)
+#define FLASH_PECR_EOPIE (1 << 16)
+#define FLASH_PECR_PARALLBANK (1 << 15)
+#define FLASH_PECR_FPRG (1 << 10)
+#define FLASH_PECR_ERASE (1 << 9)
+#define FLASH_PECR_FTDW (1 << 8)
+#define FLASH_PECR_FTDW (1 << 8)
+#define FLASH_PECR_DATA (1 << 4)
+#define FLASH_PECR_PROG (1 << 3)
+#define FLASH_PECR_OPTLOCK (1 << 2)
+#define FLASH_PECR_PRGLOCK (1 << 1)
+#define FLASH_PECR_PELOCK (1 << 0)
+
+/* Power down key register (FLASH_PDKEYR) */
+#define FLASH_PDKEYR_PDKEY1 ((uint32_t)0x04152637)
+#define FLASH_PDKEYR_PDKEY2 ((uint32_t)0xFAFBFCFD)
+
+/* Program/erase key register (FLASH_PEKEYR) */
+#define FLASH_PEKEYR_PEKEY1 ((uint32_t)0x89ABCDEF)
+#define FLASH_PEKEYR_PEKEY2 ((uint32_t)0x02030405)
+
+/* Program memory key register (FLASH_PRGKEYR) */
+#define FLASH_PRGKEYR_PRGKEY1 ((uint32_t)0x8C9DAEBF)
+#define FLASH_PRGKEYR_PRGKEY2 ((uint32_t)0x13141516)
+
+/* Option byte key register (FLASH_OPTKEYR) */
+#define FLASH_OPTKEYR_OPTKEY1 ((uint32_t)0xFBEAD9C8)
+#define FLASH_OPTKEYR_OPTKEY2 ((uint32_t)0x24252627)
+
+
+/* --- FLASH_SR values ----------------------------------------------------- */
+#define FLASH_SR_OPTVERRUSR (1 << 12)
+#define FLASH_SR_OPTVERR (1 << 11)
+#define FLASH_SR_SIZEERR (1 << 10)
+#define FLASH_SR_PGAERR (1 << 9)
+#define FLASH_SR_WRPERR (1 << 8)
+#define FLASH_SR_READY (1 << 3)
+#define FLASH_SR_ENDHV (1 << 2)
+#define FLASH_SR_EOP (1 << 1)
+#define FLASH_SR_BSY (1 << 0)
+
+/* --- FLASH_OBR values ----------------------------------------------------- */
+#define FLASH_OBR_BFB2 (1 << 23)
+#define FLASH_OBR_NRST_STDBY (1 << 22)
+#define FLASH_OBR_NRST_STOP (1 << 21)
+#define FLASH_OBR_IWDG_SW (1 << 20)
+#define FLASH_OBR_BOR_OFF (0x0 << 16)
+#define FLASH_OBR_BOR_LEVEL_1 (0x8 << 16)
+#define FLASH_OBR_BOR_LEVEL_2 (0x9 << 16)
+#define FLASH_OBR_BOR_LEVEL_3 (0xa << 16)
+#define FLASH_OBR_BOR_LEVEL_4 (0xb << 16)
+#define FLASH_OBR_BOR_LEVEL_5 (0xc << 16)
+#define FLASH_OBR_RDPRT_LEVEL_0 (0xaa)
+#define FLASH_OBR_RDPRT_LEVEL_1 (0x00)
+#define FLASH_OBR_RDPRT_LEVEL_2 (0xcc)
+
+/* --- Function prototypes ------------------------------------------------- */
+
+BEGIN_DECLS
+
+void flash_64bit_enable(void);
+void flash_64bit_disable(void);
+void flash_prefetch_enable(void);
+void flash_prefetch_disable(void);
+void flash_set_ws(uint32_t ws);
+void flash_unlock_pecr(void);
+void flash_lock_pecr(void);
+void flash_unlock_progmem(void);
+void flash_lock_progmem(void);
+void flash_unlock_option_bytes(void);
+void flash_lock_option_bytes(void);
+void flash_unlock(void);
+void flash_lock(void);
+
+void eeprom_program_word(uint32_t address, uint32_t data);
+void eeprom_program_words(uint32_t address, uint32_t *data, int length_in_words);
+
+END_DECLS
+/**@}*/
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/l1/gpio.h b/libopencm3/include/libopencm3/stm32/l1/gpio.h
new file mode 100644
index 0000000..f2c607c
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/gpio.h
@@ -0,0 +1,263 @@
+/** @defgroup gpio_defines GPIO Defines
+
+@brief <b>Defined Constants and Types for the STM32L1xx General Purpose I/O</b>
+
+@ingroup STM32L1xx_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 Karl Palsson <karlp@tweak.net.au>
+ *
+ * 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) */
+/* GPIO port base addresses (for convenience) */
+/** @defgroup gpio_port_id GPIO Port IDs
+@ingroup gpio_defines
+
+@{*/
+#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 GPIOH GPIO_PORT_H_BASE
+/**@}*/
+
+/* --- GPIO registers ------------------------------------------------------ */
+
+/* Port mode register (GPIOx_MODER) */
+#define GPIO_MODER(port) MMIO32(port + 0x00)
+#define GPIOA_MODER GPIO_MODER(GPIOA)
+#define GPIOB_MODER GPIO_MODER(GPIOB)
+#define GPIOC_MODER GPIO_MODER(GPIOC)
+#define GPIOD_MODER GPIO_MODER(GPIOD)
+#define GPIOE_MODER GPIO_MODER(GPIOE)
+#define GPIOH_MODER GPIO_MODER(GPIOH)
+
+/* Port output type register (GPIOx_OTYPER) */
+#define GPIO_OTYPER(port) MMIO32(port + 0x04)
+#define GPIOA_OTYPER GPIO_OTYPER(GPIOA)
+#define GPIOB_OTYPER GPIO_OTYPER(GPIOB)
+#define GPIOC_OTYPER GPIO_OTYPER(GPIOC)
+#define GPIOD_OTYPER GPIO_OTYPER(GPIOD)
+#define GPIOE_OTYPER GPIO_OTYPER(GPIOE)
+#define GPIOH_OTYPER GPIO_OTYPER(GPIOH)
+
+/* Port output speed register (GPIOx_OSPEEDR) */
+#define GPIO_OSPEEDR(port) MMIO32(port + 0x08)
+#define GPIOA_OSPEEDR GPIO_OSPEEDR(GPIOA)
+#define GPIOB_OSPEEDR GPIO_OSPEEDR(GPIOB)
+#define GPIOC_OSPEEDR GPIO_OSPEEDR(GPIOC)
+#define GPIOD_OSPEEDR GPIO_OSPEEDR(GPIOD)
+#define GPIOE_OSPEEDR GPIO_OSPEEDR(GPIOE)
+#define GPIOH_OSPEEDR GPIO_OSPEEDR(GPIOH)
+
+/* Port pull-up/pull-down register (GPIOx_PUPDR) */
+#define GPIO_PUPDR(port) MMIO32(port + 0x0c)
+#define GPIOA_PUPDR GPIO_PUPDR(GPIOA)
+#define GPIOB_PUPDR GPIO_PUPDR(GPIOB)
+#define GPIOC_PUPDR GPIO_PUPDR(GPIOC)
+#define GPIOD_PUPDR GPIO_PUPDR(GPIOD)
+#define GPIOE_PUPDR GPIO_PUPDR(GPIOE)
+#define GPIOH_PUPDR GPIO_PUPDR(GPIOH)
+
+/* Port input data register (GPIOx_IDR) */
+#define GPIO_IDR(port) MMIO32(port + 0x10)
+#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 GPIOH_IDR GPIO_IDR(GPIOH)
+
+/* Port output data register (GPIOx_ODR) */
+#define GPIO_ODR(port) MMIO32(port + 0x14)
+#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 GPIOH_ODR GPIO_ODR(GPIOH)
+
+/* Port bit set/reset register (GPIOx_BSRR) */
+#define GPIO_BSRR(port) MMIO32(port + 0x18)
+#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 GPIOH_BSRR GPIO_BSRR(GPIOH)
+
+/* Port configuration lock register (GPIOx_LCKR) */
+#define GPIO_LCKR(port) MMIO32(port + 0x1C)
+#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 GPIOH_LCKR GPIO_LCKR(GPIOH)
+
+/* Alternate function low register (GPIOx_AFRL) */
+#define GPIO_AFRL(port) MMIO32(port + 0x20)
+#define GPIOA_AFRL GPIO_AFRL(GPIOA)
+#define GPIOB_AFRL GPIO_AFRL(GPIOB)
+#define GPIOC_AFRL GPIO_AFRL(GPIOC)
+#define GPIOD_AFRL GPIO_AFRL(GPIOD)
+#define GPIOE_AFRL GPIO_AFRL(GPIOE)
+#define GPIOH_AFRL GPIO_AFRL(GPIOH)
+
+/* Alternate function high register (GPIOx_AFRH) */
+#define GPIO_AFRH(port) MMIO32(port + 0x24)
+#define GPIOA_AFRH GPIO_AFRH(GPIOA)
+#define GPIOB_AFRH GPIO_AFRH(GPIOB)
+#define GPIOC_AFRH GPIO_AFRH(GPIOC)
+#define GPIOD_AFRH GPIO_AFRH(GPIOD)
+#define GPIOE_AFRH GPIO_AFRH(GPIOE)
+#define GPIOH_AFRH GPIO_AFRH(GPIOH)
+
+/* --- GPIOx_MODER values-------------------------------------------- */
+
+#define GPIO_MODE(n, mode) (mode << (2 * (n)))
+#define GPIO_MODE_MASK(n) (0x3 << (2 * (n)))
+/** @defgroup gpio_mode GPIO Pin Direction and Analog/Digital Mode
+@ingroup gpio_defines
+@{*/
+#define GPIO_MODE_INPUT 0x00 /* Default */
+#define GPIO_MODE_OUTPUT 0x01
+#define GPIO_MODE_AF 0x02
+#define GPIO_MODE_ANALOG 0x03
+/**@}*/
+
+/* --- GPIOx_OTYPER values -------------------------------------------- */
+/* Output type (OTx values) */
+/** @defgroup gpio_output_type GPIO Output Pin Driver Type
+@ingroup gpio_defines
+@list Push Pull
+@list Open Drain
+@{*/
+#define GPIO_OTYPE_PP 0x0
+#define GPIO_OTYPE_OD 0x1
+/**@}*/
+
+/* Output speed values */
+#define GPIO_OSPEED(n, speed) (speed << (2 * (n)))
+#define GPIO_OSPEED_MASK(n) (0x3 << (2 * (n)))
+/** @defgroup gpio_speed GPIO Output Pin Speed
+@ingroup gpio_defines
+@{*/
+#define GPIO_OSPEED_400KHZ 0x0
+#define GPIO_OSPEED_2MHZ 0x1
+#define GPIO_OSPEED_10MHZ 0x2
+#define GPIO_OSPEED_40MHZ 0x3
+/**@}*/
+
+/* --- GPIOx_PUPDR values ------------------------------------------- */
+
+#define GPIO_PUPD(n, pupd) (pupd << (2 * (n)))
+#define GPIO_PUPD_MASK(n) (0x3 << (2 * (n)))
+/** @defgroup gpio_pup GPIO Output Pin Pullup
+@ingroup gpio_defines
+@{*/
+#define GPIO_PUPD_NONE 0x0
+#define GPIO_PUPD_PULLUP 0x1
+#define GPIO_PUPD_PULLDOWN 0x2
+/**@}*/
+
+/* --- 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_LCKR values ---------------------------------------------------- */
+
+#define GPIO_LCKK (1 << 16)
+/* GPIO_LCKR[15:0]: LCKy: Port x lock bit y (y = 0..15) */
+
+/* --- GPIOx_AFRL/H values ------------------------------------------------- */
+
+/* Note: AFRL is used for bits 0..7, AFRH is used for 8..15 */
+/* See datasheet table 5, page 35 for the definitions */
+
+#define GPIO_AFR(n, af) (af << ((n) * 4))
+#define GPIO_AFR_MASK(n) (0xf << ((n) * 4))
+/** @defgroup gpio_af_num Alternate Function Pin Selection
+@ingroup gpio_defines
+@{*/
+#define GPIO_AF0 0x0
+#define GPIO_AF1 0x1
+#define GPIO_AF2 0x2
+#define GPIO_AF3 0x3
+#define GPIO_AF4 0x4
+#define GPIO_AF5 0x5
+#define GPIO_AF6 0x6
+#define GPIO_AF7 0x7
+#define GPIO_AF8 0x8
+#define GPIO_AF9 0x9
+#define GPIO_AF10 0xa
+#define GPIO_AF11 0xb
+#define GPIO_AF12 0xc
+#define GPIO_AF13 0xd
+#define GPIO_AF14 0xe
+#define GPIO_AF15 0xf
+/**@}*/
+
+/* --- Function prototypes ------------------------------------------------- */
+
+BEGIN_DECLS
+
+/*
+ * L1, like F2 and F4, has the "new" GPIO peripheral, so use that style
+ * however the number of ports is reduced and H port naming is different.
+ * TODO: this should all really be moved to a "common" gpio header
+ */
+
+void gpio_mode_setup(uint32_t gpioport, uint8_t mode, uint8_t pull_up_down,
+ uint16_t gpios);
+void gpio_set_output_options(uint32_t gpioport, uint8_t otype, uint8_t speed,
+ uint16_t gpios);
+void gpio_set_af(uint32_t gpioport, uint8_t alt_func_num, uint16_t gpios);
+
+END_DECLS
+
+#endif
+/**@}*/
+
diff --git a/libopencm3/include/libopencm3/stm32/l1/i2c.h b/libopencm3/include/libopencm3/stm32/l1/i2c.h
new file mode 100644
index 0000000..c2ed3f3
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/i2c.h
@@ -0,0 +1,37 @@
+/** @defgroup i2c_defines I2C Defines
+
+@brief <b>Defined Constants and Types for the STM32L1xx I2C </b>
+
+@ingroup STM32L1xx_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/l1/irq.json b/libopencm3/include/libopencm3/stm32/l1/irq.json
new file mode 100644
index 0000000..abea8db
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/irq.json
@@ -0,0 +1,64 @@
+{
+ "irqs": [
+ "wwdg",
+ "pvd",
+ "tamper_stamp",
+ "rtc_wkup",
+ "flash",
+ "rcc",
+ "exti0",
+ "exti1",
+ "exti2",
+ "exti3",
+ "exti4",
+ "dma1_channel1",
+ "dma1_channel2",
+ "dma1_channel3",
+ "dma1_channel4",
+ "dma1_channel5",
+ "dma1_channel6",
+ "dma1_channel7",
+ "adc1",
+ "usb_hp",
+ "usb_lp",
+ "dac",
+ "comp",
+ "exti9_5",
+ "lcd",
+ "tim9",
+ "tim10",
+ "tim11",
+ "tim2",
+ "tim3",
+ "tim4",
+ "i2c1_ev",
+ "i2c1_er",
+ "i2c2_ev",
+ "i2c2_er",
+ "spi1",
+ "spi2",
+ "usart1",
+ "usart2",
+ "usart3",
+ "exti15_10",
+ "rtc_alarm",
+ "usb_fs_wakeup",
+ "tim6",
+ "tim7",
+ "sdio",
+ "tim5",
+ "spi3",
+ "uart4",
+ "uart5",
+ "dma2_ch1",
+ "dma2_ch2",
+ "dma2_ch3",
+ "dma2_ch4",
+ "dma2_ch5",
+ "aes",
+ "comp_acq"
+ ],
+ "partname_humanreadable": "STM32 L1 series",
+ "partname_doxygen": "STM32L1",
+ "includeguard": "LIBOPENCM3_STM32_L1_NVIC_H"
+} \ No newline at end of file
diff --git a/libopencm3/include/libopencm3/stm32/l1/iwdg.h b/libopencm3/include/libopencm3/stm32/l1/iwdg.h
new file mode 100644
index 0000000..699849a
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/iwdg.h
@@ -0,0 +1,39 @@
+/** @defgroup iwdg_defines IWDG Defines
+
+@brief <b>Defined Constants and Types for the STM32L1xx Independent Watchdog
+Timer</b>
+
+@ingroup STM32L1xx_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/l1/lcd.h b/libopencm3/include/libopencm3/stm32/l1/lcd.h
new file mode 100644
index 0000000..0a4b02b
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/lcd.h
@@ -0,0 +1,231 @@
+/** @defgroup lcd_defines LCD Defines
+ *
+ * @ingroup STM32L1xx_defines
+ *
+ * @brief Defined Constants and Types for the STM32L1xx LCD Controller
+ *
+ * @version 1.0.0
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2014
+ * Nikolay Merinov <nikolay.merinov@member.fsf.org>
+ *
+ * @date 2 March 2014
+ *
+ * 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_LCD_H
+#define LIBOPENCM3_LCD_H
+
+#include <libopencm3/stm32/memorymap.h>
+#include <libopencm3/cm3/common.h>
+
+/* --- LCD registers ------------------------------------------------------ */
+/****************************************************************************/
+/** @defgroup lcd_reg_base LCD register base addresses
+@ingroup lcd_defines
+*/
+/* @{ */
+/* Control register */
+#define LCD_CR MMIO32(LCD_BASE + 0x00)
+/* Frame control register */
+#define LCD_FCR MMIO32(LCD_BASE + 0x04)
+/* Status register */
+#define LCD_SR MMIO32(LCD_BASE + 0x08)
+/* Clear register */
+#define LCD_CLR MMIO32(LCD_BASE + 0x0C)
+/* @} */
+
+/* --- LCD display memory ------------------------------------------------- */
+/* Base address of display memory */
+#define LCD_RAM_BASE (LCD_BASE + 0x14)
+
+/* COM0 memory */
+#define LCD_RAM_COM0 MMIO64(LCD_RAM_BASE + 0x00)
+/* COM1 memory */
+#define LCD_RAM_COM1 MMIO64(LCD_RAM_BASE + 0x08)
+/* COM2 memory */
+#define LCD_RAM_COM2 MMIO64(LCD_RAM_BASE + 0x10)
+/* COM3 memory */
+#define LCD_RAM_COM3 MMIO64(LCD_RAM_BASE + 0x18)
+/* COM4 memory */
+#define LCD_RAM_COM4 MMIO64(LCD_RAM_BASE + 0x20)
+/* COM5 memory */
+#define LCD_RAM_COM5 MMIO64(LCD_RAM_BASE + 0x28)
+/* COM6 memory */
+#define LCD_RAM_COM6 MMIO64(LCD_RAM_BASE + 0x30)
+/* COM7 memory */
+#define LCD_RAM_COM7 MMIO64(LCD_RAM_BASE + 0x38)
+
+/* --- LCD_CR values ------------------------------------------------------ */
+#define LCD_CR_LCDEN (1 << 0)
+#define LCD_CR_VSEL (1 << 1)
+
+#define LCD_CR_DUTY_SHIFT 2
+#define LCD_CR_DUTY_MASK 0x7
+#define LCD_CR_DUTY_STATIC 0x0
+#define LCD_CR_DUTY_1_2 0x1
+#define LCD_CR_DUTY_1_3 0x2
+#define LCD_CR_DUTY_1_4 0x3
+#define LCD_CR_DUTY_1_8 0x4
+
+#define LCD_CR_BIAS_SHIFT 5
+#define LCD_CR_BIAS_MASK 0x3
+#define LCD_CR_BIAS_1_4 0x0
+#define LCD_CR_BIAS_1_2 0x1
+#define LCD_CR_BIAS_1_3 0x2
+
+#define LCD_CR_MUX_SEG (1 << 7)
+
+/* --- LCD_FCR values ------------------------------------------------------ */
+#define LCD_FCR_HD (1 << 0)
+#define LCD_FCR_SOFIE (1 << 1)
+#define LCD_FCR_UDDIE (1 << 3)
+
+#define LCD_FCR_PON_SHIFT 4
+#define LCD_FCR_PON_MASK 0x7
+#define LCD_FCR_PON_0 0x0
+#define LCD_FCR_PON_1 0x1
+#define LCD_FCR_PON_2 0x2
+#define LCD_FCR_PON_3 0x3
+#define LCD_FCR_PON_4 0x4
+#define LCD_FCR_PON_5 0x5
+#define LCD_FCR_PON_6 0x6
+#define LCD_FCR_PON_7 0x7
+
+#define LCD_FCR_DEAD_SHIFT 7
+#define LCD_FCR_DEAD_MASK 0x7
+#define LCD_FCR_DEAD_NONE 0x0
+#define LCD_FCR_DEAD_1_PHASE 0x1
+#define LCD_FCR_DEAD_2_PHASE 0x2
+#define LCD_FCR_DEAD_3_PHASE 0x3
+#define LCD_FCR_DEAD_4_PHASE 0x4
+#define LCD_FCR_DEAD_5_PHASE 0x5
+#define LCD_FCR_DEAD_6_PHASE 0x6
+#define LCD_FCR_DEAD_7_PHASE 0x7
+
+#define LCD_FCR_CC_SHIFT 10
+#define LCD_FCR_CC_MASK 0x7
+#define LCD_FCR_CC_0 0x0
+#define LCD_FCR_CC_1 0x1
+#define LCD_FCR_CC_2 0x2
+#define LCD_FCR_CC_3 0x3
+#define LCD_FCR_CC_4 0x4
+#define LCD_FCR_CC_5 0x5
+#define LCD_FCR_CC_6 0x6
+#define LCD_FCR_CC_7 0x7
+
+#define LCD_FCR_BLINKF_SHIFT 13
+#define LCD_FCR_BLINKF_MASK 0x7
+#define LCD_FCR_BLINKF_8 0x0
+#define LCD_FCR_BLINKF_16 0x1
+#define LCD_FCR_BLINKF_32 0x2
+#define LCD_FCR_BLINKF_64 0x3
+#define LCD_FCR_BLINKF_128 0x4
+#define LCD_FCR_BLINKF_256 0x5
+#define LCD_FCR_BLINKF_512 0x6
+#define LCD_FCR_BLINKF_1024 0x7
+
+#define LCD_FCR_BLINK_SHIFT 16
+#define LCD_FCR_BLINK_MASK 0x3
+#define LCD_FCR_BLINK_DISABLE 0x0
+#define LCD_FCR_BLINK_SEG0_COM0_ENABLE 0x1
+#define LCD_FCR_BLINK_SEG0_ENABLE 0x2
+#define LCD_FCR_BLINK_ALL_ENABLE 0x3
+
+#define LCD_FCR_DIV_SHIFT 18
+#define LCD_FCR_DIV_MASK 0xF
+#define LCD_FCR_DIV_16 0x0
+#define LCD_FCR_DIV_17 0x1
+#define LCD_FCR_DIV_18 0x2
+#define LCD_FCR_DIV_19 0x3
+#define LCD_FCR_DIV_20 0x4
+#define LCD_FCR_DIV_21 0x5
+#define LCD_FCR_DIV_22 0x6
+#define LCD_FCR_DIV_23 0x7
+#define LCD_FCR_DIV_24 0x8
+#define LCD_FCR_DIV_25 0x9
+#define LCD_FCR_DIV_26 0xA
+#define LCD_FCR_DIV_27 0xB
+#define LCD_FCR_DIV_28 0xC
+#define LCD_FCR_DIV_29 0xD
+#define LCD_FCR_DIV_30 0xE
+#define LCD_FCR_DIV_31 0xF
+
+#define LCD_FCR_PS_SHIFT 22
+#define LCD_FCR_PS_MASK 0xF
+#define LCD_FCR_PS_1 0x0
+#define LCD_FCR_PS_2 0x1
+#define LCD_FCR_PS_4 0x2
+#define LCD_FCR_PS_8 0x3
+#define LCD_FCR_PS_16 0x4
+#define LCD_FCR_PS_32 0x5
+#define LCD_FCR_PS_64 0x6
+#define LCD_FCR_PS_128 0x7
+#define LCD_FCR_PS_256 0x8
+#define LCD_FCR_PS_512 0x9
+#define LCD_FCR_PS_1024 0xA
+#define LCD_FCR_PS_2048 0xB
+#define LCD_FCR_PS_4096 0xC
+#define LCD_FCR_PS_8192 0xD
+#define LCD_FCR_PS_16384 0xE
+#define LCD_FCR_PS_32768 0xF
+
+/* --- LCD_SR values ------------------------------------------------------ */
+#define LCD_SR_ENS (1 << 0)
+#define LCD_SR_SOF (1 << 1)
+#define LCD_SR_UDR (1 << 2)
+#define LCD_SR_UDD (1 << 3)
+#define LCD_SR_RDY (1 << 4)
+#define LCD_SR_FCRSF (1 << 5)
+
+/* --- LCD_CLR values ----------------------------------------------------- */
+#define LCD_CLR_SOFC (1 << 1)
+#define LCD_CLR_UDDC (1 << 3)
+
+/* --- Function prototypes ------------------------------------------------- */
+
+BEGIN_DECLS
+
+void lcd_enable(void);
+void lcd_update(void);
+
+void lcd_wait_for_lcd_enabled(void);
+void lcd_wait_for_step_up_ready(void);
+void lcd_wait_for_update_ready(void);
+
+int lcd_is_enabled(void);
+int lcd_is_step_up_ready(void);
+int lcd_is_for_update_ready(void);
+
+void lcd_set_contrast(uint8_t contrast);
+void lcd_set_bias(uint8_t bias);
+void lcd_set_duty(uint8_t duty);
+void lcd_set_prescaler(uint8_t ps);
+void lcd_set_divider(uint8_t div);
+void lcd_enable_segment_multiplexing(void);
+void lcd_disable_segment_multiplexing(void);
+void lcd_set_refresh_frequency(uint32_t frequency);
+
+END_DECLS
+
+#endif
+/**@}*/
diff --git a/libopencm3/include/libopencm3/stm32/l1/memorymap.h b/libopencm3/include/libopencm3/stm32/l1/memorymap.h
new file mode 100644
index 0000000..abdb34d
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/memorymap.h
@@ -0,0 +1,126 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2009 Uwe Hermann <uwe@hermann-uwe.de>
+ * Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
+ *
+ * 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 busses */
+#define PERIPH_BASE (0x40000000U)
+#define INFO_BASE (0x1ff00000U)
+#define PERIPH_BASE_APB1 (PERIPH_BASE + 0x00000)
+#define PERIPH_BASE_APB2 (PERIPH_BASE + 0x10000)
+#define PERIPH_BASE_AHB (PERIPH_BASE + 0x20000)
+
+/* 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 LCD_BASE (PERIPH_BASE_APB1 + 0x2400)
+#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_BASE (PERIPH_BASE_APB1 + 0x3800)
+#define SPI3_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 USART4_BASE (PERIPH_BASE_APB1 + 0x4c00)
+#define USART5_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_SRAM_BASE (PERIPH_BASE_APB1 + 0x6000)
+/* gap */
+#define POWER_CONTROL_BASE (PERIPH_BASE_APB1 + 0x7000)
+#define DAC_BASE (PERIPH_BASE_APB1 + 0x7400)
+#define OPAMP_BASE (PERIPH_BASE_APB1 + 0x7c5c)
+#define COMP_BASE (PERIPH_BASE_APB1 + 0x7c00)
+#define ROUTING_BASE (PERIPH_BASE_APB1 + 0x7c04)
+
+/* APB2 */
+#define SYSCFG_BASE (PERIPH_BASE_APB2 + 0x0000)
+#define EXTI_BASE (PERIPH_BASE_APB2 + 0x0400)
+#define TIM9_BASE (PERIPH_BASE_APB2 + 0x0800)
+#define TIM10_BASE (PERIPH_BASE_APB2 + 0x0c00)
+#define TIM11_BASE (PERIPH_BASE_APB2 + 0x1000)
+/* gap */
+#define ADC_BASE (PERIPH_BASE_APB2 + 0x2400)
+/* ADC is the name in the L1 refman, but all other stm32's use ADC1 */
+#define ADC1_BASE ADC_BASE
+/* gap */
+#define SDIO_BASE (PERIPH_BASE_APB2 + 0x2c00)
+#define SPI1_BASE (PERIPH_BASE_APB2 + 0x3000)
+/* gap */
+#define USART1_BASE (PERIPH_BASE_APB2 + 0x3800)
+
+/* AHB */
+#define GPIO_PORT_A_BASE (PERIPH_BASE_AHB + 0x00000)
+#define GPIO_PORT_B_BASE (PERIPH_BASE_AHB + 0x00400)
+#define GPIO_PORT_C_BASE (PERIPH_BASE_AHB + 0x00800)
+#define GPIO_PORT_D_BASE (PERIPH_BASE_AHB + 0x00c00)
+#define GPIO_PORT_E_BASE (PERIPH_BASE_AHB + 0x01000)
+#define GPIO_PORT_H_BASE (PERIPH_BASE_AHB + 0x01400)
+#define GPIO_PORT_F_BASE (PERIPH_BASE_AHB + 0x01800)
+#define GPIO_PORT_G_BASE (PERIPH_BASE_AHB + 0x01c00)
+/* gap */
+#define CRC_BASE (PERIPH_BASE_AHB + 0x03000)
+/* gap */
+#define RCC_BASE (PERIPH_BASE_AHB + 0x03800)
+#define FLASH_MEM_INTERFACE_BASE (PERIPH_BASE_AHB + 0x03c00)
+/* gap */
+#define DMA1_BASE (PERIPH_BASE_AHB + 0x06000)
+#define DMA2_BASE (PERIPH_BASE_AHB + 0x04000)
+
+/* PPIB */
+#define DBGMCU_BASE (PPBI_BASE + 0x00042000)
+
+/* FSMC */
+#define FSMC_BASE (PERIPH_BASE + 0x60000000)
+/* AES */
+#define AES_BASE (PERIPH_BASE + 0x10000000)
+
+/* Device Electronic Signature */
+#define DESIG_FLASH_SIZE_BASE (INFO_BASE + 0x8004C)
+#define DESIG_UNIQUE_ID_BASE (INFO_BASE + 0x80050)
+#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 + 0x14)
+
+/* ST provided factory calibration values @ 3.0V */
+#define ST_VREFINT_CAL MMIO16(0x1FF80078)
+#define ST_TSENSE_CAL1_30C MMIO16(0x1FF8007A)
+#define ST_TSENSE_CAL2_110C MMIO16(0x1FF8007E)
+
+/* Make the map names match those for other families to allow commonality */
+#define SPI1_I2S_BASE SPI1_BASE
+#define SPI2_I2S_BASE SPI2_BASE
+#define SPI3_I2S_BASE SPI3_BASE
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/l1/pwr.h b/libopencm3/include/libopencm3/stm32/l1/pwr.h
new file mode 100644
index 0000000..ddcdc07
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/pwr.h
@@ -0,0 +1,111 @@
+/** @defgroup pwr_defines PWR Defines
+
+@brief <b>Defined Constants and Types for the STM32L1xx Power Control</b>
+
+@ingroup STM32L1xx_defines
+
+@version 1.0.0
+
+@author @htmlonly &copy; @endhtmlonly 2011 Stephen Caudle <scaudle@doceme.com>
+@author @htmlonly &copy; @endhtmlonly 2012 Karl Palsson <karlp@tweak.net.au>
+
+@date 1 July 2012
+
+LGPL License Terms @ref lgpl_license
+ */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2011 Stephen Caudle <scaudle@doceme.com>
+ * Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
+ *
+ * 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>
+
+/*
+ * This file extends the common STM32 version with definitions only
+ * applicable to the STM32L1 series of devices.
+ */
+
+/* --- PWR_CR values ------------------------------------------------------- */
+
+/* Bits [31:15]: Reserved */
+
+/* LPRUN: Low power run mode */
+#define PWR_CR_LPRUN (1 << 14)
+
+/* VOS[12:11]: Regulator voltage scaling output selection */
+#define PWR_CR_VOS_LSB 11
+/** @defgroup pwr_vos Voltage Scaling Output level selection
+@ingroup pwr_defines
+
+@{*/
+#define PWR_CR_VOS_RANGE1 (0x1 << PWR_CR_VOS_LSB)
+#define PWR_CR_VOS_RANGE2 (0x2 << PWR_CR_VOS_LSB)
+#define PWR_CR_VOS_RANGE3 (0x3 << PWR_CR_VOS_LSB)
+/**@}*/
+#define PWR_CR_VOS_MASK (0x3 << PWR_CR_VOS_LSB)
+
+/* FWU: Fast wakeup */
+#define PWR_CR_FWU (1 << 10)
+
+/* ULP: Ultralow power mode */
+#define PWR_CR_ULP (1 << 9)
+
+/* LPSDSR: Low-power deepsleep/sleep/low power run */
+#define PWR_CR_LPSDSR (1 << 0) /* masks common PWR_CR_LPDS */
+
+/* --- PWR_CSR values ------------------------------------------------------- */
+
+/* Bits [31:11]: Reserved */
+/* EWUP3: Enable WKUP3 pin */
+#define PWR_CSR_EWUP3 (1 << 10)
+
+/* EWUP2: Enable WKUP2 pin */
+#define PWR_CSR_EWUP2 (1 << 9)
+
+/* EWUP1: Enable WKUP1 pin */
+#define PWR_CSR_EWUP1 PWR_CSR_EWUP
+
+/* REGLPF : Regulator LP flag */
+#define PWR_CSR_REGLPF (1 << 5)
+
+/* VOSF: Voltage Scaling select flag */
+#define PWR_CSR_VOSF (1 << 4)
+
+/* VREFINTRDYF: Internal voltage reference (VREFINT) ready flag */
+#define PWR_CSR_VREFINTRDYF (1 << 3)
+
+
+
+/* --- Function prototypes ------------------------------------------------- */
+
+typedef enum {
+ RANGE1,
+ RANGE2,
+ RANGE3,
+} vos_scale_t;
+
+BEGIN_DECLS
+
+void pwr_set_vos_scale(vos_scale_t scale);
+
+END_DECLS
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/l1/rcc.h b/libopencm3/include/libopencm3/stm32/l1/rcc.h
new file mode 100644
index 0000000..2b5883f
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/rcc.h
@@ -0,0 +1,612 @@
+/** @defgroup rcc_defines RCC Defines
+ *
+ * @ingroup STM32L1xx_defines
+ *
+ * @brief <b>Defined Constants and Types for the STM32L1xx Reset and Clock
+ * Control</b>
+ *
+ * @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>
+ * @author @htmlonly &copy; @endhtmlonly 2012
+ * Karl Palsson <karlp@tweak.net.au>
+ *
+ * @date 11 November 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>
+ * Copyright (C) 2012 Karl Palsson <karlp@tweak.net.au>
+ *
+ * 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/>.
+ *
+ * Originally based on the F1 code, as it seemed most similar to the L1
+ * TODO: very incomplete still!
+ */
+
+/**@{*/
+
+#ifndef LIBOPENCM3_RCC_H
+#define LIBOPENCM3_RCC_H
+
+#include <libopencm3/stm32/pwr.h>
+
+/* --- RCC registers ------------------------------------------------------- */
+
+#define RCC_CR MMIO32(RCC_BASE + 0x00)
+#define RCC_ICSCR MMIO32(RCC_BASE + 0x04)
+#define RCC_CFGR MMIO32(RCC_BASE + 0x08)
+#define RCC_CIR MMIO32(RCC_BASE + 0x0c)
+#define RCC_AHBRSTR MMIO32(RCC_BASE + 0x10)
+#define RCC_APB2RSTR MMIO32(RCC_BASE + 0x14)
+#define RCC_APB1RSTR MMIO32(RCC_BASE + 0x18)
+#define RCC_AHBENR MMIO32(RCC_BASE + 0x1c)
+#define RCC_APB2ENR MMIO32(RCC_BASE + 0x20)
+#define RCC_APB1ENR MMIO32(RCC_BASE + 0x24)
+#define RCC_AHBLPENR MMIO32(RCC_BASE + 0x28)
+#define RCC_APB2LPENR MMIO32(RCC_BASE + 0x2c)
+#define RCC_APB1LPENR MMIO32(RCC_BASE + 0x30)
+#define RCC_CSR MMIO32(RCC_BASE + 0x34)
+
+/* --- RCC_CR values ------------------------------------------------------- */
+
+/* RTCPRE[1:0] at 30:29 */
+#define RCC_CR_CSSON (1 << 28)
+#define RCC_CR_PLLRDY (1 << 25)
+#define RCC_CR_PLLON (1 << 24)
+#define RCC_CR_HSEBYP (1 << 18)
+#define RCC_CR_HSERDY (1 << 17)
+#define RCC_CR_HSEON (1 << 16)
+#define RCC_CR_MSIRDY (1 << 9)
+#define RCC_CR_MSION (1 << 8)
+#define RCC_CR_HSIRDY (1 << 1)
+#define RCC_CR_HSION (1 << 0)
+
+#define RCC_CR_RTCPRE_DIV2 0
+#define RCC_CR_RTCPRE_DIV4 1
+#define RCC_CR_RTCPRE_DIV8 2
+#define RCC_CR_RTCPRE_DIV16 3
+#define RCC_CR_RTCPRE_SHIFT 29
+#define RCC_CR_RTCPRE_MASK 0x3
+
+/* --- RCC_ICSCR values ---------------------------------------------------- */
+
+#define RCC_ICSCR_MSITRIM_SHIFT 24
+#define RCC_ICSCR_MSITRIM_MASK 0xff
+#define RCC_ICSCR_MSICAL_SHIFT 16
+#define RCC_ICSCR_MSICAL_MASK 0xff
+
+#define RCC_ICSCR_MSIRANGE_SHIFT 13
+#define RCC_ICSCR_MSIRANGE_MASK 0x7
+#define RCC_ICSCR_MSIRANGE_65KHZ 0x0
+#define RCC_ICSCR_MSIRANGE_131KHZ 0x1
+#define RCC_ICSCR_MSIRANGE_262KHZ 0x2
+#define RCC_ICSCR_MSIRANGE_524KHZ 0x3
+#define RCC_ICSCR_MSIRANGE_1MHZ 0x4
+#define RCC_ICSCR_MSIRANGE_2MHZ 0x5
+#define RCC_ICSCR_MSIRANGE_4MHZ 0x6
+
+#define RCC_ICSCR_HSITRIM_SHIFT 8
+#define RCC_ICSCR_HSITRIM_MASK 0x1f
+#define RCC_ICSCR_HSICAL_SHIFT 0
+#define RCC_ICSCR_HSICAL_MASK 0xff
+
+/* --- RCC_CFGR values ----------------------------------------------------- */
+
+/* MCOPRE */
+#define RCC_CFGR_MCOPRE_DIV1 0
+#define RCC_CFGR_MCOPRE_DIV2 1
+#define RCC_CFGR_MCOPRE_DIV4 2
+#define RCC_CFGR_MCOPRE_DIV8 3
+#define RCC_CFGR_MCOPRE_DIV16 4
+
+/* MCO: Microcontroller clock output */
+#define RCC_CFGR_MCO_NOCLK 0x0
+#define RCC_CFGR_MCO_SYSCLK 0x1
+#define RCC_CFGR_MCO_HSICLK 0x2
+#define RCC_CFGR_MCO_MSICLK 0x3
+#define RCC_CFGR_MCO_HSECLK 0x4
+#define RCC_CFGR_MCO_PLLCLK 0x5
+#define RCC_CFGR_MCO_LSICLK 0x6
+#define RCC_CFGR_MCO_LSECLK 0x7
+
+/* PLL Output division selection */
+#define RCC_CFGR_PLLDIV_DIV2 0x1
+#define RCC_CFGR_PLLDIV_DIV3 0x2
+#define RCC_CFGR_PLLDIV_DIV4 0x3
+#define RCC_CFGR_PLLDIV_SHIFT 22
+#define RCC_CFGR_PLLDIV_MASK 0x3
+
+/* PLLMUL: PLL multiplication factor */
+#define RCC_CFGR_PLLMUL_MUL3 0x0
+#define RCC_CFGR_PLLMUL_MUL4 0x1
+#define RCC_CFGR_PLLMUL_MUL6 0x2
+#define RCC_CFGR_PLLMUL_MUL8 0x3
+#define RCC_CFGR_PLLMUL_MUL12 0x4
+#define RCC_CFGR_PLLMUL_MUL16 0x5
+#define RCC_CFGR_PLLMUL_MUL24 0x6
+#define RCC_CFGR_PLLMUL_MUL32 0x7
+#define RCC_CFGR_PLLMUL_MUL48 0x8
+#define RCC_CFGR_PLLMUL_SHIFT 18
+#define RCC_CFGR_PLLMUL_MASK 0xf
+
+/* PLLSRC: PLL entry clock source */
+#define RCC_CFGR_PLLSRC_HSI_CLK 0x0
+#define RCC_CFGR_PLLSRC_HSE_CLK 0x1
+
+/* PPRE2: APB high-speed prescaler (APB2) */
+#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) */
+#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 */
+#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_MSICLK 0x0
+#define RCC_CFGR_SWS_SYSCLKSEL_HSICLK 0x1
+#define RCC_CFGR_SWS_SYSCLKSEL_HSECLK 0x2
+#define RCC_CFGR_SWS_SYSCLKSEL_PLLCLK 0x3
+
+/* SW: System clock switch */
+#define RCC_CFGR_SW_SYSCLKSEL_MSICLK 0x0
+#define RCC_CFGR_SW_SYSCLKSEL_HSICLK 0x1
+#define RCC_CFGR_SW_SYSCLKSEL_HSECLK 0x2
+#define RCC_CFGR_SW_SYSCLKSEL_PLLCLK 0x3
+
+/* --- RCC_CIR values ------------------------------------------------------ */
+
+/* Clock security system interrupt clear bit */
+#define RCC_CIR_CSSC (1 << 23)
+
+/* OSC ready interrupt clear bits */
+#define RCC_CIR_MSIRDYC (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_MSIRDYIE (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_MSIRDYF (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_AHBRSTR values ------------------------------------------------- */
+#define RCC_AHBRSTR_DMA1RST (1 << 24)
+#define RCC_AHBRSTR_FLITFRST (1 << 15)
+#define RCC_AHBRSTR_CRCRST (1 << 12)
+#define RCC_AHBRSTR_GPIOHRST (1 << 5)
+#define RCC_AHBRSTR_GPIOERST (1 << 4)
+#define RCC_AHBRSTR_GPIODRST (1 << 3)
+#define RCC_AHBRSTR_GPIOCRST (1 << 2)
+#define RCC_AHBRSTR_GPIOBRST (1 << 1)
+#define RCC_AHBRSTR_GPIOARST (1 << 0)
+
+/* --- RCC_APB2RSTR values ------------------------------------------------- */
+
+#define RCC_APB2RSTR_USART1RST (1 << 14)
+#define RCC_APB2RSTR_SPI1RST (1 << 12)
+#define RCC_APB2RSTR_ADC1RST (1 << 9)
+#define RCC_APB2RSTR_TIM11RST (1 << 4)
+#define RCC_APB2RSTR_TIM10RST (1 << 3)
+#define RCC_APB2RSTR_TIM9RST (1 << 2)
+#define RCC_APB2RSTR_SYSCFGRST (1 << 0)
+
+/* --- RCC_APB1RSTR values ------------------------------------------------- */
+
+#define RCC_APB1RSTR_COMPRST (1 << 31)
+#define RCC_APB1RSTR_DACRST (1 << 29)
+#define RCC_APB1RSTR_PWRRST (1 << 28)
+#define RCC_APB1RSTR_USBRST (1 << 23)
+#define RCC_APB1RSTR_I2C2RST (1 << 22)
+#define RCC_APB1RSTR_I2C1RST (1 << 21)
+#define RCC_APB1RSTR_USART3RST (1 << 18)
+#define RCC_APB1RSTR_USART2RST (1 << 17)
+#define RCC_APB1RSTR_SPI2RST (1 << 14)
+#define RCC_APB1RSTR_WWDGRST (1 << 11)
+#define RCC_APB1RSTR_LCDRST (1 << 9)
+#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 STM32L1xx_rcc_defines
+
+@{*/
+#define RCC_AHBENR_DMA1EN (1 << 24)
+#define RCC_AHBENR_FLITFEN (1 << 15)
+#define RCC_AHBENR_CRCEN (1 << 12)
+#define RCC_AHBENR_GPIOHEN (1 << 5)
+#define RCC_AHBENR_GPIOEEN (1 << 4)
+#define RCC_AHBENR_GPIODEN (1 << 3)
+#define RCC_AHBENR_GPIOCEN (1 << 2)
+#define RCC_AHBENR_GPIOBEN (1 << 1)
+#define RCC_AHBENR_GPIOAEN (1 << 0)
+/*@}*/
+
+/* --- RCC_APB2ENR values -------------------------------------------------- */
+
+/** @defgroup rcc_apb2enr_en RCC_APB2ENR enable values
+@ingroup STM32L1xx_rcc_defines
+
+@{*/
+#define RCC_APB2ENR_USART1EN (1 << 14)
+#define RCC_APB2ENR_SPI1EN (1 << 12)
+#define RCC_APB2ENR_ADC1EN (1 << 9)
+#define RCC_APB2ENR_TIM11EN (1 << 4)
+#define RCC_APB2ENR_TIM10EN (1 << 3)
+#define RCC_APB2ENR_TIM9EN (1 << 2)
+#define RCC_APB2ENR_SYSCFGEN (1 << 0)
+/*@}*/
+
+/* --- RCC_APB1ENR values -------------------------------------------------- */
+
+/** @defgroup rcc_apb1enr_en RCC_APB1ENR enable values
+@ingroup STM32L1xx_rcc_defines
+
+@{*/
+#define RCC_APB1ENR_COMPEN (1 << 31)
+#define RCC_APB1ENR_DACEN (1 << 29)
+#define RCC_APB1ENR_PWREN (1 << 28)
+#define RCC_APB1ENR_USBEN (1 << 23)
+#define RCC_APB1ENR_I2C2EN (1 << 22)
+#define RCC_APB1ENR_I2C1EN (1 << 21)
+#define RCC_APB1ENR_USART3EN (1 << 18)
+#define RCC_APB1ENR_USART2EN (1 << 17)
+#define RCC_APB1ENR_SPI2EN (1 << 14)
+#define RCC_APB1ENR_WWDGEN (1 << 11)
+#define RCC_APB1ENR_LCDEN (1 << 9)
+#define RCC_APB1ENR_TIM7EN (1 << 5)
+#define RCC_APB1ENR_TIM6EN (1 << 4)
+#define RCC_APB1ENR_TIM4EN (1 << 2)
+#define RCC_APB1ENR_TIM3EN (1 << 1)
+#define RCC_APB1ENR_TIM2EN (1 << 0)
+/*@}*/
+
+/* --- RCC_AHBLPENR -------------------------------------------------------- */
+#define RCC_AHBLPENR_DMA1LPEN (1 << 24)
+#define RCC_AHBLPENR_SRAMLPEN (1 << 16)
+#define RCC_AHBLPENR_FLITFLPEN (1 << 15)
+#define RCC_AHBLPENR_CRCLPEN (1 << 12)
+#define RCC_AHBLPENR_GPIOHLPEN (1 << 5)
+#define RCC_AHBLPENR_GPIOELPEN (1 << 4)
+#define RCC_AHBLPENR_GPIODLPEN (1 << 3)
+#define RCC_AHBLPENR_GPIOCLPEN (1 << 2)
+#define RCC_AHBLPENR_GPIOBLPEN (1 << 1)
+#define RCC_AHBLPENR_GPIOALPEN (1 << 0)
+
+#define RCC_APB2LPENR_USART1LPEN (1 << 14)
+#define RCC_APB2LPENR_SPI1LPEN (1 << 12)
+#define RCC_APB2LPENR_ADC1LPEN (1 << 9)
+#define RCC_APB2LPENR_TIM11LPEN (1 << 4)
+#define RCC_APB2LPENR_TIM10LPEN (1 << 3)
+#define RCC_APB2LPENR_TIM9LPEN (1 << 2)
+#define RCC_APB2LPENR_SYSCFGLPEN (1 << 0)
+
+#define RCC_APB1LPENR_COMPLPEN (1 << 31)
+#define RCC_APB1LPENR_DACLPEN (1 << 29)
+#define RCC_APB1LPENR_PWRLPEN (1 << 28)
+#define RCC_APB1LPENR_USBLPEN (1 << 23)
+#define RCC_APB1LPENR_I2C2LPEN (1 << 22)
+#define RCC_APB1LPENR_I2C1LPEN (1 << 21)
+#define RCC_APB1LPENR_USART3LPEN (1 << 18)
+#define RCC_APB1LPENR_USART2LPEN (1 << 17)
+#define RCC_APB1LPENR_SPI2LPEN (1 << 14)
+#define RCC_APB1LPENR_WWDGLPEN (1 << 11)
+#define RCC_APB1LPENR_LCDLPEN (1 << 9)
+#define RCC_APB1LPENR_TIM7LPEN (1 << 5)
+#define RCC_APB1LPENR_TIM6LPEN (1 << 4)
+#define RCC_APB1LPENR_TIM4LPEN (1 << 2)
+#define RCC_APB1LPENR_TIM3LPEN (1 << 1)
+#define RCC_APB1LPENR_TIM2LPEN (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_OBLRSTF (1 << 25)
+#define RCC_CSR_RMVF (1 << 24)
+#define RCC_CSR_RTCRST (1 << 23)
+#define RCC_CSR_RTCEN (1 << 22)
+#define RCC_CSR_RTCSEL_SHIFT (16)
+#define RCC_CSR_RTCSEL_MASK (0x3)
+#define RCC_CSR_RTCSEL_NONE (0x0)
+#define RCC_CSR_RTCSEL_LSE (0x1)
+#define RCC_CSR_RTCSEL_LSI (0x2)
+#define RCC_CSR_RTCSEL_HSI (0x3)
+#define RCC_CSR_LSECSSD (1 << 12)
+#define RCC_CSR_LSECSSON (1 << 11)
+#define RCC_CSR_LSEBYP (1 << 10)
+#define RCC_CSR_LSERDY (1 << 9)
+#define RCC_CSR_LSEON (1 << 8)
+#define RCC_CSR_LSIRDY (1 << 1)
+#define RCC_CSR_LSION (1 << 0)
+
+typedef struct {
+ uint8_t pll_mul;
+ uint16_t pll_div;
+ uint8_t pll_source;
+ uint32_t flash_config;
+ uint8_t hpre;
+ uint8_t ppre1;
+ uint8_t ppre2;
+ vos_scale_t voltage_scale;
+ uint32_t apb1_frequency;
+ uint32_t apb2_frequency;
+ uint8_t msi_range;
+} clock_scale_t;
+
+typedef enum {
+ CLOCK_VRANGE1_HSI_PLL_24MHZ,
+ CLOCK_VRANGE1_HSI_PLL_32MHZ,
+ CLOCK_VRANGE1_HSI_RAW_16MHZ,
+ CLOCK_VRANGE1_HSI_RAW_4MHZ,
+ CLOCK_VRANGE1_MSI_RAW_4MHZ,
+ CLOCK_VRANGE1_MSI_RAW_2MHZ,
+ CLOCK_CONFIG_END
+} clock_config_entry_t;
+
+extern const clock_scale_t clock_config[CLOCK_CONFIG_END];
+
+
+/* --- Variable definitions ------------------------------------------------ */
+extern uint32_t rcc_ppre1_frequency;
+extern uint32_t rcc_ppre2_frequency;
+
+/* --- Function prototypes ------------------------------------------------- */
+
+typedef enum {
+ PLL, HSE, HSI, MSI, LSE, LSI
+} osc_t;
+
+#define _REG_BIT(base, bit) (((base) << 5) + (bit))
+
+enum rcc_periph_clken {
+ /* AHB peripherals */
+ RCC_GPIOA = _REG_BIT(0x1c, 0),
+ RCC_GPIOB = _REG_BIT(0x1c, 1),
+ RCC_GPIOC = _REG_BIT(0x1c, 2),
+ RCC_GPIOD = _REG_BIT(0x1c, 3),
+ RCC_GPIOE = _REG_BIT(0x1c, 4),
+ RCC_GPIOH = _REG_BIT(0x1c, 5),
+ RCC_GPIOF = _REG_BIT(0x1c, 6),
+ RCC_GPIOG = _REG_BIT(0x1c, 7),
+ RCC_CRC = _REG_BIT(0x1c, 12),
+ RCC_FLITF = _REG_BIT(0x1c, 15),
+ RCC_DMA1 = _REG_BIT(0x1c, 24),
+ RCC_DMA2 = _REG_BIT(0x1c, 25),
+ RCC_AES = _REG_BIT(0x1c, 27),
+ RCC_FSMC = _REG_BIT(0x1c, 30),
+
+ /* APB2 peripherals */
+ RCC_SYSCFG = _REG_BIT(0x20, 0),
+ RCC_TIM9 = _REG_BIT(0x20, 2),
+ RCC_TIM10 = _REG_BIT(0x20, 3),
+ RCC_TIM11 = _REG_BIT(0x20, 4),
+ RCC_ADC1 = _REG_BIT(0x20, 9),
+ RCC_SDIO = _REG_BIT(0x20, 11),
+ RCC_SPI1 = _REG_BIT(0x20, 12),
+ RCC_USART1 = _REG_BIT(0x20, 14),
+
+ /* APB1 peripherals*/
+ RCC_TIM2 = _REG_BIT(0x24, 0),
+ RCC_TIM3 = _REG_BIT(0x24, 1),
+ RCC_TIM4 = _REG_BIT(0x24, 2),
+ RCC_TIM5 = _REG_BIT(0x24, 3),
+ RCC_TIM6 = _REG_BIT(0x24, 4),
+ RCC_TIM7 = _REG_BIT(0x24, 5),
+ RCC_LCD = _REG_BIT(0x24, 9),
+ RCC_WWDG = _REG_BIT(0x24, 11),
+ RCC_SPI2 = _REG_BIT(0x24, 14),
+ RCC_SPI3 = _REG_BIT(0x24, 15),
+ RCC_USART2 = _REG_BIT(0x24, 17),
+ RCC_USART3 = _REG_BIT(0x24, 18),
+ RCC_UART4 = _REG_BIT(0x24, 19),
+ RCC_UART5 = _REG_BIT(0x24, 20),
+ RCC_I2C1 = _REG_BIT(0x24, 21),
+ RCC_I2C2 = _REG_BIT(0x24, 22),
+ RCC_USB = _REG_BIT(0x24, 23),
+ RCC_PWR = _REG_BIT(0x24, 28),
+ RCC_DAC = _REG_BIT(0x24, 29),
+ RCC_COMP = _REG_BIT(0x24, 31),
+
+ /* AHB peripherals */
+ SCC_GPIOA = _REG_BIT(0x28, 0),
+ SCC_GPIOB = _REG_BIT(0x28, 1),
+ SCC_GPIOC = _REG_BIT(0x28, 2),
+ SCC_GPIOD = _REG_BIT(0x28, 3),
+ SCC_GPIOE = _REG_BIT(0x28, 4),
+ SCC_GPIOH = _REG_BIT(0x28, 5),
+ SCC_GPIOF = _REG_BIT(0x28, 6),
+ SCC_GPIOG = _REG_BIT(0x28, 7),
+ SCC_CRC = _REG_BIT(0x28, 12),
+ SCC_FLITF = _REG_BIT(0x28, 15),
+ SCC_SRAM = _REG_BIT(0x28, 16),
+ SCC_DMA1 = _REG_BIT(0x28, 24),
+ SCC_DMA2 = _REG_BIT(0x28, 25),
+ SCC_AES = _REG_BIT(0x28, 27),
+ SCC_FSMC = _REG_BIT(0x28, 30),
+
+ /* APB2 peripherals */
+ SCC_SYSCFG = _REG_BIT(0x2c, 0),
+ SCC_TIM9 = _REG_BIT(0x2c, 2),
+ SCC_TIM10 = _REG_BIT(0x2c, 3),
+ SCC_TIM11 = _REG_BIT(0x2c, 4),
+ SCC_ADC1 = _REG_BIT(0x2c, 9),
+ SCC_SDIO = _REG_BIT(0x2c, 11),
+ SCC_SPI1 = _REG_BIT(0x2c, 12),
+ SCC_USART1 = _REG_BIT(0x2c, 14),
+
+ /* APB1 peripherals*/
+ SCC_TIM2 = _REG_BIT(0x24, 0),
+ SCC_TIM3 = _REG_BIT(0x24, 1),
+ SCC_TIM4 = _REG_BIT(0x24, 2),
+ SCC_TIM5 = _REG_BIT(0x24, 3),
+ SCC_TIM6 = _REG_BIT(0x24, 4),
+ SCC_TIM7 = _REG_BIT(0x24, 5),
+ SCC_LCD = _REG_BIT(0x24, 9),
+ SCC_WWDG = _REG_BIT(0x24, 11),
+ SCC_SPI2 = _REG_BIT(0x24, 14),
+ SCC_SPI3 = _REG_BIT(0x24, 15),
+ SCC_USART2 = _REG_BIT(0x24, 17),
+ SCC_USART3 = _REG_BIT(0x24, 18),
+ SCC_UART4 = _REG_BIT(0x24, 19),
+ SCC_UART5 = _REG_BIT(0x24, 20),
+ SCC_I2C1 = _REG_BIT(0x24, 21),
+ SCC_I2C2 = _REG_BIT(0x24, 22),
+ SCC_USB = _REG_BIT(0x24, 23),
+ SCC_PWR = _REG_BIT(0x24, 28),
+ SCC_DAC = _REG_BIT(0x24, 29),
+ SCC_COMP = _REG_BIT(0x24, 31),
+};
+
+enum rcc_periph_rst {
+ /* AHB peripherals */
+ RST_GPIOA = _REG_BIT(0x10, 0),
+ RST_GPIOB = _REG_BIT(0x10, 1),
+ RST_GPIOC = _REG_BIT(0x10, 2),
+ RST_GPIOD = _REG_BIT(0x10, 3),
+ RST_GPIOE = _REG_BIT(0x10, 4),
+ RST_GPIOH = _REG_BIT(0x10, 5),
+ RST_GPIOF = _REG_BIT(0x10, 6),
+ RST_GPIOG = _REG_BIT(0x10, 7),
+ RST_CRC = _REG_BIT(0x10, 12),
+ RST_FLITF = _REG_BIT(0x10, 15),
+ RST_DMA1 = _REG_BIT(0x10, 24),
+ RST_DMA2 = _REG_BIT(0x10, 25),
+ RST_AES = _REG_BIT(0x10, 27),
+ RST_FSMC = _REG_BIT(0x10, 30),
+
+ /* APB2 peripherals */
+ RST_SYSCFG = _REG_BIT(0x14, 0),
+ RST_TIM9 = _REG_BIT(0x14, 2),
+ RST_TIM10 = _REG_BIT(0x14, 3),
+ RST_TIM11 = _REG_BIT(0x14, 4),
+ RST_ADC1 = _REG_BIT(0x14, 9),
+ RST_SDIO = _REG_BIT(0x14, 11),
+ RST_SPI1 = _REG_BIT(0x14, 12),
+ RST_USART1 = _REG_BIT(0x14, 14),
+
+ /* APB1 peripherals*/
+ RST_TIM2 = _REG_BIT(0x18, 0),
+ RST_TIM3 = _REG_BIT(0x18, 1),
+ RST_TIM4 = _REG_BIT(0x18, 2),
+ RST_TIM5 = _REG_BIT(0x18, 3),
+ RST_TIM6 = _REG_BIT(0x18, 4),
+ RST_TIM7 = _REG_BIT(0x18, 5),
+ RST_LCD = _REG_BIT(0x18, 9),
+ RST_WWDG = _REG_BIT(0x18, 11),
+ RST_SPI2 = _REG_BIT(0x18, 14),
+ RST_SPI3 = _REG_BIT(0x18, 15),
+ RST_USART2 = _REG_BIT(0x18, 17),
+ RST_USART3 = _REG_BIT(0x18, 18),
+ RST_UART4 = _REG_BIT(0x18, 19),
+ RST_UART5 = _REG_BIT(0x18, 20),
+ RST_I2C1 = _REG_BIT(0x18, 21),
+ RST_I2C2 = _REG_BIT(0x18, 22),
+ RST_USB = _REG_BIT(0x18, 23),
+ RST_PWR = _REG_BIT(0x18, 28),
+ RST_DAC = _REG_BIT(0x18, 29),
+ RST_COMP = _REG_BIT(0x18, 31),
+};
+#include <libopencm3/stm32/common/rcc_common_all.h>
+
+BEGIN_DECLS
+
+void rcc_osc_ready_int_clear(osc_t osc);
+void rcc_osc_ready_int_enable(osc_t osc);
+void rcc_osc_ready_int_disable(osc_t osc);
+int rcc_osc_ready_int_flag(osc_t osc);
+void rcc_css_int_clear(void);
+int rcc_css_int_flag(void);
+void rcc_wait_for_osc_ready(osc_t osc);
+void rcc_wait_for_sysclk_status(osc_t osc);
+void rcc_osc_on(osc_t osc);
+void rcc_osc_off(osc_t osc);
+void rcc_css_enable(void);
+void rcc_css_disable(void);
+void rcc_osc_bypass_enable(osc_t osc);
+void rcc_osc_bypass_disable(osc_t osc);
+void rcc_set_sysclk_source(uint32_t clk);
+void rcc_set_pll_configuration(uint32_t source, uint32_t multiplier,
+ uint32_t divisor);
+void rcc_set_pll_source(uint32_t pllsrc);
+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_rtcpre(uint32_t rtcpre);
+uint32_t rcc_system_clock_source(void);
+void rcc_rtc_select_clock(uint32_t clock);
+void rcc_clock_setup_msi(const clock_scale_t *clock);
+void rcc_clock_setup_hsi(const clock_scale_t *clock);
+void rcc_clock_setup_pll(const clock_scale_t *clock);
+void rcc_backupdomain_reset(void);
+
+END_DECLS
+
+/**@}*/
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/l1/rtc.h b/libopencm3/include/libopencm3/stm32/l1/rtc.h
new file mode 100644
index 0000000..3ba885c
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/rtc.h
@@ -0,0 +1,36 @@
+/** @defgroup rtc_defines RTC Defines
+
+@brief <b>Defined Constants and Types for the STM32L1xx RTC</b>
+
+@ingroup STM32L1xx_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_RTC_H
+#define LIBOPENCM3_RTC_H
+
+#include <libopencm3/stm32/common/rtc_common_l1f024.h>
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/l1/spi.h b/libopencm3/include/libopencm3/stm32/l1/spi.h
new file mode 100644
index 0000000..0db17fc
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/spi.h
@@ -0,0 +1,37 @@
+/** @defgroup spi_defines SPI Defines
+
+@brief <b>Defined Constants and Types for the STM32L1xx SPI</b>
+
+@ingroup STM32L1xx_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/l1/syscfg.h b/libopencm3/include/libopencm3/stm32/l1/syscfg.h
new file mode 100644
index 0000000..b2e4991
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/syscfg.h
@@ -0,0 +1,41 @@
+/** @defgroup syscfg_defines SYSCFG Defines
+ *
+ * @ingroup STM32L1xx_defines
+ *
+ * @brief Defined Constants and Types for the STM32L1xx Sysconfig
+ *
+ * @version 1.0.0
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2013
+ * Frantisek Burian <BuFran@seznam.cz>
+ *
+ * @date 13 January 2014
+ *
+ * LGPL License Terms @ref lgpl_license
+ * */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2013 Frantisek Burian <BuFran@seznam.cz>
+ *
+ * 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_SYSCFG_H
+#define LIBOPENCM3_SYSCFG_H
+
+#include <libopencm3/stm32/common/syscfg_common_l1f234.h>
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/l1/timer.h b/libopencm3/include/libopencm3/stm32/l1/timer.h
new file mode 100644
index 0000000..fbe1504
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/timer.h
@@ -0,0 +1,89 @@
+/** @defgroup timer_defines Timer Defines
+
+@brief <b>libopencm3 Defined Constants and Types for the STM32L1xx Timers</b>
+
+@ingroup STM32L1xx_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>
+
+/*
+ * TIM2 and TIM5 are now 32bit and the following registers are now 32-bit wide:
+ * CNT, ARR, CCR1, CCR2, CCR3, CCR4
+ */
+
+/* Timer 2/3 option register (TIMx_OR) */
+#define TIM_OR(tim_base) MMIO32(tim_base + 0x50)
+#define TIM2_OR TIM_OR(TIM2)
+#define TIM3_OR TIM_OR(TIM3)
+
+/* --- TIMx_OR values ---------------------------------------------------- */
+
+/* ITR1_RMP */
+/****************************************************************************/
+/** @defgroup tim2_opt_trigger_remap TIM2_OR Timer 2 Option Register Internal
+Trigger 1 Remap
+@ingroup timer_defines
+
+@{*/
+/** Internal Trigger 1 remapped to timer 10 output compare */
+#define TIM2_OR_ITR1_RMP_TIM10_OC (0x0 << 0)
+/** Internal Trigger 1 remapped to timer 5 TGO */
+#define TIM2_OR_ITR1_RMP_TIM5_TGO (0x1 << 0)
+/**@}*/
+#define TIM3_OR_ITR1_RMP_MASK (0x1 << 0)
+
+/* --- TIMx_OR values ---------------------------------------------------- */
+
+/* ITR2_RMP */
+/****************************************************************************/
+/** @defgroup tim3_opt_trigger_remap TIM3_OR Timer 3 Option Register Internal Trigger 2 Remap
+@ingroup timer_defines
+
+@{*/
+/** Internal Trigger 1 remapped to timer 11 output compare */
+#define TIM3_OR_ITR2_RMP_TIM8_TRGOU (0x0 << 0)
+/** Internal Trigger 1 remapped to timer 5 TGO */
+#define TIM3_OR_ITR2_RMP_PTP (0x1 << 0)
+/**@}*/
+#define TIM3_OR_ITR2_RMP_MASK (0x1 << 0)
+
+/* --- Function prototypes ------------------------------------------------- */
+
+BEGIN_DECLS
+
+void timer_set_option(uint32_t timer_peripheral, uint32_t option);
+
+END_DECLS
+
+#endif
diff --git a/libopencm3/include/libopencm3/stm32/l1/usart.h b/libopencm3/include/libopencm3/stm32/l1/usart.h
new file mode 100644
index 0000000..6fdce0e
--- /dev/null
+++ b/libopencm3/include/libopencm3/stm32/l1/usart.h
@@ -0,0 +1,37 @@
+/** @defgroup usart_defines USART Defines
+
+@brief <b>Defined Constants and Types for the STM32L1xx USART</b>
+
+@ingroup STM32L1xx_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
+