
Cypress CY3640 USB Starter Kit
User’s Guide
Cypress Semiconductor Ver 0.993
Page 30
;********************************************************
USBSendROMBuffer:
; Clear flag
mov a,0h
iowr USBEndP0RxStatus
; Enable interrupts
mov a,[gbSysInterruptMask]
and a,~SysIntUSBEndP0
iowr SysInterrupt
; Auto ACK OUT packet (This would be a Status Out)
mov a,USBControlAckStatusData
iowr USBControl
; Initialize sequence
mov a,0h
mov [gbUSBSendSequence],a
; Send count
mov a,[gbUSBSendBytes]
USendROMBufferLoop:
; One 8-byte chunk or less left?
cmp a,08h
jz USendROMBufferLoopDone ; exactly 8 bytes left, branch
jc USendROMBufferLoopDone ; less than 8 bytes left, branch
; more than 8 bytes left, fall through and loop
; until there are 8 bytes or less.
; Save count
push a
; Send 8 byte chunk
mov a,08h
mov [gbUSBSendBytes],a
call _USBSendROMBuffer
; Check for OUT packet cancelling send
iord USBEndP0RxStatus
and a,USBEndP0RxOut
; Restore count
pop a
; Handle exception: OUT packet cancel send
jnz USendROMBufferLoopExit ; Cancelled
; Save bytes left
sub a,08h
mov [gbUSBSendBytes],a
jmp USendROMBufferLoop
USendROMBufferLoopDone:
; Send last 8 or less bytes
call _USBSendROMBuffer
USendROMBufferLoopExit:
ret
;//$PAGE
;********************************************************
; _USBSendROMBuffer()
; @func Buffer and inialize USB send of up
; to 8 bytes of ROM data on end point 0.
; @comm affects gbUSBSendBytes & gbUSBSendBuffer
;********************************************************
_USBSendROMBuffer:
; Save x