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

📄 lib_udp.mac

📁 ARM9200开发板的ROM boot程序源码1.0
💻 MAC
字号:
;------------------------------------------------------------------------------
;-         ATMEL Microcontroller Software Support  -  ROUSSET  -
;------------------------------------------------------------------------------
; The software is delivered "AS IS" without warranty or condition of any
; kind, either express, implied or statutory. This includes without
; limitation any warranty or condition with respect to merchantability or
; fitness for any particular purpose, or against the infringements of
; intellectual property rights of others.
;------------------------------------------------------------------------------
;- File Name            : lib_udp.inc
;- Object               : Assembler USB device FIQ handler.
;-
;- 1.0 17/09/01 ODi     : Creation
;------------------------------------------------------------------------------

;- ========================================================	
;- Macro definition: MAC_DMA_RX
;-
;- Arguments:
;-      $label    label used as base label for all macro's labels
;-      $toAddr   destination address
;-      $fromAddr origin address
;-      $bytesRcv number of bytes to transfer
;-      $cntLoop  scratch register to perform modulo operations
;-      $value    scratch register used to copy bytes
;- Dependencies:
;-      MAC_DMA_POP  inline code to copy a buffer
;- ========================================================	
	MACRO       
	MAC_DMA_RX $label
$label
;- Check this is a DATA OUT transaction
	ands        r10, r9,  #UDP_RCV_DATA_BANK0:OR:#UDP_RCV_DATA_BANK1
	bne         $label.exit

;- Get Data from the FIFO
	stmfd       sp!, {r9, r10, lr}
	bl          dma_rx
	ldmfd       sp!, {r9, r10, lr}

;- Clear the flag
	eor         r10, r10, r9
	ldr         r10,  [r8, #UDP_EP0]

;- test if the buffer counter == 0
	tst         r12, #1
	bne         dma_achieve_fiq ; wait for another data payload has been received 
	beq         dma_notify_isr ; (bufferLength == 0) notify the ISR

$label.exit

	MEND
	
;- ========================================================	
;- Macro definition: MAC_DMA_TX
;-
;- Arguments:
;-      $label    label used as base label for all macro's labels
;-      $toAddr   destination address
;-      $fromAddr origin address
;-      $bytesRcv number of bytes to transfer
;-      $cntLoop  scratch register to perform modulo operations
;-      $value    scratch register used to copy bytes
;- Dependencies:
;-      MAC_DMA_POP  inline code to copy a buffer
;- ========================================================	
	MACRO
	MAC_DMA_TX $label, $udpCsr
$label
;- Check this is a DATA IN transaction
	ands        r10, r9,  #UDP_TXCOMPLETE
	bne         $label.exit

;- Get Data from the FIFO
	stmfd       sp!, {r9, r10, lr}
	bl          dma_tx
	ldmfd       sp!, {r9, r10, lr}

;- Clear the flag
	eor         r10, r10, r9
	ldr         r10,  [r8, #UDP_EP0]

;- test if the buffer counter == 0
	tst         r12, #1
	bne         dma_achieve_fiq ; wait for another data payload has been received 
	beq         dma_notify_isr ; (bufferLength == 0) notify the ISR

$label.exit
	MEND
	
	
;- ========================================================	
;- Macro definition: MAC_DMA
;-
;- Description:
;-      Copy data from a FIFO to memory
;- Arguments:
;-      $label    label used as base label for all macro's labels
;-      $macro    MAC_DMA_POP or MAC_DMA_PUSH
;-      $toAddr   destination address
;-      $fromAddr origin address
;-      $nbBytes  number of bytes to transfer
;-      $cntLoop  scratch register to perform modulo operations
;-      $value    scratch register used to copy bytes
;- Dependencies:
;-      MAC_DMA_POP   inline code to copy pop bytes from a FIFO
;-      MAC_DMA_PUSH  inline code to copy push bytes to a FIFO
;- ========================================================	
	MACRO
	MAC_DMA    $label, $macro, $toAddr, $fromAddr, $nbBytes, $cntLoop, $value
	
;- Check if the (bytesRcv % 128) != 0 
	movs        $cntLoop, $nbBytes, LSR #7
	beq         $label.loop64
$label.loop128
	$macro     $toAddr, $fromAddr, 128, $value
	subs        $cntLoop, $cntLoop, #1
	beq         $label.loop128
	and         $nbBytes, $nbBytes, #0x7F
	
;- Check if the (bytesRcv % 64) != 0 
	movs        $cntLoop, $nbBytes, LSR #6
	beq         $label.loop32
$label.loop64
	$macro     $toAddr, $fromAddr, 64, $value
	subs        $cntLoop, $cntLoop, #1
	beq         $label.loop64
	and         $nbBytes, $nbBytes, #0x3F
	
;- Check if the (bytesRcv % 32) != 0 
	movs        $cntLoop, $nbBytes, LSR #5
	beq         $label.loop8
$label.loop32
	$macro     $toAddr, $fromAddr, 32, $value
	subs        $cntLoop, $cntLoop, #1
	beq         $label.loop32
	and         $nbBytes, $nbBytes, #0x1F

;- Check if the (bytesRcv % 8) != 0 
	movs        $cntLoop, $nbBytes, LSR #3
	beq         $label.loop1
$label.loop8
	$macro     $toAddr, $fromAddr, 8, $value
	subs        $cntLoop, $cntLoop, #1
	beq         $label.loop8
	and         $nbBytes, $nbBytes, #0x7

;- Copy remaining bytes
	beq         $label.exit	
$label.loop1
	$macro     $toAddr, $fromAddr, 1, $value
	subs        $nbBytes, $nbBytes, #1
	beq         $label.loop1
	
$label.exit	
	MEND
	
;- ========================================================	
;- Macro definition: MAC_DMA_POP
;-
;- Description:
;-      Copy $nbBytes data from a FIFO to memory
;- Arguments:
;-      $toAddr   destination address
;-      $fromAddr origin address
;-      $nbBytes  number of bytes to transfer
;-      $value    scratch register used to copy bytes
;- Dependencies:
;- ========================================================	
	MACRO
	MAC_DMA_POP $toAddr, $fromAddr, $nbBytes, $value
;	LCLA	    bytesSent
;bytesSent SETA      $nbBytes
;	WHILE	    bytesSent > 0
;bytesSent SETA	    bytesSent-1
	.rept        $nbBytes
	ldrb        $value, [$fromAddr] 
	strb        $value, [$toAddr],#1
	.endr
;	WEND
	MEND

;- ========================================================	
;- Macro definition: MAC_DMA_PUSH
;-
;- Description:
;-      Copy $nbBytes data from a FIFO to memory
;- Arguments:
;-      $toAddr   destination address
;-      $fromAddr origin address
;-      $nbBytes  number of bytes to transfer
;-      $value    scratch register used to copy bytes
;- Dependencies:
;- ========================================================	
	MACRO
	MAC_DMA_PUSH $toAddr, $fromAddr, $nbBytes, $value
;	LCLA	    bytesSent
;bytesSent SETA      $nbBytes
;	WHILE	    bytesSent > 0
;bytesSent SETA	    bytesSent-1
	.rept       $nbBytes
	ldrb        $value, [$fromAddr], #1 
	strb        $value, [$toAddr]
	.endr
;	WEND
	MEND


⌨️ 快捷键说明

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