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
36#ifndef SLIPDEV_H
37#define SLIPDEV_H
38
39#include <stdint.h>
40
41#include "cib.h"
42#include "net/netdev.h"
43#include "periph/uart.h"
44#include "chunked_ringbuffer.h"
45
46#ifdef __cplusplus
47extern "C" {
48#endif
49
61#ifdef CONFIG_SLIPDEV_BUFSIZE_EXP
62#define CONFIG_SLIPDEV_BUFSIZE (1<<CONFIG_SLIPDEV_BUFSIZE_EXP)
63#endif
64
65#ifndef CONFIG_SLIPDEV_BUFSIZE
66#define CONFIG_SLIPDEV_BUFSIZE (2048U)
67#endif
75enum {
104};
110typedef struct {
112 uint32_t baudrate;
114
120typedef struct {
124 /* Written to from interrupts (with irq_disable */
125 /* to prevent any simultaneous writes), */
126 /* consumed exclusively in the network stack's */
127 /* loop at _isr. */
128
129 uint8_t rxmem[CONFIG_SLIPDEV_BUFSIZE];
134 uint8_t state;
135} slipdev_t;
136
145void slipdev_setup(slipdev_t *dev, const slipdev_params_t *params, uint8_t index);
146
147#ifdef __cplusplus
148}
149#endif
150
151#endif /* SLIPDEV_H */
Chunked Ringbuffer.
Circular integer buffer interface.
Definitions low-level network driver interface.
Low-level UART peripheral driver interface definition.
uint_fast8_t uart_t
Define default UART type identifier.
Definition uart.h:85
#define CONFIG_SLIPDEV_BUFSIZE
UART buffer size used for TX and RX buffers.
Definition slipdev.h:66
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:103
@ SLIPDEV_STATE_NONE
Device is in no mode (currently did not receiving any data frame)
Definition slipdev.h:79
@ SLIPDEV_STATE_STDIN
Device writes received data to stdin.
Definition slipdev.h:91
@ SLIPDEV_STATE_NET
Device writes handles data as network device.
Definition slipdev.h:83
@ SLIPDEV_STATE_STANDBY
Device is in standby, will wake up when sending data.
Definition slipdev.h:99
@ SLIPDEV_STATE_NET_ESC
Device writes handles data as network device, next byte is escaped.
Definition slipdev.h:87
@ SLIPDEV_STATE_STDIN_ESC
Device writes received data to stdin, next byte is escaped.
Definition slipdev.h:95
A chunked ringbuffer.
Structure to hold driver state.
Definition netdev.h:363
Configuration parameters for a slipdev.
Definition slipdev.h:110
uint32_t baudrate
baudrate to use with slipdev_params_t::uart
Definition slipdev.h:112
uart_t uart
UART interface the device is connected to.
Definition slipdev.h:111
Device descriptor for slipdev.
Definition slipdev.h:120
slipdev_params_t config
configuration parameters
Definition slipdev.h:122
chunk_ringbuf_t rb
Ringbuffer to store received frames.
Definition slipdev.h:123
uint8_t state
Device state.
Definition slipdev.h:134
netdev_t netdev
parent class
Definition slipdev.h:121