![]() |
Kinetis Bootloader
2.0.0
Common bootloader for Kinetis devices
|
Data Structures | |
| struct | i2c_master_config_t |
| I2C master user config. More... | |
| struct | i2c_slave_config_t |
| I2C slave user config. More... | |
| struct | i2c_master_transfer_t |
| I2C master transfer structure. More... | |
| struct | i2c_master_handle_t |
| I2C master handle structure. More... | |
| struct | i2c_slave_transfer_t |
| I2C slave transfer structure. More... | |
| struct | i2c_slave_handle_t |
| I2C slave handle structure. More... | |
Typedefs | |
| typedef void(* | i2c_master_transfer_callback_t) (I2C_Type *base, i2c_master_handle_t *handle, status_t status, void *userData) |
| I2C master transfer callback typedef. | |
| typedef void(* | i2c_slave_transfer_callback_t) (I2C_Type *base, i2c_slave_transfer_t *xfer, void *userData) |
| I2C slave transfer callback typedef. | |
Enumerations | |
| enum | _i2c_status { kStatus_I2C_Busy = MAKE_STATUS(kStatusGroup_I2C, 0), kStatus_I2C_Idle = MAKE_STATUS(kStatusGroup_I2C, 1), kStatus_I2C_Nak = MAKE_STATUS(kStatusGroup_I2C, 2), kStatus_I2C_ArbitrationLost = MAKE_STATUS(kStatusGroup_I2C, 3), kStatus_I2C_Timeout = MAKE_STATUS(kStatusGroup_I2C, 4) } |
| I2C status return codes. More... | |
| enum | _i2c_flags { kI2C_ReceiveNakFlag = I2C_S_RXAK_MASK, kI2C_IntPendingFlag = I2C_S_IICIF_MASK, kI2C_TransferDirectionFlag = I2C_S_SRW_MASK, kI2C_RangeAddressMatchFlag = I2C_S_RAM_MASK, kI2C_ArbitrationLostFlag = I2C_S_ARBL_MASK, kI2C_BusBusyFlag = I2C_S_BUSY_MASK, kI2C_AddressMatchFlag = I2C_S_IAAS_MASK, kI2C_TransferCompleteFlag = I2C_S_TCF_MASK, kI2C_StopDetectFlag = I2C_FLT_STOPF_MASK << 8, kI2C_StartDetectFlag = I2C_FLT_STARTF_MASK << 8 } |
| I2C peripheral flags. More... | |
| enum | _i2c_interrupt_enable { kI2C_GlobalInterruptEnable = I2C_C1_IICIE_MASK, kI2C_StopDetectInterruptEnable = I2C_FLT_STOPIE_MASK, kI2C_StartStopDetectInterruptEnable = I2C_FLT_SSIE_MASK } |
| I2C feature interrupt source. More... | |
| enum | i2c_direction_t { kI2C_Write = 0x0U, kI2C_Read = 0x1U } |
| Direction of master and slave transfers. More... | |
| enum | i2c_slave_address_mode_t { kI2C_Address7bit = 0x0U, kI2C_RangeMatch = 0X2U } |
| Addressing mode. More... | |
| enum | _i2c_master_transfer_flags { kI2C_TransferDefaultFlag = 0x0U, kI2C_TransferNoStartFlag = 0x1U, kI2C_TransferRepeatedStartFlag = 0x2U, kI2C_TransferNoStopFlag = 0x4U } |
| I2C transfer control flag. More... | |
| enum | i2c_slave_transfer_event_t { kI2C_SlaveAddressMatchEvent = 0x01U, kI2C_SlaveTransmitEvent = 0x02U, kI2C_SlaveReceiveEvent = 0x04U, kI2C_SlaveTransmitAckEvent = 0x08U, kI2C_SlaveRepeatedStartEvent = 0x10U, kI2C_SlaveCompletionEvent = 0x20U, kI2C_SlaveAllEvents } |
| Set of events sent to the callback for nonblocking slave transfers. More... | |
Initialization and deinitialization | |
| void | I2C_MasterInit (I2C_Type *base, const i2c_master_config_t *masterConfig, uint32_t srcClock_Hz) |
| Initialize the I2C peripheral, call this API to ungate the i2c clock and configure the I2C with master configuration. More... | |
| void | I2C_SlaveInit (I2C_Type *base, const i2c_slave_config_t *slaveConfig) |
| Initialize the I2C peripheral, call this API to ungate the i2c clock and initializes the I2C with slave configuration. More... | |
| void | I2C_MasterDeinit (I2C_Type *base) |
| De-initialize the I2C master peripheral, call thi API will gate the i2c clock, so the I2C master module can not work unless call I2C_MasterInit. More... | |
| void | I2C_SlaveDeinit (I2C_Type *base) |
| De-initialize the I2C slave peripheral, call thi API will gate the i2c clock, so the I2C slave module can not work unless call I2C_SlaveInit to enable the clock. More... | |
| void | I2C_MasterGetDefaultConfig (i2c_master_config_t *masterConfig) |
| Set the I2C master configuration structure to default values. More... | |
| void | I2C_SlaveGetDefaultConfig (i2c_slave_config_t *slaveConfig) |
| Set the I2C slave configuration structure to default values. More... | |
| static void | I2C_Enable (I2C_Type *base, bool enable) |
| Enable or disables the I2C peripheral operation. More... | |
Status | |
| uint32_t | I2C_MasterGetStatusFlags (I2C_Type *base) |
| Gets the I2C status flags. More... | |
| static uint32_t | I2C_SlaveGetStatusFlags (I2C_Type *base) |
| Gets the I2C status flags. More... | |
| static void | I2C_MasterClearStatusFlags (I2C_Type *base, uint32_t statusMask) |
| Clears the I2C status flag state. More... | |
| static void | I2C_SlaveClearStatusFlags (I2C_Type *base, uint32_t statusMask) |
| Clears the I2C status flag state. More... | |
Interrupts | |
| void | I2C_EnableInterrupts (I2C_Type *base, uint32_t mask) |
| Enable I2C interrupt requests. More... | |
| void | I2C_DisableInterrupts (I2C_Type *base, uint32_t mask) |
| Disable I2C interrupt requests. More... | |
DMA Control | |
| static void | I2C_EnableDMA (I2C_Type *base, bool enable) |
| Enables/disables the I2C DMA interrupt. More... | |
| static uint32_t | I2C_GetDataRegAddr (I2C_Type *base) |
| Get I2C tx/rx data register address This API is used to provide transfer address for I2C DMA transfer configuration. More... | |
Bus Operations | |
| void | I2C_MasterSetBaudRate (I2C_Type *base, uint32_t baudRate_Bps, uint32_t srcClock_Hz) |
| Sets the I2C master transfer baudrate. More... | |
| status_t | I2C_MasterStart (I2C_Type *base, uint8_t address, i2c_direction_t direction) |
| Sends a START on the I2C bus. More... | |
| status_t | I2C_MasterStop (I2C_Type *base) |
| Sends a STOP signal on the I2C bus. More... | |
| status_t | I2C_MasterRepeatedStart (I2C_Type *base, uint8_t address, i2c_direction_t direction) |
| Sends a REPEATED START on the I2C bus. More... | |
| status_t | I2C_MasterWriteBlocking (I2C_Type *base, const uint8_t *txBuff, size_t txSize) |
| Performs a polling send transaction on the I2C bus without a STOP signal. More... | |
| status_t | I2C_MasterReadBlocking (I2C_Type *base, uint8_t *rxBuff, size_t rxSize) |
| Performs a polling receive transaction on the I2C bus with a STOP signal. More... | |
| status_t | I2C_SlaveWriteBlocking (I2C_Type *base, const uint8_t *txBuff, size_t txSize) |
| Performs a polling send transaction on the I2C bus. More... | |
| void | I2C_SlaveReadBlocking (I2C_Type *base, uint8_t *rxBuff, size_t rxSize) |
| Performs a polling receive transaction on the I2C bus. More... | |
| status_t | I2C_MasterTransferBlocking (I2C_Type *base, i2c_master_transfer_t *xfer) |
| Performs a master polling transfer on the I2C bus. More... | |
Transactional | |
| void | I2C_MasterTransferCreateHandle (I2C_Type *base, i2c_master_handle_t *handle, i2c_master_transfer_callback_t callback, void *userData) |
| Init the I2C handle which is used in transactional functions. More... | |
| status_t | I2C_MasterTransferNonBlocking (I2C_Type *base, i2c_master_handle_t *handle, i2c_master_transfer_t *xfer) |
| Performs a master interrupt non-blocking transfer on the I2C bus. More... | |
| status_t | I2C_MasterTransferGetCount (I2C_Type *base, i2c_master_handle_t *handle, size_t *count) |
| Get master transfer status during a interrupt non-blocking transfer. More... | |
| void | I2C_MasterTransferAbort (I2C_Type *base, i2c_master_handle_t *handle) |
| Abort a interrupt non-blocking transfer in a early time. More... | |
| void | I2C_MasterTransferHandleIRQ (I2C_Type *base, void *i2cHandle) |
| Master interrupt handler. More... | |
| void | I2C_SlaveTransferCreateHandle (I2C_Type *base, i2c_slave_handle_t *handle, i2c_slave_transfer_callback_t callback, void *userData) |
| Init the I2C handle which is used in transcational functions. More... | |
| status_t | I2C_SlaveTransferNonBlocking (I2C_Type *base, i2c_slave_handle_t *handle, uint32_t eventMask) |
| Start accepting slave transfers. More... | |
| void | I2C_SlaveTransferAbort (I2C_Type *base, i2c_slave_handle_t *handle) |
| Abort slave transfer. More... | |
| status_t | I2C_SlaveTransferGetCount (I2C_Type *base, i2c_slave_handle_t *handle, size_t *count) |
| Get slave transfer remaining bytes during a interrupt non-blocking transfer. More... | |
| void | I2C_SlaveTransferHandleIRQ (I2C_Type *base, void *i2cHandle) |
| Slave interrupt handler. More... | |
The KSDK provides a peripheral driver for the Inter-Integrated Circuit (I2C) module of Kinetis devices.
The I2C driver includes functional APIs and transactional APIs.
Functional APIs are feature/property target low level APIs. Functional APIs can be used for the I2C master/slave initialization/configuration/operation for optimization/customization purpose. Using the functional APIs requires the knowledge of the I2C master peripheral and how to organize functional APIs to meet the application requirements. The I2C functional operation groups provide the functional APIs set.
Transactional APIs are transaction target high level APIs. The transactional APIs can be used to enable the peripheral quickly and also in the application if the code size and performance of transactional APIs satisfy the requirements. If the code size and performance are critical requirements, see the transactional API implementation and write custom code using the functional APIs or accessing the hardware registers.
Transactional APIs support asynchronous transfer. This means that the functions I2C_MasterTransferNonBlocking() set up the interrupt non-blocking transfer. When the transfer completes, the upper layer is notified through a callback function with the status.
The function I2C_MasterInit()/I2C_SlaveInit() initializes the I2C master/slave with a specified configurations. The function I2C_MasterGetDefaultConfig()/I2C_SlaveGetDefaultConfig() gets the default configurations.
Provides functions to get and clear the I2C master/slave status.
Provides functions to enable/disable I2C interrupts.
Provides functions for I2C to enable/disable generate the DMA request.
Provides functions to generate bus control signals, start/re-start/stop, write/read data. Additionally, provides functions to set baud rate.
Provides functions to transfer data through interrupt or dma.
| struct i2c_master_config_t |
I2C master user config.
| struct i2c_slave_config_t |
I2C slave user config.
| Data Fields | ||
|---|---|---|
| i2c_slave_address_mode_t | addressingMode |
Addressing mode configuration of i2c_slave_address_mode_config_t. |
| bool | enableBaudRateCtl |
Enables/disables independent slave baudrate on SCL in very fast I2C modes. |
| bool | enableGeneralCall |
Enable general call addressing mode. |
| bool | enableHighDrive |
Controls the drive capability of the I2C pads. |
| bool | enableSlave |
Enables the I2C periperhal at init time. |
| bool | enableWakeUp |
Enables/disables waking up MCU from low power mode. |
| uint16_t | slaveAddress |
Slave address configuration. |
| uint16_t | upperAddress |
Maximum boundary slave address used in range matching mode. |
| struct i2c_master_transfer_t |
I2C master transfer structure.
| Data Fields | ||
|---|---|---|
| uint8_t *volatile | data |
Transfer buffer. |
| volatile size_t | dataSize |
Transfer size. |
| i2c_direction_t | direction |
Transfer direction, read or write. |
| uint32_t | flags |
Transfer flag which controls the transfer. |
| uint8_t | slaveAddress |
7-bit slave address. |
| uint32_t | subaddress |
Subaddress. Transferred MSB first. |
| uint8_t | subaddressSize |
Size of command buffer. |
| struct _i2c_master_handle |
I2C master handle structure.
I2C master handle typedef.
Collaboration diagram for i2c_master_handle_t:| Data Fields | ||
|---|---|---|
| i2c_master_transfer_callback_t | completionCallback |
Callback function called when transfer finished. |
| uint8_t | state |
Transfer state maintained during transfer. |
| i2c_master_transfer_t | transfer |
I2C master transfer copy. |
| size_t | transferSize |
Total bytes to be transferred. |
| void * | userData |
Callback parameter passed to callback function. |
| struct i2c_slave_transfer_t |
I2C slave transfer structure.
| Data Fields | ||
|---|---|---|
| status_t | completionStatus |
Success or error code describing how the transfer completed. Only applies for kI2C_SlaveCompletionEvent. |
| uint8_t *volatile | data |
Transfer buffer. |
| volatile size_t | dataSize |
Transfer size. |
| i2c_slave_transfer_event_t | event |
Reason the callback is being invoked. |
| size_t | transferredCount |
Number of bytes actually transferred since start or last repeated start. |
| struct _i2c_slave_handle |
I2C slave handle structure.
I2C slave handle typedef.
Collaboration diagram for i2c_slave_handle_t:| Data Fields | ||
|---|---|---|
| i2c_slave_transfer_callback_t | callback |
Callback function called at transfer event. |
| uint32_t | eventMask |
Mask of enabled events. |
| bool | isBusy |
Whether transfer is busy. |
| i2c_slave_transfer_t | transfer |
I2C slave transfer copy. |
| void * | userData |
Callback parameter passed to callback. |
| enum _i2c_flags |
I2C peripheral flags.
The following status register flags can be cleared:
I2C transfer control flag.
| enum _i2c_status |
| enum i2c_direction_t |
Set of events sent to the callback for nonblocking slave transfers.
These event enums are used for two related purposes. First, a bit mask created by OR'ing together events is passed to I2C_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.
| void I2C_DisableInterrupts | ( | I2C_Type * | base, |
| uint32_t | mask | ||
| ) |
Disable I2C interrupt requests.
| base | I2C base pointer |
| mask | interrupt source The parameter can be combination of the following source if defined:
|
|
inlinestatic |
Enable or disables the I2C peripheral operation.
| base | I2C base pointer |
| enable | pass true to enable module, false to disable module |
|
inlinestatic |
Enables/disables the I2C DMA interrupt.
| base | I2C base pointer |
| enable | true for enable, false for diable |
| void I2C_EnableInterrupts | ( | I2C_Type * | base, |
| uint32_t | mask | ||
| ) |
Enable I2C interrupt requests.
| base | I2C base pointer |
| mask | interrupt source The parameter can be combination of the following source if defined:
|
|
inlinestatic |
Get I2C tx/rx data register address This API is used to provide transfer address for I2C DMA transfer configuration.
| base | I2C base pointer |
|
inlinestatic |
Clears the I2C status flag state.
The following status register flags can be cleared: kI2C_ArbitrationLostFlag and kI2C_IntPendingFlag
| base | I2C base pointer |
| statusMask | The status flag mask, defined in type i2c_status_flag_t. The parameter could be any combination of the following values:
|
| void I2C_MasterDeinit | ( | I2C_Type * | base | ) |
De-initialize the I2C master peripheral, call thi API will gate the i2c clock, so the I2C master module can not work unless call I2C_MasterInit.
| base | I2C base pointer |
| void I2C_MasterGetDefaultConfig | ( | i2c_master_config_t * | masterConfig | ) |
Set the I2C master configuration structure to default values.
The purpose of this API is to get the config structure initialized for use in I2C_MasterConfigure(). User may use the initialized structure unchanged in I2C_MasterConfigure(), or modify some fields of the structure before calling I2C_MasterConfigure(). Example:
| masterConfig | Pointer to the master config structure. |
| uint32_t I2C_MasterGetStatusFlags | ( | I2C_Type * | base | ) |
Gets the I2C status flags.
| base | I2C base pointer |
| void I2C_MasterInit | ( | I2C_Type * | base, |
| const i2c_master_config_t * | masterConfig, | ||
| uint32_t | srcClock_Hz | ||
| ) |
Initialize the I2C peripheral, call this API to ungate the i2c clock and configure the I2C with master configuration.
| base | I2C base pointer |
| masterConfig | pointer to master config structure |
| srcClock_Hz | I2C pheripharal clock frequency in HZ |
| status_t I2C_MasterReadBlocking | ( | I2C_Type * | base, |
| uint8_t * | rxBuff, | ||
| size_t | rxSize | ||
| ) |
Performs a polling receive transaction on the I2C bus with a STOP signal.
| base | I2C peripheral base pointer. |
| rxBuff | The pointer to the data to store the received data. |
| rxSize | The length in bytes of the data to be received. |
| kStatus_Success | Sucessully complete the data transmission. |
| kStatus_I2C_Timeout | Send stop signal failed, timeout. |
| status_t I2C_MasterRepeatedStart | ( | I2C_Type * | base, |
| uint8_t | address, | ||
| i2c_direction_t | direction | ||
| ) |
Sends a REPEATED START on the I2C bus.
| base | I2C peripheral base pointer |
| address | 7-bit slave device address. |
| direction | Master transfer directions(transmit/receive). |
| kStatus_Success | Sucessully send the start signal. |
| kStatus_I2C_Busy | Current bus is busy but not occupied by current i2c master. |
| void I2C_MasterSetBaudRate | ( | I2C_Type * | base, |
| uint32_t | baudRate_Bps, | ||
| uint32_t | srcClock_Hz | ||
| ) |
Sets the I2C master transfer baudrate.
| base | I2C base pointer |
| baudRate_Bps | the baud rate value in bps |
| srcClock_Hz | Source clock |
| status_t I2C_MasterStart | ( | I2C_Type * | base, |
| uint8_t | address, | ||
| i2c_direction_t | direction | ||
| ) |
Sends a START on the I2C bus.
This function is used to initiate a new master mode transfer by sending the START signal. The slave address will be sent following the I2C START signal.
| base | I2C peripheral base pointer |
| address | 7-bit slave device address. |
| direction | Master transfer directions(transmit/receive). |
| kStatus_Success | Sucessully send the start signal. |
| kStatus_I2C_Busy | Current bus is busy. |
| status_t I2C_MasterStop | ( | I2C_Type * | base | ) |
Sends a STOP signal on the I2C bus.
| kStatus_Success | Sucessully send the stop signal. |
| kStatus_I2C_Timeout | Send stop signal failed, timeout. |
| void I2C_MasterTransferAbort | ( | I2C_Type * | base, |
| i2c_master_handle_t * | handle | ||
| ) |
Abort a interrupt non-blocking transfer in a early time.
| base | I2C base pointer. |
| handle | pointer to i2c_master_handle_t structure which stores the transfer state |
| status_t I2C_MasterTransferBlocking | ( | I2C_Type * | base, |
| i2c_master_transfer_t * | xfer | ||
| ) |
Performs a master polling transfer on the I2C bus.
| base | I2C peripheral base address. |
| xfer | Pointer to the transfer structure. |
| kStatus_Success | Sucessully complete the data transmission. |
| kStatus_I2C_Busy | Previous transmission still not finished. |
| kStatus_I2C_Timeout | Transfer error, wait signal timeout. |
| kStatus_I2C_ArbitrationLost | Transfer error, arbitration lost. |
| kStataus_I2C_Nak | Transfer error, receive Nak during transfer. |
| void I2C_MasterTransferCreateHandle | ( | I2C_Type * | base, |
| i2c_master_handle_t * | handle, | ||
| i2c_master_transfer_callback_t | callback, | ||
| void * | userData | ||
| ) |
Init the I2C handle which is used in transactional functions.
| base | I2C base pointer. |
| handle | pointer to i2c_master_handle_t structure to store the transfer state. |
| callback | pointer to user callback function. |
| userData | user param passed to the callback function. |
| status_t I2C_MasterTransferGetCount | ( | I2C_Type * | base, |
| i2c_master_handle_t * | handle, | ||
| size_t * | count | ||
| ) |
Get master transfer status during a interrupt non-blocking transfer.
| base | I2C base pointer. |
| handle | pointer to i2c_master_handle_t structure which stores the transfer state. |
| count | Number of bytes transferred so far by the non-blocking transaction. |
| kStatus_InvalidArgument | count is Invalid. |
| kStatus_Success | Successfully return the count. |
| void I2C_MasterTransferHandleIRQ | ( | I2C_Type * | base, |
| void * | i2cHandle | ||
| ) |
Master interrupt handler.
| base | I2C base pointer. |
| i2cHandle | pointer to i2c_master_handle_t structure. |
| status_t I2C_MasterTransferNonBlocking | ( | I2C_Type * | base, |
| i2c_master_handle_t * | handle, | ||
| i2c_master_transfer_t * | xfer | ||
| ) |
Performs a master interrupt non-blocking transfer on the I2C bus.
| base | I2C base pointer. |
| handle | pointer to i2c_master_handle_t structure which stores the transfer state. |
| xfer | pointer to i2c_master_transfer_t structure. |
| kStatus_Success | Sucessully start the data transmission. |
| kStatus_I2C_Busy | Previous transmission still not finished. |
| kStatus_I2C_Timeout | Transfer error, wait signal timeout. |
| status_t I2C_MasterWriteBlocking | ( | I2C_Type * | base, |
| const uint8_t * | txBuff, | ||
| size_t | txSize | ||
| ) |
Performs a polling send transaction on the I2C bus without a STOP signal.
| base | The I2C peripheral base pointer. |
| txBuff | The pointer to the data to be transferred. |
| txSize | The length in bytes of the data to be transferred. |
| kStatus_Success | Sucessully complete the data transmission. |
| kStatus_I2C_ArbitrationLost | Transfer error, arbitration lost. |
| kStataus_I2C_Nak | Transfer error, receive Nak during transfer. |
|
inlinestatic |
Clears the I2C status flag state.
The following status register flags can be cleared: kI2C_ArbitrationLostFlag and kI2C_IntPendingFlag
| base | I2C base pointer |
| statusMask | The status flag mask, defined in type i2c_status_flag_t. The parameter could be any combination of the following values:
|
| void I2C_SlaveDeinit | ( | I2C_Type * | base | ) |
De-initialize the I2C slave peripheral, call thi API will gate the i2c clock, so the I2C slave module can not work unless call I2C_SlaveInit to enable the clock.
| base | I2C base pointer |
| void I2C_SlaveGetDefaultConfig | ( | i2c_slave_config_t * | slaveConfig | ) |
Set the I2C slave configuration structure to default values.
The purpose of this API is to get the config structure initialized for use in I2C_SlaveConfigure(). User needs to modify some fields of the structure before calling I2C_SlaveConfigure(). Example:
| slaveConfig | Pointer to the slave config structure. |
|
inlinestatic |
Gets the I2C status flags.
| base | I2C base pointer |
| void I2C_SlaveInit | ( | I2C_Type * | base, |
| const i2c_slave_config_t * | slaveConfig | ||
| ) |
Initialize the I2C peripheral, call this API to ungate the i2c clock and initializes the I2C with slave configuration.
| base | I2C base pointer |
| slaveConfig | pointer to slave config structure |
| void I2C_SlaveReadBlocking | ( | I2C_Type * | base, |
| uint8_t * | rxBuff, | ||
| size_t | rxSize | ||
| ) |
Performs a polling receive transaction on the I2C bus.
| base | I2C peripheral base pointer. |
| rxBuff | The pointer to the data to store the received data. |
| rxSize | The length in bytes of the data to be received. |
| void I2C_SlaveTransferAbort | ( | I2C_Type * | base, |
| i2c_slave_handle_t * | handle | ||
| ) |
Abort slave transfer.
| base | I2C base pointer. |
| handle | pointer to i2c_slave_handle_t structure which stores the transfer state. |
| void I2C_SlaveTransferCreateHandle | ( | I2C_Type * | base, |
| i2c_slave_handle_t * | handle, | ||
| i2c_slave_transfer_callback_t | callback, | ||
| void * | userData | ||
| ) |
Init the I2C handle which is used in transcational functions.
| base | I2C base pointer. |
| handle | pointer to i2c_slave_handle_t structure to store the transfer state. |
| callback | pointer to user callback function. |
| userData | user param passed to the callback function. |
| status_t I2C_SlaveTransferGetCount | ( | I2C_Type * | base, |
| i2c_slave_handle_t * | handle, | ||
| size_t * | count | ||
| ) |
Get slave transfer remaining bytes during a interrupt non-blocking transfer.
| base | I2C base pointer. |
| handle | pointer to i2c_slave_handle_t structure. |
| count | Number of bytes transferred so far by the non-blocking transaction. |
| kStatus_InvalidArgument | count is Invalid. |
| kStatus_Success | Successfully return the count. |
| void I2C_SlaveTransferHandleIRQ | ( | I2C_Type * | base, |
| void * | i2cHandle | ||
| ) |
Slave interrupt handler.
| base | I2C base pointer. |
| i2cHandle | pointer to i2c_slave_handle_t structure which stores the transfer state |
| status_t I2C_SlaveTransferNonBlocking | ( | I2C_Type * | base, |
| i2c_slave_handle_t * | handle, | ||
| uint32_t | eventMask | ||
| ) |
Start accepting slave transfers.
Call this API after calling I2C_SlaveInit() and I2C_SlaveTransferCreateHandle() to start processing transactions driven by an I2C master. The slave will monitor the I2C bus and pass events to the callback that was passed into the call to I2C_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 i2c_slave_transfer_event_t enumerators for the events you wish to receive. The kI2C_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 kI2C_SlaveAllEvents constant is provided as a convenient way to enable all events.
| base | The I2C peripheral base address. |
| handle | Pointer to #i2c_slave_handle_t structure which stores the transfer state. |
| eventMask | Bit mask formed by OR'ing together 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 kI2C_SlaveAllEvents to enable all events. |
| #kStatus_Success | Slave transfers were successfully started. |
| kStatus_I2C_Busy | Slave transfers have already been started on this handle. |
| status_t I2C_SlaveWriteBlocking | ( | I2C_Type * | base, |
| const uint8_t * | txBuff, | ||
| size_t | txSize | ||
| ) |
Performs a polling send transaction on the I2C bus.
| base | The I2C peripheral base pointer. |
| txBuff | The pointer to the data to be transferred. |
| txSize | The length in bytes of the data to be transferred. |
| kStatus_Success | Sucessully complete the data transmission. |
| kStatus_I2C_ArbitrationLost | Transfer error, arbitration lost. |
| kStataus_I2C_Nak | Transfer error, receive Nak during transfer. |