⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 framemgr.lst

📁 mg128+Ov7620实现图象采集
💻 LST
📖 第 1 页 / 共 2 页
字号:
   1               		.file	"FrameMgr.c"
   2               		.arch atmega128
   3               	__SREG__ = 0x3f
   4               	__SP_H__ = 0x3e
   5               	__SP_L__ = 0x3d
   6               	__tmp_reg__ = 0
   7               	__zero_reg__ = 1
   8               		.global __do_copy_data
   9               		.global __do_clear_bss
  11               		.text
  12               	.Ltext0:
  70               		.lcomm lineCount,1
  71               		.lcomm currentState,1
  73               	.global	FrameMgr_init
  75               	FrameMgr_init:
   1:FrameMgr.c    **** /*********************************************************
   2:FrameMgr.c    **** 	Module Name: FrameMgr.c
   3:FrameMgr.c    **** 	Module Date: 04/10/2004
   4:FrameMgr.c    **** 	Module Auth: John Orlando
   5:FrameMgr.c    **** 	
   6:FrameMgr.c    **** 	Description: This modules is responsible for performing
   7:FrameMgr.c    **** 	both medium and high level processing on image data.
   8:FrameMgr.c    **** 	This is performed at both the line level as well as
   9:FrameMgr.c    **** 	the frame level.  It controls the main flow of the
  10:FrameMgr.c    **** 	system, adhering to all the critical timing 
  11:FrameMgr.c    **** 	requirements (such as when serial data can be transferred,
  12:FrameMgr.c    **** 	etc).
  13:FrameMgr.c    ****  
  14:FrameMgr.c    **** *********************************************************/
  15:FrameMgr.c    **** 
  16:FrameMgr.c    **** /*	Includes */
  17:FrameMgr.c    **** #include <stdlib.h>
  18:FrameMgr.c    **** #include <string.h>
  19:FrameMgr.c    **** #include <avr/io.h>
  20:FrameMgr.c    **** #include "Executive.h"
  21:FrameMgr.c    **** #include "UIMgr.h"
  22:FrameMgr.c    **** #include "FrameMgr.h"
  23:FrameMgr.c    **** #include "CamInterface.h"
  24:FrameMgr.c    **** #include "UartInterface.h"
  25:FrameMgr.c    **** #include "Utility.h"
  26:FrameMgr.c    **** #include "I2CInterface.h"
  27:FrameMgr.c    **** #include "CamConfig.h"
  28:FrameMgr.c    **** #include "CommonDefs.h"
  29:FrameMgr.c    **** 
  30:FrameMgr.c    **** /* 	Local Structures and Typedefs */
  31:FrameMgr.c    **** enum
  32:FrameMgr.c    **** {
  33:FrameMgr.c    **** 	ST_FrameMgr_idle,
  34:FrameMgr.c    **** 	ST_FrameMgr_DumpingFrame
  35:FrameMgr.c    **** };
  36:FrameMgr.c    **** 
  37:FrameMgr.c    **** typedef unsigned char FrameMgr_State_t;
  38:FrameMgr.c    **** 
  39:FrameMgr.c    **** /* This define is used to turn off the timer overflow interrupt
  40:FrameMgr.c    **** that is generated when the PCLK overflows TIMER1 */
  41:FrameMgr.c    **** #define DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 0xFB
  42:FrameMgr.c    **** 
  43:FrameMgr.c    **** 
  44:FrameMgr.c    **** 
  45:FrameMgr.c    **** /*  Local Variables */
  46:FrameMgr.c    **** /* The trackedObjectTable is used to hold up to eight tracked objects
  47:FrameMgr.c    **** while they are being acquired. */
  48:FrameMgr.c    **** static unsigned char lineCount = 0;
  49:FrameMgr.c    **** static FrameMgr_State_t currentState = ST_FrameMgr_idle;
  50:FrameMgr.c    **** 
  51:FrameMgr.c    **** 
  52:FrameMgr.c    **** /*  Extern Functions */
  53:FrameMgr.c    **** /* These functions are located in assembly files, and thus
  54:FrameMgr.c    **** must be externed here so they can be referenced in the source below. */
  55:FrameMgr.c    **** extern void CamIntAsm_waitForNewDumpFrame(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
  56:FrameMgr.c    **** extern void CamIntAsm_acquireDumpLine(unsigned char *pCurrBuffer, unsigned char *pPrevBuffer);
  57:FrameMgr.c    **** 
  58:FrameMgr.c    **** /***********************************************************
  59:FrameMgr.c    **** 	Function Name: FrameMgr_init
  60:FrameMgr.c    **** 	Function Description: This function is responsible
  61:FrameMgr.c    **** 	for initializing the FrameMgr.  This includes 
  62:FrameMgr.c    **** 	setting up the various buffers and data needed to 
  63:FrameMgr.c    **** 	process each frame of image data.
  64:FrameMgr.c    **** 	Inputs:  none
  65:FrameMgr.c    **** 	Outputs: none
  66:FrameMgr.c    **** ***********************************************************/	
  67:FrameMgr.c    **** void FrameMgr_init(void)
  68:FrameMgr.c    **** {
  77               	.LM1:
  78               	/* prologue: frame size=0 */
  79               	/* prologue end (size=0) */
  80               	/* epilogue: frame size=0 */
  81 0000 0895      		ret
  82               	/* epilogue end (size=1) */
  83               	/* function FrameMgr_init size 1 (0) */
  85               	.Lscope0:
  88               	.global	FrameMgr_dispatchEvent
  90               	FrameMgr_dispatchEvent:
  69:FrameMgr.c    **** }
  70:FrameMgr.c    **** 
  71:FrameMgr.c    **** 
  72:FrameMgr.c    **** /***********************************************************
  73:FrameMgr.c    **** 	Function Name: FrameMgr_dispatchEvent
  74:FrameMgr.c    **** 	Function Description: This function is responsible for
  75:FrameMgr.c    **** 	taking an incoming event and performing the needed
  76:FrameMgr.c    **** 	actions with it as pertains to the FrameMgr.
  77:FrameMgr.c    **** 	Inputs:  event - the generated event
  78:FrameMgr.c    **** 	Outputs: none
  79:FrameMgr.c    **** ***********************************************************/	
  80:FrameMgr.c    **** void FrameMgr_dispatchEvent(unsigned char event)
  81:FrameMgr.c    **** {	
  92               	.LM2:
  93               	/* prologue: frame size=0 */
  94               	/* prologue end (size=0) */
  82:FrameMgr.c    **** 	switch(event)
  96               	.LM3:
  97 0002 8230      		cpi r24,lo8(2)
  98 0004 89F4      		brne .L2
  83:FrameMgr.c    **** 	{
  84:FrameMgr.c    **** 		case EV_DUMP_FRAME:
  85:FrameMgr.c    ****             /* try re-initializing the camera before we start dumping */
  86:FrameMgr.c    ****             
  87:FrameMgr.c    **** 			CamConfig_setCamReg(0x11,0x01);  /* reduce the frame rate for dumping*/
 100               	.LM4:
 101 0006 61E0      		ldi r22,lo8(1)
 102 0008 81E1      		ldi r24,lo8(17)
 103 000a 0E94 0000 		call CamConfig_setCamReg
  88:FrameMgr.c    **** 			CamConfig_sendFifoCmds();
 105               	.LM5:
 106 000e 0E94 0000 		call CamConfig_sendFifoCmds
  89:FrameMgr.c    **** 			Utility_delay(1000);		/* allow the new frame rate to settle */
 108               	.LM6:
 109 0012 88EE      		ldi r24,lo8(1000)
 110 0014 93E0      		ldi r25,hi8(1000)
 111 0016 0E94 0000 		call Utility_delay
  90:FrameMgr.c    **** 			lineCount = 0;
 113               	.LM7:
 114 001a 1092 0000 		sts lineCount,__zero_reg__
  91:FrameMgr.c    **** 			currentState = ST_FrameMgr_DumpingFrame;
 116               	.LM8:
 117 001e 81E0      		ldi r24,lo8(1)
 118 0020 8093 0000 		sts currentState,r24
  92:FrameMgr.c    **** 			//CamIntAsm_waitForNewDumpFrame(currentLineBuffer,previousLineBuffer);
  93:FrameMgr.c    ****             FrameMgr_acquireLine();
 120               	.LM9:
 121 0024 0E94 0000 		call FrameMgr_acquireLine
 122               	.L2:
 123 0028 0895      		ret
 124               	/* epilogue: frame size=0 */
 125 002a 0895      		ret
 126               	/* epilogue end (size=1) */
 127               	/* function FrameMgr_dispatchEvent size 21 (20) */
 129               	.Lscope1:
 131               	.global	FrameMgr_acquireLine
 133               	FrameMgr_acquireLine:
  94:FrameMgr.c    **** 			break;
  95:FrameMgr.c    **** 					
  96:FrameMgr.c    **** 		case EV_PROCESS_FRAME_COMPLETE://second here
  97:FrameMgr.c    **** 			//FrameMgr_acquireFrame();
  98:FrameMgr.c    **** 			break;
  99:FrameMgr.c    **** 
 100:FrameMgr.c    **** 		case EV_SERIAL_DATA_RECEIVED:////////////////first reach here
 101:FrameMgr.c    **** 		    
 102:FrameMgr.c    **** 			//if (currentState != ST_FrameMgr_idle)
 103:FrameMgr.c    **** 			//{
 104:FrameMgr.c    **** 				/* we need to go back to processing line data, since
 105:FrameMgr.c    **** 				serial data reception interrupted us....just trash the
 106:FrameMgr.c    **** 				frame and act like the frame has been processed, which
 107:FrameMgr.c    **** 				will kick off the system to wait for the next line */
 108:FrameMgr.c    **** 				//PUBLISH_EVENT(EV_PROCESS_FRAME_COMPLETE);//Exec_writeEventFifo(event)
 109:FrameMgr.c    **** 			//}
 110:FrameMgr.c    **** 			break;
 111:FrameMgr.c    **** 			
 112:FrameMgr.c    **** 		
 113:FrameMgr.c    **** 	}
 114:FrameMgr.c    **** }
 115:FrameMgr.c    **** 
 116:FrameMgr.c    **** 
 117:FrameMgr.c    **** 
 118:FrameMgr.c    **** /***********************************************************
 119:FrameMgr.c    **** 	Function Name: FrameMgr_acquireLine
 120:FrameMgr.c    **** 	Function Description: This function is responsible for
 121:FrameMgr.c    **** 	acquiring a line of data from the camera interface.
 122:FrameMgr.c    **** 	The acquisition of this line depends on the current
 123:FrameMgr.c    **** 	state of the FrameMgr.
 124:FrameMgr.c    **** 	Inputs:  none
 125:FrameMgr.c    **** 	Outputs: none
 126:FrameMgr.c    **** ***********************************************************/	
 127:FrameMgr.c    **** void FrameMgr_acquireLine(void)
 128:FrameMgr.c    **** {
 135               	.LM10:
 136               	/* prologue: frame size=0 */
 137               	/* prologue end (size=0) */
 129:FrameMgr.c    **** 	//unsigned char tmpLineCount;
 130:FrameMgr.c    **** 	int tmpLineCount;
 131:FrameMgr.c    **** 	
 132:FrameMgr.c    **** 	/* clearing out the buffers takes too long...we should
 133:FrameMgr.c    **** 	just overwrite the data here without a problem when
 134:FrameMgr.c    **** 	we start acquiring...at no point do we check for 
 135:FrameMgr.c    **** 	a 0x00 value in the current or previous lineBuffers,
 136:FrameMgr.c    **** 	so it was a bit excessive :-)  */
 137:FrameMgr.c    **** 	
 138:FrameMgr.c    **** 	/* check which state we are in and proceed as needed */
 139:FrameMgr.c    **** 	if (currentState == ST_FrameMgr_DumpingFrame)
 139               	.LM11:
 140 002c 8091 0000 		lds r24,currentState
 141 0030 8130      		cpi r24,lo8(1)
 142 0032 A9F5      		brne .L7
 140:FrameMgr.c    **** 	{
 141:FrameMgr.c    **** 		tmpLineCount = lineCount*2;
 144               	.LM12:
 145 0034 8091 0000 		lds r24,lineCount
 146 0038 282F      		mov r18,r24
 147 003a 3327      		clr r19
 148 003c 220F      		add r18,r18
 149 003e 331F      		adc r19,r19
 142:FrameMgr.c    ****         /* clearing out the line data in dump mode is ok, and actually
 143:FrameMgr.c    ****         is needed, since it is possible for the first dump line in
 144:FrameMgr.c    ****         a frame to come back with the last line captured of the
 145:FrameMgr.c    ****         last capture session...*/
 146:FrameMgr.c    ****         memset(currentLineBuffer,0x00,LENGTH_OF_LINE_BUFFER);
 151               	.LM13:
 152 0040 80E4      		ldi r24,lo8(320)
 153 0042 91E0      		ldi r25,hi8(320)
 154 0044 E0E0      		ldi r30,lo8(currentLineBuffer)
 155 0046 F0E0      		ldi r31,hi8(currentLineBuffer)
 156 0048 AC01      		movw r20,r24
 157 004a 1192      		st Z+,__zero_reg__
 158 004c 4150      		subi r20,1
 159 004e 5040      		sbci r21,0
 160 0050 E1F7      		brne .-8
 147:FrameMgr.c    ****         memset(previousLineBuffer,0x00,LENGTH_OF_LINE_BUFFER);
 162               	.LM14:
 163 0052 E0E0      		ldi r30,lo8(previousLineBuffer)
 164 0054 F0E0      		ldi r31,hi8(previousLineBuffer)
 165 0056 1192      		st Z+,__zero_reg__
 166 0058 0197      		sbiw r24,1
 167 005a E9F7      		brne .-6
 168 005c 41E0      		ldi r20,lo8(1)
 169 005e 50E0      		ldi r21,hi8(1)
 170               	.L9:
 148:FrameMgr.c    **** 		/* wait for another VSYNC so we know which frame to use 
 149:FrameMgr.c    **** 		to start looking for a line to receive */
 150:FrameMgr.c    **** 		WAIT_FOR_VSYNC_HIGH();  
 172               	.LM15:
 173 0060 80B3      		in r24,48-0x20
 174 0062 9927      		clr r25
 175 0064 9695      		lsr r25
 176 0066 8795      		ror r24
 177 0068 9695      		lsr r25
 178 006a 8795      		ror r24
 179 006c 8170      		andi r24,lo8(1)
 180 006e 9070      		andi r25,hi8(1)
 181 0070 8417      		cp r24,r20
 182 0072 9507      		cpc r25,r21
 183 0074 A9F7      		brne .L9
 184               	.L12:
 151:FrameMgr.c    **** 		WAIT_FOR_VSYNC_LOW();
 186               	.LM16:
 187 0076 8299      		sbic 48-0x20,2
 188 0078 FECF      		rjmp .L12
 152:FrameMgr.c    **** 		
 153:FrameMgr.c    **** 		/* look at lineCount to determine how many HREFs we should
 154:FrameMgr.c    **** 		wait before we start sampling */
 155:FrameMgr.c    **** 		while(tmpLineCount != 0)
 156:FrameMgr.c    **** 		{
 157:FrameMgr.c    **** 			WAIT_FOR_HREF_HIGH(); 
 158:FrameMgr.c    **** 			tmpLineCount--;
 159:FrameMgr.c    **** 			WAIT_FOR_HREF_LOW(); 
 190               	.LM17:
 191 007a 2115      		cp r18,__zero_reg__
 192 007c 3105      		cpc r19,__zero_reg__
 193 007e 49F0      		breq .L25
 194               	.L29:
 196               	.LM18:
 197 0080 879B      		sbis 48-0x20,7
 198 0082 FECF      		rjmp .L29
 200               	.LM19:
 201 0084 2150      		subi r18,lo8(-(-1))
 202 0086 3040      		sbci r19,hi8(-(-1))
 203               	.L20:
 205               	.LM20:
 206 0088 8799      		sbic 48-0x20,7
 207 008a FECF      		rjmp .L20
 208 008c 2115      		cp r18,__zero_reg__
 209 008e 3105      		cpc r19,__zero_reg__
 210 0090 B9F7      		brne .L29
 211               	.L25:
 160:FrameMgr.c    **** 		}
 161:FrameMgr.c    **** 		
 162:FrameMgr.c    **** 		/*  we should now be ready to sample our line...*/
 163:FrameMgr.c    **** 		CamIntAsm_acquireDumpLine(currentLineBuffer,previousLineBuffer);
 213               	.LM21:
 214 0092 60E0      		ldi r22,lo8(previousLineBuffer)
 215 0094 70E0      		ldi r23,hi8(previousLineBuffer)
 216 0096 80E0      		ldi r24,lo8(currentLineBuffer)
 217 0098 90E0      		ldi r25,hi8(currentLineBuffer)
 218 009a 0E94 0000 		call CamIntAsm_acquireDumpLine
 219               	.L7:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -