RTOS_MSPM0  1.1
ECE445M starter code
Files | Macros | Functions
FIFO

First in first out queue. More...

Files

file  RTOS_FIFO.h
 Provide functions for a first in first out queue.
 

Macros

#define TXFIFOSIZE   64
 TXFIFOSIZE the size of the transmit FIFO, which can hold 0 to TXFIFOSIZE-1 elements. The size must be a power of 2.
 
#define RXFIFOSIZE   16
 RXFIFOSIZE the size of the receive FIFO, which can hold 0 to RXFIFOSIZE-1 elements The size must be a power of 2.
 
#define AddIndexFifo(NAME, SIZE, TYPE, SUCCESS, FAIL)
 

Functions

void TxFifo_Init (void)
 Initialize FIFO. More...
 
int TxFifo_Put (char data)
 Put FIFO. More...
 
char TxFifo_Get (void)
 Get FIFO. More...
 
uint32_t TxFifo_Size (void)
 number of elements in FIFO More...
 
void RxFifo_Init (void)
 Initialize FIFO. More...
 
int RxFifo_Put (char data)
 Put FIFO. More...
 
char RxFifo_Get (void)
 Get FIFO. More...
 
uint32_t RxFifo_Size (void)
 number of elements in FIFO More...
 

Detailed Description

First in first out queue.

Macro Definition Documentation

◆ AddIndexFifo

#define AddIndexFifo (   NAME,
  SIZE,
  TYPE,
  SUCCESS,
  FAIL 
)
Value:
uint32_t volatile NAME ## PutI; \
uint32_t volatile NAME ## GetI; \
TYPE static NAME ## Fifo [SIZE]; \
void NAME ## Fifo_Init(void){ \
NAME ## PutI = NAME ## GetI = 0; \
} \
int NAME ## Fifo_Put (TYPE data){ \
if(( NAME ## PutI - NAME ## GetI ) & ~(SIZE-1)){ \
return(FAIL); \
} \
NAME ## Fifo[ NAME ## PutI &(SIZE-1)] = data; \
NAME ## PutI++; \
return(SUCCESS); \
} \
int NAME ## Fifo_Get (TYPE *datapt){ \
if( NAME ## PutI == NAME ## GetI ){ \
return(FAIL); \
} \
*datapt = NAME ## Fifo[ NAME ## GetI &(SIZE-1)]; \
NAME ## GetI++; \
return(SUCCESS); \
} \
unsigned short NAME ## Fifo_Size (void){\
return ((unsigned short)( NAME ## PutI - NAME ## GetI )); \
}

Function Documentation

◆ RxFifo_Get()

char RxFifo_Get ( void  )

Get FIFO.

Get character from the receive FIFO

Parameters
none
Returns
0 for fail because empty, nonzero is data
See also
RxFifo_Init() RxFifo_Put() RxFifo_Size()
Note
RXFIFOSIZE the size of the receive FIFO

◆ RxFifo_Init()

void RxFifo_Init ( void  )

Initialize FIFO.

Initialize the receive FIFO

Parameters
none
Returns
none
See also
RxFifo_Put() RxFifo_Get() RxFifo_Size()
Note
RXFIFOSIZE the size of the receive FIFO

◆ RxFifo_Put()

int RxFifo_Put ( char  data)

Put FIFO.

Put character into the receive FIFO

Parameters
datais a new character to save
Returns
0 for fail because full, 1 for success
See also
RxFifo_Init() RxFifo_Get() RxFifo_Size()
Note
RXFIFOSIZE the size of the receive FIFO

◆ RxFifo_Size()

uint32_t RxFifo_Size ( void  )

number of elements in FIFO

Determine how many elements are currently stored in the receive FIFO

Parameters
none
Returns
number of elements in FIFO
See also
RxFifo_Init() RxFifo_Put() RxFifo_Get()
Note
Does not change the FIFO

◆ TxFifo_Get()

char TxFifo_Get ( void  )

Get FIFO.

Get character from the transmit FIFO

Parameters
none
Returns
0 for fail because empty, nonzero is data
See also
TxFifo_Init() TxFifo_Put() TxFifo_Size()
Note
TXFIFOSIZE the size of the transmit FIFO

◆ TxFifo_Init()

void TxFifo_Init ( void  )

Initialize FIFO.

Initialize the transmit FIFO

Parameters
none
Returns
none
See also
TxFifo_Put() TxFifo_Get() TxFifo_Size()
Note
TXFIFOSIZE the size of the transmit FIFO

◆ TxFifo_Put()

int TxFifo_Put ( char  data)

Put FIFO.

Put character into the transmit FIFO

Parameters
datais a new character to save
Returns
0 for fail because full, 1 for success
See also
TxFifo_Init() TxFifo_Get() TxFifo_Size()
Note
TXFIFOSIZE the size of the transmit FIFO

◆ TxFifo_Size()

uint32_t TxFifo_Size ( void  )

number of elements in FIFO

Determine how many elements are currently stored in the transmit FIFO

Parameters
none
Returns
number of elements in FIFO
See also
TxFifo_Init() TxFifo_Put() TxFifo_Get()
Note
Does not change the FIFO