2017-10-15 22:56:46 +08:00
|
|
|
#ifndef PIPE_H__
|
|
|
|
#define PIPE_H__
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Pipe Device
|
|
|
|
*/
|
|
|
|
#include <rtthread.h>
|
|
|
|
#include <rtdevice.h>
|
|
|
|
|
|
|
|
#ifndef RT_PIPE_BUFSZ
|
|
|
|
#define PIPE_BUFSZ 512
|
|
|
|
#else
|
|
|
|
#define PIPE_BUFSZ RT_PIPE_BUFSZ
|
|
|
|
#endif
|
|
|
|
|
|
|
|
struct rt_pipe_device
|
|
|
|
{
|
2017-11-03 21:09:04 +08:00
|
|
|
struct rt_device parent;
|
2017-10-15 22:56:46 +08:00
|
|
|
|
2017-11-03 21:09:04 +08:00
|
|
|
/* ring buffer in pipe device */
|
|
|
|
struct rt_ringbuffer *fifo;
|
2017-12-29 22:33:39 +08:00
|
|
|
rt_uint16_t bufsz;
|
2017-10-15 22:56:46 +08:00
|
|
|
|
2017-11-03 21:09:04 +08:00
|
|
|
rt_uint8_t readers;
|
|
|
|
rt_uint8_t writers;
|
2017-10-15 22:56:46 +08:00
|
|
|
|
2017-11-03 21:09:04 +08:00
|
|
|
rt_wqueue_t reader_queue;
|
|
|
|
rt_wqueue_t writer_queue;
|
2017-10-15 22:56:46 +08:00
|
|
|
|
2017-11-03 21:09:04 +08:00
|
|
|
struct rt_mutex lock;
|
2017-10-15 22:56:46 +08:00
|
|
|
};
|
|
|
|
typedef struct rt_pipe_device rt_pipe_t;
|
|
|
|
|
2017-12-29 22:33:39 +08:00
|
|
|
rt_pipe_t *rt_pipe_create(const char *name, int bufsz);
|
2018-07-10 14:54:39 +08:00
|
|
|
int rt_pipe_delete(const char *name);
|
2017-11-03 21:09:04 +08:00
|
|
|
#endif /* PIPE_H__ */
|