Safe Sprinkler
Master/slave irrigation system (ESP-NOW + LoRaWAN)
Loading...
Searching...
No Matches
fifo.h
Go to the documentation of this file.
1#ifndef FIFO
2#define FIFO
3#include <stdbool.h>
4#include <stdint.h>
5#include <string.h>
6
7#define FIFO_SIZE 128
8
9typedef struct
10{
11 uint8_t buffer[FIFO_SIZE];
12 uint16_t head;
13 uint16_t tail;
14 uint16_t used;
15} fifo_t;
16
23
33bool fifo_write(fifo_t* f, const void* data, uint16_t len);
34
44bool fifo_read(fifo_t* f, void* data, uint16_t len);
45
46#endif // FIFO
void fifo_init(fifo_t *f)
Initialize a FIFO to empty state.
#define FIFO_SIZE
Definition fifo.h:7
bool fifo_write(fifo_t *f, const void *data, uint16_t len)
Write bytes into the FIFO.
bool fifo_read(fifo_t *f, void *data, uint16_t len)
Read bytes from the FIFO.
Definition fifo.h:10
uint16_t head
Definition fifo.h:12
uint16_t tail
Definition fifo.h:13
uint16_t used
Definition fifo.h:14