亚洲欧美第一页_禁久久精品乱码_粉嫩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在线| 国产精品嫩草影院com| 91蜜桃视频在线| 午夜免费欧美电影| 91在线国产福利| 天天av天天翘天天综合网色鬼国产 | 一区二区高清免费观看影视大全| 亚洲男同1069视频| 99久久99久久免费精品蜜臀| 国产精品免费丝袜| 日韩精品免费视频人成| 国产视频在线观看一区二区三区 | 美脚の诱脚舐め脚责91| 一区二区三区美女| 91麻豆6部合集magnet| 国产成人精品免费网站| 欧美福利视频一区| 色综合久久久久久久| 韩日精品视频一区| 日韩电影在线观看电影| 欧美一区二区三区视频在线| 亚洲1区2区3区视频| 久久久久久毛片| 欧美日韩aaaaa| 青青草一区二区三区| 欧美精品v日韩精品v韩国精品v| 天堂蜜桃一区二区三区| 91社区在线播放| 91黄视频在线| 在线免费观看视频一区| 欧美第一区第二区| 精品国产伦一区二区三区免费| 日本韩国欧美三级| 欧美自拍丝袜亚洲| 国产精品美日韩| 久久婷婷久久一区二区三区| 欧美精品tushy高清| 欧美三级在线播放| 精品无码三级在线观看视频| 中文字幕在线观看一区| 一区二区三区精密机械公司| 国产精品理论片在线观看| 亚洲乱码国产乱码精品精98午夜| 亚洲欧美成人一区二区三区| 亚洲激情五月婷婷| 精品剧情v国产在线观看在线| 欧美亚洲动漫制服丝袜| 不卡视频免费播放| 色婷婷精品大在线视频| 色偷偷一区二区三区| 国产一区二区伦理| 91浏览器打开| 色哟哟一区二区| 在线欧美日韩国产| 中文一区二区在线观看| 国产日韩精品久久久| 亚洲三级理论片| 图片区日韩欧美亚洲| 国产成人在线视频免费播放| 欧美喷潮久久久xxxxx| 精品久久人人做人人爰| 国产精品视频观看| 亚洲成人在线观看视频| 国产一区二区三区国产| 日韩欧美中文一区二区| 中文字幕巨乱亚洲| 极品少妇xxxx偷拍精品少妇| 国产成人精品影视| 91视频www| 欧美三级乱人伦电影| 国产香蕉久久精品综合网| 免费高清在线一区| 99re在线精品| 中文字幕欧美日韩一区| 国产成人精品免费一区二区| 91啪九色porn原创视频在线观看| 欧美性猛片aaaaaaa做受| 综合久久久久久| 91污在线观看| 一区二区免费在线| 国产在线视频不卡二| 欧美自拍偷拍一区| 久久久久99精品一区| 激情综合一区二区三区| 精品国产乱码久久久久久老虎| 久久se精品一区精品二区| av在线不卡免费看| 亚洲18女电影在线观看| 国产成人鲁色资源国产91色综| 日本女人一区二区三区| 日韩久久精品一区| 色综合视频一区二区三区高清| 国产欧美日韩三区| 国产精品亚洲午夜一区二区三区| 欧美一级二级在线观看| 国内国产精品久久| 欧美精品一区二区三区在线播放| 91丝袜呻吟高潮美腿白嫩在线观看| 亚洲欧洲中文日韩久久av乱码| 日本韩国一区二区三区| 亚洲欧美怡红院| xfplay精品久久| 在线亚洲一区观看| 成人av网在线| 久久成人麻豆午夜电影| 一区二区三区不卡在线观看| 欧美成人一区二区三区在线观看| 欧美亚一区二区| 日韩激情视频在线观看| 日本一区二区在线不卡| 懂色av中文一区二区三区| 韩国一区二区三区| 国产日韩欧美不卡在线| 欧美日韩免费电影| 韩国毛片一区二区三区| 岛国精品一区二区| 蜜臀av国产精品久久久久| 亚洲chinese男男1069| 中国色在线观看另类| 欧美www视频| 97精品国产露脸对白| 日本在线观看不卡视频| 国产精品高清亚洲| 欧美伦理电影网| 欧美视频第二页| 日韩一区二区三区高清免费看看| 国产激情一区二区三区四区 | 青娱乐精品视频| 国产一区二区电影| 精品一区二区三区在线播放视频| 亚洲欧洲一区二区在线播放| 国产精品美女久久久久aⅴ国产馆| 欧美日韩精品二区第二页| 国产一区免费电影| 成人午夜av电影| 91浏览器打开| 欧美日高清视频| 成人午夜大片免费观看| 国产视频一区在线播放| 久久九九99视频| 日韩欧美资源站| 成人av资源在线观看| 91亚洲永久精品| 91麻豆精品国产91久久久久久 | 老汉av免费一区二区三区| 不卡视频一二三四| 9191久久久久久久久久久| 久久综合九色综合欧美98| 国产精品看片你懂得| 亚洲精品国产精品乱码不99| 亚洲精品欧美激情| 国产日韩欧美精品一区| 国产精品乱人伦一区二区| 欧美xxxx老人做受| 一区二区三区中文字幕电影 | 麻豆精品一区二区| 国产清纯白嫩初高生在线观看91| 午夜精品视频一区| 国产精品综合一区二区三区| 欧美调教femdomvk| 国产精品免费久久久久| 亚洲精品你懂的| 91免费视频观看| 国产精品国产自产拍高清av| 日韩av在线发布| 欧美日免费三级在线| 777午夜精品免费视频| 国产精品天干天干在观线| 亚洲蜜桃精久久久久久久| 欧洲av在线精品| 国产精品乱人伦| 天天色天天操综合| 欧美图区在线视频| 国产精品卡一卡二| 91成人在线精品| 亚洲成人精品一区| 国产在线精品免费av| 岛国av在线一区| 成人免费在线播放视频| 成人午夜电影久久影院| 国产欧美综合色| 亚洲成a人v欧美综合天堂| 蜜臀久久99精品久久久久久9| 欧美精品视频www在线观看| 亚洲国产视频一区| 日韩一区二区精品葵司在线| 国产精品久久久久影视| 欧美裸体一区二区三区| 成人美女视频在线看| 久久久电影一区二区三区| 亚洲少妇30p| 九九精品一区二区| 亚洲视频一二区| 成人高清免费观看| 麻豆精品一区二区| 欧美性淫爽ww久久久久无| 国产精品麻豆欧美日韩ww| 久久国产精品72免费观看| 国产精品国产精品国产专区不蜜|