/** * @file * @brief RTOS MemPool implementation for one variable. */ #ifndef STA_RTOS_SHAREDMEM_HPP #define STA_RTOS_SHAREDMEM_HPP #include #include /** * @defgroup STA_RTOS_SHAREDMEM SharedMem * @ingroup STA_RTOS_API * @brief RTOS Shared Memory. */ namespace sta { /** * @brief Interface object for using CMSIS RTOS2 MemPool for one variable. * * @tparam Message type * * @ingroup STA_RTOS_SHAREDMEM */ template class RtosSharedMem { public: using Message = T; /**< message type */ public: // Default Constructor RtosSharedMem(); /** * @brief Create a memory pool. And allocates exavlty one block. * * @param timeout names the timeout in milliseconds. */ RtosSharedMem(uint32_t timeout); /** * @brief Destroy the Rtos Mem Pool object and frees the memory. * */ ~RtosSharedMem(); /** * @brief Allocate a new Memory Block. * * @param _message names the message to write. */ void write(T _message); /** * @brief Gets the value of the shared memory. * * @return T Value of the shared memory. */ T read(); private: osMemoryPoolId_t handle_; /**< CMSIS RTOS2 queue handle */ T * shared_mem_; /**< Pointer to the shared memory */ }; } // namespace sta #include #endif // STA_RTOS_SHAREDMEM_HPP