NHAL Interface v0.5.0
Hardware Abstraction Layer Interface for Embedded Systems
Loading...
Searching...
No Matches
Functions
nhal_i2c_master_async.h File Reference

Hardware Abstraction Layer (HAL) for asynchronous I2C Master communication. More...

#include <stddef.h>
#include <stdint.h>
#include "nhal_common.h"
#include "nhal_i2c_types.h"

Go to the source code of this file.

Functions

nhal_result_t nhal_i2c_master_init_async (struct nhal_i2c_context *ctx, const struct nhal_async_config *async_cfg)
 Initialize I2C context for async mode.
 
nhal_result_t nhal_i2c_master_deinit_async (struct nhal_i2c_context *ctx)
 Deinitialize I2C async mode.
 
nhal_result_t nhal_i2c_master_set_async_callback (struct nhal_i2c_context *ctx, nhal_async_complete_cb_t callback)
 Set callback for async operation completion.
 
nhal_result_t nhal_i2c_master_disable_async_callback (struct nhal_i2c_context *ctx)
 Disable async completion callback.
 
nhal_async_status_t nhal_i2c_master_get_async_status (struct nhal_i2c_context *ctx)
 Get current async operation status.
 
nhal_result_t nhal_i2c_master_write_async (struct nhal_i2c_context *ctx, nhal_i2c_address dev_address, const uint8_t *data, size_t len)
 Write data to I2C device asynchronously.
 
nhal_result_t nhal_i2c_master_read_async (struct nhal_i2c_context *ctx, nhal_i2c_address dev_address, uint8_t *data, size_t len)
 Read data from I2C device asynchronously.
 
nhal_result_t nhal_i2c_master_write_read_reg_async (struct nhal_i2c_context *ctx, nhal_i2c_address dev_address, const uint8_t *reg_address, size_t reg_len, uint8_t *data, size_t data_len)
 Write to register then read from I2C device asynchronously.
 

Detailed Description

Hardware Abstraction Layer (HAL) for asynchronous I2C Master communication.

This header defines the public interface for asynchronous I2C Master operations using DMA. It provides functions for enabling async mode and performing non-blocking read/write operations with automatic DMA optimization.

Async mode provides non-blocking data transfers with callback completion. This mode requires NHAL_I2C_ASYNC_SUPPORT to be defined at compile time.

Note
This header requires nhal_i2c_master.h to be included first for base functionality

Definition in file nhal_i2c_master_async.h.

Function Documentation

◆ nhal_i2c_master_deinit_async()

nhal_result_t nhal_i2c_master_deinit_async ( struct nhal_i2c_context ctx)

Deinitialize I2C async mode.

Parameters
ctxPointer to I2C context structure
Returns
NHAL_OK on success, error code otherwise

◆ nhal_i2c_master_disable_async_callback()

nhal_result_t nhal_i2c_master_disable_async_callback ( struct nhal_i2c_context ctx)

Disable async completion callback.

Parameters
ctxPointer to I2C context structure
Returns
NHAL_OK on success, error code otherwise

◆ nhal_i2c_master_get_async_status()

nhal_async_status_t nhal_i2c_master_get_async_status ( struct nhal_i2c_context ctx)

Get current async operation status.

Parameters
ctxPointer to I2C context structure
Returns
Current async operation status

◆ nhal_i2c_master_init_async()

nhal_result_t nhal_i2c_master_init_async ( struct nhal_i2c_context ctx,
const struct nhal_async_config async_cfg 
)

Initialize I2C context for async mode.

Parameters
ctxPointer to I2C context structure
async_cfgPointer to async configuration
Returns
NHAL_OK on success, error code otherwise

◆ nhal_i2c_master_read_async()

nhal_result_t nhal_i2c_master_read_async ( struct nhal_i2c_context ctx,
nhal_i2c_address  dev_address,
uint8_t *  data,
size_t  len 
)

Read data from I2C device asynchronously.

Parameters
ctxPointer to I2C context structure
dev_addressI2C slave device address
dataPointer to buffer for received data
lenNumber of bytes to read
timeout_msTimeout in milliseconds
Returns
NHAL_OK on success, error code otherwise

◆ nhal_i2c_master_set_async_callback()

nhal_result_t nhal_i2c_master_set_async_callback ( struct nhal_i2c_context ctx,
nhal_async_complete_cb_t  callback 
)

Set callback for async operation completion.

Parameters
ctxPointer to I2C context structure
callbackCallback function to execute on completion
Returns
NHAL_OK on success, error code otherwise

◆ nhal_i2c_master_write_async()

nhal_result_t nhal_i2c_master_write_async ( struct nhal_i2c_context ctx,
nhal_i2c_address  dev_address,
const uint8_t *  data,
size_t  len 
)

Write data to I2C device asynchronously.

Parameters
ctxPointer to I2C context structure
dev_addressI2C slave device address
dataPointer to data to transmit
lenNumber of bytes to transmit
timeout_msTimeout in milliseconds
Returns
NHAL_OK on success, error code otherwise

◆ nhal_i2c_master_write_read_reg_async()

nhal_result_t nhal_i2c_master_write_read_reg_async ( struct nhal_i2c_context ctx,
nhal_i2c_address  dev_address,
const uint8_t *  reg_address,
size_t  reg_len,
uint8_t *  data,
size_t  data_len 
)

Write to register then read from I2C device asynchronously.

Parameters
ctxPointer to I2C context structure
dev_addressI2C slave device address
reg_addressPointer to register address bytes
reg_lenNumber of register address bytes
dataPointer to buffer for received data
data_lenNumber of bytes to read
timeout_msTimeout in milliseconds
Returns
NHAL_OK on success, error code otherwise