const ITimer.ANY |
|
Const used to specify any timer
enum ITimer.PeriodType |
|
PeriodType
enum PeriodType {
PeriodType_MICROSECS,
// period in microsecs
PeriodType_COUNTS
// period in counts
};
VALUES
PeriodType_MICROSECS
Period value is in microseconds.
PeriodType_COUNTS
Period value is in counts.
enum ITimer.RunMode |
|
Timer Run Modes
enum RunMode {
RunMode_CONTINUOUS,
// periodic and continuous
RunMode_ONESHOT
// one-shot
};
VALUES
RunMode_CONTINUOUS
Timer is periodic and runs continuously.
RunMode_ONESHOT
Timer runs for a single period value and stops
enum ITimer.StartMode |
|
Timer Start Modes
enum StartMode {
StartMode_AUTO,
// timer starts automatically
StartMode_USER
// timer will be started by user
};
VALUES
StartMode_AUTO
Statically created/constructed Timers will be started in BIOS_start().
Dynamically created Timers will start at create() time. This includes
timers created before BIOS_start().
StartMode_USER
Timer will be started by the user using start().
enum ITimer.Status |
|
Timer Status
enum Status {
Status_INUSE,
// timer in use
Status_FREE
// timer is free
};
VALUES
Status_INUSE
Timer is in use. A timer is marked in use from the time it gets
created to the time it gets deleted.
Status_FREE
Timer is free and can be acquired using create.
typedef ITimer.FuncPtr |
|
Timer tick function prototype
typedef Void (*FuncPtr)(UArg);
metaonly config ITimer.common$ // module-wide |
|
Common module configuration parameters
DETAILS
All modules have this configuration parameter. Its name
contains the '$' character to ensure it does not conflict with
configuration parameters declared by the module. This allows
new configuration parameters to be added in the future without
any chance of breaking existing modules.
ITimer.getNumTimers() // module-wide |
|
Returns number of timer peripherals on the platform
RETURNS
Number of timer peripherals.
ITimer.getStatus() // module-wide |
|
Returns timer status (free or in use)
RETURNS
timer status
config ITimer.arg // instance |
|
Argument for tick function. Default is null
config ITimer.extFreq // instance |
|
Timer frequency
DETAILS
This parameter is meaningfull only on platforms where the timer clock
can be changed. If value is left at zero, then default hookup of timer
clock is assumed.
config ITimer.period // instance |
|
Period of tick. Can be specified in timer counts or microseconds.
Default is 0
config UInt32 period = 0;
DETAILS
The implementation of ITimer will support a period of UInt32
timer counts and use pre-scalars if necessary.
config ITimer.periodType // instance |
|
Period Type. Default is PeriodType_MICROSECS
config ITimer.runMode // instance |
|
Timer run mode. Default is RunMode_CONTINUOUS
config ITimer.startMode // instance |
|
Start mode. Default is StartMode_AUTO
Instance Creation |
|
// Create an instance-object
ARGUMENTS
id
Timer id ranging from 0 to a platform specific value
tickFxn
function that runs upon timer expiry.
DETAILS
Create could fail if timer peripheral is unavailable. To
request any available timer use
ANY as the id.
TimerId's are logical ids. The family-specific implementations
map the ids to physical peripherals.
ITimer.getCount() // instance |
|
Reads timer counter register
RETURNS
timer counter value
ITimer.getFreq() // instance |
|
Returns timer frequency in Hz
ARGUMENTS
freq
frequency in Hz
DETAILS
This is the effective frequency of the clock incrementing the timer
counter register after all scaling factors are taken into account.
(including pre-scalars).
ITimer.getFunc() // instance |
|
Get Timer function and arg
ARGUMENTS
arg
pointer for returning Timer's function argument
RETURNS
Timer's function
ITimer.getPeriod() // instance |
|
Gets timer period in timer counts
RETURNS
period in timer counts
ITimer.setFunc() // instance |
|
Overwrite Timer function and arg
ARGUMENTS
fxn
pointer to function
arg
argument to function
DETAILS
Replaces a Timer object's tickFxn function originally
provided in
create.
ITimer.setPeriod() // instance |
|
Sets timer period specified in timer counts
Void setPeriod(UInt32 period);
ARGUMENTS
period
period in timer counts
DETAILS
Timer_setPeriod() invokes Timer_stop() prior to setting the period
and leaves the timer in the stopped state.
To dynamically change the period of a timer you must
protect against re-entrancy by disabling interrupts.
Use the following call sequence to guarantee proper results:
// disable interrupts if an interrupt could lead to
// another call to Timer_start().
key = Hwi_disable();
Timer_setPeriod(period);
Timer_start();
Hwi_restore(key);
ITimer implementation must support UInt32 and use pre-scalars whenever
necessary
SIDE EFFECTS
Calls Timer_stop(), and disables the timer's interrupt.
ITimer.setPeriodMicroSecs() // instance |
|
Sets timer period specified in microseconds
Bool setPeriodMicroSecs(UInt32 microsecs);
ARGUMENTS
period
period in microseconds
DETAILS
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, ie the timer period register cannot support the requested
period, then this function returns false.
Timer_setPeriodMicroSecs() invokes Timer_stop() prior to setting
the period and leaves the timer in the stopped state.
To dynamically change the period of a timer you must
protect against re-entrancy by disabling interrupts.
Use the following call sequence to guarantee proper results:
// disable interrupts if an interrupt could lead to
// another call to Timer_start().
key = Hwi_disable();
Timer_setPeriodMicroSecs(period);
Timer_start();
Hwi_restore(key);
ITimer.start() // instance |
|
Reloads and starts the timer
DETAILS
Thread safety must be observed when using the
start
and
stop APIs to avoid possible miss-
configuration of the timers and unintended behaviors.
To protect against re-entrancy, surround the start/stop invocations
with
Hwi_disable() and
Hwi_restore() calls:
// disable interrupts if an interrupt could lead to
// another call to Timer_start().
key = Hwi_disable();
Timer_stop();
...
Timer_start();
Hwi_restore(key);
SIDE EFFECTS
Enables the timer's interrupt.
ITimer.stop() // instance |
|
Stop the timer
DETAILS
Thread safety must be observed when using the
start
and
stop APIs to avoid possible miss-
configuration of the timers and unintended behaviors.
To protect against re-entrancy, surround the start/stop invocations
with
Hwi_disable() and
Hwi_restore() calls:
// disable interrupts if an interrupt could lead to
// another call to Timer_start().
key = Hwi_disable();
Timer_stop();
...
Timer_start();
Hwi_restore(key);
SIDE EFFECTS
Disables the timer's interrupt.