diff options
Diffstat (limited to 'yocto/esp32d/msgq.h')
-rw-r--r-- | yocto/esp32d/msgq.h | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/yocto/esp32d/msgq.h b/yocto/esp32d/msgq.h new file mode 100644 index 0000000..32b20d0 --- /dev/null +++ b/yocto/esp32d/msgq.h @@ -0,0 +1,22 @@ +#include <stdint.h> + +#define MSGQ_OK 0 +#define MSGQ_ERR -1 + +#define MSGQ_ERR_SIZE -10 +#define MSGQ_ERR_FULL -11 +#define MSGQ_ERR_EMPTY -12 + +typedef struct MSGQueue { + uint16_t idx_r; + uint16_t idx_w; + uint16_t size; + unsigned char **array; + pthread_mutex_t mutex; + pthread_cond_t cond; +} MSGQueue; + +int msgq_init(MSGQueue *msgq, unsigned char **array, uint16_t size); +int msgq_push(MSGQueue *msgq, unsigned char *buffer); +unsigned char *msgq_pop(MSGQueue *msgq); +uint16_t msgq_len(MSGQueue *msgq); |