UTILS I2C Functions

UTILS I2C Functions

group UTILS_I2C_Exported_Functions

Functions

stm32_utils_i2c_status_t STM32_UTILS_I2C_ComputeTimingBasic ( const stm32_utils_i2c_timing_basic_config_t * p_config , uint32_t * p_output_timing_reg )

Compute I2C timing according to the current I2C clock source and required I2C clock.

Parameters :
  • p_config – Pointer to a stm32_utils_i2c_timing_basic_config_t structure that contains the required parameters for I2C timing computation.

  • p_output_timing_reg – Pointer to an I2C_TIMINGR register value computed by referring to the I2C initialization section in the Reference Manual. This value is directly computed by STM32CubeMX2.

Return values :
  • STM32_UTILS_I2C_OK – Timing calculation successful.

  • STM32_UTILS_I2C_ERROR – Timing calculation error.

stm32_utils_i2c_status_t STM32_UTILS_I2C_ComputeTimingAdvanced ( const stm32_utils_i2c_timing_advanced_config_t * p_config , uint32_t * p_output_timing_reg )

Compute I2C timing according to the current I2C clock source and required I2C clock.

Parameters :
  • p_config – Pointer to a stm32_utils_i2c_timing_advanced_config_t structure that contains the required parameters for I2C timing computation.

  • p_output_timing_reg – Pointer to an I2C_TIMINGR register value computed by referring to the I2C initialization section in the Reference Manual. This value is directly computed by STM32CubeMX2.

Return values :
  • STM32_UTILS_I2C_OK – Timing calculation successful.

  • STM32_UTILS_I2C_ERROR – Timing calculation error.

stm32_utils_i2c_status_t STM32_UTILS_I2C_CompTimeoutA ( const stm32_utils_i2c_timeouta_config_t * p_config , uint32_t * p_output_timeout_reg )

Compute timeout A using the current I2C clock source, IDLE mode, and timeout requested in ns.

Note

When IDLE mode is disabled, the timeout value must be between 25000000 ns and 35000000 ns per the SMBUS specification.

Note

When IDLE mode is enabled, the timeout value must be under tIDLE= (0xFFF + 1) x 4 x tI2CCLK.

Parameters :
  • p_config – Pointer to a stm32_utils_i2c_timeouta_config_t structure containing the desired timeout parameters.

  • p_output_timeout_reg – Pointer to an I2C_TIMEOUTR register value computed. This value is directly computed by STM32CubeMX2.

Return values :
  • STM32_UTILS_I2C_OK – Timing calculation successful.

  • STM32_UTILS_I2C_INVALID_PARAM – Invalid parameter.

stm32_utils_i2c_status_t STM32_UTILS_I2C_CompTimeoutB ( const stm32_utils_i2c_timeoutb_config_t * p_config , uint32_t * p_output_timeout_reg )

Compute timeout B using the current I2C clock source, device mode, and timeout requested in ns.

Parameters :
  • p_config – Pointer to a stm32_utils_i2c_timeoutb_config_t structure containing the desired timeout parameters.

  • p_output_timeout_reg – Pointer to an I2C_TIMEOUTR register value computed. This value is directly computed by STM32CubeMX2.

Return values :
  • STM32_UTILS_I2C_OK – Timing calculation successful.

  • STM32_UTILS_I2C_INVALID_PARAM – Invalid parameter.