CAT2 Peripheral Driver Library

General Description

Functions

cy_en_scb_i2c_status_t Cy_SCB_I2C_MasterSendStart (CySCB_Type *base, uint32_t address, cy_en_scb_i2c_direction_t bitRnW, uint32_t timeoutMs, cy_stc_scb_i2c_context_t *context)
 Generates a Start condition and sends a slave address with the Read/Write bit. More...
 
cy_en_scb_i2c_status_t Cy_SCB_I2C_MasterSendReStart (CySCB_Type *base, uint32_t address, cy_en_scb_i2c_direction_t bitRnW, uint32_t timeoutMs, cy_stc_scb_i2c_context_t *context)
 Generates a ReStart condition and sends a slave address with the Read/Write bit. More...
 
cy_en_scb_i2c_status_t Cy_SCB_I2C_MasterSendStop (CySCB_Type *base, uint32_t timeoutMs, cy_stc_scb_i2c_context_t *context)
 Generates a Stop condition to complete the current transaction. More...
 
cy_en_scb_i2c_status_t Cy_SCB_I2C_MasterReadByte (CySCB_Type *base, cy_en_scb_i2c_command_t ackNack, uint8_t *byte, uint32_t timeoutMs, cy_stc_scb_i2c_context_t *context)
 Reads one byte from a slave and generates an ACK or prepares to generate a NAK. More...
 
cy_en_scb_i2c_status_t Cy_SCB_I2C_MasterWriteByte (CySCB_Type *base, uint8_t byte, uint32_t timeoutMs, cy_stc_scb_i2c_context_t *context)
 Sends one byte to a slave. More...
 

Function Documentation

◆ Cy_SCB_I2C_MasterSendStart()

cy_en_scb_i2c_status_t Cy_SCB_I2C_MasterSendStart ( CySCB_Type base,
uint32_t  address,
cy_en_scb_i2c_direction_t  bitRnW,
uint32_t  timeoutMs,
cy_stc_scb_i2c_context_t context 
)

Generates a Start condition and sends a slave address with the Read/Write bit.

This function is blocking. It does not return until the Start condition and address byte are sent and a ACK/NAK is received, or an error or timeout occurs.

Parameters
baseThe pointer to the I2C SCB instance.
address7 bit right justified slave address.
bitRnWThis sets the value of the Read/Write bit in the address, thus defining the direction of the following transfer. See cy_en_scb_i2c_direction_t for the set of constants.
timeoutMsDefines in milliseconds the time for which this function can block. If that time expires, the function returns. If a zero is passed, the function waits forever for the action to complete. If a timeout occurs, the SCB block is reset. Note The maximum value is UINT32_MAX/1000.
contextThe pointer to the context structure cy_stc_scb_i2c_context_t allocated by the user. The structure is used during the I2C operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
cy_en_scb_i2c_status_t
Note
After a read transaction is initiated and the slave ACKs the address, at least one byte must be read before completing the transaction or changing its direction.

◆ Cy_SCB_I2C_MasterSendReStart()

cy_en_scb_i2c_status_t Cy_SCB_I2C_MasterSendReStart ( CySCB_Type base,
uint32_t  address,
cy_en_scb_i2c_direction_t  bitRnW,
uint32_t  timeoutMs,
cy_stc_scb_i2c_context_t context 
)

Generates a ReStart condition and sends a slave address with the Read/Write bit.

This function is blocking. It does not return until the ReStart condition and address byte are sent and an ACK/NAK is received, or an error or timeout occurs.

Parameters
baseThe pointer to the I2C SCB instance.
addressA 7-bit right-justified slave address.
bitRnWThis sets the value of the Read/Write bit in the address, thus defining the direction of the following transfer. See cy_en_scb_i2c_direction_t for the set of constants.
timeoutMsDefines in milliseconds the time for which this function can block. If that time expires, the function returns. If a zero is passed, the function waits forever for the action to complete. If a timeout occurs, the SCB block is reset. Note The maximum value is UINT32_MAX/1000.
contextThe pointer to the context structure cy_stc_scb_i2c_context_t allocated by the user. The structure is used during the I2C operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
cy_en_scb_i2c_status_t
Note
  • A successful transaction must be initiated by Cy_SCB_I2C_MasterSendStart before calling this function. If this condition is not met, this function does nothing and returns CY_SCB_I2C_MASTER_NOT_READY.
  • After a read transaction is initiated and the slave ACKs the address, at least one byte must be read before completing the transaction or changing its direction.

◆ Cy_SCB_I2C_MasterSendStop()

cy_en_scb_i2c_status_t Cy_SCB_I2C_MasterSendStop ( CySCB_Type base,
uint32_t  timeoutMs,
cy_stc_scb_i2c_context_t context 
)

Generates a Stop condition to complete the current transaction.

This function is blocking. It does not return until the Stop condition is generated, or an error or timeout occurs.

Parameters
baseThe pointer to the I2C SCB instance.
timeoutMsDefines in milliseconds the time for which this function can block. If that time expires, the function returns. If a zero is passed, the function waits forever for the action to complete. If a timeout occurs, the SCB block is reset. Note The maximum value is UINT32_MAX/1000.
contextThe pointer to the context structure cy_stc_scb_i2c_context_t allocated by the user. The structure is used during the I2C operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
cy_en_scb_i2c_status_t
Note

◆ Cy_SCB_I2C_MasterReadByte()

cy_en_scb_i2c_status_t Cy_SCB_I2C_MasterReadByte ( CySCB_Type base,
cy_en_scb_i2c_command_t  ackNack,
uint8_t *  byte,
uint32_t  timeoutMs,
cy_stc_scb_i2c_context_t context 
)

Reads one byte from a slave and generates an ACK or prepares to generate a NAK.

The NAK will be generated before a Stop or ReStart condition by Cy_SCB_I2C_MasterSendStop or Cy_SCB_I2C_MasterSendReStart function appropriately. This function is blocking. It does not return until a byte is received, or an error or timeout occurs.

Parameters
baseThe pointer to the I2C SCB instance.
ackNackA response to a received byte. See cy_en_scb_i2c_command_t for the set of constants.
byteThe pointer to the location to store the Read byte.
timeoutMsDefines in milliseconds the time for which this function can block. If that time expires, the function returns. If a zero is passed, the function waits forever for the action to complete. If a timeout occurs, the SCB block is reset. Note The maximum value is UINT32_MAX/1000.
contextThe pointer to the context structure cy_stc_scb_i2c_context_t allocated by the user. The structure is used during the I2C operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
cy_en_scb_i2c_status_t
Note
A successful transaction must be initiated by Cy_SCB_I2C_MasterSendStart or Cy_SCB_I2C_MasterSendReStart before calling this function. If this condition is not met, this function does nothing and returns CY_SCB_I2C_MASTER_NOT_READY.

◆ Cy_SCB_I2C_MasterWriteByte()

cy_en_scb_i2c_status_t Cy_SCB_I2C_MasterWriteByte ( CySCB_Type base,
uint8_t  byte,
uint32_t  timeoutMs,
cy_stc_scb_i2c_context_t context 
)

Sends one byte to a slave.

This function is blocking. It does not return until a byte is transmitted, or an error or timeout occurs.

Parameters
baseThe pointer to the I2C SCB instance.
byteThe byte to write to a slave.
timeoutMsDefines in milliseconds the time for which this function can block. If that time expires, the function returns. If a zero is passed, the function waits forever for the action to complete. If a timeout occurs, the SCB block is reset. Note The maximum value is UINT32_MAX/1000.
contextThe pointer to the context structure cy_stc_scb_i2c_context_t allocated by the user. The structure is used during the I2C operation for internal configuration and data retention. The user must not modify anything in this structure.
Returns
cy_en_scb_i2c_status_t
Note
A successful transaction must be initiated by Cy_SCB_I2C_MasterSendStart or Cy_SCB_I2C_MasterSendReStart before calling this function. If this condition is not met, this function does nothing and returns CY_SCB_I2C_MASTER_NOT_READY.