aboutsummaryrefslogtreecommitdiffstats
path: root/os
diff options
context:
space:
mode:
authormarcoveeneman <marco-veeneman@hotmail.com>2016-10-08 19:51:16 +0200
committermarcoveeneman <marco-veeneman@hotmail.com>2016-10-08 19:51:16 +0200
commit3e069788d9d21be39fc298685b4e991685fe14a9 (patch)
tree3f7907eeea04f5db50bdccc65450f7f10bb870b9 /os
parentf8d62560b7e9f136f3d204e18cc321cdffc0ef80 (diff)
downloadChibiOS-Contrib-3e069788d9d21be39fc298685b4e991685fe14a9.tar.gz
ChibiOS-Contrib-3e069788d9d21be39fc298685b4e991685fe14a9.tar.bz2
ChibiOS-Contrib-3e069788d9d21be39fc298685b4e991685fe14a9.zip
Updated st_lld to use TivaWare.
Tickless mode is working again. Fixed st_lld_get_counter reading the wrong register.
Diffstat (limited to 'os')
-rw-r--r--os/common/startup/ARMCMx/devices/TM4C123x/cmparams.h1
-rw-r--r--os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.c18
-rw-r--r--os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.h26
3 files changed, 23 insertions, 22 deletions
diff --git a/os/common/startup/ARMCMx/devices/TM4C123x/cmparams.h b/os/common/startup/ARMCMx/devices/TM4C123x/cmparams.h
index 8aaecbf..bacd786 100644
--- a/os/common/startup/ARMCMx/devices/TM4C123x/cmparams.h
+++ b/os/common/startup/ARMCMx/devices/TM4C123x/cmparams.h
@@ -108,6 +108,7 @@ typedef int IRQn_Type;
#include "inc/hw_sysctl.h"
#include "inc/hw_gpio.h"
#include "inc/hw_uart.h"
+#include "inc/hw_timer.h"
#if CORTEX_NUM_VECTORS != ((((NUM_INTERRUPTS - 16) + 7) / 8) * 8)
#error "TivaWare NUM_INTERRUPTS mismatch"
diff --git a/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.c b/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.c
index 30fdb8a..c98a30f 100644
--- a/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.c
+++ b/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.c
@@ -67,8 +67,8 @@
#elif TIVA_ST_TIMER_NUMBER == 5
#define ST_HANDLER TIVA_WGPT5A_HANDLER
#define ST_NUMBER TIVA_WGPT5A_NUMBER
-#define ST_ENABLE_CLOCK() (SYSCTL->RCGCWTIMER |= (1 << 5))
-#define ST_WAIT_CLOCK() while (!(SYSCTL->PRWTIMER & (1 << 5)))
+#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"
@@ -184,8 +184,8 @@ OSAL_IRQ_HANDLER(ST_HANDLER)
OSAL_IRQ_PROLOGUE();
- mis = TIVA_ST_TIM->MIS;
- TIVA_ST_TIM->ICR = mis;
+ mis = HWREG(TIVA_ST_TIM + TIMER_O_MIS);
+ HWREG(TIVA_ST_TIM + TIMER_O_ICR) = mis;
if (mis & GPTM_IMR_TAMIM) {
osalSysLockFromISR();
@@ -218,14 +218,14 @@ void st_lld_init(void)
ST_WAIT_CLOCK();
/* Initializing the counter in free running down 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 */
+ HWREG(TIVA_ST_TIM + TIMER_O_CTL) = 0;
+ HWREG(TIVA_ST_TIM + TIMER_O_CFG) = GPTM_CFG_CFG_SPLIT; /* Timer split mode */
+ HWREG(TIVA_ST_TIM + TIMER_O_TAMR) = (GPTM_TAMR_TAMR_PERIODIC |/* Periodic mode */
GPTM_TAMR_TAMIE | /* Match interrupt enable */
GPTM_TAMR_TASNAPS); /* Snapshot mode */
- TIVA_ST_TIM->TAPR = (TIVA_SYSCLK / OSAL_ST_FREQUENCY) - 1;
- TIVA_ST_TIM->CTL = (GPTM_CTL_TAEN | /* Timer A enable */
+ HWREG(TIVA_ST_TIM + TIMER_O_TAPR) = (TIVA_SYSCLK / OSAL_ST_FREQUENCY) - 1;
+ HWREG(TIVA_ST_TIM + TIMER_O_CTL) = (GPTM_CTL_TAEN | /* Timer A enable */
GPTM_CTL_TASTALL); /* Timer A stall when paused */
/* IRQ enabled.*/
diff --git a/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.h b/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.h
index 027304b..177b9ba 100644
--- a/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.h
+++ b/os/hal/ports/TIVA/LLD/GPTM/hal_st_lld.h
@@ -112,7 +112,7 @@
#if !TIVA_HAS_WGPT5
#error "WGPT5 not present"
#endif
-#define TIVA_ST_TIM WGPT5
+#define TIVA_ST_TIM WTIMER5_BASE
#else
#error "TIVA_ST_USE_TIMER specifies an unsupported timer"
@@ -164,10 +164,10 @@
#error "wrong value defined for TIVA_ST_USE_WIDE_TIMER"
#endif
-#if OSAL_ST_MODE != OSAL_ST_MODE_NONE && \
- !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_ST_IRQ_PRIORITY)
-#error "Invalid IRQ priority assigned to ST"
-#endif
+//#if OSAL_ST_MODE != OSAL_ST_MODE_NONE && \
+// !OSAL_IRQ_IS_VALID_PRIORITY(TIVA_ST_IRQ_PRIORITY)
+//#error "Invalid IRQ priority assigned to ST"
+//#endif
/*===========================================================================*/
/* Driver data structures and types. */
@@ -203,7 +203,7 @@ extern "C" {
static inline systime_t st_lld_get_counter(void)
{
#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
- return (systime_t) (((systime_t) 0xffffffff) - TIVA_ST_TIM->TAR);
+ return (systime_t) (((systime_t) 0xffffffff) - HWREG(TIVA_ST_TIM + TIMER_O_TAV));
#else
return 0;
#endif
@@ -221,9 +221,9 @@ static inline systime_t st_lld_get_counter(void)
static inline void st_lld_start_alarm(systime_t time)
{
#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
- TIVA_ST_TIM->TAMATCHR = (systime_t) (((systime_t) 0xffffffff) - time);
- TIVA_ST_TIM->ICR = TIVA_ST_TIM->MIS;
- TIVA_ST_TIM->IMR = GPTM_IMR_TAMIM;
+ 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) = GPTM_IMR_TAMIM;
#endif
}
@@ -235,7 +235,7 @@ static inline void st_lld_start_alarm(systime_t time)
static inline void st_lld_stop_alarm(void)
{
#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
- TIVA_ST_TIM->IMR = 0;
+ HWREG(TIVA_ST_TIM + TIMER_O_IMR) = 0;
#endif
}
@@ -249,7 +249,7 @@ static inline void st_lld_stop_alarm(void)
static inline void st_lld_set_alarm(systime_t time)
{
#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
- TIVA_ST_TIM->TAMATCHR = (systime_t) (((systime_t) 0xffffffff) - time);
+ HWREG(TIVA_ST_TIM + TIMER_O_TAMATCHR) = (systime_t) (((systime_t) 0xffffffff) - time);
#endif
}
@@ -263,7 +263,7 @@ static inline void st_lld_set_alarm(systime_t time)
static inline systime_t st_lld_get_alarm(void)
{
#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING
- return (systime_t) (((systime_t)0xffffffff) - TIVA_ST_TIM->TAMATCHR);
+ return (systime_t) (((systime_t)0xffffffff) - HWREG(TIVA_ST_TIM + TIMER_O_TAMATCHR));
#else
return 0;
#endif
@@ -281,7 +281,7 @@ static inline systime_t st_lld_get_alarm(void)
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);
+ return (bool) ((HWREG(TIVA_ST_TIM + TIMER_O_IMR) & GPTM_IMR_TAMIM) !=0);
#else
return false;
#endif