GlobLib
HAL and API libraries for MCUs and hardware.
fifo8.h
Go to the documentation of this file.
1 
36 #ifndef FIFO8_H
37 #define FIFO8_H
38 
39 #include <stdio.h>
40 
45 typedef enum{
46 
51 
56 typedef enum{
57 
64 
75 typedef struct{
76 
77  uint8_t *buffer;
78  uint16_t head;
79  uint16_t tail;
80  uint16_t mask;
81  uint8_t idle;
83  void (*out)(uint8_t byte);
84 }FIFO8;
85 
97 fifo8_error_t FIFO8_init(FIFO8 *target, fifo8_mode_t mode, uint8_t *buffer, uint16_t size, void (*output)(uint8_t byte));
106 fifo8_error_t FIFO8_put(FIFO8 *target, uint8_t byte);
113 fifo8_error_t FIFO8_get(FIFO8 *target);
120 uint16_t FIFO8_size(FIFO8 *target);
128 
133 uint8_t FIFO8_pop(FIFO8 *target);
134 
137 #endif
uint8_t idle
Used to determine if the FIFO8 is already outputing bytes.
Definition: fifo8.h:81
Fifo contents flushed to output function ASAP.
Definition: fifo8.h:47
fifo8_error_t FIFO8_get(FIFO8 *target)
Takes a character from the buffer.
Definition: fifo8.c:45
fifo8_error_t
Error codes returned by function calls.
Definition: fifo8.h:56
uint16_t mask
Bit mask used for FIFO8 buffer memory wrapping.
Definition: fifo8.h:80
The FIFO mode doesn&#39;t exist.
Definition: fifo8.h:59
The FIFO buffer is empty.
Definition: fifo8.h:62
The FIFO buffer is full.
Definition: fifo8.h:61
uint16_t FIFO8_size(FIFO8 *target)
Return the size in bytes of the FIFO8 buffer.
Definition: fifo8.c:90
fifo8_error_t FIFO8_put(FIFO8 *target, uint8_t byte)
Adds a character to the buffer.
Definition: fifo8.c:20
uint8_t FIFO8_pop(FIFO8 *target)
Reset the fifo buffer and set its size to 0.
Definition: fifo8.c:108
fifo8_error_t FIFO8_init(FIFO8 *target, fifo8_mode_t mode, uint8_t *buffer, uint16_t size, void(*output)(uint8_t byte))
Initializes the FIFO8 buffer.
Definition: fifo8.c:64
Fifo contents flushed to output function when buffer is full.
Definition: fifo8.h:49
fifo8_error_t FIFO8_flush(FIFO8 *target)
Flush all contents of the FIFO8 to the output function.
Definition: fifo8.c:95
fifo8_mode_t mode
The FIFO8 mode of operation.
Definition: fifo8.h:82
No error.
Definition: fifo8.h:58
fifo8_mode_t
Operating modes for the buffer.
Definition: fifo8.h:45
uint8_t * buffer
Pointer to the FIFO8 memory buffer.
Definition: fifo8.h:77
Fifo content flushed to output function on call FIFO_flush()
Definition: fifo8.h:48
uint16_t tail
The current read position in the FIFO8 memory buffer.
Definition: fifo8.h:79
Data structure for FIFO8 perihperal interface.
Definition: fifo8.h:75
uint16_t head
The current write position in the FIFO8 memory buffer.
Definition: fifo8.h:78
The size of the FIFO buffer is not a power of 2.
Definition: fifo8.h:60