MCUXpresso SDK API Reference Manual  Rev. 0
NXP Semiconductors
 All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
OSTIMER: OS Event Timer Driver

Files

file  fsl_ostimer.h
 

Typedefs

typedef void(* ostimer_callback_t )(void)
 ostimer callback function. More...
 

Enumerations

enum  _ostimer_flags { kOSTIMER_MatchInterruptFlag = (OSTIMER_OSEVENT_CTRL_OSTIMER_INTRFLAG_MASK) }
 OSTIMER status flags. More...
 

Driver version

#define FSL_OSTIMER_DRIVER_VERSION   (MAKE_VERSION(2, 0, 3))
 OSTIMER driver version 2.0.3. More...
 

Initialization and deinitialization

void OSTIMER_Init (OSTIMER_Type *base)
 Initializes an OSTIMER by turning its bus clock on. More...
 
void OSTIMER_Deinit (OSTIMER_Type *base)
 Deinitializes a OSTIMER instance. More...
 
static void OSTIMER_SoftwareReset (OSTIMER_Type *base)
 OSTIMER software reset. More...
 
uint32_t OSTIMER_GetStatusFlags (OSTIMER_Type *base)
 Get OSTIMER status Flags. More...
 
void OSTIMER_ClearStatusFlags (OSTIMER_Type *base, uint32_t mask)
 Clear Status Interrupt Flags. More...
 
void OSTIMER_SetMatchRawValue (OSTIMER_Type *base, uint64_t count, ostimer_callback_t cb)
 Set the match raw value for OSTIMER. More...
 
void OSTIMER_SetMatchValue (OSTIMER_Type *base, uint64_t count, ostimer_callback_t cb)
 Set the match value for OSTIMER. More...
 
static uint64_t OSTIMER_GetCurrentTimerRawValue (OSTIMER_Type *base)
 Get current timer raw count value from OSTIMER. More...
 
uint64_t OSTIMER_GetCurrentTimerValue (OSTIMER_Type *base)
 Get current timer count value from OSTIMER. More...
 
static uint64_t OSTIMER_GetCaptureRawValue (OSTIMER_Type *base)
 Get the capture value from OSTIMER. More...
 
uint64_t OSTIMER_GetCaptureValue (OSTIMER_Type *base)
 Get the capture value from OSTIMER. More...
 
void OSTIMER_HandleIRQ (OSTIMER_Type *base, ostimer_callback_t cb)
 OS timer interrupt Service Handler. More...
 

Detailed Description

The MCUXpresso SDK provides a peripheral driver for the OSTIMER module of MCUXpresso SDK devices. OSTIMER driver is created to help user to operate the OSTIMER module. The OSTIMER timer can be used as a low power timer. The APIs can be used to enable the OSTIMER module, initialize it and set the match time, get the current timer count. And the raw value in OS timer register is gray-code type, so both decimal and gray-code format API were added for users. OSTIMER can be used as a wake up source from low power mode.

Function groups

The OSTIMER driver supports operating the module as a time counter.

Initialization and deinitialization

The OSTIMER_Init() function will initialize the OSTIMER and enable the clock for OSTIMER. The OSTIMER_Deinit() function will shut down the bus clock of OSTIMER.

OSTIMER status

The function OSTIMER_GetStatusFlags() will get the current status flag of OSTIMER. The function OSTIMER_ClearStatusFlag() will help clear the status flags.

OSTIMER set match value

For OSTIMER, allow users set the match in two ways, set match value with raw data(gray code) and st the match value with common data(decimal format). OSTIMER_SetMatchRawValue() is used with gray code and OSTIMER_SetMatchValue() is used together with decimal data.

OSTIMER get timer count

The OSTIMER driver allow users to get the timer count in two ways, getting the gray code value by using OSTIMER_GetCaptureRawValue() and getting the decimal data by using OSTIMER_GetCurrentTimerValue().

Typical use case

Refer to the driver examples codes located at <SDK_ROOT>/boards/<BOARD>/driver_examples/ostimer/

Macro Definition Documentation

#define FSL_OSTIMER_DRIVER_VERSION   (MAKE_VERSION(2, 0, 3))

Typedef Documentation

typedef void(* ostimer_callback_t)(void)

Enumeration Type Documentation

Enumerator
kOSTIMER_MatchInterruptFlag 

Match interrupt flag bit, sets if the match value was reached.

Function Documentation

void OSTIMER_Init ( OSTIMER_Type *  base)
void OSTIMER_Deinit ( OSTIMER_Type *  base)

This function shuts down OSTIMER bus clock

Parameters
baseOSTIMER peripheral base address.
static void OSTIMER_SoftwareReset ( OSTIMER_Type *  base)
inlinestatic

This function will use software to trigger an OSTIMER reset. Please note that, the OS timer reset bit was in PMC->OSTIMERr register.

Parameters
baseOSTIMER peripheral base address.
uint32_t OSTIMER_GetStatusFlags ( OSTIMER_Type *  base)

This returns the status flag. Currently, only match interrupt flag can be got.

Parameters
baseOSTIMER peripheral base address.
Returns
status register value
void OSTIMER_ClearStatusFlags ( OSTIMER_Type *  base,
uint32_t  mask 
)

This clears intrrupt status flag. Currently, only match interrupt flag can be cleared.

Parameters
baseOSTIMER peripheral base address.
Returns
none
void OSTIMER_SetMatchRawValue ( OSTIMER_Type *  base,
uint64_t  count,
ostimer_callback_t  cb 
)

This function will set a match value for OSTIMER with an optional callback. And this callback will be called while the data in dedicated pair match register is equals to the value of central EVTIMER. Please note that, the data format is gray-code, if decimal data was desired, please using OSTIMER_SetMatchValue().

Parameters
baseOSTIMER peripheral base address.
countOSTIMER timer match value.(Value is gray-code format)
cbOSTIMER callback (can be left as NULL if none, otherwise should be a void func(void)).
Returns
none
void OSTIMER_SetMatchValue ( OSTIMER_Type *  base,
uint64_t  count,
ostimer_callback_t  cb 
)

This function will set a match value for OSTIMER with an optional callback. And this callback will be called while the data in dedicated pair match register is equals to the value of central OS TIMER.

Parameters
baseOSTIMER peripheral base address.
countOSTIMER timer match value.(Value is decimal format, and this value will be translate to Gray code internally.)
cbOSTIMER callback (can be left as NULL if none, otherwise should be a void func(void)).
Returns
none
static uint64_t OSTIMER_GetCurrentTimerRawValue ( OSTIMER_Type *  base)
inlinestatic

This function will get a gray code type timer count value from OS timer register. The raw value of timer count is gray code format.

Parameters
baseOSTIMER peripheral base address.
Returns
Raw value of OSTIMER, gray code format.
uint64_t OSTIMER_GetCurrentTimerValue ( OSTIMER_Type *  base)

This function will get a decimal timer count value. The RAW value of timer count is gray code format, will be translated to decimal data internally.

Parameters
baseOSTIMER peripheral base address.
Returns
Value of OSTIMER which will be formated to decimal value.
static uint64_t OSTIMER_GetCaptureRawValue ( OSTIMER_Type *  base)
inlinestatic

This function will get a captured gray-code value from OSTIMER. The Raw value of timer capture is gray code format.

Parameters
baseOSTIMER peripheral base address.
Returns
Raw value of capture register, data format is gray code.
uint64_t OSTIMER_GetCaptureValue ( OSTIMER_Type *  base)

This function will get a capture decimal-value from OSTIMER. The RAW value of timer capture is gray code format, will be translated to decimal data internally.

Parameters
baseOSTIMER peripheral base address.
Returns
Value of capture register, data format is decimal.
void OSTIMER_HandleIRQ ( OSTIMER_Type *  base,
ostimer_callback_t  cb 
)

This function handles the interrupt and refers to the callback array in the driver to callback user (as per request in OSTIMER_SetMatchValue()). if no user callback is scheduled, the interrupt will simply be cleared.

Parameters
baseOS timer peripheral base address.
cbcallback scheduled for this instance of OS timer
Returns
none