rw24c16.c

来自「可以从计算机向WINBOND516直接下载程序的源码」· C语言 代码 · 共 38 行

C
38
字号
#include <reg51.h>                             /* define 8051 registers */
#include <stdio.h>  
#include "demo.h"
BYTE read24c16(BYTE address)
{
     BYTE temp;

    
        I2C_SendStop();
        I2C_SendByteWithStart(EEPROMWRITEID);////first 256 byte all is 8*256
        I2C_SendByte(address);
       
        I2C_SendStop();
       
        I2C_SendByteWithStart(EEPROMREADID);
        temp = I2C_GetLastByte();
       
        I2C_SendStop();
       
        I2C_ReleaseBus();
        return(temp);
}
  void write24c16(BYTE address,BYTE value)
  {	    
        I2C_SendStop();
        I2C_SendByteWithStart(EEPROMWRITEID);   //first 256 byte all is 8*256
        I2C_SendByte(address);
        ShortDelay(5);
        I2C_SendByte(value);
        ShortDelay(5);
        I2C_SendStop();
        I2C_ReleaseBus();
		ShortDelay(255);
		
    
  }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?