/* Waits for a start condition on the bus.  */
enum i2c_slave_direction i2c_slave_get_direction_wait(struct i2c_slave_module *const module)
/* Waits for a start condition on the bus.  */
enum i2c_slave_direction i2c_slave_get_direction_wait(struct i2c_slave_module *const module)
{
	Assert(module);
	Assert(module->hw);
	SercomI2cs *const i2c_hw = &(module->hw->I2CS);
	enum status_code status;
	status = _i2c_slave_wait_for_bus(module);
	if (status != STATUS_OK) {
		return I2C_SLAVE_DIRECTION_NONE;
	}
	if (!(i2c_hw->INTFLAG.reg & SERCOM_I2CS_INTFLAG_AMATCH)) {
		return I2C_SLAVE_DIRECTION_NONE;
	}
	if ((i2c_hw->STATUS.reg & SERCOM_I2CS_STATUS_DIR)) {
		return I2C_SLAVE_DIRECTION_WRITE;
	} else {
		return I2C_SLAVE_DIRECTION_READ;
	}
}