STM32 Traffic Control
Loading...
Searching...
No Matches
queue.h File Reference

Public API for circular queue implementation. More...

#include <stdint.h>
#include <stdbool.h>
#include "stm32f446xx.h"

Go to the source code of this file.

Functions

bool queue_is_empty (void)
 Check if the traffic light request queue is empty.
bool queue_is_full (void)
 Check if the traffic light request queue is full.
void queue_enqueue (uint32_t light_pair)
 Add a traffic light pair request to the queue.
int32_t queue_dequeue (void)
 Remove and return the next traffic light pair request.

Detailed Description

Public API for circular queue implementation.

Function Documentation

◆ queue_dequeue()

int32_t queue_dequeue ( void )

Remove and return the next traffic light pair request.

Retrieves the front element of the queue and updates the queue pointers. Returns -1 if the queue is empty.

Returns
ID of the next traffic light pair, or -1 if the queue is empty.

◆ queue_enqueue()

void queue_enqueue ( uint32_t lightPair)

Add a traffic light pair request to the queue.

If the queue is not full, the request is added at the rear of the queue. The queue is circular and wraps around automatically.

Parameters
lightPairID of the traffic light pair to enqueue.

◆ queue_is_empty()

bool queue_is_empty ( void )

Check if the traffic light request queue is empty.

◆ queue_is_full()

bool queue_is_full ( void )

Check if the traffic light request queue is full.