XilinxProcessorIPLib/drivers/iic/examples/xiic_tenbitaddr_example.c
int IicTenBitAddrExample(void)
{
	int Status;
	u8 Index;
	XIic_Config *ConfigPtr;	/* Pointer to configuration data */

	/*
	 * Initialize the IIC driver so that it is ready to use.
	 */
	ConfigPtr = XIic_LookupConfig(IIC_DEVICE_ID);
	if (ConfigPtr == NULL) {
		return XST_FAILURE;
	}

	Status = XIic_CfgInitialize(&IicInstance, ConfigPtr,
					ConfigPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Set the options to enable 10-bit addressing.
	 */
	XIic_SetOptions(&IicInstance, XII_SEND_10_BIT_OPTION);

	/*
	 * Setup the Interrupt System.
	 */
	Status = SetupInterruptSystem(&IicInstance);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * Include the Slave functions.
	 */
	XIic_SlaveInclude();

	/*
	 * Set the Transmit, Receive and Status Handlers.
	 */
	XIic_SetStatusHandler(&IicInstance, &IicInstance,
				  (XIic_StatusHandler) StatusHandler);
	XIic_SetSendHandler(&IicInstance, &IicInstance,
				(XIic_Handler) SendHandler);
	XIic_SetRecvHandler(&IicInstance, &IicInstance,
				(XIic_Handler) ReceiveHandler);

	/*
	 * Set the Address as a RESPOND type.
	 */
	Status = XIic_SetAddress(&IicInstance, XII_ADDR_TO_RESPOND_TYPE,
				 SLAVE_ADDRESS);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}

	/*
	 * The IIC Master on this bus should initiate the transfer
	 * and write data to the slave at this instance.
	 */
	TenBitAddrReadData(ReadBuffer, RECEIVE_COUNT);

	for (Index = 0; Index < SEND_COUNT; Index++) {
		WriteBuffer[Index] = Index;
	}

	/*
	 * The IIC Master on this bus should initiate the transfer
	 * and read data from the slave.
	 */
	TenBitAddrWriteData(SEND_COUNT);

	return XST_SUCCESS;
}
/*****************************************************************************/
/**
*
* This function writes and reads the data as a slave. The IIC master on the bus
* initiates the transfers.
*
*
* @return	XST_SUCCESS if successful else XST_FAILURE.
*
* @note		None.
*
******************************************************************************/
This function writes and reads the data as a slave. The IIC master on the bus
initiates the transfers.
This function writes and reads the data as a slave . The IIC master on the bus initiates the transfers .
int IicTenBitAddrExample(void)
{
	int Status;
	u8 Index;
	XIic_Config *ConfigPtr;	
	ConfigPtr = XIic_LookupConfig(IIC_DEVICE_ID);
	if (ConfigPtr == NULL) {
		return XST_FAILURE;
	}
	Status = XIic_CfgInitialize(&IicInstance, ConfigPtr,
					ConfigPtr->BaseAddress);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XIic_SetOptions(&IicInstance, XII_SEND_10_BIT_OPTION);
	Status = SetupInterruptSystem(&IicInstance);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	XIic_SlaveInclude();
	XIic_SetStatusHandler(&IicInstance, &IicInstance,
				  (XIic_StatusHandler) StatusHandler);
	XIic_SetSendHandler(&IicInstance, &IicInstance,
				(XIic_Handler) SendHandler);
	XIic_SetRecvHandler(&IicInstance, &IicInstance,
				(XIic_Handler) ReceiveHandler);
	Status = XIic_SetAddress(&IicInstance, XII_ADDR_TO_RESPOND_TYPE,
				 SLAVE_ADDRESS);
	if (Status != XST_SUCCESS) {
		return XST_FAILURE;
	}
	TenBitAddrReadData(ReadBuffer, RECEIVE_COUNT);
	for (Index = 0; Index < SEND_COUNT; Index++) {
		WriteBuffer[Index] = Index;
	}
	TenBitAddrWriteData(SEND_COUNT);
	return XST_SUCCESS;
}
int IicTenBitAddrExample ( void ) { int Status ; u8 Index ; XIic_Config * ConfigPtr ; ConfigPtr = XIic_LookupConfig ( IIC_DEVICE_ID ) ; if ( ConfigPtr == NULL ) { return XST_FAILURE ; } Status = XIic_CfgInitialize ( & IicInstance , ConfigPtr , ConfigPtr -> BaseAddress ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XIic_SetOptions ( & IicInstance , XII_SEND_10_BIT_OPTION ) ; Status = SetupInterruptSystem ( & IicInstance ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } XIic_SlaveInclude ( ) ; XIic_SetStatusHandler ( & IicInstance , & IicInstance , ( XIic_StatusHandler ) StatusHandler ) ; XIic_SetSendHandler ( & IicInstance , & IicInstance , ( XIic_Handler ) SendHandler ) ; XIic_SetRecvHandler ( & IicInstance , & IicInstance , ( XIic_Handler ) ReceiveHandler ) ; Status = XIic_SetAddress ( & IicInstance , XII_ADDR_TO_RESPOND_TYPE , SLAVE_ADDRESS ) ; if ( Status != XST_SUCCESS ) { return XST_FAILURE ; } TenBitAddrReadData ( ReadBuffer , RECEIVE_COUNT ) ; for ( Index = 0 ; Index < SEND_COUNT ; Index ++ ) { WriteBuffer [ Index ] = Index ; } TenBitAddrWriteData ( SEND_COUNT ) ; return XST_SUCCESS ; }
This function writes and reads the data as a slave.
This function writes and reads the data as a slave .
/* Pointer to configuration data */ /*
	 * Initialize the IIC driver so that it is ready to use.
	 */ /*
	 * Set the options to enable 10-bit addressing.
	 */ /*
	 * Setup the Interrupt System.
	 */ /*
	 * Include the Slave functions.
	 */ /*
	 * Set the Transmit, Receive and Status Handlers.
	 */ /*
	 * Set the Address as a RESPOND type.
	 */ /*
	 * The IIC Master on this bus should initiate the transfer
	 * and write data to the slave at this instance.
	 */ /*
	 * The IIC Master on this bus should initiate the transfer
	 * and read data from the slave.
	 */