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

📄 i2c.h

📁 DSP的一个范例
💻 H
字号:
/******************************************************************************/
//
// Name: SCCB Software Interface for Video Device configurations - C Callable
//
/*****************************************************************************************************************

(C) Copyright 2003 - Analog Devices, Inc.  All rights reserved.

File Name:	I2C_BF561_rev03.asm	

Date Modified:	22 December 04		TL		Rev 2.0

Software:       VisualDSP++3.5 (November Update)

Hardware:		BF561 EZ-KIT Board

Special Connections:  None

Purpose:		To configure video devices 
				
				
Program Parameters:

************************************************************************************************/

/*************** SCCB Start Settings**************************************/
/*Before Calling the SCCB_Interface the inputs to the SCCB_Taskmanager	 */
/*must be done. 														 */
/* Write to the "SCCB_Control" a "1" for reading from the Device or 	 */
/* a "2" for writing to the Device.										 */
/*																		 */
/* Leave the total number of bytes in "SCCB_Wordcount".Device Addresses  */
/* and Word Addresses included.											 */
/*																		 */
/* Write all data to the "SCCB_DataIn". 								 */
/* e.g.Writing to the device:											 */
/*																		 */
/*			SCCB_DataIn 			Device Address	(LSB must be Zero)	 */
/*									Word Address						 */
/*									Data 1								 */
/*									Data 2								 */
/*									  .									 */
/*************************************************************************/
/* (e.g.Reading from the device:										 */
/*			SCCB_DataIn 			Device Address	(LSB must be zero)   */
/*									Word Address						 */
/*									Device Address	(LSB must be one)	 */
/*																		 */
/*																		 */
/*	The data elements received can be found in the array 				 */
/*									_SCCB_DataOut[10]					 */
/*																		 */
/*																		 */
/*																		 */
/*																		 */
/*************************************************************************/

#ifndef _I2C_INCLUDE
#define _I2C_INCLUDE

/* To use the I2C routine, simply call the I2C_wr and I2C_rd	*/
/* to write to or read from the slave device, e.g. the video	*/
/* encoder or decoder. Slave address is the hardware address	*/
/* of the slave device, on receiving the slave address, the 	*/
/* corresponding slave device will acknowledge by pulling		*/
/* the Sdata line(PF0 here) low. The reg_subaddress is the		*/
/* subaddress of the slave device you want to write to or read	*/
/* from. The value is just the value you want to configure.		*/
/* To read from the device, you need to send out the slave 		*/
/* WRITE address first (NOT READ ADDRESS !!!), followed by the	*/
/* subaddress from which you want to read the value and THEN 	*/
/* the slave READ address. You can find examples in the main.c	*/
/* The above description is based on the use of the ADV7185 and	*/
/* ADV7304A, so if other devices are used, the configuration may*/
/* differ.														*/

#define I2C_wr(slave_addr, reg_subaddr, hivalue,lowvalue)\
		asm(".extern SCCB_DataIn;");\
		asm(".extern SCCB_Word_Count;");\
		asm(".extern SCCB_Control;");\
		asm(".extern _SCCB_In_Progress;");\
		asm(".extern SCCB_Interface;");\
		asm("p0.l = SCCB_DataIn;");\
		asm("p0.h = SCCB_DataIn;");\
		asm("r0=%0;" :: "d"(slave_addr));\
		asm("[p0++]=r0;");\
		asm("r0=%0;" :: "d"(reg_subaddr));\
		asm("[p0++]=r0;");\
		asm("r0=%0;" :: "d"(hivalue));\
		asm("[p0++]=r0;");\
		asm("r0=%0;" :: "d"(lowvalue));\
		asm("[p0++]=r0;");\
		asm("p0.l = SCCB_Word_Count;");\
		asm("p0.l = SCCB_Word_Count;");\
		asm("r0=4(z);");\
		asm("[p0]=r0;");\
		asm("p0.l = SCCB_Control;");\
		asm("p0.h = SCCB_Control;");\
		asm("r0 = 2 (z);");\
		asm("[p0] = r0;");\
		asm("p0.h = _SCCB_In_Progress;");\
		asm("p0.l = _SCCB_In_Progress;");\
		asm("r0 = 1;");\
		asm("[p0] = r0;");\
		asm("CALL SCCB_Interface;")

#define I2C_rd(slave_addr_wr, reg_subaddr, slave_addr_rd)\
		asm(".extern SCCB_DataIn;");\
		asm(".extern SCCB_Word_Count;");\
		asm(".extern SCCB_Control;");\
		asm(".extern _SCCB_In_Progress;");\
		asm(".extern SCCB_Interface;");\
		asm("p0.l = SCCB_DataIn;");\
		asm("p0.h = SCCB_DataIn;");\
		asm("r0=%0;" :: "d"(slave_addr_wr));\
		asm("[p0++]=r0;");\
		asm("r0=%0;" :: "d"(reg_subaddr));\
		asm("[p0++]=r0;");\
		asm("r0=%0;" :: "d"(slave_addr_rd));\
		asm("[p0++]=r0;");\
		asm("p0.l = SCCB_Word_Count;");\
		asm("p0.l = SCCB_Word_Count;");\
		asm("r0=5(z);");\
		asm("[p0] = r0;");\
		asm("p0.l = SCCB_Control;");\
		asm("p0.h = SCCB_Control;");\
		asm("r0 = 1 (z);");\
		asm("[p0] = r0;");\
		asm("p0.h = _SCCB_In_Progress;");\
		asm("p0.l = _SCCB_In_Progress;");\
		asm("r0 = 1;");\
		asm("[p0] = r0;");\
		asm("CALL SCCB_Interface;")

#endif
		
		
	

⌨️ 快捷键说明

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