24 #ifndef _FNET_SERIAL_H_ 26 #define _FNET_SERIAL_H_ 49 #define FNET_ATTR_RESET 0 50 #define FNET_ATTR_BOLD 1 51 #define FNET_ATTR_BLINK 5 52 #define FNET_ATTR_UNDERLINE 4 53 #define FNET_ATTR_REVERSE 7 55 #define FNET_COLOR_BLACK 0 56 #define FNET_COLOR_RED 1 57 #define FNET_COLOR_GREEN 2 58 #define FNET_COLOR_YELLOW 3 59 #define FNET_COLOR_BLUE 4 60 #define FNET_COLOR_MAGENTA 5 61 #define FNET_COLOR_CYAN 6 62 #define FNET_COLOR_WHITE 7 65 #define FNET_SERIAL_ESC_FG_BLACK "\33[30m" 66 #define FNET_SERIAL_ESC_FG_RED "\33[31m" 67 #define FNET_SERIAL_ESC_FG_GREEN "\33[32m" 68 #define FNET_SERIAL_ESC_FG_YELLOW "\33[33m" 69 #define FNET_SERIAL_ESC_FG_BLUE "\33[34m" 70 #define FNET_SERIAL_ESC_FG_MAGENTA "\33[35m" 71 #define FNET_SERIAL_ESC_FG_CYAN "\33[36m" 72 #define FNET_SERIAL_ESC_FG_WHITE "\33[37m" 75 #define FNET_SERIAL_ESC_BG_BLACK "\33[40m" 76 #define FNET_SERIAL_ESC_BG_RED "\33[41m" 77 #define FNET_SERIAL_ESC_BG_GREEN "\33[42m" 78 #define FNET_SERIAL_ESC_BG_YELLOW "\33[43m" 79 #define FNET_SERIAL_ESC_BG_BLUE "\33[44m" 80 #define FNET_SERIAL_ESC_BG_MAGENTA "\33[45m" 81 #define FNET_SERIAL_ESC_BG_CYAN "\33[46m" 82 #define FNET_SERIAL_ESC_BG_WHITE "\33[47m" 85 #define FNET_SERIAL_ESC_ATTR_RESET "\33[0m" 86 #define FNET_SERIAL_ESC_ATTR_BOLD "\33[1m" 87 #define FNET_SERIAL_ESC_ATTR_UNDERLINE "\33[4m" 88 #define FNET_SERIAL_ESC_ATTR_BLINK "\33[5m" 89 #define FNET_SERIAL_ESC_ATTR_REVERSE "\33[7m" 143 #define FNET_SERIAL_STREAM_PORT0 ((fnet_serial_stream_t)(&fnet_serial_stream_port0)) 149 #define FNET_SERIAL_STREAM_PORT1 ((fnet_serial_stream_t)(&fnet_serial_stream_port1)) 155 #define FNET_SERIAL_STREAM_PORT2 ((fnet_serial_stream_t)(&fnet_serial_stream_port2)) 161 #define FNET_SERIAL_STREAM_PORT3 ((fnet_serial_stream_t)(&fnet_serial_stream_port3)) 167 #define FNET_SERIAL_STREAM_PORT4 ((fnet_serial_stream_t)(&fnet_serial_stream_port4)) 173 #define FNET_SERIAL_STREAM_PORT5 ((fnet_serial_stream_t)(&fnet_serial_stream_port5)) 182 #if (FNET_CFG_CPU_SERIAL_PORT_DEFAULT == 0u) 183 #define FNET_SERIAL_STREAM_DEFAULT FNET_SERIAL_STREAM_PORT0 184 #elif (FNET_CFG_CPU_SERIAL_PORT_DEFAULT == 1u) 185 #define FNET_SERIAL_STREAM_DEFAULT FNET_SERIAL_STREAM_PORT1 186 #elif (FNET_CFG_CPU_SERIAL_PORT_DEFAULT == 2u) 187 #define FNET_SERIAL_STREAM_DEFAULT FNET_SERIAL_STREAM_PORT2 188 #elif (FNET_CFG_CPU_SERIAL_PORT_DEFAULT == 3u) 189 #define FNET_SERIAL_STREAM_DEFAULT FNET_SERIAL_STREAM_PORT3 190 #elif (FNET_CFG_CPU_SERIAL_PORT_DEFAULT == 4u) 191 #define FNET_SERIAL_STREAM_DEFAULT FNET_SERIAL_STREAM_PORT4 192 #elif (FNET_CFG_CPU_SERIAL_PORT_DEFAULT == 5u) 193 #define FNET_SERIAL_STREAM_DEFAULT FNET_SERIAL_STREAM_PORT5 195 #error "The serial library defines only 6 ports." 198 #if defined(__cplusplus) 684 #if defined(__cplusplus) Stream control structure.
void fnet_putchar(fnet_char_t character)
Write character to the default stream.
fnet_size_t fnet_vprintf(const fnet_char_t *format, va_list arg)
Print formatted variable argument list to the default stream.
fnet_size_t fnet_serial_vprintf(fnet_serial_stream_t stream, const fnet_char_t *format, va_list arg)
Print formatted variable argument list to the stream.
void(* putchar)(fnet_index_t stream_id, fnet_char_t character)
Callback function used for writing the character to the stream.
fnet_size_t fnet_serial_printf(fnet_serial_stream_t stream, const fnet_char_t *format,...)
Print formatted text to the stream.
fnet_int32_t fnet_serial_getchar(fnet_serial_stream_t stream)
Read character from the stream.
const struct fnet_serial_stream * fnet_serial_stream_t
Serial stream descriptor.
void fnet_serial_putchar(fnet_serial_stream_t stream, fnet_char_t character)
Write character to the stream.
unsigned long fnet_size_t
Unsigned integer type representing the size in bytes.
fnet_int32_t(* getchar)(fnet_index_t stream_id)
Callback function used for reading a character from the stream.
fnet_size_t fnet_snprintf(fnet_char_t *str, fnet_size_t size, const fnet_char_t *format,...)
Print formatted text to the buffer. The length of the buffer is given, that prevents the buffer overf...
fnet_index_t id
The id parameter provides a way for a stream driver to identify a particular device. For example it can be used as serial port number or pointer to a stream private structure. This parameter is passed to fnet_serial_stream.putchar() and to fnet_serial_stream.getchar() as the first parameter.
fnet_int32_t fnet_getchar(void)
Read character from the default stream.
fnet_size_t fnet_println(const fnet_char_t *format,...)
Print formatted text to the default stream and terminates the printed text by the line separator stri...
unsigned int fnet_index_t
Unsigned integer type representing the index.
char fnet_char_t
Type representing the charecter.
fnet_size_t fnet_sprintf(fnet_char_t *str, const fnet_char_t *format,...)
Print formatted text to the buffer.
fnet_size_t fnet_printf(const fnet_char_t *format,...)
Print formatted text to the default stream.
void fnet_serial_flush(fnet_serial_stream_t stream)
Send data from the internal stream buffer to the stream client.
void(* flush)(fnet_index_t stream_id)
Callback function used for immediate data sending from internal stream buffer to the steam client...