xref: /aosp_15_r20/external/pigweed/pw_channel/public/pw_channel/rp2_stdio_channel.h (revision 61c4878ac05f98d0ceed94b57d316916de578985)
1 // Copyright 2024 The Pigweed Authors
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); you may not
4 // use this file except in compliance with the License. You may obtain a copy of
5 // the License at
6 //
7 //     https://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
11 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
12 // License for the specific language governing permissions and limitations under
13 // the License.
14 #pragma once
15 
16 #include <cstdint>
17 #include <optional>
18 
19 #include "pw_async2/poll.h"
20 #include "pw_channel/channel.h"
21 #include "pw_multibuf/allocator.h"
22 #include "pw_multibuf/multibuf.h"
23 
24 namespace pw::channel {
25 
26 /// @defgroup pw_channel_rp2_stdio
27 /// @{
28 
29 /// Initializes and returns a reference to a channel that speaks over rp2's
30 /// stdio.
31 ///
32 /// ***This must only be called at-most once.***
33 ByteReaderWriter& Rp2StdioChannelInit(
34     pw::multibuf::MultiBufAllocator& read_allocator,
35     pw::multibuf::MultiBufAllocator& write_allocator);
36 
37 /// DEPRECATED: prefer the two-allocator version of this API to avoid
38 /// deadlocks due to the read or write side of the API attempting to acquire
39 /// more memory while the other holds it.
40 ///
41 /// Initializes and returns a reference to a channel that speaks over rp2's
42 /// stdio.
43 ///
44 /// ***This must only be called at-most once.***
45 [[deprecated]] ByteReaderWriter& Rp2StdioChannelInit(
46     pw::multibuf::MultiBufAllocator& allocator);
47 
48 /// @}
49 
50 }  // namespace pw::channel
51