amiro-os / core / inc / aos_iostream.h @ b010278f
History | View | Annotate | Download (5.725 KB)
1 | ba516b61 | Thomas Schöpping | /*
|
---|---|---|---|
2 | AMiRo-OS is an operating system designed for the Autonomous Mini Robot (AMiRo) platform.
|
||
3 | 84f0ce9e | Thomas Schöpping | Copyright (C) 2016..2019 Thomas Schöpping et al.
|
4 | ba516b61 | Thomas Schöpping | |
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 | 53710ca3 | Marc Rothmann | /**
|
20 | * @file aos_iostream.h
|
||
21 | * @brief Stream and channel macros and structures.
|
||
22 | *
|
||
23 | * @addtogroup aos_stream
|
||
24 | * @{
|
||
25 | */
|
||
26 | |||
27 | 6ff06bbf | Thomas Schöpping | #ifndef AMIROOS_IOSTREAM_H
|
28 | #define AMIROOS_IOSTREAM_H
|
||
29 | ba516b61 | Thomas Schöpping | |
30 | 3940ba8a | Thomas Schöpping | #include <amiroos.h> |
31 | ba516b61 | Thomas Schöpping | |
32 | f3ac1c96 | Thomas Schöpping | /******************************************************************************/
|
33 | /* CONSTANTS */
|
||
34 | /******************************************************************************/
|
||
35 | ba516b61 | Thomas Schöpping | |
36 | /**
|
||
37 | * @brief Channel flag to indicate whether the channel is attached to a stream.
|
||
38 | */
|
||
39 | f3ac1c96 | Thomas Schöpping | #define AOS_IOCHANNEL_ATTACHED ((aos_iochannelflag_t)(1 << 0)) |
40 | ba516b61 | Thomas Schöpping | |
41 | /**
|
||
42 | dd8738ea | Thomas Schöpping | * @brief Channel flag to indicate whether the channel is set as input.
|
43 | */
|
||
44 | f3ac1c96 | Thomas Schöpping | #define AOS_IOCHANNEL_INPUT_ENABLE ((aos_iochannelflag_t)(1 << 1)) |
45 | dd8738ea | Thomas Schöpping | |
46 | /**
|
||
47 | ba516b61 | Thomas Schöpping | * @brief Channel flag to indicate whether the channel is set as output.
|
48 | */
|
||
49 | f3ac1c96 | Thomas Schöpping | #define AOS_IOCHANNEL_OUTPUT_ENABLE ((aos_iochannelflag_t)(1 << 2)) |
50 | ba516b61 | Thomas Schöpping | |
51 | f3ac1c96 | Thomas Schöpping | /******************************************************************************/
|
52 | /* SETTINGS */
|
||
53 | /******************************************************************************/
|
||
54 | |||
55 | /******************************************************************************/
|
||
56 | /* CHECKS */
|
||
57 | /******************************************************************************/
|
||
58 | |||
59 | /******************************************************************************/
|
||
60 | /* DATA STRUCTURES AND TYPES */
|
||
61 | /******************************************************************************/
|
||
62 | |||
63 | typedef uint8_t aos_iochannelflag_t;
|
||
64 | ba516b61 | Thomas Schöpping | |
65 | /**
|
||
66 | f3ac1c96 | Thomas Schöpping | * @brief AosIOChannel specific methods.
|
67 | ba516b61 | Thomas Schöpping | */
|
68 | #define _aos_iochannel_methods \
|
||
69 | _base_asynchronous_channel_methods |
||
70 | |||
71 | /**
|
||
72 | * @brief AosIOChannel specific data.
|
||
73 | */
|
||
74 | #define _aos_iochannel_data \
|
||
75 | /* pointer to a BaseAsynchronousChannel object */ \
|
||
76 | BaseAsynchronousChannel* asyncchannel; \ |
||
77 | /* pointer to the next channel in a AosIOStream */ \
|
||
78 | f3ac1c96 | Thomas Schöpping | struct aos_iochannel* next; \
|
79 | ba516b61 | Thomas Schöpping | /* flags related to the channel */ \
|
80 | f3ac1c96 | Thomas Schöpping | aos_iochannelflag_t flags; |
81 | ba516b61 | Thomas Schöpping | |
82 | /**
|
||
83 | * @extends BaseAsynchronousChannelVMT
|
||
84 | *
|
||
85 | * @brief AosIOChannel virtual methods table.
|
||
86 | */
|
||
87 | struct AosIOChannelVMT {
|
||
88 | _aos_iochannel_methods |
||
89 | }; |
||
90 | |||
91 | /**
|
||
92 | * @extends BaseAsynchronousChannel
|
||
93 | *
|
||
94 | * @brief I/O Channel class.
|
||
95 | * @details This class implements an asynchronous I/O channel.
|
||
96 | */
|
||
97 | f3ac1c96 | Thomas Schöpping | typedef struct aos_iochannel { |
98 | ba516b61 | Thomas Schöpping | /** @brief Virtual Methods Table. */
|
99 | const struct AosIOChannelVMT* vmt; |
||
100 | _aos_iochannel_data |
||
101 | f3ac1c96 | Thomas Schöpping | } AosIOChannel; |
102 | ba516b61 | Thomas Schöpping | |
103 | /**
|
||
104 | * @brief AosIOStream methods.
|
||
105 | */
|
||
106 | #define _aos_iostream_methods \
|
||
107 | _base_sequential_stream_methods |
||
108 | |||
109 | /**
|
||
110 | * @brief AosIOStream data.
|
||
111 | */
|
||
112 | #define _aos_iostream_data \
|
||
113 | /* Pointer to the first channel in a list. */ \
|
||
114 | AosIOChannel* channel; |
||
115 | |||
116 | /**
|
||
117 | * @extends BaseSequentialStream
|
||
118 | *
|
||
119 | * @brief AosIOStream virtual methods table.
|
||
120 | */
|
||
121 | struct AosIOStreamVMT {
|
||
122 | _aos_iostream_methods |
||
123 | }; |
||
124 | |||
125 | /**
|
||
126 | * @extends BaseSequentialStream
|
||
127 | *
|
||
128 | * @brief I/O Stream class.
|
||
129 | * @details This class implements an base sequential stream.
|
||
130 | * @todo So far only output but no input is supported.
|
||
131 | */
|
||
132 | f3ac1c96 | Thomas Schöpping | typedef struct aos_ostream { |
133 | ba516b61 | Thomas Schöpping | const struct AosIOStreamVMT* vmt; |
134 | _aos_iostream_data |
||
135 | f3ac1c96 | Thomas Schöpping | } AosIOStream; |
136 | |||
137 | /******************************************************************************/
|
||
138 | /* MACROS */
|
||
139 | /******************************************************************************/
|
||
140 | |||
141 | /******************************************************************************/
|
||
142 | /* EXTERN DECLARATIONS */
|
||
143 | /******************************************************************************/
|
||
144 | ba516b61 | Thomas Schöpping | |
145 | 7de0cc90 | Thomas Schöpping | #if defined(__cplusplus)
|
146 | ba516b61 | Thomas Schöpping | extern "C" { |
147 | 7de0cc90 | Thomas Schöpping | #endif /* defined(__cplusplus) */ |
148 | ba516b61 | Thomas Schöpping | void aosIOStreamInit(AosIOStream* stream);
|
149 | void aosIOChannelInit(AosIOChannel* channel, BaseAsynchronousChannel* asyncchannel);
|
||
150 | void aosIOStreamAddChannel(AosIOStream* stream, AosIOChannel* channel);
|
||
151 | aos_status_t aosIOStreamRemoveChannel(AosIOStream* stream, AosIOChannel* channel); |
||
152 | dd8738ea | Thomas Schöpping | void aosIOChannelInputEnable(AosIOChannel* channel);
|
153 | void aosIOChannelInputDisable(AosIOChannel* channel);
|
||
154 | ba516b61 | Thomas Schöpping | void aosIOChannelOutputEnable(AosIOChannel* channel);
|
155 | void aosIOChannelOutputDisable(AosIOChannel* channel);
|
||
156 | 7de0cc90 | Thomas Schöpping | #if defined(__cplusplus)
|
157 | ba516b61 | Thomas Schöpping | } |
158 | 7de0cc90 | Thomas Schöpping | #endif /* defined(__cplusplus) */ |
159 | ba516b61 | Thomas Schöpping | |
160 | f3ac1c96 | Thomas Schöpping | /******************************************************************************/
|
161 | /* INLINE FUNCTIONS */
|
||
162 | /******************************************************************************/
|
||
163 | |||
164 | 6ff06bbf | Thomas Schöpping | #endif /* AMIROOS_IOSTREAM_H */ |
165 | 53710ca3 | Marc Rothmann | |
166 | /** @} */ |