29 #include <oc_system_cfg.h> 31 #include <oc_errors.h> 39 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ 41 static void TimerHandler(oC_TIMER_Channel_t Channel , oC_TIMER_LLD_SubTimer_t SubTimer , oC_TIMER_LLD_EventFlags_t EventFlags );
42 static void MemoryFaultHandler(
void * Address , MemoryEventFlags_t Event ,
const char * Function, uint32_t LineNumber );
44 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ 52 #define _________________________________________VARIABLES_SECTION__________________________________________________________________________ 55 static oC_Timestamp_t TimeStamp = 0;
57 extern uint64_t oC_ThreadManTickCounter;
60 .Mode = oC_TIMER_Mode_Periodic ,
61 .MaximumTimeForWait = CFG_TIME_MAXIMUM_TIME_FOR_INITIALIZATION_OF_SYSTEM ,
62 .Frequency = oC_Frequency_FromTime(CFG_TIME_TIMESTAMP_INCREMENT_TIME) ,
63 .PermissibleDifference = 0 ,
64 .MaximumValue = 10000 ,
65 .EventHandler = TimerHandler ,
66 .EventFlags = oC_TIMER_LLD_EventFlags_TimeoutInterrupt
71 .EventHandler = MemoryFaultHandler ,
72 .EventFlags = MemoryEventFlags_BufferOverflow |
73 MemoryEventFlags_PossibleMemoryLeak
76 #undef _________________________________________VARIABLES_SECTION__________________________________________________________________________ 84 #define _________________________________________FUNCTIONS_SECTION__________________________________________________________________________ 88 oC_ErrorCode_t oC_KTime_TurnOn(
void )
90 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
93 oC_AssignErrorCodeIfFalse(&errorCode ,
ModuleEnabledFlag ==
false , oC_ErrorCode_ModuleIsTurnedOn)
98 errorCode = oC_ErrorCode_None;
100 if(oC_TIMER_IsTurnedOn())
102 oC_AssignErrorCode(&errorCode , oC_TIMER_Configure(&TimerConfig , &Context)) &&
103 oC_AssignErrorCode(&errorCode , oC_TIMER_Start(Context));
112 oC_ErrorCode_t oC_KTime_TurnOff(
void )
114 oC_ErrorCode_t errorCode = oC_ErrorCode_ImplementError;
117 oC_AssignErrorCodeIfFalse(&errorCode ,
ModuleEnabledFlag ==
true , oC_ErrorCode_ModuleNotStartedYet) &&
118 oC_AssignErrorCode(&errorCode , oC_TIMER_Stop(Context)) &&
119 oC_AssignErrorCode(&errorCode , oC_TIMER_Unconfigure(&TimerConfig , &Context))
123 errorCode = oC_ErrorCode_None;
131 oC_Timestamp_t oC_KTime_GetTimestamp(
void )
133 oC_Timestamp_t timeStamp = 0;
135 if(oC_TIMER_IsTurnedOn() && Context !=
NULL)
137 uint64_t timerValue = 0;
139 oC_TIMER_ReadValue(Context,&timerValue);
141 timeStamp = TimeStamp + (timerValue * CFG_TIME_TIMESTAMP_INCREMENT_TIME);
145 oC_IntMan_EnterCriticalSection();
146 timeStamp = oC_KTime_TickToTime(oC_ThreadManTickCounter);
147 oC_IntMan_ExitCriticalSection();
155 uint64_t oC_KTime_GetCurrentTick (
void )
157 return oC_ThreadManTickCounter;
162 oC_Time_t oC_KTime_TickToTime( uint64_t Ticks )
164 return oC_Frequency_ToTime(CFG_FREQUENCY_DEFAULT_SYSTEM_TIMER_FREQUENCY) * Ticks;
167 #undef _________________________________________FUNCTIONS_SECTION__________________________________________________________________________ 174 #define _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ 178 static void TimerHandler(oC_TIMER_Channel_t Channel , oC_TIMER_LLD_SubTimer_t SubTimer , oC_TIMER_LLD_EventFlags_t EventFlags )
180 TimeStamp += CFG_TIME_TIMESTAMP_INCREMENT_TIME * 10000;
185 static void MemoryFaultHandler(
void * Address , MemoryEventFlags_t Event ,
const char * Function, uint32_t LineNumber )
190 #undef _________________________________________LOCAL_FUNCTIONS_SECTION____________________________________________________________________ static bool ModuleEnabledFlag
The file with LLD interface for the TIMER driver.
The file with interface for the timer driver.
identifier for allocations
The file with interface for interrupt manager.
The file with interface of kernel time module.
#define NULL
pointer to a zero