XilinxProcessorIPLib/drivers/v_hdmitxss/examples/hdcp_key_utility/hdcp_key_utility.c
unsigned EepromReadByte(u16 Address, u8 *BufferPtr, u16 ByteCount)
{
	volatile unsigned ReceivedByteCount;
	u16 StatusReg;
	u8 WriteBuffer[sizeof(Address)];

	WriteBuffer[0] = (u8)(Address >> 8);
	WriteBuffer[1] = (u8)(Address);

	/*
	 * Set the address register to the specified address by writing
	 * the address to the device, this must be tried until it succeeds
	 * because a previous write to the device could be pending and it
	 * will not ack until that write is complete.
	 */
	do {
		StatusReg = XIic_ReadReg(XHDCP_IIC_BASEADDR, XIIC_SR_REG_OFFSET);
		if(!(StatusReg & XIIC_SR_BUS_BUSY_MASK)) {
			ReceivedByteCount = XIic_Send(XHDCP_IIC_BASEADDR,
							EEPROM_ADDRESS,
							WriteBuffer,
							sizeof(Address),
							XIIC_STOP);

			if (ReceivedByteCount != sizeof(Address)) {

				/* Send is aborted so reset Tx FIFO */
				XIic_WriteReg(XHDCP_IIC_BASEADDR,
						XIIC_CR_REG_OFFSET,
						XIIC_CR_TX_FIFO_RESET_MASK);
				XIic_WriteReg(XHDCP_IIC_BASEADDR,
						XIIC_CR_REG_OFFSET,
						XIIC_CR_ENABLE_DEVICE_MASK);
			}
		}

	} while (ReceivedByteCount != sizeof(Address));

	/*
	 * Read the number of bytes at the specified address from the EEPROM.
	 */
	ReceivedByteCount = XIic_Recv(XHDCP_IIC_BASEADDR, EEPROM_ADDRESS,
					BufferPtr, ByteCount, XIIC_STOP);

	/*
	 * Return the number of bytes read from the EEPROM.
	 */
	return ReceivedByteCount;
}
/*****************************************************************************/
/**
* This function reads a number of bytes from the IIC serial EEPROM into a
* specified buffer.
*
* @param	Address contains the address in the EEPROM to read from.
* @param	BufferPtr contains the address of the data buffer to be filled.
* @param	ByteCount contains the number of bytes in the buffer to be read.
*		This value is not constrained by the page size of the device
*		such that up to 64K may be read in one call.
*
* @return	The number of bytes read. A value less than the specified input
*		value indicates an error.
*
* @note		None.
*
****************************************************************************/
This function reads a number of bytes from the IIC serial EEPROM into a
specified buffer.
This function reads a number of bytes from the IIC serial EEPROM into a specified buffer .
unsigned EepromReadByte(u16 Address, u8 *BufferPtr, u16 ByteCount)
{
	volatile unsigned ReceivedByteCount;
	u16 StatusReg;
	u8 WriteBuffer[sizeof(Address)];
	WriteBuffer[0] = (u8)(Address >> 8);
	WriteBuffer[1] = (u8)(Address);
	do {
		StatusReg = XIic_ReadReg(XHDCP_IIC_BASEADDR, XIIC_SR_REG_OFFSET);
		if(!(StatusReg & XIIC_SR_BUS_BUSY_MASK)) {
			ReceivedByteCount = XIic_Send(XHDCP_IIC_BASEADDR,
							EEPROM_ADDRESS,
							WriteBuffer,
							sizeof(Address),
							XIIC_STOP);
			if (ReceivedByteCount != sizeof(Address)) {
				XIic_WriteReg(XHDCP_IIC_BASEADDR,
						XIIC_CR_REG_OFFSET,
						XIIC_CR_TX_FIFO_RESET_MASK);
				XIic_WriteReg(XHDCP_IIC_BASEADDR,
						XIIC_CR_REG_OFFSET,
						XIIC_CR_ENABLE_DEVICE_MASK);
			}
		}
	} while (ReceivedByteCount != sizeof(Address));
	ReceivedByteCount = XIic_Recv(XHDCP_IIC_BASEADDR, EEPROM_ADDRESS,
					BufferPtr, ByteCount, XIIC_STOP);
	return ReceivedByteCount;
}
unsigned EepromReadByte ( u16 Address , u8 * BufferPtr , u16 ByteCount ) { volatile unsigned ReceivedByteCount ; u16 StatusReg ; u8 WriteBuffer [ sizeof ( Address ) ] ; WriteBuffer [ 0 ] = ( u8 ) ( Address >> 8 ) ; WriteBuffer [ 1 ] = ( u8 ) ( Address ) ; do { StatusReg = XIic_ReadReg ( XHDCP_IIC_BASEADDR , XIIC_SR_REG_OFFSET ) ; if ( ! ( StatusReg & XIIC_SR_BUS_BUSY_MASK ) ) { ReceivedByteCount = XIic_Send ( XHDCP_IIC_BASEADDR , EEPROM_ADDRESS , WriteBuffer , sizeof ( Address ) , XIIC_STOP ) ; if ( ReceivedByteCount != sizeof ( Address ) ) { XIic_WriteReg ( XHDCP_IIC_BASEADDR , XIIC_CR_REG_OFFSET , XIIC_CR_TX_FIFO_RESET_MASK ) ; XIic_WriteReg ( XHDCP_IIC_BASEADDR , XIIC_CR_REG_OFFSET , XIIC_CR_ENABLE_DEVICE_MASK ) ; } } } while ( ReceivedByteCount != sizeof ( Address ) ) ; ReceivedByteCount = XIic_Recv ( XHDCP_IIC_BASEADDR , EEPROM_ADDRESS , BufferPtr , ByteCount , XIIC_STOP ) ; return ReceivedByteCount ; }
This function reads a number of bytes from the IIC serial EEPROM into a
specified buffer.
This function reads a number of bytes from the IIC serial EEPROM into a specified buffer .
/*
	 * Set the address register to the specified address by writing
	 * the address to the device, this must be tried until it succeeds
	 * because a previous write to the device could be pending and it
	 * will not ack until that write is complete.
	 */ /* Send is aborted so reset Tx FIFO */ /*
	 * Read the number of bytes at the specified address from the EEPROM.
	 */ /*
	 * Return the number of bytes read from the EEPROM.
	 */