예제 #1
0
MXL_STATUS SemcoCtrl_ReadRegister(UINT8 I2cSlaveAddr, UINT8 RegAddr, UINT8 *DataPtr)
{
	MXL_STATUS status = MXL_TRUE;
	AVL63X1_ErrorCode r = AVL63X1_EC_OK;

	// OEM should implement I2C read protocol that complies with MxL601 I2C
	// format.

	// 8 bit Register Read Protocol:
	// +------+-+-----+-+-+----+-+----------+-+-+
	// |MASTER|S|SADDR|W| |0xFB| |RegAddr   | |P|
	// +------+-+-----+-+-+----+-+----------+-+-+
	// |SLAVE |         |A|    |A|          |A| |
	// +------+-+-----+-+-+----+-+----------+-+-+
	// +------+-+-----+-+-+-----+--+-+
	// |MASTER|S|SADDR|R| |     |MN|P|
	// +------+-+-----+-+-+-----+--+-+
	// |SLAVE |         |A|Data |  | |
	// +------+---------+-+-----+--+-+
	// Legends: SADDR(I2c slave address), S(Start condition), MA(Master Ack), MN(Master NACK), 
	// P(Stop condition)

	AVL_uchar buffer[3]={0};
	UINT8 i2c_addr;
	AVL_uint16 size=0;

	i2c_addr=I2cSlaveAddr+0x00;//write
	buffer[0]=0xFB;
	buffer[1]=RegAddr;
	size=2;

	//	pbiinfo("zxguan   [%s %d]-------------\n",__FUNCTION__,__LINE__);	
	r=AVL63X1_II2C_Repeater_WriteData(i2c_addr,buffer,size,pAVL_Semco_Chip);
	if(r!=AVL63X1_EC_OK)
	{
		pbiinfo("zxguan   [%s %d]-------------\n",__FUNCTION__,__LINE__);	
		return MXL_FALSE;
	}

	i2c_addr=I2cSlaveAddr;
	size=1;
//	pbiinfo("zxguan   [%s %d]-------------\n",__FUNCTION__,__LINE__);	
	r=AVL63X1_II2C_Repeater_ReadData(i2c_addr, DataPtr, size,pAVL_Semco_Chip);
	if (r != AVL63X1_EC_OK)
	{
		pbiinfo("zxguan   [%s %d]------r--%d-----\n",__FUNCTION__,__LINE__,r);	
		return MXL_FALSE;
	}

	return MXL_TRUE;
}
예제 #2
0
AVL63X1_ErrorCode AVL_AlpsTDAC7D01A_GetStatus(struct AVL_Tuner *pTuner)
{
	AVL63X1_ErrorCode r;
	AVL_uchar ucTunerStatus;

	// Set the number of bytes to be read from the tuner
	// Read the tuner status byte from the tuner
	r = AVL63X1_II2C_Repeater_ReadData((AVL_uchar)(pTuner->m_uiSlaveAddress), &ucTunerStatus, 1, pTuner->m_pAVL_Chip);

	// Update the tuner status structure
	pTuner->m_sStatus.m_uiLock = (AVL_uint16)((ucTunerStatus >> 6) & 0x01);
	pTuner->m_sStatus.m_uiReset = (AVL_uint16)((ucTunerStatus >> 7) & 0x01);

	return(r);
}
예제 #3
0
AVL63X1_ErrorCode AVL_Changhong_DTI7_GetStatus(struct AVL_Tuner *pTuner)
{
	AVL63X1_ErrorCode r;
	AVL_uchar ucTunerStatus;
	AVL_uint16 uiNumBytes;

	uiNumBytes = 1;
	r = AVL63X1_II2C_Repeater_ReadData((AVL_uchar)(pTuner->m_uiSlaveAddress), &ucTunerStatus, uiNumBytes, pTuner->m_pAVL_Chip);

	// Update the tuner status structure

	pTuner->m_sStatus.m_uiLock = (AVL_uint16)((ucTunerStatus >> 6) & 0x01);
	pTuner->m_sStatus.m_uiReset = (AVL_uint16)((ucTunerStatus >> 7) & 0x01);

	return(r);
}
예제 #4
0
AVL_MxL603_MXL_STATUS AVL_MxLWare603_OEM_ReadRegister(UINT8 devId, UINT8 RegAddr, UINT8 *DataPtr)
{
  // OEM should implement I2C read protocol that complies with MxL603 I2C
  // format.

  // 8 bit Register Read Protocol:
  // +------+-+-----+-+-+----+-+----------+-+-+
  // |MASTER|S|SADDR|W| |0xFB| |RegAddr   | |P|
  // +------+-+-----+-+-+----+-+----------+-+-+
  // |SLAVE |         |A|    |A|          |A| |
  // +------+-+-----+-+-+----+-+----------+-+-+
  // +------+-+-----+-+-+-----+--+-+
  // |MASTER|S|SADDR|R| |     |MN|P|
  // +------+-+-----+-+-+-----+--+-+
  // |SLAVE |         |A|Data |  | |
  // +------+---------+-+-----+--+-+
  // Legends: SADDR(I2c slave address), S(Start condition), MA(Master Ack), MN(Master NACK), 
  // P(Stop condition)

  AVL_MxL603_MXL_STATUS status = MxL603_MXL_TRUE;
  AVL63X1_ErrorCode r = AVL63X1_EC_OK;

/* If OEM data is implemented, customer needs to use OEM data structure related operation 
   Following code should be used as a reference. 
   For more information refer to sections 2.5 & 2.6 of MxL603_mxLWare_API_UserGuide document.

  UINT8 i2cSlaveAddr;
  UINT8 i2c_bus;
  user_data_t * user_data = (user_data_t *) AVL_MxL603_OEM_DataPtr[devId];
 
  if (user_data)
  {
    i2cSlaveAddr = user_data->i2c_address;           // get device i2c address
    i2c_bus = user_data->i2c_bus;                   // get device i2c bus  
  
    sem_up(user_data->sem);                         // up semaphore if needed

    // I2C Write operation 
    status = USER_I2C_READ_FUNCTION(i2cSlaveAddr, i2c_bus, RegAddr, DataPtr);
    
    sem_down(user_data->sem);                       // down semaphore
    user_data->i2c_cnt++;                           // user statistics
  }

*/

  /* If OEM data is not required, customer should treat devId as I2C slave Address */

  //devId = devId;
  //RegAddr = RegAddr;
  //*DataPtr = *DataPtr;
  AVL_uchar buffer[3] = {0};
  UINT8 i2c_addr;
  AVL_uint16 size = 0;

  i2c_addr = devId + 0x00;//write
  buffer[0] = 0xFB;
  buffer[1] = RegAddr;
  size = 2;
  r = AVL63X1_II2C_Repeater_WriteData(i2c_addr, buffer, size, pAVLChipForMxL603);
  if(r != AVL63X1_EC_OK)
  {
	  return MxL603_MXL_FALSE;
  }

  i2c_addr = devId;
  size = 1;
  r = AVL63X1_II2C_Repeater_ReadData(i2c_addr, DataPtr, size,pAVLChipForMxL603);
  if (r != AVL63X1_EC_OK)
  {
	  return MxL603_MXL_FALSE;
  }

  return MxL603_MXL_TRUE;

  //return status;
}