You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

46 lines
782 B

#ifndef __FIFO_H___
#define __FIFO_H___
#ifdef __cplusplus
extern "C" {
#endif
struct fifo {
unsigned char *buffer;
unsigned int size;
volatile unsigned int in;
volatile unsigned int out;
};
typedef struct fifo * fifo_t;
/*
* initialize fifo with `buf', len MUST be 2'n
*/
int fifo_init(fifo_t fifo, void *buf, unsigned int len);
/*
* put data to buffer
*/
unsigned int fifo_put(fifo_t fifo, const unsigned char *buffer, unsigned int len);
unsigned int fifo_get(fifo_t fifo, unsigned char *buffer, unsigned int len);
/*
* drop all data in the fifo.
*/
void fifo_reset(fifo_t fifo);
/*
* get data size in the fifo
*/
unsigned int fifo_len(fifo_t fifo);
/*
* get fifo's empty space.
*/
unsigned int fifo_empty(fifo_t fifo);
#ifdef __cplusplus
}
#endif
#endif