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 | lpi2c_slave_state_t |
Runtime state of the LPI2C Slave driver. More... | |
struct | lpi2c_slave_user_config_t |
Defines the structure to initialize the LPI2C Slave module. More... | |
Typedefs | |
typedef void(* | lpi2c_slave_callback_t )(uint8_t instance, lpi2c_slave_event_t slaveEvent, void *userData) |
LPI2C slave callback function. | |
Enumerations | |
enum | lpi2c_slave_event_t { kLPI2CSlaveTxReq = 0x02u, kLPI2CSlaveRxReq = 0x04u, kLPI2CSlaveTxNAK = 0x08u, kLPI2CSlaveTxEmpty = 0x10u, kLPI2CSlaveRxFull = 0x20u, kLPI2CSlaveAbort = 0x40u } |
Internal driver state information. More... | |
Variables | |
LPI2C_Type *const | g_lpi2cBase [LPI2C_INSTANCE_COUNT] |
Table of base addresses for LPI2C instances. More... | |
LPI2C Slave | |
void | LPI2C_DRV_SlaveInit (uint32_t instance, const lpi2c_slave_user_config_t *userConfigPtr, lpi2c_slave_state_t *slave) |
Initializes the LPI2C module. More... | |
void | LPI2C_DRV_SlaveDeinit (uint32_t instance) |
Shuts down the LPI2C slave driver. More... | |
lpi2c_slave_state_t * | LPI2C_DRV_SlaveGetHandler (uint32_t instance) |
Gets the LPI2C slave run-time state structure. More... | |
lpi2c_status_t | LPI2C_DRV_SlaveSendData (uint32_t instance, const uint8_t *txBuff, uint32_t txSize) |
Sends/transmits data by using a non-blocking method. More... | |
lpi2c_status_t | LPI2C_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... | |
lpi2c_status_t | LPI2C_DRV_SlaveReceiveData (uint32_t instance, uint8_t *rxBuff, uint32_t rxSize) |
Receives the data by using a non-blocking method. More... | |
lpi2c_status_t | LPI2C_DRV_SlaveReceiveDataBlocking (uint32_t instance, uint8_t *rxBuff, uint32_t rxSize, uint32_t timeout_ms) |
Receives data by using a blocking method. More... | |
lpi2c_status_t | LPI2C_DRV_SlaveGetReceiveStatus (uint32_t instance, uint32_t *bytesRemaining) |
Gets the current status of the LPI2C slave driver. More... | |
lpi2c_status_t | LPI2C_DRV_SlaveGetTransmitStatus (uint32_t instance, uint32_t *bytesRemaining) |
Gets the current status of the LPI2C slave driver. More... | |
lpi2c_status_t | LPI2C_DRV_SlaveAbortReceiveData (uint32_t instance, uint32_t *rxSize) |
Terminates a non-blocking receive of the LPI2C slave early. More... | |
lpi2c_status_t | LPI2C_DRV_SlaveAbortSendData (uint32_t instance, uint32_t *txSize) |
Terminates a non-blocking send of the LPI2C slave early. More... | |
static bool | LPI2C_DRV_SlaveIsBusBusy (uint32_t instance) |
Gets the current status of the LPI2C slave bus. More... | |
static lpi2c_status_t | LPI2C_DRV_SlaveSendDataPolling (uint32_t instance, const uint8_t *txBuff, uint32_t txSize) |
Sends out multiple bytes of data using a polling method. More... | |
static lpi2c_status_t | LPI2C_DRV_SlaveReceiveDataPolling (uint32_t instance, uint8_t *rxBuff, uint32_t rxSize) |
Receives multiple bytes of data using a polling method. More... | |
struct lpi2c_slave_state_t |
This structure holds data used by the LPI2C 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 | |
lpi2c_status_t | status |
The slave LPI2C status. More... | |
volatile uint32_t | txSize |
Size of the transmit buffer. More... | |
volatile uint32_t | rxSize |
Size of the receive buffer. More... | |
const uint8_t * | txBuff |
Pointer to transmit Buffer. More... | |
uint8_t * | rxBuff |
Pointer to receive 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 transmit and receive. More... | |
bool | slaveListening |
True if slave is in listening mode. More... | |
lpi2c_slave_callback_t | slaveCallback |
Pointer to user callback function. More... | |
void * | callbackParam |
Pointer to user callback parameter. More... | |
lpi2c_status_t lpi2c_slave_state_t::status |
volatile uint32_t lpi2c_slave_state_t::txSize |
volatile uint32_t lpi2c_slave_state_t::rxSize |
const uint8_t* lpi2c_slave_state_t::txBuff |
uint8_t* lpi2c_slave_state_t::rxBuff |
bool lpi2c_slave_state_t::isTxBusy |
bool lpi2c_slave_state_t::isRxBusy |
bool lpi2c_slave_state_t::isTxBlocking |
bool lpi2c_slave_state_t::isRxBlocking |
event_t lpi2c_slave_state_t::irqEvent |
bool lpi2c_slave_state_t::slaveListening |
lpi2c_slave_callback_t lpi2c_slave_state_t::slaveCallback |
void* lpi2c_slave_state_t::callbackParam |
struct lpi2c_slave_user_config_t |
Data Fields | |
uint16_t | address |
Slave's 7-bit or 10-bit address. More... | |
bool | slaveListening |
The slave configuration mode. | |
lpi2c_slave_callback_t | slaveCallback |
The slave callback function. | |
void * | callbackParam |
The slave callback data. | |
uint16_t lpi2c_slave_user_config_t::address |
If 10-bit address, the first 6 bits must be 011110 in binary.
enum lpi2c_slave_event_t |
Defines the type of flags for callback function
void LPI2C_DRV_SlaveInit | ( | uint32_t | instance, |
const lpi2c_slave_user_config_t * | userConfigPtr, | ||
lpi2c_slave_state_t * | slave | ||
) |
Saves the application callback info, turns on the clock to the module, enables the device, and enables interrupts. Sets the LPI2C to slave mode. IOMUX should be handled in the init_hardware() function.
instance | Instance number of the LPI2C module. |
userConfigPtr | Pointer of the user configuration structure |
slave | Pointer of the slave run-time structure. |
void LPI2C_DRV_SlaveDeinit | ( | uint32_t | instance | ) |
Clears the control register and turns off the clock to the module.
instance | Instance number of the LPI2C module. |
lpi2c_slave_state_t* LPI2C_DRV_SlaveGetHandler | ( | uint32_t | instance | ) |
This function gets the LPI2C slave run-time state structure.
instance | Instance number of the LPI2C module. |
lpi2c_status_t LPI2C_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. Check the status of LPI2C slave to find out whether the transmission is complete. Wait the kLPI2CSlaveStop or the kLPI2CSlaveTxDone to ensure that the transmission is ended.
instance | Instance number of the LPI2C module. |
txBuff | The pointer to sending the data buffer. |
txSize | The number of bytes which the user wants to send. |
lpi2c_status_t LPI2C_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 LPI2C 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 |
lpi2c_status_t LPI2C_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. Check the status of the LPI2C slave to find out whether the transmission is completed. Wait the kLPI2CSlaveStop or the kLPI2CSlaveRxDone to ensure that the transmission is ended.
instance | Instance number of the LPI2C module. |
rxBuff | The pointer to the received data buffer. |
rxSize | The number of bytes which the user wants to receive. |
lpi2c_status_t LPI2C_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 has ended (all data is received or a STOP signal is detected).
instance | Instance number of the LPI2C 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 |
lpi2c_status_t LPI2C_DRV_SlaveGetReceiveStatus | ( | uint32_t | instance, |
uint32_t * | bytesRemaining | ||
) |
instance | Instance number of the LPI2C module. |
bytesRemaining | The number of remaining bytes that LPI2C transmits. |
lpi2c_status_t LPI2C_DRV_SlaveGetTransmitStatus | ( | uint32_t | instance, |
uint32_t * | bytesRemaining | ||
) |
instance | Instance number of the LPI2C module. |
bytesRemaining | The number of remaining bytes that LPI2C transmits. |
lpi2c_status_t LPI2C_DRV_SlaveAbortReceiveData | ( | uint32_t | instance, |
uint32_t * | rxSize | ||
) |
During an non-blocking receiving
instance | Instance number of the LPI2C module. |
rxSize | The number of remaining bytes in LPI2C receive buffer. |
lpi2c_status_t LPI2C_DRV_SlaveAbortSendData | ( | uint32_t | instance, |
uint32_t * | txSize | ||
) |
During an non-blocking receiving
instance | Instance number of the LPI2C module. |
txSize | The number of remaining bytes in LPI2C Tx Buffer. |
|
inlinestatic |
instance | Instance number of the LPI2C module. |
|
inlinestatic |
instance | Instance number of the LPI2C 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 LPI2C module. |
rxBuff | The buffer pointer which saves the data to be received. |
rxSize | Size of data need to be received in bytes. |
LPI2C_Type* const g_lpi2cBase[LPI2C_INSTANCE_COUNT] |