aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/TIVA/LLD
diff options
context:
space:
mode:
authormarcoveeneman <marco-veeneman@hotmail.com>2014-10-13 23:01:10 +0200
committermarcoveeneman <marco-veeneman@hotmail.com>2014-10-13 23:01:10 +0200
commitb74008c8490fbd6f27392c0badd3de5b6792fc09 (patch)
tree48ae35cc8b12b478edabb854bba972ce87961b98 /os/hal/ports/TIVA/LLD
parented9baddee35122aa2654f3178148fee0d65b9547 (diff)
downloadChibiOS-Contrib-b74008c8490fbd6f27392c0badd3de5b6792fc09.tar.gz
ChibiOS-Contrib-b74008c8490fbd6f27392c0badd3de5b6792fc09.tar.bz2
ChibiOS-Contrib-b74008c8490fbd6f27392c0badd3de5b6792fc09.zip
Added Tiva HAL files.
Diffstat (limited to 'os/hal/ports/TIVA/LLD')
-rw-r--r--os/hal/ports/TIVA/LLD/gpt_lld.c708
-rw-r--r--os/hal/ports/TIVA/LLD/gpt_lld.h501
-rw-r--r--os/hal/ports/TIVA/LLD/i2c_lld.c854
-rw-r--r--os/hal/ports/TIVA/LLD/i2c_lld.h527
-rw-r--r--os/hal/ports/TIVA/LLD/pal_lld.c313
-rw-r--r--os/hal/ports/TIVA/LLD/pal_lld.h466
-rw-r--r--os/hal/ports/TIVA/LLD/pwm_lld.c577
-rw-r--r--os/hal/ports/TIVA/LLD/pwm_lld.h372
-rw-r--r--os/hal/ports/TIVA/LLD/serial_lld.c632
-rw-r--r--os/hal/ports/TIVA/LLD/serial_lld.h482
-rw-r--r--os/hal/ports/TIVA/LLD/st_lld.c284
-rw-r--r--os/hal/ports/TIVA/LLD/st_lld.h323
-rw-r--r--os/hal/ports/TIVA/LLD/tiva_gpt.h135
13 files changed, 6174 insertions, 0 deletions
diff --git a/os/hal/ports/TIVA/LLD/gpt_lld.c b/os/hal/ports/TIVA/LLD/gpt_lld.c
new file mode 100644
index 0000000..c160687
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/gpt_lld.c
@@ -0,0 +1,708 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file TIVA/gpt_lld.c
+ * @brief TM4C123x/TM4C129x GPT subsystem low level driver source.
+ *
+ * @addtogroup GPT
+ * @{
+ */
+
+#include "hal.h"
+
+#if HAL_USE_GPT || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/**
+ * @brief GPTD1 driver identifier.
+ */
+#if TIVA_GPT_USE_GPT0 || defined(__DOXYGEN__)
+GPTDriver GPTD1;
+#endif
+
+/**
+ * @brief GPTD2 driver identifier.
+ */
+#if TIVA_GPT_USE_GPT1 || defined(__DOXYGEN__)
+GPTDriver GPTD2;
+#endif
+
+/**
+ * @brief GPTD3 driver identifier.
+ */
+#if TIVA_GPT_USE_GPT2 || defined(__DOXYGEN__)
+GPTDriver GPTD3;
+#endif
+
+/**
+ * @brief GPTD4 driver identifier.
+ */
+#if TIVA_GPT_USE_GPT3 || defined(__DOXYGEN__)
+GPTDriver GPTD4;
+#endif
+
+/**
+ * @brief GPTD5 driver identifier.
+ */
+#if TIVA_GPT_USE_GPT4 || defined(__DOXYGEN__)
+GPTDriver GPTD5;
+#endif
+
+/**
+ * @brief GPTD6 driver identifier.
+ */
+#if TIVA_GPT_USE_GPT5 || defined(__DOXYGEN__)
+GPTDriver GPTD6;
+#endif
+
+/**
+ * @brief GPTD7 driver identifier.
+ */
+#if TIVA_GPT_USE_WGPT0 || defined(__DOXYGEN__)
+GPTDriver GPTD7;
+#endif
+
+/**
+ * @brief GPTD8 driver identifier.
+ */
+#if TIVA_GPT_USE_WGPT1 || defined(__DOXYGEN__)
+GPTDriver GPTD8;
+#endif
+
+/**
+ * @brief GPTD9 driver identifier.
+ */
+#if TIVA_GPT_USE_WGPT2 || defined(__DOXYGEN__)
+GPTDriver GPTD9;
+#endif
+
+/**
+ * @brief GPTD10 driver identifier.
+ */
+#if TIVA_GPT_USE_WGPT3 || defined(__DOXYGEN__)
+GPTDriver GPTD10;
+#endif
+
+/**
+ * @brief GPTD11 driver identifier.
+ */
+#if TIVA_GPT_USE_WGPT4 || defined(__DOXYGEN__)
+GPTDriver GPTD11;
+#endif
+
+/**
+ * @brief GPTD12 driver identifier.
+ */
+#if TIVA_GPT_USE_WGPT5 || defined(__DOXYGEN__)
+GPTDriver GPTD12;
+#endif
+
+/*===========================================================================*/
+/* Driver local variables and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Shared IRQ handler.
+ *
+ * @param[in] gptp pointer to @p GPTDriver object
+ */
+static void gpt_lld_serve_interrupt(GPTDriver *gptp)
+{
+ gptp->gpt->ICR = 0xffffffff;
+
+ if (gptp->state == GPT_ONESHOT) {
+ gptp->state = GPT_READY;
+ gpt_lld_stop_timer(gptp);
+ }
+
+ gptp->config->callback(gptp);
+}
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+#if TIVA_GPT_USE_GPT0
+#if !defined(TIVA_GPT0A_HANDLER)
+#error "TIVA_GPT0A_HANDLER not defined"
+#endif
+/**
+ * @brief GPT0 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_GPT0A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD1);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_GPT1
+#if !defined(TIVA_GPT1A_HANDLER)
+#error "TIVA_GPT1A_HANDLER not defined"
+#endif
+/**
+ * @brief GPT1 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_GPT1A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD2);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_GPT2
+#if !defined(TIVA_GPT2A_HANDLER)
+#error "TIVA_GPT2A_HANDLER not defined"
+#endif
+/**
+ * @brief GPT2 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_GPT2A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD3);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_GPT3
+#if !defined(TIVA_GPT3A_HANDLER)
+#error "TIVA_GPT3A_HANDLER not defined"
+#endif
+/**
+ * @brief GPT3 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_GPT3A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD4);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_GPT4
+#if !defined(TIVA_GPT4A_HANDLER)
+#error "TIVA_GPT4A_HANDLER not defined"
+#endif
+/**
+ * @brief GPT4 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_GPT4A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD5);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_GPT5
+#if !defined(TIVA_GPT5A_HANDLER)
+#error "TIVA_GPT5A_HANDLER not defined"
+#endif
+/**
+ * @brief GPT5 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_GPT5A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD6);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_WGPT0
+#if !defined(TIVA_WGPT0A_HANDLER)
+#error "TIVA_WGPT0A_HANDLER not defined"
+#endif
+/**
+ * @brief WGPT0 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_WGPT0A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD7);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_WGPT1
+#if !defined(TIVA_WGPT1A_HANDLER)
+#error "TIVA_WGPT1A_HANDLER not defined"
+#endif
+/**
+ * @brief WGPT1 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_WGPT1A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD8);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_WGPT2
+#if !defined(TIVA_WGPT2A_HANDLER)
+#error "TIVA_WGPT2A_HANDLER not defined"
+#endif
+/**
+ * @brief WGPT2 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_WGPT2A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD9);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_WGPT3
+#if !defined(TIVA_WGPT3A_HANDLER)
+#error "TIVA_WGPT3A_HANDLER not defined"
+#endif
+/**
+ * @brief WGPT3 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_WGPT3A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD10);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_WGPT4
+#if !defined(TIVA_WGPT4A_HANDLER)
+#error "TIVA_WGPT4A_HANDLER not defined"
+#endif
+/**
+ * @brief WGPT4 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_WGPT4A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD11);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_GPT_USE_WGPT5
+#if !defined(TIVA_WGPT5A_HANDLER)
+#error "TIVA_WGPT5A_HANDLER not defined"
+#endif
+/**
+ * @brief WGPT5 interrupt handler.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_WGPT5A_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ gpt_lld_serve_interrupt(&GPTD12);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Low level GPT driver initialization.
+ *
+ * @notapi
+ */
+void gpt_lld_init(void)
+{
+ /* Driver initialization.*/
+#if TIVA_GPT_USE_GPT0
+ GPTD1.gpt = GPT0;
+ gptObjectInit(&GPTD1);
+#endif
+
+#if TIVA_GPT_USE_GPT1
+ GPTD2.gpt = GPT1;
+ gptObjectInit(&GPTD2);
+#endif
+
+#if TIVA_GPT_USE_GPT2
+ GPTD3.gpt = GPT2;
+ gptObjectInit(&GPTD3);
+#endif
+
+#if TIVA_GPT_USE_GPT3
+ GPTD4.gpt = GPT3;
+ gptObjectInit(&GPTD4);
+#endif
+
+#if TIVA_GPT_USE_GPT4
+ GPTD5.gpt = GPT4;
+ gptObjectInit(&GPTD5);
+#endif
+
+#if TIVA_GPT_USE_GPT5
+ GPTD6.gpt = GPT5;
+ gptObjectInit(&GPTD6);
+#endif
+
+#if TIVA_GPT_USE_WGPT0
+ GPTD7.gpt = WGPT0;
+ gptObjectInit(&GPTD7);
+#endif
+
+#if TIVA_GPT_USE_WGPT1
+ GPTD8.gpt = WGPT1;
+ gptObjectInit(&GPTD8);
+#endif
+
+#if TIVA_GPT_USE_WGPT2
+ GPTD9.gpt = WGPT2;
+ gptObjectInit(&GPTD9);
+#endif
+
+#if TIVA_GPT_USE_WGPT3
+ GPTD10.gpt = WGPT3;
+ gptObjectInit(&GPTD10);
+#endif
+
+#if TIVA_GPT_USE_WGPT4
+ GPTD11.gpt = WGPT4;
+ gptObjectInit(&GPTD11);
+#endif
+
+#if TIVA_GPT_USE_WGPT5
+ GPTD12.gpt = WGPT5;
+ gptObjectInit(&GPTD12);
+#endif
+}
+
+/**
+ * @brief Configures and activates the GPT peripheral.
+ *
+ * @param[in] gptp pointer to the @p GPTDriver object
+ *
+ * @notapi
+ */
+void gpt_lld_start(GPTDriver *gptp)
+{
+ if (gptp->state == GPT_STOP) {
+ /* Clock activation.*/
+#if TIVA_GPT_USE_GPT0
+ if (&GPTD1 == gptp) {
+ SYSCTL->RCGCTIMER |= (1 << 0);
+ nvicEnableVector(TIVA_GPT0A_NUMBER, TIVA_GPT_GPT0A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT1
+ if (&GPTD2 == gptp) {
+ SYSCTL->RCGCTIMER |= (1 << 1);
+ nvicEnableVector(TIVA_GPT1A_NUMBER, TIVA_GPT_GPT1A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT2
+ if (&GPTD3 == gptp) {
+ SYSCTL->RCGCTIMER |= (1 << 2);
+ nvicEnableVector(TIVA_GPT2A_NUMBER, TIVA_GPT_GPT2A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT3
+ if (&GPTD4 == gptp) {
+ SYSCTL->RCGCTIMER |= (1 << 3);
+ nvicEnableVector(TIVA_GPT3A_NUMBER, TIVA_GPT_GPT3A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT4
+ if (&GPTD5 == gptp) {
+ SYSCTL->RCGCTIMER |= (1 << 4);
+ nvicEnableVector(TIVA_GPT4A_NUMBER, TIVA_GPT_GPT4A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT5
+ if (&GPTD6 == gptp) {
+ SYSCTL->RCGCTIMER |= (1 << 5);
+ nvicEnableVector(TIVA_GPT5A_NUMBER, TIVA_GPT_GPT5A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT0
+ if (&GPTD7 == gptp) {
+ SYSCTL->RCGCWTIMER |= (1 << 0);
+ nvicEnableVector(TIVA_WGPT0A_NUMBER, TIVA_GPT_WGPT0A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT1
+ if (&GPTD8 == gptp) {
+ SYSCTL->RCGCWTIMER |= (1 << 1);
+ nvicEnableVector(TIVA_WGPT1A_NUMBER, TIVA_GPT_WGPT1A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT2
+ if (&GPTD9 == gptp) {
+ SYSCTL->RCGCWTIMER |= (1 << 2);
+ nvicEnableVector(TIVA_WGPT2A_NUMBER, TIVA_GPT_WGPT2A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT3
+ if (&GPTD10 == gptp) {
+ SYSCTL->RCGCWTIMER |= (1 << 3);
+ nvicEnableVector(TIVA_WGPT3A_NUMBER, TIVA_GPT_WGPT3A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT4
+ if (&GPTD11 == gptp) {
+ SYSCTL->RCGCWTIMER |= (1 << 4);
+ nvicEnableVector(TIVA_WGPT4A_NUMBER, TIVA_GPT_WGPT4A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT5
+ if (&GPTD12 == gptp) {
+ SYSCTL->RCGCWTIMER |= (1 << 5);
+ nvicEnableVector(TIVA_WGPT5A_NUMBER, TIVA_GPT_WGPT5A_IRQ_PRIORITY);
+ }
+#endif
+ }
+
+ /* Timer configuration.*/
+ gptp->gpt->CTL = 0;
+ gptp->gpt->CFG = GPTM_CFG_CFG_SPLIT;
+ gptp->gpt->TAPR = ((TIVA_SYSCLK / gptp->config->frequency) - 1);
+}
+
+/**
+ * @brief Deactivates the GPT peripheral.
+ *
+ * @param[in] gptp pointer to the @p GPTDriver object
+ *
+ * @notapi
+ */
+void gpt_lld_stop(GPTDriver *gptp)
+{
+ if (gptp->state == GPT_READY) {
+ gptp->gpt->IMR = 0;
+ gptp->gpt->TAILR = 0;
+ gptp->gpt->CTL = 0;
+
+#if TIVA_GPT_USE_GPT0
+ if (&GPTD1 == gptp) {
+ nvicDisableVector(TIVA_GPT0A_NUMBER);
+ SYSCTL->RCGCTIMER &= ~(1 << 0);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT1
+ if (&GPTD2 == gptp) {
+ nvicDisableVector(TIVA_GPT1A_NUMBER);
+ SYSCTL->RCGCTIMER &= ~(1 << 1);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT2
+ if (&GPTD3 == gptp) {
+ nvicDisableVector(TIVA_GPT2A_NUMBER);
+ SYSCTL->RCGCTIMER &= ~(1 << 2);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT3
+ if (&GPTD4 == gptp) {
+ nvicDisableVector(TIVA_GPT3A_NUMBER);
+ SYSCTL->RCGCTIMER &= ~(1 << 3);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT4
+ if (&GPTD5 == gptp) {
+ nvicDisableVector(TIVA_GPT4A_NUMBER);
+ SYSCTL->RCGCTIMER &= ~(1 << 4);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT5
+ if (&GPTD6 == gptp) {
+ nvicDisableVector(TIVA_GPT5A_NUMBER);
+ SYSCTL->RCGCTIMER &= ~(1 << 5);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT0
+ if (&GPTD7 == gptp) {
+ nvicDisableVector(TIVA_WGPT0A_NUMBER);
+ SYSCTL->RCGCWTIMER &= ~(1 << 0);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT1
+ if (&GPTD8 == gptp) {
+ nvicDisableVector(TIVA_WGPT1A_NUMBER);
+ SYSCTL->RCGCWTIMER &= ~(1 << 1);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT2
+ if (&GPTD9 == gptp) {
+ nvicDisableVector(TIVA_WGPT2A_NUMBER);
+ SYSCTL->RCGCWTIMER &= ~(1 << 2);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT3
+ if (&GPTD10 == gptp) {
+ nvicDisableVector(TIVA_WGPT3A_NUMBER);
+ SYSCTL->RCGCWTIMER &= ~(1 << 3);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT4
+ if (&GPTD11 == gptp) {
+ nvicDisableVector(TIVA_WGPT4A_NUMBER);
+ SYSCTL->RCGCWTIMER &= ~(1 << 4);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT5
+ if (&GPTD12 == gptp) {
+ nvicDisableVector(TIVA_WGPT5A_NUMBER);
+ SYSCTL->RCGCWTIMER &= ~(1 << 5);
+ }
+#endif
+ }
+}
+
+/**
+ * @brief Starts the timer in continuous mode.
+ *
+ * @param[in] gptp pointer to the @p GPTDriver object
+ * @param[in] interval period in ticks
+ *
+ * @notapi
+ */
+void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t interval)
+{
+ gptp->gpt->TAILR = interval - 1;
+ gptp->gpt->ICR = 0xfffffff;
+ gptp->gpt->IMR = GPTM_IMR_TATOIM;
+ gptp->gpt->TAMR = GPTM_TAMR_TAMR_PERIODIC | GPTM_TAMR_TAILD | GPTM_TAMR_TASNAPS;
+ gptp->gpt->CTL = GPTM_CTL_TAEN | GPTM_CTL_TASTALL;
+}
+
+/**
+ * @brief Stops the timer.
+ *
+ * @param[in] gptp pointer to the @p GPTDriver object
+ *
+ * @notapi
+ */
+void gpt_lld_stop_timer(GPTDriver *gptp)
+{
+ gptp->gpt->IMR = 0;
+ gptp->gpt->TAILR = 0;
+ gptp->gpt->CTL &= ~GPTM_CTL_TAEN;
+}
+
+/**
+ * @brief Starts the timer in one shot mode and waits for completion.
+ * @details This function specifically polls the timer waiting for completion
+ * in order to not have extra delays caused by interrupt servicing,
+ * this function is only recommended for short delays.
+ *
+ * @param[in] gptp pointer to the @p GPTDriver object
+ * @param[in] interval time interval in ticks
+ *
+ * @notapi
+ */
+void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval)
+{
+ gptp->gpt->TAMR = GPTM_TAMR_TAMR_ONESHOT | GPTM_TAMR_TAILD | GPTM_TAMR_TASNAPS;
+ gptp->gpt->TAILR = interval - 1;
+ gptp->gpt->ICR = 0xffffffff;
+ gptp->gpt->CTL = GPTM_CTL_TAEN | GPTM_CTL_TASTALL;
+ while (!(gptp->gpt->RIS & GPTM_IMR_TATOIM))
+ ;
+ gptp->gpt->ICR = 0xffffffff;
+}
+
+#endif /* HAL_USE_GPT */
+
+/** @} */
diff --git a/os/hal/ports/TIVA/LLD/gpt_lld.h b/os/hal/ports/TIVA/LLD/gpt_lld.h
new file mode 100644
index 0000000..0e27017
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/gpt_lld.h
@@ -0,0 +1,501 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file TIVA/gpt_lld.h
+ * @brief TM4C123x/TM4C129x GPT subsystem low level driver header.
+ *
+ * @addtogroup GPT
+ * @{
+ */
+
+#ifndef _GPT_LLD_H_
+#define _GPT_LLD_H_
+
+#if HAL_USE_GPT || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @name Configuration options
+ * @{
+ */
+
+/**
+ * @brief GPTD1 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD1 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_GPT0) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_GPT0 FALSE
+#endif
+
+/**
+ * @brief GPTD2 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD2 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_GPT1) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_GPT1 FALSE
+#endif
+
+/**
+ * @brief GPTD3 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD3 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_GPT2) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_GPT2 FALSE
+#endif
+
+/**
+ * @brief GPTD4 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD4 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_GPT3) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_GPT3 FALSE
+#endif
+
+/**
+ * @brief GPTD5 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD5 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_GPT4) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_GPT4 FALSE
+#endif
+
+/**
+ * @brief GPTD6 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD6 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_GPT5) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_GPT5 FALSE
+#endif
+
+/**
+ * @brief GPTD7 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD1 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_WGPT0) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_WGPT0 FALSE
+#endif
+
+/**
+ * @brief GPTD8 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD2 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_WGPT1) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_WGPT1 FALSE
+#endif
+
+/**
+ * @brief GPTD9 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD3 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_WGPT2) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_WGPT2 FALSE
+#endif
+
+/**
+ * @brief GPTD10 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD4 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_WGPT3) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_WGPT3 FALSE
+#endif
+
+/**
+ * @brief GPTD11 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD5 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_WGPT4) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_WGPT4 FALSE
+#endif
+
+/**
+ * @brief GPTD12 driver enable switch.
+ * @details If set to @p TRUE the support for GPTD6 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_GPT_USE_WGPT5) || defined(__DOXYGEN__)
+#define TIVA_GPT_USE_WGPT5 FALSE
+#endif
+
+/**
+ * @brief GPTD1 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_GPT0A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_GPT0A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD2 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_GPT1A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_GPT1A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD3 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_GPT2A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_GPT2A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD4 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_GPT3A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_GPT3A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD5 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_GPT4A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_GPT4A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD6 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_GPT5A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_GPT5A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD7 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_WGPT0A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_WGPT0A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD8 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_WGPT1A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_WGPT1A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD9 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_WGPT2A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_WGPT2A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD10 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_WGPT3A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_WGPT3A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD11 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_WGPT4A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_WGPT4A_IRQ_PRIORITY 7
+#endif
+
+/**
+ * @brief GPTD12 interrupt priority level setting.
+ */
+#if !defined(TIVA_GPT_WGPT5A_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_GPT_WGPT5A_IRQ_PRIORITY 7
+#endif
+
+/** @} */
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+#if TIVA_GPT_USE_GPT0 && !TIVA_HAS_GPT0
+#error "GPT0 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_GPT1 && !TIVA_HAS_GPT1
+#error "GPT1 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_GPT2 && !TIVA_HAS_GPT2
+#error "GPT2 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_GPT3 && !TIVA_HAS_GPT3
+#error "GPT3 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_GPT4 && !TIVA_HAS_GPT4
+#error "GPT4 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_GPT5 && !TIVA_HAS_GPT5
+#error "GPT5 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_WGPT0 && !TIVA_HAS_WGPT0
+#error "WGPT0 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_WGPT1 && !TIVA_HAS_WGPT1
+#error "WGPT1 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_WGPT2 && !TIVA_HAS_WGPT2
+#error "WGPT2 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_WGPT3 && !TIVA_HAS_WGPT3
+#error "WGPT3 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_WGPT4 && !TIVA_HAS_WGPT4
+#error "WGPT4 not present in the selected device"
+#endif
+
+#if TIVA_GPT_USE_WGPT5 && !TIVA_HAS_WGPT5
+#error "WGPT5 not present in the selected device"
+#endif
+
+#if !TIVA_GPT_USE_GPT0 && !TIVA_GPT_USE_GPT1 && !TIVA_GPT_USE_GPT2 && \
+ !TIVA_GPT_USE_GPT3 && !TIVA_GPT_USE_GPT4 && !TIVA_GPT_USE_GPT5 && \
+ !TIVA_GPT_USE_WGPT0 && !TIVA_GPT_USE_WGPT1 && !TIVA_GPT_USE_WGPT2 && \
+ !TIVA_GPT_USE_WGPT3 && !TIVA_GPT_USE_WGPT4 && !TIVA_GPT_USE_WGPT5
+#error "GPT driver activated but no (W)GPT peripheral assigned"
+#endif
+
+#if TIVA_GPT_USE_GPT0 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_GPT0A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT0"
+#endif
+
+#if TIVA_GPT_USE_GPT1 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_GPT1A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT1"
+#endif
+
+#if TIVA_GPT_USE_GPT2 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_GPT2A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT2"
+#endif
+
+#if TIVA_GPT_USE_GPT3 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_GPT3A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT3"
+#endif
+
+#if TIVA_GPT_USE_GPT4 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_GPT4A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT4"
+#endif
+
+#if TIVA_GPT_USE_GPT5 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_GPT5A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT5"
+#endif
+
+#if TIVA_GPT_USE_WGPT0 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_WGPT0A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT0"
+#endif
+
+#if TIVA_GPT_USE_WGPT1 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_WGPT1A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT1"
+#endif
+
+#if TIVA_GPT_USE_WGPT2 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_WGPT2A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT2"
+#endif
+
+#if TIVA_GPT_USE_WGPT3 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_WGPT3A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT3"
+#endif
+
+#if TIVA_GPT_USE_WGPT4 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_WGPT4A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT4"
+#endif
+
+#if TIVA_GPT_USE_WGPT5 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_GPT_WGPT5A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT5"
+#endif
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief GPT frequency type.
+ */
+typedef uint32_t gptfreq_t;
+
+/**
+ * @brief GPT counter type.
+ */
+typedef uint16_t gptcnt_t;
+
+/**
+ * @brief Driver configuration structure.
+ * @note It could be empty on some architectures.
+ */
+typedef struct {
+ /**
+ * @brief Timer clock in Hz.
+ * @note The low level can use assertions in order to catch invalid
+ * frequency specifications.
+ */
+ gptfreq_t frequency;
+ /**
+ * @brief Timer callback pointer.
+ * @note This callback is invoked on GPT counter events.
+ */
+ gptcallback_t callback;
+ /* End of the mandatory fields.*/
+} GPTConfig;
+
+/**
+ * @brief Structure representing a GPT driver.
+ */
+struct GPTDriver {
+ /**
+ * @brief Driver state.
+ */
+ gptstate_t state;
+ /**
+ * @brief Current configuration data.
+ */
+ const GPTConfig *config;
+#if defined(GPT_DRIVER_EXT_FIELDS)
+ GPT_DRIVER_EXT_FIELDS
+#endif
+ /* End of the mandatory fields.*/
+ /**
+ * @brief Pointer to the GPT registers block.
+ */
+ GPT_TypeDef *gpt;
+};
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/**
+ * @brief Changes the interval of GPT peripheral.
+ * @details This function changes the interval of a running GPT unit.
+ * @pre The GPT unit must have been activated using @p gptStart().
+ * @pre The GPT unit must have been running in continuous mode using
+ * @p gptStartContinuous().
+ * @post The GPT unit interval is changed to the new value.
+ * @note The function has effect at the next cycle start.
+ *
+ * @param[in] gptp pointer to a @p GPTDriver object
+ * @param[in] interval new cycle time in timer ticks
+ * @notapi
+ */
+#define gpt_lld_change_interval(gptp, interval) { \
+ gptp->gpt->TAILR = interval - 1; \
+}
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#if TIVA_GPT_USE_GPT0 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD1;
+#endif
+
+#if TIVA_GPT_USE_GPT1 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD2;
+#endif
+
+#if TIVA_GPT_USE_GPT2 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD3;
+#endif
+
+#if TIVA_GPT_USE_GPT3 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD4;
+#endif
+
+#if TIVA_GPT_USE_GPT4 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD5;
+#endif
+
+#if TIVA_GPT_USE_GPT5 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD6;
+#endif
+
+#if TIVA_GPT_USE_WGPT0 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD7;
+#endif
+
+#if TIVA_GPT_USE_WGPT1 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD8;
+#endif
+
+#if TIVA_GPT_USE_WGPT2 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD9;
+#endif
+
+#if TIVA_GPT_USE_WGPT3 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD10;
+#endif
+
+#if TIVA_GPT_USE_WGPT4 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD11;
+#endif
+
+#if TIVA_GPT_USE_WGPT5 && !defined(__DOXYGEN__)
+extern GPTDriver GPTD12;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void gpt_lld_init(void);
+ void gpt_lld_start(GPTDriver *gptp);
+ void gpt_lld_stop(GPTDriver *gptp);
+ void gpt_lld_start_timer(GPTDriver *gptp, gptcnt_t period);
+ void gpt_lld_stop_timer(GPTDriver *gptp);
+ void gpt_lld_polled_delay(GPTDriver *gptp, gptcnt_t interval);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_GPT */
+
+#endif /* _GPT_LLD_H_ */
+
+/** @} */
diff --git a/os/hal/ports/TIVA/LLD/i2c_lld.c b/os/hal/ports/TIVA/LLD/i2c_lld.c
new file mode 100644
index 0000000..4019a3b
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/i2c_lld.c
@@ -0,0 +1,854 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file TIVA/LLD/i2c_lld.c
+ * @brief TM4C123x/TM4C129x I2C subsystem low level driver source.
+ *
+ * @addtogroup I2C
+ * @{
+ */
+
+#include "hal.h"
+
+#if HAL_USE_I2C || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/**
+ * @brief I2C0 driver identifier.
+ */
+#if TIVA_I2C_USE_I2C0 || defined(__DOXYGEN__)
+I2CDriver I2CD1;
+#endif
+
+/**
+ * @brief I2C1 driver identifier.
+ */
+#if TIVA_I2C_USE_I2C1 || defined(__DOXYGEN__)
+I2CDriver I2CD2;
+#endif
+
+/**
+ * @brief I2C2 driver identifier.
+ */
+#if TIVA_I2C_USE_I2C2 || defined(__DOXYGEN__)
+I2CDriver I2CD3;
+#endif
+
+/**
+ * @brief I2C3 driver identifier.
+ */
+#if TIVA_I2C_USE_I2C3 || defined(__DOXYGEN__)
+I2CDriver I2CD4;
+#endif
+
+/**
+ * @brief I2C4 driver identifier.
+ */
+#if TIVA_I2C_USE_I2C4 || defined(__DOXYGEN__)
+I2CDriver I2CD5;
+#endif
+
+/**
+ * @brief I2C5 driver identifier.
+ */
+#if TIVA_I2C_USE_I2C5 || defined(__DOXYGEN__)
+I2CDriver I2CD6;
+#endif
+
+/**
+ * @brief I2C6 driver identifier.
+ */
+#if TIVA_I2C_USE_I2C6 || defined(__DOXYGEN__)
+I2CDriver I2CD7;
+#endif
+
+/**
+ * @brief I2C7 driver identifier.
+ */
+#if TIVA_I2C_USE_I2C7 || defined(__DOXYGEN__)
+I2CDriver I2CD8;
+#endif
+
+/**
+ * @brief I2C8 driver identifier.
+ */
+#if TIVA_I2C_USE_I2C8 || defined(__DOXYGEN__)
+I2CDriver I2CD9;
+#endif
+
+/**
+ * @brief I2C9 driver identifier.
+ */
+#if TIVA_I2C_USE_I2C9 || defined(__DOXYGEN__)
+I2CDriver I2CD10;
+#endif
+
+/*===========================================================================*/
+/* Driver local variables and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/**
+ * @brief I2C shared ISR code.
+ *
+ * @param[in] i2cp pointer to the @p I2CDriver object
+ *
+ * @notapi
+ */
+static void i2c_lld_serve_interrupt(I2CDriver *i2cp)
+{
+ I2C_TypeDef *dp = i2cp->i2c;
+ uint32_t status;
+
+ // clear MIS bit in MICR by writing 1
+ dp->MICR = 1;
+
+ // read interrupt status
+ status = dp->MCS;
+
+ if (status & TIVA_MCS_ERROR) {
+ i2cp->errors |= I2C_BUS_ERROR;
+ }
+ if (status & TIVA_MCS_ARBLST) {
+ i2cp->errors |= I2C_ARBITRATION_LOST;
+ }
+
+ if (i2cp->errors == I2C_NO_ERROR) {
+ // no error detected
+ switch(i2cp->intstate) {
+ case STATE_IDLE: {
+ _i2c_wakeup_isr(i2cp);
+ break;
+ }
+ case STATE_WRITE_NEXT: {
+ if (i2cp->txbytes == 1) {
+ i2cp->intstate = STATE_WRITE_FINAL;
+ }
+ dp->MDR = *(i2cp->txbuf);
+ i2cp->txbuf++;
+ i2cp->txbytes--;
+ // start transmission
+ dp->MCS = TIVA_I2C_BURST_SEND_CONTINUE;
+ break;
+ }
+ case STATE_WRITE_FINAL: {
+ if (i2cp->rxbytes == 0) {
+ i2cp->intstate = STATE_IDLE;
+ }
+ else if (i2cp->rxbytes == 1) {
+ i2cp->intstate = STATE_READ_ONE;
+ }
+ else {
+ i2cp->intstate = STATE_READ_FIRST;
+ }
+ dp->MDR = *(i2cp->txbuf);
+ i2cp->txbuf++;
+ // txbytes - 1
+ i2cp->txbytes--;
+ // start transmission
+ dp->MCS = TIVA_I2C_BURST_SEND_FINISH;
+ break;
+ }
+ case STATE_WAIT_ACK: {
+ break;
+ }
+ case STATE_SEND_ACK: {
+ break;
+ }
+ case STATE_READ_ONE: {
+ i2cp->intstate = STATE_READ_WAIT;
+ // Initializes driver fields, LSB = 1 -> read.
+ i2cp->addr |= 1;
+
+ // set slave address
+ dp->MSA = i2cp->addr;
+ i2cp->rxbytes--;
+ //start receiving
+ dp->MCS = TIVA_I2C_SINGLE_RECEIVE;
+
+ break;
+ }
+ case STATE_READ_FIRST: {
+ if (i2cp->rxbytes == 2) {
+ i2cp->intstate = STATE_READ_FINAL;
+ }
+ else {
+ i2cp->intstate = STATE_READ_NEXT;
+ }
+
+ // Initializes driver fields, LSB = 1 -> read.
+ i2cp->addr |= 1;
+
+ // set slave address
+ dp->MSA = i2cp->addr;
+ i2cp->rxbytes--;
+ //start receiving
+ dp->MCS = TIVA_I2C_BURST_RECEIVE_START;
+
+ break;
+ }
+ case STATE_READ_NEXT: {
+ if(i2cp->rxbytes == 0) {
+ i2cp->intstate = STATE_READ_FINAL;
+ }
+ *(i2cp->rxbuf) = dp->MDR;
+ i2cp->rxbuf++;
+ i2cp->rxbytes--;
+ //start receiving
+ dp->MCS = TIVA_I2C_BURST_RECEIVE_CONTINUE;
+
+ break;
+ }
+ case STATE_READ_FINAL: {
+ i2cp->intstate = STATE_READ_WAIT;
+ *(i2cp->rxbuf) = dp->MDR;
+ i2cp->rxbuf++;
+ i2cp->rxbytes--;
+ //start receiving
+ dp->MCS = TIVA_I2C_BURST_RECEIVE_FINISH;
+
+ break;
+ }
+ case STATE_READ_WAIT: {
+ i2cp->intstate = STATE_IDLE;
+ *(i2cp->rxbuf) = dp->MDR;
+ i2cp->rxbuf++;
+ _i2c_wakeup_isr(i2cp);
+ break;
+ }
+ }
+ }
+ else {
+ // error detected
+ _i2c_wakeup_error_isr(i2cp);
+ }
+}
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+#if TIVA_I2C_USE_I2C0 || defined(__DOXYGEN__)
+/**
+ * @brief I2C0 interrupt handler.
+ *
+ * @notapi
+ */
+OSAL_IRQ_HANDLER(TIVA_I2C0_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ i2c_lld_serve_interrupt(&I2CD1);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* TIVA_I2C_USE_I2C0 */
+
+#if TIVA_I2C_USE_I2C1 || defined(__DOXYGEN__)
+/**
+ * @brief I2C1 interrupt handler.
+ *
+ * @notapi
+ */
+OSAL_IRQ_HANDLER(TIVA_I2C1_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ i2c_lld_serve_interrupt(&I2CD2);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* TIVA_I2C_USE_I2C1 */
+
+#if TIVA_I2C_USE_I2C2 || defined(__DOXYGEN__)
+/**
+ * @brief I2C2 interrupt handler.
+ *
+ * @notapi
+ */
+OSAL_IRQ_HANDLER(TIVA_I2C2_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ i2c_lld_serve_interrupt(&I2CD3);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* TIVA_I2C_USE_I2C2 */
+
+#if TIVA_I2C_USE_I2C3 || defined(__DOXYGEN__)
+/**
+ * @brief I2C3 interrupt handler.
+ *
+ * @notapi
+ */
+OSAL_IRQ_HANDLER(TIVA_I2C3_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ i2c_lld_serve_interrupt(&I2CD4);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* TIVA_I2C_USE_I2C3 */
+
+#if TIVA_I2C_USE_I2C4 || defined(__DOXYGEN__)
+/**
+ * @brief I2C4 interrupt handler.
+ *
+ * @notapi
+ */
+OSAL_IRQ_HANDLER(TIVA_I2C4_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ i2c_lld_serve_interrupt(&I2CD5);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* TIVA_I2C_USE_I2C4 */
+
+#if TIVA_I2C_USE_I2C5 || defined(__DOXYGEN__)
+/**
+ * @brief I2C5 interrupt handler.
+ *
+ * @notapi
+ */
+OSAL_IRQ_HANDLER(TIVA_I2C5_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ i2c_lld_serve_interrupt(&I2CD6);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* TIVA_I2C_USE_I2C5 */
+
+#if TIVA_I2C_USE_I2C6 || defined(__DOXYGEN__)
+/**
+ * @brief I2C6 interrupt handler.
+ *
+ * @notapi
+ */
+OSAL_IRQ_HANDLER(TIVA_I2C6_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ i2c_lld_serve_interrupt(&I2CD7);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* TIVA_I2C_USE_I2C6 */
+
+#if TIVA_I2C_USE_I2C7 || defined(__DOXYGEN__)
+/**
+ * @brief I2C7 interrupt handler.
+ *
+ * @notapi
+ */
+OSAL_IRQ_HANDLER(TIVA_I2C7_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ i2c_lld_serve_interrupt(&I2CD8);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* TIVA_I2C_USE_I2C7 */
+
+#if TIVA_I2C_USE_I2C8 || defined(__DOXYGEN__)
+/**
+ * @brief I2C8 interrupt handler.
+ *
+ * @notapi
+ */
+OSAL_IRQ_HANDLER(TIVA_I2C8_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ i2c_lld_serve_interrupt(&I2CD9);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* TIVA_I2C_USE_I2C8 */
+
+#if TIVA_I2C_USE_I2C9 || defined(__DOXYGEN__)
+/**
+ * @brief I2C9 interrupt handler.
+ *
+ * @notapi
+ */
+OSAL_IRQ_HANDLER(TIVA_I2C9_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ i2c_lld_serve_interrupt(&I2CD10);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* TIVA_I2C_USE_I2C9 */
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Low level I2C driver initialization.
+ *
+ * @notapi
+ */
+void i2c_lld_init(void) {
+
+#if TIVA_I2C_USE_I2C0
+ i2cObjectInit(&I2CD1);
+ I2CD1.thread = NULL;
+ I2CD1.i2c = I2C0;
+#endif /* TIVA_I2C_USE_I2C0 */
+
+#if TIVA_I2C_USE_I2C1
+ i2cObjectInit(&I2CD2);
+ I2CD2.thread = NULL;
+ I2CD2.i2c = I2C1;
+#endif /* TIVA_I2C_USE_I2C1 */
+
+#if TIVA_I2C_USE_I2C2
+ i2cObjectInit(&I2CD3);
+ I2CD3.thread = NULL;
+ I2CD3.i2c = I2C2;
+#endif /* TIVA_I2C_USE_I2C2 */
+
+#if TIVA_I2C_USE_I2C3
+ i2cObjectInit(&I2CD4);
+ I2CD4.thread = NULL;
+ I2CD4.i2c = I2C3;
+#endif /* TIVA_I2C_USE_I2C3 */
+
+#if TIVA_I2C_USE_I2C4
+ i2cObjectInit(&I2CD5);
+ I2CD5.thread = NULL;
+ I2CD5.i2c = I2C4;
+#endif /* TIVA_I2C_USE_I2C4 */
+
+#if TIVA_I2C_USE_I2C5
+ i2cObjectInit(&I2CD6);
+ I2CD6.thread = NULL;
+ I2CD6.i2c = I2C5;
+#endif /* TIVA_I2C_USE_I2C5 */
+
+#if TIVA_I2C_USE_I2C6
+ i2cObjectInit(&I2CD7);
+ I2CD7.thread = NULL;
+ I2CD7.i2c = I2C6;
+#endif /* TIVA_I2C_USE_I2C6 */
+
+#if TIVA_I2C_USE_I2C7
+ i2cObjectInit(&I2CD8);
+ I2CD8.thread = NULL;
+ I2CD8.i2c = I2C7;
+#endif /* TIVA_I2C_USE_I2C7 */
+
+#if TIVA_I2C_USE_I2C8
+ i2cObjectInit(&I2CD9);
+ I2CD9.thread = NULL;
+ I2CD9.i2c = I2C8;
+#endif /* TIVA_I2C_USE_I2C8 */
+
+#if TIVA_I2C_USE_I2C9
+ i2cObjectInit(&I2CD10);
+ I2CD10.thread = NULL;
+ I2CD10.i2c = I2C9;
+#endif /* TIVA_I2C_USE_I2C9 */
+}
+
+/**
+ * @brief Configures and activates the I2C peripheral.
+ *
+ * @param[in] i2cp pointer to the @p I2CDriver object
+ *
+ * @notapi
+ */
+void i2c_lld_start(I2CDriver *i2cp)
+{
+ I2C_TypeDef *dp = i2cp->i2c;
+
+ /* If in stopped state then enables the I2C clocks.*/
+ if (i2cp->state == I2C_STOP) {
+#if TIVA_I2C_USE_I2C0
+ if (&I2CD1 == i2cp) {
+ SYSCTL->RCGCI2C |= (1 << 0);
+ nvicEnableVector(TIVA_I2C0_NUMBER, TIVA_I2C_I2C0_IRQ_PRIORITY);
+ }
+#endif /* TIVA_I2C_USE_I2C0 */
+
+#if TIVA_I2C_USE_I2C1
+ if (&I2CD2 == i2cp) {
+ SYSCTL->RCGCI2C |= (1 << 1);
+ nvicEnableVector(TIVA_I2C1_NUMBER, TIVA_I2C_I2C1_IRQ_PRIORITY);
+ }
+#endif /* TIVA_I2C_USE_I2C1 */
+
+#if TIVA_I2C_USE_I2C2
+ if (&I2CD3 == i2cp) {
+ SYSCTL->RCGCI2C |= (1 << 2);
+ nvicEnableVector(TIVA_I2C2_NUMBER, TIVA_I2C_I2C2_IRQ_PRIORITY);
+ }
+#endif /* TIVA_I2C_USE_I2C2 */
+
+#if TIVA_I2C_USE_I2C3
+ if (&I2CD4 == i2cp) {
+ SYSCTL->RCGCI2C |= (1 << 3);
+ nvicEnableVector(TIVA_I2C3_NUMBER, TIVA_I2C_I2C3_IRQ_PRIORITY);
+ }
+#endif /* TIVA_I2C_USE_I2C3 */
+
+#if TIVA_I2C_USE_I2C4
+ if (&I2CD5 == i2cp) {
+ SYSCTL->RCGCI2C |= (1 << 4);
+ nvicEnableVector(TIVA_I2C4_NUMBER, TIVA_I2C_I2C4_IRQ_PRIORITY);
+ }
+#endif /* TIVA_I2C_USE_I2C4 */
+
+#if TIVA_I2C_USE_I2C5
+ if (&I2CD6 == i2cp) {
+ SYSCTL->RCGCI2C |= (1 << 5);
+ nvicEnableVector(TIVA_I2C5_NUMBER, TIVA_I2C_I2C5_IRQ_PRIORITY);
+ }
+#endif /* TIVA_I2C_USE_I2C5 */
+
+#if TIVA_I2C_USE_I2C6
+ if (&I2CD7 == i2cp) {
+ SYSCTL->RCGCI2C |= (1 << 6);
+ nvicEnableVector(TIVA_I2C6_NUMBER, TIVA_I2C_I2C6_IRQ_PRIORITY);
+ }
+#endif /* TIVA_I2C_USE_I2C6 */
+
+#if TIVA_I2C_USE_I2C7
+ if (&I2CD8 == i2cp) {
+ SYSCTL->RCGCI2C |= (1 << 7);
+ nvicEnableVector(TIVA_I2C7_NUMBER, TIVA_I2C_I2C7_IRQ_PRIORITY);
+ }
+#endif /* TIVA_I2C_USE_I2C7 */
+
+#if TIVA_I2C_USE_I2C8
+ if (&I2CD9 == i2cp) {
+ SYSCTL->RCGCI2C |= (1 << 8);
+ nvicEnableVector(TIVA_I2C8_NUMBER, TIVA_I2C_I2C8_IRQ_PRIORITY);
+ }
+#endif /* TIVA_I2C_USE_I2C7 */
+
+#if TIVA_I2C_USE_I2C9
+ if (&I2CD10 == i2cp) {
+ SYSCTL->RCGCI2C |= (1 << 9);
+ nvicEnableVector(TIVA_I2C9_NUMBER, TIVA_I2C_I2C9_IRQ_PRIORITY);
+ }
+#endif /* TIVA_I2C_USE_I2C7 */
+ }
+
+ dp->MCR = 0x10;
+ dp->MTPR = MTPR_VALUE;
+}
+
+/**
+ * @brief Deactivates the I2C peripheral.
+ *
+ * @param[in] i2cp pointer to the @p I2CDriver object
+ *
+ * @notapi
+ */
+void i2c_lld_stop(I2CDriver *i2cp)
+{
+ I2C_TypeDef *dp = i2cp->i2c;
+ /* If not in stopped state then disables the I2C clock.*/
+ if (i2cp->state != I2C_STOP) {
+
+ /* I2C disable.*/
+ // TODO: abort i2c operation
+ //i2c_lld_abort_operation(i2cp);
+
+#if TIVA_I2C_USE_I2C0
+ if (&I2CD1 == i2cp) {
+ SYSCTL->RCGCI2C &= ~(1 << 0);
+ nvicDisableVector(TIVA_I2C0_NUMBER);
+ }
+#endif /* TIVA_I2C_USE_I2C0 */
+
+#if TIVA_I2C_USE_I2C1
+ if (&I2CD2 == i2cp) {
+ SYSCTL->RCGCI2C &= ~(1 << 1);
+ nvicDisableVector(TIVA_I2C1_NUMBER);
+ }
+#endif /* TIVA_I2C_USE_I2C1 */
+
+#if TIVA_I2C_USE_I2C2
+ if (&I2CD3 == i2cp) {
+ SYSCTL->RCGCI2C &= ~(1 << 2);
+ nvicDisableVector(TIVA_I2C2_NUMBER);
+ }
+#endif /* TIVA_I2C_USE_I2C2 */
+
+#if TIVA_I2C_USE_I2C3
+ if (&I2CD4 == i2cp) {
+ SYSCTL->RCGCI2C &= ~(1 << 3);
+ nvicDisableVector(TIVA_I2C3_NUMBER);
+ }
+#endif /* TIVA_I2C_USE_I2C3 */
+
+#if TIVA_I2C_USE_I2C4
+ if (&I2CD5 == i2cp) {
+ SYSCTL->RCGCI2C &= ~(1 << 4);
+ nvicDisableVector(TIVA_I2C4_NUMBER);
+ }
+#endif /* TIVA_I2C_USE_I2C4 */
+
+#if TIVA_I2C_USE_I2C5
+ if (&I2CD6 == i2cp) {
+ SYSCTL->RCGCI2C &= ~(1 << 5);
+ nvicDisableVector(TIVA_I2C5_NUMBER);
+ }
+#endif /* TIVA_I2C_USE_I2C5 */
+
+#if TIVA_I2C_USE_I2C6
+ if (&I2CD7 == i2cp) {
+ SYSCTL->RCGCI2C &= ~(1 << 6);
+ nvicDisableVector(TIVA_I2C6_NUMBER);
+ }
+#endif /* TIVA_I2C_USE_I2C6 */
+
+#if TIVA_I2C_USE_I2C7
+ if (&I2CD8 == i2cp) {
+ SYSCTL->RCGCI2C &= ~(1 << 7);
+ nvicDisableVector(TIVA_I2C7_NUMBER);
+ }
+#endif /* TIVA_I2C_USE_I2C7 */
+
+#if TIVA_I2C_USE_I2C8
+ if (&I2CD9 == i2cp) {
+ SYSCTL->RCGCI2C &= ~(1 << 8);
+ nvicDisableVector(TIVA_I2C8_NUMBER);
+ }
+#endif /* TIVA_I2C_USE_I2C8 */
+
+#if TIVA_I2C_USE_I2C9
+ if (&I2CD10 == i2cp) {
+ SYSCTL->RCGCI2C &= ~(1 << 9);
+ nvicDisableVector(TIVA_I2C9_NUMBER);
+ }
+#endif /* TIVA_I2C_USE_I2C9 */
+
+ dp->MCR = 0;
+ dp->MTPR = 0;
+ }
+}
+
+/**
+ * @brief Receives data via the I2C bus as master.
+ *
+ * @param[in] i2cp pointer to the @p I2CDriver object
+ * @param[in] addr slave device address
+ * @param[out] rxbuf pointer to the receive buffer
+ * @param[in] rxbytes number of bytes to be received
+ * @param[in] timeout the number of ticks before the operation timeouts,
+ * the following special values are allowed:
+ * - @a TIME_INFINITE no timeout.
+ * .
+ * @return The operation status.
+ * @retval RDY_OK if the function succeeded.
+ * @retval RDY_RESET if one or more I2C errors occurred, the errors can
+ * be retrieved using @p i2cGetErrors().
+ * @retval RDY_TIMEOUT if a timeout occurred before operation end. <b>After a
+ * timeout the driver must be stopped and restarted
+ * because the bus is in an uncertain state</b>.
+ *
+ * @notapi
+ */
+msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
+ uint8_t *rxbuf, size_t rxbytes,
+ systime_t timeout)
+{
+ I2C_TypeDef *dp = i2cp->i2c;
+ systime_t start, end;
+
+ i2cp->rxbuf = rxbuf;
+ i2cp->rxbytes = rxbytes;
+
+ /* Resetting error flags for this transfer.*/
+ i2cp->errors = I2C_NO_ERROR;
+
+ /* Initializes driver fields, LSB = 1 -> receive.*/
+ i2cp->addr = (addr << 1) | 0x01;
+
+ /* Releases the lock from high level driver.*/
+ osalSysUnlock();
+
+ /* Calculating the time window for the timeout on the busy bus condition.*/
+ start = osalOsGetSystemTimeX();
+ end = start + OSAL_MS2ST(TIVA_I2C_BUSY_TIMEOUT);
+
+ /* Waits until BUSY flag is reset or, alternatively, for a timeout
+ condition.*/
+ while (true) {
+ osalSysLock();
+
+ /* If the bus is not busy then the operation can continue, note, the
+ loop is exited in the locked state.*/
+ if ((dp->MCS & TIVA_MCS_BUSY) == 0)
+ break;
+
+ /* If the system time went outside the allowed window then a timeout
+ condition is returned.*/
+ if (!osalOsIsTimeWithinX(osalOsGetSystemTimeX(), start, end))
+ return MSG_TIMEOUT;
+
+ osalSysUnlock();
+ }
+
+ /* set slave address */
+ dp->MSA = addr;
+
+ /* Starts the operation.*/
+ dp->MCS = TIVA_I2C_SINGLE_RECEIVE;
+
+ /* Waits for the operation completion or a timeout.*/
+ return osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
+}
+
+/**
+ * @brief Transmits data via the I2C bus as master.
+ *
+ * @param[in] i2cp pointer to the @p I2CDriver object
+ * @param[in] addr slave device address
+ * @param[in] txbuf pointer to the transmit buffer
+ * @param[in] txbytes number of bytes to be transmitted
+ * @param[out] rxbuf pointer to the receive buffer
+ * @param[in] rxbytes number of bytes to be received
+ * @param[in] timeout the number of ticks before the operation timeouts,
+ * the following special values are allowed:
+ * - @a TIME_INFINITE no timeout.
+ * .
+ * @return The operation status.
+ * @retval RDY_OK if the function succeeded.
+ * @retval RDY_RESET if one or more I2C errors occurred, the errors can
+ * be retrieved using @p i2cGetErrors().
+ * @retval RDY_TIMEOUT if a timeout occurred before operation end. <b>After a
+ * timeout the driver must be stopped and restarted
+ * because the bus is in an uncertain state</b>.
+ *
+ * @notapi
+ */
+msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
+ const uint8_t *txbuf, size_t txbytes,
+ uint8_t *rxbuf, size_t rxbytes,
+ systime_t timeout)
+{
+ I2C_TypeDef *dp = i2cp->i2c;
+ systime_t start, end;
+
+ i2cp->rxbuf = rxbuf;
+ i2cp->rxbytes = rxbytes;
+ i2cp->txbuf = txbuf;
+ i2cp->txbytes = txbytes;
+
+ /* Resetting error flags for this transfer.*/
+ i2cp->errors = I2C_NO_ERROR;
+
+ /* Releases the lock from high level driver.*/
+ osalSysUnlock();
+
+ /* Calculating the time window for the timeout on the busy bus condition.*/
+ start = osalOsGetSystemTimeX();
+ end = start + OSAL_MS2ST(TIVA_I2C_BUSY_TIMEOUT);
+
+ /* Waits until BUSY flag is reset or, alternatively, for a timeout
+ condition.*/
+ while (true) {
+ osalSysLock();
+
+ /* If the bus is not busy then the operation can continue, note, the
+ loop is exited in the locked state.*/
+ if ((dp->MCS & TIVA_MCS_BUSY) == 0)
+ break;
+
+ /* If the system time went outside the allowed window then a timeout
+ condition is returned.*/
+ if (!osalOsIsTimeWithinX(osalOsGetSystemTimeX(), start, end))
+ return MSG_TIMEOUT;
+
+ osalSysUnlock();
+ }
+
+ /* Initializes driver fields, LSB = 0 -> write.*/
+ i2cp->addr = addr << 1 | 0;
+
+ /* set slave address */
+ dp->MSA = i2cp->addr;
+
+ /* enable interrupts */
+ dp->MIMR = TIVA_MIMR_IM;
+
+ /* put data in register */
+ dp->MDR = *(i2cp->txbuf);
+
+ /* check if 1 or more bytes */
+ if (i2cp->txbytes == 1) {
+ if (i2cp->rxbytes == 1) {
+ // one byte read
+ i2cp->intstate = STATE_READ_ONE;
+ }
+ else {
+ // multiple byte read
+ i2cp->intstate = STATE_READ_FIRST;
+ }
+ // single byte send
+ dp->MCS = TIVA_I2C_SIGNLE_SEND;
+ }
+ else {
+ if (i2cp->txbytes == 2) {
+ // 2 bytes
+ i2cp->intstate = STATE_WRITE_FINAL;
+ }
+ else {
+ // more then 2 bytes
+ i2cp->intstate = STATE_WRITE_NEXT;
+ }
+ // multiple bytes start send
+ dp->MCS = TIVA_I2C_BURST_SEND_START;
+ }
+
+ i2cp->txbuf++;
+ i2cp->txbytes--;
+
+ /* Waits for the operation completion or a timeout.*/
+ return osalThreadSuspendTimeoutS(&i2cp->thread, timeout);
+}
+
+#endif /* HAL_USE_I2C */
+
+/** @} */
diff --git a/os/hal/ports/TIVA/LLD/i2c_lld.h b/os/hal/ports/TIVA/LLD/i2c_lld.h
new file mode 100644
index 0000000..9b7b743
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/i2c_lld.h
@@ -0,0 +1,527 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file TIVA/LLD/i2c_lld.h
+ * @brief TM4C123x/TM4C129x I2C subsystem low level driver header.
+ *
+ * @addtogroup I2C
+ * @{
+ */
+
+#ifndef _I2C_LLD_H_
+#define _I2C_LLD_H_
+
+#if HAL_USE_I2C || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+#define MTPR_VALUE ((TIVA_SYSCLK/(2*(6+4)*i2cp->config->clock_speed))-1)
+
+#define TIVA_MSA_RS (1 << 0)
+#define TIVA_MSA_SA (127 << 1)
+
+#define TIVA_MCS_BUSY (1 << 0)
+#define TIVA_MCS_ERROR (1 << 1)
+#define TIVA_MCS_ADRACK (1 << 2)
+#define TIVA_MCS_DATACK (1 << 3)
+#define TIVA_MCS_ARBLST (1 << 4)
+#define TIVA_MCS_IDLE (1 << 5)
+#define TIVA_MCS_BUSBSY (1 << 6)
+#define TIVA_MCS_CLKTO (1 << 7)
+
+#define TIVA_MCS_RUN (1 << 0)
+#define TIVA_MCS_START (1 << 1)
+#define TIVA_MCS_STOP (1 << 2)
+#define TIVA_MCS_ACK (1 << 3)
+#define TIVA_MCS_HS (1 << 4)
+
+#define TIVA_I2C_SIGNLE_SEND (TIVA_MCS_RUN | TIVA_MCS_START | TIVA_MCS_STOP)
+#define TIVA_I2C_BURST_SEND_START (TIVA_MCS_RUN | TIVA_MCS_START)
+#define TIVA_I2C_BURST_SEND_CONTINUE (TIVA_MCS_RUN)
+#define TIVA_I2C_BURST_SEND_FINISH (TIVA_MCS_RUN | TIVA_MCS_STOP)
+#define TIVA_I2C_BURST_SEND_STOP (TIVA_MCS_STOP)
+#define TIVA_I2C_BURST_SEND_ERROR_STOP (TIVA_MCS_STOP)
+
+#define TIVA_I2C_SINGLE_RECEIVE (TIVA_MCS_RUN | TIVA_MCS_START | TIVA_MCS_STOP)
+#define TIVA_I2C_BURST_RECEIVE_START (TIVA_MCS_RUN | TIVA_MCS_START | TIVA_MCS_ACK)
+#define TIVA_I2C_BURST_RECEIVE_CONTINUE (TIVA_MCS_RUN | TIVA_MCS_ACK)
+#define TIVA_I2C_BURST_RECEIVE_FINISH (TIVA_MCS_RUN | TIVA_MCS_STOP)
+#define TIVA_I2C_BURST_RECEIVE_ERROR_STOP (TIVA_MCS_STOP)
+
+#define TIVA_MDR_DATA (255 << 0)
+
+#define TIVA_MTPR_TPR (127 << 0)
+#define TIVA_MTPR_HS (1 << 7)
+
+#define TIVA_MIMR_IM (1 << 0)
+#define TIVA_MIMR_CLKIM (1 << 1)
+
+#define TIVA_MRIS_RIS (1 << 0)
+#define TIVA_MRIS_CLKRIS (1 << 1)
+
+#define TIVA_MMIS_MIS (1 << 0)
+#define TIVA_MMIS_CLKMIS (1 << 1)
+
+#define TIVA_MICR_IC (1 << 0)
+#define TIVA_MICR_CLKIC (1 << 1)
+
+#define TIVA_MCR_LPBK (1 << 0)
+#define TIVA_MCR_MFE (1 << 4)
+#define TIVA_MCR_SFE (1 << 5)
+#define TIVA_MCR_GFE (1 << 6)
+
+#define TIVA_MCLKOCNT_CNTL (255 << 0)
+
+#define TIVA_MBMON_SCL (1 << 0)
+#define TIVA_MBMON_SDA (1 << 1)
+
+#define TIVA_MCR2_GFPW (7 << 4)
+
+// interrupt states
+#define STATE_IDLE 0
+#define STATE_WRITE_NEXT 1
+#define STATE_WRITE_FINAL 2
+#define STATE_WAIT_ACK 3
+#define STATE_SEND_ACK 4
+#define STATE_READ_ONE 5
+#define STATE_READ_FIRST 6
+#define STATE_READ_NEXT 7
+#define STATE_READ_FINAL 8
+#define STATE_READ_WAIT 9
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @name Configuration options
+ * @{
+ */
+
+/**
+ * @brief I2C0 driver enable switch.
+ * @details If set to @p TRUE the support for I2C0 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_I2C_USE_I2C0) || defined(__DOXYGEN__)
+#define TIVA_I2C_USE_I2C0 FALSE
+#endif
+
+/**
+ * @brief I2C1 driver enable switch.
+ * @details If set to @p TRUE the support for I2C1 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_I2C_USE_I2C1) || defined(__DOXYGEN__)
+#define TIVA_I2C_USE_I2C1 FALSE
+#endif
+
+/**
+ * @brief I2C2 driver enable switch.
+ * @details If set to @p TRUE the support for I2C2 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_I2C_USE_I2C2) || defined(__DOXYGEN__)
+#define TIVA_I2C_USE_I2C2 FALSE
+#endif
+
+/**
+ * @brief I2C3 driver enable switch.
+ * @details If set to @p TRUE the support for I2C3 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_I2C_USE_I2C3) || defined(__DOXYGEN__)
+#define TIVA_I2C_USE_I2C3 FALSE
+#endif
+
+/**
+ * @brief I2C4 driver enable switch.
+ * @details If set to @p TRUE the support for I2C4 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_I2C_USE_I2C4) || defined(__DOXYGEN__)
+#define TIVA_I2C_USE_I2C4 FALSE
+#endif
+
+/**
+ * @brief I2C5 driver enable switch.
+ * @details If set to @p TRUE the support for I2C5 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_I2C_USE_I2C5) || defined(__DOXYGEN__)
+#define TIVA_I2C_USE_I2C5 FALSE
+#endif
+
+/**
+ * @brief I2C6 driver enable switch.
+ * @details If set to @p TRUE the support for I2C6 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_I2C_USE_I2C6) || defined(__DOXYGEN__)
+#define TIVA_I2C_USE_I2C6 FALSE
+#endif
+
+/**
+ * @brief I2C7 driver enable switch.
+ * @details If set to @p TRUE the support for I2C7 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_I2C_USE_I2C7) || defined(__DOXYGEN__)
+#define TIVA_I2C_USE_I2C7 FALSE
+#endif
+
+/**
+ * @brief I2C8 driver enable switch.
+ * @details If set to @p TRUE the support for I2C8 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_I2C_USE_I2C8) || defined(__DOXYGEN__)
+#define TIVA_I2C_USE_I2C8 FALSE
+#endif
+
+/**
+ * @brief I2C9 driver enable switch.
+ * @details If set to @p TRUE the support for I2C9 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_I2C_USE_I2C9) || defined(__DOXYGEN__)
+#define TIVA_I2C_USE_I2C9 FALSE
+#endif
+
+/**
+ * @brief I2C timeout on busy condition in milliseconds.
+ */
+#if !defined(TIVA_I2C_BUSY_TIMEOUT) || defined(__DOXYGEN__)
+#define TIVA_I2C_BUSY_TIMEOUT 50
+#endif
+
+/**
+ * @brief I2C0 interrupt priority level setting.
+ */
+#if !defined(TIVA_I2C_I2C0_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_I2C_I2C0_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief I2C1 interrupt priority level setting.
+ */
+#if !defined(TIVA_I2C_I2C1_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_I2C_I2C1_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief I2C2 interrupt priority level setting.
+ */
+#if !defined(TIVA_I2C_I2C2_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_I2C_I2C2_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief I2C3 interrupt priority level setting.
+ */
+#if !defined(TIVA_I2C_I2C3_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_I2C_I2C3_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief I2C4 interrupt priority level setting.
+ */
+#if !defined(TIVA_I2C_I2C4_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_I2C_I2C4_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief I2C5 interrupt priority level setting.
+ */
+#if !defined(TIVA_I2C_I2C5_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_I2C_I2C5_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief I2C6 interrupt priority level setting.
+ */
+#if !defined(TIVA_I2C_I2C6_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_I2C_I2C6_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief I2C7 interrupt priority level setting.
+ */
+#if !defined(TIVA_I2C_I2C7_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_I2C_I2C7_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief I2C8 interrupt priority level setting.
+ */
+#if !defined(TIVA_I2C_I2C8_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_I2C_I2C8_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief I2C9 interrupt priority level setting.
+ */
+#if !defined(TIVA_I2C_I2C9_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_I2C_I2C9_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @}
+ */
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+/**
+ * @brief error checks
+ */
+#if !TIVA_I2C_USE_I2C0 && !TIVA_I2C_USE_I2C1 && !TIVA_I2C_USE_I2C2 && \
+ !TIVA_I2C_USE_I2C3 && !TIVA_I2C_USE_I2C4 && !TIVA_I2C_USE_I2C5 && \
+ !TIVA_I2C_USE_I2C6 && !TIVA_I2C_USE_I2C7 && !TIVA_I2C_USE_I2C8 && \
+ !TIVA_I2C_USE_I2C9
+#error "I2C driver activated but no I2C peripheral assigned"
+#endif
+
+#if TIVA_I2C_USE_I2C0 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_I2C_I2C0_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to I2C0"
+#endif
+
+#if TIVA_I2C_USE_I2C1 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_I2C_I2C1_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to I2C1"
+#endif
+
+#if TIVA_I2C_USE_I2C2 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_I2C_I2C2_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to I2C2"
+#endif
+
+#if TIVA_I2C_USE_I2C3 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_I2C_I2C3_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to I2C3"
+#endif
+
+#if TIVA_I2C_USE_I2C4 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_I2C_I2C4_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to I2C4"
+#endif
+
+#if TIVA_I2C_USE_I2C5 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_I2C_I2C5_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to I2C5"
+#endif
+
+#if TIVA_I2C_USE_I2C6 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_I2C_I2C6_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to I2C6"
+#endif
+
+#if TIVA_I2C_USE_I2C7 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_I2C_I2C7_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to I2C7"
+#endif
+
+#if TIVA_I2C_USE_I2C8 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_I2C_I2C8_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to I2C8"
+#endif
+
+#if TIVA_I2C_USE_I2C9 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_I2C_I2C9_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to I2C9"
+#endif
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Type representing I2C address.
+ */
+typedef uint16_t i2caddr_t;
+
+/**
+ * @brief I2C Driver condition flags type.
+ */
+typedef uint32_t i2cflags_t;
+
+/**
+ * @brief Driver configuration structure.
+ */
+typedef struct
+{
+ /**
+ * @brief Specifies the clock frequency.
+ * @note Must be set to a value lower than 3.33Mbps.
+ * TODO: high-speed mode: 3333 kHz. setup is 100-400-1000 kHz then switched to 3333 kHz
+ */
+ uint32_t clock_speed;
+} I2CConfig;
+
+/**
+ * @brief Type of a structure representing an I2C driver.
+ */
+typedef struct I2CDriver I2CDriver;
+
+/**
+ * @brief Structure representing an I2C driver.
+ */
+struct I2CDriver {
+ /**
+ * @brief Driver state.
+ */
+ i2cstate_t state;
+ /**
+ * @brief Current configuration data.
+ */
+ const I2CConfig *config;
+ /**
+ * @brief Error flags.
+ */
+ i2cflags_t errors;
+#if I2C_USE_MUTUAL_EXCLUSION || defined(__DOXYGEN__)
+ /**
+ * @brief Mutex protecting the bus.
+ */
+ mutex_t mutex;
+#endif /* I2C_USE_MUTUAL_EXCLUSION */
+#if defined(I2C_DRIVER_EXT_FIELDS)
+ I2C_DRIVER_EXT_FIELDS
+#endif
+ /* End of the mandatory fields.*/
+ /**
+ * @brief Thread waiting for I/O completion.
+ */
+ thread_reference_t thread;
+ /**
+ * @brief Current slave address without R/W bit.
+ */
+ i2caddr_t addr;
+ /**
+ * @brief Pointer to the buffer with data to send.
+ */
+ const uint8_t *txbuf;
+ /**
+ * @brief Number of bytes of data to send.
+ */
+ size_t txbytes;
+ /**
+ * @brief Pointer to the buffer to put received data.
+ */
+ uint8_t *rxbuf;
+ /**
+ * @brief Number of bytes of data to receive.
+ */
+ size_t rxbytes;
+ /**
+ * @brief State of the interrupt state machine.
+ *
+ * TODO is it possible to remove the interrupt state?
+ */
+ uint8_t intstate;
+ /**
+ * @brief Pointer to the I2Cx registers block.
+ */
+ I2C_TypeDef *i2c;
+};
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/**
+ * @brief Get errors from I2C driver.
+ *
+ * @param[in] i2cp pointer to the @p I2CDriver object
+ *
+ * @notapi
+ */
+#define i2c_lld_get_errors(i2cp) ((i2cp)->errors)
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#if !defined(__DOXYGEN__)
+#if TIVA_I2C_USE_I2C0
+extern I2CDriver I2CD1;
+#endif
+
+#if TIVA_I2C_USE_I2C1
+extern I2CDriver I2CD2;
+#endif
+
+#if TIVA_I2C_USE_I2C2
+extern I2CDriver I2CD3;
+#endif
+
+#if TIVA_I2C_USE_I2C3
+extern I2CDriver I2CD4;
+#endif
+
+#if TIVA_I2C_USE_I2C4
+extern I2CDriver I2CD5;
+#endif
+
+#if TIVA_I2C_USE_I2C5
+extern I2CDriver I2CD6;
+#endif
+
+#if TIVA_I2C_USE_I2C6
+extern I2CDriver I2CD7;
+#endif
+
+#if TIVA_I2C_USE_I2C7
+extern I2CDriver I2CD8;
+#endif
+
+#if TIVA_I2C_USE_I2C8
+extern I2CDriver I2CD9;
+#endif
+
+#if TIVA_I2C_USE_I2C9
+extern I2CDriver I2CD10;
+#endif
+
+#endif /* !defined(__DOXYGEN__) */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void i2c_lld_init(void);
+ void i2c_lld_start(I2CDriver *i2cp);
+ void i2c_lld_stop(I2CDriver *i2cp);
+ msg_t i2c_lld_master_transmit_timeout(I2CDriver *i2cp, i2caddr_t addr,
+ const uint8_t *txbuf, size_t txbytes,
+ uint8_t *rxbuf, size_t rxbytes,
+ systime_t timeout);
+ msg_t i2c_lld_master_receive_timeout(I2CDriver *i2cp, i2caddr_t addr,
+ uint8_t *rxbuf, size_t rxbytes,
+ systime_t timeout);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_I2C */
+
+#endif /* _I2C_LLD_H_ */
+
+/** @} */
diff --git a/os/hal/ports/TIVA/LLD/pal_lld.c b/os/hal/ports/TIVA/LLD/pal_lld.c
new file mode 100644
index 0000000..657f982
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/pal_lld.c
@@ -0,0 +1,313 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file TIVA/LLD/pal_lld.c
+ * @brief TM4C123x/TM4C129x PAL subsystem low level driver.
+ *
+ * @addtogroup PAL
+ * @{
+ */
+
+#include "hal.h"
+
+#if HAL_USE_PAL || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#define RCGCGPIOA (1 << 0)
+#define RCGCGPIOB (1 << 1)
+#define RCGCGPIOC (1 << 2)
+#define RCGCGPIOD (1 << 3)
+#define RCGCGPIOE (1 << 4)
+#define RCGCGPIOF (1 << 5)
+
+#if TIVA_HAS_GPIOG || defined(__DOXYGEN__)
+#define RCGCGPIOG (1 << 6)
+#else
+#define RCGCGPIOG 0
+#endif
+
+#if TIVA_HAS_GPIOH || defined(__DOXYGEN__)
+#define RCGCGPIOH (1 << 7)
+#else
+#define RCGCGPIOH 0
+#endif
+
+#if TIVA_HAS_GPIOJ || defined(__DOXYGEN__)
+#define RCGCGPIOJ (1 << 8)
+#else
+#define RCGCGPIOJ 0
+#endif
+
+#if TIVA_HAS_GPIOK || defined(__DOXYGEN__)
+#define RCGCGPIOK (1 << 9)
+#else
+#define RCGCGPIOK 0
+#endif
+
+#if TIVA_HAS_GPIOL || defined(__DOXYGEN__)
+#define RCGCGPIOL (1 << 10)
+#else
+#define RCGCGPIOL 0
+#endif
+
+#if TIVA_HAS_GPIOM || defined(__DOXYGEN__)
+#define RCGCGPIOM (1 << 11)
+#else
+#define RCGCGPIOM 0
+#endif
+
+#if TIVA_HAS_GPION || defined(__DOXYGEN__)
+#define RCGCGPION (1 << 12)
+#else
+#define RCGCGPION 0
+#endif
+
+#if TIVA_HAS_GPIOP || defined(__DOXYGEN__)
+#define RCGCGPIOP (1 << 13)
+#else
+#define RCGCGPIOP 0
+#endif
+
+#if TIVA_HAS_GPIOQ || defined(__DOXYGEN__)
+#define RCGCGPIOQ (1 << 14)
+#else
+#define RCGCGPIOQ 0
+#endif
+
+#if TIVA_HAS_GPIOR || defined(__DOXYGEN__)
+#define RCGCGPIOR (1 << 15)
+#else
+#define RCGCGPIOR 0
+#endif
+
+#if TIVA_HAS_GPIOS || defined(__DOXYGEN__)
+#define RCGCGPIOS (1 << 16)
+#else
+#define RCGCGPIOS 0
+#endif
+
+#if TIVA_HAS_GPIOT || defined(__DOXYGEN__)
+#define RCGCGPIOT (1 << 17)
+#else
+#define RCGCGPIOT 0
+#endif
+
+#define RCGCGPIO_VALUE (RCGCGPIOA | RCGCGPIOB | RCGCGPIOC | RCGCGPIOD | \
+ RCGCGPIOE | RCGCGPIOF | RCGCGPIOG | RCGCGPIOH | \
+ RCGCGPIOJ | RCGCGPIOK | RCGCGPIOL | RCGCGPIOM | \
+ RCGCGPION | RCGCGPIOP | RCGCGPIOQ | RCGCGPIOR | \
+ RCGCGPIOS | RCGCGPIOT)
+
+/* GPIO lock password.*/
+#define TIVA_GPIO_LOCK_PWD 0x4C4F434B
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+void gpio_init (GPIO_TypeDef *gpiop, const tiva_gpio_setup_t *config)
+{
+ gpiop->DATA = config->data;
+ gpiop->DIR = config->dir;
+ gpiop->AFSEL = config->afsel;
+ gpiop->DR2R = config->dr2r;
+ gpiop->DR4R = config->dr4r;
+ gpiop->DR8R = config->dr8r;
+ gpiop->ODR = config->odr;
+ gpiop->PUR = config->pur;
+ gpiop->PDR = config->pdr;
+ gpiop->SLR = config->slr;
+ gpiop->DEN = config->den;
+ gpiop->AMSEL = config->amsel;
+ gpiop->PCTL = config->pctl;
+}
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief TIVA I/O ports configuration.
+ * @details Ports A-F (G, H, J, K, L, M, N, P, Q, R, S, T) clocks enabled.
+ *
+ * @param[in] config the TIVA ports configuration
+ *
+ * @notapi
+ */
+void _pal_lld_init(const PALConfig *config)
+{
+ SYSCTL->RCGCGPIO = RCGCGPIO_VALUE;
+
+ __NOP();
+ __NOP();
+ __NOP();
+
+ gpio_init(GPIOA, &config->PAData);
+
+ gpio_init(GPIOB, &config->PBData);
+
+ GPIOC->LOCK = TIVA_GPIO_LOCK_PWD;
+ GPIOC->CR = 0x01;
+ gpio_init(GPIOC, &config->PCData);
+ GPIOC->LOCK = 0;
+
+ gpio_init(GPIOD, &config->PDData);
+
+ gpio_init(GPIOE, &config->PEData);
+
+ GPIOF->LOCK = TIVA_GPIO_LOCK_PWD;
+ GPIOF->CR = 0x01;
+ gpio_init(GPIOF, &config->PFData);
+ GPIOF->LOCK = 0;
+
+#if TIVA_HAS_GPIOG || defined(__DOXYGEN__)
+ gpio_init(GPIOG, &config->PGData);
+#endif /* TIVA_HAS_GPIOG.*/
+
+#if TIVA_HAS_GPIOH || defined(__DOXYGEN__)
+ gpio_init(GPIOH, &config->PHData);
+#endif /* TIVA_HAS_GPIOH.*/
+
+#if TIVA_HAS_GPIOJ || defined(__DOXYGEN__)
+ gpio_init(GPIOJ, &config->PJData);
+#endif /* TIVA_HAS_GPIOJ.*/
+
+#if TIVA_HAS_GPIOK || defined(__DOXYGEN__)
+ gpio_init(GPIOK, &config->PKData);
+#endif /* TIVA_HAS_GPIOK.*/
+
+#if TIVA_HAS_GPIOL || defined(__DOXYGEN__)
+ gpio_init(GPIOL, &config->PLData);
+#endif /* TIVA_HAS_GPIOL.*/
+
+#if TIVA_HAS_GPIOM || defined(__DOXYGEN__)
+ gpio_init(GPIOM, &config->PMData);
+#endif /* TIVA_HAS_GPIOM.*/
+
+#if TIVA_HAS_GPION || defined(__DOXYGEN__)
+ gpio_init(GPION, &config->PNData);
+#endif /* TIVA_HAS_GPION.*/
+
+#if TIVA_HAS_GPIOP || defined(__DOXYGEN__)
+ gpio_init(GPIOP, &config->PPData);
+#endif /* TIVA_HAS_GPIOP.*/
+
+#if TIVA_HAS_GPIOQ || defined(__DOXYGEN__)
+ gpio_init(GPIOQ, &config->PQData);
+#endif /* TIVA_HAS_GPIOQ.*/
+
+#if TIVA_HAS_GPIOR || defined(__DOXYGEN__)
+ gpio_init(GPIOR, &config->PRData);
+#endif /* TIVA_HAS_GPIOR.*/
+
+#if TIVA_HAS_GPIOS || defined(__DOXYGEN__)
+ gpio_init(GPIOS, &config->PSData);
+#endif /* TIVA_HAS_GPIOS.*/
+
+#if TIVA_HAS_GPIOT || defined(__DOXYGEN__)
+ gpio_init(GPIOT, &config->PTData);
+#endif /* TIVA_HAS_GPIOT.*/
+}
+
+/**
+ * @brief Pads mode setup.
+ * @details This function programs a pads group belonging to the same port
+ * with the specified mode.
+ *
+ * @param[in] port the port identifier
+ * @param[in] mask the group mask
+ * @param[in] mode the mode
+ *
+ * @notapi
+ */
+void _pal_lld_setgroupmode(ioportid_t port,
+ ioportmask_t mask,
+ iomode_t mode)
+{
+ /* TODO: What does this function exactly do? The pins are already configured
+ * in board.h and initialized by the pal driver. */
+
+ (void) port;
+ (void) mask;
+ (void) mode;
+
+ /*
+ switch (mode) {
+ case PAL_MODE_UNCONNECTED:
+ case PAL_MODE_INPUT_PULLUP:
+ port->PUR |= mask;
+ case PAL_MODE_INPUT:
+ port->AFSEL &= ~mask;
+ port->DIR &= ~mask;
+ port->ODR &= ~mask;
+ port->DEN |= mask;
+ break;
+
+ case PAL_MODE_INPUT_PULLDOWN:
+ port->AFSEL &= ~mask;
+ port->DIR &= ~mask;
+ port->ODR &= ~mask;
+ port->DEN |= mask;
+ port->PDR |= mask;
+ break;
+
+ case PAL_MODE_RESET:
+ case PAL_MODE_INPUT_ANALOG:
+ port->AFSEL &= ~mask;
+ port->DIR &= ~mask;
+ port->ODR &= ~mask;
+ port->DEN &= ~mask;
+ port->PUR &= ~mask;
+ port->PDR &= ~mask;
+ break;
+
+ case PAL_MODE_OUTPUT_PUSHPULL:
+ port->AFSEL &= ~mask;
+ port->DIR |= mask;
+ port->ODR &= ~mask;
+ port->DEN |= mask;
+ break;
+
+ case PAL_MODE_OUTPUT_OPENDRAIN:
+ port->AFSEL &= ~mask;
+ port->DIR |= mask;
+ port->ODR |= mask;
+ port->DEN |= mask;
+ break;
+ }*/
+}
+
+#endif /* HAL_USE_PAL */
+
+/**
+ * @}
+ */
diff --git a/os/hal/ports/TIVA/LLD/pal_lld.h b/os/hal/ports/TIVA/LLD/pal_lld.h
new file mode 100644
index 0000000..a87e5fd
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/pal_lld.h
@@ -0,0 +1,466 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file TIVA/LLD/pal_lld.h
+ * @brief TM4C123x/TM4C129x PAL subsystem low level driver header.
+ *
+ * @addtogroup PAL
+ * @{
+ */
+
+#ifndef _PAL_LLD_H_
+#define _PAL_LLD_H_
+
+#if HAL_USE_PAL || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Unsupported modes and specific modes */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* I/O Ports Types and constants. */
+/*===========================================================================*/
+
+/**
+ * @brief GPIO port setup info.
+ */
+typedef struct
+{
+ /** @brief Initial value for DATA register.*/
+ uint32_t data;
+ /** @brief Initial value for DIR register.*/
+ uint32_t dir;
+ /** @brief Initial value for AFSEL register.*/
+ uint32_t afsel;
+ /** @brief Initial value for DR2R register.*/
+ uint32_t dr2r;
+ /** @brief Initial value for DR4R register.*/
+ uint32_t dr4r;
+ /** @brief Initial value for DR8R register.*/
+ uint32_t dr8r;
+ /** @brief Initial value for ODR register.*/
+ uint32_t odr;
+ /** @brief Initial value for PUR register.*/
+ uint32_t pur;
+ /** @brief Initial value for PDR register.*/
+ uint32_t pdr;
+ /** @brief Initial value for SLR register.*/
+ uint32_t slr;
+ /** @brief Initial value for DEN register.*/
+ uint32_t den;
+ /** @brief Initial value for AMSEL register.*/
+ uint32_t amsel;
+ /** @brief Initial value for PCTL register.*/
+ uint32_t pctl;
+} tiva_gpio_setup_t;
+
+/**
+ * @brief Tiva GPIO static initializer.
+ * @details An instance of this structure must be passed to @p palInit() at
+ * system startup time in order to initialized the digital I/O
+ * subsystem. This represents only the initial setup, specific pads
+ * or whole ports can be reprogrammed at later time.
+ */
+typedef struct
+{
+ /** @brief Port A setup data.*/
+ tiva_gpio_setup_t PAData;
+ /** @brief Port B setup data.*/
+ tiva_gpio_setup_t PBData;
+ /** @brief Port C setup data.*/
+ tiva_gpio_setup_t PCData;
+ /** @brief Port D setup data.*/
+ tiva_gpio_setup_t PDData;
+ /** @brief Port E setup data.*/
+ tiva_gpio_setup_t PEData;
+ /** @brief Port F setup data.*/
+ tiva_gpio_setup_t PFData;
+
+#if TIVA_HAS_GPIOG || defined(__DOXYGEN__)
+ /** @brief Port G setup data.*/
+ tiva_gpio_setup_t PGData;
+#endif /* TIVA_HAS_GPIOG.*/
+
+#if TIVA_HAS_GPIOH || defined(__DOXYGEN__)
+ /** @brief Port H setup data.*/
+ tiva_gpio_setup_t PHData;
+#endif /* TIVA_HAS_GPIOH.*/
+
+#if TIVA_HAS_GPIOJ || defined(__DOXYGEN__)
+ /** @brief Port J setup data.*/
+ tiva_gpio_setup_t PJData;
+#endif /* TIVA_HAS_GPIOJ.*/
+
+#if TIVA_HAS_GPIOK || defined(__DOXYGEN__)
+ /** @brief Port K setup data.*/
+ tiva_gpio_setup_t PKData;
+#endif /* TIVA_HAS_GPIOK.*/
+
+#if TIVA_HAS_GPIOL || defined(__DOXYGEN__)
+ /** @brief Port L setup data.*/
+ tiva_gpio_setup_t PLData;
+#endif /* TIVA_HAS_GPIOL.*/
+
+#if TIVA_HAS_GPIOM || defined(__DOXYGEN__)
+ /** @brief Port M setup data.*/
+ tiva_gpio_setup_t PMData;
+#endif /* TIVA_HAS_GPIOM.*/
+
+#if TIVA_HAS_GPION || defined(__DOXYGEN__)
+ /** @brief Port N setup data.*/
+ tiva_gpio_setup_t PNData;
+#endif /* TIVA_HAS_GPION.*/
+
+#if TIVA_HAS_GPIOP || defined(__DOXYGEN__)
+ /** @brief Port P setup data.*/
+ tiva_gpio_setup_t PPData;
+#endif /* TIVA_HAS_GPIOP.*/
+
+#if TIVA_HAS_GPIOQ || defined(__DOXYGEN__)
+ /** @brief Port Q setup data.*/
+ tiva_gpio_setup_t PQData;
+#endif /* TIVA_HAS_GPIOQ.*/
+
+#if TIVA_HAS_GPIOR || defined(__DOXYGEN__)
+ /** @brief Port R setup data.*/
+ tiva_gpio_setup_t PRData;
+#endif /* TIVA_HAS_GPIOR.*/
+
+#if TIVA_HAS_GPIOS || defined(__DOXYGEN__)
+ /** @brief Port S setup data.*/
+ tiva_gpio_setup_t PSData;
+#endif /* TIVA_HAS_GPIOS.*/
+
+#if TIVA_HAS_GPIOT || defined(__DOXYGEN__)
+ /** @brief Port T setup data.*/
+ tiva_gpio_setup_t PTData;
+#endif /* TIVA_HAS_GPIOT.*/
+} PALConfig;
+
+/**
+ * @brief Width, in bits, of an I/O port.
+ */
+#define PAL_IOPORTS_WIDTH 8
+
+/**
+ * @brief Whole port mask.
+ * @brief This macro specifies all the valid bits into a port.
+ */
+#define PAL_WHOLE_PORT ((ioportmask_t)0xFF)
+
+/**
+ * @brief Digital I/O port sized unsigned type.
+ */
+typedef uint32_t ioportmask_t;
+
+/**
+ * @brief Digital I/O modes.
+ */
+typedef uint32_t iomode_t;
+
+/**
+ * @brief Port Identifier.
+ */
+typedef GPIO_TypeDef *ioportid_t;
+
+/*===========================================================================*/
+/* I/O Ports Identifiers. */
+/*===========================================================================*/
+
+/** @brief GPIOA port identifier.*/
+#define IOPORT1 GPIOA
+
+/** @brief GPIOB port identifier.*/
+#define IOPORT2 GPIOB
+
+/** @brief GPIOC port identifier.*/
+#define IOPORT3 GPIOC
+
+/** @brief GPIOD port identifier.*/
+#define IOPORT4 GPIOD
+
+/** @brief GPIOE port identifier.*/
+#define IOPORT5 GPIOE
+
+/** @brief GPIOF port identifier.*/
+#define IOPORT6 GPIOF
+
+#if TIVA_HAS_GPIOG || defined(__DOXYGEN__)
+/** @brief Port G setup data.*/
+#define IOPORT7 GPIOG
+#endif /* TIVA_HAS_GPIOG.*/
+
+#if TIVA_HAS_GPIOH || defined(__DOXYGEN__)
+/** @brief Port H setup data.*/
+#define IOPORT8 GPIOH
+#endif /* TIVA_HAS_GPIOH.*/
+
+#if TIVA_HAS_GPIOJ || defined(__DOXYGEN__)
+/** @brief Port J setup data.*/
+#define IOPORT9 GPIOJ
+#endif /* TIVA_HAS_GPIOJ.*/
+
+#if TIVA_HAS_GPIOK || defined(__DOXYGEN__)
+/** @brief Port K setup data.*/
+#define IOPORT10 GPIOK
+#endif /* TIVA_HAS_GPIOK.*/
+
+#if TIVA_HAS_GPIOL || defined(__DOXYGEN__)
+/** @brief Port L setup data.*/
+#define IOPORT11 GPIOL
+#endif /* TIVA_HAS_GPIOL.*/
+
+#if TIVA_HAS_GPIOM || defined(__DOXYGEN__)
+/** @brief Port M setup data.*/
+#define IOPORT12 GPIOM
+#endif /* TIVA_HAS_GPIOM.*/
+
+#if TIVA_HAS_GPION || defined(__DOXYGEN__)
+/** @brief Port N setup data.*/
+#define IOPORT13 GPION
+#endif /* TIVA_HAS_GPION.*/
+
+#if TIVA_HAS_GPIOP || defined(__DOXYGEN__)
+/** @brief Port P setup data.*/
+#define IOPORT14 GPIOP
+#endif /* TIVA_HAS_GPIOP.*/
+
+#if TIVA_HAS_GPIOQ || defined(__DOXYGEN__)
+/** @brief Port Q setup data.*/
+#define IOPORT15 GPIOQ
+#endif /* TIVA_HAS_GPIOQ.*/
+
+#if TIVA_HAS_GPIOR || defined(__DOXYGEN__)
+/** @brief Port R setup data.*/
+#define IOPORT16 GPIOR
+#endif /* TIVA_HAS_GPIOR.*/
+
+#if TIVA_HAS_GPIOS || defined(__DOXYGEN__)
+/** @brief Port S setup data.*/
+#define IOPORT17 GPIOS
+#endif /* TIVA_HAS_GPIOS.*/
+
+#if TIVA_HAS_GPIOT || defined(__DOXYGEN__)
+/** @brief Port T setup data.*/
+#define IOPORT18 GPIOT
+#endif /* TIVA_HAS_GPIOT.*/
+
+/*===========================================================================*/
+/* Implementation, some of the following macros could be implemented as */
+/* functions, if so please put them in pal_lld.c. */
+/*===========================================================================*/
+
+/**
+ * @brief Low level PAL subsystem initialization.
+ *
+ * @param[in] config architecture-dependent ports configuration
+ *
+ * @notapi
+ */
+#define pal_lld_init(config) _pal_lld_init(config)
+
+/**
+ * @brief Reads the physical I/O port states.
+ *
+ * @param[in] port port identifier
+ * @return The port bits.
+ *
+ * @notapi
+ */
+#define pal_lld_readport(port) ((port)->DATA)
+
+/**
+ * @brief Reads the output latch.
+ * @details The purpose of this function is to read back the latched output
+ * value.
+ *
+ * @param[in] port port identifier
+ * @return The latched logical states.
+ *
+ * @notapi
+ */
+#define pal_lld_readlatch(port) ((port)->DATA)
+
+/**
+ * @brief Writes a bits mask on a I/O port.
+ *
+ * @param[in] port port identifier
+ * @param[in] bits bits to be written on the specified port
+ *
+ * @notapi
+ */
+#define pal_lld_writeport(port, bits) ((port)->DATA = (bits))
+
+/**
+ * @brief Sets a bits mask on a I/O port.
+ * @note The @ref PAL provides a default software implementation of this
+ * functionality, implement this function if can optimize it by using
+ * special hardware functionalities or special coding.
+ *
+ * @param[in] port port identifier
+ * @param[in] bits bits to be ORed on the specified port
+ *
+ * @notapi
+ */
+#define pal_lld_setport(port, bits) ((port)->MASKED_ACCESS[bits] = 0xFF)
+
+/**
+ * @brief Clears a bits mask on a I/O port.
+ * @note The @ref PAL provides a default software implementation of this
+ * functionality, implement this function if can optimize it by using
+ * special hardware functionalities or special coding.
+ *
+ * @param[in] port port identifier
+ * @param[in] bits bits to be cleared on the specified port
+ *
+ * @notapi
+ */
+#define pal_lld_clearport(port, bits) ((port)->MASKED_ACCESS[bits] = 0)
+
+/**
+ * @brief Reads a group of bits.
+ * @note The @ref PAL provides a default software implementation of this
+ * functionality, implement this function if can optimize it by using
+ * special hardware functionalities or special coding.
+ *
+ * @param[in] port port identifier
+ * @param[in] mask group mask
+ * @param[in] offset group bit offset within the port
+ * @return The group logical states.
+ *
+ * @notapi
+ */
+#define pal_lld_readgroup(port, mask, offset) \
+ ((port)->MASKED_ACCESS[(mask) << (offset)])
+
+/**
+ * @brief Writes a group of bits.
+ * @note The @ref PAL provides a default software implementation of this
+ * functionality, implement this function if can optimize it by using
+ * special hardware functionalities or special coding.
+ *
+ * @param[in] port port identifier
+ * @param[in] mask group mask
+ * @param[in] offset group bit offset within the port
+ * @param[in] bits bits to be written. Values exceeding the group width
+ * are masked.
+ *
+ * @notapi
+ */
+#define pal_lld_writegroup(port, mask, offset, bits) \
+ ((port)->MASKED_ACCESS[(mask) << (offset)] = (bits))
+
+/**
+ * @brief Pads group mode setup.
+ * @details This function programs a pads group belonging to the same port
+ * with the specified mode.
+ * @note Programming an unknown or unsupported mode is silently ignored.
+ *
+ * @param[in] port port identifier
+ * @param[in] mask group mask
+ * @param[in] offset group bit offset within the port
+ * @param[in] mode group mode
+ *
+ * @notapi
+ */
+#define pal_lld_setgroupmode(port, mask, offset, mode) \
+ _pal_lld_setgroupmode(port, mask << offset, mode)
+
+/**
+ * @brief Reads a logical state from an I/O pad.
+ * @note The @ref PAL provides a default software implementation of this
+ * functionality, implement this function if can optimize it by using
+ * special hardware functionalities or special coding.
+ *
+ * @param[in] port port identifier
+ * @param[in] pad pad number within the port
+ * @return The logical state.
+ * @retval PAL_LOW low logical state.
+ * @retval PAL_HIGH high logical state.
+ *
+ * @notapi
+ */
+#define pal_lld_readpad(port, pad) ((port)->MASKED_ACCESS[1 << (pad)])
+
+/**
+ * @brief Writes a logical state on an output pad.
+ * @note This function is not meant to be invoked directly by the
+ * application code.
+ * @note The @ref PAL provides a default software implementation of this
+ * functionality, implement this function if can optimize it by using
+ * special hardware functionalities or special coding.
+ *
+ * @param[in] port port identifier
+ * @param[in] pad pad number within the port
+ * @param[in] bit logical value, the value must be @p PAL_LOW or
+ * @p PAL_HIGH
+ *
+ * @notapi
+ */
+#define pal_lld_writepad(port, pad, bit) \
+ ((port)->MASKED_ACCESS[1 << (pad)] = (bit))
+
+/**
+ * @brief Sets a pad logical state to @p PAL_HIGH.
+ * @note The @ref PAL provides a default software implementation of this
+ * functionality, implement this function if can optimize it by using
+ * special hardware functionalities or special coding.
+ *
+ * @param[in] port port identifier
+ * @param[in] pad pad number within the port
+ *
+ * @notapi
+ */
+#define pal_lld_setpad(port, pad) \
+ ((port)->MASKED_ACCESS[1 << (pad)] = 1 << (pad))
+
+/**
+ * @brief Clears a pad logical state to @p PAL_LOW.
+ * @note The @ref PAL provides a default software implementation of this
+ * functionality, implement this function if can optimize it by using
+ * special hardware functionalities or special coding.
+ *
+ * @param[in] port port identifier
+ * @param[in] pad pad number within the port
+ *
+ * @notapi
+ */
+#define pal_lld_clearpad(port, pad) \
+ ((port)->MASKED_ACCESS[1 << (pad)] = 0)
+
+#if !defined(__DOXYGEN__)
+extern const PALConfig pal_default_config;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void _pal_lld_init(const PALConfig *config);
+ void _pal_lld_setgroupmode(ioportid_t port,
+ ioportmask_t mask,
+ iomode_t mode);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_PAL */
+
+#endif /* _PAL_LLD_H_ */
+
+/**
+ * @}
+ */
diff --git a/os/hal/ports/TIVA/LLD/pwm_lld.c b/os/hal/ports/TIVA/LLD/pwm_lld.c
new file mode 100644
index 0000000..c0ee9d7
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/pwm_lld.c
@@ -0,0 +1,577 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file TIVA/LLD/pwm_lld.c
+ * @brief TM4C123x/TM4C129x PWM subsystem low level driver.
+ *
+ * @addtogroup PWM
+ * @{
+ */
+
+#include "hal.h"
+
+#if HAL_USE_PWM || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#define PWM_INT_CMPBD (1 << 5)
+#define PWM_INT_CMPBU (1 << 4)
+#define PWM_INT_CMPAD (1 << 3)
+#define PWM_INT_CMPAU (1 << 2)
+#define PWM_INT_CNTLOAD (1 << 1)
+#define PWM_INT_CNTZERO (1 << 0)
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/**
+ * @brief PWMD1 driver identifier.
+ */
+#if TIVA_PWM_USE_PWM0 || defined(__DOXYGEN__)
+PWMDriver PWMD1;
+#endif
+
+/**
+ * @brief PWMD2 driver identifier.
+ */
+#if TIVA_PWM_USE_PWM1 || defined(__DOXYGEN__)
+PWMDriver PWMD2;
+#endif
+
+/*===========================================================================*/
+/* Driver local variables and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Common PWM Generator IRQ handler.
+ * @note It is assumed that the various sources are only activated if the
+ * associated callback pointer is not equal to @p NULL in order to not
+ * perform an extra check in a potentially critical interrupt handler.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ * @param[in] i pwm generator number
+ */
+static void pwm_lld_serve_generator_interrupt (PWMDriver *pwmp, uint8_t i)
+{
+ uint32_t isc;
+
+ isc = pwmp->pwm->PWM[i].ISC;
+ pwmp->pwm->PWM[i].ISC = isc;
+
+ if (((isc & PWM_INT_CMPAD) != 0) &&
+ (pwmp->config->channels[i * 2 + 0].callback != NULL)) {
+ pwmp->config->channels[i * 2 + 0].callback(pwmp);
+ }
+
+ if (((isc & PWM_INT_CMPAU) != 0) &&
+ (pwmp->config->channels[i * 2 + 0].callback != NULL)) {
+ pwmp->config->channels[i * 2 + 0].callback(pwmp);
+ }
+
+ if (((isc & PWM_INT_CMPBD) != 0) &&
+ (pwmp->config->channels[i * 2 + 1].callback != NULL)) {
+ pwmp->config->channels[i * 2 + 1].callback(pwmp);
+ }
+
+ if (((isc & PWM_INT_CMPBU) != 0) &&
+ (pwmp->config->channels[i * 2 + 1].callback != NULL)) {
+ pwmp->config->channels[i * 2 + 1].callback(pwmp);
+ }
+
+ if (((isc & PWM_INT_CNTLOAD) != 0) && (pwmp->config->callback != NULL)) {
+ pwmp->config->callback(pwmp);
+ }
+
+ if (((isc & PWM_INT_CNTZERO) != 0) && (pwmp->config->callback != NULL)) {
+ pwmp->config->callback(pwmp);
+ }
+}
+
+/**
+ * @brief Common PWM fault IRQ handler.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ */
+static void pwm_lld_serve_fault_interrupt (PWMDriver *pwmp)
+{
+ (void) pwmp;
+}
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+#if TIVA_PWM_USE_PWM0
+#if !defined(TIVA_PWM0FAULT_HANDLER)
+#error "TIVA_PWM0FAULT_HANDLER not defined"
+#endif
+/*
+ * @brief PWM0 Fault handler
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_PWM0FAULT_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ pwm_lld_serve_fault_interrupt(&PWMD1);
+
+ OSAL_IRQ_EPILOGUE();
+}
+
+#if !defined(TIVA_PWM0GEN0_HANDLER)
+#error "TIVA_PWM0GEN0_HANDLER not defined"
+#endif
+/*
+ * @brief PWM0 Generator 0 handler
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_PWM0GEN0_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ pwm_lld_serve_generator_interrupt(&PWMD1, 0);
+
+ OSAL_IRQ_EPILOGUE();
+}
+
+#if !defined(TIVA_PWM0GEN1_HANDLER)
+#error "TIVA_PWM0GEN1_HANDLER not defined"
+#endif
+/*
+ * @brief PWM0 Generator 1 handler
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_PWM0GEN1_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ pwm_lld_serve_generator_interrupt(&PWMD1, 1);
+
+ OSAL_IRQ_EPILOGUE();
+}
+
+#if !defined(TIVA_PWM0GEN2_HANDLER)
+#error "TIVA_PWM0GEN2_HANDLER not defined"
+#endif
+/*
+ * @brief PWM0 Generator 2 handler
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_PWM0GEN2_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ pwm_lld_serve_generator_interrupt(&PWMD1, 2);
+
+ OSAL_IRQ_EPILOGUE();
+}
+
+#if !defined(TIVA_PWM0GEN3_HANDLER)
+#error "TIVA_PWM0GEN3_HANDLER not defined"
+#endif
+/*
+ * @brief PWM0 Generator 3 handler
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_PWM0GEN3_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ pwm_lld_serve_generator_interrupt(&PWMD1, 3);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+#if TIVA_PWM_USE_PWM1
+#if !defined(TIVA_PWM1FAULT_HANDLER)
+#error "TIVA_PWM1FAULT_HANDLER not defined"
+#endif
+/*
+ * @brief PWM1 Fault handler
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_PWM1FAULT_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ pwm_lld_serve_fault_interrupt(&PWMD2);
+
+ OSAL_IRQ_EPILOGUE();
+}
+
+#if !defined(TIVA_PWM1GEN0_HANDLER)
+#error "TIVA_PWM1GEN0_HANDLER not defined"
+#endif
+/*
+ * @brief PWM1 Generator 0 handler
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_PWM1GEN0_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ pwm_lld_serve_generator_interrupt(&PWMD2, 0);
+
+ OSAL_IRQ_EPILOGUE();
+}
+
+#if !defined(TIVA_PWM1GEN1_HANDLER)
+#error "TIVA_PWM1GEN1_HANDLER not defined"
+#endif
+/*
+ * @brief PWM1 Generator 1 handler
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_PWM1GEN1_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ pwm_lld_serve_generator_interrupt(&PWMD2, 1);
+
+ OSAL_IRQ_EPILOGUE();
+}
+
+#if !defined(TIVA_PWM1GEN2_HANDLER)
+#error "TIVA_PWM1GEN2_HANDLER not defined"
+#endif
+/*
+ * @brief PWM1 Generator 2 handler
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_PWM1GEN2_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ pwm_lld_serve_generator_interrupt(&PWMD2, 2);
+
+ OSAL_IRQ_EPILOGUE();
+}
+
+#if !defined(TIVA_PWM1GEN3_HANDLER)
+#error "TIVA_PWM1GEN3_HANDLER not defined"
+#endif
+/*
+ * @brief PWM1 Generator 3 handler
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(TIVA_PWM1GEN3_HANDLER)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ pwm_lld_serve_generator_interrupt(&PWMD2, 3);
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Low level PWM driver initialization.
+ *
+ * @notapi
+ */
+void pwm_lld_init(void)
+{
+ /* Driver initialization.*/
+#if TIVA_PWM_USE_PWM0
+ pwmObjectInit(&PWMD1);
+ PWMD1.channels = PWM_CHANNELS;
+ PWMD1.pwm = PWM0;
+#endif
+
+#if TIVA_PWM_USE_PWM1
+ pwmObjectInit(&PWMD2);
+ PWMD2.channels = PWM_CHANNELS;
+ PWMD2.pwm = PWM1;
+#endif
+}
+
+/**
+ * @brief Configures and activates the PWM peripheral.
+ * @note Starting a driver that is already in the @p PWM_READY state
+ * disables all the active channels.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ *
+ * @notapi
+ */
+void pwm_lld_start(PWMDriver *pwmp)
+{
+ uint8_t i;
+ uint32_t invert = 0;
+ uint32_t enable = 0;
+
+ if (pwmp->state == PWM_STOP) {
+ /* Clock activation.*/
+#if TIVA_PWM_USE_PWM0
+ if (&PWMD1 == pwmp) {
+ SYSCTL->RCGCPWM = (1 << 0);
+ nvicEnableVector(TIVA_PWM0FAULT_NUMBER,
+ TIVA_PWM_PWM0_FAULT_IRQ_PRIORITY);
+ nvicEnableVector(TIVA_PWM0GEN0_NUMBER, TIVA_PWM_PWM0_0_IRQ_PRIORITY);
+ nvicEnableVector(TIVA_PWM0GEN1_NUMBER, TIVA_PWM_PWM0_1_IRQ_PRIORITY);
+ nvicEnableVector(TIVA_PWM0GEN2_NUMBER, TIVA_PWM_PWM0_2_IRQ_PRIORITY);
+ nvicEnableVector(TIVA_PWM0GEN3_NUMBER, TIVA_PWM_PWM0_3_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_PWM_USE_PWM1
+ if (&PWMD2 == pwmp) {
+ SYSCTL->RCGCPWM = (1 << 1);
+ nvicEnableVector(TIVA_PWM1FAULT_NUMBER,
+ TIVA_PWM_PWM1_FAULT_IRQ_PRIORITY);
+ nvicEnableVector(TIVA_PWM1GEN0_NUMBER, TIVA_PWM_PWM1_0_IRQ_PRIORITY);
+ nvicEnableVector(TIVA_PWM1GEN1_NUMBER, TIVA_PWM_PWM1_1_IRQ_PRIORITY);
+ nvicEnableVector(TIVA_PWM1GEN2_NUMBER, TIVA_PWM_PWM1_2_IRQ_PRIORITY);
+ nvicEnableVector(TIVA_PWM1GEN3_NUMBER, TIVA_PWM_PWM1_3_IRQ_PRIORITY);
+ }
+#endif
+ }
+ else {
+ /* Driver re-configuration scenario, it must be stopped first.*/
+ pwmp->pwm->PWM[0].CTL = 0;
+ pwmp->pwm->PWM[1].CTL = 0;
+ pwmp->pwm->PWM[2].CTL = 0;
+ pwmp->pwm->PWM[3].CTL = 0;
+ }
+
+ /* Timer configuration.*/
+ for (i = 0; i < (PWM_CHANNELS >> 1); i++) {
+ pwmp->pwm->PWM[i].CTL = 0;
+ pwmp->pwm->PWM[i].GEN[0] = 0x08C;
+ pwmp->pwm->PWM[i].GEN[1] = 0x80C;
+ pwmp->pwm->PWM[i].LOAD = (uint16_t)(pwmp->config->frequency - 1);
+ pwmp->pwm->PWM[i].CMP[0] = (uint16_t)(pwmp->period - 1);
+ pwmp->pwm->PWM[i].CMP[1] = (uint16_t)(pwmp->period - 1);
+ }
+
+ /* Output enables and polarities setup.*/
+ for (i = 0; i < PWM_CHANNELS; i++) {
+ switch (pwmp->config->channels[i].mode & PWM_OUTPUT_MASK) {
+ case PWM_OUTPUT_DISABLED:
+ enable &= ~(1 << i);
+ break;
+ case PWM_OUTPUT_ACTIVE_LOW:
+ invert |= (1 << i);
+ enable |= (1 << i);
+ break;
+ case PWM_OUTPUT_ACTIVE_HIGH:
+ invert &= ~(1 << i);
+ enable |= (1 << i);
+ break;
+ default:
+ ;
+ }
+ }
+
+ pwmp->pwm->INVERT = invert;
+ pwmp->pwm->ENABLE = enable;
+ pwmp->pwm->ISC = 0xFFFFFFFF;
+}
+
+/**
+ * @brief Deactivates the PWM peripheral.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ *
+ * @notapi
+ */
+void pwm_lld_stop(PWMDriver *pwmp)
+{
+ /* If in ready state then disables the PWM clock.*/
+ if (pwmp->state == PWM_READY) {
+ pwmp->pwm->PWM[0].CTL = 0;
+ pwmp->pwm->PWM[1].CTL = 0;
+ pwmp->pwm->PWM[2].CTL = 0;
+ pwmp->pwm->PWM[3].CTL = 0;
+
+#if TIVA_PWM_USE_PWM0
+ if (&PWMD1 == pwmp) {
+ nvicDisableVector(TIVA_PWM0FAULT_NUMBER);
+ nvicDisableVector(TIVA_PWM0GEN0_NUMBER);
+ nvicDisableVector(TIVA_PWM0GEN1_NUMBER);
+ nvicDisableVector(TIVA_PWM0GEN2_NUMBER);
+ nvicDisableVector(TIVA_PWM0GEN3_NUMBER);
+ SYSCTL->RCGCPWM &= ~(1 << 0);
+ }
+#endif
+
+#if TIVA_PWM_USE_PWM1
+ if (&PWMD2 == pwmp) {
+ nvicDisableVector(TIVA_PWM1FAULT_NUMBER);
+ nvicDisableVector(TIVA_PWM1GEN0_NUMBER);
+ nvicDisableVector(TIVA_PWM1GEN1_NUMBER);
+ nvicDisableVector(TIVA_PWM1GEN2_NUMBER);
+ nvicDisableVector(TIVA_PWM1GEN3_NUMBER);
+ SYSCTL->RCGCPWM &= ~(1 << 1);
+ }
+#endif
+ }
+}
+
+/**
+ * @brief Enables a PWM channel.
+ * @pre The PWM unit must have been activated using @p pwmStart().
+ * @post The channel is active using the specified configuration.
+ * @note The function has effect at the next cycle start.
+ * @note Channel notification is not enabled.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ * @param[in] channel PWM channel identifier (0...channels-1)
+ * @param[in] width PWM pulse width as clock pulses number
+ *
+ * @notapi
+ */
+void pwm_lld_enable_channel(PWMDriver *pwmp,
+ pwmchannel_t channel,
+ pwmcnt_t width)
+{
+ /* Changing channel duty cycle on the fly.*/
+ pwmp->pwm->PWM[channel >> 1].CMP[channel & 1] = width;
+ pwmp->pwm->PWM[channel >> 1].CTL |= (1 << 0);
+}
+
+/**
+ * @brief Disables a PWM channel and its notification.
+ * @pre The PWM unit must have been activated using @p pwmStart().
+ * @post The channel is disabled and its output line returned to the
+ * idle state.
+ * @note The function has effect at the next cycle start.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ * @param[in] channel PWM channel identifier (0...channels-1)
+ *
+ * @notapi
+ */
+void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel)
+{
+ pwmp->pwm->PWM[channel >> 1].CMP[channel & 1] = 0;
+ pwmp->pwm->PWM[channel >> 1].CTL &= ~(1 << 0);
+}
+
+/**
+ * @brief Enables the periodic activation edge notification.
+ * @pre The PWM unit must have been activated using @p pwmStart().
+ * @note If the notification is already enabled then the call has no effect.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ *
+ * @notapi
+ */
+void pwm_lld_enable_periodic_notification(PWMDriver *pwmp)
+{
+ uint32_t inten;
+ uint8_t i;
+
+ /* If the IRQ is not already enabled care must be taken to clear it,
+ it is probably already pending because the timer is running.*/
+ for(i = 0; i < (PWM_CHANNELS >> 1); i++) {
+ inten = pwmp->pwm->PWM[i].INTEN;
+ if ((inten & 0x03) == 0) {
+ pwmp->pwm->PWM[i].INTEN |= 0x03;
+ pwmp->pwm->PWM[i].ISC = 0x03;
+ }
+ }
+
+ pwmp->pwm->INTEN = 0x3f;
+}
+
+/**
+ * @brief Disables the periodic activation edge notification.
+ * @pre The PWM unit must have been activated using @p pwmStart().
+ * @note If the notification is already disabled then the call has no effect.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ *
+ * @notapi
+ */
+void pwm_lld_disable_periodic_notification(PWMDriver *pwmp)
+{
+ pwmp->pwm->PWM[0].INTEN &= ~(0x03);
+ pwmp->pwm->PWM[1].INTEN &= ~(0x03);
+ pwmp->pwm->PWM[2].INTEN &= ~(0x03);
+ pwmp->pwm->PWM[3].INTEN &= ~(0x03);
+ pwmp->pwm->INTEN &= ~(0x3F);
+}
+
+/**
+ * @brief Enables a channel de-activation edge notification.
+ * @pre The PWM unit must have been activated using @p pwmStart().
+ * @pre The channel must have been activated using @p pwmEnableChannel().
+ * @note If the notification is already enabled then the call has no effect.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ * @param[in] channel PWM channel identifier (0...channels-1)
+ *
+ * @notapi
+ */
+void pwm_lld_enable_channel_notification(PWMDriver *pwmp,
+ pwmchannel_t channel)
+{
+ uint32_t inten = pwmp->pwm->PWM[channel >> 1].INTEN;
+
+ /* If the IRQ is not already enabled care must be taken to clear it,
+ it is probably already pending because the timer is running.*/
+ if ((inten & (0x03 << (((channel & 1) * 2) + 2))) == 0) {
+ pwmp->pwm->PWM[channel >> 1].INTEN |= (0x03 << (((channel & 1) * 2) + 2));
+ pwmp->pwm->PWM[channel >> 1].ISC = (0x03 << (((channel & 1) * 2) + 2));
+ }
+}
+
+/**
+ * @brief Disables a channel de-activation edge notification.
+ * @pre The PWM unit must have been activated using @p pwmStart().
+ * @pre The channel must have been activated using @p pwmEnableChannel().
+ * @note If the notification is already disabled then the call has no effect.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ * @param[in] channel PWM channel identifier (0...channels-1)
+ *
+ * @notapi
+ */
+void pwm_lld_disable_channel_notification(PWMDriver *pwmp,
+ pwmchannel_t channel)
+{
+ pwmp->pwm->PWM[channel >> 1].INTEN &= ~(0x03 << (((channel & 1) * 2) + 2));
+}
+
+#endif /* HAL_USE_PWM */
+
+/**
+ * @}
+ */
diff --git a/os/hal/ports/TIVA/LLD/pwm_lld.h b/os/hal/ports/TIVA/LLD/pwm_lld.h
new file mode 100644
index 0000000..70ba97b
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/pwm_lld.h
@@ -0,0 +1,372 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file TIVA/LLD/pwm_lld.c
+ * @brief TM4C123x/TM4C129x PWM subsystem low level driver header.
+ *
+ * @addtogroup PWM
+ * @{
+ */
+
+#ifndef _PWM_LLD_H_
+#define _PWM_LLD_H_
+
+#if HAL_USE_PWM || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/**
+ * @brief Number of PWM channels per PWM driver.
+ */
+#define PWM_CHANNELS 8
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @name Configuration options
+ * @{
+ */
+
+/**
+ * @brief PWMD1 driver enable switch.
+ * @details If set to @p TRUE the support for PWMD1 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_PWM_USE_PWM0) || defined(__DOXYGEN__)
+#define TIVA_PWM_USE_PWM0 FALSE
+#endif
+
+/**
+ * @brief PWMD2 driver enable switch.
+ * @details If set to @p TRUE the support for PWMD2 is included.
+ * @note The default is @p FALSE.
+ */
+#if !defined(TIVA_PWM_USE_PWM1) || defined(__DOXYGEN__)
+#define TIVA_PWM_USE_PWM1 FALSE
+#endif
+
+/**
+ * @brief PWMD1 fault interrupt priority level setting.
+ */
+#if !defined(TIVA_PWM_PWM0_FAULT_IRQ_PRIORITY) || defined (__DOXYGEN__)
+#define TIVA_PWM_PWM0_FAULT_IRQ_PRIORITY
+#endif
+
+/**
+ * @brief PWMD1 channel 0 & 1 interrupt priority level setting.
+ */
+#if !defined(TIVA_PWM_PWM0_0_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_PWM_PWM0_0_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief PWMD1 channel 2 & 3 interrupt priority level setting.
+ */
+#if !defined(TIVA_PWM_PWM0_1_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_PWM_PWM0_1_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief PWMD1 channel 4 & 5 interrupt priority level setting.
+ */
+#if !defined(TIVA_PWM_PWM0_2_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_PWM_PWM0_2_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief PWMD1 channel 6 & 7 interrupt priority level setting.
+ */
+#if !defined(TIVA_PWM_PWM0_3_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_PWM_PWM0_3_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief PWMD2 fault interrupt priority level setting.
+ */
+#if !defined(TIVA_PWM_PWM1_FAULT_IRQ_PRIORITY) || defined (__DOXYGEN__)
+#define TIVA_PWM_PWM1_FAULT_IRQ_PRIORITY
+#endif
+
+/**
+ * @brief PWMD2 channel 0 & 1 interrupt priority level setting.
+ */
+#if !defined(TIVA_PWM_PWM1_0_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_PWM_PWM1_0_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief PWMD2 channel 2 & 3 interrupt priority level setting.
+ */
+#if !defined(TIVA_PWM_PWM1_1_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_PWM_PWM1_1_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief PWMD2 channel 4 & 5 interrupt priority level setting.
+ */
+#if !defined(TIVA_PWM_PWM1_2_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_PWM_PWM1_2_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @brief PWMD2 channel 6 & 7 interrupt priority level setting.
+ */
+#if !defined(TIVA_PWM_PWM1_3_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_PWM_PWM1_3_IRQ_PRIORITY 4
+#endif
+
+/**
+ * @}
+ */
+
+/*===========================================================================*/
+/* Configuration checks. */
+/*===========================================================================*/
+
+#if TIVA_PWM_USE_PWM0 && !TIVA_HAS_PWM0
+#error "PWM0 not present in the selected device"
+#endif
+
+#if TIVA_PWM_USE_PWM1 && !TIVA_HAS_PWM1
+#error "PWM1 not present in the selected device"
+#endif
+
+#if !TIVA_PWM_USE_PWM0 && !TIVA_PWM_USE_PWM1
+#error "PWM driver activated but no PWM peripheral assigned"
+#endif
+
+#if TIVA_PWM_USE_PWM0 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_PWM_PWM0_FAULT_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to PWM0 FAULT"
+#endif
+
+#if TIVA_PWM_USE_PWM0 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_PWM_PWM0_0_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to PWM0 GEN0"
+#endif
+
+#if TIVA_PWM_USE_PWM0 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_PWM_PWM0_1_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to PWM0 GEN1"
+#endif
+
+#if TIVA_PWM_USE_PWM0 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_PWM_PWM0_2_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to PWM0 GEN2"
+#endif
+
+#if TIVA_PWM_USE_PWM0 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_PWM_PWM0_3_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to PWM0 GEN3"
+#endif
+
+#if TIVA_PWM_USE_PWM1 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_PWM_PWM1_FAULT_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to PWM1 FAULT"
+#endif
+
+#if TIVA_PWM_USE_PWM1 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_PWM_PWM1_0_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to PWM1 GEN0"
+#endif
+
+#if TIVA_PWM_USE_PWM1 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_PWM_PWM1_1_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to PWM1 GEN1"
+#endif
+
+#if TIVA_PWM_USE_PWM1 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_PWM_PWM1_2_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to PWM1 GEN2"
+#endif
+
+#if TIVA_PWM_USE_PWM1 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_PWM_PWM1_3_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to PWM1 GEN3"
+#endif
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Type of a PWM mode.
+ */
+typedef uint32_t pwmmode_t;
+
+/**
+ * @brief Type of a PWM channel.
+ */
+typedef uint8_t pwmchannel_t;
+
+/**
+ * @brief Type of a channels mask.
+ */
+typedef uint32_t pwmchnmsk_t;
+
+/**
+ * @brief Type of a PWM counter.
+ */
+typedef uint16_t pwmcnt_t;
+
+/**
+ * @brief Type of a PWM driver channel configuration structure.
+ */
+typedef struct {
+ /**
+ * @brief Channel active logic level.
+ */
+ pwmmode_t mode;
+ /**
+ * @brief Channel callback pointer.
+ * @note This callback is invoked on the channel compare event. If set to
+ * @p NULL then the callback is disabled.
+ */
+ pwmcallback_t callback;
+ /* End of the mandatory fields.*/
+} PWMChannelConfig;
+
+/**
+ * @brief Type of a PWM driver configuration structure.
+ */
+typedef struct {
+ /**
+ * @brief Timer clock in Hz.
+ * @note The low level can use assertions in order to catch invalid
+ * frequency specifications.
+ */
+ uint32_t frequency;
+ /**
+ * @brief PWM period in ticks.
+ * @note The low level can use assertions in order to catch invalid
+ * period specifications.
+ */
+ pwmcnt_t period;
+ /**
+ * @brief Periodic callback pointer.
+ * @note This callback is invoked on PWM counter reset. If set to
+ * @p NULL then the callback is disabled.
+ */
+ pwmcallback_t callback;
+ /**
+ * @brief Channels configurations.
+ */
+ PWMChannelConfig channels[PWM_CHANNELS];
+ /* End of the mandatory fields.*/
+} PWMConfig;
+
+/**
+ * @brief Structure representing a PWM driver.
+ */
+struct PWMDriver {
+ /**
+ * @brief Driver state.
+ */
+ pwmstate_t state;
+ /**
+ * @brief Current driver configuration data.
+ */
+ const PWMConfig *config;
+ /**
+ * @brief Current PWM period in ticks.
+ */
+ pwmcnt_t period;
+ /**
+ * @brief Mask of the enabled channels.
+ */
+ pwmchnmsk_t enabled;
+ /**
+ * @brief Number of channels in this instance.
+ */
+ pwmchannel_t channels;
+#if defined(PWM_DRIVER_EXT_FIELDS)
+ PWM_DRIVER_EXT_FIELDS
+#endif
+ /* End of the mandatory fields.*/
+ /**
+ * @brief Pointer to the PWMx registers block.
+ */
+ PWM_TypeDef *pwm;
+};
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/**
+ * @brief Changes the period the PWM peripheral.
+ * @details This function changes the period of a PWM unit that has already
+ * been activated using @p pwmStart().
+ * @pre The PWM unit must have been activated using @p pwmStart().
+ * @post The PWM unit period is changed to the new value.
+ * @note The function has effect at the next cycle start.
+ * @note If a period is specified that is shorter than the pulse width
+ * programmed in one of the channels then the behavior is not
+ * guaranteed.
+ *
+ * @param[in] pwmp pointer to a @p PWMDriver object
+ * @param[in] period new cycle time in ticks
+ *
+ * @notapi
+ */
+#define pwm_lld_change_period(pwmp, period) \
+ ((pwmp)->pwm->PWM[0].LOAD = (uint16_t)((period) - 1)); \
+ ((pwmp)->pwm->PWM[1].LOAD = (uint16_t)((period) - 1)); \
+ ((pwmp)->pwm->PWM[2].LOAD = (uint16_t)((period) - 1)); \
+ ((pwmp)->pwm->PWM[3].LOAD = (uint16_t)((period) - 1))
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#if TIVA_PWM_USE_PWM0 && !defined(__DOXYGEN__)
+extern PWMDriver PWMD1;
+#endif
+
+#if TIVA_PWM_USE_PWM1 && !defined(__DOXYGEN__)
+extern PWMDriver PWMD2;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void pwm_lld_init(void);
+ void pwm_lld_start(PWMDriver *pwmp);
+ void pwm_lld_stop(PWMDriver *pwmp);
+ void pwm_lld_enable_channel(PWMDriver *pwmp,
+ pwmchannel_t channel,
+ pwmcnt_t width);
+ void pwm_lld_disable_channel(PWMDriver *pwmp, pwmchannel_t channel);
+ void pwm_lld_enable_periodic_notification(PWMDriver *pwmp);
+ void pwm_lld_disable_periodic_notification(PWMDriver *pwmp);
+ void pwm_lld_enable_channel_notification(PWMDriver *pwmp,
+ pwmchannel_t channel);
+ void pwm_lld_disable_channel_notification(PWMDriver *pwmp,
+ pwmchannel_t channel);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_PWM */
+
+#endif /* _PWM_LLD_H_ */
+
+/** @} */
diff --git a/os/hal/ports/TIVA/LLD/serial_lld.c b/os/hal/ports/TIVA/LLD/serial_lld.c
new file mode 100644
index 0000000..6874e5e
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/serial_lld.c
@@ -0,0 +1,632 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file TIVA/LLD/serial_lld.c
+ * @brief Tiva low level serial driver code.
+ *
+ * @addtogroup SERIAL
+ * @{
+ */
+
+#include "hal.h"
+
+#if HAL_USE_SERIAL || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/**
+ * @brief UART0 serial driver identifier.
+ */
+#if TIVA_SERIAL_USE_UART0 || defined(__DOXYGEN__)
+SerialDriver SD1;
+#endif
+
+/**
+ * @brief UART1 serial driver identifier.
+ */
+#if TIVA_SERIAL_USE_UART1 || defined(__DOXYGEN__)
+SerialDriver SD2;
+#endif
+
+/**
+ * @brief UART2 serial driver identifier.
+ */
+#if TIVA_SERIAL_USE_UART2 || defined(__DOXYGEN__)
+SerialDriver SD3;
+#endif
+
+/**
+ * @brief UART3 serial driver identifier.
+ */
+#if TIVA_SERIAL_USE_UART3 || defined(__DOXYGEN__)
+SerialDriver SD4;
+#endif
+
+/**
+ * @brief UART4 serial driver identifier.
+ */
+#if TIVA_SERIAL_USE_UART4 || defined(__DOXYGEN__)
+SerialDriver SD5;
+#endif
+
+/**
+ * @brief UART5 serial driver identifier.
+ */
+#if TIVA_SERIAL_USE_UART5 || defined(__DOXYGEN__)
+SerialDriver SD6;
+#endif
+
+/**
+ * @brief UART6 serial driver identifier.
+ */
+#if TIVA_SERIAL_USE_UART6 || defined(__DOXYGEN__)
+SerialDriver SD7;
+#endif
+
+/**
+ * @brief UART7 serial driver identifier.
+ */
+#if TIVA_SERIAL_USE_UART7 || defined(__DOXYGEN__)
+SerialDriver SD8;
+#endif
+
+/*===========================================================================*/
+/* Driver local variables. */
+/*===========================================================================*/
+
+/**
+ * @brief Driver default configuration.
+ */
+static const SerialConfig sd_default_config =
+{
+ SERIAL_DEFAULT_BITRATE,
+ TIVA_LCRH_FEN | TIVA_LCRH_WLEN_8,
+ TIVA_IFLS_TXIFLSEL_1_8_F | TIVA_IFLS_RXIFLSEL_1_8_E
+};
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/**
+ * @brief UART initialization.
+ *
+ * @param[in] sdp communication channel associated to the UART
+ * @param[in] config the architecture-dependent serial driver configuration
+ */
+static void uart_init(SerialDriver *sdp, const SerialConfig *config)
+{
+ UART_TypeDef *u = sdp->uart;
+ uint32_t div; /* baud rate divisor */
+
+ /* disable the UART before any of the control registers are reprogrammed */
+ u->CTL &= ~TIVA_CTL_UARTEN;
+ div = (((TIVA_SYSCLK * 8) / config->sc_speed) + 1) / 2;
+ u->IBRD = div / 64; /* integer portion of the baud rate divisor */
+ u->FBRD = div % 64; /* fractional portion of the baud rate divisor */
+ u->LCRH = config->sc_lcrh; /* set data format */
+ u->IFLS = config->sc_ifls;
+ u->CTL |= TIVA_CTL_TXE | TIVA_CTL_RXE | TIVA_CTL_UARTEN;
+ u->IM |= TIVA_IM_RXIM | TIVA_IM_TXIM | TIVA_IM_RTIM; /* interrupts enable */
+}
+
+/**
+ * @brief UART de-initialization.
+ *
+ * @param[in] u pointer to an UART I/O block
+ */
+static void uart_deinit(UART_TypeDef *u)
+{
+ u->CTL &= ~TIVA_CTL_UARTEN;
+}
+
+/**
+ * @brief Error handling routine.
+ *
+ * @param[in] sdp communication channel associated to the UART
+ * @param[in] err UART LSR register value
+ */
+static void set_error(SerialDriver *sdp, uint16_t err)
+{
+ eventflags_t sts = 0;
+
+ if (err & TIVA_MIS_FEMIS)
+ sts |= SD_FRAMING_ERROR;
+ if (err & TIVA_MIS_PEMIS)
+ sts |= SD_PARITY_ERROR;
+ if (err & TIVA_MIS_BEMIS)
+ sts |= SD_BREAK_DETECTED;
+ if (err & TIVA_MIS_OEMIS)
+ sts |= SD_OVERRUN_ERROR;
+ osalSysLockFromISR();
+ chnAddFlagsI(sdp, sts);
+ osalSysUnlockFromISR();
+}
+
+/**
+ * @brief Common IRQ handler.
+ * @note Tries hard to clear all the pending interrupt sources, we don't
+ * want to go through the whole ISR and have another interrupt soon
+ * after.
+ *
+ * @param[in] u pointer to an UART I/O block
+ * @param[in] sdp communication channel associated to the UART
+ */
+static void serial_serve_interrupt(SerialDriver *sdp)
+{
+ UART_TypeDef *u = sdp->uart;
+ uint16_t mis = u->MIS;
+
+ u->ICR = mis; /* clear interrupts */
+
+ if (mis & (TIVA_MIS_FEMIS | TIVA_MIS_PEMIS | TIVA_MIS_BEMIS | TIVA_MIS_OEMIS)) {
+ set_error(sdp, mis);
+ }
+
+ if ((mis & TIVA_MIS_RXMIS) || (mis & TIVA_MIS_RTMIS)) {
+ osalSysLockFromISR();
+ if (iqIsEmptyI(&sdp->iqueue)) {
+ chnAddFlagsI(sdp, CHN_INPUT_AVAILABLE);
+ }
+ osalSysUnlockFromISR();
+ while ((u->FR & TIVA_FR_RXFE) == 0) {
+ osalSysLockFromISR();
+ if (iqPutI(&sdp->iqueue, u->DR) < Q_OK) {
+ chnAddFlagsI(sdp, SD_OVERRUN_ERROR);
+ }
+ osalSysUnlockFromISR();
+ }
+ }
+
+ if (mis & TIVA_MIS_TXMIS) {
+ while ((u->FR & TIVA_FR_TXFF) == 0) {
+ msg_t b;
+ osalSysLockFromISR();
+ b = oqGetI(&sdp->oqueue);
+ osalSysUnlockFromISR();
+ if (b < Q_OK) {
+ u->IM &= ~TIVA_IM_TXIM;
+ osalSysLockFromISR();
+ chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
+ osalSysUnlockFromISR();
+ break;
+ }
+ u->DR = b;
+ }
+ }
+}
+
+/**
+ * @brief
+ */
+static void fifo_load(SerialDriver *sdp)
+{
+ UART_TypeDef *u = sdp->uart;
+
+ while ((u->FR & TIVA_FR_TXFF) == 0) {
+ msg_t b = oqGetI(&sdp->oqueue);
+ if (b < Q_OK) {
+ chnAddFlagsI(sdp, CHN_OUTPUT_EMPTY);
+ return;
+ }
+ u->DR = b;
+ }
+ u->IM |= TIVA_IM_TXIM; /* transmit interrupt enable */
+}
+
+/**
+ * @brief Driver SD1 output notification.
+ */
+#if TIVA_SERIAL_USE_UART0 || defined(__DOXYGEN__)
+static void notify1(io_queue_t *qp)
+{
+ (void)qp;
+ fifo_load(&SD1);
+}
+#endif
+
+/**
+ * @brief Driver SD2 output notification.
+ */
+#if TIVA_SERIAL_USE_UART1 || defined(__DOXYGEN__)
+static void notify2(io_queue_t *qp)
+{
+ (void)qp;
+ fifo_load(&SD2);
+}
+#endif
+
+/**
+ * @brief Driver SD3 output notification.
+ */
+#if TIVA_SERIAL_USE_UART2 || defined(__DOXYGEN__)
+static void notify3(io_queue_t *qp)
+{
+ (void)qp;
+ fifo_load(&SD3);
+}
+#endif
+
+/**
+ * @brief Driver SD4 output notification.
+ */
+#if TIVA_SERIAL_USE_UART3 || defined(__DOXYGEN__)
+static void notify4(io_queue_t *qp)
+{
+ (void)qp;
+ fifo_load(&SD4);
+}
+#endif
+
+/**
+ * @brief Driver SD5 output notification.
+ */
+#if TIVA_SERIAL_USE_UART4 || defined(__DOXYGEN__)
+static void notify5(io_queue_t *qp)
+{
+ (void)qp;
+ fifo_load(&SD5);
+}
+#endif
+
+/**
+ * @brief Driver SD6 output notification.
+ */
+#if TIVA_SERIAL_USE_UART5 || defined(__DOXYGEN__)
+static void notify6(io_queue_t *qp)
+{
+ (void)qp;
+ fifo_load(&SD6);
+}
+#endif
+
+/**
+ * @brief Driver SD7 output notification.
+ */
+#if TIVA_SERIAL_USE_UART6 || defined(__DOXYGEN__)
+static void notify7(io_queue_t *qp)
+{
+ (void)qp;
+ fifo_load(&SD7);
+}
+#endif
+
+/**
+ * @brief Driver SD8 output notification.
+ */
+#if TIVA_SERIAL_USE_UART7 || defined(__DOXYGEN__)
+static void notify8(io_queue_t *qp)
+{
+ (void)qp;
+ fifo_load(&SD8);
+}
+#endif
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+/**
+ * @brief UART0 IRQ handler.
+ */
+#if TIVA_SERIAL_USE_UART0 || defined(__DOXYGEN__)
+#if !defined(TIVA_UART0_HANDLER)
+#error "TIVA_UART0_HANDLER not defined"
+#endif
+CH_IRQ_HANDLER(TIVA_UART0_HANDLER)
+{
+ CH_IRQ_PROLOGUE();
+
+ serial_serve_interrupt(&SD1);
+
+ CH_IRQ_EPILOGUE();
+}
+#endif
+
+/**
+ * @brief UART1 IRQ handler.
+ */
+#if TIVA_SERIAL_USE_UART1 || defined(__DOXYGEN__)
+CH_IRQ_HANDLER(TIVA_UART1_HANDLER)
+{
+ CH_IRQ_PROLOGUE();
+
+ serial_serve_interrupt(&SD2);
+
+ CH_IRQ_EPILOGUE();
+}
+#endif
+
+/**
+ * @brief UART2 IRQ handler.
+ */
+#if TIVA_SERIAL_USE_UART2 || defined(__DOXYGEN__)
+CH_IRQ_HANDLER(TIVA_UART2_HANDLER)
+{
+ CH_IRQ_PROLOGUE();
+
+ serial_serve_interrupt(&SD3);
+
+ CH_IRQ_EPILOGUE();
+}
+#endif
+
+/**
+ * @brief UART3 IRQ handler.
+ */
+#if TIVA_SERIAL_USE_UART3 || defined(__DOXYGEN__)
+CH_IRQ_HANDLER(TIVA_UART3_HANDLER)
+{
+ CH_IRQ_PROLOGUE();
+
+ serial_serve_interrupt(&SD4);
+
+ CH_IRQ_EPILOGUE();
+}
+#endif
+
+/**
+ * @brief UART4 IRQ handler.
+ */
+#if TIVA_SERIAL_USE_UART4 || defined(__DOXYGEN__)
+CH_IRQ_HANDLER(TIVA_UART4_HANDLER)
+{
+ CH_IRQ_PROLOGUE();
+
+ serial_serve_interrupt(&SD5);
+
+ CH_IRQ_EPILOGUE();
+}
+#endif
+
+/**
+ * @brief UART5 IRQ handler.
+ */
+#if TIVA_SERIAL_USE_UART5 || defined(__DOXYGEN__)
+CH_IRQ_HANDLER(TIVA_UART5_HANDLER)
+{
+ CH_IRQ_PROLOGUE();
+
+ serial_serve_interrupt(&SD6);
+
+ CH_IRQ_EPILOGUE();
+}
+#endif
+
+/**
+ * @brief UART6 IRQ handler.
+ */
+#if TIVA_SERIAL_USE_UART6 || defined(__DOXYGEN__)
+CH_IRQ_HANDLER(TIVA_UART6_HANDLER)
+{
+ CH_IRQ_PROLOGUE();
+
+ serial_serve_interrupt(&SD7);
+
+ CH_IRQ_EPILOGUE();
+}
+#endif
+
+/**
+ * @brief UART7 IRQ handler.
+ */
+#if TIVA_SERIAL_USE_UART7 || defined(__DOXYGEN__)
+CH_IRQ_HANDLER(TIVA_UART7_HANDLER)
+{
+ CH_IRQ_PROLOGUE();
+
+ serial_serve_interrupt(&SD8);
+
+ CH_IRQ_EPILOGUE();
+}
+#endif
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Low level serial driver initialization.
+ */
+void sd_lld_init(void)
+{
+#if TIVA_SERIAL_USE_UART0
+ sdObjectInit(&SD1, NULL, notify1);
+ SD1.uart = UART0;
+#endif
+
+#if TIVA_SERIAL_USE_UART1
+ sdObjectInit(&SD2, NULL, notify2);
+ SD2.uart = UART1;
+#endif
+
+#if TIVA_SERIAL_USE_UART2
+ sdObjectInit(&SD3, NULL, notify3);
+ SD3.uart = UART2;
+#endif
+
+#if TIVA_SERIAL_USE_UART3
+ sdObjectInit(&SD4, NULL, notify4);
+ SD4.uart = UART3;
+#endif
+
+#if TIVA_SERIAL_USE_UART4
+ sdObjectInit(&SD5, NULL, notify5);
+ SD5.uart = UART4;
+#endif
+
+#if TIVA_SERIAL_USE_UART5
+ sdObjectInit(&SD6, NULL, notify6);
+ SD6.uart = UART5;
+#endif
+
+#if TIVA_SERIAL_USE_UART6
+ sdObjectInit(&SD7, NULL, notify7);
+ SD7.uart = UART6;
+#endif
+
+#if TIVA_SERIAL_USE_UART7
+ sdObjectInit(&SD8, NULL, notify8);
+ SD8.uart = UART7;
+#endif
+}
+
+/**
+ * @brief Low level serial driver configuration and (re)start.
+ *
+ * @param[in] sdp pointer to a @p SerialDriver object
+ * @param[in] config the architecture-dependent serial driver configuration.
+ * If this parameter is set to @p NULL then a default
+ * configuration is used.
+ */
+void sd_lld_start(SerialDriver *sdp, const SerialConfig *config)
+{
+ if (config == NULL)
+ config = &sd_default_config;
+
+ if (sdp->state == SD_STOP) {
+#if TIVA_SERIAL_USE_UART0
+ if (&SD1 == sdp) {
+ SYSCTL->RCGCUART |= (1 << 0);
+ nvicEnableVector(UART0_IRQn, TIVA_SERIAL_UART0_PRIORITY);
+ }
+#endif
+#if TIVA_SERIAL_USE_UART1
+ if (&SD2 == sdp) {
+ SYSCTL->RCGCUART |= (1 << 1);
+ nvicEnableVector(UART1_IRQn, TIVA_SERIAL_UART1_PRIORITY);
+ }
+#endif
+#if TIVA_SERIAL_USE_UART2
+ if (&SD3 == sdp) {
+ SYSCTL->RCGCUART |= (1 << 2); /* enable UART2 module */
+ nvicEnableVector(UART2_IRQn, TIVA_SERIAL_UART2_PRIORITY);
+ }
+#endif
+#if TIVA_SERIAL_USE_UART3
+ if (&SD4 == sdp) {
+ SYSCTL->RCGCUART |= (1 << 3); /* enable UART3 module */
+ nvicEnableVector(UART3_IRQn, TIVA_SERIAL_UART3_PRIORITY);
+ }
+#endif
+#if TIVA_SERIAL_USE_UART4
+ if (&SD5 == sdp) {
+ SYSCTL->RCGCUART |= (1 << 4); /* enable UART4 module */
+ nvicEnableVector(UART4_IRQn, TIVA_SERIAL_UART4_PRIORITY);
+ }
+#endif
+#if TIVA_SERIAL_USE_UART5
+ if (&SD6 == sdp) {
+ SYSCTL->RCGCUART |= (1 << 5); /* enable UART5 module */
+ nvicEnableVector(UART5_IRQn, TIVA_SERIAL_UART5_PRIORITY);
+ }
+#endif
+#if TIVA_SERIAL_USE_UART6
+ if (&SD7 == sdp) {
+ SYSCTL->RCGCUART |= (1 << 6); /* enable UART6 module */
+ nvicEnableVector(UART6_IRQn, TIVA_SERIAL_UART6_PRIORITY);
+ }
+#endif
+#if TIVA_SERIAL_USE_UART7
+ if (&SD8 == sdp) {
+ SYSCTL->RCGCUART |= (1 << 7); /* enable UART7 module */
+ nvicEnableVector(UART7_IRQn, TIVA_SERIAL_UART7_PRIORITY);
+ }
+#endif
+ }
+ uart_init(sdp, config);
+}
+
+/**
+ * @brief Low level serial driver stop.
+ * @details De-initializes the UART, stops the associated clock, resets the
+ * interrupt vector.
+ *
+ * @param[in] sdp pointer to a @p SerialDriver object
+ */
+void sd_lld_stop(SerialDriver *sdp)
+{
+ if (sdp->state == SD_READY) {
+ uart_deinit(sdp->uart);
+#if TIVA_SERIAL_USE_UART0
+ if (&SD1 == sdp) {
+ SYSCTL->RCGCUART &= ~(1 << 0); /* disable UART0 module */
+ nvicDisableVector(UART0_IRQn);
+ return;
+ }
+#endif
+#if TIVA_SERIAL_USE_UART1
+ if (&SD2 == sdp) {
+ SYSCTL->RCGCUART &= ~(1 << 1); /* disable UART1 module */
+ nvicDisableVector(UART1_IRQn);
+ return;
+ }
+#endif
+#if TIVA_SERIAL_USE_UART2
+ if (&SD3 == sdp) {
+ SYSCTL->RCGCUART &= ~(1 << 2); /* disable UART2 module */
+ nvicDisableVector(UART2_IRQn);
+ return;
+ }
+#endif
+#if TIVA_SERIAL_USE_UART3
+ if (&SD4 == sdp) {
+ SYSCTL->RCGCUART &= ~(1 << 3); /* disable UART3 module */
+ nvicDisableVector(UART3_IRQn);
+ return;
+ }
+#endif
+#if TIVA_SERIAL_USE_UART4
+ if (&SD5 == sdp) {
+ SYSCTL->RCGCUART &= ~(1 << 4); /* disable UART4 module */
+ nvicDisableVector(UART4_IRQn);
+ return;
+ }
+#endif
+#if TIVA_SERIAL_USE_UART5
+ if (&SD6 == sdp) {
+ SYSCTL->RCGCUART &= ~(1 << 5); /* disable UART5 module */
+ nvicDisableVector(UART5_IRQn);
+ return;
+ }
+#endif
+#if TIVA_SERIAL_USE_UART6
+ if (&SD7 == sdp) {
+ SYSCTL->RCGCUART &= ~(1 << 6); /* disable UART6 module */
+ nvicDisableVector(UART6_IRQn);
+ return;
+ }
+#endif
+#if TIVA_SERIAL_USE_UART7
+ if (&SD8 == sdp) {
+ SYSCTL->RCGCUART &= ~(1 << 7); /* disable UART7 module */
+ nvicDisableVector(UART7_IRQn);
+ return;
+ }
+#endif
+ }
+}
+
+#endif /* CH_HAL_USE_SERIAL */
+
+/** @} */
diff --git a/os/hal/ports/TIVA/LLD/serial_lld.h b/os/hal/ports/TIVA/LLD/serial_lld.h
new file mode 100644
index 0000000..5ba4645
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/serial_lld.h
@@ -0,0 +1,482 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file TIVA/LLD/serial_lld.h
+ * @brief Tiva low level serial driver header.
+ *
+ * @addtogroup SERIAL
+ * @{
+ */
+
+#ifndef _SERIAL_LLD_H_
+#define _SERIAL_LLD_H_
+
+#if HAL_USE_SERIAL || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/**
+ * @name FR register bits definitions
+ * @{
+ */
+
+#define TIVA_FR_CTS (1 << 0)
+
+#define TIVA_FR_BUSY (1 << 3)
+
+#define TIVA_FR_RXFE (1 << 4)
+
+#define TIVA_FR_TXFF (1 << 5)
+
+#define TIVA_FR_RXFF (1 << 6)
+
+#define TIVA_FR_TXFE (1 << 7)
+
+/**
+ * @}
+ */
+
+/**
+ * @name LCRH register bits definitions
+ * @{
+ */
+
+#define TIVA_LCRH_BRK (1 << 0)
+
+#define TIVA_LCRH_PEN (1 << 1)
+
+#define TIVA_LCRH_EPS (1 << 2)
+
+#define TIVA_LCRH_STP2 (1 << 3)
+
+#define TIVA_LCRH_FEN (1 << 4)
+
+#define TIVA_LCRH_WLEN_MASK (3 << 5)
+#define TIVA_LCRH_WLEN_5 (0 << 5)
+#define TIVA_LCRH_WLEN_6 (1 << 5)
+#define TIVA_LCRH_WLEN_7 (2 << 5)
+#define TIVA_LCRH_WLEN_8 (3 << 5)
+
+#define TIVA_LCRH_SPS (1 << 7)
+
+/**
+ * @}
+ */
+
+/**
+ * @name CTL register bits definitions
+ * @{
+ */
+
+#define TIVA_CTL_UARTEN (1 << 0)
+
+#define TIVA_CTL_SIREN (1 << 1)
+
+#define TIVA_CTL_SIRLP (1 << 2)
+
+#define TIVA_CTL_SMART (1 << 3)
+
+#define TIVA_CTL_EOT (1 << 4)
+
+#define TIVA_CTL_HSE (1 << 5)
+
+#define TIVA_CTL_LBE (1 << 7)
+
+#define TIVA_CTL_TXE (1 << 8)
+
+#define TIVA_CTL_RXE (1 << 9)
+
+#define TIVA_CTL_RTS (1 << 11)
+
+#define TIVA_CTL_RTSEN (1 << 14)
+
+#define TIVA_CTL_CTSEN (1 << 15)
+
+/**
+ * @}
+ */
+
+/**
+ * @name IFLS register bits definitions
+ * @{
+ */
+
+#define TIVA_IFLS_TXIFLSEL_MASK (7 << 0)
+#define TIVA_IFLS_TXIFLSEL_1_8_F (0 << 0)
+#define TIVA_IFLS_TXIFLSEL_1_4_F (1 << 0)
+#define TIVA_IFLS_TXIFLSEL_1_2_F (2 << 0)
+#define TIVA_IFLS_TXIFLSEL_3_4_F (3 << 0)
+#define TIVA_IFLS_TXIFLSEL_7_8_F (4 << 0)
+
+#define TIVA_IFLS_RXIFLSEL_MASK (7 << 3)
+#define TIVA_IFLS_RXIFLSEL_7_8_E (0 << 3)
+#define TIVA_IFLS_RXIFLSEL_3_4_E (1 << 3)
+#define TIVA_IFLS_RXIFLSEL_1_2_E (2 << 3)
+#define TIVA_IFLS_RXIFLSEL_1_4_E (3 << 3)
+#define TIVA_IFLS_RXIFLSEL_1_8_E (4 << 3)
+
+/**
+ * @}
+ */
+
+/**
+ * @name MIS register bits definitions
+ * @{
+ */
+
+#define TIVA_MIS_CTSMIS (1 << 1)
+
+#define TIVA_MIS_RXMIS (1 << 4)
+
+#define TIVA_MIS_TXMIS (1 << 5)
+
+#define TIVA_MIS_RTMIS (1 << 6)
+
+#define TIVA_MIS_FEMIS (1 << 7)
+
+#define TIVA_MIS_PEMIS (1 << 8)
+
+#define TIVA_MIS_BEMIS (1 << 9)
+
+#define TIVA_MIS_OEMIS (1 << 10)
+
+#define TIVA_MIS_9BITMIS (1 << 12)
+
+/**
+ * @}
+ */
+
+/**
+ * @name IM register bits definitions
+ * @{
+ */
+
+#define TIVA_IM_CTSIM (1 << 1)
+
+#define TIVA_IM_RXIM (1 << 4)
+
+#define TIVA_IM_TXIM (1 << 5)
+
+#define TIVA_IM_RTIM (1 << 6)
+
+#define TIVA_IM_FEIM (1 << 7)
+
+#define TIVA_IM_PEIM (1 << 8)
+
+#define TIVA_IM_BEIM (1 << 9)
+
+#define TIVA_IM_OEIM (1 << 10)
+
+#define TIVA_IM_9BITIM (1 << 12)
+
+/**
+ * @}
+ */
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @name Configuration options
+ * @{
+ */
+
+/**
+ * @brief UART0 driver enable switch.
+ * @details If set to @p TRUE the support for UART0 is included.
+ * @note The default is @p TRUE.
+ */
+#if !defined(TIVA_SERIAL_USE_UART0) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_USE_UART0 FALSE
+#endif
+
+/**
+ * @brief UART1 driver enable switch.
+ * @details If set to @p TRUE the support for UART1 is included.
+ * @note The default is @p FALSE .
+ */
+#if !defined(TIVA_SERIAL_USE_UART1) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_USE_UART1 FALSE
+#endif
+
+/**
+ * @brief UART2 driver enable switch.
+ * @details If set to @p TRUE the support for UART2 is included.
+ * @note The default is @p FALSE .
+ */
+#if !defined(TIVA_SERIAL_USE_UART2) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_USE_UART2 FALSE
+#endif
+
+/**
+ * @brief UART3 driver enable switch.
+ * @details If set to @p TRUE the support for UART3 is included.
+ * @note The default is @p FALSE .
+ */
+#if !defined(TIVA_SERIAL_USE_UART3) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_USE_UART3 FALSE
+#endif
+
+/**
+ * @brief UART4 driver enable switch.
+ * @details If set to @p TRUE the support for UART4 is included.
+ * @note The default is @p FALSE .
+ */
+#if !defined(TIVA_SERIAL_USE_UART4) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_USE_UART4 FALSE
+#endif
+
+/**
+ * @brief UART5 driver enable switch.
+ * @details If set to @p TRUE the support for UART5 is included.
+ * @note The default is @p FALSE .
+ */
+#if !defined(TIVA_SERIAL_USE_UART5) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_USE_UART5 FALSE
+#endif
+
+/**
+ * @brief UART6 driver enable switch.
+ * @details If set to @p TRUE the support for UART6 is included.
+ * @note The default is @p FALSE .
+ */
+#if !defined(TIVA_SERIAL_USE_UART6) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_USE_UART6 FALSE
+#endif
+
+/**
+ * @brief UART7 driver enable switch.
+ * @details If set to @p TRUE the support for UART7 is included.
+ * @note The default is @p FALSE .
+ */
+#if !defined(TIVA_SERIAL_USE_UART7) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_USE_UART7 FALSE
+#endif
+
+/**
+ * @brief UART0 interrupt priority level setting.
+ */
+#if !defined(TIVA_SERIAL_UART0_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_UART0_PRIORITY 5
+#endif
+
+/**
+ * @brief UART1 interrupt priority level setting.
+ */
+#if !defined(TIVA_SERIAL_UART1_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_UART1_PRIORITY 5
+#endif
+
+/**
+ * @brief UART2 interrupt priority level setting.
+ */
+#if !defined(TIVA_SERIAL_UART2_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_UART2_PRIORITY 5
+#endif
+
+/**
+ * @brief UART3 interrupt priority level setting.
+ */
+#if !defined(TIVA_SERIAL_UART3_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_UART3_PRIORITY 5
+#endif
+
+/**
+ * @brief UART4 interrupt priority level setting.
+ */
+#if !defined(TIVA_SERIAL_UART4_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_UART4_PRIORITY 5
+#endif
+
+/**
+ * @brief UART5 interrupt priority level setting.
+ */
+#if !defined(TIVA_SERIAL_UART5_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_UART5_PRIORITY 5
+#endif
+
+/**
+ * @brief UART6 interrupt priority level setting.
+ */
+#if !defined(TIVA_SERIAL_UART6_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_UART6_PRIORITY 5
+#endif
+
+/**
+ * @brief UART7 interrupt priority level setting.
+ */
+#if !defined(TIVA_SERIAL_UART7_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_SERIAL_UART7_PRIORITY 5
+#endif
+
+/**
+ * @}
+ */
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+#if !TIVA_SERIAL_USE_UART0 && !TIVA_SERIAL_USE_UART1 && \
+ !TIVA_SERIAL_USE_UART2 && !TIVA_SERIAL_USE_UART3 && \
+ !TIVA_SERIAL_USE_UART4 && !TIVA_SERIAL_USE_UART5 && \
+ !TIVA_SERIAL_USE_UART6 && !TIVA_SERIAL_USE_UART7
+#error "SERIAL driver activated but no UART peripheral assigned"
+#endif
+
+#if TIVA_SERIAL_USE_UART0 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_SERIAL_UART0_PRIORITY)
+#error "Invalid IRQ priority assigned to UART0"
+#endif
+
+#if TIVA_SERIAL_USE_UART1 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_SERIAL_UART1_PRIORITY)
+#error "Invalid IRQ priority assigned to UART1"
+#endif
+
+#if TIVA_SERIAL_USE_UART2 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_SERIAL_UART2_PRIORITY)
+#error "Invalid IRQ priority assigned to UART2"
+#endif
+
+#if TIVA_SERIAL_USE_UART3 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_SERIAL_UART3_PRIORITY)
+#error "Invalid IRQ priority assigned to UART3"
+#endif
+
+#if TIVA_SERIAL_USE_UART4 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_SERIAL_UART4_PRIORITY)
+#error "Invalid IRQ priority assigned to UART4"
+#endif
+
+#if TIVA_SERIAL_USE_UART5 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_SERIAL_UART5_PRIORITY)
+#error "Invalid IRQ priority assigned to UART5"
+#endif
+
+#if TIVA_SERIAL_USE_UART6 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_SERIAL_UART6_PRIORITY)
+#error "Invalid IRQ priority assigned to UART6"
+#endif
+
+#if TIVA_SERIAL_USE_UART7 && \
+ !CORTEX_IS_VALID_KERNEL_PRIORITY(TIVA_SERIAL_UART7_PRIORITY)
+#error "Invalid IRQ priority assigned to UART7"
+#endif
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/**
+ * @brief Tiva Serial Driver configuration structure.
+ * @details An instance of this structure must be passed to @p sdStart()
+ * in order to configure and start a serial driver operations.
+ */
+typedef struct {
+ /**
+ * @brief Bit rate.
+ */
+ uint32_t sc_speed;
+ /* End of the mandatory fields. */
+ /**
+ * @brief Initialization value for the LCRH (Line Control) register.
+ */
+ uint32_t sc_lcrh;
+ /**
+ * @brief Initialization value for the IFLS (Interrupt FIFO Level Select)
+ * register.
+ */
+ uint32_t sc_ifls;
+} SerialConfig;
+
+/**
+ * @brief @p SerialDriver specific data.
+ */
+#define _serial_driver_data \
+ _base_asynchronous_channel_data \
+ /* Driver state.*/ \
+ sdstate_t state; \
+ /* Input queue.*/ \
+ input_queue_t iqueue; \
+ /* Output queue.*/ \
+ output_queue_t oqueue; \
+ /* Input circular buffer.*/ \
+ uint8_t ib[SERIAL_BUFFERS_SIZE]; \
+ /* Output circular buffer.*/ \
+ uint8_t ob[SERIAL_BUFFERS_SIZE]; \
+ /* End of the mandatory fields.*/ \
+ /* Pointer to the USART registers block.*/ \
+ UART_TypeDef *uart;
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#if TIVA_SERIAL_USE_UART0 && !defined(__DOXYGEN__)
+extern SerialDriver SD1;
+#endif
+
+#if TIVA_SERIAL_USE_UART1 && !defined(__DOXYGEN__)
+extern SerialDriver SD2;
+#endif
+
+#if TIVA_SERIAL_USE_UART2 && !defined(__DOXYGEN__)
+extern SerialDriver SD3;
+#endif
+
+#if TIVA_SERIAL_USE_UART3 && !defined(__DOXYGEN__)
+extern SerialDriver SD4;
+#endif
+
+#if TIVA_SERIAL_USE_UART4 && !defined(__DOXYGEN__)
+extern SerialDriver SD5;
+#endif
+
+#if TIVA_SERIAL_USE_UART5 && !defined(__DOXYGEN__)
+extern SerialDriver SD6;
+#endif
+
+#if TIVA_SERIAL_USE_UART6 && !defined(__DOXYGEN__)
+extern SerialDriver SD7;
+#endif
+
+#if TIVA_SERIAL_USE_UART7 && !defined(__DOXYGEN__)
+extern SerialDriver SD8;
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void sd_lld_init(void);
+ void sd_lld_start(SerialDriver *sdp, const SerialConfig *config);
+ void sd_lld_stop(SerialDriver *sdp);
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* HAL_USE_SERIAL */
+
+#endif /* _SERIAL_LLD_H_ */
+
+/** @} */
diff --git a/os/hal/ports/TIVA/LLD/st_lld.c b/os/hal/ports/TIVA/LLD/st_lld.c
new file mode 100644
index 0000000..6e83c10
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/st_lld.c
@@ -0,0 +1,284 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file Tiva/LLD/st_lld.c
+ * @brief ST Driver subsystem low level driver code.
+ *
+ * @addtogroup ST
+ * @{
+ */
+
+#include "hal.h"
+
+#if (OSAL_ST_MODE != OSAL_ST_MODE_NONE) || defined(__DOXYGEN__)
+
+/*===========================================================================*/
+/* Driver local definitions. */
+/*===========================================================================*/
+
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+
+#if (TIVA_ST_USE_WIDE_TIMER == TRUE)
+
+#if TIVA_ST_TIMER_NUMBER == 0
+#warning "WGPT0"
+#define ST_HANDLER TIVA_WGPT0A_HANDLER
+#define ST_NUMBER TIVA_WGPT0A_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 0))
+
+#elif TIVA_ST_TIMER_NUMBER == 1
+#warning "WGPT1"
+#define ST_HANDLER TIVA_WGPT1A_HANDLER
+#define ST_NUMBER TIVA_WGPT1A_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 1))
+
+#elif TIVA_ST_TIMER_NUMBER == 2
+#warning "WGPT2"
+#define ST_HANDLER TIVA_WGPT2A_HANDLER
+#define ST_NUMBER TIVA_WGPT2A_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 2))
+
+#elif TIVA_ST_TIMER_NUMBER == 3
+#warning "WGPT3"
+#define ST_HANDLER TIVA_WGPT3A_HANDLER
+#define ST_NUMBER TIVA_WGPT3A_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 3))
+
+#elif TIVA_ST_TIMER_NUMBER == 4
+#warning "WGPT4"
+#define ST_HANDLER TIVA_WGPT4A_HANDLER
+#define ST_NUMBER TIVA_WGPT4A_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 4))
+
+#elif TIVA_ST_TIMER_NUMBER == 5
+#warning "WGPT5"
+#define ST_HANDLER TIVA_WGPT5A_HANDLER
+#define ST_NUMBER TIVA_WGPT5A_NUMBER
+//#define ST_CLOCK_SRC (80000000)
+#define ST_CLOCK_SRC (16000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 5))
+
+#else
+#error "TIVA_ST_USE_TIMER specifies an unsupported timer"
+#endif
+
+#if (ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1 > 0xFFFF
+#error "the selected ST frequency is not obtainable because TIM timer prescaler limits"
+#endif
+
+#elif (TIVA_ST_USE_WIDE_TIMER == FALSE)
+
+#if TIVA_ST_TIMER_NUMBER == 0
+#warning "GPT0"
+#define ST_HANDLER TIVA_GPT0_HANDLER
+#define ST_NUMBER TIVA_GPT0_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 0))
+
+#elif TIVA_ST_TIMER_NUMBER == 1
+#warning "GPT1"
+#define ST_HANDLER TIVA_GPT1_HANDLER
+#define ST_NUMBER TIVA_GPT1_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 1))
+
+#elif TIVA_ST_TIMER_NUMBER == 2
+#warning "GPT2"
+#define ST_HANDLER TIVA_GPT2_HANDLER
+#define ST_NUMBER TIVA_GPT2_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 2))
+
+#elif TIVA_ST_TIMER_NUMBER == 3
+#warning "GPT3"
+#define ST_HANDLER TIVA_GPT3_HANDLER
+#define ST_NUMBER TIVA_GPT3_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 3))
+
+#elif TIVA_ST_TIMER_NUMBER == 4
+#warning "GPT4"
+#define ST_HANDLER TIVA_GPT4_HANDLER
+#define ST_NUMBER TIVA_GPT4_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 4))
+
+#elif TIVA_ST_TIMER_NUMBER == 5
+#warning "GPT5"
+#define ST_HANDLER TIVA_GPT5_HANDLER
+#define ST_NUMBER TIVA_GPT5_NUMBER
+#define ST_CLOCK_SRC (80000000)
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 5))
+
+#else
+#error "TIVA_ST_USE_TIMER specifies an unsupported timer"
+#endif
+
+#if (ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1 > 0xFF
+#error "the selected ST frequency is not obtainable because TIM timer prescaler limits"
+#endif
+
+#endif
+
+#if ST_CLOCK_SRC % OSAL_ST_FREQUENCY != 0
+#error "the selected ST frequency is not obtainable because integer rounding"
+#endif
+
+#endif
+
+//#if (ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1 > 0xFFFF
+//#error "the selected ST frequency is not obtainable because TIM timer prescaler limits"
+//#endif
+
+/*===========================================================================*/
+/* Driver exported variables. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local variables and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver local functions. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver interrupt handlers. */
+/*===========================================================================*/
+
+#if (OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC) || defined(__DOXYGEN__)
+/**
+ * @brief System Timer vector.
+ * @details This interrupt is used for system tick in periodic mode.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(SysTick_Handler)
+{
+ OSAL_IRQ_PROLOGUE();
+
+ osalSysLockFromISR();
+ osalOsTimerHandlerI();
+ osalSysUnlockFromISR();
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */
+
+#if (OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING) || defined(__DOXYGEN__)
+/**
+ * @brief TIM2 interrupt handler.
+ * @details This interrupt is used for system tick in free running mode.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(ST_HANDLER)
+{
+ uint32_t mis;
+ uint32_t temp;
+
+ OSAL_IRQ_PROLOGUE();
+
+ mis = TIVA_ST_TIM->MIS;
+ TIVA_ST_TIM->ICR = 0xffffffff;
+
+ if (mis & GPTM_IMR_TATOIM) {
+ temp = 3;
+ }
+
+ if (mis & GPTM_IMR_CAMIM) {
+ temp = 1;
+ }
+
+ if (mis & GPTM_IMR_CAEIM) {
+ temp = 2;
+ }
+
+ if (mis & GPTM_IMR_TAMIM) {
+ osalSysLockFromISR();
+ osalOsTimerHandlerI();
+ osalSysUnlockFromISR();
+ }
+
+ OSAL_IRQ_EPILOGUE();
+}
+#endif /* OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING */
+
+/*===========================================================================*/
+/* Driver exported functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Low level ST driver initialization.
+ *
+ * @notapi
+ */
+void st_lld_init(void)
+{
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+ /* Free running counter mode.*/
+
+ /* Enabling timer clock.*/
+ ST_ENABLE_CLOCK();
+
+ /* Initializing the counter in free running mode.*/
+ TIVA_ST_TIM->CTL = 0;
+ TIVA_ST_TIM->CFG = GPTM_CFG_CFG_SPLIT; /* Timer split mode */
+ TIVA_ST_TIM->TAMR = (GPTM_TAMR_TAMR_PERIODIC | /* Periodic mode */
+ GPTM_TAMR_TACDIR | /* Count up */
+ GPTM_TAMR_TAMIE | /* Match interrupt enable */
+ GPTM_TAMR_TASNAPS); /* Snapshot mode */
+ //TIVA_ST_TIM->TAPR = (ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1;
+ /* in up mode (used by tickless mode) the prescaler register extends the TAV
+ * and TAR registers. How to solve this? In down mode it is working better
+ * because the prescaler really works as prescaler. */
+ //TIVA_ST_TIM->CTL = (GPTM_CTL_TAEN | GPTM_CTL_TASTALL);
+ TIVA_ST_TIM->CTL = (GPTM_CTL_TAEN | /* Timer A enable */
+ GPTM_CTL_TASTALL); /* Timer A stall when paused */
+
+ /* IRQ enabled.*/
+ nvicEnableVector(ST_NUMBER, TIVA_ST_IRQ_PRIORITY);
+#endif /* OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING */
+
+#if OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC
+ /* Periodic systick mode, the Cortex-Mx internal systick timer is used
+ in this mode.*/
+ SysTick->LOAD = (TIVA_SYSCLK / OSAL_ST_FREQUENCY) - 1;
+ SysTick->VAL = 0;
+ SysTick->CTRL = SysTick_CTRL_CLKSOURCE_Msk |
+ SysTick_CTRL_ENABLE_Msk |
+ SysTick_CTRL_TICKINT_Msk;
+
+ /* IRQ enabled.*/
+ nvicSetSystemHandlerPriority(HANDLER_SYSTICK, TIVA_ST_IRQ_PRIORITY);
+#endif /* OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC */
+}
+
+#endif /* OSAL_ST_MODE != OSAL_ST_MODE_NONE */
+
+/**
+ * @}
+ */
diff --git a/os/hal/ports/TIVA/LLD/st_lld.h b/os/hal/ports/TIVA/LLD/st_lld.h
new file mode 100644
index 0000000..49bd91d
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/st_lld.h
@@ -0,0 +1,323 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file Tiva/LLD/st_lld.h
+ * @brief ST Driver subsystem low level driver header.
+ * @details This header is designed to be include-able without having to
+ * include other files from the HAL.
+ *
+ * @addtogroup ST
+ * @{
+ */
+
+#ifndef _ST_LLD_H_
+#define _ST_LLD_H_
+
+#include "mcuconf.h"
+#include "tiva_registry.h"
+#include "tiva_gpt.h"
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+#define TIVA_ST_TIM_PRESCALER ((80000000 / 10000) - 1)
+
+/*===========================================================================*/
+/* Driver pre-compile time settings. */
+/*===========================================================================*/
+
+/**
+ * @name Configuration options
+ * @{
+ */
+
+/**
+ * @brief SysTick timer IRQ priority.
+ */
+#if !defined(TIVA_ST_IRQ_PRIORITY) || defined(__DOXYGEN__)
+#define TIVA_ST_IRQ_PRIORITY 2
+#endif
+
+/**
+ * @brief GPTx unit (by number) to be used for free running operations.
+ * @note You must select a 32 bits timer if a 32 bits @p systick_t type
+ * is required.
+ */
+#if !defined(TIVA_ST_TIMER_NUMBER) || defined(__DOXYGEN__)
+#define TIVA_ST_TIMER_NUMBER 0
+#endif
+
+/* TODO: Add description */
+#if !defined(TIVA_ST_USE_WIDE_TIMER) || defined(__DOXYGEN__)
+#define TIVA_ST_USE_WIDE_TIMER TRUE
+#endif
+
+/**
+ * @}
+ */
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+
+#error "Tickless system tick mode is not working yet! Please use the periodic system tick mode."
+
+#if (TIVA_ST_USE_WIDE_TIMER == TRUE)
+
+#if TIVA_ST_TIMER_NUMBER == 0
+#if !TIVA_HAS_WGPT0
+#error "WGPT0 not present"
+#endif
+#define TIVA_ST_TIM WGPT0
+
+#elif TIVA_ST_TIMER_NUMBER == 1
+#if !TIVA_HAS_WGPT1
+#error "WGPT1 not present"
+#endif
+#define TIVA_ST_TIM WGPT1
+
+#elif TIVA_ST_TIMER_NUMBER == 2
+#if !TIVA_HAS_WGPT2
+#error "WGPT2 not present"
+#endif
+#define TIVA_ST_TIM WGPT2
+
+#elif TIVA_ST_TIMER_NUMBER == 3
+#if !TIVA_HAS_WGPT3
+#error "WGPT3 not present"
+#endif
+#define TIVA_ST_TIM WGPT3
+
+#elif TIVA_ST_TIMER_NUMBER == 4
+#if !TIVA_HAS_WGPT4
+#error "WGPT4 not present"
+#endif
+#define TIVA_ST_TIM WGPT4
+
+#elif TIVA_ST_TIMER_NUMBER == 5
+#if !TIVA_HAS_WGPT5
+#error "WGPT5 not present"
+#endif
+#define TIVA_ST_TIM WGPT5
+
+#else
+#error "TIVA_ST_USE_TIMER specifies an unsupported timer"
+#endif
+
+#elif (TIVA_ST_USE_WIDE_TIMER == FALSE)
+
+#if TIVA_ST_TIMER_NUMBER == 0
+#if !TIVA_HAS_GPT0
+#error "GPT0 not present"
+#endif
+#define TIVA_ST_TIM GPT0
+
+#elif TIVA_ST_TIMER_NUMBER == 1
+#if !TIVA_HAS_GPT1
+#error "GPT1 not present"
+#endif
+#define TIVA_ST_TIM GPT1
+
+#elif TIVA_ST_TIMER_NUMBER == 2
+#if !TIVA_HAS_GPT2
+#error "GPT2 not present"
+#endif
+#define TIVA_ST_TIM GPT2
+
+#elif TIVA_ST_TIMER_NUMBER == 3
+#if !TIVA_HAS_GPT3
+#error "GPT3 not present"
+#endif
+#define TIVA_ST_TIM GPT3
+
+#elif TIVA_ST_TIMER_NUMBER == 4
+#if !TIVA_HAS_GPT4
+#error "GPT4 not present"
+#endif
+#define TIVA_ST_TIM GPT4
+
+#elif TIVA_ST_TIMER_NUMBER == 5
+#if !TIVA_HAS_GPT5
+#error "GPT5 not present"
+#endif
+#define TIVA_ST_TIM GPT5
+
+#else
+#error "TIVA_ST_TIMER_NUMBER specifies an unsupported timer"
+#endif
+
+#else
+#error "wrong value defined for TIVA_ST_USE_WIDE_TIMER"
+#endif
+
+#endif
+
+/*===========================================================================*/
+/* Driver data structures and types. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* Driver macros. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* External declarations. */
+/*===========================================================================*/
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void st_lld_init(void);
+#ifdef __cplusplus
+}
+#endif
+
+/*===========================================================================*/
+/* Driver inline functions. */
+/*===========================================================================*/
+
+/**
+ * @brief Returns the time counter value.
+ *
+ * @return The counter value.
+ *
+ * @notapi
+ */
+static inline systime_t st_lld_get_counter(void)
+{
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+ return (systime_t) TIVA_ST_TIM->TAV;
+#else
+ return (systime_t) 0;
+#endif
+}
+
+/**
+ * @brief Starts the alarm.
+ * @note Makes sure that no spurious alarms are triggered after
+ * this call.
+ *
+ * @param[in] time the time to be set for the first alarm
+ *
+ * @notapi
+ */
+static inline void st_lld_start_alarm(systime_t time)
+{
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+ uint64_t temp;
+
+ temp = (uint64_t) time * TIVA_ST_TIM_PRESCALER;
+
+ TIVA_ST_TIM->TAMATCHR = (uint32_t) temp;
+
+ temp = temp >> 32;
+
+ TIVA_ST_TIM->TAPMR = (uint16_t) temp;
+
+ TIVA_ST_TIM->ICR = 0xffffffff;
+ TIVA_ST_TIM->IMR = GPTM_IMR_TAMIM;
+#else
+ (void)time;
+#endif
+}
+
+/**
+ * @brief Stops the alarm interrupt.
+ *
+ * @notapi
+ */
+static inline void st_lld_stop_alarm(void)
+{
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+ TIVA_ST_TIM->IMR = 0;
+#endif
+}
+
+/**
+ * @brief Sets the alarm time.
+ *
+ * @param[in] time the time to be set for the next alarm
+ *
+ * @notapi
+ */
+static inline void st_lld_set_alarm(systime_t time)
+{
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+ uint64_t temp;
+
+ temp = (uint64_t) time * TIVA_ST_TIM_PRESCALER;
+
+ TIVA_ST_TIM->TAMATCHR = (uint32_t) temp;
+
+ temp = temp >> 32;
+
+ TIVA_ST_TIM->TAPMR = (uint16_t) temp;
+#else
+ (void)time;
+#endif
+}
+
+/**
+ * @brief Returns the current alarm time.
+ *
+ * @return The currently set alarm time.
+ *
+ * @notapi
+ */
+static inline systime_t st_lld_get_alarm(void)
+{
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+ uint64_t temp;
+
+ temp = TIVA_ST_TIM->TAPR;
+ temp = temp << 32;
+ temp = TIVA_ST_TIM->TAR;
+
+ temp = temp / TIVA_ST_TIM_PRESCALER;
+
+ return (systime_t) temp;
+#else
+ return (systime_t) 0;
+#endif
+}
+
+/**
+ * @brief Determines if the alarm is active.
+ *
+ * @return The alarm status.
+ * @retval false if the alarm is not active.
+ * @retval true is the alarm is active
+ *
+ * @notapi
+ */
+static inline bool st_lld_is_alarm_active(void)
+{
+#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
+ return (bool) ((TIVA_ST_TIM->IMR & GPTM_IMR_TAMIM) !=0);
+#else
+ return (bool) false;
+#endif
+}
+
+#endif /* _ST_LLD_H_ */
+
+/**
+ * @}
+ */
diff --git a/os/hal/ports/TIVA/LLD/tiva_gpt.h b/os/hal/ports/TIVA/LLD/tiva_gpt.h
new file mode 100644
index 0000000..0644724
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/tiva_gpt.h
@@ -0,0 +1,135 @@
+/*
+ Copyright (C) 2014 Marco Veeneman
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+*/
+
+/**
+ * @file tiva_gpt.h
+ * @brief TIVA GPT registers layout header.
+ *
+ * @addtogroup TIVA_GPT
+ * @{
+ */
+
+#ifndef TIVA_GPT_H_
+#define TIVA_GPT_H_
+
+// cfg
+#define GPTM_CFG_CFG_MASK (7 << 0)
+#define GPTM_CFG_CFG_WHOLE (0 << 0)
+#define GPTM_CFG_CFG_RTC (1 << 0)
+#define GPTM_CFG_CFG_SPLIT (4 << 0)
+
+// tamr
+#define GPTM_TAMR_TAMR_MASK (3 << 0)
+#define GPTM_TAMR_TAMR_ONESHOT (1 << 0)
+#define GPTM_TAMR_TAMR_PERIODIC (2 << 0)
+#define GPTM_TAMR_TAMR_CAPTURE (3 << 0)
+
+#define GPTM_TAMR_TACMR (1 << 2)
+
+#define GPTM_TAMR_TAAMS (1 << 3)
+
+#define GPTM_TAMR_TACDIR (1 << 4)
+
+#define GPTM_TAMR_TAMIE (1 << 5)
+
+#define GPTM_TAMR_TAWOT (1 << 6)
+
+#define GPTM_TAMR_TASNAPS (1 << 7)
+
+#define GPTM_TAMR_TAILD (1 << 8)
+
+#define GPTM_TAMR_TAPWMIE (1 << 9)
+
+#define GPTM_TAMR_TAMRSU (1 << 10)
+
+#define GPTM_TAMR_TAPLO (1 << 11)
+
+// ctl
+#define GPTM_CTL_TAEN (1 << 0)
+
+#define GPTM_CTL_TASTALL (1 << 1)
+
+#define GPTM_CTL_TAEVENT_MASK (3 << 2)
+#define GPTM_CTL_TAEVENT_POS (0 << 2)
+#define GPTM_CTL_TAEVENT_NEG (1 << 2)
+#define GPTM_CTL_TAEVENT_BOTH (3 << 2)
+
+#define GPTM_CTL_RTCEN (1 << 4)
+
+#define GPTM_CTL_TAOTE (1 << 5)
+
+#define GPTM_CTL_TAPWML (1 << 6)
+
+#define GPTM_CTL_TBEN (1 << 8)
+
+#define GPTM_CTL_TBSTALL (1 << 9)
+
+#define GPTM_CTL_TBEVENT_MASK (3 << 10)
+#define GPTM_CTL_TBEVENT_POS (0 << 10)
+#define GPTM_CTL_TBEVENT_NEG (1 << 10)
+#define GPTM_CTL_TBEVENT_BOTH (3 << 10)
+
+#define GPTM_CTL_TBOTE (1 << 13)
+
+#define GPTM_CTL_TBPWML (1 << 14)
+
+// imr
+#define GPTM_IMR_TATOIM (1 << 0)
+
+#define GPTM_IMR_CAMIM (1 << 1)
+
+#define GPTM_IMR_CAEIM (1 << 2)
+
+#define GPTM_IMR_RTCIM (1 << 3)
+
+#define GPTM_IMR_TAMIM (1 << 4)
+
+#define GPTM_IMR_TBTOIM (1 << 8)
+
+#define GPTM_IMR_CBMIM (1 << 9)
+
+#define GPTM_IMR_CBEIM (1 << 10)
+
+#define GPTM_IMR_TBMIM (1 << 11)
+
+#define GPTM_IMR_WUEIM (1 << 16)
+
+// icr
+#define GPTM_ICR_TATOCINT (1 << 0)
+
+#define GPTM_ICR_CAMCINT (1 << 1)
+
+#define GPTM_ICR_CAECINT (1 << 2)
+
+#define GPTM_ICR_RTCCINT (1 << 3)
+
+#define GPTM_ICR_TAMCINT (1 << 4)
+
+#define GPTM_ICR_TBTOCINT (1 << 8)
+
+#define GPTM_ICR_CBMCINT (1 << 9)
+
+#define GPTM_ICR_CBECINT (1 << 10)
+
+#define GPTM_ICR_TBMCINT (1 << 11)
+
+#define GPTM_ICR_WUECINT (1 << 16)
+
+#endif /* TIVA_GPT_H_ */
+
+/*
+ * @}
+ */