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

📄 caminterfaceasm.lst

📁 he AVRcam source files were built using the WinAVR distribution (version 3.3.1 of GCC). I haven t t
💻 LST
📖 第 1 页 / 共 5 页
字号:
 119               	pixelCount			= 16
 120               	pixelRunStart		= 17
 121               	lastColor     		= 18
 122               	tmp1				= 19	; be sure to not use tmp1 and color simultaneously
 123               	tmp2				= 20
 124               	color           	= 19
 125               	greenData       	= 20
 126               	blueData        	= 21
 127               	colorMapLow	  		= 22
 128               	colorMapHigh		= 23
 129               	prevLineBuffLow  	= 22  	; overlaps with memLookupLow (but orthogonal)
 130               	prevLineBuffHigh	= 23	; overlaps with memLookupHigh (but orthogonal)
 131               	currLineBuffLow     = 24
 132               	currLineBuffHigh  	= 25
 133               	
 134               	        .section .text
 135               	
 136               	; These are the global assembly function names that are accessed via other
 137               	; C functions
 138               	        .global CamIntAsm_waitForNewTrackingFrame
 139               			.global CamIntAsm_waitForNewDumpFrame
 140               			.global CamIntAsm_acquireDumpLine
 141               			.global CamIntAsm_acquireTrackingLine
 142               			.global SIG_INTERRUPT0
 143               			.global SIG_INTERRUPT1
 144               			.global SIG_OVERFLOW0
 145               			.global SIG_OVERFLOW1
 146               			
 147               	;*****************************************************************		
 148               	;   	Function Name: CamIntAsm_waitForNewTrackingFrame
 149               	;       Function Description: This function is responsible for
 150               	;       going to sleep until a new frame begins (indicated by
 151               	;    	VSYNC transitioning from low to high.  This will wake
 152               	;       the "VSYNC sleep" up and allow it to continue with 
 153               	;       the acquireLine function, where the system waits for
 154               	;       an "HREF sleep" that we use to synchronize with the
 155               	;       data.  
 156               	;       Inputs:  r25 - MSB of currentLineBuffer
 157               	;                r24 - LSB of currentLineBuffer
 158               	;				 r23 - MSB of colorMap
 159               	; 				 r22 - LSB of colorMap
 160               	;       Outputs: none
 161               	;       NOTES: This function doesn't really return...it sorta just
 162               	;       floats into the acquireLine function after the "VSYNC sleep"
 163               	;       is awoken, then begins processing the line data.  Once
 164               	;		176 pixels are sampled (and the counter overflows), then
 165               	;		an interrupt will occur, the 'T' bit in the SREG will be
 166               	;		set, and the function will return.
 167               	;*****************************************************************
 168               			
 169               	CamIntAsm_waitForNewTrackingFrame:
 170:CamInterfaceAsm.S **** 		sbi		_SFR_IO_ADDR(PORTD),PD6  ; For testing...
 171:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTD),PD6		
 172:CamInterfaceAsm.S **** 		sleep
 173               	
 174               	;*****************************************************************
 175               	; REMEMBER...everything from here on out is critically timed to be
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s 			page 13


 176               	; synchronized with the flow of pixel data from the camera...
 177               	;*****************************************************************
 178               	
 179               	CamIntAsm_acquireTrackingLine:
 180:CamInterfaceAsm.S **** 		brts	_cleanUp
 181               			;sbi		_SFR_IO_ADDR(PORTD),PD6 ; For testing...
 182               			;cbi		_SFR_IO_ADDR(PORTD),PD6
 183               	        
 184:CamInterfaceAsm.S ****         in      tmp1,_SFR_IO_ADDR(TCCR1B) ; Enable the PCLK line to actually
 185:CamInterfaceAsm.S ****         ori     tmp1, 0x07                 ; feed Timer1
 186:CamInterfaceAsm.S ****         out     _SFR_IO_ADDR(TCCR1B),tmp1 
 187               											; The line is about to start...		
 188:CamInterfaceAsm.S **** 		ldi     pixelCount,0			; Initialize the RLE stats...
 189:CamInterfaceAsm.S **** 		ldi		pixelRunStart,PIXEL_RUN_START_INITIAL  	; Remember, we always calculate
 190               															; the pixel run length as
 191               															; TCNT1L - pixelRunStart
 192               			
 193:CamInterfaceAsm.S **** 		ldi		lastColor,0x00				; clear out the last color before we start
 194               			
 195:CamInterfaceAsm.S **** 		mov   	XH,currLineBuffHigh    	; Load the pointer to the current line
 196:CamInterfaceAsm.S **** 		mov		XL,currLineBuffLow		; buffer into the X pointer regs		 
 197               			
 198:CamInterfaceAsm.S **** 		mov   	ZH,colorMapHigh      	; Load the pointers to the membership
 199:CamInterfaceAsm.S **** 		mov		ZL,colorMapLow			; lookup tables (ZL and YL will be overwritten
 200:CamInterfaceAsm.S **** 		mov 	YH,colorMapHigh	 		; as soon as we start reading data) to Z and Y
 201               			
 202:CamInterfaceAsm.S **** 		in		tmp1, _SFR_IO_ADDR(TIMSK)			; enable TIMER1 to start counting
 203:CamInterfaceAsm.S **** 		ori		tmp1, ENABLE_PCLK_TIMER1_OVERFLOW_BITMASK 	; external PCLK pulses and interrupt on 
 204:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(TIMSK),tmp1			; overflow
 205               			
 206:CamInterfaceAsm.S **** 		ldi 	tmp1,PIXEL_RUN_START_INITIAL	; set up the TCNT1 to overflow (and
 207:CamInterfaceAsm.S **** 		ldi 	tmp2,0xFF 						; interrupts) after 176 pixels		
 208:CamInterfaceAsm.S **** 		out 	_SFR_IO_ADDR(TCNT1H),tmp2		
 209:CamInterfaceAsm.S **** 		out 	_SFR_IO_ADDR(TCNT1L),tmp1				
 210               			
 211:CamInterfaceAsm.S **** 		mov		YL,colorMapLow		
 212               			
 213:CamInterfaceAsm.S **** 		in 		tmp1, _SFR_IO_ADDR(GICR)	; enable the HREF interrupt...remember, we
 214               												; only use this interrupt to synchronize
 215               												; the beginning of the line
 216:CamInterfaceAsm.S **** 		ori 	tmp1, HREF_INTERRUPT_ENABLE_MASK
 217:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(GICR), tmp1
 218               			
 219               	;*******************************************************************************************
 220               	;   Track Frame handler 
 221               	;*******************************************************************************************		
 222               			
 223               	_trackFrame:		
 224:CamInterfaceAsm.S **** 		sbi		_SFR_IO_ADDR(PORTD),PD6
 225:CamInterfaceAsm.S **** 		sleep   ; ...And we wait...
 226               			
 227               		; Returning from the interrupt/sleep wakeup will consume
 228               		; 14 clock cycles (7 to wakeup from idle sleep, 3 to vector, and 4 to return)	
 229               	
 230               		; Disable the HREF interrupt
 231:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTD),PD6
 232:CamInterfaceAsm.S **** 		in 		tmp1, _SFR_IO_ADDR(GICR)
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s 			page 14


 233:CamInterfaceAsm.S **** 		andi 	tmp1, HREF_INTERRUPT_DISABLE_MASK
 234:CamInterfaceAsm.S **** 		out		_SFR_IO_ADDR(GICR), tmp1
 235               			
 236               		; A couple of NOPs are needed here to sync up the pixel data...the number (2)
 237               		; of NOPs was determined emperically by trial and error.
 238:CamInterfaceAsm.S **** 		nop
 239:CamInterfaceAsm.S **** 		nop
 240               	_acquirePixelBlock:							;							Clock Cycle Count
 241:CamInterfaceAsm.S **** 		in		ZL,RB_PORT         			; sample the red value (PINB)		(1)
 242:CamInterfaceAsm.S **** 		in		YL,G_PORT         			; sample the green value (PINC)		(1)
 243:CamInterfaceAsm.S **** 		andi	YL,0x0F            			; clear the high nibble				(1)
 244:CamInterfaceAsm.S **** 		ldd		color,Z+RED_MEM_OFFSET  	; lookup the red membership			(2)
 245:CamInterfaceAsm.S **** 		in		ZL,RB_PORT         			; sample the blue value (PINB)		(1)
 246:CamInterfaceAsm.S **** 		ldd		greenData,Y+GREEN_MEM_OFFSET; lookup the green membership		(2)
 247:CamInterfaceAsm.S **** 		ldd		blueData,Z+BLUE_MEM_OFFSET	; lookup the blue membership		(2)
 248:CamInterfaceAsm.S **** 		and		color,greenData 			; mask memberships together			(1)
 249:CamInterfaceAsm.S **** 		and		color,blueData  			; to produce the final color		(1)
 250:CamInterfaceAsm.S **** 		brts    _cleanUpTrackingLine		; if some interrupt routine has		(1...not set)
 251               												; come in and set our T flag in 
 252               												; SREG, then we need to hop out
 253               												; and blow away this frames data (common cleanup)									
 254:CamInterfaceAsm.S **** 		cp		color,lastColor     		; check to see if the run continues	(1)
 255:CamInterfaceAsm.S **** 		breq    _acquirePixelBlock  		;									(2...equal)
 256               												;									___________
 257               												;								16 clock cycles 		
 258               												; (16 clock cycles = 1 uS = 1 pixelBlock time)
 259               			
 260               			; Toggle the debug line to indicate a color change
 261:CamInterfaceAsm.S **** 		sbi     _SFR_IO_ADDR(PORTD),PD6
 262:CamInterfaceAsm.S **** 		nop
 263:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTD),PD6
 264               			
 265:CamInterfaceAsm.S **** 		mov		tmp2,pixelRunStart				; get the count value of the
 266               													; current pixel run
 267:CamInterfaceAsm.S **** 		in		pixelCount,_SFR_IO_ADDR(TCNT1L)	; get the current TCNT1 value 
 268:CamInterfaceAsm.S **** 		mov   	pixelRunStart,pixelCount		; reload pixelRunStart for the
 269               													; next run
 270:CamInterfaceAsm.S **** 		sub		pixelCount,tmp2     			; pixelCount = TCNT1L - pixelRunStart
 271               											
 272:CamInterfaceAsm.S **** 		st		X+,lastColor			; record the color run in the current line buffer
 273:CamInterfaceAsm.S **** 		st		X+,pixelCount			; with its length
 274:CamInterfaceAsm.S **** 		mov		lastColor,color			; set lastColor so we can figure out when it changes
 275               			
 276:CamInterfaceAsm.S **** 		nop								; waste one more cycle for a total of 16
 277:CamInterfaceAsm.S **** 		rjmp	_acquirePixelBlock	
 278               			
 279               	; _cleanUpTrackingLine is used to write the last run length block off to the currentLineBuffer so
 280               	; that all 176 pixels in the line are accounted for.
 281               	_cleanUpTrackingLine:		
 282:CamInterfaceAsm.S **** 		ldi		pixelCount,0xFF		; the length of the last run is ALWAYS 0xFF minus the last
 283:CamInterfaceAsm.S **** 		sub		pixelCount,pixelRunStart  	; pixelRunStart
 284               			
 285:CamInterfaceAsm.S **** 		inc		pixelCount				; increment pixelCount since we actually need to account
 286               											; for the overflow of TCNT1
 287               											
 288:CamInterfaceAsm.S **** 		st		X+,color				; record the color run in the current line buffer
 289:CamInterfaceAsm.S **** 		st		X,pixelCount		
GAS LISTING C:\DOCUME~1\John\LOCALS~1\Temp/ccIlaaaa.s 			page 15


 290:CamInterfaceAsm.S **** 		rjmp	_cleanUp
 291               			
 292               	_cleanUpDumpLine:		
 293               			; NOTE: If serial data is received, to interrupt the tracking of a line, we'll
 294               			; get a EV_SERIAL_DATA_RECEIVED event, and the T bit set so we will end the
 295               			; line's processing...however, the PCLK will keep on ticking for the rest of
 296               			; the frame/line, which will cause the TCNT to eventually overflow and
 297               			; interrupt us, generating a EV_ACQUIRE_LINE_COMPLETE event.  We don't want
 298               			; this, so we need to actually turn off the PCLK counting each time we exit
 299               			; this loop, and only turn it on when we begin acquiring lines....
 300               	        ; NOT NEEDED FOR NOW...
 301               			;in		tmp1, _SFR_IO_ADDR(TIMSK)			; disable TIMER1 to stop counting
 302               			;andi	tmp1, DISABLE_PCLK_TIMER1_OVERFLOW_BITMASK 	; external PCLK pulses
 303               			;out		_SFR_IO_ADDR(TIMSK),tmp1
 304               	
 305               	_cleanUp:
 306               	        ; Disable the external clocking of the Timer1 counter 
 307:CamInterfaceAsm.S ****         in      tmp1, _SFR_IO_ADDR(TCCR1B)
 308:CamInterfaceAsm.S ****         andi    tmp1, 0xF8
 309:CamInterfaceAsm.S ****         out     _SFR_IO_ADDR(TCCR1B),tmp1
 310               			
 311               			; Toggle the debug line to indicate the line is complete
 312:CamInterfaceAsm.S **** 		sbi     _SFR_IO_ADDR(PORTD),PD6
 313:CamInterfaceAsm.S **** 		cbi		_SFR_IO_ADDR(PORTD),PD6
 314:CamInterfaceAsm.S **** 		clt				; clear out the T bit since we have detected
 315               							; the interruption and are exiting to handle it
 316               	_exit:
 317:CamInterfaceAsm.S **** 		ret
 318               			
 319               	;*****************************************************************		
 320               	;   	Function Name: CamIntAsm_waitForNewDumpFrame
 321               	;       Function Description: This function is responsible for
 322               	;       going to sleep until a new frame begins (indicated by
 323               	;    	VSYNC transitioning from low to high.  This will wake
 324               	;       the "VSYNC sleep" up and allow it to continue with 
 325               	;       acquiring a line of pixel data to dump out to the UI.
 326               	;       Inputs:  r25 - MSB of currentLineBuffer
 327               	;                r24 - LSB of currentLineBuffer
 328               	;				 r23 - MSB of prevLineBuffer
 329               	;				 r22 - LSB of prevLineBuffer
 330               	;       Outputs: none

⌨️ 快捷键说明

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