This module manages Alarms objects. Alarm objects internally create
and schedule Clock objects, to expire at specified 64-bit RTC count values.
typedef Alarm_FuncPtr |
|
Instance function prototype
typedef Void (*Alarm_FuncPtr)(UArg);
Alarm_getCount() // module-wide |
|
Get the current RTC count
Module-Wide Built-Ins |
|
// Get this module's unique id
Bool Alarm_Module_startupDone();
// Test if this module has completed startup
// The heap from which this module allocates memory
Bool Alarm_Module_hasMask();
// Test whether this module has a diagnostics mask
Bits16 Alarm_Module_getMask();
// Returns the diagnostics mask for this module
Void Alarm_Module_setMask(Bits16 mask);
// Set the diagnostics mask for this module
Instance Object Types |
|
typedef struct Alarm_Object Alarm_Object;
// Opaque internal representation of an instance object
// Client reference to an instance object
typedef struct Alarm_Struct Alarm_Struct;
// Opaque client structure large enough to hold an instance object
// Convert this instance structure pointer into an instance handle
// Convert this instance handle into an instance structure pointer
Instance Config Parameters |
|
typedef struct Alarm_Params {
// Instance config-params structure
// Common per-instance configs
} Alarm_Params;
// Initialize this config-params structure with supplier-specified defaults before instance creation
Runtime Instance Creation |
|
// Allocate and initialize a new instance object and return its handle
// Initialize a new instance object inside the provided structure
ARGUMENTS
arg
argument to the alarm function
params
per-instance config params, or NULL to select default values (target-domain only)
eb
active error-handling block, or NULL to select default policy (target-domain only)
Instance Deletion |
|
// Finalize and free this previously allocated instance object, setting the referenced handle to NULL
// Finalize the instance object inside the provided structure
Alarm_set() // instance |
|
Set and start an alarm, to expire upon a specified RTC count value
ARGUMENTS
handle
handle of a previously-created Alarm instance object
countRTC
64-bit target RTC count
RETURNS
TRUE if alarm is set, FALSE if countRTC is in the past,
or is too soon to trigger the corresponding Clock
interrupt
DETAILS
The RTC count will be converted to the closest
Clock tick that expires before the
specified RTC count.
When the alarm expires, the alarm's function will be called, with the
specified argument, from
Swi context. The
alarm function could complete its processing and return, or it might
defer processing by signaling another thread.
The alarm function can be unique to the application, or it might be
a common kernel function. For example, to create an alarm that wakes
a task that is pended upon a semaphore, the alarm function could be
Semaphore_post(), and the argument the handle of a semaphore that
the task is pended upon:
Void yourFunc() {
...
sem = Semaphore_create(0, NULL, NULL);
...
alm = Alarm_create((Alarm_FuncPtr)Semaphore_post, (UArg)sem, NULL,
NULL);
...
Alarm_set(alm, 0x200000000);
...
}
Alarm_setFunc() // instance |
|
Change an alarm's function and argument
ARGUMENTS
handle
handle of a previously-created Alarm instance object
arg
argument to the Alarm function
DETAILS
Replaces an alarm's function and argument, with a new function and
argument.
CONSTRAINTS
Cannot change the function and argument of Alarm that has already been
started with
Alarm_set or
Alarm_setTick.
Alarm_stop() // instance |
|
Stop an alarm that has been started with Alarm_set or
Alarm_setTick
ARGUMENTS
handle
handle of a previously-created Alarm instance object
Instance Built-Ins |
|
Int Alarm_Object_count();
// The number of statically-created instance objects
// The handle of the i-th statically-created instance object (array == NULL)
// The handle of the first dynamically-created instance object, or NULL
// The handle of the next dynamically-created instance object, or NULL
// The heap used to allocate dynamically-created instance objects
// The label associated with this instance object
// The name of this instance object