OUT endpoint example code for enCoRe(sitlcag)
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
Answer:
Unfortunately, we do not have any sample code for an OUT endpoint. However, it's very straight forward. You may need to modify your Config, Interface, and Endpoint descriptors to tell the host about the new OUT endpoint, and you need to add code for the OUT ISR. Below is an example for an OUT ISR:
EP2_ISR:
push A
push X
iord Ep2_Count ; error checking
and A, DATA_VALID ; Is the data valid?
jz .set_NAK_OUT_Mode ; If not, 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 .set_NAK_OUT_Mode
iord Ep2Count
and A,BYTE_COUNT ; make sure data byte
cmp A,0Bh ; count is <= 10 bytes
jnc .set_NAK_OUT_Mode:
iord Ep2_Count
and A, DATA_TOGGLE ; Did the host send
xor A, [ep2_data_toggle] ; the same DataToggle?
jnz .set_NAK_OUT_Mode ; If yes, don?t toggle DataToggle
mov A, ACK_OUT ; If bad data toggle, ignore. You can jump to
iowr Ep2_Mode ; set_NAK_OUT_Mode and have your main routine
jmp endpoint2_ISR_done ;re-arm the endpoint.
.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
xor [ep2_data_toggle], A ; toggle data_toggle bit
;...anything else you need to do in the ISR.
;...
.set_NAK_OUT_Mode:
mov A, NAK_OUT
iowr Ep2_Mode
endpoint2_ISR_done:
pop X
pop A
reti ; return with interrupts enabled
-
This widget could not be displayed.Anonymous