amiro-os / os / core / inc / aos_ssm.h @ e545e620
History | View | Annotate | Download (3.242 KB)
1 | e545e620 | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | Copyright (C) 2016..2018 Thomas Schöpping et al.
|
||
4 | |||
5 | This program is free software: you can redistribute it and/or modify
|
||
6 | it under the terms of the GNU General Public License as published by
|
||
7 | the Free Software Foundation, either version 3 of the License, or
|
||
8 | (at your option) any later version.
|
||
9 | |||
10 | This program is distributed in the hope that it will be useful,
|
||
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
13 | GNU General Public License for more details.
|
||
14 | |||
15 | You should have received a copy of the GNU General Public License
|
||
16 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||
17 | */
|
||
18 | |||
19 | #ifndef _AMIROOS_SSM_H_
|
||
20 | #define _AMIROOS_SSM_H_
|
||
21 | |||
22 | #include <hal.h> |
||
23 | #include <aos_types.h> |
||
24 | #include <aos_debug.h> |
||
25 | |||
26 | /**
|
||
27 | * @brief Sequential Stream Multiplexer output structure.
|
||
28 | */
|
||
29 | typedef struct ssm_output { |
||
30 | /**
|
||
31 | * @brief Pointer to a BaseSequentialStream object.
|
||
32 | */
|
||
33 | BaseSequentialStream* stream; |
||
34 | |||
35 | /**
|
||
36 | * @brief Pointer to the next element in a singly linked list.
|
||
37 | */
|
||
38 | struct ssm_output* next;
|
||
39 | |||
40 | /**
|
||
41 | * @brief Flags related to the output.
|
||
42 | */
|
||
43 | uint8_t flags; |
||
44 | } ssm_output_t; |
||
45 | |||
46 | /**
|
||
47 | * @brief Output flag to indicate whether the output is attached to a SSM list.
|
||
48 | */
|
||
49 | #define SSM_OUTPUT_FLAG_ATTACHED (1 << 0) |
||
50 | |||
51 | /**
|
||
52 | * @brief Output flag to indicate whether the output is enabled.
|
||
53 | */
|
||
54 | #define SSM_OUTPUT_FLAG_ENABLED (1 << 1) |
||
55 | |||
56 | /**
|
||
57 | * @brief Sequential Stream Multiplexer specific methods.
|
||
58 | */
|
||
59 | #define _sequential_stream_mux_methods \
|
||
60 | _base_sequential_stream_methods \ |
||
61 | |||
62 | /**
|
||
63 | * @brief Sequential Stream Multiplexer specific data.
|
||
64 | */
|
||
65 | #define _sequential_stream_mux_data \
|
||
66 | _base_sequential_stream_data \ |
||
67 | ssm_output_t* outputs; \ |
||
68 | BaseSequentialStream* input; \ |
||
69 | |||
70 | /**
|
||
71 | * @brief Sequential Stream Multiplexer virtual methods table.
|
||
72 | */
|
||
73 | struct SequentialStreamMuxVMT {
|
||
74 | _sequential_stream_mux_methods |
||
75 | }; |
||
76 | |||
77 | /**
|
||
78 | * @brief Sequential Stream Multiplexer structure.
|
||
79 | */
|
||
80 | typedef struct { |
||
81 | /**
|
||
82 | * @brief Virtual methods table.
|
||
83 | */
|
||
84 | const struct SequentialStreamMuxVMT *vmt; |
||
85 | |||
86 | /**
|
||
87 | * @brief Data fields.
|
||
88 | */
|
||
89 | _sequential_stream_mux_data |
||
90 | } SequentialStreamMux; |
||
91 | |||
92 | #ifdef __cplusplus
|
||
93 | extern "C" { |
||
94 | #endif
|
||
95 | void ssmObjectInit(SequentialStreamMux* ssmp);
|
||
96 | void ssmOutputInit(ssm_output_t* op, BaseSequentialStream* stream);
|
||
97 | void ssmAddOutput(SequentialStreamMux* ssmp, ssm_output_t* output);
|
||
98 | aos_status_t ssmRemoveOutput(SequentialStreamMux* ssmp, BaseSequentialStream* stream, ssm_output_t** removed); |
||
99 | aos_status_t ssmEnableOutput(SequentialStreamMux* ssmp, BaseSequentialStream* stream); |
||
100 | aos_status_t ssmDisableOutput(SequentialStreamMux* ssmp, BaseSequentialStream* stream); |
||
101 | #ifdef __cplusplus
|
||
102 | } |
||
103 | #endif
|
||
104 | |||
105 | /**
|
||
106 | * @brief Set the input stream
|
||
107 | *
|
||
108 | * @param[in] ssmp pointer to the @p SequentialStreamMux object
|
||
109 | * @param[in] stream pointer to a @p BaseSequentialStream or NULL to disable input
|
||
110 | */
|
||
111 | static inline void ssmSetInput(SequentialStreamMux* ssmp, BaseSequentialStream* stream) |
||
112 | { |
||
113 | aosDbgCheck(ssmp != NULL);
|
||
114 | |||
115 | ssmp->input = stream; |
||
116 | |||
117 | return;
|
||
118 | } |
||
119 | |||
120 | #endif /* _AMIROOS_SSM_H_ */ |