mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-06-10 01:55:59 +00:00
69 lines
1.3 KiB
C++
69 lines
1.3 KiB
C++
/**
|
|
* @file
|
|
* @brief RTOS MemPool implementation.
|
|
*/
|
|
#ifndef STA_RTOS_MEMPOOL_HPP
|
|
#define STA_RTOS_MEMPOOL_HPP
|
|
|
|
#include <cmsis_os2.h>
|
|
|
|
#include <cstdint>
|
|
|
|
/**
|
|
* @defgroup STA_RTOS_MEMPOOL MemPool
|
|
* @ingroup STA_RTOS_API
|
|
* @brief RTOS Memory Pool.
|
|
*/
|
|
|
|
namespace sta
|
|
{
|
|
/**
|
|
* @brief Interface object for using CMSIS RTOS2 MemPool.
|
|
*
|
|
* @tparam Message type
|
|
*
|
|
* @ingroup STA_RTOS_MEMPOOL
|
|
*/
|
|
template <typename T>
|
|
class RtosMemPool
|
|
{
|
|
public:
|
|
using Message = T; /**< Queue message type */
|
|
|
|
public:
|
|
// Default Constructor
|
|
RtosMemPool();
|
|
|
|
/**
|
|
* @brief Create a memory pool.
|
|
*
|
|
* @param block_count names the amount of blocks.
|
|
* @param block_size names the size of each block.
|
|
*/
|
|
RtosMemPool(uint32_t block_count, uint32_t block_size);
|
|
|
|
/**
|
|
* @brief Allocate a new Memory Block.
|
|
*
|
|
* @param timeout names the timeout in milliseconds.
|
|
*/
|
|
void * alloc(uint32_t timeout);
|
|
|
|
/**
|
|
* @brief Free a Memory Block.
|
|
*
|
|
* @param block names the block to free.
|
|
*/
|
|
void free(void *block);
|
|
|
|
private:
|
|
osMemoryPoolId_t handle_; /**< CMSIS RTOS2 queue handle */
|
|
};
|
|
} // namespace sta
|
|
|
|
|
|
#include <sta/rtos/mempool.tpp>
|
|
|
|
|
|
#endif // STA_RTOS_MEMPOOL_HPP
|