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

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? i2cinterface.c

?? ov7620是采用cmos傳感器技術的攝像頭
?? C
字號:
/***********************************************************
    Module Name: I2CInterface.c
    Module Date: 4/10/2004
    Module Auth: John Orlando 
    Copyright (c) 2004 John Orlando  All Rights Reserved 

    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.

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

/*	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;
    }
}









?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
日韩你懂的在线观看| 亚洲影院理伦片| 91精品久久久久久久99蜜桃| 成人看片黄a免费看在线| 久久99国产精品免费网站| 日韩av在线发布| 日韩精品一卡二卡三卡四卡无卡| 亚洲精品高清在线| 一区二区不卡在线播放 | 在线成人高清不卡| 色噜噜狠狠一区二区三区果冻| 9l国产精品久久久久麻豆| 不卡电影一区二区三区| 99精品欧美一区二区三区小说 | 福利一区二区在线| 美腿丝袜亚洲综合| 国产精品99久久久久久似苏梦涵 | 亚洲婷婷国产精品电影人久久| 国产精品欧美一区喷水| 亚洲欧美另类小说| 日韩国产成人精品| 国产一区在线不卡| 成年人网站91| 欧美群妇大交群的观看方式| 日韩一卡二卡三卡国产欧美| 26uuu精品一区二区| 国产精品高潮久久久久无| 亚洲视频1区2区| 免费成人在线播放| 成人app软件下载大全免费| 欧美视频精品在线观看| 欧美电影免费观看高清完整版在线 | 亚洲国产精品久久人人爱| 日韩极品在线观看| 粉嫩在线一区二区三区视频| 91成人国产精品| 久久综合久色欧美综合狠狠| 中文字幕制服丝袜一区二区三区| 亚洲国产日日夜夜| 国产精一区二区三区| 在线观看免费一区| 欧美激情艳妇裸体舞| 同产精品九九九| 成人精品国产一区二区4080| 在线电影院国产精品| 成人欧美一区二区三区黑人麻豆 | 欧美一卡2卡三卡4卡5免费| 国产精品久久久久精k8| 精品一区二区日韩| 色综合久久综合网| 中文字幕免费观看一区| 免费成人av在线播放| 91久久精品国产91性色tv| 久久精品视频网| 日本欧美一区二区| 欧美日本乱大交xxxxx| 国产精品久久久久毛片软件| 国产一区二区三区综合| 欧美精品18+| 一二三区精品福利视频| 成人激情黄色小说| 国产日韩精品一区二区三区在线| 免费看日韩a级影片| 欧美性猛片xxxx免费看久爱| 自拍偷拍国产精品| 曰韩精品一区二区| 成人国产亚洲欧美成人综合网| 精品久久人人做人人爽| 日本不卡免费在线视频| 欧美日韩一二三| 亚洲影院免费观看| 欧美探花视频资源| 亚洲va欧美va人人爽午夜| 色天使色偷偷av一区二区| 欧美国产日韩亚洲一区| 成人18视频在线播放| 中文字幕在线观看不卡视频| 国产成人99久久亚洲综合精品| 久久久午夜精品| 国产伦理精品不卡| 中文字幕国产精品一区二区| 国产99久久久国产精品潘金| 国产亚洲一区二区在线观看| 国产在线视频不卡二| 久久久精品免费观看| 成人午夜精品在线| 国产精品乱码人人做人人爱| 99精品热视频| 亚洲综合图片区| 在线成人免费视频| 久久99久久精品| 久久中文字幕电影| 99精品桃花视频在线观看| 亚洲丝袜精品丝袜在线| 欧美日韩一区小说| 全部av―极品视觉盛宴亚洲| 欧美tk丨vk视频| 成人黄色大片在线观看| 亚洲第四色夜色| 日韩欧美一级特黄在线播放| 久久99精品国产91久久来源| 中文字幕av不卡| 精品1区2区在线观看| 国产乱码精品一区二区三区忘忧草 | 在线这里只有精品| 视频一区二区三区在线| 国产三级精品视频| 色欧美乱欧美15图片| 免费成人在线视频观看| 17c精品麻豆一区二区免费| 欧美区视频在线观看| 国产一区二区三区蝌蚪| 亚洲男女一区二区三区| 欧美不卡在线视频| 色噜噜狠狠色综合中国| 久久爱www久久做| 亚洲精品国产无天堂网2021 | 激情国产一区二区| 亚洲欧美成人一区二区三区| 日韩写真欧美这视频| 99久久精品免费| 久久av资源站| 亚洲一区二区精品久久av| 国产欧美精品在线观看| 欧美日本乱大交xxxxx| 白白色 亚洲乱淫| 经典三级视频一区| 视频一区国产视频| 亚洲综合色视频| 中文字幕欧美激情一区| 欧美电影免费观看完整版| 欧美亚洲国产bt| www.在线成人| 国产乱人伦偷精品视频不卡| 日韩电影一区二区三区| 亚洲国产欧美在线| 一区二区三区欧美在线观看| 久久久久国产精品免费免费搜索| 91麻豆精品国产91久久久| 日本久久精品电影| 91网站最新地址| av一本久道久久综合久久鬼色| 国产在线麻豆精品观看| 日本在线不卡视频| 首页国产欧美久久| 亚洲bt欧美bt精品| 亚洲国产精品一区二区www| 亚洲色图一区二区三区| 中文字幕在线观看一区| 国产精品久久久久永久免费观看| 国产欧美日韩激情| 国产精品久久久久影院色老大 | 色婷婷精品久久二区二区蜜臂av| 国产激情一区二区三区四区| 精品一二三四区| 黄色精品一二区| 国产精品一区二区三区四区 | 99在线精品一区二区三区| 高清国产一区二区三区| 成人妖精视频yjsp地址| 成人免费视频app| 91丝袜国产在线播放| 91丨国产丨九色丨pron| 在线免费av一区| 欧美精品第1页| 久久久久久免费网| 国产精品九色蝌蚪自拍| 一区二区在线观看免费视频播放| 亚洲午夜日本在线观看| 偷拍一区二区三区| 狠狠色综合播放一区二区| 大陆成人av片| 色噜噜久久综合| 51精品视频一区二区三区| 精品国产乱码久久久久久图片| 国产女人18毛片水真多成人如厕| 国产免费成人在线视频| 亚洲精品国产一区二区精华液| 五月天中文字幕一区二区| 久久99精品一区二区三区 | 在线看一区二区| 91麻豆精品国产91久久久久久久久 | 91日韩一区二区三区| 欧美高清视频不卡网| 久久午夜国产精品| 又紧又大又爽精品一区二区| 奇米影视一区二区三区| 99免费精品在线| 日韩西西人体444www| 亚洲欧洲美洲综合色网| 日精品一区二区三区| 国产91清纯白嫩初高中在线观看| 在线精品国精品国产尤物884a| 欧美草草影院在线视频| 亚洲精品成人a在线观看| 麻豆成人av在线| 91久久精品一区二区二区| 久久久久久久久99精品| 亚洲123区在线观看| 不卡电影一区二区三区|