#ifndef STA_RTOS_SHAREDMEM_TPP #define STA_RTOS_SHAREDMEM_TPP #ifndef STA_RTOS_SHAREDMEM_HPP # error "Internal header. Use instead." #endif // !STA_RTOS_MEMPOOL_HPP #include namespace sta { template RtosSharedMem::RtosSharedMem(uint32_t timeout /* = osWaitForever */) { handle_ = osMemoryPoolNew(sizeof(T), 1, NULL); STA_ASSERT_MSG(handle_ != nullptr, "Failed to Create RtosMemPool for sharedmem"); shared_mem_ = (T*) osMemoryPoolAlloc(handle_, timeout); STA_ASSERT_MSG(shared_mem_ != nullptr, "Failed to Alloc RtosMemPool Block"); } template RtosSharedMem::~RtosSharedMem() { osMemoryPoolFree(handle_, shared_mem_); osMemoryPoolDelete(handle_); } template void RtosSharedMem::write(T _message) { *shared_mem_ = _message; } template T RtosSharedMem::read() { return *shared_mem_; } } // namespace sta #endif // STA_RTOS_SHAREDMEM_TPP