From 38d4bd0f6224583e555fb47391084d185a89ce44 Mon Sep 17 00:00:00 2001 From: Michael Jacobsen Date: Sun, 23 Aug 2015 10:21:42 +0200 Subject: [PATCH] Header files adjustment (MQTT changes split from original commit - @projectgus.) --- examples/cpp_01_tasks/main.cpp | 4 ++-- extras/cpp_support/include/mutex.hpp | 20 ++++++++++++++++++-- extras/cpp_support/include/queue.hpp | 7 ++----- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/examples/cpp_01_tasks/main.cpp b/examples/cpp_01_tasks/main.cpp index 219be74..1295327 100644 --- a/examples/cpp_01_tasks/main.cpp +++ b/examples/cpp_01_tasks/main.cpp @@ -95,9 +95,9 @@ esp_open_rtos::thread::queue_t MyQueue; */ extern "C" void user_init(void) { - sdk_uart_div_modify(0, UART_CLK_FREQ / 115200); + sdk_uart_div_modify(0, UART_CLK_FREQ / 115200); - MyQueue.create(10); + MyQueue.queue_create(10); task_1.queue = MyQueue; task_2.queue = MyQueue; diff --git a/extras/cpp_support/include/mutex.hpp b/extras/cpp_support/include/mutex.hpp index 714c585..aaf29db 100644 --- a/extras/cpp_support/include/mutex.hpp +++ b/extras/cpp_support/include/mutex.hpp @@ -46,14 +46,30 @@ public: */ inline mutex_t() { - mutex = xSemaphoreCreateMutex(); + mutex = 0; + } + /** + * + * @return + */ + inline int mutex_create() + { + mutex = xSemaphoreCreateMutex(); + + if(mutex == NULL) { + return -1; + } + else { + return 0; + } } /** * */ - inline ~mutex_t() + inline void mutex_destroy() { vQueueDelete(mutex); + mutex = 0; } /** * diff --git a/extras/cpp_support/include/queue.hpp b/extras/cpp_support/include/queue.hpp index a24f302..047ce29 100644 --- a/extras/cpp_support/include/queue.hpp +++ b/extras/cpp_support/include/queue.hpp @@ -56,7 +56,7 @@ public: * @param uxItemSize * @return */ - inline int create(unsigned portBASE_TYPE uxQueueLength) + inline int queue_create(unsigned portBASE_TYPE uxQueueLength) { queue = xQueueCreate(uxQueueLength, sizeof(Data)); @@ -69,11 +69,8 @@ public: } /** * - * @param data - * @param ms - * @return */ - inline void destroy() + inline void queue_destroy() { vQueueDelete(queue); queue = 0;