Loading...
Searching...
No Matches
slipdev.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2015-2017 Freie Universität Berlin
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
26
46
60
61#include <stdint.h>
62
63#include "cib.h"
64#include "net/netdev.h"
65#include "periph/uart.h"
66#include "chunked_ringbuffer.h"
67#include "sched.h"
68
69#ifdef __cplusplus
70extern "C" {
71#endif
72
84#ifdef CONFIG_SLIPDEV_BUFSIZE_EXP
85#define CONFIG_SLIPDEV_BUFSIZE (1 << CONFIG_SLIPDEV_BUFSIZE_EXP)
86#endif
87
88#ifndef CONFIG_SLIPDEV_BUFSIZE
89#define CONFIG_SLIPDEV_BUFSIZE (2048U)
90#endif
92
147
151typedef struct {
153 uint32_t baudrate;
155
161typedef struct {
162#if IS_USED(MODULE_SLIPDEV_NET)
164 chunk_ringbuf_t rb;
165 /* Written to from interrupts (with irq_disable */
166 /* to prevent any simultaneous writes), */
167 /* consumed exclusively in the network stack's */
168 /* loop at _isr. */
169
170 uint8_t rxmem[CONFIG_SLIPDEV_BUFSIZE];
171#endif
172
173#if IS_USED(MODULE_SLIPDEV_CONFIG)
174 chunk_ringbuf_t rb_config;
175 uint8_t rxmem_config[CONFIG_SLIPDEV_BUFSIZE];
176 kernel_pid_t coap_server_pid;
177#endif
178
185} slipdev_t;
186
195void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params, uint8_t index);
196
197#ifdef __cplusplus
198}
199#endif
200
Chunked Ringbuffer.
Circular integer buffer interface.
Definitions low-level network driver interface.
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:134
struct netdev netdev_t
Forward declaration for netdev struct.
Definition netdev.h:285
uint_fast8_t uart_t
Define default UART type identifier.
Definition uart.h:109
#define CONFIG_SLIPDEV_BUFSIZE
UART buffer size used for TX and RX buffers.
Definition slipdev.h:89
void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params, uint8_t index)
Setup a slipdev device state.
slipdev_state_t
States for the slipdev and its parser.
Definition slipdev.h:96
@ SLIPDEV_STATE_SLEEP
Device is in sleep mode.
Definition slipdev.h:145
@ SLIPDEV_STATE_UNKNOWN
Device discards incoming data.
Definition slipdev.h:113
@ SLIPDEV_STATE_NONE
Device is in no mode (currently not receiving any frame), this is the idle state.
Definition slipdev.h:106
@ SLIPDEV_STATE_STDIN
Device writes received data to stdin.
Definition slipdev.h:125
@ SLIPDEV_STATE_NET
Device writes handles data as network device.
Definition slipdev.h:117
@ SLIPDEV_STATE_STANDBY
Device is in standby, will wake up when sending data.
Definition slipdev.h:141
@ SLIPDEV_STATE_CONFIG
Device writes received data as CoAP message.
Definition slipdev.h:133
@ SLIPDEV_STATE_NET_ESC
Device writes handles data as network device, next byte is escaped.
Definition slipdev.h:121
@ SLIPDEV_STATE_STDIN_ESC
Device writes received data to stdin, next byte is escaped.
Definition slipdev.h:129
@ SLIPDEV_STATE_CONFIG_ESC
Device writes received data as CoAP message, next byte is escaped.
Definition slipdev.h:137
A chunked ringbuffer.
Structure to hold driver state.
Definition netdev.h:362
Configuration parameters for a slipdev.
Definition slipdev.h:151
uint32_t baudrate
baudrate to use with slipdev_params_t::uart
Definition slipdev.h:153
uart_t uart
UART interface the device is connected to.
Definition slipdev.h:152
Device descriptor for slipdev.
Definition slipdev.h:161
slipdev_params_t config
configuration parameters
Definition slipdev.h:179
slipdev_state_t state
Device state.
Definition slipdev.h:184
Low-level UART peripheral driver interface definition.