1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
// Copyright 2022 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use crate::*;
pub(crate) fn new() -> Item {
let docs = docs! {
/// Timer operations.
};
let name = "timer".into();
let items = vec. The associated unregister
/// function is [`free()`].
fn allocate "ta" {
/// Function called when the timer triggers.
handler_func: fn { data: *const void },
/// The opaque data to use when calling the handler function.
handler_data: *const void,
} -> usize
},
item! {
/// Starts a stopped timer given its identifier.
fn start "tb" {
/// The identifier of the timer to start.
///
/// It must come from an allocated timer that wasn't stopped.
id: usize,
/// Whether the timer should periodically fire.
///
/// Valid values are defined by [`Mode`](super::Mode).
mode: usize,
/// How long until the timer triggers in milli-seconds.
duration_ms: usize,
} -> ()
},
item! {
/// Stops a running timer given its identifier.
///
/// Note that if the timer triggers while being stopped, the handler may still be
/// called.
fn stop "tc" {
/// The identifier of the timer to stop.
id: usize,
} -> ()
},
item! {
/// Deallocates a stopped timer given its identifier.
fn free "td" {
/// The identifier of the timer to free.
id: usize,
} -> ()
},
];
Item::Mod(Mod { docs, name, items })
}