diff options
Diffstat (limited to 'os/hal/ports/TIVA/LLD')
-rw-r--r-- | os/hal/ports/TIVA/LLD/st_lld.c | 15 | ||||
-rw-r--r-- | os/hal/ports/TIVA/LLD/st_lld.h | 96 |
2 files changed, 5 insertions, 106 deletions
diff --git a/os/hal/ports/TIVA/LLD/st_lld.c b/os/hal/ports/TIVA/LLD/st_lld.c index 538cf2e..bd744a6 100644 --- a/os/hal/ports/TIVA/LLD/st_lld.c +++ b/os/hal/ports/TIVA/LLD/st_lld.c @@ -35,42 +35,36 @@ #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) @@ -87,42 +81,36 @@ #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) @@ -230,8 +218,7 @@ void st_lld_init(void) 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_TAMIE | /* Match interrupt enable */ - /*GPTM_TAMR_TASNAPS*/0); /* Snapshot mode */ + GPTM_TAMR_TAMIE); /* Match interrupt enable */ TIVA_ST_TIM->TAPR = (ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1; TIVA_ST_TIM->CTL = (GPTM_CTL_TAEN | /* Timer A enable */ GPTM_CTL_TASTALL); /* Timer A stall when paused */ diff --git a/os/hal/ports/TIVA/LLD/st_lld.h b/os/hal/ports/TIVA/LLD/st_lld.h index c2e1a80..86a31c0 100644 --- a/os/hal/ports/TIVA/LLD/st_lld.h +++ b/os/hal/ports/TIVA/LLD/st_lld.h @@ -35,8 +35,6 @@ /* Driver constants. */ /*===========================================================================*/ -#define TIVA_ST_TIM_PRESCALER ((80000000 / 10000) - 1) - /*===========================================================================*/ /* Driver pre-compile time settings. */ /*===========================================================================*/ @@ -62,7 +60,10 @@ #define TIVA_ST_TIMER_NUMBER 0 #endif -/* TODO: Add description */ +/** + * @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 @@ -75,10 +76,6 @@ /* 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 @@ -167,8 +164,6 @@ #error "wrong value defined for TIVA_ST_USE_WIDE_TIMER" #endif -#endif - /*===========================================================================*/ /* Driver data structures and types. */ /*===========================================================================*/ @@ -193,9 +188,6 @@ extern "C" { /* Driver inline functions. */ /*===========================================================================*/ -#define OSAL_ST_FREQUENCY 10000 -#define ST_CLOCK_SRC 80000000 - /** * @brief Returns the time counter value. * @@ -205,13 +197,7 @@ extern "C" { */ static inline systime_t st_lld_get_counter(void) { -#if OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING return (systime_t) 0xffffffff - TIVA_ST_TIM->TAV; - //return (systime_t) TIVA_ST_TIM->TAV/((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); - //return (systime_t) ((TIVA_ST_TIM->TAV >> 16) | (TIVA_ST_TIM->TAPV << 16))/((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); -#else - return (systime_t) 0; -#endif } /** @@ -225,38 +211,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 -// 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; - -// uint64_t settime = time * ((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); -// -// TIVA_ST_TIM->TAPMR = (uint16_t) ((settime >> 32) & 0xffff); -// TIVA_ST_TIM->TAMATCHR = (uint32_t) (settime); -// -// TIVA_ST_TIM->ICR = TIVA_ST_TIM->MIS; -// TIVA_ST_TIM->IMR = GPTM_IMR_TAMIM; - - //uint64_t settime = time * ((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); - - //TIVA_ST_TIM->TAPMR = (uint16_t) ((settime >> 32) & 0xffff); TIVA_ST_TIM->TAMATCHR = (uint32_t) 0xffffffff - time; - TIVA_ST_TIM->ICR = TIVA_ST_TIM->MIS; TIVA_ST_TIM->IMR = GPTM_IMR_TAMIM; -#else - (void)time; -#endif } /** @@ -266,9 +223,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; -#endif } /** @@ -280,29 +235,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 -// 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; - -// uint64_t settime = time * ((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); -// -// TIVA_ST_TIM->TAPMR = (uint16_t) ((settime >> 32) & 0xffff); -// TIVA_ST_TIM->TAMATCHR = (uint32_t) (settime); - - //uint64_t settime = time * ((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); - - //TIVA_ST_TIM->TAPMR = (uint16_t) ((settime >> 32) & 0xffff); TIVA_ST_TIM->TAMATCHR = (uint32_t) (0xffffffff - time); -#else - (void)time; -#endif } /** @@ -314,24 +247,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 -// 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; - - //return (systime_t) (TIVA_ST_TIM->TAPR << 16 | TIVA_ST_TIM->TAR >> 16); - //return (systime_t) ((TIVA_ST_TIM->TAV >> 16) | (TIVA_ST_TIM->TAPV << 16))/((ST_CLOCK_SRC / OSAL_ST_FREQUENCY) - 1); - return (systime_t) TIVA_ST_TIM->TAR; -#else - return (systime_t) 0; -#endif } /** @@ -345,11 +261,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); -#else - return (bool) false; -#endif } #endif /* _ST_LLD_H_ */ |