1 /*******************************************************************************
2  * @file
3  * @brief STDIO compatibility layer.
4  *******************************************************************************
5  * # License
6  * <b>Copyright 2019 Silicon Laboratories Inc. www.silabs.com</b>
7  *******************************************************************************
8  *
9  * SPDX-License-Identifier: Zlib
10  *
11  * The licensor of this software is Silicon Laboratories Inc.
12  *
13  * This software is provided 'as-is', without any express or implied
14  * warranty. In no event will the authors be held liable for any damages
15  * arising from the use of this software.
16  *
17  * Permission is granted to anyone to use this software for any purpose,
18  * including commercial applications, and to alter it and redistribute it
19  * freely, subject to the following restrictions:
20  *
21  * 1. The origin of this software must not be misrepresented; you must not
22  *    claim that you wrote the original software. If you use this software
23  *    in a product, an acknowledgment in the product documentation would be
24  *    appreciated but is not required.
25  * 2. Altered source versions must be plainly marked as such, and must not be
26  *    misrepresented as being the original software.
27  * 3. This notice may not be removed or altered from any source distribution.
28  *
29  ******************************************************************************/
30 
31 #ifndef SL_STDIO_H
32 #define SL_STDIO_H
33 
34 #include "sl_status.h"
35 #include <stddef.h>
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 /*******************************************************************************
42  * @addtogroup stdio Standard I/O
43  * @brief Standard I/O allows to get and put characters on stdio stream that is the default in I/O Streams.
44  * @{
45  ******************************************************************************/
46 
47 // -----------------------------------------------------------------------------
48 // Prototypes
49 
50 #ifndef DOXYGEN
51 int sl_putchar_std_wrapper(int c);
52 int sl_getchar_std_wrapper(void);
53 #endif
54 
55 /*******************************************************************************
56  * Put a character on the default stream.
57  *
58  * @param[in] c   Character to print
59  *
60  * @return  Status result
61  ******************************************************************************/
62 sl_status_t sl_putchar(char c);
63 
64 /*******************************************************************************
65  * Put a character on the default stream (match standard API).
66  *
67  * @param[in] c   Integer character to print
68  *
69  * @return  On success, the character written is returned.
70  *          If a writing error occurs, -1 is returned (EOF).
71  ******************************************************************************/
72 #define putchar  sl_putchar_std_wrapper
73 
74 /*******************************************************************************
75  * Get a character on the default stream.
76  *
77  * @param[out] c Pointer to variable that will receive the character.
78  *
79  * @return  Status result
80  ******************************************************************************/
81 sl_status_t sl_getchar(char *c);
82 
83 /*******************************************************************************
84  * Get a character on the default stream.
85  *
86  * @return  On success, the character read is returned
87  *          If a reading error occurs, -1 is returned (EOF).
88  ******************************************************************************/
89 #define getchar  sl_getchar_std_wrapper
90 
91 /** @} (end addtogroup stdio) */
92 
93 #ifdef __cplusplus
94 }
95 #endif
96 
97 #endif /* SL_STDIO_H */
98