RTEMS 6.1-rc4
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Enumerator | Variables
Lpi2c_slave_driver

Data Structures

struct  _lpi2c_slave_config
 Structure with settings to initialize the LPI2C slave module. More...
 
struct  _lpi2c_slave_transfer
 LPI2C slave transfer structure. More...
 
struct  _lpi2c_slave_handle
 LPI2C slave handle structure. More...
 

Typedefs

typedef enum _lpi2c_slave_address_match lpi2c_slave_address_match_t
 LPI2C slave address match options.
 
typedef struct _lpi2c_slave_config lpi2c_slave_config_t
 Structure with settings to initialize the LPI2C slave module.
 
typedef enum _lpi2c_slave_transfer_event lpi2c_slave_transfer_event_t
 Set of events sent to the callback for non blocking slave transfers.
 
typedef struct _lpi2c_slave_transfer lpi2c_slave_transfer_t
 LPI2C slave transfer structure.
 
typedef struct _lpi2c_slave_handle lpi2c_slave_handle_t
 
typedef void(* lpi2c_slave_transfer_callback_t) (LPI2C_Type *base, lpi2c_slave_transfer_t *transfer, void *userData)
 Slave event callback function pointer type.
 

Enumerations

enum  _lpi2c_slave_flags {
  kLPI2C_SlaveTxReadyFlag = LPI2C_SSR_TDF_MASK , kLPI2C_SlaveRxReadyFlag = LPI2C_SSR_RDF_MASK , kLPI2C_SlaveAddressValidFlag = LPI2C_SSR_AVF_MASK , kLPI2C_SlaveTransmitAckFlag = LPI2C_SSR_TAF_MASK ,
  kLPI2C_SlaveRepeatedStartDetectFlag = LPI2C_SSR_RSF_MASK , kLPI2C_SlaveStopDetectFlag = LPI2C_SSR_SDF_MASK , kLPI2C_SlaveBitErrFlag = LPI2C_SSR_BEF_MASK , kLPI2C_SlaveFifoErrFlag = LPI2C_SSR_FEF_MASK ,
  kLPI2C_SlaveAddressMatch0Flag = LPI2C_SSR_AM0F_MASK , kLPI2C_SlaveAddressMatch1Flag = LPI2C_SSR_AM1F_MASK , kLPI2C_SlaveGeneralCallFlag = LPI2C_SSR_GCF_MASK , kLPI2C_SlaveBusyFlag = LPI2C_SSR_SBF_MASK ,
  kLPI2C_SlaveBusBusyFlag = LPI2C_SSR_BBF_MASK , kLPI2C_SlaveClearFlags , kLPI2C_SlaveIrqFlags , kLPI2C_SlaveErrorFlags = kLPI2C_SlaveFifoErrFlag | kLPI2C_SlaveBitErrFlag
}
 LPI2C slave peripheral flags. More...
 
enum  _lpi2c_slave_address_match { kLPI2C_MatchAddress0 = 0U , kLPI2C_MatchAddress0OrAddress1 = 2U , kLPI2C_MatchAddress0ThroughAddress1 = 6U }
 LPI2C slave address match options. More...
 
enum  _lpi2c_slave_transfer_event {
  kLPI2C_SlaveAddressMatchEvent = 0x01U , kLPI2C_SlaveTransmitEvent = 0x02U , kLPI2C_SlaveReceiveEvent = 0x04U , kLPI2C_SlaveTransmitAckEvent = 0x08U ,
  kLPI2C_SlaveRepeatedStartEvent = 0x10U , kLPI2C_SlaveCompletionEvent = 0x20U , kLPI2C_SlaveAllEvents
}
 Set of events sent to the callback for non blocking slave transfers. More...
 

Variables

bool _lpi2c_master_config::enableMaster
 
bool _lpi2c_master_config::enableDoze
 
bool _lpi2c_master_config::debugEnable
 
bool _lpi2c_master_config::ignoreAck
 
lpi2c_master_pin_config_t _lpi2c_master_config::pinConfig
 
uint32_t _lpi2c_master_config::baudRate_Hz
 
uint32_t _lpi2c_master_config::busIdleTimeout_ns
 
uint32_t _lpi2c_master_config::pinLowTimeout_ns
 
uint8_t _lpi2c_master_config::sdaGlitchFilterWidth_ns
 
uint8_t _lpi2c_master_config::sclGlitchFilterWidth_ns
 
bool   _lpi2c_master_config::enable
 
lpi2c_host_request_source_t   _lpi2c_master_config::source
 
lpi2c_host_request_polarity_t   _lpi2c_master_config::polarity
 
struct {
   bool   _lpi2c_master_config::enable
 
   lpi2c_host_request_source_t   _lpi2c_master_config::source
 
   lpi2c_host_request_polarity_t   _lpi2c_master_config::polarity
 
_lpi2c_master_config::hostRequest
 
lpi2c_data_match_config_mode_t _lpi2c_match_config::matchMode
 
bool _lpi2c_match_config::rxDataMatchOnly
 
uint32_t _lpi2c_match_config::match0
 
uint32_t _lpi2c_match_config::match1
 
uint32_t _lpi2c_master_transfer::flags
 
uint16_t _lpi2c_master_transfer::slaveAddress
 
lpi2c_direction_t _lpi2c_master_transfer::direction
 
uint32_t _lpi2c_master_transfer::subaddress
 
size_t _lpi2c_master_transfer::subaddressSize
 
void * _lpi2c_master_transfer::data
 
size_t _lpi2c_master_transfer::dataSize
 
uint8_t _lpi2c_master_handle::state
 
uint16_t _lpi2c_master_handle::remainingBytes
 
uint8_t * _lpi2c_master_handle::buf
 
uint16_t _lpi2c_master_handle::commandBuffer [6]
 
lpi2c_master_transfer_t _lpi2c_master_handle::transfer
 
lpi2c_master_transfer_callback_t _lpi2c_master_handle::completionCallback
 
void * _lpi2c_master_handle::userData
 
bool _lpi2c_slave_config::enableSlave
 
uint8_t _lpi2c_slave_config::address0
 
uint8_t _lpi2c_slave_config::address1
 
lpi2c_slave_address_match_t _lpi2c_slave_config::addressMatchMode
 
bool _lpi2c_slave_config::filterDozeEnable
 
bool _lpi2c_slave_config::filterEnable
 
bool _lpi2c_slave_config::enableGeneralCall
 
bool   _lpi2c_slave_config::enableAck
 
bool   _lpi2c_slave_config::enableTx
 
bool   _lpi2c_slave_config::enableRx
 
bool   _lpi2c_slave_config::enableAddress
 
struct {
   bool   _lpi2c_slave_config::enableAck
 
   bool   _lpi2c_slave_config::enableTx
 
   bool   _lpi2c_slave_config::enableRx
 
   bool   _lpi2c_slave_config::enableAddress
 
_lpi2c_slave_config::sclStall
 
bool _lpi2c_slave_config::ignoreAck
 
bool _lpi2c_slave_config::enableReceivedAddressRead
 
uint32_t _lpi2c_slave_config::sdaGlitchFilterWidth_ns
 
uint32_t _lpi2c_slave_config::sclGlitchFilterWidth_ns
 
uint32_t _lpi2c_slave_config::dataValidDelay_ns
 
uint32_t _lpi2c_slave_config::clockHoldTime_ns
 
lpi2c_slave_transfer_event_t _lpi2c_slave_transfer::event
 
uint8_t _lpi2c_slave_transfer::receivedAddress
 
uint8_t * _lpi2c_slave_transfer::data
 
size_t _lpi2c_slave_transfer::dataSize
 
status_t _lpi2c_slave_transfer::completionStatus
 
size_t _lpi2c_slave_transfer::transferredCount
 
lpi2c_slave_transfer_t _lpi2c_slave_handle::transfer
 
bool _lpi2c_slave_handle::isBusy
 
bool _lpi2c_slave_handle::wasTransmit
 
uint32_t _lpi2c_slave_handle::eventMask
 
uint32_t _lpi2c_slave_handle::transferredCount
 
lpi2c_slave_transfer_callback_t _lpi2c_slave_handle::callback
 
void * _lpi2c_slave_handle::userData
 

Slave initialization and deinitialization

void LPI2C_SlaveGetDefaultConfig (lpi2c_slave_config_t *slaveConfig)
 Provides a default configuration for the LPI2C slave peripheral.
 
void LPI2C_SlaveInit (LPI2C_Type *base, const lpi2c_slave_config_t *slaveConfig, uint32_t sourceClock_Hz)
 Initializes the LPI2C slave peripheral.
 
void LPI2C_SlaveDeinit (LPI2C_Type *base)
 Deinitializes the LPI2C slave peripheral.
 

Slave bus operations

status_t LPI2C_SlaveSend (LPI2C_Type *base, void *txBuff, size_t txSize, size_t *actualTxSize)
 Performs a polling send transfer on the I2C bus.
 
status_t LPI2C_SlaveReceive (LPI2C_Type *base, void *rxBuff, size_t rxSize, size_t *actualRxSize)
 Performs a polling receive transfer on the I2C bus.
 

Slave non-blocking

void LPI2C_SlaveTransferCreateHandle (LPI2C_Type *base, lpi2c_slave_handle_t *handle, lpi2c_slave_transfer_callback_t callback, void *userData)
 Creates a new handle for the LPI2C slave non-blocking APIs.
 
status_t LPI2C_SlaveTransferNonBlocking (LPI2C_Type *base, lpi2c_slave_handle_t *handle, uint32_t eventMask)
 Starts accepting slave transfers.
 
status_t LPI2C_SlaveTransferGetCount (LPI2C_Type *base, lpi2c_slave_handle_t *handle, size_t *count)
 Gets the slave transfer status during a non-blocking transfer.
 
void LPI2C_SlaveTransferAbort (LPI2C_Type *base, lpi2c_slave_handle_t *handle)
 Aborts the slave non-blocking transfers.
 

Slave IRQ handler

void LPI2C_SlaveTransferHandleIRQ (LPI2C_Type *base, lpi2c_slave_handle_t *handle)
 Reusable routine to handle slave interrupts.
 

Detailed Description

Typedef Documentation

◆ lpi2c_slave_config_t

Structure with settings to initialize the LPI2C slave module.

This structure holds configuration settings for the LPI2C slave peripheral. To initialize this structure to reasonable defaults, call the LPI2C_SlaveGetDefaultConfig() function and pass a pointer to your configuration structure instance.

The configuration structure can be made constant so it resides in flash.

◆ lpi2c_slave_transfer_callback_t

typedef void(* lpi2c_slave_transfer_callback_t) (LPI2C_Type *base, lpi2c_slave_transfer_t *transfer, void *userData)

Slave event callback function pointer type.

This callback is used only for the slave non-blocking transfer API. To install a callback, use the LPI2C_SlaveSetCallback() function after you have created a handle.

Parameters
baseBase address for the LPI2C instance on which the event occurred.
transferPointer to transfer descriptor containing values passed to and/or from the callback.
userDataArbitrary pointer-sized value passed from the application.

◆ lpi2c_slave_transfer_event_t

Set of events sent to the callback for non blocking slave transfers.

These event enumerations are used for two related purposes. First, a bit mask created by OR'ing together events is passed to LPI2C_SlaveTransferNonBlocking() in order 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.

Enumeration Type Documentation

◆ _lpi2c_slave_address_match

LPI2C slave address match options.

Enumerator
kLPI2C_MatchAddress0 

Match only address 0.

kLPI2C_MatchAddress0OrAddress1 

Match either address 0 or address 1.

kLPI2C_MatchAddress0ThroughAddress1 

Match a range of slave addresses from address 0 through address 1.

◆ _lpi2c_slave_flags

LPI2C slave peripheral flags.

The following status register flags can be cleared:

All flags except kLPI2C_SlaveBusyFlag and kLPI2C_SlaveBusBusyFlag can be enabled as interrupts.

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

Transmit data flag

kLPI2C_SlaveRxReadyFlag 

Receive data flag

kLPI2C_SlaveAddressValidFlag 

Address valid flag

kLPI2C_SlaveTransmitAckFlag 

Transmit ACK flag

kLPI2C_SlaveRepeatedStartDetectFlag 

Repeated start detect flag

kLPI2C_SlaveStopDetectFlag 

Stop detect flag

kLPI2C_SlaveBitErrFlag 

Bit error flag

kLPI2C_SlaveFifoErrFlag 

FIFO error flag

kLPI2C_SlaveAddressMatch0Flag 

Address match 0 flag

kLPI2C_SlaveAddressMatch1Flag 

Address match 1 flag

kLPI2C_SlaveGeneralCallFlag 

General call flag

kLPI2C_SlaveBusyFlag 

Master busy flag

kLPI2C_SlaveBusBusyFlag 

Bus busy flag

kLPI2C_SlaveClearFlags 

All flags which are cleared by the driver upon starting a transfer.

kLPI2C_SlaveIrqFlags 

IRQ sources enabled by the non-blocking transactional API.

kLPI2C_SlaveErrorFlags 

Errors to check for.

◆ _lpi2c_slave_transfer_event

Set of events sent to the callback for non blocking slave transfers.

These event enumerations are used for two related purposes. First, a bit mask created by OR'ing together events is passed to LPI2C_SlaveTransferNonBlocking() in order 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
kLPI2C_SlaveAddressMatchEvent 

Received the slave address after a start or repeated start.

kLPI2C_SlaveTransmitEvent 

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

kLPI2C_SlaveReceiveEvent 

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

kLPI2C_SlaveTransmitAckEvent 

Callback needs to either transmit an ACK or NACK.

kLPI2C_SlaveRepeatedStartEvent 

A repeated start was detected.

kLPI2C_SlaveCompletionEvent 

A stop was detected, completing the transfer.

kLPI2C_SlaveAllEvents 

Bit mask of all available events.

Function Documentation

◆ LPI2C_SlaveDeinit()

void LPI2C_SlaveDeinit ( LPI2C_Type base)

Deinitializes the LPI2C slave peripheral.

This function disables the LPI2C slave peripheral and gates the clock. It also performs a software reset to restore the peripheral to reset conditions.

Parameters
baseThe LPI2C peripheral base address.

brief Deinitializes the LPI2C slave peripheral.

This function disables the LPI2C slave peripheral and gates the clock. It also performs a software reset to restore the peripheral to reset conditions.

param base The LPI2C peripheral base address.

◆ LPI2C_SlaveGetDefaultConfig()

void LPI2C_SlaveGetDefaultConfig ( lpi2c_slave_config_t slaveConfig)

Provides a default configuration for the LPI2C slave peripheral.

This function provides the following default configuration for the LPI2C slave peripheral:

slaveConfig->enableSlave = true;
slaveConfig->address0 = 0U;
slaveConfig->address1 = 0U;
slaveConfig->addressMatchMode = kLPI2C_MatchAddress0;
slaveConfig->filterDozeEnable = true;
slaveConfig->filterEnable = true;
slaveConfig->enableGeneralCall = false;
slaveConfig->sclStall.enableAck = false;
slaveConfig->sclStall.enableTx = true;
slaveConfig->sclStall.enableRx = true;
slaveConfig->sclStall.enableAddress = true;
slaveConfig->ignoreAck = false;
slaveConfig->enableReceivedAddressRead = false;
slaveConfig->sdaGlitchFilterWidth_ns = 0;
slaveConfig->sclGlitchFilterWidth_ns = 0;
slaveConfig->dataValidDelay_ns = 0;
slaveConfig->clockHoldTime_ns = 0;
@ kLPI2C_MatchAddress0
Definition: fsl_lpi2c.h:314

After calling this function, override any settings to customize the configuration, prior to initializing the master driver with LPI2C_SlaveInit(). Be sure to override at least the address0 member of the configuration structure with the desired slave address.

Parameters
[out]slaveConfigUser provided configuration structure that is set to default values. Refer to lpi2c_slave_config_t.

brief Provides a default configuration for the LPI2C slave peripheral.

This function provides the following default configuration for the LPI2C slave peripheral: code slaveConfig->enableSlave = true; slaveConfig->address0 = 0U; slaveConfig->address1 = 0U; slaveConfig->addressMatchMode = kLPI2C_MatchAddress0; slaveConfig->filterDozeEnable = true; slaveConfig->filterEnable = true; slaveConfig->enableGeneralCall = false; slaveConfig->sclStall.enableAck = false; slaveConfig->sclStall.enableTx = true; slaveConfig->sclStall.enableRx = true; slaveConfig->sclStall.enableAddress = true; slaveConfig->ignoreAck = false; slaveConfig->enableReceivedAddressRead = false; slaveConfig->sdaGlitchFilterWidth_ns = 0; slaveConfig->sclGlitchFilterWidth_ns = 0; slaveConfig->dataValidDelay_ns = 0; slaveConfig->clockHoldTime_ns = 0; endcode

After calling this function, override any settings to customize the configuration, prior to initializing the master driver with LPI2C_SlaveInit(). Be sure to override at least the a address0 member of the configuration structure with the desired slave address.

param[out] slaveConfig User provided configuration structure that is set to default values. Refer to lpi2c_slave_config_t.

◆ LPI2C_SlaveInit()

void LPI2C_SlaveInit ( LPI2C_Type base,
const lpi2c_slave_config_t slaveConfig,
uint32_t  sourceClock_Hz 
)

Initializes the LPI2C slave peripheral.

This function enables the peripheral clock and initializes the LPI2C slave peripheral as described by the user provided configuration.

Parameters
baseThe LPI2C peripheral base address.
slaveConfigUser provided peripheral configuration. Use LPI2C_SlaveGetDefaultConfig() to get a set of defaults that you can override.
sourceClock_HzFrequency in Hertz of the LPI2C functional clock. Used to calculate the filter widths, data valid delay, and clock hold time.

brief Initializes the LPI2C slave peripheral.

This function enables the peripheral clock and initializes the LPI2C slave peripheral as described by the user provided configuration.

param base The LPI2C peripheral base address. param slaveConfig User provided peripheral configuration. Use LPI2C_SlaveGetDefaultConfig() to get a set of defaults that you can override. param sourceClock_Hz Frequency in Hertz of the LPI2C functional clock. Used to calculate the filter widths, data valid delay, and clock hold time.

◆ LPI2C_SlaveReceive()

status_t LPI2C_SlaveReceive ( LPI2C_Type base,
void *  rxBuff,
size_t  rxSize,
size_t *  actualRxSize 
)

Performs a polling receive transfer on the I2C bus.

Parameters
baseThe LPI2C peripheral base address.
rxBuffThe pointer to the data to be transferred.
rxSizeThe length in bytes of the data to be transferred.
[out]actualRxSize
Returns
Error or success status returned by API.

brief Performs a polling receive transfer on the I2C bus.

param base The LPI2C peripheral base address. param rxBuff The pointer to the data to be transferred. param rxSize The length in bytes of the data to be transferred. param[out] actualRxSize return Error or success status returned by API.

◆ LPI2C_SlaveSend()

status_t LPI2C_SlaveSend ( LPI2C_Type base,
void *  txBuff,
size_t  txSize,
size_t *  actualTxSize 
)

Performs a polling send transfer on the I2C bus.

Parameters
baseThe LPI2C peripheral base address.
txBuffThe pointer to the data to be transferred.
txSizeThe length in bytes of the data to be transferred.
[out]actualTxSize
Returns
Error or success status returned by API.

brief Performs a polling send transfer on the I2C bus.

param base The LPI2C peripheral base address. param txBuff The pointer to the data to be transferred. param txSize The length in bytes of the data to be transferred. param[out] actualTxSize return Error or success status returned by API.

◆ LPI2C_SlaveTransferAbort()

void LPI2C_SlaveTransferAbort ( LPI2C_Type base,
lpi2c_slave_handle_t handle 
)

Aborts the slave non-blocking transfers.

Note
This API could be called at any time to stop slave for handling the bus events.
Parameters
baseThe LPI2C peripheral base address.
handlePointer to lpi2c_slave_handle_t structure which stores the transfer state.
Return values
kStatus_Success
kStatus_LPI2C_Idle

brief Aborts the slave non-blocking transfers. note This API could be called at any time to stop slave for handling the bus events. param base The LPI2C peripheral base address. param handle Pointer to lpi2c_slave_handle_t structure which stores the transfer state. retval kStatus_Success retval kStatus_LPI2C_Idle

◆ LPI2C_SlaveTransferCreateHandle()

void LPI2C_SlaveTransferCreateHandle ( LPI2C_Type base,
lpi2c_slave_handle_t handle,
lpi2c_slave_transfer_callback_t  callback,
void *  userData 
)

Creates a new handle for the LPI2C slave non-blocking APIs.

The creation of a handle is for use with the non-blocking APIs. Once a handle is created, there is not a corresponding destroy handle. If the user wants to terminate a transfer, the LPI2C_SlaveTransferAbort() API shall be called.

Note
The function also enables the NVIC IRQ for the input LPI2C. Need to notice that on some SoCs the LPI2C IRQ is connected to INTMUX, in this case user needs to enable the associated INTMUX IRQ in application.
Parameters
baseThe LPI2C peripheral base address.
[out]handlePointer to the LPI2C slave driver handle.
callbackUser provided pointer to the asynchronous callback function.
userDataUser provided pointer to the application callback data.

brief Creates a new handle for the LPI2C slave non-blocking APIs.

The creation of a handle is for use with the non-blocking APIs. Once a handle is created, there is not a corresponding destroy handle. If the user wants to terminate a transfer, the LPI2C_SlaveTransferAbort() API shall be called.

note The function also enables the NVIC IRQ for the input LPI2C. Need to notice that on some SoCs the LPI2C IRQ is connected to INTMUX, in this case user needs to enable the associated INTMUX IRQ in application.

param base The LPI2C peripheral base address. param[out] handle Pointer to the LPI2C slave driver handle. param callback User provided pointer to the asynchronous callback function. param userData User provided pointer to the application callback data.

◆ LPI2C_SlaveTransferGetCount()

status_t LPI2C_SlaveTransferGetCount ( LPI2C_Type base,
lpi2c_slave_handle_t handle,
size_t *  count 
)

Gets the slave transfer status during a non-blocking transfer.

Parameters
baseThe LPI2C peripheral base address.
handlePointer to i2c_slave_handle_t structure.
[out]countPointer to a value to hold the number of bytes transferred. May be NULL if the count is not required.
Return values
kStatus_Success
kStatus_NoTransferInProgress

brief Gets the slave transfer status during a non-blocking transfer. param base The LPI2C peripheral base address. param handle Pointer to i2c_slave_handle_t structure. param[out] count Pointer to a value to hold the number of bytes transferred. May be NULL if the count is not required. retval kStatus_Success retval kStatus_NoTransferInProgress

◆ LPI2C_SlaveTransferHandleIRQ()

void LPI2C_SlaveTransferHandleIRQ ( LPI2C_Type base,
lpi2c_slave_handle_t handle 
)

Reusable routine to handle slave interrupts.

Note
This function does not need to be called unless you are reimplementing the non blocking API's interrupt handler routines to add special functionality.
Parameters
baseThe LPI2C peripheral base address.
handlePointer to lpi2c_slave_handle_t structure which stores the transfer state.

brief Reusable routine to handle slave interrupts. note This function does not need to be called unless you are reimplementing the non blocking API's interrupt handler routines to add special functionality. param base The LPI2C peripheral base address. param handle Pointer to lpi2c_slave_handle_t structure which stores the transfer state.

◆ LPI2C_SlaveTransferNonBlocking()

status_t LPI2C_SlaveTransferNonBlocking ( LPI2C_Type base,
lpi2c_slave_handle_t handle,
uint32_t  eventMask 
)

Starts accepting slave transfers.

Call this API after calling I2C_SlaveInit() and LPI2C_SlaveTransferCreateHandle() to start processing transactions driven by an I2C master. The slave monitors the I2C bus and pass events to the callback that was passed into the call to LPI2C_SlaveTransferCreateHandle(). 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 lpi2c_slave_transfer_event_t enumerators for the events you wish to receive. The kLPI2C_SlaveTransmitEvent and kLPI2C_SlaveReceiveEvent events are always enabled and do not need to be included in the mask. Alternatively, you can pass 0 to get a default set of only the transmit and receive events that are always enabled. In addition, the kLPI2C_SlaveAllEvents constant is provided as a convenient way to enable all events.

Parameters
baseThe LPI2C peripheral base address.
handlePointer to lpi2c_slave_handle_t structure which stores the transfer state.
eventMaskBit mask formed by OR'ing together lpi2c_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 kLPI2C_SlaveAllEvents to enable all events.
Return values
kStatus_SuccessSlave transfers were successfully started.
kStatus_LPI2C_BusySlave transfers have already been started on this handle.

brief Starts accepting slave transfers.

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

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

param base The LPI2C peripheral base address. param handle Pointer to lpi2c_slave_handle_t structure which stores the transfer state. param eventMask Bit mask formed by OR'ing together lpi2c_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 kLPI2C_SlaveAllEvents to enable all events.

retval kStatus_Success Slave transfers were successfully started. retval kStatus_LPI2C_Busy Slave transfers have already been started on this handle.

Variable Documentation

◆ address0

uint8_t _lpi2c_slave_config::address0

Slave's 7-bit address.

◆ address1

uint8_t _lpi2c_slave_config::address1

Alternate slave 7-bit address.

◆ addressMatchMode

lpi2c_slave_address_match_t _lpi2c_slave_config::addressMatchMode

Address matching options.

◆ baudRate_Hz

uint32_t _lpi2c_master_config::baudRate_Hz

Desired baud rate in Hertz.

◆ buf

uint8_t* _lpi2c_master_handle::buf

Buffer pointer for current state.

◆ busIdleTimeout_ns

uint32_t _lpi2c_master_config::busIdleTimeout_ns

Bus idle timeout in nanoseconds. Set to 0 to disable.

◆ callback

lpi2c_slave_transfer_callback_t _lpi2c_slave_handle::callback

Callback function called at transfer event.

◆ clockHoldTime_ns

uint32_t _lpi2c_slave_config::clockHoldTime_ns

Width in nanoseconds of the clock hold time.

◆ commandBuffer

uint16_t _lpi2c_master_handle::commandBuffer[6]

LPI2C command sequence. When all 6 command words are used: Start&addr&write[1 word] + subaddr[4 words] + restart&addr&read[1 word]

◆ completionCallback

lpi2c_master_transfer_callback_t _lpi2c_master_handle::completionCallback

Callback function pointer.

◆ completionStatus

status_t _lpi2c_slave_transfer::completionStatus

Success or error code describing how the transfer completed. Only applies for kLPI2C_SlaveCompletionEvent.

◆ data [1/2]

void* _lpi2c_master_transfer::data

Pointer to data to transfer.

◆ data [2/2]

uint8_t* _lpi2c_slave_transfer::data

Transfer buffer

◆ dataSize [1/2]

size_t _lpi2c_master_transfer::dataSize

Number of bytes to transfer.

◆ dataSize [2/2]

size_t _lpi2c_slave_transfer::dataSize

Transfer size

◆ dataValidDelay_ns

uint32_t _lpi2c_slave_config::dataValidDelay_ns

Width in nanoseconds of the data valid delay.

◆ debugEnable

bool _lpi2c_master_config::debugEnable

Enable transfers to continue when halted in debug mode.

◆ direction

lpi2c_direction_t _lpi2c_master_transfer::direction

◆ enable [1/2]

bool _lpi2c_master_config::enable

Enable host request.

◆  [2/2]

bool { ... } ::enable

Enable host request.

◆  [1/2]

bool { ... } ::enableAck

Enables SCL clock stretching during slave-transmit address byte(s) and slave-receiver address and data byte(s) to allow software to write the Transmit ACK Register before the ACK or NACK is transmitted. Clock stretching occurs when transmitting the 9th bit. When enableAckSCLStall is enabled, there is no need to set either enableRxDataSCLStall or enableAddressSCLStall.

◆ enableAck [2/2]

bool _lpi2c_slave_config::enableAck

Enables SCL clock stretching during slave-transmit address byte(s) and slave-receiver address and data byte(s) to allow software to write the Transmit ACK Register before the ACK or NACK is transmitted. Clock stretching occurs when transmitting the 9th bit. When enableAckSCLStall is enabled, there is no need to set either enableRxDataSCLStall or enableAddressSCLStall.

◆  [1/2]

bool { ... } ::enableAddress

Enables SCL clock stretching when the address valid flag is asserted.

◆ enableAddress [2/2]

bool _lpi2c_slave_config::enableAddress

Enables SCL clock stretching when the address valid flag is asserted.

◆ enableDoze

bool _lpi2c_master_config::enableDoze

Whether master is enabled in doze mode.

◆ enableGeneralCall

bool _lpi2c_slave_config::enableGeneralCall

Enable general call address matching.

◆ enableMaster

bool _lpi2c_master_config::enableMaster

Whether to enable master mode.

◆ enableReceivedAddressRead

bool _lpi2c_slave_config::enableReceivedAddressRead

Enable reading the address received address as the first byte of data.

◆  [1/2]

bool { ... } ::enableRx

Enables SCL clock stretching when receive data flag is set during a slave-receive transfer.

◆ enableRx [2/2]

bool _lpi2c_slave_config::enableRx

Enables SCL clock stretching when receive data flag is set during a slave-receive transfer.

◆ enableSlave

bool _lpi2c_slave_config::enableSlave

Enable slave mode.

◆ enableTx [1/2]

bool _lpi2c_slave_config::enableTx

Enables SCL clock stretching when the transmit data flag is set during a slave-transmit transfer.

◆  [2/2]

bool { ... } ::enableTx

Enables SCL clock stretching when the transmit data flag is set during a slave-transmit transfer.

◆ event

lpi2c_slave_transfer_event_t _lpi2c_slave_transfer::event

Reason the callback is being invoked.

◆ eventMask

uint32_t _lpi2c_slave_handle::eventMask

Mask of enabled events.

◆ filterDozeEnable

bool _lpi2c_slave_config::filterDozeEnable

Enable digital glitch filter in doze mode.

◆ filterEnable

bool _lpi2c_slave_config::filterEnable

Enable digital glitch filter.

◆ flags

uint32_t _lpi2c_master_transfer::flags

Bit mask of options for the transfer. See enumeration _lpi2c_master_transfer_flags for available options. Set to 0 or kLPI2C_TransferDefaultFlag for normal transfers.

◆ 

struct { ... } _lpi2c_master_config::hostRequest

Host request options.

◆ ignoreAck [1/2]

bool _lpi2c_master_config::ignoreAck

Whether to ignore ACK/NACK.

◆ ignoreAck [2/2]

bool _lpi2c_slave_config::ignoreAck

Continue transfers after a NACK is detected.

◆ isBusy

bool _lpi2c_slave_handle::isBusy

Whether transfer is busy.

◆ match0

uint32_t _lpi2c_match_config::match0

Match value 0.

◆ match1

uint32_t _lpi2c_match_config::match1

Match value 1.

◆ matchMode

lpi2c_data_match_config_mode_t _lpi2c_match_config::matchMode

Data match configuration setting.

◆ pinConfig

lpi2c_master_pin_config_t _lpi2c_master_config::pinConfig

The pin configuration option.

◆ pinLowTimeout_ns

uint32_t _lpi2c_master_config::pinLowTimeout_ns

Pin low timeout in nanoseconds. Set to 0 to disable.

◆  [1/2]

lpi2c_host_request_polarity_t { ... } ::polarity

Host request pin polarity.

◆ polarity [2/2]

lpi2c_host_request_polarity_t _lpi2c_master_config::polarity

Host request pin polarity.

◆ receivedAddress

uint8_t _lpi2c_slave_transfer::receivedAddress

Matching address send by master.

◆ remainingBytes

uint16_t _lpi2c_master_handle::remainingBytes

Remaining byte count in current state.

◆ rxDataMatchOnly

bool _lpi2c_match_config::rxDataMatchOnly

When set to true, received data is ignored until a successful match.

◆ sclGlitchFilterWidth_ns [1/2]

uint8_t _lpi2c_master_config::sclGlitchFilterWidth_ns

Width in nanoseconds of glitch filter on SCL pin. Set to 0 to disable.

◆ sclGlitchFilterWidth_ns [2/2]

uint32_t _lpi2c_slave_config::sclGlitchFilterWidth_ns

Width in nanoseconds of the digital filter on the SCL signal. Set to 0 to disable.

◆ sdaGlitchFilterWidth_ns [1/2]

uint8_t _lpi2c_master_config::sdaGlitchFilterWidth_ns

Width in nanoseconds of glitch filter on SDA pin. Set to 0 to disable.

◆ sdaGlitchFilterWidth_ns [2/2]

uint32_t _lpi2c_slave_config::sdaGlitchFilterWidth_ns

Width in nanoseconds of the digital filter on the SDA signal. Set to 0 to disable.

◆ slaveAddress

uint16_t _lpi2c_master_transfer::slaveAddress

The 7-bit slave address.

◆  [1/2]

lpi2c_host_request_source_t { ... } ::source

Host request source.

◆ source [2/2]

lpi2c_host_request_source_t _lpi2c_master_config::source

Host request source.

◆ state

uint8_t _lpi2c_master_handle::state

Transfer state machine current state.

◆ subaddress

uint32_t _lpi2c_master_transfer::subaddress

Sub address. Transferred MSB first.

◆ subaddressSize

size_t _lpi2c_master_transfer::subaddressSize

Length of sub address to send in bytes. Maximum size is 4 bytes.

◆ transfer [1/2]

lpi2c_master_transfer_t _lpi2c_master_handle::transfer

Copy of the current transfer info.

◆ transfer [2/2]

lpi2c_slave_transfer_t _lpi2c_slave_handle::transfer

LPI2C slave transfer copy.

◆ transferredCount [1/2]

size_t _lpi2c_slave_transfer::transferredCount

Number of bytes actually transferred since start or last repeated start.

◆ transferredCount [2/2]

uint32_t _lpi2c_slave_handle::transferredCount

Count of bytes transferred.

◆ userData [1/2]

void* _lpi2c_master_handle::userData

Application data passed to callback.

◆ userData [2/2]

void* _lpi2c_slave_handle::userData

Callback parameter passed to callback.

◆ wasTransmit

bool _lpi2c_slave_handle::wasTransmit

Whether the last transfer was a transmit.