static RET_CODE i2c_gpio_std_read(lld_i2c_t *p_lld,
                                       u8 slv_addr,
                                       u8 *p_buf,
                                       u32 wlen,
                                       u32 rlen,
                                       u32 param)
{
  RET_CODE ret = 0;
  i2c_gpio_priv_t *p_priv = (i2c_gpio_priv_t *)p_lld->p_priv;
  if(wlen == 0)
  {
    return i2c_gpio_read(p_lld, slv_addr, p_buf, rlen, param);
  }
  
  ret = i2c_gpio_write(p_lld, slv_addr, p_buf, wlen, param);
  if(SUCCESS != ret)
  {
    DEBUG("@@i2c seq_read error1!\n");
    return ret;
  }  
  
  ret = i2c_gpio_read_no_stop(p_priv, slv_addr, p_buf, rlen);
  if(SUCCESS != ret)
  {
    DEBUG("@@i2c seq_read error2!\n");
    return ret;
  } 
  
  i2c_gpio_phase_stop(p_priv);

  return SUCCESS;
}
Example #2
0
YW_ErrorType_T i2c_soft_read(YWI2CSoft_Handle_t Handle,
			     U8              *Buffer_p,
			     U32             MaxLen,
			     U32             Timeout,
			     U32             *ActLen_p)
{
	int                     ret;
	//YW_ErrorType_T          ErrorType = YW_NO_ERROR;
	U32                     DeviceIndex, HandleIndex;
	YWI2CSoft_OpenParam_t   *Param = (YWI2CSoft_OpenParam_t *)Handle;

	YWI2C_INTERFACE(("%s line:%d in\n", __FUNCTION__, __LINE__));
	if (!CheckI2cParam(Handle, &DeviceIndex, &HandleIndex))
	{
		YWI2C_DEBUG(("%s %d\n", __FUNCTION__, __LINE__));
		return YWHAL_ERROR_INVALID_HANDLE;
	}

	if (!Param->IsOpen)
	{
		YWI2C_DEBUG(("%s %d\n", __FUNCTION__, __LINE__));
		return YWHAL_ERROR_INVALID_HANDLE;
	}

	i2csoft_lock(DeviceIndex);

	ret = i2c_gpio_read(Param->SlaveAddr, Buffer_p, MaxLen, Timeout, &(I2CSoftDevice[DeviceIndex]));

	i2csoft_unlock(DeviceIndex);

	*ActLen_p = ret;
	YWI2C_INTERFACE(("%s line:%d OUT\n", __FUNCTION__, __LINE__));


	return YW_NO_ERROR;

}