hal
Hardware Abstraction Layer
i2c_transaction_queue.h File Reference

FIFO data structure used to store handles to client I2C transaction requests. More...

#include "i2c.h"
Include dependency graph for i2c_transaction_queue.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define I2C_TRANSACTION_QUEUE_SIZE   10
 Adjust to increase/decrease the queue size.
 

Enumerations

enum  i2c_queue_status_t {
  _I2C_QUEUE_STATUS_ENUM_MIN = 0 , I2C_QUEUE_STATUS_SUCCESS = _I2C_QUEUE_STATUS_ENUM_MIN , I2C_QUEUE_STATUS_FAIL , I2C_QUEUE_STATUS_QUEUE_FULL ,
  I2C_QUEUE_STATUS_QUEUE_EMPTY , _I2C_QUEUE_STATUS_ENUM_MAX
}
 Possible return types for queue operations. More...
 

Functions

i2c_queue_status_t i2c_transaction_queue_add (hal_i2c_txn_t *txn)
 Add a transaction to the queue. More...
 
i2c_queue_status_t i2c_transaction_queue_get_next (hal_i2c_txn_t **txn)
 Get the next transaction from the queue. Removes the transaction from the queue. More...
 
void i2c_transaction_queue_reset ()
 Resets the queue. More...
 

Detailed Description

FIFO data structure used to store handles to client I2C transaction requests.

Note
Clients are responsible for owning the memory for their transactions. This queue only holds handles to the transactions so they may be processed in order.
Warning
Undefined behavior will occur if the transaction added to queue was located on a function's call stack that then returns.

Copyright (c) 2025 Cory McKiel. Licensed under the MIT License. See LICENSE file in the project root.

Enumeration Type Documentation

◆ i2c_queue_status_t

Possible return types for queue operations.

Enumerator
_I2C_QUEUE_STATUS_ENUM_MIN 

Lower bound of enum. Inclusive.

I2C_QUEUE_STATUS_SUCCESS 

The queue operation was successful.

I2C_QUEUE_STATUS_FAIL 

The queue operation encountered an error and was not successful.

I2C_QUEUE_STATUS_QUEUE_FULL 

The queue operation could not be performed because the queue is full.

I2C_QUEUE_STATUS_QUEUE_EMPTY 

The queue operation could not be performed because the queue is empty.

_I2C_QUEUE_STATUS_ENUM_MAX 

Upper bound of enum. Exclusive.

Function Documentation

◆ i2c_transaction_queue_add()

i2c_queue_status_t i2c_transaction_queue_add ( hal_i2c_txn_t txn)

Add a transaction to the queue.

Parameters
txnA reference to the transaction to queue.
Warning
Clients are responsible for maintaining the memory for their transactions. This merely queues a handle.
Returns
The status of the request. SUCCESS is the only return value indicating the request was queued.

◆ i2c_transaction_queue_get_next()

i2c_queue_status_t i2c_transaction_queue_get_next ( hal_i2c_txn_t **  txn)

Get the next transaction from the queue. Removes the transaction from the queue.

Parameters
txnA reference to a handle type for a transaction.
Note
txn is a double pointer because the client is meant to pass in a null handle that they want set to point to the next transaction to process. But to actually set a param, there needs to be a reference to it, hence, the double pointer.
Returns
The status of the request. SUCCESS is the only return value indicating the next transaction was properly dequeued.

◆ i2c_transaction_queue_reset()

void i2c_transaction_queue_reset ( )

Resets the queue.

It resets all internal variables that manage the queue so it will be "like new".