Add initializer and constructor functions for the packet buffer
This commit is contained in:
parent
4aa9598e00
commit
bc09a7e411
|
@ -1,3 +1,14 @@
|
|||
/*
|
||||
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/>.
|
||||
*/
|
||||
|
||||
#include "radio.h"
|
||||
#include "packet.h"
|
||||
|
@ -7,7 +18,15 @@
|
|||
size_t circular_next(size_t current, size_t max);
|
||||
|
||||
packet_buffer_t *packet_buffer_new() {
|
||||
return malloc(sizeof(packet_buffer_t));
|
||||
packet_buffer_t *buffer = malloc(sizeof(packet_buffer_t));
|
||||
packet_buffer_init(buffer);
|
||||
return buffer;
|
||||
}
|
||||
|
||||
void packet_buffer_init(packet_buffer_t *buffer) {
|
||||
buffer->count = 0;
|
||||
buffer->bottom = 0;
|
||||
buffer->top = 0;
|
||||
}
|
||||
|
||||
packet_t *packet_buffer_enqueue(packet_buffer_t *self, packet_buffer_status_e *status) {
|
||||
|
|
|
@ -1,9 +1,19 @@
|
|||
/*
|
||||
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"
|
||||
#include <stdlib.h>
|
||||
|
||||
typedef enum {
|
||||
packet_buffer_status_ok,
|
||||
|
@ -19,6 +29,7 @@ typedef struct {
|
|||
} packet_buffer_t;
|
||||
|
||||
packet_buffer_t *packet_buffer_new();
|
||||
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 *);
|
||||
|
|
Loading…
Reference in New Issue