aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/ports/TIVA/LLD/GPTM
diff options
context:
space:
mode:
Diffstat (limited to 'os/hal/ports/TIVA/LLD/GPTM')
-rw-r--r--os/hal/ports/TIVA/LLD/GPTM/hal_gpt_lld.c756
-rw-r--r--os/hal/ports/TIVA/LLD/GPTM/hal_gpt_lld.h501
-rw-r--r--os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.c255
-rw-r--r--os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.h270
4 files changed, 1782 insertions, 0 deletions
diff --git a/os/hal/ports/TIVA/LLD/GPTM/hal_gpt_lld.c b/os/hal/ports/TIVA/LLD/GPTM/hal_gpt_lld.c
new file mode 100644
index 0000000..60d2b82
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/GPTM/hal_gpt_lld.c
@@ -0,0 +1,756 @@
+/*
+ Copyright (C) 2014..2016 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)
+{
+ HWREG(gptp->gpt + TIMER_O_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 = TIMER0_BASE;
+ gptObjectInit(&GPTD1);
+#endif
+
+#if TIVA_GPT_USE_GPT1
+ GPTD2.gpt = TIMER1_BASE;
+ gptObjectInit(&GPTD2);
+#endif
+
+#if TIVA_GPT_USE_GPT2
+ GPTD3.gpt = TIMER2_BASE;
+ gptObjectInit(&GPTD3);
+#endif
+
+#if TIVA_GPT_USE_GPT3
+ GPTD4.gpt = TIMER3_BASE;
+ gptObjectInit(&GPTD4);
+#endif
+
+#if TIVA_GPT_USE_GPT4
+ GPTD5.gpt = TIMER4_BASE;
+ gptObjectInit(&GPTD5);
+#endif
+
+#if TIVA_GPT_USE_GPT5
+ GPTD6.gpt = TIMER5_BASE;
+ gptObjectInit(&GPTD6);
+#endif
+
+#if TIVA_GPT_USE_WGPT0
+ GPTD7.gpt = WTIMER0_BASE;
+ gptObjectInit(&GPTD7);
+#endif
+
+#if TIVA_GPT_USE_WGPT1
+ GPTD8.gpt = WTIMER1_BASE;
+ gptObjectInit(&GPTD8);
+#endif
+
+#if TIVA_GPT_USE_WGPT2
+ GPTD9.gpt = WTIMER2_BASE;
+ gptObjectInit(&GPTD9);
+#endif
+
+#if TIVA_GPT_USE_WGPT3
+ GPTD10.gpt = WTIMER3_BASE;
+ gptObjectInit(&GPTD10);
+#endif
+
+#if TIVA_GPT_USE_WGPT4
+ GPTD11.gpt = WTIMER4_BASE;
+ gptObjectInit(&GPTD11);
+#endif
+
+#if TIVA_GPT_USE_WGPT5
+ GPTD12.gpt = WTIMER5_BASE;
+ 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) {
+ HWREG(SYSCTL_RCGCTIMER) |= (1 << 0);
+
+ while (!(HWREG(SYSCTL_PRTIMER) & (1 << 0)))
+ ;
+
+ nvicEnableVector(TIVA_GPT0A_NUMBER, TIVA_GPT_GPT0A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT1
+ if (&GPTD2 == gptp) {
+ HWREG(SYSCTL_RCGCTIMER) |= (1 << 1);
+
+ while (!(HWREG(SYSCTL_PRTIMER) & (1 << 1)))
+ ;
+
+ nvicEnableVector(TIVA_GPT1A_NUMBER, TIVA_GPT_GPT1A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT2
+ if (&GPTD3 == gptp) {
+ HWREG(SYSCTL_RCGCTIMER) |= (1 << 2);
+
+ while (!(HWREG(SYSCTL_PRTIMER) & (1 << 2)))
+ ;
+
+ nvicEnableVector(TIVA_GPT2A_NUMBER, TIVA_GPT_GPT2A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT3
+ if (&GPTD4 == gptp) {
+ HWREG(SYSCTL_RCGCTIMER) |= (1 << 3);
+
+ while (!(HWREG(SYSCTL_PRTIMER) & (1 << 3)))
+ ;
+
+ nvicEnableVector(TIVA_GPT3A_NUMBER, TIVA_GPT_GPT3A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT4
+ if (&GPTD5 == gptp) {
+ HWREG(SYSCTL_RCGCTIMER) |= (1 << 4);
+
+ while (!(HWREG(SYSCTL_PRTIMER) & (1 << 4)))
+ ;
+
+ nvicEnableVector(TIVA_GPT4A_NUMBER, TIVA_GPT_GPT4A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT5
+ if (&GPTD6 == gptp) {
+ HWREG(SYSCTL_RCGCTIMER) |= (1 << 5);
+
+ while (!(HWREG(SYSCTL_PRTIMER) & (1 << 5)))
+ ;
+
+ nvicEnableVector(TIVA_GPT5A_NUMBER, TIVA_GPT_GPT5A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT0
+ if (&GPTD7 == gptp) {
+ HWREG(SYSCTL_RCGCWTIMER) |= (1 << 0);
+
+ while (!(HWREG(SYSCTL_PRWTIMER) & (1 << 0)))
+ ;
+
+ nvicEnableVector(TIVA_WGPT0A_NUMBER, TIVA_GPT_WGPT0A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT1
+ if (&GPTD8 == gptp) {
+ HWREG(SYSCTL_RCGCWTIMER) |= (1 << 1);
+
+ while (!(HWREG(SYSCTL_PRWTIMER) & (1 << 1)))
+ ;
+
+ nvicEnableVector(TIVA_WGPT1A_NUMBER, TIVA_GPT_WGPT1A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT2
+ if (&GPTD9 == gptp) {
+ HWREG(SYSCTL_RCGCWTIMER) |= (1 << 2);
+
+ while (!(HWREG(SYSCTL_PRWTIMER) & (1 << 2)))
+ ;
+
+ nvicEnableVector(TIVA_WGPT2A_NUMBER, TIVA_GPT_WGPT2A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT3
+ if (&GPTD10 == gptp) {
+ HWREG(SYSCTL_RCGCWTIMER) |= (1 << 3);
+
+ while (!(HWREG(SYSCTL_PRWTIMER) & (1 << 3)))
+ ;
+
+ nvicEnableVector(TIVA_WGPT3A_NUMBER, TIVA_GPT_WGPT3A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT4
+ if (&GPTD11 == gptp) {
+ HWREG(SYSCTL_RCGCWTIMER) |= (1 << 4);
+
+ while (!(HWREG(SYSCTL_PRWTIMER) & (1 << 4)))
+ ;
+
+ nvicEnableVector(TIVA_WGPT4A_NUMBER, TIVA_GPT_WGPT4A_IRQ_PRIORITY);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT5
+ if (&GPTD12 == gptp) {
+ HWREG(SYSCTL_RCGCWTIMER) |= (1 << 5);
+
+ while (!(HWREG(SYSCTL_PRWTIMER) & (1 << 5)))
+ ;
+
+ nvicEnableVector(TIVA_WGPT5A_NUMBER, TIVA_GPT_WGPT5A_IRQ_PRIORITY);
+ }
+#endif
+ }
+
+ /* Timer configuration.*/
+ HWREG(gptp->gpt + TIMER_O_CTL) = 0;
+ HWREG(gptp->gpt + TIMER_O_CFG) = TIMER_CFG_16_BIT;
+ HWREG(gptp->gpt + TIMER_O_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) {
+ HWREG(gptp->gpt + TIMER_O_IMR) = 0;
+ HWREG(gptp->gpt + TIMER_O_TAILR) = 0;
+ HWREG(gptp->gpt + TIMER_O_CTL) = 0;
+
+#if TIVA_GPT_USE_GPT0
+ if (&GPTD1 == gptp) {
+ nvicDisableVector(TIVA_GPT0A_NUMBER);
+ HWREG(SYSCTL_RCGCTIMER) &= ~(1 << 0);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT1
+ if (&GPTD2 == gptp) {
+ nvicDisableVector(TIVA_GPT1A_NUMBER);
+ HWREG(SYSCTL_RCGCTIMER) &= ~(1 << 1);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT2
+ if (&GPTD3 == gptp) {
+ nvicDisableVector(TIVA_GPT2A_NUMBER);
+ HWREG(SYSCTL_RCGCTIMER) &= ~(1 << 2);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT3
+ if (&GPTD4 == gptp) {
+ nvicDisableVector(TIVA_GPT3A_NUMBER);
+ HWREG(SYSCTL_RCGCTIMER) &= ~(1 << 3);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT4
+ if (&GPTD5 == gptp) {
+ nvicDisableVector(TIVA_GPT4A_NUMBER);
+ HWREG(SYSCTL_RCGCTIMER) &= ~(1 << 4);
+ }
+#endif
+
+#if TIVA_GPT_USE_GPT5
+ if (&GPTD6 == gptp) {
+ nvicDisableVector(TIVA_GPT5A_NUMBER);
+ HWREG(SYSCTL_RCGCTIMER) &= ~(1 << 5);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT0
+ if (&GPTD7 == gptp) {
+ nvicDisableVector(TIVA_WGPT0A_NUMBER);
+ HWREG(SYSCTL_RCGCWTIMER) &= ~(1 << 0);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT1
+ if (&GPTD8 == gptp) {
+ nvicDisableVector(TIVA_WGPT1A_NUMBER);
+ HWREG(SYSCTL_RCGCWTIMER) &= ~(1 << 1);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT2
+ if (&GPTD9 == gptp) {
+ nvicDisableVector(TIVA_WGPT2A_NUMBER);
+ HWREG(SYSCTL_RCGCWTIMER) &= ~(1 << 2);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT3
+ if (&GPTD10 == gptp) {
+ nvicDisableVector(TIVA_WGPT3A_NUMBER);
+ HWREG(SYSCTL_RCGCWTIMER) &= ~(1 << 3);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT4
+ if (&GPTD11 == gptp) {
+ nvicDisableVector(TIVA_WGPT4A_NUMBER);
+ HWREG(SYSCTL_RCGCWTIMER) &= ~(1 << 4);
+ }
+#endif
+
+#if TIVA_GPT_USE_WGPT5
+ if (&GPTD12 == gptp) {
+ nvicDisableVector(TIVA_WGPT5A_NUMBER);
+ HWREG(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)
+{
+ HWREG(gptp->gpt + TIMER_O_TAILR) = interval - 1;
+ HWREG(gptp->gpt + TIMER_O_ICR) = 0xfffffff;
+ HWREG(gptp->gpt + TIMER_O_IMR) = TIMER_IMR_TATOIM;
+ HWREG(gptp->gpt + TIMER_O_TAMR) = TIMER_TAMR_TAMR_PERIOD | TIMER_TAMR_TAILD | TIMER_TAMR_TASNAPS;
+ HWREG(gptp->gpt + TIMER_O_CTL) = TIMER_CTL_TAEN | TIMER_CTL_TASTALL;
+}
+
+/**
+ * @brief Stops the timer.
+ *
+ * @param[in] gptp pointer to the @p GPTDriver object
+ *
+ * @notapi
+ */
+void gpt_lld_stop_timer(GPTDriver *gptp)
+{
+ HWREG(gptp->gpt + TIMER_O_IMR) = 0;
+ HWREG(gptp->gpt + TIMER_O_TAILR) = 0;
+ HWREG(gptp->gpt + TIMER_O_CTL) &= ~TIMER_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)
+{
+ HWREG(gptp->gpt + TIMER_O_TAMR) = TIMER_TAMR_TAMR_1_SHOT | TIMER_TAMR_TAILD | TIMER_TAMR_TASNAPS;
+ HWREG(gptp->gpt + TIMER_O_TAILR) = interval - 1;
+ HWREG(gptp->gpt + TIMER_O_ICR) = 0xffffffff;
+ HWREG(gptp->gpt + TIMER_O_CTL) = TIMER_CTL_TAEN | TIMER_CTL_TASTALL;
+ while (!(HWREG(gptp->gpt + TIMER_O_RIS) & TIMER_IMR_TATOIM))
+ ;
+ HWREG(gptp->gpt + TIMER_O_ICR) = 0xffffffff;
+}
+
+#endif /* HAL_USE_GPT */
+
+/** @} */
diff --git a/os/hal/ports/TIVA/LLD/GPTM/hal_gpt_lld.h b/os/hal/ports/TIVA/LLD/GPTM/hal_gpt_lld.h
new file mode 100644
index 0000000..88a6809
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/GPTM/hal_gpt_lld.h
@@ -0,0 +1,501 @@
+/*
+ Copyright (C) 2014..2016 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 HAL_GPT_LLD_H
+#define HAL_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 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_GPT0A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT0"
+#endif
+
+#if TIVA_GPT_USE_GPT1 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_GPT1A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT1"
+#endif
+
+#if TIVA_GPT_USE_GPT2 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_GPT2A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT2"
+#endif
+
+#if TIVA_GPT_USE_GPT3 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_GPT3A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT3"
+#endif
+
+#if TIVA_GPT_USE_GPT4 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_GPT4A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT4"
+#endif
+
+#if TIVA_GPT_USE_GPT5 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_GPT5A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to GPT5"
+#endif
+
+#if TIVA_GPT_USE_WGPT0 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_WGPT0A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT0"
+#endif
+
+#if TIVA_GPT_USE_WGPT1 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_WGPT1A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT1"
+#endif
+
+#if TIVA_GPT_USE_WGPT2 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_WGPT2A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT2"
+#endif
+
+#if TIVA_GPT_USE_WGPT3 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_WGPT3A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT3"
+#endif
+
+#if TIVA_GPT_USE_WGPT4 && \
+ !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_GPT_WGPT4A_IRQ_PRIORITY)
+#error "Invalid IRQ priority assigned to WGPT4"
+#endif
+
+#if TIVA_GPT_USE_WGPT5 && \
+ !OSAL_IRQ_IS_VALID_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.
+ */
+ uint32_t 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) { \
+ HWREG(gptp->gpt + TIMER_O_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 /* HAL_GPT_LLD_H */
+
+/** @} */
diff --git a/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.c b/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.c
new file mode 100644
index 0000000..d87652b
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.c
@@ -0,0 +1,255 @@
+/*
+ Copyright (C) 2014..2016 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
+#define ST_HANDLER TIVA_WGPT0A_HANDLER
+#define ST_NUMBER TIVA_WGPT0A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 0))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRWTIMER & (1 << 0)))
+
+#elif TIVA_ST_TIMER_NUMBER == 1
+#define ST_HANDLER TIVA_WGPT1A_HANDLER
+#define ST_NUMBER TIVA_WGPT1A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 1))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRWTIMER & (1 << 1)))
+
+#elif TIVA_ST_TIMER_NUMBER == 2
+#define ST_HANDLER TIVA_WGPT2A_HANDLER
+#define ST_NUMBER TIVA_WGPT2A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 2))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRWTIMER & (1 << 2)))
+
+#elif TIVA_ST_TIMER_NUMBER == 3
+#define ST_HANDLER TIVA_WGPT3A_HANDLER
+#define ST_NUMBER TIVA_WGPT3A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 3))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRWTIMER & (1 << 3)))
+
+#elif TIVA_ST_TIMER_NUMBER == 4
+#define ST_HANDLER TIVA_WGPT4A_HANDLER
+#define ST_NUMBER TIVA_WGPT4A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 4))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRWTIMER & (1 << 4)))
+
+#elif TIVA_ST_TIMER_NUMBER == 5
+#define ST_HANDLER TIVA_WGPT5A_HANDLER
+#define ST_NUMBER TIVA_WGPT5A_NUMBER
+#define ST_ENABLE_CLOCK() (HWREG(SYSCTL_RCGCWTIMER) |= (1 << 5))
+#define ST_WAIT_CLOCK() while (!(HWREG(SYSCTL_PRWTIMER) & (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
+#define ST_HANDLER TIVA_GPT0A_HANDLER
+#define ST_NUMBER TIVA_GPT0A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 0))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRTIMER & (1 << 0)))
+
+#elif TIVA_ST_TIMER_NUMBER == 1
+#define ST_HANDLER TIVA_GPT1A_HANDLER
+#define ST_NUMBER TIVA_GPT1A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 1))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRTIMER & (1 << 1)))
+
+#elif TIVA_ST_TIMER_NUMBER == 2
+#define ST_HANDLER TIVA_GPT2A_HANDLER
+#define ST_NUMBER TIVA_GPT2A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 2))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRTIMER & (1 << 2)))
+
+#elif TIVA_ST_TIMER_NUMBER == 3
+#define ST_HANDLER TIVA_GPT3A_HANDLER
+#define ST_NUMBER TIVA_GPT3A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 3))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRTIMER & (1 << 3)))
+
+#elif TIVA_ST_TIMER_NUMBER == 4
+#define ST_HANDLER TIVA_GPT4A_HANDLER
+#define ST_NUMBER TIVA_GPT4A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 4))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRTIMER & (1 << 4)))
+
+#elif TIVA_ST_TIMER_NUMBER == 5
+#define ST_HANDLER TIVA_GPT5A_HANDLER
+#define ST_NUMBER TIVA_GPT5A_NUMBER
+#define ST_ENABLE_CLOCK() (SYSCTL->RCGCTIMER |= (1 << 5))
+#define ST_WAIT_CLOCK() while (!(SYSCTL->PRTIMER & (1 << 5)))
+
+#else
+#error "TIVA_ST_USE_TIMER specifies an unsupported timer"
+#endif
+
+#if (TIVA_SYSCLK / OSAL_ST_FREQUENCY) - 1 > 0xFF
+#error "the selected ST frequency is not obtainable because TIM timer prescaler limits"
+#endif
+
+#endif
+
+#if TIVA_SYSCLK % OSAL_ST_FREQUENCY != 0
+#error "the selected ST frequency is not obtainable because integer rounding"
+#endif
+
+#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 GPT interrupt handler.
+ * @details This interrupt is used for system tick in free running mode.
+ *
+ * @isr
+ */
+OSAL_IRQ_HANDLER(ST_HANDLER)
+{
+ uint32_t mis;
+
+ OSAL_IRQ_PROLOGUE();
+
+ mis = HWREG(TIVA_ST_TIM + TIMER_O_MIS);
+ HWREG(TIVA_ST_TIM + TIMER_O_ICR) = mis;
+
+ if (mis & TIMER_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();
+
+ /* Wait until timer peripheral is ready */
+ ST_WAIT_CLOCK();
+
+ /* Initializing the counter in free running down mode.*/
+ HWREG(TIVA_ST_TIM + TIMER_O_CTL) = 0;
+ HWREG(TIVA_ST_TIM + TIMER_O_CFG) = TIMER_CFG_16_BIT; /* Timer split mode */
+ HWREG(TIVA_ST_TIM + TIMER_O_TAMR) = (
+ TIMER_TAMR_TAMR_PERIOD | /* Periodic mode */
+ TIMER_TAMR_TAMIE | /* Match interrupt enable */
+ TIMER_TAMR_TASNAPS); /* Snapshot mode */
+
+ HWREG(TIVA_ST_TIM + TIMER_O_TAPR) = (TIVA_SYSCLK / OSAL_ST_FREQUENCY) - 1;
+ HWREG(TIVA_ST_TIM + TIMER_O_CTL) = (
+ TIMER_CTL_TAEN | /* Timer A enable */
+ TIMER_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/GPTM/hal_st_lld.h b/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.h
new file mode 100644
index 0000000..cd076d6
--- /dev/null
+++ b/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.h
@@ -0,0 +1,270 @@
+/*
+ Copyright (C) 2014..2016 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 HAL_ST_LLD_H
+#define HAL_ST_LLD_H
+
+#include "mcuconf.h"
+#include "tiva_registry.h"
+
+/*===========================================================================*/
+/* Driver constants. */
+/*===========================================================================*/
+
+/*===========================================================================*/
+/* 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
+
+/**
+ * @brief When set to @p TRUE a wide timer is used. When set to @p FALSE a
+ * normal timer is used.
+ */
+#if !defined(TIVA_ST_USE_WIDE_TIMER) || defined(__DOXYGEN__)
+#define TIVA_ST_USE_WIDE_TIMER TRUE
+#endif
+
+/**
+ * @}
+ */
+
+/*===========================================================================*/
+/* Derived constants and error checks. */
+/*===========================================================================*/
+
+#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 WTIMER0_BASE
+
+#elif TIVA_ST_TIMER_NUMBER == 1
+#if !TIVA_HAS_WGPT1
+#error "WGPT1 not present"
+#endif
+#define TIVA_ST_TIM WTIMER1_BASE
+
+#elif TIVA_ST_TIMER_NUMBER == 2
+#if !TIVA_HAS_WGPT2
+#error "WGPT2 not present"
+#endif
+#define TIVA_ST_TIM WTIMER2_BASE
+
+#elif TIVA_ST_TIMER_NUMBER == 3
+#if !TIVA_HAS_WGPT3
+#error "WGPT3 not present"
+#endif
+#define TIVA_ST_TIM WTIMER3_BASE
+
+#elif TIVA_ST_TIMER_NUMBER == 4
+#if !TIVA_HAS_WGPT4
+#error "WGPT4 not present"
+#endif
+#define TIVA_ST_TIM WTIMER4_BASE
+
+#elif TIVA_ST_TIMER_NUMBER == 5
+#if !TIVA_HAS_WGPT5
+#error "WGPT5 not present"
+#endif
+#define TIVA_ST_TIM WTIMER5_BASE
+
+#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 TIMER0_BASE
+
+#elif TIVA_ST_TIMER_NUMBER == 1
+#if !TIVA_HAS_GPT1
+#error "GPT1 not present"
+#endif
+#define TIVA_ST_TIM TIMER1_BASE
+
+#elif TIVA_ST_TIMER_NUMBER == 2
+#if !TIVA_HAS_GPT2
+#error "GPT2 not present"
+#endif
+#define TIVA_ST_TIM TIMER2_BASE
+
+#elif TIVA_ST_TIMER_NUMBER == 3
+#if !TIVA_HAS_GPT3
+#error "GPT3 not present"
+#endif
+#define TIVA_ST_TIM TIMER3_BASE
+
+#elif TIVA_ST_TIMER_NUMBER == 4
+#if !TIVA_HAS_GPT4
+#error "GPT4 not present"
+#endif
+#define TIVA_ST_TIM TIMER4_BASE
+
+#elif TIVA_ST_TIMER_NUMBER == 5
+#if !TIVA_HAS_GPT5
+#error "GPT5 not present"
+#endif
+#define TIVA_ST_TIM TIMER5_BASE
+
+#else
+#error "TIVA_ST_TIMER_NUMBER specifies an unsupported timer"
+#endif
+
+#else
+#error "wrong value defined for TIVA_ST_USE_WIDE_TIMER"
+#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)
+{
+ return (systime_t) (((systime_t) 0xffffffff) - HWREG(TIVA_ST_TIM + TIMER_O_TAV));
+}
+
+/**
+ * @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)
+{
+ HWREG(TIVA_ST_TIM + TIMER_O_TAMATCHR) = (systime_t) (((systime_t) 0xffffffff) - time);
+ HWREG(TIVA_ST_TIM + TIMER_O_ICR) = HWREG(TIVA_ST_TIM + TIMER_O_MIS);
+ HWREG(TIVA_ST_TIM + TIMER_O_IMR) = TIMER_IMR_TAMIM;
+}
+
+/**
+ * @brief Stops the alarm interrupt.
+ *
+ * @notapi
+ */
+static inline void st_lld_stop_alarm(void)
+{
+ HWREG(TIVA_ST_TIM + TIMER_O_IMR) = 0;
+}
+
+/**
+ * @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)
+{
+ HWREG(TIVA_ST_TIM + TIMER_O_TAMATCHR) = (systime_t) (((systime_t) 0xffffffff) - time);
+}
+
+/**
+ * @brief Returns the current alarm time.
+ *
+ * @return The currently set alarm time.
+ *
+ * @notapi
+ */
+static inline systime_t st_lld_get_alarm(void)
+{
+ return (systime_t) (((systime_t)0xffffffff) - HWREG(TIVA_ST_TIM + TIMER_O_TAMATCHR));
+}
+
+/**
+ * @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)
+{
+ return (bool) ((HWREG(TIVA_ST_TIM + TIMER_O_IMR) & TIMER_IMR_TAMIM) !=0);
+}
+
+#endif /* HAL_ST_LLD_H */
+
+/**
+ * @}
+ */