1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/include/net/gnrc/slip.h

94 lines
2.8 KiB
C
Raw Normal View History

2015-03-22 18:42:34 +01:00
/*
* Copyright (C) 2015 Martine Lenders <mlenders@inf.fu-berlin.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
/**
* @defgroup net_gnrc_slip SLIP
* @ingroup net_gnrc
2015-03-22 18:42:34 +01:00
* @brief Provides a SLIP interface over UART utilizing
* @ref driver_periph_uart.
* @see <a href="https://www.ietf.org/rfc/rfc1055">RFC 1055</a>
* @{
*
* @file
* @brief SLIP interface defintion
*
* @author Martine Lenders <mlenders@inf.fu-berlin.de>
* @author Hauke Petersen <hauke.petersen@fu-berlin.de>
*/
#ifndef GNRC_SLIP_H_
#define GNRC_SLIP_H_
2015-03-22 18:42:34 +01:00
#include <inttypes.h>
2015-08-10 02:41:08 +02:00
#include "net/gnrc.h"
2015-03-22 18:42:34 +01:00
#include "periph/uart.h"
#include "ringbuffer.h"
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief UART buffer size used for TX and RX buffers
*
* Reduce this value if your expected traffic does not include full IPv6 MTU
* sized packets
*/
#ifndef GNRC_SLIP_BUFSIZE
#define GNRC_SLIP_BUFSIZE (1500U)
2015-03-22 18:42:34 +01:00
#endif
/**
* @brief Device descriptor for SLIP devices
*/
typedef struct {
uart_t uart; /**< the UART interface */
2015-06-01 16:40:24 +02:00
ringbuffer_t in_buf; /**< RX buffer */
ringbuffer_t out_buf; /**< TX buffer */
char rx_mem[GNRC_SLIP_BUFSIZE]; /**< memory used by RX buffer */
char tx_mem[GNRC_SLIP_BUFSIZE]; /**< memory used by TX buffer */
2015-03-22 18:42:34 +01:00
uint32_t in_bytes; /**< the number of bytes received of a
* currently incoming packet */
uint16_t in_esc; /**< receiver is in escape mode */
kernel_pid_t slip_pid; /**< PID of the device thread */
} gnrc_slip_dev_t;
2015-03-22 18:42:34 +01:00
2015-05-09 17:55:15 +02:00
/**
* @brief auto_init struct holding SLIP initalization params
*/
typedef struct xbee_params {
uart_t uart; /**< UART interfaced the device is connected to */
uint32_t baudrate; /**< baudrate to use */
} gnrc_slip_params_t;
2015-05-09 17:55:15 +02:00
2015-03-22 18:42:34 +01:00
/**
* @brief Initializes a new @ref net_gnrc_slip control thread for UART device
2015-03-22 18:42:34 +01:00
* @p uart
*
* @param[in] dev un-initialized SLIP device descriptor
* @param[in] uart UART device to use
* @param[in] baudrate baudrate to use
* @param[in] stack stack memory to use for the SLIP devices thread
* @param[in] stack_size size of @p stack
* @param[in] priority priority for the newly created thread
*
* @return PID of SLIP thread on success
* @return -EFAULT, if slip thread could not be created
* @return -ENODEV, if gnrc_slip_dev_t::uart of @p dev was no valid UART
2015-03-22 18:42:34 +01:00
*/
kernel_pid_t gnrc_slip_init(gnrc_slip_dev_t *dev, uart_t uart, uint32_t baudrate,
char *stack, size_t stack_size, char priority);
2015-03-22 18:42:34 +01:00
#ifdef __cplusplus
}
#endif
#endif /* __SLIP_H_ */
/** @} */