TI-RTOS Drivers  tidrivers_full_2_20_00_08
Data Structures | Typedefs | Enumerations | Functions
ClockP.h File Reference

Detailed Description

Clock interface for the RTOS Porting Interface.

============================================================================

The ClockP module can be used to schedule functions that run at intervals specified in the underlying kernel's system ticks. ClockP instances are one-shot. The one-shot function will be run once after the specified period has elapsed since calling ClockP_start().

The ClockP module can also be used to obtain the period of the kernel's system tick in microseconds. This is useful for determining the number of ticks needed for setting a Clock object's period.

When using the TI-RTOS kernel, ClockP functions are run at software interrupt level. With FreeRTOS, the ClockP functions are run by a timer service task with priority configured by the application.

A common use case is to post a semaphore in the clock function. There is a specific API for this: Semaphore_postFromClock(). This must be used in a clock function (instead of Semaphore_post or Semaphore_postFromISR).


#include <stdint.h>
#include <stdbool.h>
#include <stddef.h>
Include dependency graph for ClockP.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ClockP_FreqHz
 Frequency-in-hertz struct. More...
 
struct  ClockP_Params
 Basic ClockP Parameters. More...
 

Typedefs

typedef struct ClockP_FreqHz ClockP_FreqHz
 Frequency-in-hertz struct. More...
 
typedef enum ClockP_Status ClockP_Status
 Status codes for ClockP APIs. More...
 
typedef void * ClockP_Handle
 Opaque client reference to an instance of a ClockP. More...
 
typedef void(* ClockP_Fxn) (uintptr_t arg)
 Prototype for a ClockP function. More...
 
typedef struct ClockP_Params ClockP_Params
 Basic ClockP Parameters. More...
 

Enumerations

enum  ClockP_Status {
  ClockP_OK = 0,
  ClockP_FAILURE = -1
}
 Status codes for ClockP APIs. More...
 

Functions

ClockP_Handle ClockP_create (ClockP_Fxn clockFxn, ClockP_Params *params)
 Function to create a clock object. More...
 
ClockP_Status ClockP_delete (ClockP_Handle handle)
 Function to delete a clock. More...
 
void ClockP_getCpuFreq (ClockP_FreqHz *freq)
 Get CPU frequency in Hz. More...
 
uint32_t ClockP_getSystemTickPeriod ()
 Get the system tick period in microseconds. More...
 
uint32_t ClockP_getSystemTicks ()
 Get the current tick value. More...
 
void ClockP_Params_init (ClockP_Params *params)
 Initialize params structure to default values. More...
 
ClockP_Status ClockP_start (ClockP_Handle handle, uint32_t timeout)
 Function to start a clock. More...
 
ClockP_Status ClockP_startFromISR (ClockP_Handle handle, uint32_t timeout)
 Function to start a clock from an interrupt. More...
 
ClockP_Status ClockP_stop (ClockP_Handle handle)
 Function to stop a clock. More...
 
ClockP_Status ClockP_stopFromISR (ClockP_Handle handle)
 Function to stop a clock from an interrupt. More...
 
ClockP_Status ClockP_timestamp (ClockP_Handle handle)
 

Typedef Documentation

typedef struct ClockP_FreqHz ClockP_FreqHz

Frequency-in-hertz struct.

Status codes for ClockP APIs.

typedef void* ClockP_Handle

Opaque client reference to an instance of a ClockP.

A ClockP_Handle returned from the ClockP_create represents that instance. and then is used in the other instance based functions (e.g. ClockP_start, ClockP_stop, etc.).

typedef void(* ClockP_Fxn) (uintptr_t arg)

Prototype for a ClockP function.

typedef struct ClockP_Params ClockP_Params

Basic ClockP Parameters.

Structure that contains the parameters passed into ClockP_create when creating a ClockP instance. The ClockP_Params_init function should be used to initialize the fields to default values before the application sets the fields manually. The ClockP default parameters are noted in ClockP_Params_init.

Enumeration Type Documentation

Status codes for ClockP APIs.

Enumerator
ClockP_OK 
ClockP_FAILURE 

Function Documentation

ClockP_Handle ClockP_create ( ClockP_Fxn  clockFxn,
ClockP_Params params 
)

Function to create a clock object.

Parameters
clockFxnFunction called when timeout or period expires.
paramsPointer to the instance configuration parameters. NULL denotes to use the default parameters. The ClockP default parameters are noted in ClockP_Params_init.
Returns
A ClockP_Handle on success or a NULL on an error. This handle can be passed to ClockP_start()
ClockP_Status ClockP_delete ( ClockP_Handle  handle)

Function to delete a clock.

Parameters
handleA ClockP_Handle returned from ClockP_create
Returns
Status of the function.
  • ClockP_OK: Deleted the clock instance
  • ClockP_FAILURE: Timed out waiting to delete the clock object.
void ClockP_getCpuFreq ( ClockP_FreqHz freq)

Get CPU frequency in Hz.

Parameters
freqPointer to the FreqHz structure
uint32_t ClockP_getSystemTickPeriod ( )

Get the system tick period in microseconds.

Returns
The kernel's system tick period in microseconds.
uint32_t ClockP_getSystemTicks ( )

Get the current tick value.

The value returned will wrap back to zero after it reaches the max value that can be stored in 32 bits.

Returns
Time in system clock ticks
void ClockP_Params_init ( ClockP_Params params)

Initialize params structure to default values.

The default parameters are:

  • name: NULL
  • arg: 0
Parameters
paramsPointer to the instance configuration parameters.
ClockP_Status ClockP_start ( ClockP_Handle  handle,
uint32_t  timeout 
)

Function to start a clock.

Parameters
handleA ClockP_Handle returned from ClockP_create
timeoutThe timeout used for a one-shot clock object. The value of timeout must not be 0.
Returns
Status of the functions
  • ClockP_OK: Scheduled the clock function successfully
  • ClockP_FAILURE: The API failed.
ClockP_Status ClockP_startFromISR ( ClockP_Handle  handle,
uint32_t  timeout 
)

Function to start a clock from an interrupt.

Parameters
handleA ClockP_Handle returned from ClockP_create
timeoutThe timeout used for a one-shot clock object. The value of timeout must not be 0.
Returns
Status of the functions
  • ClockP_OK: Scheduled the clock function successfully
  • ClockP_FAILURE: The API failed.
ClockP_Status ClockP_stop ( ClockP_Handle  handle)

Function to stop a clock.

Parameters
handleA ClockP_Handle returned from ClockP_create

It is ok to call ClockP_stop() for a clock that has not been started.

Returns
Status of the functions
  • ClockP_OK: Stopped the clock function successfully
  • ClockP_FAILURE: The API failed.
ClockP_Status ClockP_stopFromISR ( ClockP_Handle  handle)

Function to stop a clock from an interrupt.

Parameters
handleA ClockP_Handle returned from ClockP_create
Returns
Status of the functions
  • ClockP_OK: Stopped the clock function successfully
  • ClockP_FAILURE: The API failed.
ClockP_Status ClockP_timestamp ( ClockP_Handle  handle)
Copyright 2016, Texas Instruments Incorporated