MTB CAT1 Peripheral driver library

General Description

Functions

void Cy_SCB_I2C_SlaveConfigReadBuf (CySCB_Type const *base, uint8_t *buffer, uint32_t size, cy_stc_scb_i2c_context_t *context)
 Configures the buffer pointer and the read buffer size. More...
 
void Cy_SCB_I2C_SlaveAbortRead (CySCB_Type *base, cy_stc_scb_i2c_context_t *context)
 Aborts the configured slave read buffer to be read by the master. More...
 
void Cy_SCB_I2C_SlaveConfigWriteBuf (CySCB_Type const *base, uint8_t *buffer, uint32_t size, cy_stc_scb_i2c_context_t *context)
 Configures the buffer pointer and size of the write buffer. More...
 
void Cy_SCB_I2C_SlaveAbortWrite (CySCB_Type *base, cy_stc_scb_i2c_context_t *context)
 Aborts the configured slave write buffer to be written by the master. More...
 
uint32_t Cy_SCB_I2C_SlaveGetStatus (CySCB_Type const *base, cy_stc_scb_i2c_context_t const *context)
 Returns the current I2C slave status. More...
 
uint32_t Cy_SCB_I2C_SlaveClearReadStatus (CySCB_Type const *base, cy_stc_scb_i2c_context_t *context)
 Clears the read status and error conditions flags and returns their values. More...
 
uint32_t Cy_SCB_I2C_SlaveClearWriteStatus (CySCB_Type const *base, cy_stc_scb_i2c_context_t *context)
 Clears the write status flags and error condition flags and returns their values. More...
 
uint32_t Cy_SCB_I2C_SlaveGetReadTransferCount (CySCB_Type const *base, cy_stc_scb_i2c_context_t const *context)
 Returns the number of bytes read by the master since the last time Cy_SCB_I2C_SlaveConfigReadBuf was called. More...
 
uint32_t Cy_SCB_I2C_SlaveGetWriteTransferCount (CySCB_Type const *base, cy_stc_scb_i2c_context_t const *context)
 Returns the number of bytes written by the master since the last time Cy_SCB_I2C_SlaveConfigWriteBuf was called. More...
 

Function Documentation

◆ Cy_SCB_I2C_SlaveConfigReadBuf()

void Cy_SCB_I2C_SlaveConfigReadBuf ( CySCB_Type const *  base,
uint8_t *  buffer,
uint32_t  size,
cy_stc_scb_i2c_context_t context 
)

Configures the buffer pointer and the read buffer size.

This is the buffer from which the master reads data. After this function is called, data transfer from the read buffer to the master is handled by Cy_SCB_I2C_Interrupt.

When the Read transaction is completed (master generated Stop, ReStart or error occurred), the CY_SCB_I2C_SLAVE_RD_BUSY status is cleared and the CY_SCB_I2C_SLAVE_RD_CMPLT is set. Also the CY_SCB_I2C_SLAVE_RD_CMPLT_EVENT event is generated.

Parameters
baseThe pointer to the I2C SCB instance.
bufferThe pointer to the buffer with data to be read by the master.
sizeSize of the buffer.
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.
Note
  • The Read buffer must not be modified and stay allocated until it has been read by the master.
  • If this function has not been called, and the master tries to read data from the slave a CY_SCB_I2C_DEFAULT_TX is returned to the master.
  • If the master tries to read more bytes than available in the Read buffer, a CY_SCB_I2C_SLAVE_RD_BUF_EMPTY_EVENT event occurs. The CY_SCB_I2C_DEFAULT_TX is returned to the master if the buffer remains empty after an event notification.

◆ Cy_SCB_I2C_SlaveAbortRead()

void Cy_SCB_I2C_SlaveAbortRead ( CySCB_Type base,
cy_stc_scb_i2c_context_t context 
)

Aborts the configured slave read buffer to be read by the master.

If the master reads and "abort operation" is requested, the CY_SCB_I2C_SLAVE_RD_BUF_EMPTY_EVENT event occurs. The CY_SCB_I2C_DEFAULT_TX is returned to the master if the buffer remains empty after the event notification.

Parameters
baseThe pointer to the I2C SCB instance.
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.
Side Effects
If the TX FIFO is used, this function clears it. The TX FIFO clear operation also clears the shift register, thus the shifter can be cleared in the middle of a data element transfer, corrupting it. The data element corruption means that all bits that have not been transmitted are transmitted as "ones" on the bus.

◆ Cy_SCB_I2C_SlaveConfigWriteBuf()

void Cy_SCB_I2C_SlaveConfigWriteBuf ( CySCB_Type const *  base,
uint8_t *  buffer,
uint32_t  size,
cy_stc_scb_i2c_context_t context 
)

Configures the buffer pointer and size of the write buffer.

This is the buffer that the master writes data to. After this function is called data transfer from the master into the write buffer is handled by Cy_SCB_I2C_Interrupt.

When write transaction is completed (master generated Stop, ReStart or error occurred) the CY_SCB_I2C_SLAVE_WR_BUSY status is cleared and the CY_SCB_I2C_SLAVE_WR_CMPLT is set, also the CY_SCB_I2C_SLAVE_WR_CMPLT_EVENT event is generated.

Parameters
baseThe pointer to the I2C SCB instance.
bufferThe pointer to buffer to store data written by the master.
sizeSize of the buffer.
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.
Note
  • The write buffer must not be modified and must stay allocated until it has been written by the master.
  • If this function has not been called and the master tries to write data, the first byte is NAKed and discarded.
  • If the master writes more bytes than the slave can store in the write buffer, the CY_SCB_I2C_SLAVE_WR_OVRFL status is set and the slave will NACK last byte, unless the RX FIFO is used. Then the slave will NAK only after RX FIFO becomes full.
  • If the RX FIFO is used, the minimum write buffer size is automatically the size of the RX FIFO. If a write buffer is less than the RX FIFO size, extra bytes are ACKed and stored into RX FIFO but ignored by firmware.

◆ Cy_SCB_I2C_SlaveAbortWrite()

void Cy_SCB_I2C_SlaveAbortWrite ( CySCB_Type base,
cy_stc_scb_i2c_context_t context 
)

Aborts the configured slave write buffer to be written by the master.

If master writes and an "abort operation" is requested, the next incoming byte will be NAKed.

Parameters
baseThe pointer to the I2C SCB instance.
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.
Note
If the RX FIFO is used, the NAK will not be sent until RX FIFO becomes full, however bytes accepted after an abort request are ignored.

◆ Cy_SCB_I2C_SlaveGetStatus()

uint32_t Cy_SCB_I2C_SlaveGetStatus ( CySCB_Type const *  base,
cy_stc_scb_i2c_context_t const *  context 
)

Returns the current I2C slave status.

This status is a bit mask and the value returned may have multiple bits set.

Parameters
baseThe pointer to the I2C SCB instance.
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
I2C Slave Status.

◆ Cy_SCB_I2C_SlaveClearReadStatus()

uint32_t Cy_SCB_I2C_SlaveClearReadStatus ( CySCB_Type const *  base,
cy_stc_scb_i2c_context_t context 
)

Clears the read status and error conditions flags and returns their values.

Parameters
baseThe pointer to the I2C SCB instance.
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
I2C Slave Status.
Note
The CY_SCB_I2C_SLAVE_RD_BUSY flag is not cleared.

◆ Cy_SCB_I2C_SlaveClearWriteStatus()

uint32_t Cy_SCB_I2C_SlaveClearWriteStatus ( CySCB_Type const *  base,
cy_stc_scb_i2c_context_t context 
)

Clears the write status flags and error condition flags and returns their values.

Parameters
baseThe pointer to the I2C SCB instance.
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
I2C Slave Status.
Note
The CY_SCB_I2C_SLAVE_WR_BUSY flag is not cleared.

◆ Cy_SCB_I2C_SlaveGetReadTransferCount()

uint32_t Cy_SCB_I2C_SlaveGetReadTransferCount ( CySCB_Type const *  base,
cy_stc_scb_i2c_context_t const *  context 
)

Returns the number of bytes read by the master since the last time Cy_SCB_I2C_SlaveConfigReadBuf was called.

Parameters
baseThe pointer to the I2C SCB instance.
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
The number of bytes read by the master.
Note
  • This function returns an invalid value if a read transaction was aborted or any listed event occurs during the transaction: CY_SCB_I2C_SLAVE_ARB_LOST, CY_SCB_I2C_SLAVE_BUS_ERR.
  • This number is updated only when a transaction completes, either through an error or successfully.

◆ Cy_SCB_I2C_SlaveGetWriteTransferCount()

uint32_t Cy_SCB_I2C_SlaveGetWriteTransferCount ( CySCB_Type const *  base,
cy_stc_scb_i2c_context_t const *  context 
)

Returns the number of bytes written by the master since the last time Cy_SCB_I2C_SlaveConfigWriteBuf was called.

Parameters
baseThe pointer to the I2C SCB instance.
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
Number of bytes written by the master.
Note
  • This function returns an invalid value if write transaction was aborted or any listed event occurs during the transaction: CY_SCB_I2C_SLAVE_ARB_LOST, CY_SCB_I2C_SLAVE_BUS_ERR.
  • This number is updated only when the transaction completes, either through an error or successfully.