⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 example.c

📁 I2c驱动
💻 C
字号:
/****************************************************************************/
/* Copyright (c) 1999-2007  Digital Core Design  DCD                        */
/****************************************************************************/
/* Please review the terms of the license agreement before using this file. */
/* If you are not an authorized user, please destroy this source code file  */
/* and notify DCD immediately that you inadvertently received an            */
/* unauthorized copy.                                                       */
/****************************************************************************/
/*                                                                          */
/*--------------------------------------------------------------------------*/
/* Project name         : DI2CS                                             */
/* Project description  : DI2CS - I2C BUS INTERFACE-SLAVE                   */
/*                                                                          */
/* File name            : example.c                                         */
/* File contents        : DI2CS C compiler interface functions              */
/*                        sample test.                                      */
//--------------------------------------------------------------------------
// Design Engineer      : T.K.
// Version              : 1.37
// Last modification    : 2007-01-24
//----------------------------------------------------------------------------
// Functions body are defined in "di2cs.h" file for DP80390/DP8051
//****************************************************************************

#include "di2cs.h"

volatile unsigned char slave_address, datain;
// very simple DI2CS interface test
int main()
{
 slave_address=0xAA;
 datain=0x20;
 
 
 ownaddr_di2cs( slave_address ); // Set Own address
 enable_di2cs(); // Enable DI2CS module
 
 while(1){
   if (read_di2cs(DI2CS_SR)& SR_RREQ) // Read received byte
     datain=readbuf_di2cs();
   if (read_di2cs(DI2CS_SR)& SR_TREQ){ // Submit byte
     writebuf_di2cs(datain);
	 datain++;
   }
 }

 return 0;
}

⌨️ 快捷键说明

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