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

📄 caminterfaceasm.lst

📁 mg128+Ov7620实现图象采集
💻 LST
📖 第 1 页 / 共 4 页
字号:
  31               	
  32               	
  33               	; A pixelBlock is defined as a contiguous group of 4 pixels that are combined 
  34               	; together to form a specific color.  Typically, this is formed by sampling a
  35               	; a green value, followed by a red and blue value (since we are dealing
  36               	; with Bayer color data).  We could optionally sample a second green with
  37               	; the red and average the greens, because the eye is more sensitive to
  38               	; green, but for speed we don't do this.  These three values (RGB) are then
  39               	; used as indices into the color membership lookup table (memLookup) to
  40               	; determine which color the pixelBlock maps into.  The memLookup table is
  41               	; manually generated for now (though it will hopefully be modified over
  42               	; the serial interface eventually).
  43               	;
  44               	; Here is a pixel block:
  45               	; ...G  G  G  G...  (row x)
  46               	; ...B  R  B  R...  (row x+1)
  47               	;    |  |  |  |--this is skipped 
  48               	;    |  |  |--this is skipped
  49               	;    |  |--this is sampled
  50               	;    |--this is sampled
  51               	
  52               	
  53               	
  54               	; These are the registers that will be used throughout this
  55               	; module for acquiring each line of pixel data
  56               	pixelCount			= 16
  57               	pixelRunStart		= 17
  58               	lastColor     		= 18
  59               	tmp1				= 19	; be sure to not use tmp1 and color simultaneously
  60               	tmp2				= 20
  61               	color           	= 19
  62               	prevLineBuffLow  	= 22  	; overlaps with memLookupLow (but orthogonal)
  63               	prevLineBuffHigh	= 23	; overlaps with memLookupHigh (but orthogonal)
  64               	currLineBuffLow     = 24
  65               	currLineBuffHigh  	= 25
  66               	
  67               	        .section .text
  68               	
  69               	; These are the global assembly function names that are accessed via other
  70               	; C functions
  71               			.global CamIntAsm_waitForNewDumpFrame
  72               			.global CamIntAsm_acquireDumpLine
  73               			.global SIG_INTERRUPT0
  74               			.global SIG_INTERRUPT1
  75               			.global SIG_OVERFLOW1
  76               			
  77               	
  78               	_cleanUpDumpLine:		
  79               			; NOTE: If serial data is received, to interrupt the tracking of a line, we'll
  80               			; get a EV_SERIAL_DATA_RECEIVED event, and the T bit set so we will end the
  81               			; line's processing...however, the PCLK will keep on ticking for the rest of
  82               			; the frame/line, which will cause the TCNT to eventually overflow and
  83               			; interrupt us, generating a EV_ACQUIRE_LINE_COMPLETE event.  We don't want
  84               			; this, so we need to actually turn off the PCLK counting each time we exit
  85               			; this loop, and only turn it on when we begin acquiring lines....
  86               	        ; NOT NEEDED FOR NOW...
  87               			;in		tmp1, _SFR_IO_ADDR(TIMSK)			; disable TIMER1 to stop counting
  88               			;andi	tmp1, DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 	; external PCLK pulses
  89               			;out		_SFR_IO_ADDR(TIMSK),tmp1
  90               			
  91               			
  92               	
  93               	_cleanUp:
  94               	        ; Disable the external clocking of the Timer1 counter 
  95:CamInterfaceAsm.S ****         in      tmp1, _SFR_IO_ADDR(TCCR1B)
  96:CamInterfaceAsm.S ****         andi    tmp1, 0xF8
  97:CamInterfaceAsm.S ****         out     _SFR_IO_ADDR(TCCR1B),tmp1
  98               			
  99               			; Toggle the debug line to indicate the line is complete
 100:CamInterfaceAsm.S **** 		sbi     _SFR_IO_ADDR(PORTB),PB6
 101:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTB),PB6
 102:CamInterfaceAsm.S **** 		clt				; clear out the T bit since we have detected
 103               							; the interruption and are exiting to handle it
 104               	_exit:
 105:CamInterfaceAsm.S **** 		ret
 106               			
 107               	;*****************************************************************		
 108               	;   	Function Name: CamIntAsm_waitForNewDumpFrame
 109               	;       Function Description: This function is responsible for
 110               	;       going to sleep until a new frame begins (indicated by
 111               	;    	VSYNC transitioning from low to high.  This will wake
 112               	;       the "VSYNC sleep" up and allow it to continue with 
 113               	;       acquiring a line of pixel data to dump out to the UI.
 114               	;       Inputs:  r25 - MSB of currentLineBuffer
 115               	;                r24 - LSB of currentLineBuffer
 116               	;				 r23 - MSB of prevLineBuffer
 117               	;				 r22 - LSB of prevLineBuffer
 118               	;       Outputs: none
 119               	;       NOTES: This function doesn't really return...it sorta just
 120               	;       floats into the acquireDumpLine function after the "VSYNC sleep"
 121               	;       is awoken.
 122               	;*****************************************************************		
 123               	CamIntAsm_waitForNewDumpFrame:
 124:CamInterfaceAsm.S **** 		sbi		_SFR_IO_ADDR(PORTB),PB6  ; For testing...
 125:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTB),PB6
 126:CamInterfaceAsm.S **** 		sleep
 127               	
 128               	;*****************************************************************
 129               	; REMEMBER...everything from here on out is critically timed to be
 130               	; synchronized with the flow of pixel data from the camera...
 131               	;*****************************************************************
 132               	
 133               	CamIntAsm_acquireDumpLine:
 134:CamInterfaceAsm.S **** 		brts	_cleanUp
 135               			;sbi		_SFR_IO_ADDR(PORTD),PD6 ; For testing...
 136               			;cbi		_SFR_IO_ADDR(PORTD),PD6
 137               			
 138:CamInterfaceAsm.S **** 		mov   	XH,currLineBuffHigh    	; Load the pointer to the current line
 139:CamInterfaceAsm.S **** 		mov		XL,currLineBuffLow		; buffer into the X pointer regs
 140               	
 141:CamInterfaceAsm.S **** 		mov		YH,prevLineBuffHigh		; Load the pointer to the previous line
 142:CamInterfaceAsm.S **** 		mov		YL,prevLineBuffLow  	; buffer into the Y pointer regs
 143               			
 144:CamInterfaceAsm.S **** 		ldi 	tmp1,0xC0                  ;PIXEL_RUN_START_INITIAL	;0x50 set up the TCNT1 to overflow (and
 145:CamInterfaceAsm.S **** 		ldi 	tmp2,0xFE	  				;//0xff interrupts) after 176 pixels	320	
 146:CamInterfaceAsm.S **** 		out 	_SFR_IO_ADDR(TCNT1H),tmp2		
 147:CamInterfaceAsm.S **** 		out 	_SFR_IO_ADDR(TCNT1L),tmp1		
 148               			
 149:CamInterfaceAsm.S ****         in      tmp1, _SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually
 150:CamInterfaceAsm.S ****         ori     tmp1, 0x07                 ; feed Timer1
 151:CamInterfaceAsm.S ****         out     _SFR_IO_ADDR(TCCR1B),tmp1
 152:CamInterfaceAsm.S ****         nop
 153               	        
 154:CamInterfaceAsm.S **** 		in		tmp1, _SFR_IO_ADDR(TIMSK)			; enable TIMER1 to start counting
 155:CamInterfaceAsm.S **** 		ori		tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK 	; external PCLK pulses and interrupt on 0x04
 156:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(TIMSK),tmp1			; overflow			
 157               			
 158:CamInterfaceAsm.S **** 		in 		tmp1, _SFR_IO_ADDR(EIMSK)	; enable the HREF interrupt...remember, we
 159               												; only use this interrupt to synchronize
 160               												; the beginning of the line  INT3
 161:CamInterfaceAsm.S **** 		ori 	tmp1, HREF_INTERRUPT_ENABLE_MASK ;0x08
 162:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(EIMSK), tmp1
 163               			
 164               			
 165               			
 166               	;*******************************************************************************************
 167               	;   Dump Frame handler 
 168               	;*******************************************************************************************		
 169               			
 170               	_dumpFrame:		
 171:CamInterfaceAsm.S **** 		sbi		_SFR_IO_ADDR(PORTB),PB6
 172:CamInterfaceAsm.S **** 		sleep   ; ...And we wait...
 173               	
 174:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTB),PB6             ;(2)
 175:CamInterfaceAsm.S **** 		in 		tmp1, _SFR_IO_ADDR(EIMSK)			;(1) disable the HREF interrupt
 176:CamInterfaceAsm.S **** 		andi 	tmp1, HREF_INTERRUPT_DISABLE_MASK  	;(1) so we don't get interrupted
 177:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(EIMSK), tmp1			;(1) while dumping the line
 178               		
 179               			;nop		;改 Remember...if we ever remove the "cbi" instruction above,
 180               					; we need to add two more NOPs to cover this
 181               	    
 182               	; Ok...the following loop needs to run in 8 clock cycles, so we can get every
 183               	; pixel in the line...this shouldn't be a problem, since the PCLK timing was
 184               	; reduced by a factor of 2 whenever we go to dump a line (this is to give us
 185               	; enough time to do the sampling and storing of the pixel data).  In addition,
 186               	; it is assumed that we will have to do some minor processing on the data right
 187               	; before we send it out, like mask off the top 4-bits of each, and then pack both
 188               	; low nibbles into a single byte for transmission...we just don't have time to
 189               	; do that here (only 8 instruction cycles :-)  )
 190               	_sampleDumpPixel:
 191:CamInterfaceAsm.S **** 		in		tmp1,G_PORT			    ; sample the G value					(1)
 192:CamInterfaceAsm.S **** 		in		tmp2,RB_PORT			; sample the R/B value					(1)
 193:CamInterfaceAsm.S **** 		st		X+,tmp1					; store to the currLineBuff and inc ptrs(2)
 194:CamInterfaceAsm.S **** 		st		Y+,tmp2					; store to the prevLineBuff and inc ptrs(2)
 195:CamInterfaceAsm.S **** 		brtc	_sampleDumpPixel		; loop back unless flag is set			(2...if not set)
 196               											;									___________
 197               											;									8 cycles normally
 198               																				
 199               			; if we make it here, it means the T flag is set, and we must have been interrupted
 200               			; so we need to exit (what if we were interrupted for serial? should we disable it?)
 201               			
 202               			
 203               			
 204:CamInterfaceAsm.S **** 		rjmp	_cleanUpDumpLine	
 205               	
 206               	;***********************************************************
 207               	;	Function Name: <interrupt handler for External Interrupt0> 
 208               	;	Function Description: This function is responsible
 209               	;	for handling a rising edge on the Ext Interrupt 0.  This
 210               	;	routine simply returns, since we just want to wake up
 211               	;	whenever the VSYNC transitions (meaning the start of a new
 212               	;	frame).
 213               	;	Inputs:  none
 214               	;	Outputs: none
 215               	;***********************************************************
 216               	SIG_INTERRUPT2:
 217               	; This will wake us up when VSYNC transitions high...we just want to return
 218:CamInterfaceAsm.S **** 		reti
 219               			
 220               	;***********************************************************
 221               	;	Function Name: <interrupt handler for External Interrupt1> 
 222               	;	Function Description: This function is responsible
 223               	;	for handling a falling edge on the Ext Interrupt 1.  This
 224               	;	routine simply returns, since we just want to wake up
 225               	;	whenever the HREF transitions (meaning the pixels 
 226               	;	are starting after VSYNC transitioned, and we need to
 227               	; 	start acquiring the pixel blocks
 228               	;	Inputs:  none
 229               	;	Outputs: none
 230               	;***********************************************************	
 231               	SIG_INTERRUPT3:
 232               	; This will wake us up when HREF transitions high...we just want to return
 233:CamInterfaceAsm.S **** 		reti                     ;(4)                
 234               			
 235               	
 236               	;***********************************************************
 237               	;	Function Name: <interrupt handler for Timer1 overflow>
 238               	;	Function Description: This function is responsible
 239               	;	for handling the Timer1 overflow (hooked up to indicate
 240               	;	when we have reached the end of a line of pixel data,
 241               	;	since PCLK is hooked up to overflow TCNT1 after 176 
 242               	;	pixels).  This routine generates an acquire line complete
 243               	;	event in the fastEventBitmask, which is streamlined for
 244               	;	efficiency reasons.
 245               	;***********************************************************
 246               	SIG_OVERFLOW1:				
 247:CamInterfaceAsm.S **** 		lds		tmp1,fastEventBitmask   		; set a flag indicating
 248:CamInterfaceAsm.S **** 		ori		tmp1,FEV_ACQUIRE_LINE_COMPLETE	; a line is complete
 249:CamInterfaceAsm.S **** 		sts		fastEventBitmask,tmp1
 250:CamInterfaceAsm.S **** 		set		; set the T bit in SREG 
 251               	
 252:CamInterfaceAsm.S **** 		reti
 253               	
 254               	; This is the default handler for all interrupts that don't
 255               	; have handler routines specified for them.
 256               	        .global __vector_default              
 257               	__vector_default:
 258:CamInterfaceAsm.S ****         reti
 259               	
 260               	        .end
DEFINED SYMBOLS
                            *ABS*:00000000 CamInterfaceAsm.S
                            *ABS*:00000000 Events.h
                            *ABS*:00000000 CamInterfaceAsm.S
                            *ABS*:00000000 d:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/io.h
                            *ABS*:00000000 d:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/portpins.h
                            *ABS*:00000000 d:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/io.h
                            *ABS*:00000000 d:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/iom128.h
                            *ABS*:00000000 d:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/io.h
                            *ABS*:00000000 d:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/sfr_defs.h
                            *ABS*:00000000 d:/WinAVR/bin/../lib/gcc/avr/3.4.3/../../../../avr/include/avr/io.h
                            *ABS*:00000000 CamInterfaceAsm.S
                            *ABS*:00000000 <command line>
                            *ABS*:00000000 <built-in>
                            *ABS*:00000000 CamInterfaceAsm.S
                            *ABS*:00000010 pixelCount
                            *ABS*:00000011 pixelRunStart
                            *ABS*:00000012 lastColor
                            *ABS*:00000013 tmp1
                            *ABS*:00000014 tmp2
                            *ABS*:00000013 color
                            *ABS*:00000016 prevLineBuffLow
                            *ABS*:00000017 prevLineBuffHigh
                            *ABS*:00000018 currLineBuffLow
                            *ABS*:00000019 currLineBuffHigh
   CamInterfaceAsm.S:123    .text:0000000e CamIntAsm_waitForNewDumpFrame
   CamInterfaceAsm.S:133    .text:00000014 CamIntAsm_acquireDumpLine
   CamInterfaceAsm.S:246    .text:00000056 __vector_14
   CamInterfaceAsm.S:78     .text:00000000 _cleanUpDumpLine
   CamInterfaceAsm.S:93     .text:00000000 _cleanUp
   CamInterfaceAsm.S:104    .text:0000000c _exit
   CamInterfaceAsm.S:170    .text:0000003a _dumpFrame
   CamInterfaceAsm.S:190    .text:00000046 _sampleDumpPixel
   CamInterfaceAsm.S:216    .text:00000052 __vector_3
   CamInterfaceAsm.S:231    .text:00000054 __vector_4
   CamInterfaceAsm.S:257    .text:00000064 __vector_default

UNDEFINED SYMBOLS
__vector_1
__vector_2
fastEventBitmask

⌨️ 快捷键说明

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