C++ refactoring (#91)

This commit is contained in:
Ken Van Hoeylandt
2024-11-26 17:51:05 +01:00
committed by GitHub
parent d06137ba76
commit ca5d4b8226
159 changed files with 904 additions and 1086 deletions
+38 -36
View File
@@ -3,48 +3,50 @@
#include "CoreTypes.h"
#include "Thread.h"
#ifdef ESP_PLATFORM
#include "freertos/FreeRTOS.h"
#include "freertos/semphr.h"
#else
#include "FreeRTOS.h"
#include "semphr.h"
#endif
namespace tt {
typedef void Semaphore;
/** Allocate semaphore
*
* @param[in] max_count The maximum count
* @param[in] initial_count The initial count
*
* @return pointer to Semaphore instance
/**
* Wrapper for xSemaphoreCreateBinary (max count == 1) and xSemaphoreCreateCounting (max count > 1)
* Can be used in IRQ mode (within ISR context)
*/
Semaphore* tt_semaphore_alloc(uint32_t max_count, uint32_t initial_count);
class Semaphore {
private:
SemaphoreHandle_t handle;
public:
/**
* @param[in] maxCount The maximum count
* @param[in] initialCount The initial count
*/
Semaphore(uint32_t maxCount, uint32_t initialCount);
/** Free semaphore
*
* @param instance The pointer to Semaphore instance
*/
void tt_semaphore_free(Semaphore* instance);
/**
* @param instance The pointer to Semaphore instance
*/
~Semaphore();
/** Acquire semaphore
*
* @param instance The pointer to Semaphore instance
* @param[in] timeout The timeout
*
* @return The status.
*/
TtStatus tt_semaphore_acquire(Semaphore* instance, uint32_t timeout);
/** Acquire semaphore
* @param[in] timeout The timeout
* @return the status
*/
TtStatus acquire(uint32_t timeout) const;
/** Release semaphore
*
* @param instance The pointer to Semaphore instance
*
* @return The status.
*/
TtStatus tt_semaphore_release(Semaphore* instance);
/** Release semaphore
* @return the status
*/
TtStatus release() const;
/** Get semaphore count
*
* @param instance The pointer to Semaphore instance
*
* @return Semaphore count
*/
uint32_t tt_semaphore_get_count(Semaphore* instance);
/** Get semaphore count
* @return semaphore count
*/
uint32_t getCount() const;
};
} // namespace