hal_queue.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef SUNXI_HAL_MAILBOX_H
  2. #define SUNXI_HAL_MAILBOX_H
  3. #ifdef __cplusplus
  4. extern "C"
  5. {
  6. #endif
  7. #include <stddef.h>
  8. #include <stdint.h>
  9. #ifdef CONFIG_KERNEL_FREERTOS
  10. #include <FreeRTOS.h>
  11. #include <queue.h>
  12. typedef QueueHandle_t hal_mailbox_t;
  13. typedef QueueHandle_t hal_queue_t;
  14. #else
  15. #include <rtthread.h>
  16. #include <rtdevice.h>
  17. // #include <workqueue.h>
  18. typedef rt_mailbox_t hal_mailbox_t;
  19. typedef rt_mq_t hal_queue_t;
  20. typedef struct rt_workqueue hal_workqueue;
  21. typedef struct rt_work hal_work;
  22. #define hal_work_init rt_work_init
  23. hal_workqueue *hal_workqueue_create(const char *name, unsigned short stack_size, unsigned char priority);
  24. int hal_workqueue_dowork(hal_workqueue *queue, hal_work *work);
  25. #endif
  26. enum IPC_MAILBOX_CMD
  27. {
  28. IPC_MAILBOX_CMD_GET_STATE,
  29. IPC_MAILBOX_CMD_NUMS,
  30. };
  31. hal_mailbox_t hal_mailbox_create(const char *name, unsigned int size);
  32. int hal_mailbox_delete(hal_mailbox_t mailbox);
  33. int hal_mailbox_send(hal_mailbox_t mailbox, unsigned int value);
  34. int hal_mailbox_send_wait(hal_mailbox_t mailbox, unsigned int value, int timeout);
  35. int hal_mailbox_recv(hal_mailbox_t mailbox, unsigned int *value, int timeout);
  36. int hal_is_mailbox_empty(hal_mailbox_t mailbox);
  37. hal_queue_t hal_queue_create(const char *name, unsigned int item_size, unsigned int queue_size);
  38. int hal_queue_delete(hal_queue_t queue);
  39. int hal_queue_send(hal_queue_t queue, void *buffer);
  40. int hal_queue_send_wait(hal_queue_t queue, void *buffer, int timeout);
  41. int hal_queue_recv(hal_queue_t queue, void *buffer, int timeout);
  42. int hal_is_queue_empty(hal_queue_t queue);
  43. #ifdef __cplusplus
  44. }
  45. #endif
  46. #endif