Sample codes for enCore's OUT endpoint? | Cypress Semiconductor
Support & Community
Sample codes for enCore's OUT endpoint?
Are there any sample codes for enCore's OUT endpoint?
No. Currently, the enCore's reference designs only use IN endpoint. There're a couple things you need to do.
1. You need to add the ep2 info into your ep descriptor table and specify that ep2 is an OUT ep.
2. You need to add code to handle ep2 ISR. Below are some suggestions for EP2_ISR's error checking: EP2_ISR:
iord Ep2_Count ; error checking
and A, DATA_VALID ; Is the data valid?
jz endpoint2_ISR_done ; do something about it. In this example, just simply exit the ISR.
iord Ep2_Mode ; Note: a NAK does cause an interrupt. Is it a NAK and A, EP_ACK ;interrupt? If yes, we're not ready.
Exit jz endpoint2_ISR_done
and A,BYTE_COUNT ; make sure data byte count is <= 10 bytes
and A, DATA_TOGGLE ; Did the host send the same DataToggle?
xor A, [ep2_data_toggle]
jz .good_data_toggle ;If not, continue
mov A, ACK_OUT ; If bad data toggle, re-arm the ep (or set a flag to process the event in the main loop)
jmp endpoint2_ISR_done .good_data_toggle: ; ...Done Error checking. If you get here, the data was received error free.
mov A, DATA_TOGGLE ; It's an ACK interrupt and byte count < ep length, toggle data_toggle bit
xor [ep2_data_toggle], A ;... ;... endpoint2_ISR_done:
reti ; return with interrupts enabled