不含stm32 底层的代码
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.
MyStm32Code/libraries/kfifo.h

40 lines
1.2 KiB

2 years ago
#ifndef __KFIFO_H
#define __KFIFO_H
#include "stdint.h"
// #include "stm32f407xx.h"
// #include "main.h"
// #include "base.h"
#ifndef min
#define min(x,y) ((x) < (y) ? x : y)
#endif
typedef struct _kfifo {
uint8_t *buffer; /* the buffer holding the data */
uint16_t size; /* the size of the allocated buffer */
uint16_t in; /* data is added at offset (in % size) */
uint16_t out; /* data is extracted from off. (out % size) */
}kfifo_t;
static inline unsigned int __kfifo_len(kfifo_t *fifo)
{
return fifo->in - fifo->out;
}
// extern kfifo_t recvfifo;
// extern uint8_t USART_Receive_Buf[64];
extern void kfifo_init(kfifo_t *fifo, uint8_t *pFifoBuffer, uint16_t fifoSize);
extern uint16_t __kfifo_put(kfifo_t *fifo, uint8_t *buffer, uint16_t len);
extern void __kfifo_put_singlebyte(kfifo_t *fifo, uint8_t data);
extern uint16_t __kfifo_get(kfifo_t *fifo, uint8_t *buffer, uint16_t len);
// extern uint16_t __kfifo_put(kfifo_t *fifo, uint8_t *buffer, uint16_t len);
// extern void __kfifo_put_singlebyte(kfifo_t *fifo, uint8_t data);
// extern uint16_t __kfifo_get(kfifo_t *fifo, uint8_t *buffer, uint16_t len);
#endif