|
1 | | -.. _lib_timer: |
| 1 | +.. _lib_bm_timer: |
2 | 2 |
|
3 | | -Timer Library |
| 3 | +Timer library |
4 | 4 | ############# |
5 | 5 |
|
6 | 6 | .. contents:: |
7 | 7 | :local: |
8 | 8 | :depth: 2 |
9 | 9 |
|
10 | | -Overview |
11 | | -******** |
| 10 | +The timer library allows the application to create multiple timer instances. |
12 | 11 |
|
13 | | -The timer library enables the application to create multiple timer instances. |
14 | | -Start and stop requests, checking for time-outs, and invoking the user time-out handlers are performed in the GRTC interrupt handler. |
| 12 | +Functions such as starting and stopping timers, checking for timeouts, and invoking user-defined timeout handlers are all managed within the GRTC interrupt handler. |
15 | 13 |
|
16 | 14 | Configuration |
17 | 15 | ************* |
18 | 16 |
|
19 | 17 | The library is enabled and configured entirely using the Kconfig system. |
20 | 18 | Set the :kconfig:option:`CONFIG_BM_TIMER` Kconfig option to enable the library. |
21 | 19 |
|
22 | | -You can set the timer IRQ priority by setting the :kconfig:option:`CONFIG_BM_TIMER_IRQ_PRIO` Kconfig option. |
| 20 | +You can adjust the timer IRQ priority using the :kconfig:option:`CONFIG_BM_TIMER_IRQ_PRIO` Kconfig option. |
23 | 21 |
|
24 | 22 | Initialization |
25 | 23 | ============== |
26 | 24 |
|
27 | | -A timer instance is initialized by calling the :c:func:`bm_timer_init` function, selecting the timer mode and providing the user callback for when the timer expires. |
| 25 | +To initialize a timer instance, call the :c:func:`bm_timer_init` function. |
| 26 | +Specify the timer mode and provide a user callback function that will be called when the timer expires. |
| 27 | + |
28 | 28 | The timer can be initialized in the following modes: |
29 | 29 |
|
30 | | -* :c:macro:`BM_TIMER_MODE_SINGLE_SHOT` - Expire only once when started. |
31 | | -* :c:macro:`BM_TIMER_MODE_REPEATED` - Restart when expired until stopped. |
| 30 | +* :c:macro:`BM_TIMER_MODE_SINGLE_SHOT` - The timer expires only once after it is started. |
| 31 | +* :c:macro:`BM_TIMER_MODE_REPEATED` - The timer automatically restarts upon expiring until it is stopped. |
32 | 32 |
|
33 | 33 | Usage |
34 | 34 | ***** |
35 | 35 |
|
36 | | -After initialization, the timer is started by calling the :c:func:`bm_timer_start` function, providing the timeout and user provided context passed to the callback. |
37 | | -The timeout is given in ticks. |
38 | | -The library provides macros for providing the time in standard time units: |
| 36 | +After initialization, start the timer by calling the :c:func:`bm_timer_start` function, providing the timeout and user-provided context passed to the callback. |
| 37 | +The timeout is provided in ticks. |
| 38 | + |
| 39 | +The library provides macros to convert standard time units to ticks: |
39 | 40 |
|
40 | 41 | * :c:macro:`BM_TIMER_US_TO_TICKS` - Converts microseconds to ticks. |
41 | 42 | * :c:macro:`BM_TIMER_MS_TO_TICKS` - Converts milliseconds to ticks. |
42 | 43 |
|
43 | | -A timer is stopped by calling the :c:func:`bm_timer_stop` function. |
| 44 | +To stop a timer, call the :c:func:`bm_timer_stop` function. |
| 45 | + |
| 46 | +Sample |
| 47 | +****** |
| 48 | + |
| 49 | +Usage of this library is demonstrated in the :ref:`timer_sample` sample. |
44 | 50 |
|
45 | 51 | Dependencies |
46 | 52 | ************ |
|
0 commit comments