1 /* 2 * Copyright (c) 2006-2018, RT-Thread Development Team 3 * 4 * SPDX-License-Identifier: Apache-2.0 5 * 6 * Change Logs: 7 * Date Author Notes 8 */ 9 #ifndef PIPE_H__ 10 #define PIPE_H__ 11 12 /** 13 * Pipe Device 14 */ 15 #include <rtthread.h> 16 #include <rtdevice.h> 17 18 #ifndef RT_PIPE_BUFSZ 19 #define PIPE_BUFSZ 512 20 #else 21 #define PIPE_BUFSZ RT_PIPE_BUFSZ 22 #endif 23 24 struct rt_pipe_device 25 { 26 struct rt_device parent; 27 28 /* ring buffer in pipe device */ 29 struct rt_ringbuffer *fifo; 30 rt_uint16_t bufsz; 31 32 rt_uint8_t readers; 33 rt_uint8_t writers; 34 35 rt_wqueue_t reader_queue; 36 rt_wqueue_t writer_queue; 37 38 struct rt_mutex lock; 39 }; 40 typedef struct rt_pipe_device rt_pipe_t; 41 42 rt_pipe_t *rt_pipe_create(const char *name, int bufsz); 43 int rt_pipe_delete(const char *name); 44 #endif /* PIPE_H__ */ 45