ex

Fork of mbed-os-example-mbed5-blinky by mbed-os-examples

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers shared_buffer.h Source File

shared_buffer.h

00001 #pragma once
00002 #include "rtos.h"
00003 
00004 class SharedBuffer
00005 {
00006 public:
00007     SharedBuffer(unsigned int size);
00008     ~SharedBuffer();
00009     unsigned int read(unsigned char out[], unsigned int size);
00010     unsigned int write(const unsigned char in[], unsigned int size);
00011     void wait();
00012 private:
00013       unsigned int m_nBufferSize;
00014     unsigned int m_nWriteOffset;
00015     unsigned int m_nDataSize;
00016     unsigned char *m_pBuffer;
00017     rtos::Semaphore sem_Read;
00018     rtos::Semaphore sem_Write;
00019 };