timer_initialize. STMicroelectronics OS20
โฆษณา
โฆษณา
OS20 User Manual 16.2 OS20 function descriptions
timer_initialize
Initialize the timer plug-in library for ST20-C1 cores
Synopsis
#include <c1timer.h> void timer_initialize( timer_api_t* timer_functions );
Arguments timer_api_t* timer_functions Table of function pointers for use by the OS20 time functions
Results
None
Errors
None
Description
The timer_initialize function enables OS20 when it is run on an ST20-C1 core to fully implement the OS20 API. The ST20-C1 core does not have a built-in timer and therefore requires the timer code in order to support functions that require timed waits such as task_delay or message_claim_timeout . See
Chapter 13: ST20-C1 specific features on page 87
.
The plug-in functions are typically implemented using the on-chip PWM peripheral but there are other ways the timer can be implemented.
timer_functions should be populated with function pointers as described below.
int (*timer_read)(void); timer_read is used by OS20 to determine the current time.
timer_read should return a 32-bit unsigned integer (although for legacy reasons it is prototyped to return a signed integer)). To ensure that the timer arithmetic works correctly it is important that the timer does not roll-over before it reaches 0xFFFFFFFF. For example a
16-bit counter should be multiplied by 65536 before being returned, in order to meet the rollover requirements.
void (*timer_set)(int time); timer_set is used by OS20 to set the point at which the timer expires.
timer_set should treat its argument as a 32-bit unsigned integer (although for legacy reasons it is prototyped to take a signed integer). When the current time reaches the supplied time, the timer plug-in should call timer_interrupt . Typically this function programs whatever hardware device is being used to generate an interrupt at the appropriate time.
void (*timer_enable_int)(void); void (*timer_disable_int)(void);
The functions are used by OS20 to enable or disable the timer interrupt.
The timer_interrupt function should not be called unless the timer interrupt is enabled.
292
ADCS 7473749D
16.2 OS20 function descriptions 16 Alphabetical list of functions void (*timer_raise_int)(void); timer_raise_int is used by OS20 to forcibly generate a timer interrupt.
This function should cause timer_interrupt to be called, typically by generating a software interrupt using interrupt_raise_number .
Callable from
Tasks only
Example
Refer to the examples supplied with the toolset in:
$ST20ROOT/examples/os20/c1timer
See also
293
ADCS 7473749D
ดาวน์โหลด
โฆษณา