PDK API Guide for AM64x
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)0u)
72 
76 #define TimerP_MAX_PERIOD ((uint32_t)0xffffffffu)
77 
81 #define TimerP_USE_DEFAULT (-(int32_t)1)
82 
86 typedef struct TimerP_FreqHz_s {
87  uint32_t hi;
88  uint32_t lo;
90 
94 typedef enum TimerP_Status_e {
95  TimerP_OK = 0,
96  TimerP_FAILURE = (-(int32_t) 1),
97  TimerP_NOT_AVAILABLE = (-(int32_t) 2),
98  TimerP_BAD_INT_NUM = (-(int32_t) 3),
99  TimerP_ISR_HOOK_ERR = (-(int32_t) 4)
100 } TimerP_Status;
101 
102 
106 typedef enum TimerP_PeriodType_e {
110 
114 typedef enum TimerP_RunMode_e {
117  } TimerP_RunMode;
118 
122 typedef enum TimerP_StartMode_e {
126 
131 typedef enum TimerP_Timer64Mode_e {
136 
141 typedef enum TimerP_Timer64Half_e {
146 
154 typedef void *TimerP_Handle;
155 
159 typedef void (*TimerP_Fxn)(uintptr_t arg);
160 
170 typedef struct TimerP_Params_s {
171  char *name;
175  uint32_t periodType;
176  int32_t extfreqLo;
178  int32_t extfreqHi;
180  int32_t intfreqLo;
182  int32_t intfreqHi;
184  uint32_t startMode;
185  uint32_t runMode;
186  uint32_t period;
190  int32_t intNum;
191 #if defined (_TMS320C6X)
192  int32_t eventId;
193 #endif
194  void* arg;
195 } TimerP_Params;
196 
211 extern TimerP_Handle TimerP_create(int32_t id,
212  TimerP_Fxn tickFxn,
213  const TimerP_Params *timerParams);
214 
224 extern TimerP_Status TimerP_delete(TimerP_Handle timerHandle);
225 
244 extern TimerP_Status TimerP_setPeriodMicroSecs(TimerP_Handle timerHandle, uint32_t microsecs);
245 
255 extern void TimerP_Params_init(TimerP_Params *timerParams);
256 
266 extern TimerP_Status TimerP_start(TimerP_Handle timerHandle);
267 
277 extern TimerP_Status TimerP_stop(TimerP_Handle timerHandle);
278 
289 
298 extern uint64_t TimerP_getTimeInUsecs(void);
299 
300 #ifdef __cplusplus
301 }
302 #endif
303 
304 #endif /* ti_osal_ClockP__include */
305 /* @} */
uint32_t hi
Definition: TimerP.h:87
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:171
int32_t intNum
Definition: TimerP.h:190
int32_t intfreqLo
Definition: TimerP.h:180
TimerP_Status
Status codes for TimerP APIs.
Definition: TimerP.h:94
Definition: TimerP.h:97
Definition: TimerP.h:124
Definition: TimerP.h:98
uint32_t lo
Definition: TimerP.h:88
TimerP_Timer64Mode timerMode
Definition: TimerP.h:187
Definition: TimerP.h:99
TimerP_Timer64Mode
Timer mode for 64 bit timers (KeyStone devices)
Definition: TimerP.h:131
Definition: TimerP.h:95
Definition: TimerP.h:142
void * TimerP_Handle
Opaque client reference to an instance of a TimerP.
Definition: TimerP.h:154
TimerP_Timer64Half
Timer half when 64 bit timer is split into two 32 bit timer (Keystone devices)
Definition: TimerP.h:141
uint32_t runMode
Definition: TimerP.h:185
Definition: TimerP.h:132
int32_t extfreqLo
Definition: TimerP.h:176
Definition: TimerP.h:133
void(* TimerP_Fxn)(uintptr_t arg)
Prototype for a TimerP function.
Definition: TimerP.h:159
Definition: TimerP.h:116
Definition: TimerP.h:144
Definition: TimerP.h:134
void * arg
Definition: TimerP.h:194
int32_t intfreqHi
Definition: TimerP.h:182
TimerP_StartMode
Timer start modes for TimerP APIs.
Definition: TimerP.h:122
Definition: TimerP.h:143
Definition: TimerP.h:96
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_Handle TimerP_create(int32_t id, TimerP_Fxn tickFxn, const TimerP_Params *timerParams)
Function to create a timer object.
TimerP_RunMode
Timer runtime modes for TimerP APIs.
Definition: TimerP.h:114
TimerP_Status TimerP_ClearInterrupt(TimerP_Handle timerHandle)
Function to clear the interrupt of the timer.
uint32_t startMode
Definition: TimerP.h:184
TimerP_Status TimerP_stop(TimerP_Handle timerHandle)
Function to stop a timer.
Definition: TimerP.h:108
Definition: TimerP.h:107
Frequency-in-hertz struct.
Definition: TimerP.h:86
Basic TimerP Parameters.
Definition: TimerP.h:170
int32_t extfreqHi
Definition: TimerP.h:178
Definition: TimerP.h:123
Definition: TimerP.h:115
TimerP_PeriodType
Timer period units for TimerP APIs.
Definition: TimerP.h:106
TimerP_Timer64Half timerHalf
Definition: TimerP.h:188
uint32_t periodType
Definition: TimerP.h:175
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 period
Definition: TimerP.h:186