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

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

?? mca25_pgm_buggy.c

?? 基于AVRETH1的最新網絡軟件
?? C
?? 第 1 頁 / 共 2 頁
字號:
/*********************************************************** driver for MCA-25 camera** Author   : {{removed according to contest rules}}*            -> circuitcellar.com avr design contest 2006*            -> Entry #AT2616** 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., 51* Franklin St, Fifth Floor, Boston, MA 02110, USA** http://www.gnu.de/gpl-ger.html***********************************************************/#include "mca25.h"#include "main.h"volatile unsigned char mca25_uart_disabled;unsigned char mca25_cam_busy_for_socket = MCA25_NOT_BUSY;unsigned char mca25_cam_status = 0;volatile unsigned char mca25_cam_active;/* typical usage:  1) mca25_init();     -> trigger a hardware reset and activates mux transfer 2) mca25_configure();     -> set up image format etc. 3) mca25_start_image_grab();    -> activate image grabbing, take a preview image 4) mca25_grab_jpeg();    -> activate jpg transfer 5) mca25_grab_data();    -> get x byte data 6) while (){ mca25_send_data_ack(); mca25_grab_data(); ... }    -> ack & grab loop => see mca25_copy_image_data_to_tcp_buffer() as an example ;) *//*======================================================================| copy the image data to the tcp data buffer, | buffer must be at least CAM_BUFFER_LEN byte long !`======================================================================*/unsigned char mca25_copy_image_data_to_tcp_buffer(char *buffer, int *bufferlen){	unsigned int result16;	unsigned int len = 0;	unsigned char frametype = 0;	//set cam active flag:	mca25_cam_active = 1;		//Errechnet startpunkt der Daten im Tcp buffer	//IP Headerl?ge + TCP Headerl?ge + Ethernetframe	result16 = ((buffer[IP_VERS_LEN] & 0x0F) << 2) + ((buffer[TCP_HDRFLAGS] & 0xF0) >>2) + 14;		//if we have had an error, we need to skip 	//the remaining picture. cam has no ABORT cmd ?!?!	if (mca25_cam_status == MCA25_SKIP_PICTURE){			frametype = 0x48;						//skip the current active picture...			//dirty hack but seems like cam does			//not have any abort commands :(			while (frametype == 0x48){				mca25_uart_disabled = 0;				mca25_send_data_ack();				mca25_uart_disabled = 1;					mca25_grab_data((buffer+result16), &len, &frametype); //grabs 250 byte data			}				mca25_uart_disabled=0;			printf_P(PSTR("\xF9\x01\xEF\x0B\xE3\x07\x23\x0C\x01\x79\xF9"));			mca25_uart_disabled=1;						mca25_cam_status = MCA25_FIRST_DATA;		}		#if USE_SERVO	//this is the _only_ safe position to move the servo	//a servo movement while cam is running freezes the cam ! 	//maybe a seperate power supply for servo can fix this (EM)	if (servo_need_update){		servo_move();		//wait some time		for (unsigned int z=0; z<60000; z++){			for (int y=0; y<20; y++){				nop();nop();nop();nop();nop();nop();			}		}	}#endif		if (mca25_cam_status == MCA25_FIRST_DATA){		//start grab here, this takes a 		//long time...		mca25_start_image_grab();		//initialise jpg dump		mca25_grab_jpeg();				//first packet done		mca25_cam_status = MCA25_NEXT_DATA;	}else{ // if (mca25_cam_status == MCA25_NEXT_DATA){		mca25_uart_disabled = 0;		mca25_send_data_ack();		mca25_uart_disabled = 1;	}		// we use the ethernet buffer for	// storing the image data	// --> make sure it is big enough ! (fixme)	mca25_grab_data((buffer+result16), &len, &frametype); 		//sometimes the last packet seems to be empty	//-> send this dummy data, it does not matter ...	if (len == 0)		len = CAM_BUFFER_LEN;				//store data length	result16 = result16 + len;		//fixme, do something here ...	/*if (result16 >  (MTU_SIZE - 1)){			Buffer_Full = 1;			printf_P(PSTR("WARN: buffer > MTU-1 !\n");			break;	}*/	//Wait a short Time	for(int a = 0;a<1000;a++){nop();};		TCP_New_Packtlen (buffer,bufferlen,result16);		// last picture is XX SH SL CC 00 	// CC = 0x48 -> more data (?)	//    = 0x49 -> last data	if (frametype!=0x48){		// this is important ! after the image grad		// we need to do this! without this the camera		// sometimes hangs while grabbing another image ... strange		// reconfig mux (?)		mca25_uart_disabled=0;		printf_P(PSTR("\xF9\x01\xEF\x0B\xE3\x07\x23\x0C\x01\x79\xF9"));		mca25_uart_disabled=1;				return 0; // this is a smaller packet -> it was the last	}else		return 1; // this is a full packet -> there should be more (fixme)}/*====================================================================== | this is called in the main loop. | it makes sure that the cam does not hang after a | user hits "abort" while loading the picture `======================================================================*/void mca25_check_for_closed_tcpconn(void){	//no transfer active:	if (mca25_cam_busy_for_socket == MCA25_NOT_BUSY)		return;		//reset cam active flag:	mca25_cam_active = 0;		//if cam busy flag is not cleared within 5 seconds	//we have a problem	for (int i=0; i<5000; i++){		_delay_ms(1);	}	if (mca25_cam_active == 0){		//active flag was not set !		//-> maybe someone canceled the image transfer		//-> set new status, httpd will cleanup later:		mca25_cam_busy_for_socket = MCA25_BUSY_ABORTED;	}}/*======================================================================| grab the next x byte data frame| (cam must bei in jpg capture mode!)`======================================================================*/void mca25_grab_data(char *buffer, unsigned int *datalen, char *frametype){	unsigned int j=0;	unsigned char togo=31;																		unsigned char rx=0;	unsigned char state=0;	unsigned char firstframe = 1;	//enable uart:	mca25_uart_disabled=0;		*datalen = 0;		// we start with len=0,	// we extract the packetlength 	// after the first packet and update len	//	// if we re in state12 -> continue, we do not have the full len yet	while( *datalen==0 || (j<*datalen) || state>99 || state == 12 ){		MCA25_STATUS_LED_ON();		while (!(USR & (1<<RXC))){}		rx = UDR;			MCA25_STATUS_LED_OFF();				switch(state){			case 0: 				//no packet header rcv, wait for header:				if (rx == 0xF9)					state = 1;				//else: do nothing				break;			case 1:				//we got a F9				if (rx == 0x83)					state = 2; //we have a data packet				else if (rx == 0xF9){					state = 1; //this is the real start byte					//MCA25_ERROR_LED_ON();				}else{					state = 0; // we missed something, try again.					//MCA25_ERROR_LED_ON();				}				break;			case 2:				//now we expect EF				if (rx == 0xEF){					state = 3;	// packet ok				}else{					if (rx == 0xF9){						//??? happens sometimes						state = 1;					}else{						state = 0; // something went wrong -> retry						//MCA25_ERROR_LED_ON();					}				}				break;			case 3: 					//next byte is frame len:				togo = (rx-1)/2; //rx/2				//printf_P(PSTR("len=%d\n",togo);				//if (togo != 31 && togo != 13) printf_P(PSTR("len=%d\n",togo);				if (firstframe==1)					state = 10; //get frame info				else					state = 100; //grab data				break;			case 10:				//90 01 00 48 00 xx				//this is the first packet and we 				//have not sampled anything				//-> this is 0x90 -> ignore				togo--;				state = 11; 				firstframe = 0;				break;			case 11:				//this is the first packet and 				//this byte is hi(length)				*datalen = (unsigned int)(rx<<8);				togo--;				state = 12;				break;			case 12:				//this is the first packet and 				//this byte is lo(length)								*datalen = (unsigned int)*datalen + (unsigned int)(rx) - 6; //substract the first				                                                            //6byte frame info								//make sure len is valid				if (*datalen > CAM_BUFFER_LEN){					*datalen = CAM_BUFFER_LEN;				}								togo--;				state = 13;				break;			case 13:				//this is the first packet and 				//this byte is the frame type 				*frametype = rx;				togo--;				state = 14;				break;			case 14:				//this is the first packet and 				//this byte is ??? -> ignore				togo--;				state = 15;				break;			case 15:				//this is the first packet and 				//this byte is ??? -> ignore				togo--;				state = 100; //now sample data				break;						case 100:				//now sample data:				if (j<CAM_BUFFER_LEN)					buffer[j] = rx;				else					MCA25_ERROR_LED_ON(); //printf_P(PSTR("ARGHHHHHHHHHHHHHHH\n");				//printf_P(PSTR("OUT[%03d] 0x%02x\n",j,rx);				j++;								togo--;				if (togo == 0)					state = 101;				break;			case 101:				//data is there now we read checksum:				//ignore CS...				//printf_P(PSTR("CSUM=%02x\n",rx);				state = 102;				break;			case 102: 				//we have frame end:				if (rx != 0xF9){						//MCA25_ERROR_LED_ON();						//printf_P(PSTR("FRAME ERROR! @packet:%d: (0x%02x) len=%d\n"),j,rx,togo);				}				//printf_P(PSTR("EOF=%d\n\n",rx);				state = 0;				break;			default:				printf_P(PSTR("yeah stack problems. out of mem ? :-X\n"));		}	}	//disable uart:	mca25_uart_disabled=1;}/*======================================================================| start a jpg grab| (mca_25_start_image_grab() has to be called first)`======================================================================*/void mca25_grab_jpeg(){	//enable uart:	mca25_uart_disabled=0;		// send capture start cmd:	mca25_pgm_send(MCA25_START_JPG);  	//send an ok for the power consumption message	//printf_P(PSTR("\xF9\x21\xEF\x0D\x0D\x0A\x4F\x4B\x0D\x0A\x48\xF9"));	  		//disable uart:	mca25_uart_disabled=1;}/*======================================================================| initialise the image grabbing| it starts preview mode and "skips" a whole preview image`======================================================================*/void mca25_start_image_grab(){	unsigned char state;	unsigned char datapos;	unsigned char buf[MCA25_COMM_BUFFER_LEN];		//enable uart:	mca25_uart_disabled=0;		//grab 6 preview pictures:	for (char i=0; i<6; i++){			/*while ( memcmp_P(buf,PSTR("\xF9\x83\xEF\x07\xA0\x00\x03",7) != 0)			mca25_read_mux_packet(buf);		*/				// wait for go ?! fIXME	 	// f9 83 f9 00 32 02  ???		mca25_read_mux_packet(buf);				// send capture start cmd:		mca25_pgm_send(MCA25_START_CAPTURING_1);		// this delay is neccessary !		// without this we get a lot of		// noise in the picture !		for (unsigned int z=0; z<10000; z++){				nop();nop();nop();nop();nop();nop();		}		mca25_pgm_send(MCA25_START_CAPTURING_2);		mca25_pgm_send(MCA25_START_CAPTURING_3);				//send an ok for the power consumption message			printf_P(PSTR("\xF9\x21\xEF\x0D\x0D\x0A\x4F\x4B\x0D\x0A\x48\xF9"));	  			mca25_send_data_ack();				state = 0;		datapos = 0;			// grab actual image and tell cam to keep it in RAM		// we acknowledge the _preview_ image and download		// the full size image later...		while (state != 100){			mca25_read_mux_packet(buf); //read MUX packet			switch (state){				case 0:					// wait for first packet, decode if is last data					// [F9 83 EF 3F 90 01 00 xx xx FD * ] F9 ]					// xx xx = C3 00 -> first 256 byte					// xx xx = 48 01 -> middle					// xx xx = 49 01 -> last data!				#if CAM_BUFFER_LEN == 256					if (memcmp_P(buf,PSTR("\xF9\x83\xEF\x3F\x90"),5) == 0){#else					// 512byte buf:					// 90 02 00 C3 00 00 					// 90 02 00 48 01 FD					// A0 01 10 49 01 0D					if (memcmp_P(buf,PSTR("\xF9\x83\xEF\x3F\x90\x02"),6) == 0){#endif						if (buf[7] == 0xC3 && buf[8] == 0x00){							//first frame:							datapos = 1;						}else if(buf[7] == 0x48 && buf[8] == 0x01){							//middle							datapos = 2;						}else if(buf[7] == 0x49 && buf[8] == 0x01){							//end:							datapos = 3;						}else if(buf[7] == 0x48 && buf[8] == 0x00){							//end?							datapos = 2;						}else{							//printf_P(PSTR("buf7=%x, buf8=%x\n\n",buf[7],buf[8]);						}						state = 1;						//last data -> send ack!							mca25_send_data_ack();					}else if (memcmp_P(buf,PSTR("\xF9\x83\xEF\x3F\xA0"),5) == 0){						// F9 83 EF 3F A0 00 4C 49 00 49 00 						if(buf[7] == 0x49 && buf[8] == 0x00){							//end when CAM_BUF_LEN = 256							datapos = 3;						}else if(buf[7] == 0x49 && buf[8] == 0x01){							//end when CAM_BUF_LEN = 512							datapos = 3;						}else{							//printf_P(PSTR("buf7=%x, buf8=%x\n\n",buf[7],buf[8]);						}						state = 1;						//last data -> send ack!							mca25_send_data_ack();					}					break;	

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
亚洲成人先锋电影| 成人黄色av网站在线| 一区二区三区精品在线观看| 亚洲va欧美va天堂v国产综合| 三级久久三级久久| 国产一区欧美一区| 色哟哟一区二区三区| 欧美一级理论片| 国产婷婷色一区二区三区四区| 亚洲欧美日韩电影| 精品一区二区日韩| 91久久奴性调教| 久久婷婷国产综合国色天香| 一级做a爱片久久| 精品一区二区免费看| 欧美日韩中文国产| 欧美激情资源网| 日韩精品一二三| 91色在线porny| 精品国产一区二区三区av性色| 亚洲精品综合在线| 国产综合色在线| 欧美军同video69gay| 中文在线一区二区| 久久99精品国产91久久来源| 欧美日韩dvd在线观看| 精品国产乱子伦一区| 亚洲成人精品一区| 91啪亚洲精品| 久久久久久久精| 日韩在线a电影| 91国产免费观看| 日本一区二区三区电影| 久久99国产精品成人| 欧美卡1卡2卡| 亚洲国产视频一区| 色综合天天狠狠| 中文字幕免费不卡在线| 蜜臀av性久久久久蜜臀av麻豆| 色吧成人激情小说| 最好看的中文字幕久久| 波多野结衣一区二区三区| 337p粉嫩大胆色噜噜噜噜亚洲| 日韩电影免费在线看| 欧美亚洲国产一区二区三区va| 国产精品你懂的在线| 国产成人精品亚洲日本在线桃色| 久久综合九色综合97婷婷女人| 麻豆高清免费国产一区| 欧美日韩国产综合久久| 亚洲国产另类av| 99这里只有精品| 一区二区中文视频| 在线观看国产日韩| 琪琪一区二区三区| 日韩欧美中文字幕一区| 捆绑调教一区二区三区| 欧美日本一道本在线视频| 日本vs亚洲vs韩国一区三区 | 国产精品99久久久久久有的能看 | 亚洲欧美日韩中文字幕一区二区三区 | 国产亚洲自拍一区| 国产不卡视频一区| 26uuu亚洲综合色欧美 | 水野朝阳av一区二区三区| 欧美日韩一卡二卡| 日韩成人午夜精品| 欧美电视剧免费全集观看 | 中文字幕一区二区在线播放| 国产精品激情偷乱一区二区∴| 成年人午夜久久久| 在线欧美日韩国产| 亚洲h在线观看| 高清国产一区二区| 亚洲一二三区在线观看| 欧美一区二区性放荡片| 一本大道av一区二区在线播放| 国内外成人在线视频| 丝袜美腿高跟呻吟高潮一区| 亚洲精品日产精品乱码不卡| 国产婷婷色一区二区三区在线| 日韩精品最新网址| 91麻豆精品国产无毒不卡在线观看 | 国产精品青草久久| 欧美日韩精品综合在线| 国产一区二区毛片| 成人高清视频在线观看| 黑人巨大精品欧美一区| 日韩电影在线观看网站| 天天色图综合网| 亚洲国产精品久久人人爱蜜臀| 亚洲视频狠狠干| 亚洲色图视频网站| 亚洲人成小说网站色在线 | 香港成人在线视频| 性做久久久久久免费观看欧美| 亚洲一区在线观看免费观看电影高清| 中文字幕中文乱码欧美一区二区| 日韩手机在线导航| 欧美日韩国产系列| 欧美视频一区二| 欧美日韩夫妻久久| 69堂成人精品免费视频| 欧美日韩国产另类一区| 欧美日韩一区二区在线观看视频| 欧美亚洲一区二区在线观看| 在线免费精品视频| 在线精品视频免费播放| 欧美日韩精品综合在线| 6080午夜不卡| 久久久久久久久久久久久久久99| 中文字幕国产一区二区| 久久久久久久久伊人| 久久婷婷综合激情| 亚洲小说欧美激情另类| 午夜影视日本亚洲欧洲精品| 美美哒免费高清在线观看视频一区二区| 日韩黄色一级片| 国产一区中文字幕| 北条麻妃一区二区三区| 欧美亚洲免费在线一区| 日韩午夜精品视频| 久久精品夜夜夜夜久久| 国产精品不卡在线| 亚洲高清视频的网址| 黄色成人免费在线| 精品综合久久久久久8888| 色婷婷av一区二区三区软件| 欧美久久一二区| 337p粉嫩大胆噜噜噜噜噜91av| 亚洲图片另类小说| 视频一区二区欧美| 国产成人免费视频网站| 91久久国产综合久久| 日韩精品中文字幕一区二区三区| 国产欧美一区二区精品久导航| 亚洲视频一区二区在线观看| 亚洲成人av一区| 不卡的电影网站| 91精品国产综合久久精品| 久久日一线二线三线suv| 一区二区三区国产| 久久草av在线| 色88888久久久久久影院按摩 | 久久免费看少妇高潮| 成人欧美一区二区三区黑人麻豆 | 精品在线播放午夜| 91首页免费视频| 日韩免费视频线观看| 自拍偷拍欧美激情| 精品一区二区三区在线视频| 91网站最新地址| 日韩欧美久久久| 亚洲在线视频一区| 国v精品久久久网| 日韩美女视频在线| 亚洲一区二区三区自拍| 丁香天五香天堂综合| 欧美丰满一区二区免费视频| 成人欧美一区二区三区白人| 秋霞午夜鲁丝一区二区老狼| 99久久777色| 久久婷婷成人综合色| 日韩制服丝袜av| 在线观看91视频| 国产精品美女久久久久aⅴ国产馆| 免费在线一区观看| 精品视频一区三区九区| 亚洲女性喷水在线观看一区| 国产91综合网| 久久伊人蜜桃av一区二区| 亚洲综合小说图片| 国产九九视频一区二区三区| 国产欧美日韩在线| 韩国av一区二区三区四区| 欧美精品粉嫩高潮一区二区| 一区二区三区免费在线观看| av爱爱亚洲一区| 国产精品久久久久久久午夜片| 国产成人在线视频免费播放| 精品国产伦一区二区三区观看体验 | 亚洲精品大片www| 国产精品白丝av| 精品国产成人在线影院 | 久久美女高清视频| 久久福利视频一区二区| 欧美一区二区三区思思人| 爽好久久久欧美精品| 91美女在线视频| 亚洲一区免费观看| 欧美三区在线视频| 香蕉久久一区二区不卡无毒影院| 91高清视频在线| 一区二区三区高清| 欧美在线看片a免费观看| 亚洲人成小说网站色在线| 色菇凉天天综合网| 免费av成人在线| 国产精品视频在线看| 日本黄色一区二区|