Kinetis SDK v.1.3 API Reference Manual
Rev. 0
Freescale Semiconductor, Inc.
|
This section describes the programming interface of the I2C slave mode Peripheral driver.
Data Structures | |
struct | i2c_slave_state_t |
Runtime state of the I2C Slave driver. More... | |
struct | i2c_slave_user_config_t |
Defines the structure to initialize the I2C Slave module. More... | |
Typedefs | |
typedef void(* | i2c_slave_callback_t )(uint8_t instance, i2c_slave_event_t slaveEvent, void *userData) |
I2C slave callback function. | |
Enumerations | |
enum | i2c_slave_event_t { kI2CSlaveTxReq = 0x02u, kI2CSlaveRxReq = 0x04u, kI2CSlaveTxNAK = 0x08u, kI2CSlaveTxEmpty = 0x10u, kI2CSlaveRxFull = 0x20u, kI2CSlaveAbort = 0x40u } |
Internal driver state information. More... | |
Variables | |
I2C_Type *const | g_i2cBase [I2C_INSTANCE_COUNT] |
Table of base addresses for I2C instances. More... | |
I2C Slave | |
i2c_status_t | I2C_DRV_SlaveInit (uint32_t instance, const i2c_slave_user_config_t *userConfigPtr, i2c_slave_state_t *slave) |
Initializes the I2C module. More... | |
i2c_status_t | I2C_DRV_SlaveDeinit (uint32_t instance) |
Shuts down the I2C slave driver. More... | |
i2c_slave_state_t * | I2C_DRV_SlaveGetHandler (uint32_t instance) |
Gets the I2C slave run-time state structure. More... | |
i2c_status_t | I2C_DRV_SlaveSendData (uint32_t instance, const uint8_t *txBuff, uint32_t txSize) |
Sends/transmits data by using a non-blocking method. More... | |
i2c_status_t | I2C_DRV_SlaveSendDataBlocking (uint32_t instance, const uint8_t *txBuff, uint32_t txSize, uint32_t timeout_ms) |
Sends (transmits) data by using a blocking method. More... | |
i2c_status_t | I2C_DRV_SlaveReceiveData (uint32_t instance, uint8_t *rxBuff, uint32_t rxSize) |
Receives the data by using a non-blocking method. More... | |
i2c_status_t | I2C_DRV_SlaveReceiveDataBlocking (uint32_t instance, uint8_t *rxBuff, uint32_t rxSize, uint32_t timeout_ms) |
Receives data by using a blocking method. More... | |
i2c_status_t | I2C_DRV_SlaveGetReceiveStatus (uint32_t instance, uint32_t *bytesRemaining) |
Gets the current status of the I2C slave driver. More... | |
i2c_status_t | I2C_DRV_SlaveGetTransmitStatus (uint32_t instance, uint32_t *bytesRemaining) |
Gets the current status of the I2C slave driver. More... | |
i2c_status_t | I2C_DRV_SlaveAbortReceiveData (uint32_t instance, uint32_t *rxSize) |
Terminates a non-blocking receive of the I2C slave early. More... | |
i2c_status_t | I2C_DRV_SlaveAbortSendData (uint32_t instance, uint32_t *txSize) |
Terminates a non-blocking send of the I2C slave early. More... | |
static bool | I2C_DRV_SlaveIsBusBusy (uint32_t instance) |
Gets the current status of the I2C slave bus. More... | |
static i2c_status_t | I2C_DRV_SlaveSendDataPolling (uint32_t instance, const uint8_t *txBuff, uint32_t txSize) |
Sends out multiple bytes of data using a polling method. More... | |
static i2c_status_t | I2C_DRV_SlaveReceiveDataPolling (uint32_t instance, uint8_t *rxBuff, uint32_t rxSize) |
Receives multiple bytes of data using a polling method. More... | |
void | I2C_DRV_SlaveIRQHandler (uint32_t instance) |
The interrupt handler for I2C slave mode. More... | |
struct i2c_slave_state_t |
This structure holds data used by the I2C Slave Peripheral driver to communicate between the transfer function and the interrupt handler. The interrupt handler also uses this information to keep track of its progress.
Data Fields | |
i2c_status_t | status |
The slave I2C status. More... | |
volatile uint32_t | txSize |
Size of the TX buffer. More... | |
volatile uint32_t | rxSize |
Size of the RX buffer. More... | |
const uint8_t * | txBuff |
Pointer to Tx Buffer. More... | |
uint8_t * | rxBuff |
Pointer to Rx Buffer. More... | |
bool | isTxBusy |
True if the driver is sending data. More... | |
bool | isRxBusy |
True if the driver is receiving data. More... | |
bool | isTxBlocking |
True if transmit is blocking transaction. More... | |
bool | isRxBlocking |
True if receive is blocking transaction. More... | |
event_t | irqEvent |
Use to wait for ISR to complete its Tx, Rx business. | |
bool | slaveListening |
True if slave is in listening mode. More... | |
i2c_slave_callback_t | slaveCallback |
Pointer to user callback function. More... | |
void * | callbackParam |
Pointer to user callback param. More... | |
i2c_status_t i2c_slave_state_t::status |
volatile uint32_t i2c_slave_state_t::txSize |
volatile uint32_t i2c_slave_state_t::rxSize |
const uint8_t* i2c_slave_state_t::txBuff |
uint8_t* i2c_slave_state_t::rxBuff |
bool i2c_slave_state_t::isTxBusy |
bool i2c_slave_state_t::isRxBusy |
bool i2c_slave_state_t::isTxBlocking |
bool i2c_slave_state_t::isRxBlocking |
bool i2c_slave_state_t::slaveListening |
i2c_slave_callback_t i2c_slave_state_t::slaveCallback |
void* i2c_slave_state_t::callbackParam |
struct i2c_slave_user_config_t |
Data Fields | |
uint16_t | address |
Slave's 7-bit or 10-bit address. More... | |
bool | slaveListening |
The slave configuration mode. | |
i2c_slave_callback_t | slaveCallback |
The slave callback function. | |
void * | callbackParam |
The slave callback data. | |
uint16_t i2c_slave_user_config_t::address |
If 10-bit address, the first 6 bits must be 011110 in binary.
enum i2c_slave_event_t |
Defines the type of flags for callback function
i2c_status_t I2C_DRV_SlaveInit | ( | uint32_t | instance, |
const i2c_slave_user_config_t * | userConfigPtr, | ||
i2c_slave_state_t * | slave | ||
) |
Saves the application callback info, turns on the clock to the module, enables the device, and enables interrupts. Sets the I2C to slave mode. IOMUX should be handled in the init_hardware() function.
instance | Instance number of the I2C module. |
userConfigPtr | Pointer of the user configuration structure |
slave | Pointer of the slave run-time structure. |
i2c_status_t I2C_DRV_SlaveDeinit | ( | uint32_t | instance | ) |
Clears the control register and turns off the clock to the module.
instance | Instance number of the I2C module. |
i2c_slave_state_t* I2C_DRV_SlaveGetHandler | ( | uint32_t | instance | ) |
This function gets the I2C slave run-time state structure.
instance | Instance number of the I2C module. |
i2c_status_t I2C_DRV_SlaveSendData | ( | uint32_t | instance, |
const uint8_t * | txBuff, | ||
uint32_t | txSize | ||
) |
This function returns immediately when the buffer pointer and length are set to the transfer buffer and transfer size. The user should check the status of I2C slave to find out whether the transmission is completed. The user can also wait the kI2CSlaveStop or the kI2CSlaveTxDone to ensure that the transmission is ended.
instance | Instance number of the I2C module. |
txBuff | The pointer to sending the data buffer. |
txSize | The number of bytes which the user wants to send. |
i2c_status_t I2C_DRV_SlaveSendDataBlocking | ( | uint32_t | instance, |
const uint8_t * | txBuff, | ||
uint32_t | txSize, | ||
uint32_t | timeout_ms | ||
) |
This function sets the buffer pointer and length to the transfer buffer and the transfer size and waits until the transmission is ended (NAK is detected).
instance | Instance number of the I2C module. |
txBuff | The pointer to sending the data buffer. |
txSize | The number of bytes which the user wants to send. |
timeout_ms | The maximum number of milliseconds to wait for transmit completed |
i2c_status_t I2C_DRV_SlaveReceiveData | ( | uint32_t | instance, |
uint8_t * | rxBuff, | ||
uint32_t | rxSize | ||
) |
This function returns immediately when the buffer pointer and length are set to the receive buffer and the receive size. The user should check the status of the I2C slave to find out whether the transmission is completed. The user can also wait the kI2CSlaveStop or the kI2CSlaveRxDone to ensure that the transmission is ended.
instance | Instance number of the I2C module. |
rxBuff | The pointer to the received data buffer. |
rxSize | The number of bytes which the user wants to receive. |
i2c_status_t I2C_DRV_SlaveReceiveDataBlocking | ( | uint32_t | instance, |
uint8_t * | rxBuff, | ||
uint32_t | rxSize, | ||
uint32_t | timeout_ms | ||
) |
This function sets the buffer pointer and length to the receive buffer and the receive size. Then, the function waits until the transmission is ended (all data is received or a STOP signal is detected).
instance | Instance number of the I2C module. |
rxBuff | The pointer to the received data buffer. |
rxSize | The number of bytes which the user wants to receive. |
timeout_ms | The maximum number of milliseconds to wait for receive completed |
i2c_status_t I2C_DRV_SlaveGetReceiveStatus | ( | uint32_t | instance, |
uint32_t * | bytesRemaining | ||
) |
instance | Instance number of the I2C module. |
bytesRemaining | The number of remaining bytes that I2C transmits. |
i2c_status_t I2C_DRV_SlaveGetTransmitStatus | ( | uint32_t | instance, |
uint32_t * | bytesRemaining | ||
) |
instance | Instance number of the I2C module. |
bytesRemaining | The number of remaining bytes that I2C transmits. |
i2c_status_t I2C_DRV_SlaveAbortReceiveData | ( | uint32_t | instance, |
uint32_t * | rxSize | ||
) |
During an non-blocking receiving
instance | Instance number of the I2C module. |
rxSize | The number of remaining bytes in I2C Rx Buffer. |
i2c_status_t I2C_DRV_SlaveAbortSendData | ( | uint32_t | instance, |
uint32_t * | txSize | ||
) |
During an non-blocking receiving
instance | Instance number of the I2C module. |
txSize | The number of remaining bytes in I2C Tx Buffer. |
|
inlinestatic |
instance | Instance number of the I2C module. |
|
inlinestatic |
instance | Instance number of the I2C module. |
txBuff | The buffer pointer which saves the data to be sent. |
txSize | Size of data to be sent in bytes. |
|
inlinestatic |
instance | Instance number of the I2C module. |
rxBuff | The buffer pointer which saves the data to be received. |
rxSize | Size of data need to be received in bytes. |
void I2C_DRV_SlaveIRQHandler | ( | uint32_t | instance | ) |
instance | Instance number of the I2C module. |
I2C_Type* const g_i2cBase[I2C_INSTANCE_COUNT] |