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

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

?? uimgr.c

?? 基于avr單片機的嵌入式攝像機的源程序
?? 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电影在线观看| 免费日韩伦理电影| 成人美女视频在线观看18| 国产日韩欧美制服另类| 成人精品国产一区二区4080| ...av二区三区久久精品| 91天堂素人约啪| 亚洲麻豆国产自偷在线| 欧美三级视频在线播放| 亚洲成av人片一区二区三区| 欧美一区二区三区视频免费播放| 免费人成黄页网站在线一区二区| 欧美成人精品高清在线播放| 国产91丝袜在线18| 亚洲精品成人少妇| 欧美日本视频在线| 精品一区二区三区视频| 国产精品久久网站| 欧洲一区在线电影| 麻豆久久久久久| 国产精品日韩精品欧美在线| 91国偷自产一区二区三区成为亚洲经典 | 亚洲成av人片一区二区| 日韩欧美电影在线| 不卡的av中国片| 日韩电影免费在线观看网站| 欧美精品久久一区| 日韩激情中文字幕| 国产性天天综合网| 欧美中文字幕一二三区视频| 经典三级视频一区| 亚洲自拍另类综合| 欧美精品一区二区蜜臀亚洲| 色八戒一区二区三区| 美女视频网站黄色亚洲| 日韩一区有码在线| 欧美成人精品二区三区99精品| 99在线精品观看| 久久精品国产亚洲高清剧情介绍 | 欧美日韩高清影院| 成人黄页在线观看| 久久机这里只有精品| 亚洲综合免费观看高清完整版在线| 欧美tk—视频vk| 欧美三级日韩三级| 国产91精品一区二区麻豆亚洲| 日韩成人免费电影| 欧美高清一级片在线观看| 精品国精品国产| 91啪亚洲精品| 久久99国产精品久久99果冻传媒| 日韩一区中文字幕| 久久人人97超碰com| 欧美日韩国产欧美日美国产精品| 成人短视频下载| 国内欧美视频一区二区| 亚洲gay无套男同| 亚洲天堂中文字幕| 久久理论电影网| 欧美精品久久久久久久多人混战| 色综合久久久久网| 国产成人亚洲综合a∨婷婷| 奇米影视7777精品一区二区| 一区二区三区鲁丝不卡| 日韩一区欧美一区| 国产精品污www在线观看| 久久综合五月天婷婷伊人| 成人免费黄色大片| 国产成人一级电影| 国产一区二区三区视频在线播放| 日本欧美久久久久免费播放网| 精品一区二区在线视频| 天天影视涩香欲综合网| 亚洲一区免费观看| 一区二区三区日韩在线观看| 国产精品久久久久婷婷二区次| 久久综合九色综合欧美亚洲| 精品精品国产高清一毛片一天堂| 日韩欧美中文一区二区| 欧美成人福利视频| 久久综合久久综合亚洲| 久久噜噜亚洲综合| 久久精品日韩一区二区三区| 久久综合色播五月| 国产亚洲精品aa午夜观看| 久久久久久综合| 国产日韩欧美制服另类| 国产精品网友自拍| 亚洲欧洲精品天堂一级| 亚洲日本在线看| 亚洲午夜视频在线观看| 午夜免费欧美电影| 成人免费一区二区三区视频| 成人h版在线观看| 国产精品综合视频| 国产呦萝稀缺另类资源| 国产一区二区免费视频| 处破女av一区二区| 色综合中文字幕| 欧美性色黄大片| 欧美zozozo| 欧美激情在线一区二区| 一区二区在线观看免费| 天堂午夜影视日韩欧美一区二区| 精一区二区三区| av动漫一区二区| 欧美日韩国产一级| 久久综合色婷婷| 亚洲欧美日韩综合aⅴ视频| 午夜久久久影院| 国产精品资源网站| 91女厕偷拍女厕偷拍高清| 国产日韩欧美精品电影三级在线| 国产精品美女久久福利网站 | 亚洲精品免费一二三区| 欧美国产日韩亚洲一区| 一区二区三区加勒比av| 免费观看30秒视频久久| 成人免费视频视频在线观看免费 | 久久av中文字幕片| www.性欧美| 欧美一区二区三区婷婷月色| 国产精品免费视频一区| 亚洲国产三级在线| 国产成人精品免费视频网站| 欧美午夜精品理论片a级按摩| 久久一区二区三区国产精品| 亚洲乱码中文字幕| 国产在线国偷精品产拍免费yy| 91老师国产黑色丝袜在线| 欧美电视剧在线看免费| 国产精品超碰97尤物18| 久久精品国产99| 在线一区二区三区四区| 国产欧美精品国产国产专区| 香蕉av福利精品导航| 成人白浆超碰人人人人| 日韩欧美www| 亚洲国产精品久久人人爱蜜臀| 国产成人在线视频网站| 欧美美女激情18p| 亚洲裸体xxx| 成人动漫在线一区| 久久久久久亚洲综合影院红桃| 亚洲成人三级小说| 91在线视频网址| 欧美精品一区二区三区很污很色的 | 亚洲专区一二三| 成人免费视频免费观看| 精品黑人一区二区三区久久| 天堂成人免费av电影一区| 在线欧美小视频| ...xxx性欧美| 夫妻av一区二区| 久久女同精品一区二区| 麻豆精品一区二区av白丝在线| 欧美亚洲图片小说| 亚洲精品v日韩精品| 成人精品高清在线| 久久精品视频网| 国产自产v一区二区三区c| 日韩一区二区在线看片| 五月天激情综合网| 欧美在线一区二区三区| 中文字幕一区二区三区色视频| 国产91精品一区二区麻豆网站 | 久久成人久久鬼色| 制服丝袜激情欧洲亚洲| 天堂资源在线中文精品| 欧美日韩一区精品| 亚洲成人午夜电影| 欧美人xxxx| 日本不卡123| 日韩免费在线观看| 狠狠色丁香婷婷综合| 久久久亚洲国产美女国产盗摄| 久久精品国产久精国产爱| 精品少妇一区二区三区在线视频 | 午夜亚洲国产au精品一区二区| 精品视频在线视频| 日韩中文字幕91| 欧美成人精品3d动漫h| 国产一区在线观看视频| 久久精品综合网| 91在线观看视频| 一级中文字幕一区二区| 欧美欧美欧美欧美| 日韩一区二区三区电影在线观看| 久久综合色鬼综合色| 国产激情一区二区三区桃花岛亚洲| 久久久久久影视| 99久久久精品| 亚洲一区自拍偷拍| 91精品欧美福利在线观看| 麻豆成人久久精品二区三区红| 久久久久久久av麻豆果冻| 97精品国产露脸对白| 亚洲影视在线观看| 日韩免费电影一区| 不卡的av网站|