42 lines
1.5 KiB
C
42 lines
1.5 KiB
C
/*
|
|
Copyright 2022, Savanni D'Gerinel <savanni@luminescent-dreams.com>
|
|
|
|
This file is part of Savanni's AVR library.
|
|
|
|
This AVR library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
|
|
|
This AVR library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License along with this AVR library. If not, see <https://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef __PACKET_BUFFER_H__
|
|
#define __PACKET_BUFFER_H__
|
|
|
|
#include "packet.h"
|
|
|
|
typedef enum {
|
|
packet_buffer_status_ok,
|
|
packet_buffer_status_empty,
|
|
packet_buffer_status_full,
|
|
} packet_buffer_status_e;
|
|
|
|
typedef struct {
|
|
size_t count;
|
|
size_t bottom;
|
|
size_t top;
|
|
packet_t buffer[5];
|
|
} packet_buffer_t;
|
|
|
|
packet_buffer_t *packet_buffer_new(void);
|
|
void packet_buffer_init(packet_buffer_t *);
|
|
|
|
packet_t * packet_buffer_enqueue(packet_buffer_t *, packet_buffer_status_e *);
|
|
packet_t * packet_buffer_head(packet_buffer_t *, packet_buffer_status_e *);
|
|
void packet_buffer_dequeue(packet_buffer_t *, packet_buffer_status_e *);
|
|
|
|
bool packet_buffer_is_full(packet_buffer_t *);
|
|
bool packet_buffer_is_empty(packet_buffer_t *);
|
|
|
|
#endif
|