m62393.c

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

C
46
字号
 #include <reg51.h>
 #include"demo.h"
 void init_M62393()
 {  BYTE i;
   //I2C_SendByteWithStart(WRITE_M62393);
   //I2C_SendByte(1);
    
	//for(i=0; i<8; i++)
    //{
	//I2C_SendByte(Userdate.value3.bytes[i]);
    //    ShortDelay(5);     
    //}
      
	//I2C_SendStop();
    //I2C_ReleaseBus();
	for(i=0; i<8; i++)
	 Set_M62393(i+1,Userdate.value3.bytes[i]);

 }
bit Set_M62393(BYTE addr,BYTE val)
{
	BYTE i;
    BYTE temp;	
     
	I2C_SendByteWithStart(WRITE_M62393);   
    I2C_SendByte(addr);
  
    for(i=0; i<8; i++)
    {
    	temp = val;
        temp >>= 7-i;
        temp &= 0x01;
           
		I2C_SDA = temp;
		I2C_SCL = 1;   
            ShortDelay(2);
		I2C_SCL = 0;   
            ShortDelay(2); 		
    }
	I2C_SendStop();
	I2C_ReleaseBus();
    return(I2C_GetACK());
}
 

⌨️ 快捷键说明

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