Difference between revisions of "MansOS Alarm"

From DiLab
Jump to: navigation, search
(izeditēju laukā alarmu dokumentaciju, kas neatbilst esošajam kodam)
 
(19 intermediate revisions by one other user not shown)
Line 1: Line 1:
__NOTOC__
__NOTOC__
{{MansOS_ref_navbar|Alarm}}
NOTE: This feature is not implemented as described currently. Older interface version exists.
----


Alarms are used to execute some code after a certain time period, possibly repeatedly.
'''Include file:'''
#include "alarm.h"


The more timers you run, the less precise they may be due to the possibility for several of them to fire at the same time. Only one callback function will be executed immediately, the rest of them will wait for the previous callback to finish and thus will be delayed.
== Data types ==

'''AlarmId_t'''
Handle (ID) for identifying the alarm when calling the alarm procedures.

'''AlarmCb_t'''
Alarm callback function pointer. Points to a function that will be called when the alarm event occurs.


== Constants ==

typedef enum {
ALARM_TYPE_ONESHOOT = 0x01, // fires the alarm once
ALARM_TYPE_REPEAT = 0x02, // fires the alarm repeatedly until stopped
ALARM_TYPE_STARTNOW = 0x04, // Starts the timer now.
} '''AlarmType_t''';

== Functions ==

AlarmId_t '''alarmNew'''();
Create a new alarm. Returns the ID for the new alarm.


void '''alarmSet'''( AlarmId_t id, AlarmType_t type, uint delayInMs, AlarmCb_t callbackFunction );
Set the alarm type and time period.
Set the callback function, unless NULL. When NULL, leave the old callback function.

Do not start the alarm unless ALARM_TYPE_STARTNOW is added to the type.
Stop the alarm if it is already running.



void '''alarmStart'''( AlarmId_t id );
Start the alarm. Resets the alarm if it was already running.


void '''alarmStop'''( AlarmId_t id );
Stop the alarm. You may start this alarm later again.


'''Declared in:'''
#include "alarm.h"


----
void '''alarmFree'''( AlarmId_t id );
{{MansOS_ref_navbar|Alarm}}
Stops and releases the alarm with this ID.

Latest revision as of 14:49, 28 September 2011

MansOS --> Reference --> Alarm :: #Basic :: #Advanced :: #Example

Alarms are used to execute some code after a certain time period, possibly repeatedly.

The more timers you run, the less precise they may be due to the possibility for several of them to fire at the same time. Only one callback function will be executed immediately, the rest of them will wait for the previous callback to finish and thus will be delayed.

Declared in:

#include "alarm.h"

MansOS --> Reference --> Alarm :: #Basic :: #Advanced :: #Example