diff --git a/packages/ti/osal/src/nonos/timer/v1/TimerP_nonos.c b/packages/ti/osal/src/nonos/timer/v1/TimerP_nonos.c
index 74b032cf2ee26c88c104972c8cbf4c1a41dc3804..d9c5b83145a70a20271cab1891be5609a6a40493 100755 (executable)
/*
- * Copyright (c) 2015-2018, Texas Instruments Incorporated
+ * Copyright (c) 2015-2019, Texas Instruments Incorporated
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* The TimerP_Struct pool servers to get an available timer
* handle during timer create API call.
*/
-TimerP_Struct gTimerStructs[OSAL_NONOS_CONFIGNUM_TIMER];
+TimerP_Struct gTimerStructs[OSAL_NONOS_CONFIGNUM_TIMER] = {0U};
static uint32_t gTimerInitDone = 0U;
static uint32_t gTimerAnyMask;
#if defined (BUILD_MCU)
@@ -121,7 +121,6 @@ static TimerP_Status TimerP_dmTimerDeviceCfg(TimerP_Struct *timer, uint32_t base
static TimerP_Status TimerP_dmTimerInitObj(TimerP_Struct *timer, TimerP_Fxn tickFxn, const TimerP_Params *params);
static TimerP_Status TimerP_dmTimerInstanceInit(TimerP_Struct *timer, uint32_t id, TimerP_Fxn tickFxn, const TimerP_Params *params);
-
/*
* This private function returns the base address of the timer based on
* the ID passed in.
@@ -535,13 +534,17 @@ static TimerP_Status TimerP_dmTimerInstanceInit(TimerP_Struct *timer, uint32_t i
gTimerAnyMask = timer->availMask;
+#if defined (BUILD_MCU)
+ tempId = TimerP_mapId(tempId);
+#endif
+
/* Initialize the timer state object */
timer->timerId = tempId; /* Record the timer Id */
baseAddr = TimerP_getTimerBaseAddr(timer->timerId);
HwiP_restore(key);
- if (tempId == 0xffffU) {
+ if ((tempId == 0xffffU) || (0x0 == baseAddr)) {
ret = TimerP_NOT_AVAILABLE;
}
}
@@ -556,6 +559,15 @@ static TimerP_Status TimerP_dmTimerInstanceInit(TimerP_Struct *timer, uint32_t i
{
if (timer->tickFxn != (TimerP_Fxn) NULL_PTR)
{
+ /* PDK-6534 If the timers were indeed running (left running from previous)
+ op. The provided ISR could be invoked at un-expected time.
+ Ensure to reset the timer */
+
+ /* tiocpCfg is populated by tiocpCfg */
+ if ((timer->tiocpCfg & TIMERP_DM_TIOCP_CFG_SOFTRESET_FLAG) > 0U) {
+ (void)TIMERReset(baseAddr);
+ }
+
intNum = timer->intNum;
/* Initialize with defaults */
Osal_RegisterInterrupt_initParams(&interruptRegParams);
@@ -566,7 +578,7 @@ static TimerP_Status TimerP_dmTimerInstanceInit(TimerP_Struct *timer, uint32_t i
interruptRegParams.corepacConfig.isrRoutine=TimerP_dmTimerStub;
#if defined (__ARM_ARCH_7A__) || defined (__aarch64__) || defined (__TI_ARM_V7R4__)
-#if defined(SOC_AM335x) || defined(SOC_AM437x) || defined(SOC_AM65XX) || defined(SOC_J721E)
+#if defined(SOC_AM335x) || defined(SOC_AM437x) || defined(SOC_AM65XX) || defined(SOC_J721E) || defined(SOC_J7200) || defined(SOC_AM64X)
interruptRegParams.corepacConfig.triggerSensitivity = (uint32_t)OSAL_ARM_GIC_TRIG_TYPE_HIGH_LEVEL;
interruptRegParams.corepacConfig.priority = 0x20U;
#else
{
/* Release or free the memory */
uint32_t key;
+ uint32_t id;
uint32_t index = (uint32_t)(( ((uintptr_t) handle) - ((uintptr_t) gTimerStructs) )/sizeof(TimerP_Struct)); /* struct subtraction */
TimerP_Status ret = TimerP_OK;
TimerP_Struct *timer = (TimerP_Struct *) handle;
TIMOSAL_Assert((handle == NULL_PTR));
- if(timer != NULL_PTR)
+ key = (uint32_t)HwiP_disable();
+
+ if((timer != NULL_PTR) && ((gTimerStructs[index].used) == (bool)true))
{
/* clear the ISR that was set before */
- (void)HwiP_delete(timer->hwi);
-
- key = (uint32_t)HwiP_disable();
+ if(timer->hwi != NULL_PTR)
+ {
+ (void)HwiP_delete(timer->hwi);
+ }
+
+ /* reset the timer's bit field in the mask and clear the used flag */
gTimerStructs[index].used = (bool)false;
+ id = gTimerStructs[index].timerId;
+ uint32_t shift = ((uint32_t) 1u) << id;
+ if(((gTimerAnyMask & shift)) == 0U)
+ {
+ gTimerAnyMask |= shift;
+ }
+ else
+ {
+ ret = TimerP_FAILURE;
+ }
+
/* Found the osal timer object to delete */
if (gOsalTimerAllocCnt > 0U)
{
gOsalTimerAllocCnt--;
}
- HwiP_restore(key);
- ret = TimerP_OK;
}
else
{
ret = TimerP_FAILURE;
}
+ HwiP_restore(key);
+
return (ret);
}
TimerP_Struct *timer = (TimerP_Struct *) handle;
uint32_t max_period = (uint32_t) 0xffffffffU;
TimerP_Status retVal = TimerP_OK;
-
+ uint32_t eventId;
uint32_t baseAddr = TimerP_getTimerBaseAddr(timer->timerId);
if (baseAddr == 0U) {
} while (status != (uint32_t) 0u);
if(timer->hwi != NULL_PTR) {
- HwiP_clearInterrupt(timer->intNum);
- HwiP_enableInterrupt(timer->intNum);
+#if defined (_TMS320C6X)
+ eventId = timer->eventId;
+#else
+ eventId = 0u;
+#endif
+ Osal_ClearInterrupt(eventId, timer->intNum);
+ Osal_EnableInterrupt(eventId, timer->intNum);
+ }
+ else {
+ retVal = TimerP_FAILURE;
}
if (timer->runMode == (uint32_t)TimerP_RunMode_CONTINUOUS) {
runMode = TIMERP_DM_TCLR_START_DYNAMIC;
}
- (void)TIMERModeConfigure(baseAddr, runMode);
-
- do {
- status = (TIMERWritePostedStatusGet(baseAddr) & TIMERP_DM_TWPS_W_PEND_TCLR);
- } while (status != (uint32_t) 0u);
+ if (retVal == TimerP_OK) {
+ (void)TIMERModeConfigure(baseAddr, runMode);
- (void)TIMEREnable(baseAddr);
+ do {
+ status = (TIMERWritePostedStatusGet(baseAddr) & TIMERP_DM_TWPS_W_PEND_TCLR);
+ } while (status != (uint32_t) 0u);
+ (void)TIMEREnable(baseAddr);
+ }
HwiP_restore(key);
}
return (retVal);
uint32_t tisr, status;
TimerP_Struct *timer = (TimerP_Struct *) handle;
TimerP_Status retVal = TimerP_OK;
-
+ uint32_t eventId;
uint32_t baseAddr = TimerP_getTimerBaseAddr(timer->timerId);
if (baseAddr == 0U) {
tisr = TIMERIntStatusGet(baseAddr);
+
if(tisr > 0U) {
- /* Clear all pending interrupts */
- (void)TIMERIntStatusClear(baseAddr, tisr);
+ /* Clear all pending interrupts */
+ (void)TIMERIntStatusClear(baseAddr, tisr);
+ }
+
+ if(timer->hwi != NULL_PTR) {
+#if defined (_TMS320C6X)
+ eventId = timer->eventId;
+#else
+ eventId = 0u;
+#endif
+ Osal_ClearInterrupt(eventId, timer->intNum);
+ Osal_DisableInterrupt(eventId, timer->intNum);
+ }
+ else {
+ retVal = TimerP_FAILURE;
}
}
return(retVal);
{
TimeStamp_Struct timestamp64;
uint64_t cur_ts, freq;
- uint32_t tsFreqKHz;
+ uint32_t tsFreqKHz;
/* Get the timestamp */
osalArch_TimestampGet64(×tamp64);