Loading...
Searching...
No Matches
slipdev.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015-17 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
9#pragma once
10
29
49
63
64#include <stdint.h>
65
66#include "cib.h"
67#include "net/netdev.h"
68#include "periph/uart.h"
69#include "chunked_ringbuffer.h"
70#include "sched.h"
71
72#ifdef __cplusplus
73extern "C" {
74#endif
75
87#ifdef CONFIG_SLIPDEV_BUFSIZE_EXP
88#define CONFIG_SLIPDEV_BUFSIZE (1<<CONFIG_SLIPDEV_BUFSIZE_EXP)
89#endif
90
91#ifndef CONFIG_SLIPDEV_BUFSIZE
92#define CONFIG_SLIPDEV_BUFSIZE (2048U)
93#endif
95
101enum {
138};
140
144typedef struct {
146 uint32_t baudrate;
148
154typedef struct {
158 /* Written to from interrupts (with irq_disable */
159 /* to prevent any simultaneous writes), */
160 /* consumed exclusively in the network stack's */
161 /* loop at _isr. */
162
164
165#if IS_USED(MODULE_SLIPDEV_CONFIG)
166 chunk_ringbuf_t rb_config;
167 uint8_t rxmem_config[CONFIG_SLIPDEV_BUFSIZE];
168 kernel_pid_t coap_server_pid;
169#endif
174 uint8_t state;
175} slipdev_t;
176
185void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params, uint8_t index);
186
187#ifdef __cplusplus
188}
189#endif
190
Chunked Ringbuffer.
Circular integer buffer interface.
Definitions low-level network driver interface.
int16_t kernel_pid_t
Unique process identifier.
Definition sched.h:138
struct netdev netdev_t
Forward declaration for netdev struct.
Definition netdev.h:288
uint_fast8_t uart_t
Define default UART type identifier.
Definition uart.h:84
#define CONFIG_SLIPDEV_BUFSIZE
UART buffer size used for TX and RX buffers.
Definition slipdev.h:92
void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params, uint8_t index)
Setup a slipdev device state.
@ SLIPDEV_STATE_SLEEP
Device is in sleep mode.
Definition slipdev.h:137
@ SLIPDEV_STATE_NONE
Device is in no mode (currently did not receiving any data frame)
Definition slipdev.h:105
@ SLIPDEV_STATE_STDIN
Device writes received data to stdin.
Definition slipdev.h:117
@ SLIPDEV_STATE_NET
Device writes handles data as network device.
Definition slipdev.h:109
@ SLIPDEV_STATE_STANDBY
Device is in standby, will wake up when sending data.
Definition slipdev.h:133
@ SLIPDEV_STATE_CONFIG
Device writes received data as CoAP message.
Definition slipdev.h:125
@ SLIPDEV_STATE_NET_ESC
Device writes handles data as network device, next byte is escaped.
Definition slipdev.h:113
@ SLIPDEV_STATE_STDIN_ESC
Device writes received data to stdin, next byte is escaped.
Definition slipdev.h:121
@ SLIPDEV_STATE_CONFIG_ESC
Device writes received data as CoAP message, next byte is escaped.
Definition slipdev.h:129
Scheduler API definition.
A chunked ringbuffer.
Configuration parameters for a slipdev.
Definition slipdev.h:144
uint32_t baudrate
baudrate to use with slipdev_params_t::uart
Definition slipdev.h:146
uart_t uart
UART interface the device is connected to.
Definition slipdev.h:145
Device descriptor for slipdev.
Definition slipdev.h:154
slipdev_params_t config
configuration parameters
Definition slipdev.h:156
chunk_ringbuf_t rb
Ringbuffer to store received networking frames.
Definition slipdev.h:157
uint8_t state
Device state.
Definition slipdev.h:174
uint8_t rxmem[CONFIG_SLIPDEV_BUFSIZE]
memory used by RX buffer
Definition slipdev.h:163
netdev_t netdev
parent class
Definition slipdev.h:155
Low-level UART peripheral driver interface definition.