PSoC 6 Peripheral Driver Library
SCB (Serial Communication Block)

General Description

The Serial Communications Block (SCB) supports three serial communication protocols: Serial Peripheral Interface (SPI), Universal Asynchronous Receiver Transmitter (UART), and Inter Integrated Circuit (I2C or IIC).

Only one of the protocols is supported by an SCB at any given time.

The functions and other declarations used in this driver are in cy_scb_spi.h, cy_scb_uart.h, cy_scb_ezi2c.h, cy_scb_i2c.h respectively. Include cy_pdl.h to get access to all functions and declarations in the PDL.

More Information

For more information on the SCB peripheral, refer to the technical reference manual (TRM).

MISRA-C Compliance

MISRA rule Rule Class (Required/Advisory) Rule Description Description of Deviation(s)
11.4 A A cast should not be performed between a pointer to object type and a different pointer to object type.
14.1 R There shall be no unreachable code. The SCB block parameters can be a constant false or true depends on the selected device and cause code to be unreachable.
14.2 R All non-null statements shall either: a) have at least one side-effect however executed, or b) cause control flow to change. The unused function parameters are cast to void. This statement has no side-effect and is used to suppress a compiler warning.
14.7 R A function shall have a single point of exit at the end of the function. The functions can return from several points. This is done to improve code clarity when returning error status code if input parameters validation fails.
13.7 R Boolean operations whose results are invariant shall not be permitted.
  • The SCB block parameters can be a constant false or true depends on the selected device and cause this violation.
  • The same condition check is executed before and after callback is called because after the callback returns, the condition might be not true any more.


VersionChangesReason for Change
2.50 Fixed the Cy_SCB_SPI_SetActiveSlaveSelectPolarity function to properly configure the polarity of the slave select line. Cy_SCB_SPI_SetActiveSlaveSelectPolarity function works incorrectly.
2.40.2 Minor documentation updates. Documentation enhancement.
2.40 Update level selection logic of RX FIFO trigger in the Cy_SCB_UART_Receive(). Fix possible stuck if the RTS level is less than the RX FIFO level.
Exclude self-test assertion macros under release build profile. Avoid dependency on CY_ASSERT macro implementation.
2.30.1 Added header guards CY_IP_MXSCB. To enable the PDL compilation with wounded out IP blocks.
2.30 Fixed MISRA violation. MISRA compliance.
Changed values CY_SCB_SPI_CPHA0_CPOL1 and CY_SCB_SPI_CPHA1_CPOL0 in enum cy_en_scb_spi_sclk_mode_t. The incorrect values in cy_en_scb_spi_sclk_mode_t caused incorrect initialization of the combination of phases and polarity: "CHPA = 0, CPOL = 1" and "CHPA = 1, CPOL = 0".
Added new CY_SCB_UART_RECEIVE_NOT_EMTPY and CY_SCB_UART_TRANSMIT_EMTPY callback events UART Callback Events. Extended the driver callback events to support the MBED-OS.
Merged SCB changelogs for each mode into one changelog. Changelog optimization.
Merged SCB MISRA-C Compliance sections for each mode into one section. To optimize the SCB MISRA-C Compliance sections.
2.20.1 Documentation of the MISRA rule violation. MISRA compliance.
2.20 Flattened the organization of the driver source code into the single source directory and the single include directory. Driver library directory-structure simplification.
Added register access layer. Use register access macros instead of direct register access using dereferenced pointers. Makes register access device-independent, so that the PDL does not need to be recompiled for each supported part number.
Added the enableDigitalFilter, highPhaseDutyCycle and lowPhaseDutyCycle fields to the cy_stc_scb_i2c_config_t configuration structure. Added the I2C master data rate configuration using the configuration structure.
Fixed the Cy_SCB_I2C_SetDataRate function to properly configure data rates greater than 400 kbps in Master and Master-Slave modes.
Added verification that clk_scb is within the valid range for the desired data rate.
The analog filter was enabled for all data rates in Master and Master-Slave modes. This prevents reaching the maximum supported data rate of 1000 kbps which requires a digital filter.
2.10 Fixed the ReStart condition generation sequence for a write transaction in the Cy_SCB_I2C_MasterWrite function. The driver can notify about a zero length write transaction completion before the address byte is sent if the Cy_SCB_I2C_MasterWrite function execution was interrupted between setting the restart generation command and writing the address byte into the TX FIFO.
Added the slave- and master-specific interrupt functions: Cy_SCB_I2C_SlaveInterrupt and Cy_SCB_I2C_MasterInterrupt. Improved the interrupt configuration options for the I2C slave and master mode configurations.
Updated the Start condition generation sequence in the Cy_SCB_I2C_MasterWrite and Cy_SCB_I2C_MasterRead.
Updated the ReStart condition generation sequence for a write transaction in the Cy_SCB_I2C_MasterSendReStart function.
2.0 Added parameters validation for public API.
Fixed functions which return interrupt status to return only defined set of interrupt statuses.
Added missing "cy_cb_" to the callback function type names.
Replaced variables that have limited range of values with enumerated types.
Added function Cy_SCB_UART_SendBreakBlocking for break condition generation.
Fixed low power callbacks Cy_SCB_UART_DeepSleepCallback and Cy_SCB_UART_HibernateCallback to prevent the device from entering low power mode when RX FIFO is not empty. The callbacks allowed entering device into low power mode when RX FIFO had data.
Fixed SPI callback notification when error event occurred. The SPI callback passed incorrect event value if error event occurred.
Fixed the Cy_SCB_I2C_MasterSendReStart function to properly generate the ReStart condition when the previous transaction was a write. The master interpreted the address byte written into the TX FIFO as a data byte and continued a write transaction. The ReStart condition was generated after the master completed transferring the data byte. The SCL line was stretched by the master waiting for the address byte to be written into the TX FIFO after the ReStart condition generation. The following timeout detection released the bus from the master control.
Fixed the slave operation after the address byte was NACKed by the firmware. The observed slave operation failure depends on whether Level 2 assert is enabled or not. Enabled: the device stuck in the fault handler due to the assert assignment in the Cy_SCB_I2C_Interrupt. Disabled: the slave sets the transaction completion status and notifies on the transaction completion event after the address was NACKed. The failure is observed only when the slave is configured to accept an address in the RX FIFO.
1.0 Initial version.

API Reference

 Common API for the Serial Communication Block.
 Driver API for EZI2C Slave Peripheral.
 I2C (SCB)
 Driver API for I2C Bus Peripheral.
 Driver API for SPI Peripheral.
 Driver API for UART.