-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathnsi_hws_models_if.h
More file actions
49 lines (42 loc) · 1.25 KB
/
nsi_hws_models_if.h
File metadata and controls
49 lines (42 loc) · 1.25 KB
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
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef NSI_COMMON_SRC_INCL_HWS_MODELS_IF_H
#define NSI_COMMON_SRC_INCL_HWS_MODELS_IF_H
#include <stdint.h>
#include "nsi_utils.h"
#include "nsi_hw_scheduler.h"
#ifdef __cplusplus
extern "C" {
#endif
/* Internal structure used to link HW events */
struct nsi_hw_event_st {
void (*const callback)(void);
uint64_t *timer;
};
/**
* Register an event timer and event callback
*
* The HW scheduler will keep track of this event, and call its callback whenever its
* timer is reached.
* The ordering of events in the same microsecond is given by prio (lowest first).
* (Normally HW models will not care about the event ordering, and will simply set a prio like 100)
*
* Only very particular models will need to execute before or after others.
*
* Priority can be a number between 0 and 999.
*/
#define NSI_HW_EVENT(t, fn, prio) \
static const struct nsi_hw_event_st NSI_CONCAT(NSI_CONCAT(__nsi_hw_event_, fn), t) \
__attribute__((__used__)) NSI_NOASAN \
__attribute__((__section__(".nsi_hw_event_" NSI_STRINGIFY(prio)))) \
= { \
.callback = fn, \
.timer = &t, \
}
#ifdef __cplusplus
}
#endif
#endif /* NSI_COMMON_SRC_INCL_HWS_MODELS_IF_H */