Files
TencentOS-tiny/components/connectivity/LoraWAN/system/fifo.h
supowang edb2879617 first commit for opensource
first commit for opensource
2019-09-16 13:19:50 +08:00

89 lines
1.9 KiB
C

/*!
* \file fifo.h
*
* \brief FIFO buffer implementation
*
* \copyright Revised BSD License, see section \ref LICENSE.
*
* \code
* ______ _
* / _____) _ | |
* ( (____ _____ ____ _| |_ _____ ____| |__
* \____ \| ___ | (_ _) ___ |/ ___) _ \
* _____) ) ____| | | || |_| ____( (___| | | |
* (______/|_____)_|_|_| \__)_____)\____)_| |_|
* (C)2013-2017 Semtech
*
* \endcode
*
* \author Miguel Luis ( Semtech )
*
* \author Gregory Cristian ( Semtech )
*/
#ifndef __FIFO_H__
#define __FIFO_H__
#include <stdbool.h>
#include <stdint.h>
/*!
* FIFO structure
*/
typedef struct Fifo_s
{
uint16_t Begin;
uint16_t End;
uint8_t *Data;
uint16_t Size;
}Fifo_t;
/*!
* Initializes the FIFO structure
*
* \param [IN] fifo Pointer to the FIFO object
* \param [IN] buffer Buffer to be used as FIFO
* \param [IN] size Size of the buffer
*/
void FifoInit( Fifo_t *fifo, uint8_t *buffer, uint16_t size );
/*!
* Pushes data to the FIFO
*
* \param [IN] fifo Pointer to the FIFO object
* \param [IN] data Data to be pushed into the FIFO
*/
void FifoPush( Fifo_t *fifo, uint8_t data );
/*!
* Pops data from the FIFO
*
* \param [IN] fifo Pointer to the FIFO object
* \retval data Data popped from the FIFO
*/
uint8_t FifoPop( Fifo_t *fifo );
/*!
* Flushes the FIFO
*
* \param [IN] fifo Pointer to the FIFO object
*/
void FifoFlush( Fifo_t *fifo );
/*!
* Checks if the FIFO is empty
*
* \param [IN] fifo Pointer to the FIFO object
* \retval isEmpty true: FIFO is empty, false FIFO is not empty
*/
bool IsFifoEmpty( Fifo_t *fifo );
/*!
* Checks if the FIFO is full
*
* \param [IN] fifo Pointer to the FIFO object
* \retval isFull true: FIFO is full, false FIFO is not full
*/
bool IsFifoFull( Fifo_t *fifo );
#endif // __FIFO_H__