TI-RTOS Drivers
tidrivers_msp43x_2_16_01_13
|
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>
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 struct ClockP_FreqHz ClockP_FreqHz |
Frequency-in-hertz struct.
typedef enum ClockP_Status ClockP_Status |
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.
enum ClockP_Status |
ClockP_Handle ClockP_create | ( | ClockP_Fxn | clockFxn, |
ClockP_Params * | params | ||
) |
Function to create a clock object.
clockFxn | Function called when timeout or period expires. |
params | Pointer to the instance configuration parameters. NULL denotes to use the default parameters. The ClockP default parameters are noted in ClockP_Params_init. |
ClockP_Status ClockP_delete | ( | ClockP_Handle | handle | ) |
Function to delete a clock.
handle | A ClockP_Handle returned from ClockP_create |
void ClockP_getCpuFreq | ( | ClockP_FreqHz * | freq | ) |
Get CPU frequency in Hz.
freq | Pointer to the FreqHz structure |
uint32_t ClockP_getSystemTickPeriod | ( | ) |
Get the 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.
void ClockP_Params_init | ( | ClockP_Params * | params | ) |
Initialize params structure to default values.
The default parameters are:
params | Pointer to the instance configuration parameters. |
ClockP_Status ClockP_start | ( | ClockP_Handle | handle, |
uint32_t | timeout | ||
) |
Function to start a clock.
handle | A ClockP_Handle returned from ClockP_create |
timeout | The timeout used for a one-shot clock object. The value of timeout must not be 0. |
ClockP_Status ClockP_startFromISR | ( | ClockP_Handle | handle, |
uint32_t | timeout | ||
) |
Function to start a clock from an interrupt.
handle | A ClockP_Handle returned from ClockP_create |
timeout | The timeout used for a one-shot clock object. The value of timeout must not be 0. |
ClockP_Status ClockP_stop | ( | ClockP_Handle | handle | ) |
Function to stop a clock.
handle | A ClockP_Handle returned from ClockP_create |
It is ok to call ClockP_stop() for a clock that has not been started.
ClockP_Status ClockP_stopFromISR | ( | ClockP_Handle | handle | ) |
Function to stop a clock from an interrupt.
handle | A ClockP_Handle returned from ClockP_create |
ClockP_Status ClockP_timestamp | ( | ClockP_Handle | handle | ) |