This program utilizes the mcr20 Thread Shield on the FRDM-K64F MCU which is a two-part workspace (HVAC Server (RX)/Probe(TX)) to handle low temperature events read at the probe(s) to prevent pipes from freezing.
Dependencies: fsl_phy_mcr20a fsl_smac mbed-rtos mbed
Fork of mcr20_wireless_uart by
circular_buffer.h@29:be24c0c29f17, 2017-03-30 (annotated)
- Committer:
- haircules
- Date:
- Thu Mar 30 20:22:35 2017 +0000
- Revision:
- 29:be24c0c29f17
- Parent:
- 27:1eb29717bfd9
SmartPipe HVAC Server
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
andreikovacs | 27:1eb29717bfd9 | 1 | #ifndef __CIRCULAR_BUFFER_H__ |
andreikovacs | 27:1eb29717bfd9 | 2 | #define __CIRCULAR_BUFFER_H__ |
andreikovacs | 27:1eb29717bfd9 | 3 | |
andreikovacs | 27:1eb29717bfd9 | 4 | #include "EmbeddedTypes.h" |
andreikovacs | 27:1eb29717bfd9 | 5 | #include "MemManager.h" |
andreikovacs | 27:1eb29717bfd9 | 6 | |
andreikovacs | 27:1eb29717bfd9 | 7 | #ifndef gCircularBufferSize_c |
andreikovacs | 27:1eb29717bfd9 | 8 | #define gCircularBufferSize_c 32 |
andreikovacs | 27:1eb29717bfd9 | 9 | #endif |
andreikovacs | 27:1eb29717bfd9 | 10 | |
andreikovacs | 27:1eb29717bfd9 | 11 | typedef enum bufferStatus_tag |
andreikovacs | 27:1eb29717bfd9 | 12 | { |
andreikovacs | 27:1eb29717bfd9 | 13 | buffer_Ok_c = 0, |
andreikovacs | 27:1eb29717bfd9 | 14 | buffer_Empty_c, |
andreikovacs | 27:1eb29717bfd9 | 15 | buffer_Full_c |
andreikovacs | 27:1eb29717bfd9 | 16 | }bufferStatus_t; |
andreikovacs | 27:1eb29717bfd9 | 17 | |
andreikovacs | 27:1eb29717bfd9 | 18 | class CircularBuffer { |
andreikovacs | 27:1eb29717bfd9 | 19 | public: |
andreikovacs | 27:1eb29717bfd9 | 20 | CircularBuffer(); |
andreikovacs | 27:1eb29717bfd9 | 21 | CircularBuffer(uint32_t sz); |
andreikovacs | 27:1eb29717bfd9 | 22 | ~CircularBuffer(); |
andreikovacs | 27:1eb29717bfd9 | 23 | bufferStatus_t addToBuffer (uint8_t c); |
andreikovacs | 27:1eb29717bfd9 | 24 | bufferStatus_t getFromBuffer (uint8_t *c); |
andreikovacs | 27:1eb29717bfd9 | 25 | uint32_t getCount(); |
andreikovacs | 27:1eb29717bfd9 | 26 | private: |
andreikovacs | 27:1eb29717bfd9 | 27 | uint8_t *buffer; |
andreikovacs | 27:1eb29717bfd9 | 28 | uint32_t size; |
andreikovacs | 27:1eb29717bfd9 | 29 | uint32_t readIndex; |
andreikovacs | 27:1eb29717bfd9 | 30 | uint32_t writeIndex; |
andreikovacs | 27:1eb29717bfd9 | 31 | uint32_t count; |
andreikovacs | 27:1eb29717bfd9 | 32 | }; |
andreikovacs | 27:1eb29717bfd9 | 33 | |
andreikovacs | 27:1eb29717bfd9 | 34 | #endif |