slipdev_internal.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 Freie Universität Berlin
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
19 #ifndef SLIPDEV_INTERNAL_H
20 #define SLIPDEV_INTERNAL_H
21 
22 #include <stddef.h>
23 #include <stdint.h>
24 
25 #include "isrpipe.h"
26 #include "periph/uart.h"
27 #include "mutex.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
38 #define SLIPDEV_END (0xc0U)
39 #define SLIPDEV_ESC (0xdbU)
40 #define SLIPDEV_END_ESC (0xdcU)
41 #define SLIPDEV_ESC_ESC (0xddU)
42 
48 #define SLIPDEV_STDIO_START (0x0aU)
49 
55 
60 extern mutex_t slipdev_mutex;
61 
68 static inline void slipdev_write_byte(uart_t uart, uint8_t byte)
69 {
70  uart_write(uart, &byte, 1U);
71 }
72 
80 void slipdev_write_bytes(uart_t uart, const uint8_t *data, size_t len);
81 
97 unsigned slipdev_unstuff_readbyte(uint8_t *buf, uint8_t byte, bool *escaped);
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif /* SLIPDEV_INTERNAL_H */
104 
slipdev_unstuff_readbyte
unsigned slipdev_unstuff_readbyte(uint8_t *buf, uint8_t byte, bool *escaped)
Unstuffs a (SLIP-escaped) byte.
uart_t
unsigned int uart_t
Define default UART type identifier.
Definition: uart.h:76
uart.h
Low-level UART peripheral driver interface definition.
slipdev_mutex
mutex_t slipdev_mutex
Mutex to synchronize write operations to the UART between stdio sub-module and normal SLIP.
isrpipe.h
isrpipe Interface
mutex.h
Mutex for thread synchronization.
slipdev_stdio_isrpipe
isrpipe_t slipdev_stdio_isrpipe
ISR pipe to hand read bytes to stdin.
slipdev_write_byte
static void slipdev_write_byte(uart_t uart, uint8_t byte)
Writes one byte to UART.
Definition: slipdev_internal.h:68
slipdev_write_bytes
void slipdev_write_bytes(uart_t uart, const uint8_t *data, size_t len)
Write multiple bytes SLIP-escaped to UART.
uart_write
void uart_write(uart_t uart, const uint8_t *data, size_t len)
Write data from the given buffer to the specified UART device.
isrpipe_t
Context structure for isrpipe.
Definition: isrpipe.h:37
mutex_t
Mutex structure.
Definition: mutex.h:120