
Cypress CY3640 USB Starter Kit
User’s Guide
Cypress Semiconductor Ver 0.993
Page 24
; Stall any subsequent IN's or OUT's until the
; stall bit (bit 5) is cleard by an I/O write to
; the USB End Point 0 TX Configuration Register (0x10)
; or any SETUP is received.
iord USBEndP0TxConfig
or a,USBEndP0TxStall
iowr USBEndP0TxConfig
; OK. We've set the stall condition for Endpoint 0.
; Now let's complete the routine.
jmp USBEventEP0End
;*******************************************************************************
;
; We know we have received a Setup token. Now we need to parse it to
; determine what command it is.
;
;*******************************************************************************
;//$PAGE
;*******************************************************************************
; USBEventEP0_SETUP()
; @func End point event SETUP packet handler.
; @devnote Runs in interrupt enabled context.
;********************************************************
USBEventEP0_SETUP:
; Well, we have a SETUP packet. Let's find out what to do.
mov A,[gbSysInterruptMask]
iowr SysInterrupt
; If we are here and are and we are processing a previous Setup,
; we need to abort the processing of the previous Setup
mov a,0 ; Clear any indication that we have bytes left to transfer
mov [gbUSBSendBytes],a
; Clear EP0 RxReg (including the Setup flag)
; The Data toggle bit remains unchanged, however.
mov a,0
iowr USBEndP0RxStatus
;*********************************************
; Setup Event
;*********************************************
; Check the request type and branch to the correct location to handle it.
mov a,[USBEndP0FIFO_0]
USBEventEP0SetupTargetDeviceOUT:
; Target Device?
cmp a,USBRqstTargetDevice
jz USBEventEP0SetupIsSetAddress ; Yes
USBEventEP0SetupTargetInterfaceOUT:
cmp a,USBRqstTargetInterface
jz USBEventEP0Stall ; Yes. Oops! We don't have an interface.
USBEventEP0SetupTargetEndpointOUT:
cmp a,USBRqstTargetEndPoint
jz USBEventEP0Stall ; Yes
USBEventEP0SetupTargetDeviceIN:
cmp a,USBRqstTargetDevice | USBRqstTypeDirection
jz USBEventEP0SetupGetDescriptor ; Yes
USBEventEP0SetupTargetInterfaceIN:
cmp a,USBRqstTargetInterface | USBRqstTypeDirection
jz USBEventEP0Stall ; Yes Oops! We don't have an interface.
USBEventEP0SetupTargetEndpointIN:
cmp a,USBRqstTargetEndPoint | USBRqstTypeDirection