diff options
Diffstat (limited to 'src/FreeRTOS.h')
-rw-r--r-- | src/FreeRTOS.h | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/FreeRTOS.h b/src/FreeRTOS.h index edaa9df..43a3b8f 100644 --- a/src/FreeRTOS.h +++ b/src/FreeRTOS.h @@ -9,10 +9,12 @@ #define MAIN_FREERTOS_H_ #include <stdint.h> #include <string> +#include <pthread.h> -#include <freertos/FreeRTOS.h> // Include the base FreeRTOS definitions -#include <freertos/task.h> // Include the task definitions -#include <freertos/semphr.h> // Include the semaphore definitions +#include <freertos/FreeRTOS.h> // Include the base FreeRTOS definitions. +#include <freertos/task.h> // Include the task definitions. +#include <freertos/semphr.h> // Include the semaphore definitions. +#include <freertos/ringbuf.h> // Include the ringbuffer definitions. /** @@ -30,20 +32,39 @@ public: public: Semaphore(std::string owner = "<Unknown>"); ~Semaphore(); - void give(); - void giveFromISR(); - void give(uint32_t value); - void setName(std::string name); - void take(std::string owner="<Unknown>"); - void take(uint32_t timeoutMs, std::string owner="<Unknown>"); - uint32_t wait(std::string owner="<Unknown>"); + void give(); + void give(uint32_t value); + void giveFromISR(); + void setName(std::string name); + void take(std::string owner="<Unknown>"); + void take(uint32_t timeoutMs, std::string owner="<Unknown>"); std::string toString(); + uint32_t wait(std::string owner="<Unknown>"); + private: SemaphoreHandle_t m_semaphore; + pthread_mutex_t m_pthread_mutex; std::string m_name; std::string m_owner; uint32_t m_value; + bool m_usePthreads; }; }; + +/** + * @brief Ringbuffer. + */ +class Ringbuffer { +public: + Ringbuffer(size_t length, ringbuf_type_t type = RINGBUF_TYPE_NOSPLIT); + ~Ringbuffer(); + + void* receive(size_t* size, TickType_t wait = portMAX_DELAY); + void returnItem(void* item); + uint32_t send(void* data, size_t length, TickType_t wait = portMAX_DELAY); +private: + RingbufHandle_t m_handle; +}; + #endif /* MAIN_FREERTOS_H_ */ |