pipe.h 631 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifndef PIPE_H__
  2. #define PIPE_H__
  3. /**
  4. * Pipe Device
  5. */
  6. #include <rtthread.h>
  7. #include <rtdevice.h>
  8. #if defined(RT_USING_POSIX)
  9. #ifndef RT_PIPE_BUFSZ
  10. #define PIPE_BUFSZ 512
  11. #else
  12. #define PIPE_BUFSZ RT_PIPE_BUFSZ
  13. #endif
  14. struct rt_pipe_device
  15. {
  16. struct rt_device parent;
  17. /* ring buffer in pipe device */
  18. struct rt_ringbuffer *fifo;
  19. rt_uint8_t readers;
  20. rt_uint8_t writers;
  21. rt_wqueue_t reader_queue;
  22. rt_wqueue_t writer_queue;
  23. struct rt_mutex lock;
  24. };
  25. typedef struct rt_pipe_device rt_pipe_t;
  26. rt_pipe_t *rt_pipe_create(const char *name);
  27. #endif /* RT_USING_POSIX */
  28. #endif /* PIPE_H__ */