#ifndef __RKFIFO_H_
#define __RKFIFO_H_


#ifdef __cplusplus
 extern "C" {
#endif /* __cplusplus */

#include <stdint.h>


/* 返回值宏定义 */
#define	RKFIFO_ENOMEM		12	/* Out of Memory */
#define	RKFIFO_EINVAL		22	/* Invalid argument */
#define RKFIFO_ENOSPC		28	/* No space left on device */


typedef struct rkfifo
{
    uint32_t in;
    uint32_t out;
    uint32_t mask;
    uint32_t esize;
    void* data;
}rkfifo_t;


int rkfifo_init(rkfifo_t *fifo, void *buffer, uint32_t size, uint32_t esize);

unsigned int rkfifo_in(rkfifo_t *fifo, const void *buf, unsigned int len);

unsigned int rkfifo_out_peek(rkfifo_t *fifo, void *buf, unsigned int len);

unsigned int rkfifo_out(rkfifo_t *fifo, void *buf, unsigned int len);



#ifdef __cplusplus
}
#endif /* __cplusplus */


#endif
