ssm  0.0.2
Runtime Library for the Sparse Synchronous Model
ssm-platform.h
Go to the documentation of this file.
1 #ifndef _SSM_PLATFORM_H
2 #define _SSM_PLATFORM_H
3 
4 #include <ssm.h>
5 
6 /**
7  * @addtogroup platform
8  * @{
9  */
10 
11 /** @brief Platform-defined entry point.
12  *
13  * Should be called by @a main function to start running SSM code.
14  *
15  * @returns 0 on success, negative errno otherwise.
16  */
18 
19 /** @brief Insert an input event into the input queue.
20  *
21  * The input event is timestamped with the current (platform-defined)
22  * timestamp. The given value @a val will later be written to the scheduled
23  * variable @a sv once the tick function has caught up with current time.
24  *
25  * Note that this function is not re-entrant and should be called with some
26  * kind of lock held to avoid clobbering the input queue.
27  *
28  * @param sv the scheduled variable to be updated.
29  * @param val the value @a sv should be updated with.
30  * @returns 0 on success, negative errno otherwise.
31  */
33 
34 /** @} */
35 
36 #if 0 // This subsystem isn't really ready yet.
37 /**
38  * @addtogroup device
39  * @{
40  */
41 
42 /** @brief Lookup symbol for device with given name. */
43 #define SSM_DEVICE(name) name
44 
45 /** @brief Lookup symbol for input device's #ssm_input_t using given name. */
46 #define SSM_DEVICE_INPUT(name) ssm_input_device_##name
47 
48 /** @brief Lookup symbol for output device's #ssm_output_t using given name. */
49 #define SSM_DEVICE_OUTPUT(name) ssm_output_device_##name
50 
51 /** @brief Lookup symbol determining whether a device is in use.
52  *
53  * @param kind either `INPUT` or `OUTPUT`.
54  * @param name the name of the device.
55  */
56 #define SSM_DEVICE_IN_USE(kind, name) SSM_##kind##_DEVICE_IN_USE_##name
57 
58 /** @brief Announce that a device of some name exists and may be used.
59  *
60  * Note that this only declares that a device <emph>might</emph> be used.
61  * By default, it is assumed not to be used, using a weak definition.
62  *
63  * User programs may declare that they <emph>will</emph> use some device using
64  * SSM_DECLARE_DEVICE_IN_USE(), overriding this macro's weak definition.
65  *
66  * @param kind either `INPUT` or `OUTPUT`.
67  * @param name the name of the device.
68  */
69 #define SSM_DECLARE_DEVICE_EXISTS(kind, name) \
70  bool __attribute__((weak)) SSM_DEVICE_IN_USE(kind, name) = false
71 
72 /** @brief Announce that a device of some name will (or won't) be used.
73  *
74  * Note that this only declares that a device <emph>might</emph> be used.
75  * By default, it is assumed not to be used, using a weak definition.
76  *
77  * User programs may declare that they <emph>will</emph> use some device using
78  * SSM_DECLARE_DEVICE_IN_USE(), overriding this macro's weak definition.
79  *
80  * @param kind either `INPUT` or `OUTPUT`.
81  * @param name the name of the device.
82  * @param in_use boolean indicating whether the device will be used.
83  */
84 #define SSM_DECLARE_DEVICE_IN_USE(kind, name, in_use) \
85  bool SSM_DEVICE_IN_USE(kind, name) = in_use
86 
87 /** @brief Declare a Zephyr input device used by the user program.
88  *
89  * @param name the name of the device.
90  */
91 #define SSM_DECLARE_ZEPHYR_INPUT_DEVICE(name) \
92  SSM_DECLARE_DEVICE_IN_USE(INPUT, name, true); \
93  extern ssm_sv_t SSM_DEVICE(name);
94 
95 /** @brief Declare a Zephyr output device used by the user program.
96  *
97  * @param name the name of the device.
98  */
99 #define SSM_DECLARE_ZEPHYR_OUTPUT_DEVICE(name) \
100  SSM_DECLARE_DEVICE_IN_USE(OUTPUT, name, true); \
101  extern ssm_sv_t SSM_DEVICE(name);
102 
103 /** @brief Declare a Zephyr I/O device used by the user program.
104  *
105  * @param name the name of the device.
106  */
107 #define SSM_DECLARE_ZEPHYR_IO_DEVICE(name) \
108  SSM_DECLARE_DEVICE_IN_USE(INPUT, name, true); \
109  SSM_DECLARE_DEVICE_IN_USE(OUTPUT, name, true); \
110  extern ssm_sv_t SSM_DEVICE(name);
111 
112 /** @} */
113 #endif // #if 0
114 
115 #endif /* ifndef _SSM_PLATFORM_H */
int ssm_platform_entry(void)
Platform-defined entry point.
int ssm_insert_input(ssm_sv_t *sv, ssm_value_t val)
Insert an input event into the input queue.
Interface to the SSM runtime.
A scheduled variable that supports scheduled updates with triggers.
Definition: ssm.h:588
SSM values are either "packed" values or heap-allocated.
Definition: ssm.h:232