summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d713693)
raw | patch | inline | side by side (parent: d713693)
author | Don Dominic <a0486429@ti.com> | |
Fri, 3 Sep 2021 13:43:40 +0000 (19:13 +0530) | ||
committer | Ankur <ankurbaranwal@ti.com> | |
Thu, 16 Sep 2021 13:38:54 +0000 (08:38 -0500) |
- Added New APIs:-
- TimerP_getReloadCount: Get timer reload count
- TimerP_getCount: Get timer current count
- Added implementation for DMTimer and RTI Timer (v1/v2)
- Not implemented for timer64(v0) - K2 devices
Signed-off-by: Don Dominic <a0486429@ti.com>
- TimerP_getReloadCount: Get timer reload count
- TimerP_getCount: Get timer current count
- Added implementation for DMTimer and RTI Timer (v1/v2)
- Not implemented for timer64(v0) - K2 devices
Signed-off-by: Don Dominic <a0486429@ti.com>
packages/ti/osal/TimerP.h | patch | blob | history | |
packages/ti/osal/src/nonos/timer/v1/TimerP_nonos.c | patch | blob | history | |
packages/ti/osal/src/nonos/timer/v2/TimerP_nonos.c | patch | blob | history |
index 0592d3a3bd886ac7075df146e6d7c3c692eb96e7..c929ef843c69e9b4a50603fb860ffdf4d23c2370 100644 (file)
*/
extern uint64_t TimerP_getTimeInUsecs(void);
+/**
+ * @brief Get timer reload count
+ *
+ * @param timerHandle A TimerP_Handle returned from ::TimerP_create
+ *
+ * @return Reload count value
+ */
+extern uint32_t TimerP_getReloadCount(TimerP_Handle timerHandle);
+
+/**
+ * @brief Get timer current count
+ *
+ * @param timerHandle A TimerP_Handle returned from ::TimerP_create
+ *
+ * @return Current timer count value
+ */
+uint32_t TimerP_getCount(TimerP_Handle timerHandle);
+
#ifdef __cplusplus
}
#endif
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 bee22637b06554c18d75acc390feb1ab5945ff76..dd16807efd6bdbb53964c0c8be68c6cea65d1e4a 100755 (executable)
#endif
return (curTime);
}
-/* This file implements the DM timer osal functions on AM devices */
+
+/* Get timer reload count */
+uint32_t TimerP_getReloadCount(TimerP_Handle handle)
+{
+ uint32_t reloadCnt = 0U;
+ TimerP_Struct *timer = (TimerP_Struct *) handle;
+ uint32_t baseAddr = TimerP_getTimerBaseAddr(timer->timerId);
+
+ if (baseAddr != 0U)
+ {
+ (void)TIMERReloadGet2(baseAddr, &reloadCnt);
+ }
+
+ return (reloadCnt);
+}
+
+/* Get timer current count */
+uint32_t TimerP_getCount(TimerP_Handle handle)
+{
+ uint32_t count = 0U;
+ TimerP_Struct *timer = (TimerP_Struct *) handle;
+ uint32_t baseAddr = TimerP_getTimerBaseAddr(timer->timerId);
+
+ if (baseAddr != 0U)
+ {
+ (void)TIMERCounterGet2(baseAddr, &count);
+ }
+
+ return (count);
+
+}
+
+/* This file implements the DM timer osal functions on K3 devices */
diff --git a/packages/ti/osal/src/nonos/timer/v2/TimerP_nonos.c b/packages/ti/osal/src/nonos/timer/v2/TimerP_nonos.c
index 106d49c2eb937a0b4c09a282835d0ffd495f1d37..9057462167b59e1169dd14ca532953fe297338f9 100644 (file)
return ((cur_ts*1000u)/freq);
}
+
+/* Get timer reload count */
+uint32_t TimerP_getReloadCount(TimerP_Handle handle)
+{
+ uint32_t reloadCnt = 0U;
+ uint32_t rticomp;
+ TimerP_Struct *timer = (TimerP_Struct *) handle;
+ uint32_t baseAddr = TimerP_getTimerBaseAddr(timer->id);
+
+ if (baseAddr != 0U)
+ {
+ if ((timer->id & 0x01U) != 0U)
+ {
+ rticomp = RTITmrCompareGet(baseAddr, RTI_TMR_CNT_BLK_INDEX_1);
+ }
+ else
+ {
+ rticomp = RTITmrCompareGet(baseAddr, RTI_TMR_CNT_BLK_INDEX_0);
+ }
+ }
+
+ /* return 0xFFFFFFFF - value, since this is the expected format to calculate current time */
+ reloadCnt = 0xFFFFFFFFU - (rticomp) - 1UL;
+
+ return (reloadCnt);
+}
+
+/* Get timer current count */
+uint32_t TimerP_getCount(TimerP_Handle handle)
+{
+ uint32_t count = 0U;
+ rtiTmrCnts_t rtiCnts;
+ uint32_t rticomp;
+ TimerP_Struct *timer = (TimerP_Struct *) handle;
+ uint32_t baseAddr = TimerP_getTimerBaseAddr(timer->id);
+
+ if (baseAddr != 0U)
+ {
+ if ((timer->id & 0x01U) != 0U)
+ {
+ (void)RTITmrCounterGet(baseAddr, RTI_TMR_CNT_BLK_INDEX_1, &rtiCnts);
+ rticomp = RTITmrCompareGet(baseAddr, RTI_TMR_CNT_BLK_INDEX_1);
+ }
+ else
+ {
+ (void)RTITmrCounterGet(baseAddr, RTI_TMR_CNT_BLK_INDEX_0, &rtiCnts);
+ rticomp = RTITmrCompareGet(baseAddr, RTI_TMR_CNT_BLK_INDEX_0);
+ }
+ }
+
+ /* return 0xFFFFFFFF - value, since this is the expected format to calculate current time */
+ count = 0xFFFFFFFFU - (rticomp - rtiCnts.frc) - 1UL;
+
+ return (count);
+
+}
+
/* This file implements the RTI timer osal functions on devices */