Rock, Paper, Scissors game coordinator

Dependencies:   fsl_phy_mcr20a fsl_smac mbed-rtos mbed

Fork of mcr20_RPS_Coordinator by Freescale

Committer:
mnorman4
Date:
Tue Nov 17 17:14:10 2015 +0000
Revision:
0:9c8c234fd5ae
Initial commit of Rock, Paper, Scissors game coordinator

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mnorman4 0:9c8c234fd5ae 1 #ifndef __CIRCULAR_BUFFER_H__
mnorman4 0:9c8c234fd5ae 2 #define __CIRCULAR_BUFFER_H__
mnorman4 0:9c8c234fd5ae 3
mnorman4 0:9c8c234fd5ae 4 #include "EmbeddedTypes.h"
mnorman4 0:9c8c234fd5ae 5 #include "MemManager.h"
mnorman4 0:9c8c234fd5ae 6
mnorman4 0:9c8c234fd5ae 7 #ifndef gCircularBufferSize_c
mnorman4 0:9c8c234fd5ae 8 #define gCircularBufferSize_c 32
mnorman4 0:9c8c234fd5ae 9 #endif
mnorman4 0:9c8c234fd5ae 10
mnorman4 0:9c8c234fd5ae 11 typedef enum bufferStatus_tag
mnorman4 0:9c8c234fd5ae 12 {
mnorman4 0:9c8c234fd5ae 13 buffer_Ok_c = 0,
mnorman4 0:9c8c234fd5ae 14 buffer_Empty_c,
mnorman4 0:9c8c234fd5ae 15 buffer_Full_c
mnorman4 0:9c8c234fd5ae 16 }bufferStatus_t;
mnorman4 0:9c8c234fd5ae 17
mnorman4 0:9c8c234fd5ae 18 class CircularBuffer {
mnorman4 0:9c8c234fd5ae 19 public:
mnorman4 0:9c8c234fd5ae 20 CircularBuffer();
mnorman4 0:9c8c234fd5ae 21 CircularBuffer(uint32_t sz);
mnorman4 0:9c8c234fd5ae 22 ~CircularBuffer();
mnorman4 0:9c8c234fd5ae 23 bufferStatus_t addToBuffer (uint8_t c);
mnorman4 0:9c8c234fd5ae 24 bufferStatus_t getFromBuffer (uint8_t *c);
mnorman4 0:9c8c234fd5ae 25 uint32_t getCount();
mnorman4 0:9c8c234fd5ae 26 private:
mnorman4 0:9c8c234fd5ae 27 uint8_t *buffer;
mnorman4 0:9c8c234fd5ae 28 uint32_t size;
mnorman4 0:9c8c234fd5ae 29 uint32_t readIndex;
mnorman4 0:9c8c234fd5ae 30 uint32_t writeIndex;
mnorman4 0:9c8c234fd5ae 31 uint32_t count;
mnorman4 0:9c8c234fd5ae 32 };
mnorman4 0:9c8c234fd5ae 33
mnorman4 0:9c8c234fd5ae 34 #endif