#ifndef STA_RTOS_MEMPOOL_TPP #define STA_RTOS_MEMPOOL_TPP #ifndef STA_RTOS_MEMPOOL_HPP # error "Internal header. Use instead." #endif // !STA_RTOS_MEMPOOL_HPP #include namespace sta { template RtosMemPool::RtosMemPool() { } template RtosMemPool::RtosMemPool(uint32_t block_count, uint32_t block_size) { osMemoryPoolAttr_t mp_attr = { .name = "MemoryPool" }; handle_ = osMemoryPoolNew(block_size, block_count, &mp_attr); STA_ASSERT_MSG(handle_ != nullptr, "Failed to Create RtosMemPool"); } template void * RtosMemPool::alloc(uint32_t timeout /* = osWaitForever */) { void * addr = osMemoryPoolAlloc(handle_, timeout) STA_ASSERT_MSG(addr != nullptr, "Failed to Alloc RtosMemPool Block"); return addr; } template void RtosMemPool::free(void * block) { STA_ASSERT_MSG(osMemoryPoolFree(handle_, block) == osOK, "Failed to Free RtosMemPool Block"); } } // namespace sta #endif // STA_RTOS_MEMPOOL_TPP