📄 i2c_write.c
字号:
/*************************** Function Message ****************************
** Funtion Name : I2C_WriteByte
** Arguments: wAddrressWritten : the address of the memory byte unit
** of the E2prom which will be written and the written
** content is the followed argument : bContent ;
** bContent : the content will be written to the byte
** unit of the E2Prom
** Return Value: TRUE : write successfully
** FALSE : write error
** Restrictions: none
** created by: ZhangBin
** Last modified: 12/7/04 (MM/DD/YY)
** Description: the main program of the EOS System
***************************************************************************/
void I2C_WriteByte(BYTE bAddrressWritten, BYTE bContent )
{
BYTE i;
I2C_Start();
I2C_Txd(_WR_ID__);
I2C_Txd(bAddrressWritten);
I2C_Txd(bContent);
I2C_Stop();
I2C_DELAY();
};
/*************************** Function Message ****************************
** Funtion Name : I2C_WritePage
** Arguments: wAddrressWritten : the address of the memory byte unit
** of the E2prom which will be written and the written
** content is the followed argument : bContent ;
** bContent : the content will be written to the byte
** unit of the E2Prom
** Return Value: none
** Restrictions: none
** created by: ZhangBin
** Last modified: 12/7/04 (MM/DD/YY)
** Description: the main program of the EOS System
***************************************************************************/
void I2C_WritePage(WORD wHeadAddrress, BYTE* dptr, BYTE bLoop)
{
BYTE i;
I2C_Start();
I2C_Txd(WR_ID);
i = (BYTE)(wHeadAddrress >> 8);
I2C_Txd(i);
i = (BYTE)wHeadAddrress;
I2C_Txd(i);
do{
I2C_Txd(*dptr++);
I2C_DELAY();
}while(--bLoop);
I2C_Stop();
DelayMs(10);
};
/*************************** Function Message ****************************
** Funtion Name : I2C_WritePage
** Arguments: wAddrressWritten : the address of the memory byte unit
** of the E2prom which will be written and the written
** content is the followed argument : bContent ;
** bContent : the content will be written to the byte
** unit of the E2Prom
** Return Value: TRUE : write successfully
** FALSE : write error
** Restrictions: none
** created by: ZhangBin
** Last modified: 12/7/04 (MM/DD/YY)
** Description: note that the dptr pointer , if in bank2 or bank3, should
** setup anoter new function
***************************************************************************/
void I2C_WritePage2(BYTE bHeadAddrress, bank2 BYTE* dptr, BYTE bLoop)
{
BYTE i;
I2C_Start();
I2C_Txd(WR_ID);
I2C_Txd(bHeadAddrress);
do{
I2C_Txd(*dptr++);
I2C_DELAY();
}while(--bLoop);
I2C_Stop();
DelayMs(10);
};
/*************************** Function Message ****************************
** Funtion Name : I2C_Erase
** Arguments: wAddrressWritten : the address of the memory byte unit
** of the E2prom which will be written and the written
** content is the followed argument : bContent ;
** bContent : the content will be written to the byte
** unit of the E2Prom
** Return Value: TRUE : write successfully
** FALSE : write error
** Restrictions: none
** created by: ZhangBin
** Last modified: 12/7/04 (MM/DD/YY)
** Description: the main program of the EOS System
***************************************************************************
void I2C_Erase(WORD wHeadAddrress, BYTE bData, BYTE bLoop)
{
BYTE i;
I2C_Start();
I2C_Txd(WR_ID);
i = (BYTE)(wHeadAddrress >> 8);
I2C_Txd(i);
i = (BYTE)wHeadAddrress;
I2C_Txd(i);
do{
I2C_Txd(bData);
I2C_DELAY();
}while(--bLoop);
I2C_Stop();
DelayMs(10);
};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -