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

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

?? uimgr.c

?? AVR與圖像傳感器OVA6620的接口程序 通過I2C總線進行通信對圖像進行采集和預處理
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*
    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: UIMgr.c
	Module Date: 04/10/2004
	Module Auth: John Orlando
	
	Description: This module is responsible for providing
	the processing to manage the user interface of the
	system.  This user interface is provided via the UART.
	This module handles the incoming serial commands, and
	performs the needed functionality.  It is then
	responsible for generating any needed response to
	the external entity.
    
    Revision History:
    Date        Rel Ver.    Notes
    4/10/2004      0.1     Module created
    6/30/2004      1.0     Initial release for Circuit Cellar
                           contest.
    11/15/2004     1.2     Updated version string to 1.2.
    1/16/2005      1.4     Added code to write the colorMap
                           to EEPROM one byte at a time, 
                           ensuring that the EEPROM is only
                           written when the data is different
                           than the current value (thus saving
                           EEPROM writes).  Updated version
                           string to 1.4.
***********************************************************/

/*	Includes */
#include <avr/io.h>
#include <stdlib.h>
#include <string.h>
#include <avr/eeprom.h>
#include "CommonDefs.h"
#include "UIMgr.h"
#include "UartInterface.h"
#include "CamConfig.h"
#include "Utility.h"
#include "Executive.h"
#include "CamInterface.h"

/* 	Local Structures and Typedefs */

typedef enum
{
	getVersionCmd,
	pingCmd,
	setCameraRegsCmd,
	dumpFrameCmd,
	enableTrackingCmd,
	disableTrackingCmd,
	setColorMapCmd,
	resetCameraCmd,
	noCmd,
	invalidCmd
} UIMgr_Cmd_t;

typedef enum
{
	setRed,
	setGreen,
	setBlue
} setColorState_t;
	

/*  Local Variables */
static unsigned char charCount = 0; 
static unsigned char charIndex = 0;
static unsigned char asciiTokenBuffer[MAX_TOKEN_LENGTH+1]; /* +1 to ensure NULL at end */
static unsigned char tokenCount = 0;
static unsigned char tokenBuffer[MAX_TOKEN_COUNT];
static UIMgr_Cmd_t receivedCmd = noCmd;
static unsigned char AVRcamVersion[] = "AVRcam v1.4\r";

/*  Local Function Declaration */
static unsigned char UIMgr_readRxFifo(void);
static unsigned char UIMgr_readTxFifo(void);
static unsigned char UIMgr_readRxFifo(void);
static void UIMgr_sendNck(void);
static void UIMgr_sendAck(void);
static void UIMgr_convertTokenToCmd(void);
static void UIMgr_convertTokenToValue(void);
static void UIMgr_executeCmd(void);

/*  Extern Variables */
unsigned char UIMgr_rxFifo[UI_MGR_RX_FIFO_SIZE];
unsigned char UIMgr_rxFifoHead=0;
unsigned char UIMgr_rxFifoTail=0;

unsigned char UIMgr_txFifo[UI_MGR_TX_FIFO_SIZE];
unsigned char UIMgr_txFifoHead=0;
unsigned char UIMgr_txFifoTail=0;

/*  Definitions */
#define IS_DATA_IN_TX_FIFO() (!(UIMgr_txFifoHead == UIMgr_txFifoTail))
#define IS_DATA_IN_RX_FIFO() (!(UIMgr_rxFifoHead == UIMgr_rxFifoTail))

/* MAX_EEPROM_WRITE_ATTEMPTS limits the number of writes that can be
done to a particular EEPROM cell, so that it can't possible just 
write to the same cell over and over */
#define MAX_EEPROM_WRITE_ATTEMPTS 3

/***********************************************************
	Function Name: UIMgr_init
	Function Description: This function is responsible for
	initializing the UIMgr module.  It sets up the fifo
	used to hold incoming data, etc.
	Inputs:  none 
	Outputs: none
***********************************************************/	
void UIMgr_init(void)
{
	memset(asciiTokenBuffer,0x00,MAX_TOKEN_LENGTH+1);
	memset(tokenBuffer,0x00,MAX_TOKEN_COUNT);
	memset(UIMgr_txFifo,0x00,UI_MGR_TX_FIFO_SIZE);
	memset(UIMgr_rxFifo,0x00,UI_MGR_RX_FIFO_SIZE);
}

/***********************************************************
	Function Name: UIMgr_dispatchEvent
	Function Description: This function is responsible for
	processing events that pertain to the UIMgr.
	Inputs:  event - the generated event
	Outputs: none
***********************************************************/	
void UIMgr_dispatchEvent(unsigned char event)
{
	switch(event)
	{
		case EV_ACQUIRE_LINE_COMPLETE:
			UIMgr_transmitPendingData();
			break;
			
		case EV_SERIAL_DATA_RECEIVED:		
			UIMgr_processReceivedData();
			break;
			
		case EV_SERIAL_DATA_PENDING_TX:
			UIMgr_flushTxBuffer();
			break;
	}
}
/***********************************************************
	Function Name: UIMgr_transmitPendingData
	Function Description: This function is responsible for
	transmitting a single byte of data if data is waiting
	to be sent.  Otherwise, if nothing is waiting, the
	function just returns.
	Inputs:  none 
	Outputs: none
***********************************************************/
void UIMgr_transmitPendingData(void)
{
	if (IS_DATA_IN_TX_FIFO() == TRUE)
	{
		/* data is waiting...send a single byte */
		UartInt_txByte( UIMgr_readTxFifo() );
	}
}
/***********************************************************
	Function Name: UIMgr_processReceivedData
	Function Description: This function is responsible for
	parsing any serial data waiting in the rx fifo
	Inputs:  none 
	Outputs: none
***********************************************************/
void UIMgr_processReceivedData(void)
{
	unsigned char tmpData = 0;

	/* still need to add a mechanism to handle token counts 
	that are excessive!!! FIX ME!!! */
    
	while(IS_DATA_IN_RX_FIFO() == TRUE)
	{
		tmpData = UIMgr_readRxFifo();
		if (tmpData == '\r') 
		{
			/* we have reached a token separator */
			if (tokenCount == 0)
			{
				/* convert the command */
				UIMgr_convertTokenToCmd();				
			}
			else
			{
				/* convert a value */
				UIMgr_convertTokenToValue();
				tokenCount++;
			}
			/* either way, it is time to try to process the received
			token list since we have reached the end of the cmd. */
			Utility_delay(100);
			if (receivedCmd == invalidCmd ||
			     receivedCmd == noCmd )
			{
				UIMgr_sendNck();
				PUBLISH_EVENT(EV_SERIAL_DATA_PENDING_TX);
			}
			else
			{
				UIMgr_sendAck();
				/* publish the serial data pending event, so it
				will push the ACK out before we execute the cmd */
				PUBLISH_EVENT(EV_SERIAL_DATA_PENDING_TX);
				UIMgr_executeCmd();
			}
			
			/* reset any necessary data */
			tokenCount = 0;
			memset(tokenBuffer,0x00,MAX_TOKEN_COUNT);
		}
		else if (tmpData == ' ')  /* space char */
		{
			/* the end of a token has been reached */
			if (tokenCount == 0)
			{
				UIMgr_convertTokenToCmd();
				tokenCount++;   /* check this...why is this being incremented here??? This
                means we have received a token, with tokenCount == 0, which means it is a
                command...why is this contributing to tokenCount?
                This might cause the set color map command to include too much data, since
                it sets the color map based on tokenCount...CHECK*/
			}
			else
			{
				/* check to see if this token is going to push
				us over the limit...if so, abort the transaction */
				if (tokenCount+1 >= MAX_TOKEN_COUNT)
				{
					/* we received too many tokens, and 
					need to NCK this request, since its too
					large...reset everything...*/
					charCount=0;
					charIndex=0;
					tokenCount=0;
					receivedCmd = invalidCmd;
				}
				else
				{
					/* tokenCount is still in range...*/
					UIMgr_convertTokenToValue();
					tokenCount++;
				}
			}
		}
		else if ( (tmpData >= 'A' && tmpData <= 'Z') ||
				   (tmpData >= '0' && tmpData <= '9') )
		{
			/* a valid range of token was received */
			asciiTokenBuffer[charIndex] = tmpData;
			charCount++;
			charIndex++;
			if (charCount > MAX_TOKEN_LENGTH)
			{
				/* we have received a token that cannot be handled...
				set the received cmd to an invalid cmd, and wait
				for the \r to process it */
				receivedCmd = invalidCmd;
				charIndex = 0;  /* ...so we won't overwrite memory */
			}
		}
		else
		{
			/* an invalid character was received */
			receivedCmd = invalidCmd;
		}
	}  /* end while */
	
	asm volatile("clt"::);  /* clear out the T flag in case it wasn't
								 cleared already */
}						

/***********************************************************
	Function Name: UIMgr_executeCmd
	Function Description: This function is responsible for
	executing whatever cmd is stored in the receivedCmd
	object.
	Inputs:  none 
	Outputs: none
***********************************************************/
static void UIMgr_executeCmd(void)
{
	unsigned char i,eepromData, num_writes=0;
	unsigned char *pData;
    unsigned char eeprom_write_succeeded = FALSE;
#if	DEBUG_COLOR_MAP	
	unsigned char asciiBuffer[5];
#endif

	if (receivedCmd == pingCmd) 
	{
	}
	else if (receivedCmd == getVersionCmd)
	{
		pData = AVRcamVersion;
		while(*pData != 0)
		{		
			UIMgr_writeTxFifo(*pData++);
		}
	}		
	else if (receivedCmd == resetCameraCmd)
	{
		CamInt_resetCam();
	}
	else if (receivedCmd == dumpFrameCmd)
	{
		/* publish the event that will indicate that

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
精品一区免费av| 欧美三级资源在线| 久久蜜桃香蕉精品一区二区三区| 久久精品久久久精品美女| 日韩视频永久免费| 91美女在线看| 亚洲影院理伦片| 欧美精品一区在线观看| 国产91精品在线观看| 亚洲桃色在线一区| 欧美一区二区三区啪啪| 国产91精品精华液一区二区三区| 亚洲天堂久久久久久久| 欧美人与禽zozo性伦| 国产精品一区二区在线播放| 亚洲欧美自拍偷拍色图| 欧美日韩成人在线一区| 国产精品资源网| 亚洲18女电影在线观看| 亚洲精品在线一区二区| 一本一道久久a久久精品| 久久成人av少妇免费| 亚洲精品美国一| 精品国产三级a在线观看| 在线一区二区三区| 国产精品91xxx| 日韩高清不卡一区二区三区| 国产精品免费网站在线观看| 欧美午夜寂寞影院| 成人丝袜视频网| 久久精品国产一区二区三| 一区二区三区在线观看欧美| 久久久亚洲精品石原莉奈| 欧美另类高清zo欧美| 一本久道久久综合中文字幕 | 欧美α欧美αv大片| 在线亚洲一区二区| av高清久久久| 国产精品小仙女| 久久精品99国产精品| 亚洲成人先锋电影| 亚洲精品视频免费看| 中文字幕视频一区二区三区久| 久久久久综合网| 久久免费视频一区| 欧美一区欧美二区| 欧美日韩成人激情| 欧美女孩性生活视频| 日韩三级免费观看| 欧美日韩视频在线一区二区| 色婷婷久久99综合精品jk白丝| av高清不卡在线| 成人听书哪个软件好| 成人短视频下载| 成人午夜电影小说| 99精品视频中文字幕| 成人国产精品免费网站| www.欧美日韩| 99re视频这里只有精品| 白白色 亚洲乱淫| 色综合视频一区二区三区高清| 97国产精品videossex| 97成人超碰视| 欧美日韩一区二区三区四区| 欧美人狂配大交3d怪物一区| 欧美疯狂做受xxxx富婆| 欧美电视剧免费观看| 精品国产不卡一区二区三区| wwwwww.欧美系列| 国产精品久久久久久久久动漫| 成人欧美一区二区三区黑人麻豆| 亚洲激情在线播放| 日韩成人免费电影| 国产福利91精品一区| 99久久综合国产精品| 欧美妇女性影城| 久久婷婷色综合| 亚洲欧美欧美一区二区三区| 亚洲国产日产av| 狠狠v欧美v日韩v亚洲ⅴ| www.一区二区| 欧美日韩高清在线| 久久久国产午夜精品 | 色哟哟日韩精品| 欧美日韩不卡一区| 国产日韩欧美一区二区三区乱码 | 欧美不卡视频一区| 中文字幕成人网| 日韩在线一区二区三区| 国产不卡视频一区| 欧美日韩和欧美的一区二区| 久久久国产精华| 香蕉加勒比综合久久| 国产精品一区专区| 欧美午夜在线一二页| 国产亚洲人成网站| 亚洲国产成人av好男人在线观看| 国产在线国偷精品产拍免费yy| 日本韩国欧美一区| 久久午夜羞羞影院免费观看| 亚洲福利视频一区| 不卡的电视剧免费网站有什么| 欧美蜜桃一区二区三区| 中文字幕电影一区| 久久er99精品| 欧美男同性恋视频网站| 亚洲三级在线观看| 国产福利视频一区二区三区| 日韩精品在线一区二区| 亚洲精品网站在线观看| 激情综合五月婷婷| 欧美一区二区久久久| 亚洲一区二区三区中文字幕在线 | 成人性色生活片免费看爆迷你毛片| 欧美日韩国产美| 亚洲九九爱视频| 91亚洲国产成人精品一区二三| 久久九九99视频| 国产乱一区二区| 日韩欧美精品在线| 蜜臀va亚洲va欧美va天堂 | 精品日韩一区二区| 日韩一区精品视频| 欧美日韩黄视频| 丝袜美腿亚洲色图| 精品视频1区2区| 亚洲精品v日韩精品| 91在线看国产| 亚洲乱码日产精品bd| 91丨九色丨黑人外教| 自拍av一区二区三区| 91尤物视频在线观看| 国产精品久久久久久久久免费樱桃| 国产伦精品一区二区三区免费 | **性色生活片久久毛片| 国产九九视频一区二区三区| 久久久精品一品道一区| 国产福利一区二区三区| 欧美激情在线看| 99re亚洲国产精品| 一区二区三区91| 6080国产精品一区二区| 日韩在线播放一区二区| 日韩一区二区电影在线| 国产露脸91国语对白| 日本一区二区动态图| www.欧美日韩国产在线| 一区二区久久久久久| 3d动漫精品啪啪一区二区竹菊| 美女www一区二区| 久久综合狠狠综合| 99综合电影在线视频| 亚洲成人先锋电影| 精品剧情在线观看| 成人免费高清在线观看| 亚洲自拍偷拍综合| 日韩午夜三级在线| 丁香五精品蜜臀久久久久99网站| 亚洲欧美一区二区不卡| 4438亚洲最大| 波多野结衣中文字幕一区| 亚洲国产一区二区在线播放| 日韩色在线观看| 91在线免费看| 美国十次综合导航| 亚洲欧美在线视频| 欧美一区二区三区四区在线观看| 国产精品亚洲综合一区在线观看| 亚洲精品乱码久久久久久黑人 | 日日夜夜精品视频天天综合网| 精品国产91乱码一区二区三区| 91在线免费视频观看| 久久电影国产免费久久电影| 蜜臀av在线播放一区二区三区 | 成人欧美一区二区三区视频网页| 在线不卡a资源高清| 成人精品视频.| 美女在线一区二区| 亚洲麻豆国产自偷在线| 欧美mv和日韩mv国产网站| 在线日韩av片| 波多野结衣中文字幕一区二区三区 | 成人激情午夜影院| 美女一区二区久久| 亚洲国产中文字幕在线视频综合 | 成人a免费在线看| 玖玖九九国产精品| 午夜欧美视频在线观看| 亚洲欧美日韩国产手机在线| 国产拍欧美日韩视频二区| 欧美一区二区三区在线电影 | 欧美一区二区福利在线| 色综合久久88色综合天天免费| 国产精品一区二区三区乱码| 麻豆91小视频| 日韩精品一二三区| 日韩精品一区第一页| 亚洲成人在线网站| 亚洲午夜在线观看视频在线| 亚洲欧美日韩中文字幕一区二区三区 |