Classes | Macros | Typedefs | Enumerations
I2C_Adapter

Classes

struct  _hal_i2c_master_config
 HAL I2C master user configuration. More...
 
struct  _hal_i2c_master_transfer
 HAL I2C master transfer structure. More...
 
struct  _hal_i2c_slave_config
 HAL I2C slave user configuration. More...
 
struct  _hal_i2c_slave_transfer
 HAL I2C slave transfer structure. More...
 

Macros

#define HAL_I2C_MASTER_HANDLE_DEFINE(name)   uint32_t name[(HAL_I2C_MASTER_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]
 Defines the I2C master handle. More...
 
#define HAL_I2C_MASTER_HANDLE_SIZE   (80U)
 HAL I2C master handle size. More...
 
#define HAL_I2C_SLAVE_HANDLE_DEFINE(name)   uint32_t name[(HAL_I2C_SLAVE_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]
 Defines the I2C slave handle. More...
 
#define HAL_I2C_SLAVE_HANDLE_SIZE   (88U)
 HAL I2C slave handle size. More...
 

Typedefs

typedef enum _hal_i2c_direction hal_i2c_direction_t
 Direction of master and slave transfers. More...
 
typedef struct _hal_i2c_master_config hal_i2c_master_config_t
 HAL I2C master user configuration. More...
 
typedef void * hal_i2c_master_handle_t
 HAL I2C master handle. More...
 
typedef void(* hal_i2c_master_transfer_callback_t) (hal_i2c_master_handle_t handle, hal_i2c_status_t completionStatus, void *callbackParam)
 Master completion callback function pointer type. More...
 
typedef enum _hal_i2c_master_transfer_flag hal_i2c_master_transfer_flag_t
 I2C transfer control flag. More...
 
typedef struct _hal_i2c_master_transfer hal_i2c_master_transfer_t
 HAL I2C master transfer structure. More...
 
typedef struct _hal_i2c_slave_config hal_i2c_slave_config_t
 HAL I2C slave user configuration. More...
 
typedef void * hal_i2c_slave_handle_t
 HAL I2C slave handle. More...
 
typedef void(* hal_i2c_slave_transfer_callback_t) (hal_i2c_slave_handle_t handle, hal_i2c_slave_transfer_t *transfer, void *callbackParam)
 Slave event callback function pointer type. More...
 
typedef enum _hal_i2c_slave_transfer_event hal_i2c_slave_transfer_event_t
 Set of events sent to the callback for nonblocking slave transfers. More...
 
typedef struct _hal_i2c_slave_transfer hal_i2c_slave_transfer_t
 HAL I2C slave transfer structure. More...
 
typedef enum _hal_i2c_status hal_i2c_status_t
 HAL I2C status. More...
 

Enumerations

enum  _hal_i2c_direction { kHAL_I2cWrite = 0U, kHAL_I2cRead = 1U }
 Direction of master and slave transfers. More...
 
enum  _hal_i2c_master_transfer_flag { kHAL_I2cTransferDefaultFlag = 0x0U, kHAL_I2cTransferNoStartFlag = 0x1U, kHAL_I2cTransferRepeatedStartFlag = 0x2U, kHAL_I2cTransferNoStopFlag = 0x4U }
 I2C transfer control flag. More...
 
enum  _hal_i2c_slave_transfer_event {
  kHAL_I2cSlaveAddressMatchEvent = 0x01U, kHAL_I2cSlaveTransmitEvent = 0x02U, kHAL_I2cSlaveReceiveEvent = 0x04U, kHAL_I2cSlaveTransmitAckEvent = 0x08U,
  kHAL_I2cSlaveCompletionEvent = 0x20U, kHAL_I2cSlaveStartEvent = 0x10U, kHAL_I2cSlaveGenaralcallEvent = 0x40U, kHAL_I2cSlaveAllEvents
}
 Set of events sent to the callback for nonblocking slave transfers. More...
 
enum  _hal_i2c_status {
  kStatus_HAL_I2cSuccess = kStatus_Success, kStatus_HAL_I2cError = MAKE_STATUS(kStatusGroup_HAL_I2C, 1), kStatus_HAL_I2cBusy = MAKE_STATUS(kStatusGroup_HAL_I2C, 2), kStatus_HAL_I2cIdle = MAKE_STATUS(kStatusGroup_HAL_I2C, 3),
  kStatus_HAL_I2cNak = MAKE_STATUS(kStatusGroup_HAL_I2C, 4), kStatus_HAL_I2cArbitrationLost = MAKE_STATUS(kStatusGroup_HAL_I2C, 5), kStatus_HAL_I2cTimeout = MAKE_STATUS(kStatusGroup_HAL_I2C, 6), kStatus_HAL_I2cAddrressNak = MAKE_STATUS(kStatusGroup_HAL_I2C, 7)
}
 HAL I2C status. More...
 

Initialization and de-initialization

hal_i2c_status_t HAL_I2cMasterInit (hal_i2c_master_handle_t handle, const hal_i2c_master_config_t *config)
 Initializes the HAL I2C master peripheral. More...
 
hal_i2c_status_t HAL_I2cSlaveInit (hal_i2c_slave_handle_t handle, const hal_i2c_slave_config_t *config)
 Initializes the HAL I2C peripheral. More...
 
hal_i2c_status_t HAL_I2cMasterDeinit (hal_i2c_master_handle_t handle)
 De-initializes the HAL I2C master peripheral. Call this API to gate the HAL I2C clock. The HAL I2C master module can't work unless the HAL_I2cMasterInit is called. More...
 
hal_i2c_status_t HAL_I2cSlaveDeinit (hal_i2c_slave_handle_t handle)
 De-initializes the HAL I2C slave peripheral. Calling this API gates the HAL I2C clock. The HAL I2C slave module can't work unless the HAL_I2cSlaveInit is called to enable the clock. More...
 

Bus Operations

hal_i2c_status_t HAL_I2cMasterWriteBlocking (hal_i2c_master_handle_t handle, const uint8_t *txBuff, size_t txSize, uint32_t flags)
 Performs a polling send transaction on the HAL I2C bus. More...
 
hal_i2c_status_t HAL_I2cMasterReadBlocking (hal_i2c_master_handle_t handle, uint8_t *rxBuff, size_t rxSize, uint32_t flags)
 Performs a polling receive transaction on the HAL I2C bus. More...
 
hal_i2c_status_t HAL_I2cSlaveWriteBlocking (hal_i2c_slave_handle_t handle, const uint8_t *txBuff, size_t txSize)
 Performs a polling send transaction on the HAL I2C bus. More...
 
hal_i2c_status_t HAL_I2cSlaveReadBlocking (hal_i2c_slave_handle_t handle, uint8_t *rxBuff, size_t rxSize)
 Performs a polling receive transaction on the HAL I2C bus. More...
 
hal_i2c_status_t HAL_I2cMasterTransferBlocking (hal_i2c_master_handle_t handle, hal_i2c_master_transfer_t *xfer)
 Performs a master polling transfer on the HAL I2C bus. More...
 

Transactional

hal_i2c_status_t HAL_I2cMasterTransferInstallCallback (hal_i2c_master_handle_t handle, hal_i2c_master_transfer_callback_t callback, void *callbackParam)
 Installs a callback and callback parameter. More...
 
hal_i2c_status_t HAL_I2cMasterTransferNonBlocking (hal_i2c_master_handle_t handle, hal_i2c_master_transfer_t *xfer)
 Performs a master interrupt non-blocking transfer on the HAL I2C bus. More...
 
hal_i2c_status_t HAL_I2cMasterTransferGetCount (hal_i2c_master_handle_t handle, size_t *count)
 Gets the master transfer status during a interrupt non-blocking transfer. More...
 
hal_i2c_status_t HAL_I2cMasterTransferAbort (hal_i2c_master_handle_t handle)
 Aborts an interrupt non-blocking transfer early. More...
 
hal_i2c_status_t HAL_I2cSlaveTransferInstallCallback (hal_i2c_slave_handle_t handle, hal_i2c_slave_transfer_callback_t callback, void *callbackParam)
 Installs a callback and callback parameter. More...
 
hal_i2c_status_t HAL_I2cSlaveTransferNonBlocking (hal_i2c_slave_handle_t handle, uint32_t eventMask)
 Starts accepting slave transfers. More...
 
hal_i2c_status_t HAL_I2cSlaveTransferAbort (hal_i2c_slave_handle_t handle)
 Aborts the slave transfer. More...
 
hal_i2c_status_t HAL_I2cSlaveTransferGetCount (hal_i2c_slave_handle_t handle, size_t *count)
 Gets the slave transfer remaining bytes during a interrupt non-blocking transfer. More...
 

Detailed Description

Macro Definition Documentation

◆ HAL_I2C_MASTER_HANDLE_DEFINE

#define HAL_I2C_MASTER_HANDLE_DEFINE (   name)    uint32_t name[(HAL_I2C_MASTER_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]

Defines the I2C master handle.

This macro is used to define a 4 byte aligned I2C master handle. Then use "(hal_i2c_master_handle_t)name" to get the I2C master handle.

The macro should be global and could be optional. You could also define I2C master handle by yourself.

This is an example,

Parameters
nameThe name string of the I2C master handle.

Definition at line 146 of file i2c.h.

◆ HAL_I2C_MASTER_HANDLE_SIZE

#define HAL_I2C_MASTER_HANDLE_SIZE   (80U)

HAL I2C master handle size.

Definition at line 21 of file i2c.h.

◆ HAL_I2C_SLAVE_HANDLE_DEFINE

#define HAL_I2C_SLAVE_HANDLE_DEFINE (   name)    uint32_t name[(HAL_I2C_SLAVE_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t)]

Defines the I2C slave handle.

This macro is used to define a 4 byte aligned I2C slave handle. Then use "(hal_i2c_slave_handle_t)name" to get the I2C slave handle.

The macro should be global and could be optional. You could also define I2C slave handle by yourself.

This is an example,

Parameters
nameThe name string of the I2C slave handle.

Definition at line 164 of file i2c.h.

◆ HAL_I2C_SLAVE_HANDLE_SIZE

#define HAL_I2C_SLAVE_HANDLE_SIZE   (88U)

HAL I2C slave handle size.

Definition at line 24 of file i2c.h.

Typedef Documentation

◆ hal_i2c_direction_t

Direction of master and slave transfers.

◆ hal_i2c_master_config_t

HAL I2C master user configuration.

◆ hal_i2c_master_handle_t

typedef void* hal_i2c_master_handle_t

HAL I2C master handle.

Definition at line 126 of file i2c.h.

◆ hal_i2c_master_transfer_callback_t

typedef void(* hal_i2c_master_transfer_callback_t) (hal_i2c_master_handle_t handle, hal_i2c_status_t completionStatus, void *callbackParam)

Master completion callback function pointer type.

This callback is used only for the non-blocking master transfer API. Specify the callback you wish to use in the call to HAL_I2cMasterTransferInstallCallback().

Parameters
handlei2c master handle pointer, this should be a static variable.
completionStatusEither kStatus_HAL_I2cSuccess or an error code describing how the transfer completed.
callbackParamArbitrary pointer-sized value passed from the application.

Definition at line 177 of file i2c.h.

◆ hal_i2c_master_transfer_flag_t

I2C transfer control flag.

◆ hal_i2c_master_transfer_t

HAL I2C master transfer structure.

◆ hal_i2c_slave_config_t

HAL I2C slave user configuration.

◆ hal_i2c_slave_handle_t

typedef void* hal_i2c_slave_handle_t

HAL I2C slave handle.

Definition at line 129 of file i2c.h.

◆ hal_i2c_slave_transfer_callback_t

typedef void(* hal_i2c_slave_transfer_callback_t) (hal_i2c_slave_handle_t handle, hal_i2c_slave_transfer_t *transfer, void *callbackParam)

Slave event callback function pointer type.

This callback is used only for the slave non-blocking transfer API. Specify the callback you wish to use in the call to HAL_I2cSlaveTransferInstallCallback().

Parameters
handlei2c slave master handle pointer, this should be a static variable.
transferPointer to transfer descriptor containing values passed to and/or from the callback.
callbackParamArbitrary pointer-sized value passed from the application.

Definition at line 191 of file i2c.h.

◆ hal_i2c_slave_transfer_event_t

Set of events sent to the callback for nonblocking slave transfers.

These event enumerations are used for two related purposes. First, a bit mask created by OR'ing together events is passed to I2C_SlaveTransferNonBlocking() to specify which events to enable. Then, when the slave callback is invoked, it is passed the current event through its transfer parameter.

Note
These enumerations are meant to be OR'd together to form a bit mask of events.

◆ hal_i2c_slave_transfer_t

HAL I2C slave transfer structure.

◆ hal_i2c_status_t

HAL I2C status.

Enumeration Type Documentation

◆ _hal_i2c_direction

Direction of master and slave transfers.

Enumerator
kHAL_I2cWrite 

Master transmit.

kHAL_I2cRead 

Master receive.

Definition at line 58 of file i2c.h.

◆ _hal_i2c_master_transfer_flag

I2C transfer control flag.

Enumerator
kHAL_I2cTransferDefaultFlag 

A transfer starts with a start signal, stops with a stop signal.

kHAL_I2cTransferNoStartFlag 

A transfer starts without a start signal, only support write only or write+read with no start flag, do not support read only with no start flag.

kHAL_I2cTransferRepeatedStartFlag 

A transfer starts with a repeated start signal.

kHAL_I2cTransferNoStopFlag 

A transfer ends without a stop signal.

Definition at line 65 of file i2c.h.

◆ _hal_i2c_slave_transfer_event

Set of events sent to the callback for nonblocking slave transfers.

These event enumerations are used for two related purposes. First, a bit mask created by OR'ing together events is passed to I2C_SlaveTransferNonBlocking() to specify which events to enable. Then, when the slave callback is invoked, it is passed the current event through its transfer parameter.

Note
These enumerations are meant to be OR'd together to form a bit mask of events.
Enumerator
kHAL_I2cSlaveAddressMatchEvent 

Received the slave address after a start or repeated start.

kHAL_I2cSlaveTransmitEvent 

A callback is requested to provide data to transmit (slave-transmitter role).

kHAL_I2cSlaveReceiveEvent 

A callback is requested to provide a buffer in which to place received data (slave-receiver role).

kHAL_I2cSlaveTransmitAckEvent 

A callback needs to either transmit an ACK or NACK.

kHAL_I2cSlaveCompletionEvent 

A stop was detected or finished transfer, completing the transfer.

kHAL_I2cSlaveStartEvent 

A start/repeated start was detected.

kHAL_I2cSlaveGenaralcallEvent 

Received the general call address after a start or repeated start.

kHAL_I2cSlaveAllEvents 

A bit mask of all available events.

Definition at line 84 of file i2c.h.

◆ _hal_i2c_status

HAL I2C status.

Enumerator
kStatus_HAL_I2cSuccess 

Successfully

kStatus_HAL_I2cError 

Error occurs on HAL I2C

kStatus_HAL_I2cBusy 

HAL I2C is busy with current transfer

kStatus_HAL_I2cIdle 

HAL I2C transmitter is idle

kStatus_HAL_I2cNak 

NAK received during transfer

kStatus_HAL_I2cArbitrationLost 

Arbitration lost during transfer

kStatus_HAL_I2cTimeout 

Timeout

kStatus_HAL_I2cAddrressNak 

NAK received during the address probe

Definition at line 27 of file i2c.h.

Function Documentation

◆ HAL_I2cMasterDeinit()

hal_i2c_status_t HAL_I2cMasterDeinit ( hal_i2c_master_handle_t  handle)

De-initializes the HAL I2C master peripheral. Call this API to gate the HAL I2C clock. The HAL I2C master module can't work unless the HAL_I2cMasterInit is called.

Parameters
handlei2c master handle pointer, this should be a static variable.
Return values
kStatus_HAL_I2cSuccessi2c master de-initialization succeed

Definition at line 171 of file lpi2c_adapter.c.

◆ HAL_I2cMasterInit()

hal_i2c_status_t HAL_I2cMasterInit ( hal_i2c_master_handle_t  handle,
const hal_i2c_master_config_t config 
)

Initializes the HAL I2C master peripheral.

Note
This API should be called at the beginning of the application. Otherwise, any operation to the HAL I2C module can cause a hard fault because the clock is not enabled. This function configures the i2c master with user-defined settings. The user can configure the configuration structure. The parameter handle is a pointer to point to a memory space of size HAL_I2C_MASTER_HANDLE_SIZE allocated by the caller.

Example below shows how to use this API to configure the I2C master.

masterConfig.enableMaster = true;
masterConfig.baudRate_Bps = 100000U;
masterConfig.srcClock_Hz = 12000000U;
masterConfig.instance = 0;
HAL_I2cMasterInit((hal_i2c_master_handle_t)i2cMasterHandle, &masterConfig);
Parameters
handlePointer to point to a memory space of size HAL_I2C_MASTER_HANDLE_SIZE allocated by the caller. The handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. You can define the handle in the following two ways: HAL_I2C_MASTER_HANDLE_DEFINE(handle); or uint32_t handle[((HAL_I2C_MASTER_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))];
configA pointer to the master configuration structure
Return values
kStatus_HAL_I2cErrorAn error occurred.
kStatus_HAL_I2cSuccessi2c master initialization succeed

Definition at line 129 of file lpi2c_adapter.c.

◆ HAL_I2cMasterReadBlocking()

hal_i2c_status_t HAL_I2cMasterReadBlocking ( hal_i2c_master_handle_t  handle,
uint8_t *  rxBuff,
size_t  rxSize,
uint32_t  flags 
)

Performs a polling receive transaction on the HAL I2C bus.

Note
The HAL_I2cMasterReadBlocking function stops the bus before reading the final byte. Without stopping the bus prior for the final read, the bus issues another read, resulting in garbage data being read into the data register.
Parameters
handlei2c master handle pointer, this should be a static variable.
rxBuffThe pointer to the data to store the received data.
rxSizeThe length in bytes of the data to be received.
flagsTransfer control flag to decide whether need to send a stop, use kHAL_I2cTransferDefaultFlag to issue a stop and kHAL_I2cTransferNoStopFlag to not send a stop.
Return values
kStatus_HAL_I2cSuccessSuccessfully complete the data transmission.
kStatus_HAL_I2cTimeoutSend stop signal failed, timeout.

Definition at line 205 of file lpi2c_adapter.c.

◆ HAL_I2cMasterTransferAbort()

hal_i2c_status_t HAL_I2cMasterTransferAbort ( hal_i2c_master_handle_t  handle)

Aborts an interrupt non-blocking transfer early.

Note
This API can be called at any time when an interrupt non-blocking transfer initiates to abort the transfer early.
Parameters
handlei2c master handle pointer, this should be a static variable.
Return values
kStatus_HAL_I2cTimeoutTimeout during polling flag.
kStatus_HAL_I2cSuccessSuccessfully abort the transfer.

Definition at line 295 of file lpi2c_adapter.c.

◆ HAL_I2cMasterTransferBlocking()

hal_i2c_status_t HAL_I2cMasterTransferBlocking ( hal_i2c_master_handle_t  handle,
hal_i2c_master_transfer_t xfer 
)

Performs a master polling transfer on the HAL I2C bus.

Note
The API does not return until the transfer succeeds or fails due to arbitration lost or receiving a NAK.
Parameters
handlei2c master handle pointer, this should be a static variable.
xferPointer to the transfer structure.
Return values
kStatus_HAL_I2cSuccessSuccessfully complete the data transmission.
kStatus_HAL_I2cBusyPrevious transmission still not finished.
kStatus_HAL_I2cTimeoutTransfer error, wait signal timeout.
kStatus_HAL_I2cArbitrationLostTransfer error, arbitration lost.
kStatus_HAL_I2cNakTransfer error, receive NAK during transfer.

Definition at line 223 of file lpi2c_adapter.c.

◆ HAL_I2cMasterTransferGetCount()

hal_i2c_status_t HAL_I2cMasterTransferGetCount ( hal_i2c_master_handle_t  handle,
size_t *  count 
)

Gets the master transfer status during a interrupt non-blocking transfer.

Parameters
handlei2c master handle pointer, this should be a static variable.
countNumber of bytes transferred so far by the non-blocking transaction.
Return values
kStatus_HAL_I2cErrorAn error occurred.
kStatus_HAL_I2cSuccessSuccessfully return the count.

Definition at line 283 of file lpi2c_adapter.c.

◆ HAL_I2cMasterTransferInstallCallback()

hal_i2c_status_t HAL_I2cMasterTransferInstallCallback ( hal_i2c_master_handle_t  handle,
hal_i2c_master_transfer_callback_t  callback,
void *  callbackParam 
)

Installs a callback and callback parameter.

This function is used to install the callback and callback parameter for i2c master module. When any status of the i2c master changed, the driver will notify the upper layer by the installed callback function. And the status is also passed as status parameter when the callback is called.

Parameters
handlei2c master handle pointer, this should be a static variable.
callbackpointer to user callback function.
callbackParamuser parameter passed to the callback function.
Return values
kStatus_HAL_I2cSuccessi2c master handle created

Definition at line 244 of file lpi2c_adapter.c.

◆ HAL_I2cMasterTransferNonBlocking()

hal_i2c_status_t HAL_I2cMasterTransferNonBlocking ( hal_i2c_master_handle_t  handle,
hal_i2c_master_transfer_t xfer 
)

Performs a master interrupt non-blocking transfer on the HAL I2C bus.

Note
Calling the API returns immediately after transfer initiates. The user needs to call HAL_I2cMasterGetTransferCount to poll the transfer status to check whether the transfer is finished. If the return status is not kStatus_HAL_I2cBusy, the transfer is finished.
Parameters
handlei2c master handle pointer, this should be a static variable.
xferpointer to hal_i2c_master_transfer_t structure.
Return values
kStatus_HAL_I2cSuccessSuccessfully start the data transmission.
kStatus_HAL_I2cBusyPrevious transmission still not finished.
kStatus_HAL_I2cTimeoutTransfer error, wait signal timeout.

Definition at line 262 of file lpi2c_adapter.c.

◆ HAL_I2cMasterWriteBlocking()

hal_i2c_status_t HAL_I2cMasterWriteBlocking ( hal_i2c_master_handle_t  handle,
const uint8_t *  txBuff,
size_t  txSize,
uint32_t  flags 
)

Performs a polling send transaction on the HAL I2C bus.

Parameters
handlei2c master handle pointer, this should be a static variable.
txBuffThe pointer to the data to be transferred.
txSizeThe length in bytes of the data to be transferred.
flagsTransfer control flag to decide whether need to send a stop, use kHAL_I2cTransferDefaultFlag to issue a stop and kHAL_I2cTransferNoStopFlag to not send a stop.
Return values
kStatus_HAL_I2cSuccessSuccessfully complete the data transmission.
kStatus_HAL_I2cArbitrationLostTransfer error, arbitration lost.
kStatus_HAL_I2cNakTransfer error, receive NAK during transfer.

Definition at line 197 of file lpi2c_adapter.c.

◆ HAL_I2cSlaveDeinit()

hal_i2c_status_t HAL_I2cSlaveDeinit ( hal_i2c_slave_handle_t  handle)

De-initializes the HAL I2C slave peripheral. Calling this API gates the HAL I2C clock. The HAL I2C slave module can't work unless the HAL_I2cSlaveInit is called to enable the clock.

Parameters
handlei2c slave handle pointer, this should be a static variable.
Return values
kStatus_HAL_I2cSuccessi2c slave de-initialization succeed

Definition at line 184 of file lpi2c_adapter.c.

◆ HAL_I2cSlaveInit()

hal_i2c_status_t HAL_I2cSlaveInit ( hal_i2c_slave_handle_t  handle,
const hal_i2c_slave_config_t config 
)

Initializes the HAL I2C peripheral.

Note
This API should be called at the beginning of the application. Otherwise, any operation to the HAL I2C module can cause a hard fault because the clock is not enabled. This function configures the i2c slave with user-defined settings. The user can configure the configuration structure. The parameter handle is a pointer to point to a memory space of size HAL_I2C_SLAVE_HANDLE_SIZE allocated by the caller.

Example below shows how to use this API to configure the I2C slave.

slaveConfig.enableSlave = true;
slaveConfig.slaveAddress = 0x01U;
slaveConfig.srcClock_Hz = 12000000U;
slaveConfig.instance = 0;
HAL_I2cSlaveInit((hal_i2c_slave_handle_t)i2cSlaveHandle, &slaveConfig);
Parameters
handlePointer to point to a memory space of size HAL_I2C_SLAVE_HANDLE_SIZE allocated by the caller. The handle should be 4 byte aligned, because unaligned access doesn't be supported on some devices. You can define the handle in the following two ways: HAL_I2C_SLAVE_HANDLE_DEFINE(handle); or uint32_t handle[((HAL_I2C_SLAVE_HANDLE_SIZE + sizeof(uint32_t) - 1U) / sizeof(uint32_t))];
configA pointer to the slave configuration structure
Return values
kStatus_HAL_I2cErrorAn error occurred.
kStatus_HAL_I2cSuccessi2c slave initialization succeed

Definition at line 150 of file lpi2c_adapter.c.

◆ HAL_I2cSlaveReadBlocking()

hal_i2c_status_t HAL_I2cSlaveReadBlocking ( hal_i2c_slave_handle_t  handle,
uint8_t *  rxBuff,
size_t  rxSize 
)

Performs a polling receive transaction on the HAL I2C bus.

Parameters
handlei2c slave handle pointer, this should be a static variable.
rxBuffThe pointer to the data to store the received data.
rxSizeThe length in bytes of the data to be received.
Return values
kStatus_HAL_I2cSuccessSuccessfully complete data receive.
kStatus_HAL_I2cTimeoutWait status flag timeout.

Definition at line 218 of file lpi2c_adapter.c.

◆ HAL_I2cSlaveTransferAbort()

hal_i2c_status_t HAL_I2cSlaveTransferAbort ( hal_i2c_slave_handle_t  handle)

Aborts the slave transfer.

Note
This API can be called at any time to stop slave for handling the bus events.
Parameters
handlei2c slave handle pointer, this should be a static variable.
Return values
kStatus_HAL_I2cSuccessSuccessfully return the count.

Definition at line 337 of file lpi2c_adapter.c.

◆ HAL_I2cSlaveTransferGetCount()

hal_i2c_status_t HAL_I2cSlaveTransferGetCount ( hal_i2c_slave_handle_t  handle,
size_t *  count 
)

Gets the slave transfer remaining bytes during a interrupt non-blocking transfer.

Parameters
handlei2c slave handle pointer, this should be a static variable.
countNumber of bytes transferred so far by the non-blocking transaction.
Return values
kStatus_HAL_I2cErrorAn error occurred.
kStatus_HAL_I2cSuccessSuccessfully return the count.

Definition at line 350 of file lpi2c_adapter.c.

◆ HAL_I2cSlaveTransferInstallCallback()

hal_i2c_status_t HAL_I2cSlaveTransferInstallCallback ( hal_i2c_slave_handle_t  handle,
hal_i2c_slave_transfer_callback_t  callback,
void *  callbackParam 
)

Installs a callback and callback parameter.

This function is used to install the callback and callback parameter for i2c slave module. When any status of the i2c slave changed, the driver will notify the upper layer by the installed callback function. And the status is also passed as status parameter when the callback is called.

Parameters
handlei2c slave handle pointer, this should be a static variable.
callbackpointer to user callback function.
callbackParamuser parameter passed to the callback function.
Return values
kStatus_HAL_I2cSuccessi2c slave handle created

Definition at line 307 of file lpi2c_adapter.c.

◆ HAL_I2cSlaveTransferNonBlocking()

hal_i2c_status_t HAL_I2cSlaveTransferNonBlocking ( hal_i2c_slave_handle_t  handle,
uint32_t  eventMask 
)

Starts accepting slave transfers.

Call this API after calling the HAL_I2cSlaveInit() and HAL_I2cSlaveTransferInstallCallback() to start processing transactions driven by an HAL I2C slave. The slave monitors the HAL I2C bus and passes events to the callback that was passed into the call to HAL_I2cSlaveTransferInstallCallback(). The callback is always invoked from the interrupt context.

The set of events received by the callback is customizable. To do so, set the eventMask parameter to the OR'd combination of hal_i2c_slave_transfer_event_t enumerators for the events you wish to receive. The kHAL_I2cSlaveTransmitEvent and kHAL_I2cSlaveReceiveEvent events are always enabled and do not need to be included in the mask. Alternatively, pass 0 to get a default set of only the transmit and receive events that are always enabled. In addition, the kHAL_I2cSlaveAllEvents constant is provided as a convenient way to enable all events.

Parameters
handlei2c slave handle pointer, this should be a static variable.
eventMaskBit mask formed by OR'ing together hal_i2c_slave_transfer_event_t enumerators to specify which events to send to the callback. Other accepted values are 0 to get a default set of only the transmit and receive events, and kHAL_I2cSlaveAllEvents to enable all events.
Return values
kStatus_HAL_I2cSuccessSlave transfers were successfully started.
kStatus_HAL_I2cBusySlave transfers have already been started on this handle.

Definition at line 325 of file lpi2c_adapter.c.

◆ HAL_I2cSlaveWriteBlocking()

hal_i2c_status_t HAL_I2cSlaveWriteBlocking ( hal_i2c_slave_handle_t  handle,
const uint8_t *  txBuff,
size_t  txSize 
)

Performs a polling send transaction on the HAL I2C bus.

Parameters
handlei2c slave handle pointer, this should be a static variable.
txBuffThe pointer to the data to be transferred.
txSizeThe length in bytes of the data to be transferred.
Return values
kStatus_HAL_I2cSuccessSuccessfully complete the data transmission.
kStatus_HAL_I2cArbitrationLostTransfer error, arbitration lost.
kStatus_HAL_I2cNakTransfer error, receive NAK during transfer.

Definition at line 213 of file lpi2c_adapter.c.

HAL_I2cSlaveInit
hal_i2c_status_t HAL_I2cSlaveInit(hal_i2c_slave_handle_t handle, const hal_i2c_slave_config_t *config)
Initializes the HAL I2C peripheral.
Definition: lpi2c_adapter.c:150
_hal_i2c_master_config::baudRate_Bps
uint32_t baudRate_Bps
Definition: i2c.h:43
_hal_i2c_slave_config
HAL I2C slave user configuration.
Definition: i2c.h:49
_hal_i2c_slave_config::enableSlave
bool enableSlave
Definition: i2c.h:53
_hal_i2c_master_config::enableMaster
bool enableMaster
Definition: i2c.h:44
_hal_i2c_slave_config::instance
uint8_t instance
Definition: i2c.h:54
_hal_i2c_master_config
HAL I2C master user configuration.
Definition: i2c.h:40
_hal_i2c_master_config::instance
uint8_t instance
Definition: i2c.h:45
HAL_I2cMasterInit
hal_i2c_status_t HAL_I2cMasterInit(hal_i2c_master_handle_t handle, const hal_i2c_master_config_t *config)
Initializes the HAL I2C master peripheral.
Definition: lpi2c_adapter.c:129
hal_i2c_slave_handle_t
void * hal_i2c_slave_handle_t
HAL I2C slave handle.
Definition: i2c.h:129
_hal_i2c_slave_config::slaveAddress
uint16_t slaveAddress
Definition: i2c.h:52
_hal_i2c_slave_config::srcClock_Hz
uint32_t srcClock_Hz
Definition: i2c.h:51
HAL_I2C_SLAVE_HANDLE_DEFINE
#define HAL_I2C_SLAVE_HANDLE_DEFINE(name)
Defines the I2C slave handle.
Definition: i2c.h:164
hal_i2c_master_handle_t
void * hal_i2c_master_handle_t
HAL I2C master handle.
Definition: i2c.h:126
_hal_i2c_master_config::srcClock_Hz
uint32_t srcClock_Hz
Definition: i2c.h:42
HAL_I2C_MASTER_HANDLE_DEFINE
#define HAL_I2C_MASTER_HANDLE_DEFINE(name)
Defines the I2C master handle.
Definition: i2c.h:146


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:15:09