mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-06-10 01:55:59 +00:00
SharedMemFixes
This commit is contained in:
parent
6f64a06164
commit
3e28326798
@ -20,7 +20,7 @@ namespace sta
|
||||
* @ingroup STA_RTOS_API
|
||||
*/
|
||||
template <typename T>
|
||||
class RtosMemPool
|
||||
class RtosSharedMem
|
||||
{
|
||||
public:
|
||||
using Message = T; /**< message type */
|
||||
@ -32,10 +32,9 @@ namespace sta
|
||||
/**
|
||||
* @brief Create a memory pool. And allocates exavlty one block.
|
||||
*
|
||||
* @param block_size names the size of each block.
|
||||
* @param timeout names the timeout in milliseconds.
|
||||
*/
|
||||
RtosSharedMem(uint32_t block_size, uint32_t timeout);
|
||||
RtosSharedMem(uint32_t timeout);
|
||||
|
||||
/**
|
||||
* @brief Destroy the Rtos Mem Pool object and frees the memory.
|
||||
|
@ -11,35 +11,35 @@
|
||||
namespace sta
|
||||
{
|
||||
template <typename T>
|
||||
RtosMemPool<T>::RtosMemPool()
|
||||
RtosSharedMem<T>::RtosSharedMem()
|
||||
{
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
RtosMemPool<T>::RtosMemPool(uint32_t block_size, uint32_t timeout /* = osWaitForever */)
|
||||
RtosSharedMem<T>::RtosSharedMem(uint32_t timeout /* = osWaitForever */)
|
||||
{
|
||||
handle_ = osMemoryPoolNew(block_size, block_count, NULL);
|
||||
handle_ = osMemoryPoolNew(sizeof(T), 1, NULL);
|
||||
STA_ASSERT_MSG(handle_ != nullptr, "Failed to Create RtosMemPool for sharedmem");
|
||||
|
||||
shared_mem_ = osMemoryPoolAlloc(handle_, timeout)
|
||||
shared_mem_ = (T*) osMemoryPoolAlloc(handle_, timeout);
|
||||
STA_ASSERT_MSG(shared_mem_ != nullptr, "Failed to Alloc RtosMemPool Block");
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
RtosMemPool<T>::~RtosSharedMem()
|
||||
RtosSharedMem<T>::~RtosSharedMem()
|
||||
{
|
||||
osMemoryPoolFree(handle_, shared_mem_);
|
||||
osMemoryPoolDelete(handle_);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
void RtosMemPool<T>::write(T _message)
|
||||
void RtosSharedMem<T>::write(T _message)
|
||||
{
|
||||
*shared_mem_ = _message;
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T RtosMemPool<T>::read(void * block)
|
||||
T RtosSharedMem<T>::read()
|
||||
{
|
||||
return *shared_mem_;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user