FreeBSD/sys/boot/arm/at91/bootspi/ee.c
void
EERead(unsigned ee_off, char *data_addr, unsigned size)
{
	const AT91PS_TWI 	twiPtr = AT91C_BASE_TWI;
	unsigned int status;

	if ((ee_off & ~0xff) != ((ee_off + size) & ~0xff)) {
		printf("Crosses page boundary: 0x%x 0x%x\n", ee_off, size);
		return;
	}

	status = twiPtr->TWI_SR;
	status = twiPtr->TWI_RHR;
	twiPtr->TWI_MMR = (iicaddr(ee_off) << 16) | AT91C_TWI_IADRSZ_1_BYTE |
	    AT91C_TWI_MREAD;
	twiPtr->TWI_IADR = ee_off & 0xff;
	twiPtr->TWI_CR = AT91C_TWI_START;
	while (size-- > 1) {
		while (!(twiPtr->TWI_SR & AT91C_TWI_RXRDY))
			continue;
		*(data_addr++) = twiPtr->TWI_RHR;
	}
	twiPtr->TWI_CR = AT91C_TWI_STOP;
	status = twiPtr->TWI_SR;
	while (!(twiPtr->TWI_SR & AT91C_TWI_TXCOMP))
		continue;
	*data_addr = twiPtr->TWI_RHR;
}
/*
 * .KB_C_FN_DEFINITION_START
 * void ReadEEPROM(unsigned ee_addr, char *data_addr, unsigned size)
 *  This global function reads data from the eeprom at ee_addr storing data
 * to data_addr for size bytes.  Assume the TWI has been initialized.
 * This function does not utilize the page read mode to simplify the code.
 * .KB_C_FN_DEFINITION_END
 */
.KB_C_FN_DEFINITION_START
void ReadEEPROM(unsigned ee_addr, char *data_addr, unsigned size)
This global function reads data from the eeprom at ee_addr storing data
to data_addr for size bytes.  Assume the TWI has been initialized.
This function does not utilize the page read mode to simplify the code.
. KB_C_FN_DEFINITION_START void ReadEEPROM ( unsigned ee_addr char * data_addr unsigned size ) This global function reads data from the eeprom at ee_addr storing data to data_addr for size bytes . Assume the TWI has been initialized . This function does not utilize the page read mode to simplify the code .
void
EERead(unsigned ee_off, char *data_addr, unsigned size)
{
	const AT91PS_TWI 	twiPtr = AT91C_BASE_TWI;
	unsigned int status;
	if ((ee_off & ~0xff) != ((ee_off + size) & ~0xff)) {
		printf("Crosses page boundary: 0x%x 0x%x\n", ee_off, size);
		return;
	}
	status = twiPtr->TWI_SR;
	status = twiPtr->TWI_RHR;
	twiPtr->TWI_MMR = (iicaddr(ee_off) << 16) | AT91C_TWI_IADRSZ_1_BYTE |
	    AT91C_TWI_MREAD;
	twiPtr->TWI_IADR = ee_off & 0xff;
	twiPtr->TWI_CR = AT91C_TWI_START;
	while (size-- > 1) {
		while (!(twiPtr->TWI_SR & AT91C_TWI_RXRDY))
			continue;
		*(data_addr++) = twiPtr->TWI_RHR;
	}
	twiPtr->TWI_CR = AT91C_TWI_STOP;
	status = twiPtr->TWI_SR;
	while (!(twiPtr->TWI_SR & AT91C_TWI_TXCOMP))
		continue;
	*data_addr = twiPtr->TWI_RHR;
}
void EERead ( unsigned ee_off , char * data_addr , unsigned size ) { const AT91PS_TWI twiPtr = AT91C_BASE_TWI ; unsigned int status ; if ( ( ee_off & ~ 0xff ) != ( ( ee_off + size ) & ~ 0xff ) ) { printf ( " \n " , ee_off , size ) ; return ; } status = twiPtr -> TWI_SR ; status = twiPtr -> TWI_RHR ; twiPtr -> TWI_MMR = ( iicaddr ( ee_off ) << 16 ) | AT91C_TWI_IADRSZ_1_BYTE | AT91C_TWI_MREAD ; twiPtr -> TWI_IADR = ee_off & 0xff ; twiPtr -> TWI_CR = AT91C_TWI_START ; while ( size -- > 1 ) { while ( ! ( twiPtr -> TWI_SR & AT91C_TWI_RXRDY ) ) continue ; * ( data_addr ++ ) = twiPtr -> TWI_RHR ; } twiPtr -> TWI_CR = AT91C_TWI_STOP ; status = twiPtr -> TWI_SR ; while ( ! ( twiPtr -> TWI_SR & AT91C_TWI_TXCOMP ) ) continue ; * data_addr = twiPtr -> TWI_RHR ; }
.KB_C_FN_DEFINITION_START
 void ReadEEPROM(unsigned ee_addr, char *data_addr, unsigned size)
  This global function reads data from the eeprom at ee_addr storing data
 to data_addr for size bytes.
. KB_C_FN_DEFINITION_START void ReadEEPROM ( unsigned ee_addr char * data_addr unsigned size ) This global function reads data from the eeprom at ee_addr storing data to data_addr for size bytes .