Loading...
Searching...
No Matches
slipdev_internal.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2018 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
18
19#include <stddef.h>
20#include <stdint.h>
21
22#include "isrpipe.h"
23#include "periph/uart.h"
24#include "mutex.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
35#define SLIPDEV_END (0xc0U)
36#define SLIPDEV_ESC (0xdbU)
37#define SLIPDEV_END_ESC (0xdcU)
38#define SLIPDEV_ESC_ESC (0xddU)
39
45#define SLIPDEV_START_STDIO (0x0aU)
46
52#define SLIPDEV_START_COAP (0xa9U)
53
57#define SLIPDEV_START_NET(byte) ( \
58 /* is it an IPv4 packet? */ \
59 (byte >= 0x45 && byte <= 0x4f) || \
60 /* or is it an IPv6 packet? */ \
61 (byte >= 0x60 && byte <= 0x6f) \
62 )
63
64
69
75
82static inline void slipdev_write_byte(uart_t uart, uint8_t byte)
83{
84 uart_write(uart, &byte, 1U);
85}
86
94void slipdev_write_bytes(uart_t uart, const uint8_t *data, size_t len);
95
96#ifdef __cplusplus
97}
98#endif
99
uint_fast8_t uart_t
Define default UART type identifier.
Definition uart.h:112
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 Interface
Mutex for thread synchronization.
isrpipe_t slipdev_stdio_isrpipe
ISR pipe to hand read bytes to stdin.
mutex_t slipdev_mutex
Mutex to synchronize write operations to the UART between stdio sub-module and normal SLIP.
static void slipdev_write_byte(uart_t uart, uint8_t byte)
Writes one byte to UART.
void slipdev_write_bytes(uart_t uart, const uint8_t *data, size_t len)
Write multiple bytes SLIP-escaped to UART.
Context structure for isrpipe.
Definition isrpipe.h:36
Mutex structure.
Definition mutex.h:36
Low-level UART peripheral driver interface definition.