亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來(lái)到蟲(chóng)蟲(chóng)下載站! | ?? 資源下載 ?? 資源專(zhuān)輯 ?? 關(guān)于我們
? 蟲(chóng)蟲(chóng)下載站

?? i2cinterface.c

?? AVR與圖像傳感器OVA6620的接口程序 通過(guò)I2C總線進(jìn)行通信對(duì)圖像進(jìn)行采集和預(yù)處理
?? C
字號(hào):
/*
    Copyright (C) 2004    John Orlando
    
   AVRcam: a small real-time image processing engine.

    This program is free software; you can redistribute it and/or
    modify it under the terms of the GNU General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    General Public License for more details.

    You should have received a copy of the GNU General Public
    License along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

   For more information on the AVRcam, please contact:

   john@jrobot.net

   or go to www.jrobot.net for more details regarding the system.
*/
/***********************************************************
	Module Name: I2CInterface.c
	Module Date: 4/10/2004
	Module Auth: John Orlando
	
	Description: This module is responsible for providing a
	low-level interface to the I2C hardware resident on the
	mega8 processor (also known as the Two-Wire Interface,
	or TWI).  The interface is needed to configure the
	needed registers in the OV6620 camera.  This interface
	is interrupt-driven based on the events that should
	occur upon successful writing of an I2C register.
    
    Revision History:
    Date        Rel Ver.    Notes
    4/10/2004      0.1     Module created
    6/30/2004      1.0     Initial release for Circuit Cellar
                           contest.

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

/*	Includes */
#include <avr/io.h>
#include <avr/twi.h>
#include <avr/signal.h>
#include <avr/interrupt.h>
#include "CamConfig.h"
#include "CommonDefs.h"

/*  Local Variables */

/* These variables are used as storage space for the current
   I2C command being sent over the interface.  They need to
   be volatile since they are dealt with an the TWI ISR */
volatile static unsigned char twi_address;
volatile static unsigned char *twi_data;
volatile static unsigned char twi_ddr;
volatile static unsigned char twi_bytes;
volatile static unsigned char status;
volatile static unsigned char retry_cnt;

/* 	Local Structures and Typedefs */

/*  Extern Variables */

/*  Definitions */
/* Bit definitions for the tw_status register */
#define MAX_TWI_RETRIES 2
#define BUSY 7

/***********************************************************
	Function Name: I2CInt_init
	Function Description: This function is responsible
	for setting up the registers needed for the TWI 
	interface
	
	Inputs:  none
	Outputs: none
***********************************************************/	
void I2CInt_init(void)
{
	TWSR = 0;
    
	/* init the speed of the I2C interface, running at
    100 Kbps */
	TWBR = (FOSC / I2C_SPEED - 16)/2;
}

/***********************************************************
	Function Name: I2CInt_writeData
	Function Description: This function is responsible for
	initiating the process of writing a sequence of bytes
	an I2C slave address.  This function will try to write
	the data three times before giving up.
	Inputs: address: the address of the I2C slave device
			data: a pointer to the data to be written 
				  to the slave...for camera interfacing,
				  the data follows a <register #><data>
				  format
			bytes: the number of bytes to write 
	Outputs: none
***********************************************************/
void I2CInt_writeData(unsigned char address, unsigned char *data, unsigned char bytes)
{
	while(status & (1<<BUSY));		/* Bus is busy wait (or exit with error code) */
	while(TWCR & (1<<TWSTO));
	
	/* copy the needed data and state info to our local I2C command structure */
	twi_address = address;
	twi_data = data;
	twi_bytes = bytes;
	twi_ddr = TW_WRITE;

	retry_cnt = 0;
	
	/* Generate start condition, the remainder of the transfer is interrupt driven and
	   will be performed in the background */
	TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWIE);
	
	status |= (1<<BUSY);
}

/***********************************************************
	Function Name: I2CInt_readData
	Function Description: This funcion is responsible for
	reading the specified number of bytes from a slave
	device.
	Inputs:  address: the slave address to read from
			 data: a pointer to where the data will be stored
			 bytes: the number of bytes to read
	Outputs: none
***********************************************************/
void I2CInt_readData(unsigned char address, unsigned char *data, unsigned char bytes)
{
    /* Bus is busy wait (or exit with error code) */
	while(status & (1<<BUSY));									

	twi_address = address;
	twi_data = data;
	twi_bytes = bytes;
	twi_ddr = TW_READ;

	retry_cnt = 0;
	
	/* Generate start condition, the remainder of the transfer is interrupt driven and
	   will be performed in the background */
	TWCR = (1<<TWINT)|(1<<TWSTA)|(1<<TWEN)|(1<<TWIE);
	
	status |= (1<<BUSY);
}

/***********************************************************
	Function Name: I2CInt_isI2cBusy
	Function Description: This funcion is responsible for
	indicating if the I2C bus is currently busy to external
	modules.
	device.
	Inputs:  none
	Outputs: bool_t - indicating if bus is busy
***********************************************************/
bool_t I2CInt_isI2cBusy(void)
{
	bool_t retVal = FALSE;
	if ( (status & (1<<BUSY)) != 0)
	{
		retVal = TRUE;
	}
	
	return(retVal);
}

/***********************************************************
	Function Name: <interrupt handler for I2C>
	Function Description: This function is responsible for
	implementing the control logic needed to perform a
	read or write operation with an I2C slave.
	Inputs:  none
	Outputs: none
***********************************************************/
SIGNAL(SIG_2WIRE_SERIAL)
{
	unsigned char TWI_status = TWSR & TW_STATUS_MASK;   /* grab just the status bits */
	
    /* the entire I2C handler is state-based...determine
    what needs to be done based on TWI_status */
	switch(TWI_status) 
    {
        case TW_START:									/* Start condition */
        case TW_REP_START:								/* Repeated start condition */
            if(retry_cnt > MAX_TWI_RETRIES) 
            {
                /* generate stop condition if we've reached our retry limit */
                TWCR |= (1<<TWINT)|(1<<TWSTO);					
                status &= ~(1<<BUSY);								
                return;												
            }
            /* indicate read or write */
            TWDR = (twi_address<<1) + twi_ddr;	
            /* TWSTA must be cleared...also clears TWINT */
            TWCR &= ~(1<<TWSTA);
            break;

        case TW_MT_SLA_ACK:							/* Slave acknowledged address, */
            retry_cnt = 0;					
            /* tx the data, and increment the data pointer */
            TWDR = *twi_data;										
            twi_data++;			

            /* clear the int to continue */
            TWCR |= (1<<TWINT);						
            break;

        case TW_MT_SLA_NACK:							/* Slave didn't acknowledge address, */
        case TW_MR_SLA_NACK:
            retry_cnt++;		

            /* retry...*/
            TWCR |= (1<<TWINT)|(1<<TWSTA)|(1<<TWSTO);	
            break;

        case TW_MT_DATA_ACK:							/* Slave Acknowledged data, */
            if(--twi_bytes > 0) 
            {						
                /* more data to send, so send it */
                TWDR = *twi_data;									
                twi_data++;											
                TWCR |= (1<<TWINT);								
            }
            else 
            {
                /* generate the stop condition if needed */
                TWCR |= (1<<TWSTO)|(1<<TWINT);					
                status &= ~(1<<BUSY);								
            }
            break;

        case TW_MT_DATA_NACK:							/* Slave didn't acknowledge data */
            /* send the stop condition */
            TWCR |= (1<<TWINT)|(1<<TWSTO);						
            status &= ~(1<<BUSY);									
            break;

        case TW_MR_SLA_ACK:                             /* Slave acknowledged address */
            if(--twi_bytes > 0) 
            {
                /* if there is more than one byte to read, acknowledge */
                TWCR |= (1<<TWEA)|(1<<TWINT);	
            }
			else
            {
                /* no acknowledge */
                TWCR |= (1<<TWINT);					
            }
            break;

        case TW_MR_DATA_ACK: 							/* Master acknowledged data */
        
            /* grab the received data */
            *twi_data = TWDR;										
            twi_data++;											
            if(--twi_bytes > 0) 
            {
                /* get the next data byte and ack */
                TWCR |= (1<<TWEA)|(1<<TWINT);	
            }
            else
            {
                /* clear out the enable acknowledge bit */
                TWCR &= ~(1<<TWEA);							
            }
            break;

        case TW_MR_DATA_NACK:						/* Master didn't acknowledge data -> end of read process */
            /* read data, and generate the stop condition */
            *twi_data = TWDR;										
            TWCR |= (1<<TWSTO)|(1<<TWINT); 						
            status &= ~(1<<BUSY);											
            break;
	}
}









?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人动漫在线观看| 欧美三级三级三级爽爽爽| 国产成人无遮挡在线视频| 国产精品久久久久精k8| 欧美日韩久久久久久| 国产成人综合在线播放| 三级影片在线观看欧美日韩一区二区| 精品动漫一区二区三区在线观看| 色综合天天狠狠| 国产一区二区三区蝌蚪| 视频一区在线播放| 亚洲视频免费在线| 国产亚洲精品aa| 日韩欧美国产电影| 欧美日韩一区三区四区| 成人免费看黄yyy456| 久久国产视频网| 午夜精品久久久久久久99樱桃| 国产精品久久久久影院| 2欧美一区二区三区在线观看视频 337p粉嫩大胆噜噜噜噜噜91av | 中文字幕一区二区三区蜜月| 日韩午夜av一区| 欧美日韩三级一区| 日本道色综合久久| 97久久精品人人爽人人爽蜜臀| 国产米奇在线777精品观看| 日韩av电影免费观看高清完整版在线观看| 日韩理论片网站| 国产精品的网站| 国产片一区二区| 久久久久88色偷偷免费| 精品美女在线播放| 日韩三级视频在线观看| 这里只有精品视频在线观看| 欧美人体做爰大胆视频| 欧美性猛交xxxx乱大交退制版 | 国产精品超碰97尤物18| 国产欧美一区二区三区鸳鸯浴 | 国产乱码精品一区二区三区av| 日韩激情中文字幕| 日日夜夜免费精品| 日韩一区精品字幕| 免费精品视频在线| 精品系列免费在线观看| 国产一区二区中文字幕| 国产馆精品极品| 国产成人精品一区二区三区四区 | 精品国产凹凸成av人网站| 日韩精品一区二区三区四区视频| 91精品国产综合久久精品app| 欧美肥妇毛茸茸| 日韩你懂的在线播放| 精品国产一区二区三区av性色| 欧美电视剧免费观看| 欧美精品一区二区三区高清aⅴ | 2欧美一区二区三区在线观看视频| 欧美电视剧在线看免费| 国产日韩欧美麻豆| 综合在线观看色| 亚洲综合清纯丝袜自拍| 午夜精品久久久久久久蜜桃app| 日韩国产高清影视| 国产一区二区中文字幕| 成人免费高清视频在线观看| 91欧美一区二区| 欧美日韩国产小视频在线观看| 欧美一级高清片在线观看| 久久精品夜色噜噜亚洲a∨| 国产精品久久久一区麻豆最新章节| 综合色天天鬼久久鬼色| 日产国产高清一区二区三区 | 免费三级欧美电影| 国产91在线观看| 欧美在线色视频| 日韩视频在线观看一区二区| 国产农村妇女精品| 亚洲伊人伊色伊影伊综合网| 久久99精品国产91久久来源| 成人av午夜影院| 正在播放亚洲一区| 国产欧美日韩综合| 亚洲第一搞黄网站| 国产一区视频网站| 欧美亚洲禁片免费| 久久亚洲综合av| 亚洲精品高清视频在线观看| 老司机精品视频线观看86| 大胆欧美人体老妇| 91精品国产综合久久久久久久久久 | 日本成人在线一区| 丁香网亚洲国际| 欧美久久久久久久久久| 国产制服丝袜一区| 99精品国产热久久91蜜凸| 91精品国产欧美一区二区| 欧美经典一区二区三区| 日日夜夜一区二区| 91影视在线播放| 久久免费电影网| 亚洲成人av电影| www.亚洲国产| www欧美成人18+| 日韩主播视频在线| 91麻豆免费视频| 久久九九久久九九| 青娱乐精品在线视频| 色综合久久久久综合体桃花网| 欧美精品一区二区三区在线播放| 亚洲午夜久久久久久久久电影网 | 亚洲码国产岛国毛片在线| 九九久久精品视频| 欧美群妇大交群的观看方式 | 日韩国产欧美在线观看| 91热门视频在线观看| 欧美韩国日本不卡| 韩国精品主播一区二区在线观看 | 国产清纯在线一区二区www| 日韩**一区毛片| 欧美图区在线视频| 亚洲图片激情小说| 成人黄色免费短视频| 老司机免费视频一区二区| 欧美羞羞免费网站| 一区二区激情小说| 色噜噜狠狠成人网p站| 中文字幕永久在线不卡| 成年人国产精品| 中文一区二区在线观看| 成人一区在线观看| 中文字幕免费不卡在线| 高清在线不卡av| 日本一区二区成人在线| 国产盗摄女厕一区二区三区| 精品国产乱码久久久久久影片| 青青草一区二区三区| 日韩一区二区中文字幕| 蜜臀av在线播放一区二区三区| 欧美日韩1区2区| 日韩经典一区二区| 337p亚洲精品色噜噜狠狠| 日韩精品一级中文字幕精品视频免费观看| 欧美午夜不卡在线观看免费| 洋洋成人永久网站入口| 欧美日韩一区二区不卡| 丝袜亚洲另类欧美| 日韩免费视频线观看| 国产一区二区三区免费观看| 国产人成亚洲第一网站在线播放| 国产成人a级片| 一色桃子久久精品亚洲| 91一区在线观看| 亚洲一区二区欧美日韩| 欧美日韩一区二区电影| 免费人成黄页网站在线一区二区| 日韩精品一区二区三区蜜臀| 国产一区二区0| 国产精品护士白丝一区av| 在线一区二区三区四区五区| 午夜视频一区二区三区| 欧美不卡激情三级在线观看| 国产精品123区| 亚洲男人天堂av| 欧美精三区欧美精三区| 国产在线播放一区| 中文字幕亚洲电影| 欧美自拍偷拍一区| 久久精品国产一区二区| 国产精品视频看| 欧美性三三影院| 久久er99精品| 国产精品久久777777| 欧美美女直播网站| 国产老妇另类xxxxx| 一区二区三区资源| 日韩亚洲欧美在线| a在线播放不卡| 丝袜a∨在线一区二区三区不卡| 日本中文字幕一区二区有限公司| www久久久久| 在线国产电影不卡| 国内不卡的二区三区中文字幕| 亚洲日本乱码在线观看| 91精品在线观看入口| 波多野结衣中文字幕一区| 亚洲va欧美va人人爽| 国产欧美日韩在线| 欧美三级乱人伦电影| 国产91在线|亚洲| 婷婷国产在线综合| 国产精品毛片无遮挡高清| 制服丝袜成人动漫| 91免费看`日韩一区二区| 老司机免费视频一区二区三区| 一区在线观看免费| 精品电影一区二区三区| 欧美日韩国产经典色站一区二区三区 | 亚洲日本va午夜在线影院| 精品久久人人做人人爽| 欧美性三三影院| 97精品国产97久久久久久久久久久久|