PDK API Guide for J721E
TimerP

Introduction

TimerP interface

Files

file  TimerP.h
 Timer interface for the RTOS Porting Interface.
 

Data Structures

struct  TimerP_FreqHz
 Frequency-in-hertz struct. More...
 
struct  TimerP_Params
 Basic TimerP Parameters. More...
 

Functions

TimerP_Handle TimerP_create (int32_t id, TimerP_Fxn tickFxn, const TimerP_Params *timerParams)
 Function to create a timer object. More...
 
TimerP_Status TimerP_delete (TimerP_Handle timerHandle)
 Function to delete a timer. More...
 
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 period register. There might be a slight rounding error based on resolution of timer period register. If the timer frequency cannot support the requested period, i.e. the timer period register cannot support the requested period, then this function returns false. TimerP_setPeriodMicroSecs() invokes TimerP_stop() prior to setting the period and leaves the timer in the stopped state. More...
 
void TimerP_Params_init (TimerP_Params *timerParams)
 Initialize params structure to default values. More...
 
TimerP_Status TimerP_start (TimerP_Handle timerHandle)
 Function to start a timer. More...
 
TimerP_Status TimerP_stop (TimerP_Handle timerHandle)
 Function to stop a timer. More...
 
TimerP_Status TimerP_ClearInterrupt (TimerP_Handle timerHandle)
 Function to clear the interrupt of the timer. More...
 
uint64_t TimerP_getTimeInUsecs (void)
 

Typedefs

typedef void * TimerP_Handle
 Opaque client reference to an instance of a TimerP. More...
 
typedef void(* TimerP_Fxn) (uintptr_t arg)
 Prototype for a TimerP function. More...
 

Enumerations

enum  TimerP_Status {
  TimerP_OK = 0, TimerP_FAILURE = (-(int32_t) 1), TimerP_NOT_AVAILABLE = (-(int32_t) 2), TimerP_BAD_INT_NUM = (-(int32_t) 3),
  TimerP_ISR_HOOK_ERR = (-(int32_t) 4)
}
 Status codes for TimerP APIs. More...
 
enum  TimerP_PeriodType { TimerP_PeriodType_MICROSECS, TimerP_PeriodType_COUNTS }
 Timer period units for TimerP APIs. More...
 
enum  TimerP_RunMode { TimerP_RunMode_CONTINUOUS, TimerP_RunMode_ONESHOT }
 Timer runtime modes for TimerP APIs. More...
 
enum  TimerP_StartMode { TimerP_StartMode_AUTO, TimerP_StartMode_USER }
 Timer start modes for TimerP APIs. More...
 
enum  TimerP_Timer64Mode { TimerP_Timer64Mode_64BITGPTIMER, TimerP_Timer64Mode_UNCHAINED, TimerP_Timer64Mode_CHAINED }
 Timer mode for 64 bit timers (KeyStone devices) More...
 
enum  TimerP_Timer64Half { TimerP_Timer64Half_LOWER, TimerP_Timer64Half_UPPER, TimerP_Timer64Half_DEFAULT }
 Timer half when 64 bit timer is split into two 32 bit timer (Keystone devices) More...
 

Macros

#define TimerP_ANY   (~(uint32_t)0u)
 
#define TimerP_MAX_PERIOD   ((uint32_t)0xffffffffu)
 
#define TimerP_USE_DEFAULT   (-(int32_t)1)
 

Macro Definition Documentation

#define TimerP_ANY   (~(uint32_t)0u)

Const used to specify any timer

#define TimerP_MAX_PERIOD   ((uint32_t)0xffffffffu)

Max value of Timer period for PeriodType_COUNTS

#define TimerP_USE_DEFAULT   (-(int32_t)1)

Use default values as provided by the OSAL package

Typedef Documentation

typedef void* TimerP_Handle

Opaque client reference to an instance of a TimerP.

A TimerP_Handle returned from the TimerP_create represents that instance. and then is used in the other instance based functions (e.g. TimerP_start, TimerP_stop, etc.).

typedef void(* TimerP_Fxn) (uintptr_t arg)

Prototype for a TimerP function.

Enumeration Type Documentation

Status codes for TimerP APIs.

Enumerator
TimerP_OK 
TimerP_FAILURE 
TimerP_NOT_AVAILABLE 
TimerP_BAD_INT_NUM 
TimerP_ISR_HOOK_ERR 

Timer period units for TimerP APIs.

Enumerator
TimerP_PeriodType_MICROSECS 

timer period is in micro seconds

TimerP_PeriodType_COUNTS 

timer period is in counts

Timer runtime modes for TimerP APIs.

Enumerator
TimerP_RunMode_CONTINUOUS 

timer is periodic and runs continuously

TimerP_RunMode_ONESHOT 

timer runs for a single period values and stops

Timer start modes for TimerP APIs.

Enumerator
TimerP_StartMode_AUTO 

timer starts automatically after create

TimerP_StartMode_USER 

timer will be started by the user

Timer mode for 64 bit timers (KeyStone devices)

Note
this is not applicable for non KeyStone devices such as AM572x etc
Enumerator
TimerP_Timer64Mode_64BITGPTIMER 
TimerP_Timer64Mode_UNCHAINED 
TimerP_Timer64Mode_CHAINED 

Timer half when 64 bit timer is split into two 32 bit timer (Keystone devices)

Note
this is not applicable for non KeyStone devices such as AM572x etc
Enumerator
TimerP_Timer64Half_LOWER 
TimerP_Timer64Half_UPPER 
TimerP_Timer64Half_DEFAULT 

Function Documentation

TimerP_Handle TimerP_create ( int32_t  id,
TimerP_Fxn  tickFxn,
const TimerP_Params timerParams 
)

Function to create a timer object.

Parameters
idTimer Id
tickFxnFunction that runs upon timer expiry
timerParamsPointer to the instance configuration parameters. NULL denotes to use the default parameters. The TimerP default parameters are noted in TimerP_Params_init.
Returns
A TimerP_Handle on success or a NULL on an error. This handle can be passed to TimerP_start()
TimerP_Status TimerP_delete ( TimerP_Handle  timerHandle)

Function to delete a timer.

Parameters
timerHandleA TimerP_Handle returned from TimerP_create
Returns
Status of the function.
  • TimerP_OK: Deleted the timer instance
  • TimerP_FAILURE: Timed out waiting to delete the timer object.
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 period register. There might be a slight rounding error based on resolution of timer period register. If the timer frequency cannot support the requested period, i.e. the timer period register cannot support the requested period, then this function returns false. TimerP_setPeriodMicroSecs() invokes TimerP_stop() prior to setting the period and leaves the timer in the stopped state.

Parameters
timerHandleA TimerP_Handle returned from TimerP_create
microsecstime in micro seconds
Returns
Status of the function.
  • TimerP_OK: Deleted the timer instance
  • TimerP_FAILURE: Timed out waiting to delete the timer object.
void TimerP_Params_init ( TimerP_Params timerParams)

Initialize params structure to default values.

The default parameters are:

  • name: NULL
  • arg: 0
Parameters
timerParamsPointer to the instance configuration parameters.
TimerP_Status TimerP_start ( TimerP_Handle  timerHandle)

Function to start a timer.

Parameters
timerHandleA TimerP_Handle returned from TimerP_create
Returns
Status of the functions
  • TimerP_OK: Scheduled the timer function successfully
  • TimerP_FAILURE: The API failed.
TimerP_Status TimerP_stop ( TimerP_Handle  timerHandle)

Function to stop a timer.

Parameters
timerHandleA TimerP_Handle returned from TimerP_create
Returns
Status of the functions
  • TimerP_OK: Scheduled the timer function successfully
  • TimerP_FAILURE: The API failed.
TimerP_Status TimerP_ClearInterrupt ( TimerP_Handle  timerHandle)

Function to clear the interrupt of the timer.

Parameters
timerHandleA TimerP_Handle returned from TimerP_create
Returns
Status of the function
  • TimerP_OK: Clear the interrupt of the timer function successfully.
uint64_t TimerP_getTimeInUsecs ( void  )