1

Topic: Queue in With as in FreeRTOS.

I want to make that that like

check_sendToqueue = FRTOS1_xQueueSendToBack (Global_Queue_Handle, &lf_rec_buff, 0);
check_queue = FRTOS1_xQueueReceive (Global_Queue_Handle, &lt_rec_buff, 0);

Also that that I was tangled

#define QUEU_ELEMENT_COUNT 4
#define QUEU_ELEMENT_SIZE 64
typedef struct
{
uint8_t idx;
uint8_t capacity;
uint8_t new_element;
uint8_t size;
uint8_t queue_array [QUEU_ELEMENT_COUNT] [QUEU_ELEMENT_SIZE];
}S_QUEUE;
int QUEUE_Push (S_QUEUE* queue, uint8_t *item)
{
if ((queue-> size)> = queue-> capacity)
{
queue-> new_element = 0;
return QUEUE_FULL;
}
memcpy (&queue->queue_array [queue-> idx] [0], item, sizeof (item));
queue-> new_element = 1;
queue-> size ++;
queue-> idx ++;
return QUEUE_OK;
}
int QUEUE_Pop (S_QUEUE* queue, uint8_t *item)
{
if (queue-> size> 0)
{
memcpy (item, &queue->queue_array [queue-> idx] [0], sizeof (item));
queue-> size-;
queue-> idx-;
return QUEUE_NEW;
}
else
return QUEUE_OK;
}

But so principle FIFO is not observed. Or I am not right?

2

Re: Queue in With as in FreeRTOS.

jenya7;
It at you a stack.
To make FIFO use the ring buffer.
At you already all almost is, only instead of one idx use 2 pointers: write_idx and read_idx.
At a read and write in queue  . The pointer, and at achievement of edge of an array turn in 0.
PS. Well and here to replace uint8_t on size_t

uint8_t idx;
uint8_t capacity;
uint8_t size;

And that one awkward driving also will be overflow uint8

3

Re: Queue in With as in FreeRTOS.

Anatoly Moskovsky wrote:

jenya7;
It at you a stack.
To make FIFO use the ring buffer.
At you already all almost is, only instead of one idx use 2 pointers: write_idx and read_idx.
At a read and write in queue  . The pointer, and at achievement of edge of an array turn in 0.
PS. Well and here to replace uint8_t on size_t

uint8_t idx;
uint8_t capacity;
uint8_t size;

And that one awkward driving also will be overflow uint8

Thanks.