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 (uint32_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)
 Function to return current time in units of micro-secs. More...
 
uint32_t TimerP_getReloadCount (TimerP_Handle timerHandle)
 Get timer reload count. More...
 
uint32_t TimerP_getCount (TimerP_Handle timerHandle)
 Get timer current count. More...
 

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_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)0xFEEDU)
 
#define TimerP_ANY_MAX_RESTRICTIONS   ((uint32_t)15U)
 
#define TimerP_ID_INVALID   ((uint32_t)0xFFFFU)
 
#define TimerP_MAX_PERIOD   ((uint32_t)0xFFFFFFFFU)
 
#define TimerP_USE_DEFAULT   ((uint32_t)0xFFFFFFFFU)
 

Timer period units for TimerP APIs

typedef uint32_t TimerP_PeriodType
 This enumerator defines the Timer Period unit. More...
 
#define TimerP_PeriodType_MICROSECS   ( (uint32_t) 0U)
 
#define TimerP_PeriodType_COUNTS   ( (uint32_t) 1U)
 

Timer runtime modes for TimerP APIs

typedef uint32_t TimerP_RunMode
 This enumerator defines the Timer runtime modes. More...
 
#define TimerP_RunMode_CONTINUOUS   ( (uint32_t) 0U)
 
#define TimerP_RunMode_ONESHOT   ( (uint32_t) 1U)
 

Timer start modes for TimerP APIs

typedef uint32_t TimerP_StartMode
 This enumerator defines the Timer start modes. More...
 
#define TimerP_StartMode_AUTO   ( (uint32_t) 0U)
 
#define TimerP_StartMode_USER   ( (uint32_t) 1U)
 

Macro Definition Documentation

◆ TimerP_ANY

#define TimerP_ANY   ((uint32_t)0xFEEDU)

Const used to specify any timer

◆ TimerP_ANY_MAX_RESTRICTIONS

#define TimerP_ANY_MAX_RESTRICTIONS   ((uint32_t)15U)

Const used to specify maximum number of programmable restrictions for TimerP_ANY flag

◆ TimerP_ID_INVALID

#define TimerP_ID_INVALID   ((uint32_t)0xFFFFU)

Const used to specify invalid timer

◆ TimerP_MAX_PERIOD

#define TimerP_MAX_PERIOD   ((uint32_t)0xFFFFFFFFU)

Max value of Timer period for PeriodType_COUNTS

◆ TimerP_USE_DEFAULT

#define TimerP_USE_DEFAULT   ((uint32_t)0xFFFFFFFFU)

Use default values as provided by the OSAL package

◆ TimerP_PeriodType_MICROSECS

#define TimerP_PeriodType_MICROSECS   ( (uint32_t) 0U)

Timer period unit is in micro seconds

◆ TimerP_PeriodType_COUNTS

#define TimerP_PeriodType_COUNTS   ( (uint32_t) 1U)

Timer period unit is in counts

◆ TimerP_RunMode_CONTINUOUS

#define TimerP_RunMode_CONTINUOUS   ( (uint32_t) 0U)

Timer is periodic and runs continuously

◆ TimerP_RunMode_ONESHOT

#define TimerP_RunMode_ONESHOT   ( (uint32_t) 1U)

Timer runs for a single period values and stops

◆ TimerP_StartMode_AUTO

#define TimerP_StartMode_AUTO   ( (uint32_t) 0U)

Timer starts automatically after create

◆ TimerP_StartMode_USER

#define TimerP_StartMode_USER   ( (uint32_t) 1U)

Timer will be started by the user

Typedef Documentation

◆ TimerP_PeriodType

typedef uint32_t TimerP_PeriodType

This enumerator defines the Timer Period unit.

◆ TimerP_RunMode

typedef uint32_t TimerP_RunMode

This enumerator defines the Timer runtime modes.

◆ TimerP_StartMode

typedef uint32_t TimerP_StartMode

This enumerator defines the Timer start modes.

◆ TimerP_Handle

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.).

◆ TimerP_Fxn

typedef void(* TimerP_Fxn) (uintptr_t arg)

Prototype for a TimerP function.

Enumeration Type Documentation

◆ TimerP_Status

Status codes for TimerP APIs.

Enumerator
TimerP_OK 
TimerP_FAILURE 
TimerP_NOT_AVAILABLE 
TimerP_BAD_INT_NUM 
TimerP_ISR_HOOK_ERR 

◆ TimerP_Timer64Mode

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 

◆ TimerP_Timer64Half

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_create()

TimerP_Handle TimerP_create ( uint32_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_delete()

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_setPeriodMicroSecs()

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.

◆ TimerP_Params_init()

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_start()

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_stop()

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_ClearInterrupt()

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.

◆ TimerP_getTimeInUsecs()

uint64_t TimerP_getTimeInUsecs ( void  )

Function to return current time in units of micro-secs.

Returns
Current time in units of micro-secs

Note: This API is not supported for J7/OMAPL13x platforms and result in link errors if used in the application

◆ TimerP_getReloadCount()

uint32_t TimerP_getReloadCount ( TimerP_Handle  timerHandle)

Get timer reload count.

Parameters
timerHandleA TimerP_Handle returned from TimerP_create
Returns
Reload count value

◆ TimerP_getCount()

uint32_t TimerP_getCount ( TimerP_Handle  timerHandle)

Get timer current count.

Parameters
timerHandleA TimerP_Handle returned from TimerP_create
Returns
Current timer count value