summaryrefslogtreecommitdiffstats
path: root/libopencm3/include/libopencm3/lm4f
diff options
context:
space:
mode:
Diffstat (limited to 'libopencm3/include/libopencm3/lm4f')
-rw-r--r--libopencm3/include/libopencm3/lm4f/doc-lm4f.h32
-rw-r--r--libopencm3/include/libopencm3/lm4f/gpio.h380
-rw-r--r--libopencm3/include/libopencm3/lm4f/memorymap.h71
-rw-r--r--libopencm3/include/libopencm3/lm4f/rcc.h133
-rw-r--r--libopencm3/include/libopencm3/lm4f/ssi.h118
-rw-r--r--libopencm3/include/libopencm3/lm4f/systemcontrol.h743
-rw-r--r--libopencm3/include/libopencm3/lm4f/uart.h550
-rw-r--r--libopencm3/include/libopencm3/lm4f/usb.h422
8 files changed, 2449 insertions, 0 deletions
diff --git a/libopencm3/include/libopencm3/lm4f/doc-lm4f.h b/libopencm3/include/libopencm3/lm4f/doc-lm4f.h
new file mode 100644
index 0000000..4877721
--- /dev/null
+++ b/libopencm3/include/libopencm3/lm4f/doc-lm4f.h
@@ -0,0 +1,32 @@
+/** @mainpage libopencm3 LM4F
+
+@version 1.0.0
+
+@date 22 November 2012
+
+API documentation for TI Stellaris LM4F Cortex M4F series.
+
+LGPL License Terms @ref lgpl_license
+*/
+
+/** @defgroup LM4Fxx LM4F
+Libraries for TI Stellaris LM4F series.
+
+@version 1.0.0
+
+@date 22 November 2012
+
+LGPL License Terms @ref lgpl_license
+*/
+
+/** @defgroup LM4Fxx_defines LM4F Defines
+
+@brief Defined Constants and Types for the LM4F series
+
+@version 1.0.0
+
+@date 22 November 2012
+
+LGPL License Terms @ref lgpl_license
+*/
+
diff --git a/libopencm3/include/libopencm3/lm4f/gpio.h b/libopencm3/include/libopencm3/lm4f/gpio.h
new file mode 100644
index 0000000..5f90ad3
--- /dev/null
+++ b/libopencm3/include/libopencm3/lm4f/gpio.h
@@ -0,0 +1,380 @@
+/** @defgroup gpio_defines General Purpose I/O Defines
+ *
+ * @brief <b>Defined Constants and Types for the LM4F General Purpose I/O</b>
+ *
+ * @ingroup LM4Fxx_defines
+ *
+ * @version 1.0.0
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2011
+ * Gareth McMullin <gareth@blacksphere.co.nz>
+ * @author @htmlonly &copy; @endhtmlonly 2013
+ * Alexandru Gagniuc <mr.nuke.me@gmail.com>
+ *
+ * @date 16 March 2013
+ *
+ * LGPL License Terms @ref lgpl_license
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2011 Gareth McMullin <gareth@blacksphere.co.nz>
+ * Copyright (C) 2013 Alexandru Gagniuc <mr.nuke.me@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 LM4F_GPIO_H
+#define LM4F_GPIO_H
+
+/**@{*/
+
+#include <libopencm3/cm3/common.h>
+#include <libopencm3/lm4f/memorymap.h>
+
+/* =============================================================================
+ * Convenience macros
+ * ---------------------------------------------------------------------------*/
+/** @defgroup gpio_reg_base GPIO register base addresses
+ * @{*/
+#define GPIOA GPIOA_BASE
+#define GPIOB GPIOB_BASE
+#define GPIOC GPIOC_BASE
+#define GPIOD GPIOD_BASE
+#define GPIOE GPIOE_BASE
+#define GPIOF GPIOF_BASE
+#define GPIOG GPIOG_BASE
+#define GPIOH GPIOH_BASE
+#define GPIOJ GPIOJ_BASE
+#define GPIOK GPIOK_BASE
+#define GPIOL GPIOL_BASE
+#define GPIOM GPIOM_BASE
+#define GPION GPION_BASE
+#define GPIOP GPIOP_BASE
+#define GPIOQ GPIOQ_BASE
+/** @} */
+
+/* =============================================================================
+ * GPIO number definitions (for convenience)
+ *
+ * These are usable across all GPIO registers,
+ * except GPIO_LOCK and GPIO_PCTL
+ * ---------------------------------------------------------------------------*/
+/** @defgroup gpio_pin_id GPIO pin identifiers
+ * @{*/
+#define GPIO0 (1 << 0)
+#define GPIO1 (1 << 1)
+#define GPIO2 (1 << 2)
+#define GPIO3 (1 << 3)
+#define GPIO4 (1 << 4)
+#define GPIO5 (1 << 5)
+#define GPIO6 (1 << 6)
+#define GPIO7 (1 << 7)
+#define GPIO_ALL 0xff
+/** @} */
+
+/* =============================================================================
+ * GPIO registers
+ * ---------------------------------------------------------------------------*/
+
+/* GPIO Data */
+#define GPIO_DATA(port) (&MMIO32(port + 0x000))
+
+/* GPIO Direction */
+#define GPIO_DIR(port) MMIO32(port + 0x400)
+
+/* GPIO Interrupt Sense */
+#define GPIO_IS(port) MMIO32(port + 0x404)
+
+/* GPIO Interrupt Both Edges */
+#define GPIO_IBE(port) MMIO32(port + 0x408)
+
+/* GPIO Interrupt Event */
+#define GPIO_IEV(port) MMIO32(port + 0x40c)
+
+/* GPIO Interrupt Mask */
+#define GPIO_IM(port) MMIO32(port + 0x410)
+
+/* GPIO Raw Interrupt Status */
+#define GPIO_RIS(port) MMIO32(port + 0x414)
+
+/* GPIO Masked Interrupt Status */
+#define GPIO_MIS(port) MMIO32(port + 0x418)
+
+/* GPIO Interrupt Clear */
+#define GPIO_ICR(port) MMIO32(port + 0x41c)
+
+/* GPIO Alternate Function Select */
+#define GPIO_AFSEL(port) MMIO32(port + 0x420)
+
+/* GPIO 2-mA Drive Select */
+#define GPIO_DR2R(port) MMIO32(port + 0x500)
+
+/* GPIO 4-mA Drive Select */
+#define GPIO_DR4R(port) MMIO32(port + 0x504)
+
+/* GPIO 8-mA Drive Select */
+#define GPIO_DR8R(port) MMIO32(port + 0x508)
+
+/* GPIO Open Drain Select */
+#define GPIO_ODR(port) MMIO32(port + 0x50c)
+
+/* GPIO Pull-Up Select */
+#define GPIO_PUR(port) MMIO32(port + 0x510)
+
+/* GPIO Pull-Down Select */
+#define GPIO_PDR(port) MMIO32(port + 0x514)
+
+/* GPIO Slew Rate Control Select */
+#define GPIO_SLR(port) MMIO32(port + 0x518)
+
+/* GPIO Digital Enable */
+#define GPIO_DEN(port) MMIO32(port + 0x51c)
+
+/* GPIO Lock */
+#define GPIO_LOCK(port) MMIO32(port + 0x520)
+
+/* GPIO Commit */
+#define GPIO_CR(port) MMIO32(port + 0x524)
+
+/* GPIO Analog Mode Select */
+#define GPIO_AMSEL(port) MMIO32(port + 0x528)
+
+/* GPIO Port Control */
+#define GPIO_PCTL(port) MMIO32(port + 0x52C)
+
+/* GPIO ADC Control */
+#define GPIO_ADCCTL(port) MMIO32(port + 0x530)
+
+/* GPIO DMA Control */
+#define GPIO_DMACTL(port) MMIO32(port + 0x534)
+
+/* GPIO Peripheral Identification */
+#define GPIO_PERIPH_ID4(port) MMIO32(port + 0xFD0)
+#define GPIO_PERIPH_ID5(port) MMIO32(port + 0xFD4)
+#define GPIO_PERIPH_ID6(port) MMIO32(port + 0xFD8)
+#define GPIO_PERIPH_ID7(port) MMIO32(port + 0xFDC)
+#define GPIO_PERIPH_ID0(port) MMIO32(port + 0xFE0)
+#define GPIO_PERIPH_ID1(port) MMIO32(port + 0xFE4)
+#define GPIO_PERIPH_ID2(port) MMIO32(port + 0xFE8)
+#define GPIO_PERIPH_ID3(port) MMIO32(port + 0xFEC)
+
+/* GPIO PrimeCell Identification */
+#define GPIO_PCELL_ID0(port) MMIO32(port + 0xFF0)
+#define GPIO_PCELL_ID1(port) MMIO32(port + 0xFF4)
+#define GPIO_PCELL_ID2(port) MMIO32(port + 0xFF8)
+#define GPIO_PCELL_ID3(port) MMIO32(port + 0xFFC)
+
+/* =============================================================================
+ * Convenience enums
+ * ---------------------------------------------------------------------------*/
+enum gpio_mode {
+ GPIO_MODE_OUTPUT, /**< Configure pin as output */
+ GPIO_MODE_INPUT, /**< Configure pin as input */
+ GPIO_MODE_ANALOG, /**< Configure pin as analog function */
+};
+
+enum gpio_pullup {
+ GPIO_PUPD_NONE, /**< Do not pull the pin high or low */
+ GPIO_PUPD_PULLUP, /**< Pull the pin high */
+ GPIO_PUPD_PULLDOWN, /**< Pull the pin low */
+};
+
+enum gpio_output_type {
+ GPIO_OTYPE_PP, /**< Push-pull configuration */
+ GPIO_OTYPE_OD, /**< Open drain configuration */
+};
+
+enum gpio_drive_strength {
+ GPIO_DRIVE_2MA, /**< 2mA drive */
+ GPIO_DRIVE_4MA, /**< 4mA drive */
+ GPIO_DRIVE_8MA, /**< 8mA drive */
+ GPIO_DRIVE_8MA_SLEW_CTL,/**< 8mA drive with slew rate control */
+};
+
+enum gpio_trigger {
+ GPIO_TRIG_LVL_LOW, /**< Level trigger, signal low */
+ GPIO_TRIG_LVL_HIGH, /**< Level trigger, signal high */
+ GPIO_TRIG_EDGE_FALL, /**< Falling edge trigger */
+ GPIO_TRIG_EDGE_RISE, /**< Rising edge trigger*/
+ GPIO_TRIG_EDGE_BOTH, /**< Falling and Rising edges trigger*/
+};
+/* =============================================================================
+ * Function prototypes
+ * ---------------------------------------------------------------------------*/
+BEGIN_DECLS
+
+void gpio_enable_ahb_aperture(void);
+void gpio_mode_setup(uint32_t gpioport, enum gpio_mode mode,
+ enum gpio_pullup pullup, uint8_t gpios);
+void gpio_set_output_config(uint32_t gpioport, enum gpio_output_type otype,
+ enum gpio_drive_strength drive, uint8_t gpios);
+void gpio_set_af(uint32_t gpioport, uint8_t alt_func_num, uint8_t gpios);
+
+void gpio_toggle(uint32_t gpioport, uint8_t gpios);
+void gpio_unlock_commit(uint32_t gpioport, uint8_t gpios);
+
+/* Let's keep these ones inlined. GPIO control should be fast */
+/** @ingroup gpio_control
+ * @{ */
+
+/**
+ * \brief Get status of a Group of Pins (atomic)
+ *
+ * Reads the level of the given pins. Bit 0 of the returned data corresponds to
+ * GPIO0 level, bit 1 to GPIO1 level. and so on. Bits corresponding to masked
+ * pins (corresponding bit of gpios parameter set to zero) are returned as 0.
+ *
+ * This is an atomic operation.
+ *
+ * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
+ * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
+ * by OR'ing then together.
+ *
+ * @return The level of the GPIO port. The pins not specified in gpios are
+ * masked to zero.
+ */
+static inline uint8_t gpio_read(uint32_t gpioport, uint8_t gpios)
+{
+ return GPIO_DATA(gpioport)[gpios];
+}
+
+/**
+ * \brief Set level of a Group of Pins (atomic)
+ *
+ * Sets the level of the given pins. Bit 0 of the data parameter corresponds to
+ * GPIO0, bit 1 to GPIO1. and so on. Maskedpins (corresponding bit of gpios
+ * parameter set to zero) are returned not affected.
+ *
+ * This is an atomic operation.
+ *
+ * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
+ * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
+ * by OR'ing then together.
+ * @param[in] data Level to set pin to. Bit 0 of data corresponds to GPIO0, bit
+ * 1 to GPIO1. and so on.
+ */
+static inline void gpio_write(uint32_t gpioport, uint8_t gpios, uint8_t data)
+{
+ /* ipaddr[9:2] mask the bits to be set, hence the array index */
+ GPIO_DATA(gpioport)[gpios] = data;
+}
+
+/**
+ * \brief Set a Group of Pins (atomic)
+ *
+ * Set one or more pins of the given GPIO port. This is an atomic operation.
+ *
+ * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
+ * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
+ * by OR'ing then together.
+ */
+static inline void gpio_set(uint32_t gpioport, uint8_t gpios)
+{
+ gpio_write(gpioport, gpios, 0xff);
+}
+
+/**
+ * \brief Clear a Group of Pins (atomic)
+ *
+ * Clear one or more pins of the given GPIO port. This is an atomic operation.
+ *
+ * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
+ * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
+ * by OR'ing then together.
+ */
+static inline void gpio_clear(uint32_t gpioport, uint8_t gpios)
+{
+ gpio_write(gpioport, gpios, 0);
+}
+
+/**
+ * \brief Read level of all pins from a port (atomic)
+ *
+ * Read the current value of the given GPIO port. This is an atomic operation.
+ *
+ * This is functionally identical to @ref gpio_read (gpioport, GPIO_ALL).
+ *
+ * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
+ *
+ * @return The level of all the pins on the GPIO port.
+ */
+static inline uint8_t gpio_port_read(uint32_t gpioport)
+{
+ return gpio_read(gpioport, GPIO_ALL);
+}
+
+/**
+ * \brief Set level of of all pins from a port (atomic)
+ *
+ * Set the level of all pins on the given GPIO port. This is an atomic
+ * operation.
+ *
+ * This is functionally identical to @ref gpio_write (gpioport, GPIO_ALL, data).
+ *
+ * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
+ * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
+ * by OR'ing then together.
+ * @param[in] data Level to set pin to. Bit 0 of data corresponds to GPIO0, bit
+ * 1 to GPIO1. and so on.
+ */
+static inline void gpio_port_write(uint32_t gpioport, uint8_t data)
+{
+ gpio_write(gpioport, GPIO_ALL, data);
+}
+/** @} */
+
+void gpio_configure_trigger(uint32_t gpioport, enum gpio_trigger trigger,
+ uint8_t gpios);
+void gpio_enable_interrupts(uint32_t gpioport, uint8_t gpios);
+void gpio_disable_interrupts(uint32_t gpioport, uint8_t gpios);
+
+
+/* Let's keep these ones inlined. GPIO. They are designed to be used in ISRs */
+/** @ingroup gpio_irq
+ * @{ */
+/** \brief Determine if interrupt is generated by the given pin
+ *
+ * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
+ * @param[in] srcpins source pin or group of pins to check.
+ */
+static inline bool gpio_is_interrupt_source(uint32_t gpioport, uint8_t srcpins)
+{
+ return GPIO_MIS(gpioport) & srcpins;
+}
+
+/**
+ * \brief Mark interrupt as serviced
+ *
+ * After an interrupt is services, its flag must be cleared. If the flag is not
+ * cleared, then execution will jump back to the start of the ISR after the ISR
+ * returns.
+ *
+ * @param[in] gpioport GPIO block register address base @ref gpio_reg_base
+ * @param[in] gpios @ref gpio_pin_id. Any combination of pins may be specified
+ * by OR'ing then together.
+ */
+static inline void gpio_clear_interrupt_flag(uint32_t gpioport, uint8_t gpios)
+{
+ GPIO_ICR(gpioport) |= gpios;
+}
+
+/** @} */
+END_DECLS
+
+#endif
+
+/**@}*/
+
diff --git a/libopencm3/include/libopencm3/lm4f/memorymap.h b/libopencm3/include/libopencm3/lm4f/memorymap.h
new file mode 100644
index 0000000..9a20f6d
--- /dev/null
+++ b/libopencm3/include/libopencm3/lm4f/memorymap.h
@@ -0,0 +1,71 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2011 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/>.
+ */
+
+#ifndef LM4F_MEMORYMAP_H
+#define LM4F_MEMORYMAP_H
+
+#include <libopencm3/cm3/common.h>
+
+/* --- LM4F specific peripheral definitions ----------------------------- */
+
+#define GPIOA_APB_BASE (0x40004000U)
+#define GPIOB_APB_BASE (0x40005000U)
+#define GPIOC_APB_BASE (0x40006000U)
+#define GPIOD_APB_BASE (0x40007000U)
+#define GPIOE_APB_BASE (0x40024000U)
+#define GPIOF_APB_BASE (0x40025000U)
+#define GPIOG_APB_BASE (0x40026000U)
+#define GPIOH_APB_BASE (0x40027000U)
+#define GPIOJ_APB_BASE (0x4003D000U)
+
+#define GPIOA_BASE (0x40058000U)
+#define GPIOB_BASE (0x40059000U)
+#define GPIOC_BASE (0x4005A000U)
+#define GPIOD_BASE (0x4005B000U)
+#define GPIOE_BASE (0x4005C000U)
+#define GPIOF_BASE (0x4005D000U)
+#define GPIOG_BASE (0x4005E000U)
+#define GPIOH_BASE (0x4005F000U)
+#define GPIOJ_BASE (0x40060000U)
+#define GPIOK_BASE (0x40061000U)
+#define GPIOL_BASE (0x40062000U)
+#define GPIOM_BASE (0x40063000U)
+#define GPION_BASE (0x40064000U)
+#define GPIOP_BASE (0x40065000U)
+#define GPIOQ_BASE (0x40066000U)
+
+#define UART0_BASE (0x4000C000U)
+#define UART1_BASE (0x4000D000U)
+#define UART2_BASE (0x4000E000U)
+#define UART3_BASE (0x4000F000U)
+#define UART4_BASE (0x40010000U)
+#define UART5_BASE (0x40011000U)
+#define UART6_BASE (0x40012000U)
+#define UART7_BASE (0x40013000U)
+
+#define SSI0_BASE (0x40008000U)
+#define SSI1_BASE (0x40009000U)
+#define SSI2_BASE (0x4000A000U)
+#define SSI3_BASE (0x4000B000U)
+
+#define USB_BASE (0x40050000U)
+
+#define SYSCTL_BASE (0x400FE000U)
+
+#endif
diff --git a/libopencm3/include/libopencm3/lm4f/rcc.h b/libopencm3/include/libopencm3/lm4f/rcc.h
new file mode 100644
index 0000000..98a92cf
--- /dev/null
+++ b/libopencm3/include/libopencm3/lm4f/rcc.h
@@ -0,0 +1,133 @@
+/** @defgroup rcc_defines Reset and Clock Control
+
+@brief <b>Defined Constants and Types for the LM4F Reset and Clock Control</b>
+
+@ingroup LM4Fxx_defines
+
+@version 1.0.0
+
+@author @htmlonly &copy; @endhtmlonly 2012
+Alexandru Gagniuc <mr.nuke.me@gmail.com>
+
+@date 10 March 2013
+
+LGPL License Terms @ref lgpl_license
+*/
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@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 LM4F_RCC_H
+#define LM4F_RCC_H
+
+/**@{*/
+
+#include <libopencm3/lm4f/systemcontrol.h>
+
+/**
+ * \brief Oscillator source values
+ *
+ * Possible values of the oscillator source.
+ */
+enum osc_src {
+ OSCSRC_MOSC = SYSCTL_RCC2_OSCSRC2_MOSC,
+ OSCSRC_PIOSC = SYSCTL_RCC2_OSCSRC2_PIOSC,
+ OSCSRC_PIOSC_D4 = SYSCTL_RCC2_OSCSRC2_PIOSC_D4,
+ OSCSRC_30K_INT = SYSCTL_RCC2_OSCSRC2_30K,
+ OSCSRC_32K_EXT = SYSCTL_RCC2_OSCSRC2_32K768,
+};
+
+/**
+ * \brief PWM clock divisor values
+ *
+ * Possible values of the binary divisor used to predivide the system clock down
+ * for use as the timing reference for the PWM module.
+ */
+enum pwm_clkdiv {
+ PWMDIV_2 = SYSCTL_RCC_PWMDIV_2,
+ PWMDIV_4 = SYSCTL_RCC_PWMDIV_4,
+ PWMDIV_8 = SYSCTL_RCC_PWMDIV_8,
+ PWMDIV_16 = SYSCTL_RCC_PWMDIV_16,
+ PWMDIV_32 = SYSCTL_RCC_PWMDIV_32,
+ PWMDIV_64 = SYSCTL_RCC_PWMDIV_64,
+};
+
+/**
+ * \brief Predefined crystal values
+ *
+ * Predefined crystal values for the XTAL field in SYSCTL_RCC.
+ * Using these predefined values in the XTAL field, the SYSCTL_PLLFREQ0 and
+ * SYSCTL_PLLFREQ1 are automatically adjusted in hardware to provide a PLL clock
+ * of 400MHz.
+ */
+enum xtal_t {
+ XTAL_4M = SYSCTL_RCC_XTAL_4M,
+ XTAL_4M_096 = SYSCTL_RCC_XTAL_4M_096,
+ XTAL_4M_9152 = SYSCTL_RCC_XTAL_4M_9152,
+ XTAL_5M = SYSCTL_RCC_XTAL_5M,
+ XTAL_5M_12 = SYSCTL_RCC_XTAL_5M_12,
+ XTAL_6M = SYSCTL_RCC_XTAL_6M,
+ XTAL_6M_144 = SYSCTL_RCC_XTAL_6M_144,
+ XTAL_7M_3728 = SYSCTL_RCC_XTAL_7M_3728,
+ XTAL_8M = SYSCTL_RCC_XTAL_8M,
+ XTAL_8M_192 = SYSCTL_RCC_XTAL_8M_192,
+ XTAL_10M = SYSCTL_RCC_XTAL_10M,
+ XTAL_12M = SYSCTL_RCC_XTAL_12M,
+ XTAL_12M_288 = SYSCTL_RCC_XTAL_12M_288,
+ XTAL_13M_56 = SYSCTL_RCC_XTAL_13M_56,
+ XTAL_14M_31818 = SYSCTL_RCC_XTAL_14M_31818,
+ XTAL_16M = SYSCTL_RCC_XTAL_16M,
+ XTAL_16M_384 = SYSCTL_RCC_XTAL_16M_384,
+ XTAL_18M = SYSCTL_RCC_XTAL_18M,
+ XTAL_20M = SYSCTL_RCC_XTAL_20M,
+ XTAL_24M = SYSCTL_RCC_XTAL_24M,
+ XTAL_25M = SYSCTL_RCC_XTAL_25M,
+};
+
+/* =============================================================================
+ * Function prototypes
+ * ---------------------------------------------------------------------------*/
+BEGIN_DECLS
+/* Low-level clock API */
+void rcc_configure_xtal(enum xtal_t xtal);
+void rcc_disable_main_osc(void);
+void rcc_disable_interal_osc(void);
+void rcc_enable_main_osc(void);
+void rcc_enable_interal_osc(void);
+void rcc_enable_rcc2(void);
+void rcc_pll_off(void);
+void rcc_pll_on(void);
+void rcc_set_osc_source(enum osc_src src);
+void rcc_pll_bypass_disable(void);
+void rcc_pll_bypass_enable(void);
+void rcc_set_pll_divisor(uint8_t div400);
+void rcc_set_pwm_divisor(enum pwm_clkdiv div);
+void rcc_usb_pll_off(void);
+void rcc_usb_pll_on(void);
+void rcc_wait_for_pll_ready(void);
+/* High-level clock API */
+void rcc_change_pll_divisor(uint8_t plldiv400);
+uint32_t rcc_get_system_clock_frequency(void);
+void rcc_sysclk_config(enum osc_src src, enum xtal_t xtal, uint8_t pll_div400);
+
+END_DECLS
+
+/**@}*/
+
+#endif /* LM4F_RCC_H */
diff --git a/libopencm3/include/libopencm3/lm4f/ssi.h b/libopencm3/include/libopencm3/lm4f/ssi.h
new file mode 100644
index 0000000..be9e4a8
--- /dev/null
+++ b/libopencm3/include/libopencm3/lm4f/ssi.h
@@ -0,0 +1,118 @@
+/** @defgroup ssi_defines Synchronous Serial Interface
+ *
+ * @brief <b>Defined Constants and Types for the LM4F Synchronous Serial Interface (SSI)</b>
+ *
+ * @ingroup LM4Fxx_defines
+ *
+ * @version 1.0.0
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2014
+ * Tiago Costa <nippius+github@gmail.com>
+ *
+ * @date 11 June 2014
+ *
+ * LGPL License Terms @ref lgpl_license
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2014 Tiago Costa <nippius+github@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 LM4F_SSI_H
+#define LM4F_SSI_H
+
+/**@{*/
+
+#include <libopencm3/cm3/common.h>
+#include <libopencm3/lm4f/memorymap.h>
+
+/* =============================================================================
+ * Convenience macros
+ * ---------------------------------------------------------------------------*/
+/** @defgroup ssi_base SSI register base addresses
+ * @{*/
+#define SSI0 SSI0_BASE
+#define SSI1 SSI1_BASE
+#define SSI2 SSI2_BASE
+#define SSI3 SSI3_BASE
+/** @} */
+
+/* =============================================================================
+ * SSI registers
+ * ---------------------------------------------------------------------------*/
+
+/* SSI Control 0 */
+#define SSI_CR0(port) MMIO32(port + 0x000)
+
+/* SSI Control 1 */
+#define SSI_CR1(port) MMIO32(port + 0x004)
+
+/* SSI Data */
+#define SSI_DR(port) MMIO32(port + 0x008)
+
+/* SSI Satus */
+#define SSI_SR(port) MMIO32(port + 0x00C)
+
+/* SSI Clock Prescale */
+#define SSI_CPSR(port) MMIO32(port + 0x010)
+
+/* SSI Interrupt Mask */
+#define SSI_IM(port) MMIO32(port + 0x014)
+
+/* SSI Raw Interrupt Status */
+#define SSI_RIS(port) MMIO32(port + 0x018)
+
+/* SSI Masked Interrupt Status */
+#define SSI_MIS(port) MMIO32(port + 0x01C)
+
+/* SSI Interrupt Clear */
+#define SSI_ICR(port) MMIO32(port + 0x020)
+
+/* SSI DMA Control */
+#define SSI_DMACTL(port) MMIO32(port + 0x024)
+
+/* SSI Clock Configuration */
+#define SSI_CC(port) MMIO32(port + 0xFC8)
+
+/* SSI Peripheral Identification */
+#define SSI_PERIPH_ID4(port) MMIO32(port + 0xFD0)
+#define SSI_PERIPH_ID5(port) MMIO32(port + 0xFD4)
+#define SSI_PERIPH_ID6(port) MMIO32(port + 0xFD8)
+#define SSI_PERIPH_ID7(port) MMIO32(port + 0xFDC)
+#define SSI_PERIPH_ID0(port) MMIO32(port + 0xFE0)
+#define SSI_PERIPH_ID1(port) MMIO32(port + 0xFE4)
+#define SSI_PERIPH_ID2(port) MMIO32(port + 0xFE8)
+#define SSI_PERIPH_ID3(port) MMIO32(port + 0xFEC)
+
+/* SSI PrimeCell Identification */
+#define SSI_PCELL_ID0(port) MMIO32(port + 0xFF0)
+#define SSI_PCELL_ID1(port) MMIO32(port + 0xFF4)
+#define SSI_PCELL_ID2(port) MMIO32(port + 0xFF8)
+#define SSI_PCELL_ID3(port) MMIO32(port + 0xFFC)
+
+/* =============================================================================
+ * Function prototypes
+ * ---------------------------------------------------------------------------*/
+BEGIN_DECLS
+
+END_DECLS
+
+/**@}*/
+
+#endif /* LM4F_SSI_H */
+ \ No newline at end of file
diff --git a/libopencm3/include/libopencm3/lm4f/systemcontrol.h b/libopencm3/include/libopencm3/lm4f/systemcontrol.h
new file mode 100644
index 0000000..62e2231
--- /dev/null
+++ b/libopencm3/include/libopencm3/lm4f/systemcontrol.h
@@ -0,0 +1,743 @@
+/** @defgroup systemcontrol_defines System Control
+
+@brief <b>Defined Constants and Types for the LM4F System Control</b>
+
+@ingroup LM4Fxx_defines
+
+@version 1.0.0
+
+@author @htmlonly &copy; @endhtmlonly 2012
+Alexandru Gagniuc <mr.nuke.me@gmail.com>
+
+@date 10 March 2013
+
+LGPL License Terms @ref lgpl_license
+ */
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@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 LM4F_SYSTEMCONTROL_H
+#define LM4F_SYSTEMCONTROL_H
+
+/**@{*/
+
+#include <libopencm3/cm3/common.h>
+#include <libopencm3/lm4f/memorymap.h>
+
+#define SYSCTL_DID0 MMIO32(SYSCTL_BASE + 0x000)
+#define SYSCTL_DID1 MMIO32(SYSCTL_BASE + 0x004)
+#define SYSCTL_PBORCTL MMIO32(SYSCTL_BASE + 0x030)
+#define SYSCTL_LDORCTL MMIO32(SYSCTL_BASE + 0x034)
+#define SYSCTL_RIS MMIO32(SYSCTL_BASE + 0x050)
+#define SYSCTL_IMC MMIO32(SYSCTL_BASE + 0x054)
+#define SYSCTL_MISC MMIO32(SYSCTL_BASE + 0x058)
+#define SYSCTL_RESC MMIO32(SYSCTL_BASE + 0x05C)
+#define SYSCTL_RCC MMIO32(SYSCTL_BASE + 0x060)
+#define SYSCTL_PLLCFG MMIO32(SYSCTL_BASE + 0x064)
+#define SYSCTL_GPIOHBCTL MMIO32(SYSCTL_BASE + 0x06C)
+#define SYSCTL_RCC2 MMIO32(SYSCTL_BASE + 0x070)
+#define SYSCTL_MOSCCTL MMIO32(SYSCTL_BASE + 0x07C)
+#define SYSCTL_DSLPCLKCFG MMIO32(SYSCTL_BASE + 0x144)
+#define SYSCTL_SYSPROP MMIO32(SYSCTL_BASE + 0x14C)
+#define SYSCTL_PIOSCCAL MMIO32(SYSCTL_BASE + 0x150)
+#define SYSCTL_PIOSCSTAT MMIO32(SYSCTL_BASE + 0x154)
+#define SYSCTL_PLLFREQ0 MMIO32(SYSCTL_BASE + 0x160)
+#define SYSCTL_PLLFREQ1 MMIO32(SYSCTL_BASE + 0x164)
+#define SYSCTL_PLLSTAT MMIO32(SYSCTL_BASE + 0x168)
+/* Peripheral present */
+#define SYSCTL_PPWD MMIO32(SYSCTL_BASE + 0x300)
+#define SYSCTL_PPTIMER MMIO32(SYSCTL_BASE + 0x304)
+#define SYSCTL_PPGPIO MMIO32(SYSCTL_BASE + 0x308)
+#define SYSCTL_PPDMA MMIO32(SYSCTL_BASE + 0x30C)
+#define SYSCTL_PPHIB MMIO32(SYSCTL_BASE + 0x314)
+#define SYSCTL_PPUART MMIO32(SYSCTL_BASE + 0x318)
+#define SYSCTL_PPSSI MMIO32(SYSCTL_BASE + 0x31C)
+#define SYSCTL_PPI2C MMIO32(SYSCTL_BASE + 0x320)
+#define SYSCTL_PPUSB MMIO32(SYSCTL_BASE + 0x328)
+#define SYSCTL_PPCAN MMIO32(SYSCTL_BASE + 0x334)
+#define SYSCTL_PPADC MMIO32(SYSCTL_BASE + 0x338)
+#define SYSCTL_PPACMP MMIO32(SYSCTL_BASE + 0x33C)
+#define SYSCTL_PPPWM MMIO32(SYSCTL_BASE + 0x340)
+#define SYSCTL_PPQEI MMIO32(SYSCTL_BASE + 0x344)
+#define SYSCTL_PPEEPROM MMIO32(SYSCTL_BASE + 0x358)
+#define SYSCTL_PPWTIMER MMIO32(SYSCTL_BASE + 0x35C)
+/* Peripheral software reset */
+#define SYSCTL_SRWD MMIO32(SYSCTL_BASE + 0x500)
+#define SYSCTL_SRTIMER MMIO32(SYSCTL_BASE + 0x504)
+#define SYSCTL_SRGPIO MMIO32(SYSCTL_BASE + 0x508)
+#define SYSCTL_SRDMA MMIO32(SYSCTL_BASE + 0x50C)
+#define SYSCTL_SRHIB MMIO32(SYSCTL_BASE + 0x514)
+#define SYSCTL_SRUART MMIO32(SYSCTL_BASE + 0x518)
+#define SYSCTL_SRSSI MMIO32(SYSCTL_BASE + 0x51C)
+#define SYSCTL_SRI2C MMIO32(SYSCTL_BASE + 0x520)
+#define SYSCTL_SRUSB MMIO32(SYSCTL_BASE + 0x528)
+#define SYSCTL_SRCAN MMIO32(SYSCTL_BASE + 0x534)
+#define SYSCTL_SRADC MMIO32(SYSCTL_BASE + 0x538)
+#define SYSCTL_SRACMP MMIO32(SYSCTL_BASE + 0x53C)
+#define SYSCTL_SRPWM MMIO32(SYSCTL_BASE + 0x540)
+#define SYSCTL_SRQEI MMIO32(SYSCTL_BASE + 0x544)
+#define SYSCTL_SREEPROM MMIO32(SYSCTL_BASE + 0x558)
+#define SYSCTL_SRWTIMER MMIO32(SYSCTL_BASE + 0x55C)
+/* Peripheral run mode clock gating control */
+#define SYSCTL_RCGCWD MMIO32(SYSCTL_BASE + 0x600)
+#define SYSCTL_RCGCTIMER MMIO32(SYSCTL_BASE + 0x604)
+#define SYSCTL_RCGCGPIO MMIO32(SYSCTL_BASE + 0x608)
+#define SYSCTL_RCGCDMA MMIO32(SYSCTL_BASE + 0x60C)
+#define SYSCTL_RCGCHIB MMIO32(SYSCTL_BASE + 0x614)
+#define SYSCTL_RCGCUART MMIO32(SYSCTL_BASE + 0x618)
+#define SYSCTL_RCGCSSI MMIO32(SYSCTL_BASE + 0x61C)
+#define SYSCTL_RCGCI2C MMIO32(SYSCTL_BASE + 0x620)
+#define SYSCTL_RCGCUSB MMIO32(SYSCTL_BASE + 0x628)
+#define SYSCTL_RCGCCAN MMIO32(SYSCTL_BASE + 0x634)
+#define SYSCTL_RCGCADC MMIO32(SYSCTL_BASE + 0x638)
+#define SYSCTL_RCGCACMP MMIO32(SYSCTL_BASE + 0x63C)
+#define SYSCTL_RCGCPWM MMIO32(SYSCTL_BASE + 0x640)
+#define SYSCTL_RCGCQEI MMIO32(SYSCTL_BASE + 0x644)
+#define SYSCTL_RCGCEEPROM MMIO32(SYSCTL_BASE + 0x658)
+#define SYSCTL_RCGCWTIMER MMIO32(SYSCTL_BASE + 0x65C)
+/* Peripheral sleep mode clock gating control */
+#define SYSCTL_SCGCWD MMIO32(SYSCTL_BASE + 0x700)
+#define SYSCTL_SCGCTIMER MMIO32(SYSCTL_BASE + 0x704)
+#define SYSCTL_SCGCGPIO MMIO32(SYSCTL_BASE + 0x708)
+#define SYSCTL_SCGCDMA MMIO32(SYSCTL_BASE + 0x70C)
+#define SYSCTL_SCGCHIB MMIO32(SYSCTL_BASE + 0x714)
+#define SYSCTL_SCGCUART MMIO32(SYSCTL_BASE + 0x718)
+#define SYSCTL_SCGCSSI MMIO32(SYSCTL_BASE + 0x71C)
+#define SYSCTL_SCGCI2C MMIO32(SYSCTL_BASE + 0x720)
+#define SYSCTL_SCGCUSB MMIO32(SYSCTL_BASE + 0x728)
+#define SYSCTL_SCGCCAN MMIO32(SYSCTL_BASE + 0x734)
+#define SYSCTL_SCGCADC MMIO32(SYSCTL_BASE + 0x738)
+#define SYSCTL_SCGCACMP MMIO32(SYSCTL_BASE + 0x73C)
+#define SYSCTL_SCGCPWM MMIO32(SYSCTL_BASE + 0x740)
+#define SYSCTL_SCGCQEI MMIO32(SYSCTL_BASE + 0x744)
+#define SYSCTL_SCGCEEPROM MMIO32(SYSCTL_BASE + 0x758)
+#define SYSCTL_SCGCWTIMER MMIO32(SYSCTL_BASE + 0x75C)
+/* Peripheral deep-sleep mode clock gating control */
+#define SYSCTL_DCGCWD MMIO32(SYSCTL_BASE + 0x800)
+#define SYSCTL_DCGCTIMER MMIO32(SYSCTL_BASE + 0x804)
+#define SYSCTL_DCGCGPIO MMIO32(SYSCTL_BASE + 0x808)
+#define SYSCTL_DCGCDMA MMIO32(SYSCTL_BASE + 0x80C)
+#define SYSCTL_DCGCHIB MMIO32(SYSCTL_BASE + 0x814)
+#define SYSCTL_DCGCUART MMIO32(SYSCTL_BASE + 0x818)
+#define SYSCTL_DCGCSSI MMIO32(SYSCTL_BASE + 0x81C)
+#define SYSCTL_DCGCI2C MMIO32(SYSCTL_BASE + 0x820)
+#define SYSCTL_DCGCUSB MMIO32(SYSCTL_BASE + 0x828)
+#define SYSCTL_DCGCCAN MMIO32(SYSCTL_BASE + 0x834)
+#define SYSCTL_DCGCADC MMIO32(SYSCTL_BASE + 0x838)
+#define SYSCTL_DCGCACMP MMIO32(SYSCTL_BASE + 0x83C)
+#define SYSCTL_DCGCPWM MMIO32(SYSCTL_BASE + 0x840)
+#define SYSCTL_DCGCQEI MMIO32(SYSCTL_BASE + 0x844)
+#define SYSCTL_DCGCEEPROM MMIO32(SYSCTL_BASE + 0x858)
+#define SYSCTL_DCGCWTIMER MMIO32(SYSCTL_BASE + 0x85C)
+/* Peripheral ready */
+#define SYSCTL_PRWD MMIO32(SYSCTL_BASE + 0xA00)
+#define SYSCTL_PRTIMER MMIO32(SYSCTL_BASE + 0xA04)
+#define SYSCTL_PRGPIO MMIO32(SYSCTL_BASE + 0xA08)
+#define SYSCTL_PRDMA MMIO32(SYSCTL_BASE + 0xA0C)
+#define SYSCTL_PRHIB MMIO32(SYSCTL_BASE + 0xA14)
+#define SYSCTL_PRUART MMIO32(SYSCTL_BASE + 0xA18)
+#define SYSCTL_PRSSI MMIO32(SYSCTL_BASE + 0xA1C)
+#define SYSCTL_PRI2C MMIO32(SYSCTL_BASE + 0xA20)
+#define SYSCTL_PRUSB MMIO32(SYSCTL_BASE + 0xA28)
+#define SYSCTL_PRCAN MMIO32(SYSCTL_BASE + 0xA34)
+#define SYSCTL_PRADC MMIO32(SYSCTL_BASE + 0xA38)
+#define SYSCTL_PRACMP MMIO32(SYSCTL_BASE + 0xA3C)
+#define SYSCTL_PRPWM MMIO32(SYSCTL_BASE + 0xA40)
+#define SYSCTL_PRQEI MMIO32(SYSCTL_BASE + 0xA44)
+#define SYSCTL_PREEPROM MMIO32(SYSCTL_BASE + 0xA58)
+#define SYSCTL_PRWTIMER MMIO32(SYSCTL_BASE + 0xA5C)
+/* =============================================================================
+ * System Control Legacy Registers
+ * ---------------------------------------------------------------------------*/
+#ifdef LM4F_LEGACY_SYSCTL
+#define SYSCTL_DC0 MMIO32(SYSCTL_BASE + 0x008)
+#define SYSCTL_DC1 MMIO32(SYSCTL_BASE + 0x010)
+#define SYSCTL_DC2 MMIO32(SYSCTL_BASE + 0x014)
+#define SYSCTL_DC3 MMIO32(SYSCTL_BASE + 0x018)
+#define SYSCTL_DC4 MMIO32(SYSCTL_BASE + 0x01C)
+#define SYSCTL_DC5 MMIO32(SYSCTL_BASE + 0x020)
+#define SYSCTL_DC6 MMIO32(SYSCTL_BASE + 0x024)
+#define SYSCTL_DC7 MMIO32(SYSCTL_BASE + 0x028)
+#define SYSCTL_DC8 MMIO32(SYSCTL_BASE + 0x02C)
+#define SYSCTL_SRCR0 MMIO32(SYSCTL_BASE + 0x040)
+#define SYSCTL_SRCR1 MMIO32(SYSCTL_BASE + 0x044)
+#define SYSCTL_SRCR2 MMIO32(SYSCTL_BASE + 0x048)
+#define SYSCTL_RCGC0 MMIO32(SYSCTL_BASE + 0x100)
+#define SYSCTL_RCGC1 MMIO32(SYSCTL_BASE + 0x104)
+#define SYSCTL_RCGC2 MMIO32(SYSCTL_BASE + 0x108)
+#define SYSCTL_SCGC0 MMIO32(SYSCTL_BASE + 0x110)
+#define SYSCTL_SCGC1 MMIO32(SYSCTL_BASE + 0x114)
+#define SYSCTL_SCGC2 MMIO32(SYSCTL_BASE + 0x118)
+#define SYSCTL_DCGC0 MMIO32(SYSCTL_BASE + 0x120)
+#define SYSCTL_DCGC1 MMIO32(SYSCTL_BASE + 0x124)
+#define SYSCTL_DCGC2 MMIO32(SYSCTL_BASE + 0x128)
+#define SYSCTL_DC9 MMIO32(SYSCTL_BASE + 0x190)
+#define SYSCTL_NVMSTAT MMIO32(SYSCTL_BASE + 0x1A0)
+#endif /* LM4F_LEGACY_SYSCTL */
+
+/* =============================================================================
+ * SYSCTL_DID0 values
+ * ---------------------------------------------------------------------------*/
+/** DID0 version */
+#define SYSCTL_DID0_VER_MASK (7 << 28)
+/** Device class */
+#define SYSCTL_DID0_CLASS_MASK (0xFF << 16)
+/** Major revision */
+#define SYSCTL_DID0_MAJOR_MASK (0xFF << 8)
+/** Minor revision */
+#define SYSCTL_DID0_MAJOR_MASK (0xFF << 8)
+
+/* =============================================================================
+ * SYSCTL_DID1 values
+ * ---------------------------------------------------------------------------*/
+/** DID1 version */
+#define SYSCTL_DID1_VER_MASK (0xF << 28)
+/** Family */
+#define SYSCTL_DID1_FAM_MASK (0xF << 24)
+/** Part number */
+#define SYSCTL_DID1_PARTNO_MASK (0xFF << 16)
+/** Pin count */
+#define SYSCTL_DID1_PINCOUNT_MASK (0x7 << 13)
+#define SYSCTL_DID1_PINCOUNT_28P (0x0 << 13)
+#define SYSCTL_DID1_PINCOUNT_48P (0x1 << 13)
+#define SYSCTL_DID1_PINCOUNT_100P (0x2 << 13)
+#define SYSCTL_DID1_PINCOUNT_64P (0x3 << 13)
+#define SYSCTL_DID1_PINCOUNT_144P (0x4 << 13)
+#define SYSCTL_DID1_PINCOUNT_157P (0x5 << 13)
+/** Temperature range */
+#define SYSCTL_DID1_TEMP_MASK (0x7 << 5)
+#define SYSCTL_DID1_TEMP_0_70 (0x0 << 5)
+#define SYSCTL_DID1_TEMP_M40_85 (0x1 << 5)
+#define SYSCTL_DID1_TEMP_M40_105 (0x2 << 5)
+/** Package */
+#define SYSCTL_DID1_PKG_MASK (0x3 << 5)
+#define SYSCTL_DID1_PKG_SOIC (0x0 << 5)
+#define SYSCTL_DID1_PKG_LQFP (0x1 << 5)
+#define SYSCTL_DID1_PKG_BGA (0x2 << 5)
+/** ROHS compliance */
+#define SYSCTL_DID1_ROHS (1 << 2)
+/** Qualification status */
+#define SYSCTL_DID1_QUAL_MASK (3 << 0)
+
+/* =============================================================================
+ * SYSCTL_PBORCTL values
+ * ---------------------------------------------------------------------------*/
+/** BOR interrupt or reset */
+#define SYSCTL_PBORCTL_BORIOR (1 << 1)
+
+/* =============================================================================
+ * SYSCTL_RIS values
+ * ---------------------------------------------------------------------------*/
+/** MOSC Power Up Raw Interrupt Status */
+#define SYSCTL_RIS_MOSCPUPRIS (1 << 8)
+/** USB PLL Lock Raw Interrupt Status */
+#define SYSCTL_RIS_USBPLLLRIS (1 << 7)
+/** PLL Lock Raw Interrupt Status */
+#define SYSCTL_RIS_PLLLRIS (1 << 6)
+/** Main Oscillator Failure Raw Interrupt Status */
+#define SYSCTL_RIS_MOFRIS (1 << 3)
+/** Brown-Out Reset Raw Interrupt Status */
+#define SYSCTL_RIS_BORRIS (1 << 1)
+
+/* =============================================================================
+ * SYSCTL_IMC values
+ * ---------------------------------------------------------------------------*/
+/** MOSC Power Up Raw Interrupt Status */
+#define SYSCTL_IMC_MOSCPUPIM (1 << 8)
+/** USB PLL Lock Raw Interrupt Status */
+#define SYSCTL_IMC_USBPLLLIM (1 << 7)
+/** PLL Lock Raw Interrupt Status */
+#define SYSCTL_IMC_PLLLIM (1 << 6)
+/** Main Oscillator Failure Raw Interrupt Status */
+#define SYSCTL_IMC_MOFIM (1 << 3)
+/** Brown-Out Reset Raw Interrupt Status */
+#define SYSCTL_IMC_BORIM (1 << 1)
+
+/* =============================================================================
+ * SYSCTL_MISC values
+ * ---------------------------------------------------------------------------*/
+/** MOSC Power Up Raw Interrupt Status */
+#define SYSCTL_MISC_MOSCPUPMIS (1 << 8)
+/** USB PLL Lock Raw Interrupt Status */
+#define SYSCTL_MISC_USBPLLLMIS (1 << 7)
+/** PLL Lock Raw Interrupt Status */
+#define SYSCTL_MISC_PLLLMIS (1 << 6)
+/** Main Oscillator Failure Raw Interrupt Status */
+#define SYSCTL_MISC_MOFMIS (1 << 3)
+/** Brown-Out Reset Raw Interrupt Status */
+#define SYSCTL_MISC_BORMIS (1 << 1)
+
+/* =============================================================================
+ * SYSCTL_RESC values
+ * ---------------------------------------------------------------------------*/
+/** MOSC Failure Reset */
+#define SYSCTL_RESC_MOSCFAIL (1 << 18)
+/** Watchdog Timer 1 Reset */
+#define SYSCTL_RESC_WDT1 (1 << 5)
+/** Software Reset */
+#define SYSCTL_RESC_SW (1 << 4)
+/** Watchdog Timer 0 Reset */
+#define SYSCTL_RESC_WDT0 (1 << 3)
+/** Brown-Out Reset */
+#define SYSCTL_RESC_BOR (1 << 2)
+/** Power-On Reset */
+#define SYSCTL_RESC_POR (1 << 1)
+/** External Reset */
+#define SYSCTL_RESC_EXT (1 << 0)
+
+/* =============================================================================
+ * SYSCTL_RCC values
+ * ---------------------------------------------------------------------------*/
+/** Auto Clock Gating */
+#define SYSCTL_RCC_ACG (1 << 27)
+/** System Clock Divisor */
+#define SYSCTL_RCC_SYSDIV_MASK (0xF << 23)
+/** Enable System Clock Divider */
+#define SYSCTL_RCC_USESYSDIV (1 << 22)
+/** Enable PWM Clock Divisor */
+#define SYSCTL_RCC_USEPWMDIV (1 << 20)
+/** PWM Unit Clock Divisor */
+#define SYSCTL_RCC_PWMDIV_MASK (0xF << 17)
+#define SYSCTL_RCC_PWMDIV_2 (0x0 << 17)
+#define SYSCTL_RCC_PWMDIV_4 (0x1 << 17)
+#define SYSCTL_RCC_PWMDIV_8 (0x2 << 17)
+#define SYSCTL_RCC_PWMDIV_16 (0x3 << 17)
+#define SYSCTL_RCC_PWMDIV_32 (0x4 << 17)
+#define SYSCTL_RCC_PWMDIV_64 (0x5 << 17)
+/** PLL Power Down */
+#define SYSCTL_RCC_PWRDN (1 << 13)
+/** PLL Bypass */
+#define SYSCTL_RCC_BYPASS (1 << 11)
+/** Crystal Value */
+#define SYSCTL_RCC_XTAL_MASK (0x1F << 6)
+#define SYSCTL_RCC_XTAL_4M (0x06 << 6)
+#define SYSCTL_RCC_XTAL_4M_096 (0x07 << 6)
+#define SYSCTL_RCC_XTAL_4M_9152 (0x08 << 6)
+#define SYSCTL_RCC_XTAL_5M (0x09 << 6)
+#define SYSCTL_RCC_XTAL_5M_12 (0x0A << 6)
+#define SYSCTL_RCC_XTAL_6M (0x0B << 6)
+#define SYSCTL_RCC_XTAL_6M_144 (0x0C << 6)
+#define SYSCTL_RCC_XTAL_7M_3728 (0x0D << 6)
+#define SYSCTL_RCC_XTAL_8M (0x0E << 6)
+#define SYSCTL_RCC_XTAL_8M_192 (0x0F << 6)
+#define SYSCTL_RCC_XTAL_10M (0x10 << 6)
+#define SYSCTL_RCC_XTAL_12M (0x11 << 6)
+#define SYSCTL_RCC_XTAL_12M_288 (0x12 << 6)
+#define SYSCTL_RCC_XTAL_13M_56 (0x13 << 6)
+#define SYSCTL_RCC_XTAL_14M_31818 (0x14 << 6)
+#define SYSCTL_RCC_XTAL_16M (0x15 << 6)
+#define SYSCTL_RCC_XTAL_16M_384 (0x16 << 6)
+#define SYSCTL_RCC_XTAL_18M (0x17 << 6)
+#define SYSCTL_RCC_XTAL_20M (0x18 << 6)
+#define SYSCTL_RCC_XTAL_24M (0x19 << 6)
+#define SYSCTL_RCC_XTAL_25M (0x1A << 6)
+/** Oscillator Source */
+#define SYSCTL_RCC_OSCSRC_MASK (0x3 << 4)
+#define SYSCTL_RCC_OSCSRC_MOSC (0x0 << 4)
+#define SYSCTL_RCC_OSCSRC_PIOSC (0x1 << 4)
+#define SYSCTL_RCC_OSCSRC_PIOSC_D4 (0x2 << 4)
+#define SYSCTL_RCC_OSCSRC_30K (0x3 << 4)
+/** Precision Internal Oscillator Disable */
+#define SYSCTL_RCC_IOSCDIS (1 << 1)
+/** Main Oscillator Disable */
+#define SYSCTL_RCC_MOSCDIS (1 << 0)
+
+/* =============================================================================
+ * SYSCTL_GPIOHBCTL values
+ * ---------------------------------------------------------------------------*/
+#define SYSCTL_GPIOHBCTL_PORTQ (1 << 14)
+#define SYSCTL_GPIOHBCTL_PORTP (1 << 13)
+#define SYSCTL_GPIOHBCTL_PORTN (1 << 12)
+#define SYSCTL_GPIOHBCTL_PORTM (1 << 11)
+#define SYSCTL_GPIOHBCTL_PORTL (1 << 10)
+#define SYSCTL_GPIOHBCTL_PORTK (1 << 9)
+#define SYSCTL_GPIOHBCTL_PORTJ (1 << 8)
+#define SYSCTL_GPIOHBCTL_PORTH (1 << 7)
+#define SYSCTL_GPIOHBCTL_PORTG (1 << 6)
+#define SYSCTL_GPIOHBCTL_PORTF (1 << 5)
+#define SYSCTL_GPIOHBCTL_PORTE (1 << 4)
+#define SYSCTL_GPIOHBCTL_PORTD (1 << 3)
+#define SYSCTL_GPIOHBCTL_PORTC (1 << 2)
+#define SYSCTL_GPIOHBCTL_PORTB (1 << 1)
+#define SYSCTL_GPIOHBCTL_PORTA (1 << 0)
+
+/* =============================================================================
+ * SYSCTL_RCC2 values
+ * ---------------------------------------------------------------------------*/
+/** RCC2 overides RCC */
+#define SYSCTL_RCC2_USERCC2 (1 << 31)
+/** Divide PLL as 400 MHz vs. 200 MHz */
+#define SYSCTL_RCC2_DIV400 (1 << 30)
+/** Auto Clock Gating */
+#define SYSCTL_RCC2_ACG (1 << 27)
+/** System Clock Divisor 2 */
+#define SYSCTL_RCC2_SYSDIV2_MASK (0x3F << 23)
+/** Additional LSB for SYSDIV2 */
+#define SYSCTL_RCC2_SYSDIV2LSB (1 << 22)
+/** System clock divisor mask when RCC2_DIV400 is set */
+#define SYSCTL_RCC2_SYSDIV400_MASK (0x7F << 22)
+/** Power-Down USB PLL */
+#define SYSCTL_RCC2_USBPWRDN (1 << 14)
+/** PLL Power Down 2 */
+#define SYSCTL_RCC2_PWRDN2 (1 << 13)
+/** PLL Bypass 2 */
+#define SYSCTL_RCC2_BYPASS2 (1 << 11)
+/** Oscillator Source 2 */
+#define SYSCTL_RCC2_OSCSRC2_MASK (0x7 << 4)
+#define SYSCTL_RCC2_OSCSRC2_MOSC (0x0 << 4)
+#define SYSCTL_RCC2_OSCSRC2_PIOSC (0x1 << 4)
+#define SYSCTL_RCC2_OSCSRC2_PIOSC_D4 (0x2 << 4)
+#define SYSCTL_RCC2_OSCSRC2_30K (0x3 << 4)
+#define SYSCTL_RCC2_OSCSRC2_32K768 (0x7 << 4)
+
+/* =============================================================================
+ * SYSCTL_MOSCCTL values
+ * ---------------------------------------------------------------------------*/
+/** No Crystal Connected */
+#define SYSCTL_MOSCCTL_NOXTAL (1 << 2)
+/** MOSC Failure Action */
+#define SYSCTL_MOSCCTL_MOSCIM (1 << 1)
+/** Clock Validation for MOSC */
+#define SYSCTL_MOSCCTL_CVAL (1 << 0)
+
+/* =============================================================================
+ * SYSCTL_DSLPCLKCFG values
+ * ---------------------------------------------------------------------------*/
+/*TODO*/
+
+/* =============================================================================
+ * SYSCTL_SYSPROP values
+ * ---------------------------------------------------------------------------*/
+/** FPU present */
+#define SYSCTL_SYSPROP_FPU (1 << 0)
+
+/* =============================================================================
+ * SYSCTL_PIOSCCAL values
+ * ---------------------------------------------------------------------------*/
+/** Use User Trim Value */
+#define SYSCTL_PIOSCCAL_UTEN (1 << 31)
+/** Start calibration */
+#define SYSCTL_PIOSCCAL_CAL (1 << 9)
+/** Update trim */
+#define SYSCTL_PIOSCCAL_UPDATE (1 << 8)
+/** User Trim Value */
+#define SYSCTL_PIOSCCAL_UT_MASK (0x7F << 0)
+
+/* =============================================================================
+ * SYSCTL_PIOSCSTAT values
+ * ---------------------------------------------------------------------------*/
+/** Default Trim Value */
+#define SYSCTL_PIOSCSTAT_DT_MASK (0x7F << 16)
+/** Calibration result */
+#define SYSCTL_PIOSCSTAT_RESULT_MASK (0x3 << 8)
+/** Calibration Trim Value */
+#define SYSCTL_PIOSCSTAT_CT_MASK (0x7F << 0)
+/* =============================================================================
+ * SYSCTL_PLLFREQ0 values
+ * ---------------------------------------------------------------------------*/
+/** PLL M fractional value */
+#define SYSCTL_PLLFREQ0_MFRAC_MASK (0x3FF << 10)
+/** PLL M integer value */
+#define SYSCTL_PLLFREQ0_MINT_MASK (0x3FF << 0)
+
+/* =============================================================================
+ * SYSCTL_PLLFREQ1 values
+ * ---------------------------------------------------------------------------*/
+/** PLL Q value */
+#define SYSCTL_PLLFREQ1_Q_MASK (0x1F << 8)
+/** PLL N value */
+#define SYSCTL_PLLFREQ1_N_MASK (0x1F << 0)
+
+/* =============================================================================
+ * SYSCTL_PLLSTAT values
+ * ---------------------------------------------------------------------------*/
+/** PLL lock */
+#define SYSCTL_PLLSTAT_LOCK (1 << 0)
+
+/* =============================================================================
+ * Convenience definitions for a readable API
+ * ---------------------------------------------------------------------------*/
+/**
+ * \brief Clock enable definitions
+ *
+ * The definitions are specified in the form
+ * 31:5 register offset from SYSCTL_BASE for the clock register
+ * 4:0 bit offset for the given peripheral
+ *
+ * The names have the form [clock_type]_[periph_type]_[periph_number]
+ * Where clock_type is
+ * RCC for run clock
+ * SCC for sleep clock
+ * DCC for deep-sleep clock
+ */
+enum lm4f_clken {
+ /*
+ * Run clock control
+ */
+ RCC_WD0 = ((uint32_t)&SYSCTL_RCGCWD - SYSCTL_BASE) << 5,
+ RCC_WD1,
+
+ RCC_TIMER0 = ((uint32_t)&SYSCTL_RCGCTIMER - SYSCTL_BASE) << 5,
+ RCC_TIMER1,
+ RCC_TIMER2,
+ RCC_TIMER3,
+ RCC_TIMER4,
+ RCC_TIMER5,
+
+ RCC_GPIOA = ((uint32_t)&SYSCTL_RCGCGPIO - SYSCTL_BASE) << 5,
+ RCC_GPIOB,
+ RCC_GPIOC,
+ RCC_GPIOD,
+ RCC_GPIOE,
+ RCC_GPIOF,
+ RCC_GPIOG,
+ RCC_GPIOH,
+ RCC_GPIOJ,
+ RCC_GPIOK,
+ RCC_GPIOL,
+ RCC_GPIOM,
+ RCC_GPION,
+ RCC_GPIOP,
+ RCC_GPIOQ,
+
+ RCC_DMA = ((uint32_t)&SYSCTL_RCGCDMA - SYSCTL_BASE) << 5,
+
+ RCC_HIB = ((uint32_t)&SYSCTL_RCGCGPIO - SYSCTL_BASE) << 5,
+
+ RCC_UART0 = ((uint32_t)&SYSCTL_RCGCUART - SYSCTL_BASE) << 5,
+ RCC_UART1,
+ RCC_UART2,
+ RCC_UART3,
+ RCC_UART4,
+ RCC_UART5,
+ RCC_UART6,
+ RCC_UART7,
+
+ RCC_SSI0 = ((uint32_t)&SYSCTL_RCGCSSI - SYSCTL_BASE) << 5,
+ RCC_SSI1,
+ RCC_SSI2,
+ RCC_SSI3,
+
+ RCC_I2C0 = ((uint32_t)&SYSCTL_RCGCI2C - SYSCTL_BASE) << 5,
+ RCC_I2C1,
+ RCC_I2C2,
+ RCC_I2C3,
+ RCC_I2C4,
+ RCC_I2C5,
+
+ RCC_USB0 = ((uint32_t)&SYSCTL_RCGCUSB - SYSCTL_BASE) << 5,
+
+ RCC_CAN0 = ((uint32_t)&SYSCTL_RCGCCAN - SYSCTL_BASE) << 5,
+ RCC_CAN1,
+
+ RCC_ADC0 = ((uint32_t)&SYSCTL_RCGCADC - SYSCTL_BASE) << 5,
+ RCC_ADC1,
+
+ RCC_ACMP0 = ((uint32_t)&SYSCTL_RCGCACMP - SYSCTL_BASE) << 5,
+
+ RCC_PWM0 = ((uint32_t)&SYSCTL_RCGCPWM - SYSCTL_BASE) << 5,
+ RCC_PWM1,
+
+ RCC_QEI0 = ((uint32_t)&SYSCTL_RCGCQEI - SYSCTL_BASE) << 5,
+ RCC_QEI1,
+
+ RCC_EEPROM0 = ((uint32_t)&SYSCTL_RCGCEEPROM - SYSCTL_BASE) << 5,
+
+ RCC_WTIMER0 = ((uint32_t)&SYSCTL_RCGCWTIMER - SYSCTL_BASE) << 5,
+ RCC_WTIMER1,
+ RCC_WTIMER2,
+ RCC_WTIMER3,
+ RCC_WTIMER4,
+ RCC_WTIMER5,
+
+
+ /*
+ * Sleep clock control
+ */
+ SCC_WD0 = ((uint32_t)&SYSCTL_SCGCWD - SYSCTL_BASE) << 5,
+ SCC_WD1,
+
+ SCC_TIMER0 = ((uint32_t)&SYSCTL_SCGCTIMER - SYSCTL_BASE) << 5,
+ SCC_TIMER1,
+ SCC_TIMER2,
+ SCC_TIMER3,
+ SCC_TIMER4,
+ SCC_TIMER5,
+
+ SCC_GPIOA = ((uint32_t)&SYSCTL_SCGCGPIO - SYSCTL_BASE) << 5,
+ SCC_GPIOB,
+ SCC_GPIOC,
+ SCC_GPIOD,
+ SCC_GPIOE,
+ SCC_GPIOF,
+ SCC_GPIOG,
+ SCC_GPIOH,
+ SCC_GPIOJ,
+ SCC_GPIOK,
+ SCC_GPIOL,
+ SCC_GPIOM,
+ SCC_GPION,
+ SCC_GPIOP,
+ SCC_GPIOQ,
+
+ SCC_DMA = ((uint32_t)&SYSCTL_SCGCDMA - SYSCTL_BASE) << 5,
+
+ SCC_HIB = ((uint32_t)&SYSCTL_SCGCGPIO - SYSCTL_BASE) << 5,
+
+ SCC_UART0 = ((uint32_t)&SYSCTL_SCGCUART - SYSCTL_BASE) << 5,
+ SCC_UART1,
+ SCC_UART2,
+ SCC_UART3,
+ SCC_UART4,
+ SCC_UART5,
+ SCC_UART6,
+ SCC_UART7,
+
+ SCC_SSI0 = ((uint32_t)&SYSCTL_SCGCSSI - SYSCTL_BASE) << 5,
+ SCC_SSI1,
+ SCC_SSI2,
+ SCC_SSI3,
+
+ SCC_I2C0 = ((uint32_t)&SYSCTL_SCGCI2C - SYSCTL_BASE) << 5,
+ SCC_I2C1,
+ SCC_I2C2,
+ SCC_I2C3,
+ SCC_I2C4,
+ SCC_I2C5,
+
+ SCC_USB0 = ((uint32_t)&SYSCTL_SCGCUSB - SYSCTL_BASE) << 5,
+
+ SCC_CAN0 = ((uint32_t)&SYSCTL_SCGCCAN - SYSCTL_BASE) << 5,
+ SCC_CAN1,
+
+ SCC_ADC0 = ((uint32_t)&SYSCTL_SCGCADC - SYSCTL_BASE) << 5,
+ SCC_ADC1,
+
+ SCC_ACMP0 = ((uint32_t)&SYSCTL_SCGCACMP - SYSCTL_BASE) << 5,
+
+ SCC_PWM0 = ((uint32_t)&SYSCTL_SCGCPWM - SYSCTL_BASE) << 5,
+ SCC_PWM1,
+
+ SCC_QEI0 = ((uint32_t)&SYSCTL_SCGCQEI - SYSCTL_BASE) << 5,
+ SCC_QEI1,
+
+ SCC_EEPROM0 = ((uint32_t)&SYSCTL_SCGCEEPROM - SYSCTL_BASE) << 5,
+
+ SCC_WTIMER0 = ((uint32_t)&SYSCTL_SCGCWTIMER - SYSCTL_BASE) << 5,
+ SCC_WTIMER1,
+ SCC_WTIMER2,
+ SCC_WTIMER3,
+ SCC_WTIMER4,
+ SCC_WTIMER5,
+
+ /*
+ * Deep-sleep clock control
+ */
+ DCC_WD0 = ((uint32_t)&SYSCTL_DCGCWD - SYSCTL_BASE) << 5,
+ DCC_WD1,
+
+ DCC_TIMER0 = ((uint32_t)&SYSCTL_DCGCTIMER - SYSCTL_BASE) << 5,
+ DCC_TIMER1,
+ DCC_TIMER2,
+ DCC_TIMER3,
+ DCC_TIMER4,
+ DCC_TIMER5,
+
+ DCC_GPIOA = ((uint32_t)&SYSCTL_DCGCGPIO - SYSCTL_BASE) << 5,
+ DCC_GPIOB,
+ DCC_GPIOC,
+ DCC_GPIOD,
+ DCC_GPIOE,
+ DCC_GPIOF,
+ DCC_GPIOG,
+ DCC_GPIOH,
+ DCC_GPIOJ,
+ DCC_GPIOK,
+ DCC_GPIOL,
+ DCC_GPIOM,
+ DCC_GPION,
+ DCC_GPIOP,
+ DCC_GPIOQ,
+
+ DCC_DMA = ((uint32_t)&SYSCTL_DCGCDMA - SYSCTL_BASE) << 5,
+
+ DCC_HIB = ((uint32_t)&SYSCTL_DCGCGPIO - SYSCTL_BASE) << 5,
+
+ DCC_UART0 = ((uint32_t)&SYSCTL_DCGCUART - SYSCTL_BASE) << 5,
+ DCC_UART1,
+ DCC_UART2,
+ DCC_UART3,
+ DCC_UART4,
+ DCC_UART5,
+ DCC_UART6,
+ DCC_UART7,
+
+ DCC_SSI0 = ((uint32_t)&SYSCTL_DCGCSSI - SYSCTL_BASE) << 5,
+ DCC_SSI1,
+ DCC_SSI2,
+ DCC_SSI3,
+
+ DCC_I2C0 = ((uint32_t)&SYSCTL_DCGCI2C - SYSCTL_BASE) << 5,
+ DCC_I2C1,
+ DCC_I2C2,
+ DCC_I2C3,
+ DCC_I2C4,
+ DCC_I2C5,
+
+ DCC_USB0 = ((uint32_t)&SYSCTL_DCGCUSB - SYSCTL_BASE) << 5,
+
+ DCC_CAN0 = ((uint32_t)&SYSCTL_DCGCCAN - SYSCTL_BASE) << 5,
+ DCC_CAN1,
+
+ DCC_ADC0 = ((uint32_t)&SYSCTL_DCGCADC - SYSCTL_BASE) << 5,
+ DCC_ADC1,
+
+ DCC_ACMP0 = ((uint32_t)&SYSCTL_DCGCACMP - SYSCTL_BASE) << 5,
+
+ DCC_PWM0 = ((uint32_t)&SYSCTL_DCGCPWM - SYSCTL_BASE) << 5,
+ DCC_PWM1,
+
+ DCC_QEI0 = ((uint32_t)&SYSCTL_DCGCQEI - SYSCTL_BASE) << 5,
+ DCC_QEI1,
+
+ DCC_EEPROM0 = ((uint32_t)&SYSCTL_DCGCEEPROM - SYSCTL_BASE) << 5,
+
+ DCC_WTIMER0 = ((uint32_t)&SYSCTL_DCGCWTIMER - SYSCTL_BASE) << 5,
+ DCC_WTIMER1,
+ DCC_WTIMER2,
+ DCC_WTIMER3,
+ DCC_WTIMER4,
+ DCC_WTIMER5,
+
+};
+
+/* ============================================================================
+ * Function prototypes
+ * --------------------------------------------------------------------------*/
+BEGIN_DECLS
+
+void periph_clock_enable(enum lm4f_clken periph);
+void periph_clock_disable(enum lm4f_clken periph);
+
+END_DECLS
+
+/**@}*/
+
+#endif /* LM4F_SYSTEMCONTROL_H */
+
diff --git a/libopencm3/include/libopencm3/lm4f/uart.h b/libopencm3/include/libopencm3/lm4f/uart.h
new file mode 100644
index 0000000..5bd7e37
--- /dev/null
+++ b/libopencm3/include/libopencm3/lm4f/uart.h
@@ -0,0 +1,550 @@
+/** @defgroup uart_defines UART Control
+ *
+ * @brief <b>Defined Constants and Types for the LM4F UART Control</b>
+ *
+ * @ingroup LM4Fxx_defines
+ *
+ * @version 1.0.0
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2013
+ * Alexandru Gagniuc <mr.nuke.me@gmail.com>
+ *
+ * @date 07 May 2013
+ *
+ * LGPL License Terms @ref lgpl_license
+ */
+
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@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_LM4F_UART_H
+#define LIBOPENCM3_LM4F_UART_H
+
+/**@{*/
+
+#include <libopencm3/lm4f/memorymap.h>
+#include <libopencm3/cm3/common.h>
+
+/* =============================================================================
+ * Convenience macros
+ * ---------------------------------------------------------------------------*/
+/** @defgroup uart_reg_base UART register base addresses
+ * @{*/
+#define UART0 UART0_BASE
+#define UART1 UART1_BASE
+#define UART2 UART2_BASE
+#define UART3 UART3_BASE
+#define UART4 UART4_BASE
+#define UART5 UART5_BASE
+#define UART6 UART6_BASE
+#define UART7 UART7_BASE
+/** @} */
+
+/* =============================================================================
+ * UART registers
+ * ---------------------------------------------------------------------------*/
+
+/* UART data register */
+#define UART_DR(uart_base) MMIO32(uart_base + 0x00)
+
+/* UART Receive Status/Error Clear register */
+#define UART_RSR(uart_base) MMIO32(uart_base + 0x04)
+#define UART_ECR(uart_base) MMIO32(uart_base + 0x04)
+
+/* UART Flag register */
+#define UART_FR(uart_base) MMIO32(uart_base + 0x18)
+
+/* UART IrDA Low-Power register */
+#define UART_ILPR(uart_base) MMIO32(uart_base + 0x20)
+
+/* UART Integer baudrate divisor */
+#define UART_IBRD(uart_base) MMIO32(uart_base + 0x24)
+
+/* UART Fractional baudrate divisor */
+#define UART_FBRD(uart_base) MMIO32(uart_base + 0x28)
+
+/* UART Line control */
+#define UART_LCRH(uart_base) MMIO32(uart_base + 0x2C)
+
+/* UART Control */
+#define UART_CTL(uart_base) MMIO32(uart_base + 0x30)
+
+/* UART Interrupt FIFO level select */
+#define UART_IFLS(uart_base) MMIO32(uart_base + 0x34)
+
+/* UART Interrupt mask */
+#define UART_IM(uart_base) MMIO32(uart_base + 0x38)
+
+/* UART Raw interrupt status */
+#define UART_RIS(uart_base) MMIO32(uart_base + 0x3C)
+
+/* UART Masked Interrupt status */
+#define UART_MIS(uart_base) MMIO32(uart_base + 0x40)
+
+/* UART Interrupt Clear */
+#define UART_ICR(uart_base) MMIO32(uart_base + 0x44)
+
+/* UART DMA control */
+#define UART_DMACTL(uart_base) MMIO32(uart_base + 0x48)
+
+/* UART LIN control */
+#define UART_LCTL(uart_base) MMIO32(uart_base + 0x90)
+
+/* UART LIN snap shot */
+#define UART_LSS(uart_base) MMIO32(uart_base + 0x94)
+
+/* UART LIN timer */
+#define UART_LTIM(uart_base) MMIO32(uart_base + 0x98)
+
+/* UART 9-Bit self address */
+#define UART_9BITADDR(uart_base) MMIO32(uart_base + 0xA4)
+
+/* UART 9-Bit self address mask */
+#define UART_9BITAMASK(uart_base) MMIO32(uart_base + 0xA8)
+
+/* UART Peripheral properties */
+#define UART_PP(uart_base) MMIO32(uart_base + 0xFC0)
+
+/* UART Clock configuration */
+#define UART_CC(uart_base) MMIO32(uart_base + 0xFC8)
+
+/* UART Peripheral Identification 4 */
+#define UART_PERIPH_ID4(uart_base) MMIO32(uart_base + 0xFD0)
+
+/* UART Peripheral Identification 5 */
+#define UART_PERIPH_ID5(uart_base) MMIO32(uart_base + 0xFD4)
+
+/* UART Peripheral Identification 6 */
+#define UART_PERIPH_ID6(uart_base) MMIO32(uart_base + 0xFD8)
+
+/* UART Peripheral Identification 7 */
+#define UART_PERIPH_ID7(uart_base) MMIO32(uart_base + 0xFDC)
+
+/* UART Peripheral Identification 0 */
+#define UART_PERIPH_ID0(uart_base) MMIO32(uart_base + 0xFE0)
+
+/* UART Peripheral Identification 1 */
+#define UART_PERIPH_ID1(uart_base) MMIO32(uart_base + 0xFE4)
+
+/* UART Peripheral Identification 2 */
+#define UART_PERIPH_ID2(uart_base) MMIO32(uart_base + 0xFE8)
+
+/* UART Peripheral Identification 3 */
+#define UART_PERIPH_ID3(uart_base) MMIO32(uart_base + 0xFEC)
+
+/* UART PrimeCell Identification 0 */
+#define UART_PCELL_ID0(uart_base) MMIO32(uart_base + 0xFF0)
+
+/* UART PrimeCell Identification 1 */
+#define UART_PCELL_ID1(uart_base) MMIO32(uart_base + 0xFF4)
+
+/* UART PrimeCell Identification 2 */
+#define UART_PCELL_ID2(uart_base) MMIO32(uart_base + 0xFF8)
+
+/* UART PrimeCell Identification 3 */
+#define UART_PCELL_ID3(uart_base) MMIO32(uart_base + 0xFFC)
+
+
+/* =============================================================================
+ * UART_DR values
+ * ---------------------------------------------------------------------------*/
+/** Overrun Error */
+#define UART_DR_OE (1 << 11)
+/** Break Error */
+#define UART_DR_BE (1 << 10)
+/** Parity Error */
+#define UART_DR_PE (1 << 9)
+/** Framing Error */
+#define UART_DR_FE (1 << 8)
+/** Data transmitted or received */
+#define UART_DR_DATA_MASK (0xFF << 0)
+
+/* =============================================================================
+ * Readonly UART_RSR values
+ * ---------------------------------------------------------------------------*/
+/** Overrun Error */
+#define UART_RSR_OE (1 << 3)
+/** Break Error */
+#define UART_RSR_BE (1 << 2)
+/** Parity Error */
+#define UART_RSR_PE (1 << 1)
+/** Framing Error */
+#define UART_RSR_FE (1 << 0)
+
+/* =============================================================================
+ * UART_FR values
+ * ---------------------------------------------------------------------------*/
+/** Tx FIFO empty */
+#define UART_FR_TXFE (1 << 7)
+/** Rx FIFO full */
+#define UART_FR_RXFF (1 << 6)
+/** Tx FIFO full */
+#define UART_FR_TXFF (1 << 5)
+/** Rx FIFO empty */
+#define UART_FR_RXFE (1 << 4)
+/** UART Busy */
+#define UART_FR_BUSY (1 << 3)
+/** Clear To Send */
+#define UART_FR_CTS (1 << 0)
+
+/* =============================================================================
+ * UART_LCRH values
+ * ---------------------------------------------------------------------------*/
+/** Stick parity select */
+#define UART_LCRH_SPS (1 << 7)
+/** Word length */
+#define UART_LCRH_WLEN_MASK (3 << 5)
+#define UART_LCRH_WLEN_5 (0 << 5)
+#define UART_LCRH_WLEN_6 (1 << 5)
+#define UART_LCRH_WLEN_7 (2 << 5)
+#define UART_LCRH_WLEN_8 (3 << 5)
+/** Enable FIFOs */
+#define UART_LCRH_FEN (1 << 4)
+/** Two stop bits select */
+#define UART_LCRH_STP2 (1 << 3)
+/** Even parity select */
+#define UART_LCRH_EPS (1 << 2)
+/** Parity enable */
+#define UART_LCRH_PEN (1 << 1)
+/** Send break */
+#define UART_LCRH_BRK (1 << 0)
+
+/* =============================================================================
+ * UART_CTL values
+ * ---------------------------------------------------------------------------*/
+/** Enable Clear To Send */
+#define UART_CTL_CTSEN (1 << 15)
+/** Enable Request To Send */
+#define UART_CTL_RTSEN (1 << 14)
+/** Request To Send */
+#define UART_CTL_RTS (1 << 11)
+/** Data terminal ready */
+#define UART_CTL_DTR (1 << 10)
+/** Rx Enable */
+#define UART_CTL_RXE (1 << 9)
+/** Tx Enable */
+#define UART_CTL_TXE (1 << 8)
+/** Loop back enable */
+#define UART_CTL_LBE (1 << 7)
+/** LIN mode enable */
+#define UART_CTL_LIN (1 << 6)
+/** High speed Enable */
+#define UART_CTL_HSE (1 << 5)
+/** End of transmission */
+#define UART_CTL_EOT (1 << 4)
+/** ISO 7816 Smart Card support */
+#define UART_CTL_SMART (1 << 3)
+/** SIR low-power mode */
+#define UART_CTL_SIRLIP (1 << 2)
+/** SIR enable */
+#define UART_CTL_SIREN (1 << 1)
+/** UART enable */
+#define UART_CTL_UARTEN (1 << 0)
+
+/* =============================================================================
+ * UART_IFLS values
+ * ---------------------------------------------------------------------------*/
+/** UART Rx interrupt FIFO level select */
+#define UART_IFLS_RXIFLSEL_MASK (7 << 3)
+#define UART_IFLS_RXIFLSEL_1_8 (0 << 3)
+#define UART_IFLS_RXIFLSEL_1_4 (1 << 3)
+#define UART_IFLS_RXIFLSEL_1_2 (2 << 3)
+#define UART_IFLS_RXIFLSEL_3_4 (3 << 3)
+#define UART_IFLS_RXIFLSEL_7_8 (4 << 3)
+/** UART Tx interrupt FIFO level select */
+#define UART_IFLS_TXIFLSEL_MASK (7 << 0)
+#define UART_IFLS_TXIFLSEL_7_8 (0 << 0)
+#define UART_IFLS_TXIFLSEL_3_4 (1 << 0)
+#define UART_IFLS_TXIFLSEL_1_2 (2 << 0)
+#define UART_IFLS_TXIFLSEL_1_4 (3 << 0)
+#define UART_IFLS_TXIFLSEL_1_8 (4 << 0)
+
+/* =============================================================================
+ * UART interrupt mask values
+ *
+ * These are interchangeable across UART_IM, UART_RIS, UART_MIS, and UART_ICR
+ * registers.
+ * ---------------------------------------------------------------------------*/
+/** LIN mode edge 5 interrupt mask */
+#define UART_IM_LME5IM (1 << 15)
+/** LIN mode edge 1 interrupt mask */
+#define UART_IM_LME1IM (1 << 14)
+/** LIN mode sync break interrupt mask */
+#define UART_IM_LMSBIM (1 << 13)
+/** 9-bit mode interrupt mask */
+#define UART_IM_9BITIM (1 << 12)
+/** Overrun error interrupt mask */
+#define UART_IM_OEIM (1 << 10)
+/** Break error interrupt mask */
+#define UART_IM_BEIM (1 << 9)
+/** Parity error interrupt mask */
+#define UART_IM_PEIM (1 << 8)
+/** Framing error interrupt mask */
+#define UART_IM_FEIM (1 << 7)
+/** Receive time-out interrupt mask */
+#define UART_IM_RTIM (1 << 6)
+/** Transmit interrupt mask */
+#define UART_IM_TXIM (1 << 5)
+/** Receive interrupt mask */
+#define UART_IM_RXIM (1 << 4)
+/** Data Set Ready modem interrupt mask */
+#define UART_IM_DSRIM (1 << 3)
+/** Data Carrier Detect modem interrupt mask */
+#define UART_IM_DCDIM (1 << 2)
+/** Clear To Send modem interrupt mask */
+#define UART_IM_CTSIM (1 << 1)
+/** Ring Indicator modem interrupt mask */
+#define UART_IM_RIIM (1 << 0)
+
+/* =============================================================================
+ * UART_DMACTL values
+ * ---------------------------------------------------------------------------*/
+/** DMA on error */
+#define UART_DMACTL_DMAERR (1 << 2)
+/** Transmit DMA enable */
+#define UART_DMACTL_TXDMAE (1 << 1)
+/** Recieve DMA enable */
+#define UART_DMACTL_RXDMAE (1 << 0)
+
+/* =============================================================================
+ * UART_LCTL values
+ * ---------------------------------------------------------------------------*/
+/** Sync break length */
+#define UART_LCTL_BLEN_MASK (3 << 4)
+#define UART_LCTL_BLEN_16T (3 << 4)
+#define UART_LCTL_BLEN_15T (2 << 4)
+#define UART_LCTL_BLEN_14T (1 << 4)
+#define UART_LCTL_BLEN_13T (0 << 4)
+/** LIN master enable */
+#define UART_LCTL_MASTER (1 << 0)
+
+/* =============================================================================
+ * UART_9BITADDR values
+ * ---------------------------------------------------------------------------*/
+/** Enable 9-bit mode */
+#define UART_UART_9BITADDR_9BITEN (1 << 15)
+/** Self-address for 9-bit mode */
+#define UART_UART_9BITADDR_ADDR_MASK (0xFF << 0)
+
+/* =============================================================================
+ * UART_PP values
+ * ---------------------------------------------------------------------------*/
+/** 9-bit support */
+#define UART_UART_PP_NB (1 << 1)
+/** Smart Card support */
+#define UART_UART_PP_SC (1 << 0)
+
+/* =============================================================================
+ * UART_CC values
+ * ---------------------------------------------------------------------------*/
+/** UART baud clock source */
+#define UART_CC_CS_MASK (0xF << 0)
+#define UART_CC_CS_SYSCLK (0x0 << 0)
+#define UART_CC_CS_PIOSC (0x5 << 0)
+
+/* =============================================================================
+ * Convenience enums
+ * ---------------------------------------------------------------------------*/
+enum uart_parity {
+ UART_PARITY_NONE,
+ UART_PARITY_ODD,
+ UART_PARITY_EVEN,
+ UART_PARITY_STICK_0,
+ UART_PARITY_STICK_1,
+};
+
+enum uart_flowctl {
+ UART_FLOWCTL_NONE,
+ UART_FLOWCTL_RTS,
+ UART_FLOWCTL_CTS,
+ UART_FLOWCTL_RTS_CTS,
+};
+
+/**
+ * \brief UART interrupt masks
+ *
+ * These masks can be OR'ed together to specify more than one interrupt. For
+ * example, (UART_INT_TXIM | UART_INT_TXIM) specifies both Rx and Tx Interrupt.
+ */
+enum uart_interrupt_flag {
+
+ UART_INT_LME5 = UART_IM_LME5IM,
+ UART_INT_LME1 = UART_IM_LME1IM,
+ UART_INT_LMSB = UART_IM_LMSBIM,
+ UART_INT_9BIT = UART_IM_9BITIM,
+ UART_INT_OE = UART_IM_OEIM,
+ UART_INT_BE = UART_IM_BEIM,
+ UART_INT_PE = UART_IM_PEIM,
+ UART_INT_FE = UART_IM_FEIM,
+ UART_INT_RT = UART_IM_RTIM,
+ UART_INT_TX = UART_IM_TXIM,
+ UART_INT_RX = UART_IM_RXIM,
+ UART_INT_DSR = UART_IM_DSRIM,
+ UART_INT_DCD = UART_IM_DCDIM,
+ UART_INT_CTS = UART_IM_CTSIM,
+ UART_INT_RI = UART_IM_RIIM,
+};
+
+/**
+ * \brief UART RX FIFO interrupt trigger levels
+ *
+ * The levels indicate how full the FIFO should be before an interrupt is
+ * generated. UART_FIFO_RX_TRIG_3_4 means that an interrupt is triggered when
+ * the FIFO is 3/4 full. As the FIFO is 8 elements deep, 1/8 is equal to being
+ * triggered by a single character.
+ */
+enum uart_fifo_rx_trigger_level {
+ UART_FIFO_RX_TRIG_1_8 = UART_IFLS_RXIFLSEL_1_8,
+ UART_FIFO_RX_TRIG_1_4 = UART_IFLS_RXIFLSEL_1_4,
+ UART_FIFO_RX_TRIG_1_2 = UART_IFLS_RXIFLSEL_1_2,
+ UART_FIFO_RX_TRIG_3_4 = UART_IFLS_RXIFLSEL_3_4,
+ UART_FIFO_RX_TRIG_7_8 = UART_IFLS_RXIFLSEL_7_8
+};
+
+/**
+ * \brief UART TX FIFO interrupt trigger levels
+ *
+ * The levels indicate how empty the FIFO should be before an interrupt is
+ * generated. Note that this indicates the emptiness of the FIFO and not the
+ * fullness. This is somewhat confusing, but it follows the wording of the
+ * LM4F120H5QR datasheet.
+ *
+ * UART_FIFO_TX_TRIG_3_4 means that an interrupt is triggered when the FIFO is
+ * 3/4 empty. As the FIFO is 8 elements deep, 7/8 is equal to being triggered
+ * by a single character.
+ */
+enum uart_fifo_tx_trigger_level {
+ UART_FIFO_TX_TRIG_7_8 = UART_IFLS_TXIFLSEL_7_8,
+ UART_FIFO_TX_TRIG_3_4 = UART_IFLS_TXIFLSEL_3_4,
+ UART_FIFO_TX_TRIG_1_2 = UART_IFLS_TXIFLSEL_1_2,
+ UART_FIFO_TX_TRIG_1_4 = UART_IFLS_TXIFLSEL_1_4,
+ UART_FIFO_TX_TRIG_1_8 = UART_IFLS_TXIFLSEL_1_8
+};
+
+/* =============================================================================
+ * Function prototypes
+ * ---------------------------------------------------------------------------*/
+BEGIN_DECLS
+
+void uart_set_baudrate(uint32_t uart, uint32_t baud);
+void uart_set_databits(uint32_t uart, uint8_t databits);
+void uart_set_stopbits(uint32_t uart, uint8_t stopbits);
+void uart_set_parity(uint32_t uart, enum uart_parity parity);
+void uart_set_mode(uint32_t uart, uint32_t mode);
+void uart_set_flow_control(uint32_t uart, enum uart_flowctl flow);
+void uart_enable(uint32_t uart);
+void uart_disable(uint32_t uart);
+void uart_clock_from_piosc(uint32_t uart);
+void uart_clock_from_sysclk(uint32_t uart);
+
+void uart_send(uint32_t uart, uint16_t data);
+uint16_t uart_recv(uint32_t uart);
+void uart_wait_send_ready(uint32_t uart);
+void uart_wait_recv_ready(uint32_t uart);
+void uart_send_blocking(uint32_t uart, uint16_t data);
+uint16_t uart_recv_blocking(uint32_t uart);
+
+void uart_enable_rx_dma(uint32_t uart);
+void uart_disable_rx_dma(uint32_t uart);
+void uart_enable_tx_dma(uint32_t uart);
+void uart_disable_tx_dma(uint32_t uart);
+
+void uart_enable_fifo(uint32_t uart);
+void uart_disable_fifo(uint32_t uart);
+void uart_set_fifo_trigger_levels(uint32_t uart,
+ enum uart_fifo_rx_trigger_level rx_level,
+ enum uart_fifo_tx_trigger_level tx_level);
+
+/* We inline FIFO full/empty checks as they are intended to be called from ISRs
+ * */
+/** @ingroup uart_fifo
+ * @{
+ * \brief Determine if the TX fifo is full
+ *
+ * @param[in] uart UART block register address base @ref uart_reg_base
+ */
+static inline
+bool uart_is_tx_fifo_full(uint32_t uart)
+{
+ return UART_FR(uart) & UART_FR_TXFF;
+}
+
+
+/**
+ * \brief Determine if the TX fifo is empty
+ *
+ * @param[in] uart UART block register address base @ref uart_reg_base
+ */
+static inline
+bool uart_is_tx_fifo_empty(uint32_t uart)
+{
+ return UART_FR(uart) & UART_FR_TXFE;
+}
+
+/**
+ * \brief Determine if the RX fifo is full
+ *
+ * @param[in] uart UART block register address base @ref uart_reg_base
+ */
+static inline
+bool uart_is_rx_fifo_full(uint32_t uart)
+{
+ return UART_FR(uart) & UART_FR_RXFF;
+}
+
+/**
+ * \brief Determine if the RX fifo is empty
+ *
+ * @param[in] uart UART block register address base @ref uart_reg_base
+ */
+static inline
+bool uart_is_rx_fifo_empty(uint32_t uart)
+{
+ return UART_FR(uart) & UART_FR_RXFE;
+}
+/**@}*/
+
+void uart_enable_interrupts(uint32_t uart, enum uart_interrupt_flag ints);
+void uart_disable_interrupts(uint32_t uart, enum uart_interrupt_flag ints);
+void uart_enable_rx_interrupt(uint32_t uart);
+void uart_disable_rx_interrupt(uint32_t uart);
+void uart_enable_tx_interrupt(uint32_t uart);
+void uart_disable_tx_interrupt(uint32_t uart);
+void uart_clear_interrupt_flag(uint32_t uart, enum uart_interrupt_flag ints);
+
+/* Let's keep this one inlined. It's designed to be used in ISRs */
+/** @ingroup uart_irq
+ * @{
+ * \brief Determine if interrupt is generated by the given source
+ *
+ * @param[in] uart UART block register address base @ref uart_reg_base
+ * @param[in] source source to check.
+ */
+static inline
+bool uart_is_interrupt_source(uint32_t uart, enum uart_interrupt_flag source)
+{
+ return UART_MIS(uart) & source;
+}
+/**@}*/
+
+END_DECLS
+
+/**@}*/
+
+#endif /* LIBOPENCM3_LM4F_UART_H */
diff --git a/libopencm3/include/libopencm3/lm4f/usb.h b/libopencm3/include/libopencm3/lm4f/usb.h
new file mode 100644
index 0000000..f22d799
--- /dev/null
+++ b/libopencm3/include/libopencm3/lm4f/usb.h
@@ -0,0 +1,422 @@
+/*
+ * This file is part of the libopencm3 project.
+ *
+ * Copyright (C) 2012 Alexandru Gagniuc <mr.nuke.me@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/>.
+ */
+
+/** @defgroup usb_defines USB Controller
+ *
+ * @brief <b>Defined Constants and Types for the LM4F USB Controller</b>
+ *
+ * @ingroup LM4Fxx_defines
+ *
+ * @version 1.0.0
+ *
+ * @author @htmlonly &copy; @endhtmlonly 2013 Alexandru Gagniuc <mr.nuke.me@gmail.com>
+ *
+ * @date 15 May 2013
+ *
+ * LGPL License Terms @ref lgpl_license
+ */
+
+
+#ifndef LIBOPENCM3_LM4F_USB_H
+#define LIBOPENCM3_LM4F_USB_H
+
+/**@{*/
+
+#include <libopencm3/lm4f/memorymap.h>
+#include <libopencm3/cm3/common.h>
+
+/* ============================================================================
+ * USB registers
+ * --------------------------------------------------------------------------*/
+
+/* USB Device Functional Address */
+#define USB_FADDR MMIO8(USB_BASE + 0x00)
+
+/* USB Power */
+#define USB_POWER MMIO8(USB_BASE + 0x01)
+
+/* USB Transmit Interrupt Status */
+#define USB_TXIS MMIO16(USB_BASE + 0x02)
+
+/* USB Receive Interrupt Status */
+#define USB_RXIS MMIO16(USB_BASE + 0x04)
+
+/* USB Transmit Interrupt Enable */
+#define USB_TXIE MMIO16(USB_BASE + 0x06)
+
+/* USB Receive Interrupt Enable */
+#define USB_RXIE MMIO16(USB_BASE + 0x08)
+
+/* USB General Interrupt Status */
+#define USB_IS MMIO8(USB_BASE + 0x0A)
+
+/* USB Interrupt Enable */
+#define USB_IE MMIO8(USB_BASE + 0x0B)
+
+/* USB Frame Value */
+#define USB_FRAME MMIO16(USB_BASE + 0x0C)
+
+/* USB Endpoint Index */
+#define USB_EPIDX MMIO8(USB_BASE + 0x0E)
+
+/* USB Test Mode */
+#define USB_TEST MMIO8(USB_BASE + 0x0F)
+
+/* USB FIFO Endpoint [0-7] */
+#define USB_FIFO8(n) MMIO8(USB_BASE + 0x20 + n*0x04)
+#define USB_FIFO16(n) MMIO16(USB_BASE + 0x20 + n*0x04)
+#define USB_FIFO32(n) MMIO32(USB_BASE + 0x20 + n*0x04)
+
+/* USB Transmit Dynamic FIFO Sizing */
+#define USB_TXFIFOSZ MMIO8(USB_BASE + 0x62)
+
+/* USB Receive Dynamic FIFO Sizing */
+#define USB_RXFIFOSZ MMIO8(USB_BASE + 0x63)
+
+/* USB Transmit FIFO Start Address */
+#define USB_TXFIFOADD MMIO16(USB_BASE + 0x64)
+
+/* USB Receive FIFO Start Address */
+#define USB_RXFIFOADD MMIO16(USB_BASE + 0x66)
+
+/* USB Connect Timing */
+#define USB_CONTIM MMIO8(USB_BASE + 0x7A)
+
+/* USB Full-Speed Last Transaction to End of Frame Timing */
+#define USB_FSEOF MMIO8(USB_BASE + 0x7D)
+
+/* USB Low-Speed Last Transaction to End of Frame Timing */
+#define USB_LSEOF MMIO8(USB_BASE + 0x7E)
+
+/* USB Control and Status Endpoint 0 Low */
+#define USB_CSRL0 MMIO8(USB_BASE + 0x102)
+
+/* USB Control and Status Endpoint 0 High */
+#define USB_CSRH0 MMIO8(USB_BASE + 0x103)
+
+/* USB Receive Byte Count Endpoint 0 */
+#define USB_COUNT0 MMIO8(USB_BASE + 0x108)
+
+/* USB Maximum Transmit Data Endpoint [1-7] */
+#define USB_TXMAXP(n) MMIO16(USB_BASE + 0x100 + n*0x10)
+
+/* USB Transmit Control and Status Endpoint [1-7] Low */
+#define USB_TXCSRL(n) MMIO8(USB_BASE + 0x102 + n*0x10)
+
+/* USB Transmit Control and Status Endpoint [1-7] High */
+#define USB_TXCSRH(n) MMIO8(USB_BASE + 0x103 + n*0x10)
+
+/* USB Maximum Receive Data Endpoint [1-7] */
+#define USB_RXMAXP(n) MMIO16(USB_BASE + 0x104 + n*0x10)
+
+/* USB Receive Control and Status Endpoint [1-7] Low */
+#define USB_RXCSRL(n) MMIO8(USB_BASE + 0x106 + n*0x10)
+
+/* USB Receive Control and Status Endpoint [1-7] High */
+#define USB_RXCSRH(n) MMIO8(USB_BASE + 0x107 + n*0x10)
+
+/* USB Receive Byte Count Endpoint [1-7] */
+#define USB_RXCOUNT(n) MMIO16(USB_BASE + 0x108 + n*0x10)
+
+/* USB Receive Double Packet Buffer Disable */
+#define USB_RXDPKTBUFDIS MMIO16(USB_BASE + 0x340)
+
+/* USB Transmit Double Packet Buffer Disable */
+#define USB_TXDPKTBUFDIS MMIO16(USB_BASE + 0x342)
+
+/* USB Device RESUME Raw Interrupt Status */
+#define USB_DRRIS MMIO32(USB_BASE + 0x410)
+
+/* USB Device RESUME Interrupt Mask */
+#define USB_DRIM MMIO32(USB_BASE + 0x414)
+
+/* USB Device RESUME Interrupt Status and Clear */
+#define USB_DRISC MMIO32(USB_BASE + 0x418)
+
+/* USB DMA Select */
+#define USB_DMASEL MMIO32(USB_BASE + 0x450)
+
+/* USB Peripheral Properties */
+#define USB_PP MMIO32(USB_BASE + 0xFC0)
+
+
+/* =============================================================================
+ * USB_FADDR values
+ * ---------------------------------------------------------------------------*/
+/** Function Address */
+#define USB_FADDR_FUNCADDR_MASK (0x3f << 0)
+
+/* =============================================================================
+ * USB_POWER values
+ * ---------------------------------------------------------------------------*/
+/** Isochronous Update */
+#define USB_POWER_ISOUP (1 << 7)
+/** Soft Connect/Disconnect */
+#define USB_POWER_SOFTCONN (1 << 6)
+/** RESET signaling */
+#define USB_POWER_RESET (1 << 3)
+/** RESUME signaling */
+#define USB_POWER_RESUME (1 << 2)
+/** SUSPEND mode */
+#define USB_POWER_SUSPEND (1 << 1)
+/** Power down PHY */
+#define USB_POWER_PWRDNPHY (1 << 0)
+
+/* =============================================================================
+ * Endpoint bitmasks for interrupt status and control registers
+ * Applies to USB_TXIS, USB_RXIS, USB_TXIE, USB_RXIE, USB_RXDPKTBUFDIS,
+ * USB_TXDPKTBUFDIS
+ * ---------------------------------------------------------------------------*/
+#define USB_EP7 (1 << 7)
+#define USB_EP6 (1 << 6)
+#define USB_EP5 (1 << 5)
+#define USB_EP4 (1 << 4)
+#define USB_EP3 (1 << 3)
+#define USB_EP2 (1 << 2)
+#define USB_EP1 (1 << 1)
+#define USB_EP0 (1 << 0)
+
+/* =============================================================================
+ * USB interrupt mask values
+ *
+ * These are interchangeable across USB_IS, and USB_IE registers.
+ * ---------------------------------------------------------------------------*/
+/** USB disconnect interrupt */
+#define USB_IM_DISCON (1 << 5)
+/** Start of frame */
+#define USB_IM_SOF (1 << 3)
+/** RESET signaling detected */
+#define USB_IM_RESET (1 << 2)
+/** RESUME signaling detected */
+#define USB_IM_RESUME (1 << 1)
+/** SUSPEND signaling detected */
+#define USB_IM_SUSPEND (1 << 0)
+
+/* =============================================================================
+ * USB_FRAME values
+ * ---------------------------------------------------------------------------*/
+/** Frame number */
+#define USB_FRAME_MASK (0x03FF)
+
+/* =============================================================================
+ * USB_IDX values
+ * ---------------------------------------------------------------------------*/
+/** Endpoint Index */
+#define USB_EPIDX_MASK (0x0F)
+
+/* =============================================================================
+ * USB_TEST values
+ * ---------------------------------------------------------------------------*/
+/** FIFO access */
+#define USB_TEST_FIFOACC (1 << 6)
+/** Force full-speed mode */
+#define USB_TEST_FORCEFS (1 << 5)
+
+/* =============================================================================
+ * USB_TXFIFOSZ and USB_RXFIFOSZ values
+ * ---------------------------------------------------------------------------*/
+/** Double packet buffer support */
+#define USB_FIFOSZ_DPB (1 << 4)
+/* USB Transmit Dynamic FIFO Sizing */
+#define USB_FIFOSZ_SIZE_MASK (0x0F << 0)
+#define USB_FIFOSZ_SIZE_8 (0x00 << 0)
+#define USB_FIFOSZ_SIZE_16 (0x01 << 0)
+#define USB_FIFOSZ_SIZE_32 (0x02 << 0)
+#define USB_FIFOSZ_SIZE_64 (0x03 << 0)
+#define USB_FIFOSZ_SIZE_128 (0x04 << 0)
+#define USB_FIFOSZ_SIZE_256 (0x05 << 0)
+#define USB_FIFOSZ_SIZE_512 (0x06 << 0)
+#define USB_FIFOSZ_SIZE_1024 (0x07 << 0)
+#define USB_FIFOSZ_SIZE_2048 (0x08 << 0)
+
+
+/* =============================================================================
+ * USB_CONTIM values
+ * ---------------------------------------------------------------------------*/
+/** Connect wait */
+#define USB_CONTIM_WTCON_MASK (0x0F << 4)
+/** Wait ID */
+#define USB_CONTIM_WTID_MASK (0x0F << 0)
+
+/* =============================================================================
+ * USB_CSRL0 values
+ * ---------------------------------------------------------------------------*/
+/** Setup End Clear */
+#define USB_CSRL0_SETENDC (1 << 7)
+/** RXRDY Clear */
+#define USB_CSRL0_RXRDYC (1 << 6)
+/** Send Stall */
+#define USB_CSRL0_STALL (1 << 5)
+/** Setup End */
+#define USB_CSRL0_SETEND (1 << 4)
+/** Data End */
+#define USB_CSRL0_DATAEND (1 << 3)
+/** Endpoint Stalled */
+#define USB_CSRL0_STALLED (1 << 2)
+/** Transmit Packet Ready */
+#define USB_CSRL0_TXRDY (1 << 1)
+/** Receive Packet Ready */
+#define USB_CSRL0_RXRDY (1 << 0)
+
+/* =============================================================================
+ * USB_CSRH0 values
+ * ---------------------------------------------------------------------------*/
+/** Flush FIFO */
+#define USB_CSRH0_FLUSH (1 << 0)
+
+/* =============================================================================
+ * USB_TXCSRLx values
+ * ---------------------------------------------------------------------------*/
+/** Clear data toggle */
+#define USB_TXCSRL_CLRDT (1 << 6)
+/** Endpoint Stalled */
+#define USB_TXCSRL_STALLED (1 << 5)
+/** Send Stall */
+#define USB_TXCSRL_STALL (1 << 4)
+/** Flush FIFO */
+#define USB_TXCSRL_FLUSH (1 << 3)
+/** Underrun */
+#define USB_TXCSRL_UNDRN (1 << 2)
+/** FIFO not empty */
+#define USB_TXCSRL_FIFONE (1 << 1)
+/** Transmit Packet Ready */
+#define USB_TXCSRL_TXRDY (1 << 0)
+
+/* =============================================================================
+ * USB_TXCSRHx values
+ * ---------------------------------------------------------------------------*/
+/** Auto set */
+#define USB_TXCSRH_AUTOSET (1 << 7)
+/** Isochronous transfers */
+#define USB_TXCSRH_ISO (1 << 6)
+/** Mode */
+#define USB_TXCSRH_MODE (1 << 5)
+/** DMA request enable */
+#define USB_TXCSRH_DMAEN (1 << 4)
+/** Force data toggle */
+#define USB_TXCSRH_FDT (1 << 3)
+/** DMA request mode */
+#define USB_TXCSRH_DMAMOD (1 << 2)
+
+/* =============================================================================
+ * USB_RXCSRLx values
+ * ---------------------------------------------------------------------------*/
+/** Clear data toggle */
+#define USB_RXCSRL_CLRDT (1 << 7)
+/** Endpoint Stalled */
+#define USB_RXCSRL_STALLED (1 << 6)
+/** Send Stall */
+#define USB_RXCSRL_STALL (1 << 5)
+/** Flush FIFO */
+#define USB_RXCSRL_FLUSH (1 << 4)
+/** Data error */
+#define USB_RXCSRL_DATAERR (1 << 2)
+/** Overrun */
+#define USB_RXCSRL_OVER (1 << 2)
+/** FIFO full */
+#define USB_RXCSRL_FULL (1 << 1)
+/** Receive Packet Ready */
+#define USB_RXCSRL_RXRDY (1 << 0)
+
+/* =============================================================================
+ * USB_RXCSRHx values
+ * ---------------------------------------------------------------------------*/
+/** Auto clear */
+#define USB_RXCSRH_AUTOCL (1 << 7)
+/** Isochronous transfers */
+#define USB_RXCSRH_ISO (1 << 6)
+/** DMA request enable */
+#define USB_RXCSRH_DMAEN (1 << 5)
+/** Disable NYET / PID error */
+#define USB_RXCSRH_PIDERR (1 << 4)
+/** DMA request mode */
+#define USB_RXCSRH_DMAMOD (1 << 3)
+
+/* =============================================================================
+ * USB_DRRIS values
+ * ---------------------------------------------------------------------------*/
+/** RESUME interrupt status */
+#define USB_DRRIS_RESUME (1 << 0)
+
+/* =============================================================================
+ * USB_DRIM values
+ * ---------------------------------------------------------------------------*/
+/** RESUME interrupt mask */
+#define USB_DRIM_RESUME (1 << 0)
+
+/* =============================================================================
+ * USB_DRISC values
+ * ---------------------------------------------------------------------------*/
+/** RESUME interrupt status and clear */
+#define USB_DRISC_RESUME (1 << 0)
+
+/* =============================================================================
+ * USB_PP values
+ * ---------------------------------------------------------------------------*/
+/** Endpoint count */
+#define USB_PP_ECNT_MASK (0xFF << 8)
+/** USB capability */
+#define USB_PP_USB_MASK (0x03 << 6)
+#define USB_PP_USB_NA (0x00 << 6)
+#define USB_PP_USB_DEVICE (0x01 << 6)
+#define USB_PP_USB_HOST (0x02 << 6)
+#define USB_PP_USB_OTG (0x03 << 6)
+/** PHY present */
+#define USB_PP_PHY (1 << 4)
+/** Controller type */
+#define USB_PP_TYPE_MASK (0x0F << 0)
+
+/* =============================================================================
+ * Convenience enums
+ * ---------------------------------------------------------------------------*/
+enum usb_interrupt {
+ USB_INT_DISCON = USB_IM_DISCON,
+ USB_INT_SOF = USB_IM_SOF,
+ USB_INT_RESET = USB_IM_RESET,
+ USB_INT_RESUME = USB_IM_RESUME,
+ USB_INT_SUSPEND = USB_IM_SUSPEND,
+};
+
+enum usb_ep_interrupt {
+ USB_EP0_INT = USB_EP0,
+ USB_EP1_INT = USB_EP1,
+ USB_EP2_INT = USB_EP2,
+ USB_EP3_INT = USB_EP3,
+ USB_EP4_INT = USB_EP4,
+ USB_EP5_INT = USB_EP5,
+ USB_EP6_INT = USB_EP6,
+ USB_EP7_INT = USB_EP7,
+};
+/* =============================================================================
+ * Function prototypes
+ * ---------------------------------------------------------------------------*/
+BEGIN_DECLS
+
+void usb_enable_interrupts(enum usb_interrupt ints,
+ enum usb_ep_interrupt rx_ints,
+ enum usb_ep_interrupt tx_ints);
+void usb_disable_interrupts(enum usb_interrupt ints,
+ enum usb_ep_interrupt rx_ints,
+ enum usb_ep_interrupt tx_ints);
+
+END_DECLS
+
+/**@}*/
+
+#endif /* LIBOPENCM3_LM4F_USB_H */