Ejemplo n.º 1
0
MV_VOID mvVbSpiRead(MV_U16 lineId, MV_U8 address, mv_line_t lineType, MV_U8 *data)
{
	MV_U8 control = 0, spiMode;
	MV_U32 val1 = 0, val2 = 0, cmd = 0;

#ifdef MV_TDM_2CHANNELS
	spiMode = mvBoardTdmSpiModeGet();

	if(lineType == MV_LINE_FXO)
	{
		if(spiMode) /* daisy-chain */
		{
	   		control = DAA_READ_CONTROL_BYTE << 1; /* 2 channels */
		}
		else /* dedicated CS */
		{
			control = DAA_READ_CONTROL_BYTE;
		}

		val1 =  (MV_U32)((address<<8) | control);
		cmd = TRANSFER_BYTES(2) | ENDIANESS_MSB_MODE | RD_MODE | READ_1_BYTE | CLK_SPEED_LO_DIV;
	}
	else /* MV_LINE_FXS */
	{
		address |= 0x80;

		if(spiMode)
		{
			val1 = (MV_U32)((address<<8) | (1 << lineId));
			cmd = TRANSFER_BYTES(2) | ENDIANESS_MSB_MODE | RD_MODE | READ_1_BYTE | CLK_SPEED_LO_DIV;
		}
		else
		{
			val1 = address;
			cmd = TRANSFER_BYTES(1) | ENDIANESS_MSB_MODE | RD_MODE | READ_1_BYTE | CLK_SPEED_LO_DIV;
		}

	}

	mvTdmSpiRead(val1, val2, cmd, lineId, data);

#else /* MV_TDM_32CHANNELS */
	/* TBD - Fix dedicated SPI driver APIs  */

#endif /* MV_TDM_2CHANNELS */
}
Ejemplo n.º 2
0
static MV_VOID mvTdmDaisyChainModeSet(MV_VOID)
{
	mvOsPrintf("Setting Daisy Chain Mode\n");
	while( (MV_REG_READ(SPI_CTRL_REG) & SPI_STAT_MASK) == SPI_ACTIVE);
	MV_REG_WRITE(SPI_CODEC_CMD_LO_REG, (0x80<<8) | 0);
	MV_REG_WRITE(SPI_CODEC_CTRL_REG, TRANSFER_BYTES(2) | ENDIANESS_MSB_MODE | WR_MODE | CLK_SPEED_LO_DIV);
	MV_REG_WRITE(SPI_CTRL_REG, MV_REG_READ(SPI_CTRL_REG) | SPI_ACTIVE);
	/* Poll for ready indication */
	while( (MV_REG_READ(SPI_CTRL_REG) & SPI_STAT_MASK) == SPI_ACTIVE);
}
Ejemplo n.º 3
0
unsigned char readDaaDirectReg(unsigned int daa_dev, unsigned char address)
{

	unsigned char data, control = 0;
	MV_DAA_DEV *pDaaDev = (MV_DAA_DEV *)daa_dev;
	unsigned int val1 = 0, val2 = 0, cmd = 0;

	control |= 0x60;

	if(work_mode)
		control |= pDaaDev->ch;       

	val1 =  (unsigned int)((address<<8) | control);
	cmd = TRANSFER_BYTES(2) | ENDIANESS_MSB_MODE | RD_MODE | READ_1_BYTE | CLK_SPEED_LO_DIV;


	mvTdmSpiRead(val1, val2, cmd, pDaaDev->ch, &data);
	return data;
}
Ejemplo n.º 4
0
void writeDaaDirectReg(unsigned int daa_dev, unsigned char address, unsigned char data)
{
	/*unsigned short addr;*/
	MV_DAA_DEV *pDaaDev = (MV_DAA_DEV *)daa_dev;
	unsigned char control = 0;
	unsigned int val1 = 0, val2 = 0, cmd = 0;


	control = 0x20;

	if(work_mode)
		control |= pDaaDev->ch;       

	val1 = (unsigned int)((address<<8) | control);
	val2 = (unsigned int)data;
	cmd = TRANSFER_BYTES(3) | ENDIANESS_MSB_MODE | WR_MODE | CLK_SPEED_LO_DIV;



	mvTdmSpiWrite(val1, val2, cmd, pDaaDev->ch);
}