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