-
Notifications
You must be signed in to change notification settings - Fork 4
/
MessageBuffer.h
30 lines (25 loc) · 1.14 KB
/
MessageBuffer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef __MESSAGE_BUFFER_H__
#define __MESSAGE_BUFFER_H__
/* Includes: */
#include <LUFA/Drivers/Misc/RingBuffer.h>
/* Macros: */
#define KEY_STATE_BUFFER_SIZE 128
/* Type Defines: */
typedef struct {
RingBuffer_t RingBuffer;
uint8_t PreviousInsertByte;
uint8_t PreviousRemoveByte;
bool IsPreviousInsertByteEOM;
bool IsPreviousRemoveByteEOM;
uint8_t MessageCount;
} MessageBuffer_t;
/* Function Prototypes: */
void MessageBuffer_InitBuffer(MessageBuffer_t *MessageBuffer, uint8_t* const DataPtr, const uint16_t Size);
uint16_t MessageBuffer_GetCount(MessageBuffer_t *MessageBuffer);
uint16_t MessageBuffer_GetFreeCount(MessageBuffer_t *MessageBuffer);
bool MessageBuffer_IsEmpty(MessageBuffer_t *MessageBuffer);
bool MessageBuffer_IsFull(MessageBuffer_t *MessageBuffer);
void MessageBuffer_Insert(MessageBuffer_t *MessageBuffer, const uint8_t Data);
uint8_t MessageBuffer_Remove(MessageBuffer_t *MessageBuffer);
uint8_t MessageBuffer_Peek(MessageBuffer_t *MessageBuffer);
#endif