/*
 * datafifo.h
 *
 *  Created on: 1 Jul 2018
 *      Author: nats
 */

#ifndef DATAFIFO_H_
#define DATAFIFO_H_

#include <stdint.h>

/* Maximum expected size is 255 elements
 * For optimisation use power of two size
 */

#define FIFOSIZE 		64
#define FIFOMASK 		FIFOSIZE-1
#define FIFOSHIFT 		6
#define PACKETSIZE		48

#define READY 			0
#define FULL 			1
#define EMPTY			2
#define FIFOERROR		3
#define FIFOOK			4

typedef struct packet {
	uint8_t byte[PACKETSIZE+1];
} packet;

uint8_t add_packet(packet *p);
uint8_t read_packet(packet *p);
uint8_t check_full();
uint8_t check_empty();
void init_fifo();

#endif /* DATAFIFO_H_ */
