I am currently working on a ZigBee WSNDemo project and I am stuck on this part of code. Basically, I have to use this macro for queue purposes in appInitMsgSender
function.
void appInitMsgSender(void)
{
txState = APP_MSG_TX_FREE_STATE;
resetQueue(&appToSendQueue);
resetQueue(&appFreeQueue);
resetQueue(&appSentQueue);
resetQueue(&appDoneQueue);
for (uint8_t i = 0; i < ARRAY_SIZE(appTxBuffers); i++)
{
putQueueElem(&appFreeQueue, &appTxBuffers[i].next);
}
}
Above is the application's message send initialization function. The following are macros used for it. I want to know how both are connected. I mean how to understand the working of this code.
#define DECLARE_QUEUE(queue) QueueDescriptor_t queue = {.head = NULL,}
// Type of queue element
typedef struct _QueueElement_t
{
struct _QueueElement_t *next;
} QueueElement_t;
// Queue descriptor
typedef struct
{
QueueElement_t *head;
} QueueDescriptor_t;
INLINE void resetQueue(QueueDescriptor_t *queue)
{
queue->head = NULL;
}
I am really confused with use of pointer here. I am aware about how pointer works and theory behind it. But in the above context I am bewildered.