blinky/sam0/drivers/sercom/i2c/i2c_samd21_r21_d10_d11_l21/i2c_master.c
/**
 * \internal
 * Waits for answer on bus.
 *
 * \param[in,out] module  Pointer to software module structure
 *
 * \return Status of bus.
 * \retval STATUS_OK           If given response from slave device
 * \retval STATUS_ERR_TIMEOUT  If no response was given within specified timeout
 *                             period
 */
\internal
Waits for answer on bus.

\param[in,out] module  Pointer to software module structure

\return Status of bus.
\retval STATUS_OK           If given response from slave device
\retval STATUS_ERR_TIMEOUT  If no response was given within specified timeout
period
\ internal Waits for answer on bus . \ param [ in out ] module Pointer to software module structure \ return Status of bus . \ retval STATUS_OK If given response from slave device \ retval STATUS_ERR_TIMEOUT If no response was given within specified timeout period
enum status_code _i2c_master_wait_for_bus(
		struct i2c_master_module *const module)
{
	Assert(module);
	Assert(module->hw);
	SercomI2cm *const i2c_module = &(module->hw->I2CM);
	uint16_t timeout_counter = 0;
	while (!(i2c_module->INTFLAG.reg & SERCOM_I2CM_INTFLAG_MB) &&
			!(i2c_module->INTFLAG.reg & SERCOM_I2CM_INTFLAG_SB)) {
		if (++timeout_counter >= module->buffer_timeout) {
			return STATUS_ERR_TIMEOUT;
		}
	}
	return STATUS_OK;
}
enum status_code _i2c_master_wait_for_bus ( struct i2c_master_module * const module ) { Assert ( module ) ; Assert ( module -> hw ) ; SercomI2cm * const i2c_module = & ( module -> hw -> I2CM ) ; uint16_t timeout_counter = 0 ; while ( ! ( i2c_module -> INTFLAG . reg & SERCOM_I2CM_INTFLAG_MB ) && ! ( i2c_module -> INTFLAG . reg & SERCOM_I2CM_INTFLAG_SB ) ) { if ( ++ timeout_counter >= module -> buffer_timeout ) { return STATUS_ERR_TIMEOUT ; } } return STATUS_OK ; }
\internal
 Waits for answer on bus.
\ internal Waits for answer on bus .
/* Sanity check arguments */ /* Wait for reply. */ /* Check timeout condition. */