//***************************************************************************** // (C) Automotive Lighting China // // Automotive Lighting Reutlingen GmbH owns all the rights to this work. // This work shall not be copied, reproduced, used, modified, transferred // or its information shall not be disclosed without the prior written // authorization of Automotive Lighting China. //***************************************************************************** // ---------------------------------------------------------------------------- /// \file StaticRingQueue.h /// /// \author f24301c [mailto:walker.lv@marelli.com] /// /// \date 05.27.2024 /// /// \brief define a ring buffer using Queue semantics. this data struct manage /// PDU buffer to be sent/received, one queue per bus (channel) /// // ---------------------------------------------------------------------------- #ifndef _STATIC_RING_QUEUE_H_ #define _STATIC_RING_QUEUE_H_ //============================================================================= // Includes //============================================================================= #include #include #include //============================================================================= // Defines and Typedef //============================================================================= // queue entity definition typedef struct { ProtocolBuf_t pdu; // memory allocate in the array of QueueEntity_t } QueueEntity_t; #if (UUE_RINGQUEUE_PROFILE == STD_ON) typedef struct { uint8 levelMax; // maximal queue level during measure time } QueueStatistic_t; #endif // ring queue definition typedef struct { uint8 head; // point to the head of active entity, [0..depth - 1] uint8 tail; // point to the tail of queue, where to add new entity, [0..depth - 1] uint8 depth; // queue depth uint8 level; // current queue fill level QueueEntity_t* entities; // pointer of an array of entity*, length is depth #if (UUE_RINGQUEUE_PROFILE == STD_ON) QueueStatistic_t statistic; // queue statistic #endif } StaticRingQueue_t; //----------------------------------------------------------------------------- // public API declaration or MARCO //----------------------------------------------------------------------------- #define DEFAULT_RINGQUEUE_SIZE (32) /* should be move to configuration of queue */ extern UUE_ErrorType Queue_Init(StaticRingQueue_t* pThis); extern UUE_ErrorType Queue_Enqueue(StaticRingQueue_t* pThis, void* playload); extern UUE_ErrorType Queue_Dequeue(StaticRingQueue_t* pThis); extern uint8 Queue_GetDepth(StaticRingQueue_t* pThis); extern uint8 Queue_GetLevel(StaticRingQueue_t* pThis); extern QueueEntity_t* Queue_GetEntity(StaticRingQueue_t* pThis); extern uint8 Queue_IsEmpty(StaticRingQueue_t* pThis); extern uint8 Queue_IsFull(StaticRingQueue_t* pThis); //----------------------------------------------------------------------------- // End of public API declaration or MARCO //----------------------------------------------------------------------------- #endif // _STATIC_RING_QUEUE_H_