blob: 8a3de6e8cce0eb6aa1f58ec23af4f3838599e6a1 [file] [log] [blame]
Kévin Redonb14518c2019-06-06 13:54:50 +02001===============================
2The Calendar driver (bare-bone)
3===============================
4
5The Calendar driver provides means to set and get current date and time.
6After enabling, an instance of the driver starts counting time from the base date with
7the resolution of one second. The default base date is 00:00:00 1st of January 1970.
8Only the base year of the base date can be changed via the driver API.
9
10The current date and time is kept internally in a relative form as the difference between
11current date and time and the base date and time. This means that changing the base year changes
12current date.
13
14The base date and time defines time "zero" or the earliest possible point in time that the calender driver can describe,
15this means that current time and alarms can not be set to anything earlier than this time.
16
17The Calendar driver provides alarm functionality.
18An alarm is a software trigger which fires on particular date and time with particular periodicity.
19Upon firing the given callback function is called.
20
21An alarm can be in single-shot mode, firing only once at matching time; or in repeating mode, meaning that it will
22reschedule a new alarm automatically based on repeating mode configuration.
23In single-shot mode an alarm is removed from the alarm queue before its callback is called. It allows an application to
24reuse the memory of expired alarm in the callback.
25
26An alarm can be triggered on the following events: match on second, minute, hour, day, month or year.
27Matching on second means that the alarm is triggered when the value of seconds of the current time is equal to
28the alarm's value of seconds. This means repeating alarm with match on seconds is triggered with the period of a minute.
29Matching on minute means that the calendars minute and seconds values has to match the alarms, the rest of the date-time
30value is ignored. In repeating mode this means a new alarm every hour.
31The same logic is applied to match on hour, day, month and year.
32
33Each instance of the Calendar driver supports infinite amount of software alarms, only limited by the amount of RAM available.
34
35Features
36--------
37* Initialization and de-initialization
38* Enabling and disabling
39* Date and time operations
40* Software alarms
41
42Applications
43------------
44* A source of current date and time for an embedded system.
45* Periodical functionality in low-power applications since the driver is designed to use 1Hz clock.
46* Periodical function calls in case if it is more convenient to operate with absolute time.
47
48Dependencies
49------------
50* This driver expects a counter to be increased by one every second to count date and time correctly.
51* Each instance of the driver requires separate hardware timer.
52
53Concurrency
54-----------
55The Calendar driver is an interrupt driven driver.This means that the interrupt that triggers an alarm may occur during
56the process of adding or removing an alarm via the driver's API. In such case the interrupt processing is postponed
57until the alarm adding or removing is complete.
58
59The alarm queue is not protected from the access by interrupts not used by the driver. Due to this
60it is not recommended to add or remove an alarm from such interrupts: in case if a higher priority interrupt supersedes
61the driver's interrupt, adding or removing an alarm may cause unpredictable behavior of the driver.
62
63Limitations
64-----------
65* Only years divisible by 4 are deemed a leap year, this gives a correct result between the years 1901 to 2099.
66* The driver is designed to work outside of an operating system environment, the software alarm queue is therefore processed in interrupt context which may delay execution of other interrupts.
67* If there are a lot of frequently called interrupts with the priority higher than the driver's one, it may cause delay in alarm's triggering.
68* Changing the base year or setting current date or time does not shift alarms' date and time accordingly or expires alarms.
69
70Knows issues and workarounds
71----------------------------
72Not applicable