Skip to content
datafifo.h 633 B
Newer Older
/*
 * 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
 */

natsfr's avatar
natsfr committed
#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 {
natsfr's avatar
natsfr committed
	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();
natsfr's avatar
natsfr committed
void init_fifo();

#endif /* DATAFIFO_H_ */