Master Low-Level

group group_scb_i2c_master_low_level_functions

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.

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.

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.

Return

cy_en_scb_i2c_status_t

Parameters
  • base: The pointer to the I2C SCB instance.

  • address: 7 bit right justified slave address.

  • bitRnW: This 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.

  • timeoutMs: Defines 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.

  • context: The 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.

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.

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.

Return

cy_en_scb_i2c_status_t

Parameters
  • base: The pointer to the I2C SCB instance.

  • address: A 7-bit right-justified slave address.

  • bitRnW: This 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.

  • timeoutMs: Defines 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.

  • context: The 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.

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.

note

Return

cy_en_scb_i2c_status_t

Parameters
  • base: The pointer to the I2C SCB instance.

  • timeoutMs: Defines 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.

  • context: The 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.

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.

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.

Return

cy_en_scb_i2c_status_t

Parameters
  • base: The pointer to the I2C SCB instance.

  • ackNack: A response to a received byte. See cy_en_scb_i2c_command_t for the set of constants.

  • byte: The pointer to the location to store the Read byte.

  • timeoutMs: Defines 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.

  • context: The 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.

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.

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.

Return

cy_en_scb_i2c_status_t

Parameters
  • base: The pointer to the I2C SCB instance.

  • byte: The byte to write to a slave.

  • timeoutMs: Defines 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.

  • context: The 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.