pipe.h 645 B

123456789101112131415161718192021222324252627282930313233343536
  1. #ifndef PIPE_H__
  2. #define PIPE_H__
  3. /**
  4. * Pipe Device
  5. */
  6. #include <rtthread.h>
  7. #include <rtdevice.h>
  8. #ifndef RT_PIPE_BUFSZ
  9. #define PIPE_BUFSZ 512
  10. #else
  11. #define PIPE_BUFSZ RT_PIPE_BUFSZ
  12. #endif
  13. struct rt_pipe_device
  14. {
  15. struct rt_device parent;
  16. /* ring buffer in pipe device */
  17. struct rt_ringbuffer *fifo;
  18. rt_uint16_t bufsz;
  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, int bufsz);
  27. int rt_pipe_delete(const char *name);
  28. #endif /* PIPE_H__ */