PDK API Guide for J721E
TimerP.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2016-2017, Texas Instruments Incorporated
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  * notice, this list of conditions and the following disclaimer in the
14  * documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of Texas Instruments Incorporated nor the names of
17  * its contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
57 #ifndef ti_osal_TimerP__include
58 #define ti_osal_TimerP__include
59 
60 #ifdef __cplusplus
61 extern "C" {
62 #endif
63 
64 #include <stdint.h>
65 #include <stdbool.h>
66 #include <stddef.h>
67 
71 #define TimerP_ANY ((uint32_t)0xFEEDU)
72 
76 #define TimerP_ANY_MAX_RESTRICTIONS ((uint32_t)15U)
77 
81 #define TimerP_ID_INVALID ((uint32_t)0xFFFFU)
82 
86 #define TimerP_MAX_PERIOD ((uint32_t)0xFFFFFFFFU)
87 
91 #define TimerP_USE_DEFAULT ((uint32_t)0xFFFFFFFFU)
92 
96 typedef struct TimerP_FreqHz_s {
97  uint32_t hi;
98  uint32_t lo;
100 
104 typedef enum TimerP_Status_e {
106  TimerP_FAILURE = (-(int32_t) 1),
107  TimerP_NOT_AVAILABLE = (-(int32_t) 2),
108  TimerP_BAD_INT_NUM = (-(int32_t) 3),
109  TimerP_ISR_HOOK_ERR = (-(int32_t) 4)
110 } TimerP_Status;
111 
121 typedef uint32_t TimerP_PeriodType;
123 #define TimerP_PeriodType_MICROSECS ( (uint32_t) 0U)
124 
125 #define TimerP_PeriodType_COUNTS ( (uint32_t) 1U)
126 /* @} */
127 
137 typedef uint32_t TimerP_RunMode;
139 #define TimerP_RunMode_CONTINUOUS ( (uint32_t) 0U)
140 
141 #define TimerP_RunMode_ONESHOT ( (uint32_t) 1U)
142 /* @} */
143 
153 typedef uint32_t TimerP_StartMode;
155 #define TimerP_StartMode_AUTO ( (uint32_t) 0U)
156 
157 #define TimerP_StartMode_USER ( (uint32_t) 1U)
158 /* @} */
159 
164 typedef enum TimerP_Timer64Mode_e {
169 
174 typedef enum TimerP_Timer64Half_e {
179 
187 typedef void *TimerP_Handle;
188 
192 typedef void (*TimerP_Fxn)(uintptr_t arg);
193 
203 typedef struct TimerP_Params_s {
204  char *name;
208  uint32_t periodType;
209  uint32_t extfreqLo;
211  uint32_t extfreqHi;
213  uint32_t intfreqLo;
215  uint32_t intfreqHi;
217  uint32_t startMode;
218  uint32_t runMode;
219  uint32_t period;
223  uint32_t intNum;
224 #if (defined (_TMS320C6X) || defined (BUILD_C7X))
225  uint32_t eventId;
226 #endif
227  void* arg;
228 } TimerP_Params;
229 
244 extern TimerP_Handle TimerP_create(uint32_t id,
245  TimerP_Fxn tickFxn,
246  const TimerP_Params *timerParams);
247 
257 extern TimerP_Status TimerP_delete(TimerP_Handle timerHandle);
258 
277 extern TimerP_Status TimerP_setPeriodMicroSecs(TimerP_Handle timerHandle, uint32_t microsecs);
278 
288 extern void TimerP_Params_init(TimerP_Params *timerParams);
289 
299 extern TimerP_Status TimerP_start(TimerP_Handle timerHandle);
300 
310 extern TimerP_Status TimerP_stop(TimerP_Handle timerHandle);
311 
322 
331 extern uint64_t TimerP_getTimeInUsecs(void);
332 
340 extern uint32_t TimerP_getReloadCount(TimerP_Handle timerHandle);
341 
349 uint32_t TimerP_getCount(TimerP_Handle timerHandle);
350 
351 #ifdef __cplusplus
352 }
353 #endif
354 
355 #endif /* ti_osal_ClockP__include */
356 /* @} */
uint32_t hi
Definition: TimerP.h:97
uint64_t TimerP_getTimeInUsecs(void)
Function to return current time in units of micro-secs.
void TimerP_Params_init(TimerP_Params *timerParams)
Initialize params structure to default values.
char * name
Definition: TimerP.h:204
TimerP_Status
Status codes for TimerP APIs.
Definition: TimerP.h:104
Definition: TimerP.h:107
Definition: TimerP.h:108
uint32_t lo
Definition: TimerP.h:98
TimerP_Timer64Mode timerMode
Definition: TimerP.h:220
Definition: TimerP.h:109
uint32_t TimerP_getReloadCount(TimerP_Handle timerHandle)
Get timer reload count.
TimerP_Timer64Mode
Timer mode for 64 bit timers (KeyStone devices)
Definition: TimerP.h:164
Definition: TimerP.h:105
Definition: TimerP.h:175
void * TimerP_Handle
Opaque client reference to an instance of a TimerP.
Definition: TimerP.h:187
TimerP_Timer64Half
Timer half when 64 bit timer is split into two 32 bit timer (Keystone devices)
Definition: TimerP.h:174
uint32_t runMode
Definition: TimerP.h:218
Definition: TimerP.h:165
TimerP_Handle TimerP_create(uint32_t id, TimerP_Fxn tickFxn, const TimerP_Params *timerParams)
Function to create a timer object.
Definition: TimerP.h:166
uint32_t intNum
Definition: TimerP.h:223
void(* TimerP_Fxn)(uintptr_t arg)
Prototype for a TimerP function.
Definition: TimerP.h:192
Definition: TimerP.h:177
Definition: TimerP.h:167
uint32_t TimerP_PeriodType
This enumerator defines the Timer Period unit.
Definition: TimerP.h:121
void * arg
Definition: TimerP.h:227
Definition: TimerP.h:176
uint32_t TimerP_RunMode
This enumerator defines the Timer runtime modes.
Definition: TimerP.h:137
Definition: TimerP.h:106
TimerP_Status TimerP_start(TimerP_Handle timerHandle)
Function to start a timer.
TimerP_Status TimerP_delete(TimerP_Handle timerHandle)
Function to delete a timer.
TimerP_Status TimerP_ClearInterrupt(TimerP_Handle timerHandle)
Function to clear the interrupt of the timer.
uint32_t intfreqLo
Definition: TimerP.h:213
uint32_t startMode
Definition: TimerP.h:217
TimerP_Status TimerP_stop(TimerP_Handle timerHandle)
Function to stop a timer.
uint32_t extfreqLo
Definition: TimerP.h:209
uint32_t TimerP_StartMode
This enumerator defines the Timer start modes.
Definition: TimerP.h:153
uint32_t extfreqHi
Definition: TimerP.h:211
Frequency-in-hertz struct.
Definition: TimerP.h:96
Basic TimerP Parameters.
Definition: TimerP.h:203
uint32_t TimerP_getCount(TimerP_Handle timerHandle)
Get timer current count.
TimerP_Timer64Half timerHalf
Definition: TimerP.h:221
uint32_t periodType
Definition: TimerP.h:208
TimerP_Status TimerP_setPeriodMicroSecs(TimerP_Handle timerHandle, uint32_t microsecs)
Function to set timer period specified in micro seconds A best-effort method will be used to set the ...
uint32_t intfreqHi
Definition: TimerP.h:215
uint32_t period
Definition: TimerP.h:219