#ifndef STA_RTOS_QUEUE_TPP #define STA_RTOS_QUEUE_TPP #ifndef STA_RTOS_QUEUE_HPP # error "Internal header. Use instead." #endif // !STA_RTOS_QUEUE_HPP #include namespace sta { template RtosQueue::RtosQueue() { } template RtosQueue::RtosQueue(osMessageQueueId_t handle) : handle_{handle} { STA_ASSERT(handle != NULL); } template RtosQueue::RtosQueue(uint32_t length) : handle_{osMessageQueueNew(length, sizeof(T), NULL)} { STA_ASSERT(handle_ != NULL); } template bool RtosQueue::put(const T msg, uint32_t timeout /* = osWaitForever */) { return (osOK == osMessageQueuePut(handle_, &msg, 0, timeout)); } template bool RtosQueue::get(T * outMsg, uint32_t timeout /* = osWaitForever */) { uint8_t prio; return (osOK == osMessageQueueGet(handle_, outMsg, &prio, timeout)); } template uint32_t RtosQueue::available() const { return osMessageQueueGetCount(handle_); } } // namespace sta #endif // STA_RTOS_QUEUE_TPP