📄 davincievm_eeprom.c
字号:
/*
* Copyright 2005 by Spectrum Digital Incorporated.
* All rights reserved. Property of Spectrum Digital Incorporated.
*
* Not for distribution.
*/
/*
* EEPROM implementation
*
*/
#include "davincievm_eeprom.h"
/* ------------------------------------------------------------------------ *
* *
* DAVINCIEVM_EEPROM_init( ) *
* *
* Initialize the I2C EEPROM *
* *
* ------------------------------------------------------------------------ */
Int16 DAVINCIEVM_EEPROM_init( )
{
return 0;
}
/* ------------------------------------------------------------------------ *
* *
* DAVINCIEVM_EEPROM_read( src, dst, length ) *
* *
* Read from the I2C EEPROM *
* *
* ------------------------------------------------------------------------ */
Int16 DAVINCIEVM_EEPROM_read( Uint32 src, Uint32 dst, Uint32 length )
{
Int16 retcode = 0;
Uint8 addr[2];
addr[0] = src >> 8; // HIGH address
addr[1] = src & 0xFF; // LOW address
/* Send 16-bit address */
retcode |= DAVINCIEVM_I2C_write( EEPROM_I2C_ADDR, addr, 2 );
/* Wait for EEPROM to process */
DAVINCIEVM_waitusec( 1000 );
/* Read data */
retcode |= DAVINCIEVM_I2C_read ( EEPROM_I2C_ADDR, ( Uint8* )dst, length );
return retcode;
}
/* ------------------------------------------------------------------------ *
* *
* DAVINCIEVM_EEPROM_write( src, dst, length ) *
* *
* Write to the I2C EEPROM *
* *
* ------------------------------------------------------------------------ */
Int16 DAVINCIEVM_EEPROM_write( Uint32 src, Uint32 dst, Uint32 length )
{
Int16 retcode = 0;
Uint16 i;
Uint8 buffer[64 + 2];
Uint8* psrc8 = ( Uint8* )src;
Uint8* pdst8 = &buffer[2];
buffer[0] = dst >> 8; // HIGH address
buffer[1] = dst & 0xFF; // LOW address
/* Fill in data */
for ( i = 0 ; i < length ; i++ )
*pdst8++ = *psrc8++;
/* Send 16-bit address and data */
retcode |= DAVINCIEVM_I2C_write( EEPROM_I2C_ADDR, buffer, 2 + length );
return retcode;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -