123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475 |
- #include "queue.h"
- #include "user_interface.h"
- #include "osapi.h"
- #include "os_type.h"
- #include "mem.h"
- #include "proto.h"
- uint8_t *last_rb_p_r;
- uint8_t *last_rb_p_w;
- uint32_t last_fill_cnt;
- void ICACHE_FLASH_ATTR QUEUE_Init(QUEUE *queue, int bufferSize)
- {
- queue->buf = (uint8_t*)os_zalloc(bufferSize);
- RINGBUF_Init(&queue->rb, queue->buf, bufferSize);
- }
- int32_t ICACHE_FLASH_ATTR QUEUE_Puts(QUEUE *queue, uint8_t* buffer, uint16_t len)
- {
- uint32_t ret;
-
- last_rb_p_r = queue->rb.p_r;
- last_rb_p_w = queue->rb.p_w;
- last_fill_cnt = queue->rb.fill_cnt;
- ret = PROTO_AddRb(&queue->rb, buffer, len);
- if (ret == -1) {
-
- queue->rb.p_r = last_rb_p_r;
- queue->rb.p_w = last_rb_p_w;
- queue->rb.fill_cnt = last_fill_cnt;
- }
- return ret;
- }
- int32_t ICACHE_FLASH_ATTR QUEUE_Gets(QUEUE *queue, uint8_t* buffer, uint16_t* len, uint16_t maxLen)
- {
- return PROTO_ParseRb(&queue->rb, buffer, len, maxLen);
- }
- BOOL ICACHE_FLASH_ATTR QUEUE_IsEmpty(QUEUE *queue)
- {
- if (queue->rb.fill_cnt <= 0)
- return TRUE;
- return FALSE;
- }
|