xxopiumxx
Joined: 01 Jul 2011 Posts: 20
|
USB library doubt |
Posted: Tue Sep 20, 2011 9:35 am |
|
|
Hi. I'm working a lot on USB HID, with a PIC18F4550. Anyways, i think that i spend more time reading the libraries, and trying to understand them, than properly programming.
In this moment I am trying to edit my own interrupt functions, and I am having some trouble.
I understand that when an interrupt comes up, a certain register changes its value and that calls a subroutine. particularly that segment is (obviating the control/en==0 instructions):
Code: |
void usb_isr_tok_dne() {
(...)
else {
if (!bit_test(USTAT,2)) {
usb_isr_tok_out_dne(en);
}
else {
usb_isr_tok_in_dne(en);
}
}
|
Digging a bit deeper, I found that the function usb_isr_tok_in_dne doesn't do anything in case of en==1 (or generically !=0||!=CDC)
Code: |
void usb_isr_tok_in_dne(int8 endpoint) {
if (endpoint==0) {
if (USB_stack_status.dev_req == GET_DESCRIPTOR) {usb_copy_desc_seg_to_ep();} //check this, we are missing report descriptor?
else if (USB_stack_status.dev_req == SET_ADDRESS) {usb_finish_set_address();}
}
#if USB_CDC_DEVICE
else if (endpoint==USB_CDC_DATA_IN_ENDPOINT) { //see ex_usb_serial.c example and usb_cdc.h driver
usb_isr_tok_in_cdc_data_dne();
}
#endif
}
|
This is just for curiosity, because I am actually managing the in-interrupt at my will, but I wish to understand it better.
The other thing that I don't understand and I suspect that is giving me some trouble is the usb_flush_in & usb_flush_out. As I understand it 'clears' the endpoint for new incomes/outcomes; but I cannot find where it is first called; and it is not implicit called because if I don't call the usb_flush_in, for example, explicitly my pic doesn't see the interrupt in.
I know this because I've configured a pair of leds, in the interrupt routine, that informs me about it.
thanks for your time. any answer will be great! |
|