Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

usb_sound_card.c - line 290 "todo lie thru our teeth for now" #28

Open
Bram-Pl opened this issue Sep 26, 2022 · 0 comments
Open

usb_sound_card.c - line 290 "todo lie thru our teeth for now" #28

Bram-Pl opened this issue Sep 26, 2022 · 0 comments

Comments

@Bram-Pl
Copy link

Bram-Pl commented Sep 26, 2022

Isochronous data with asynchronous USB transfer type

Line 290 states: todo lie thru our teeth for now in the _as_sync_packet' function. What exactly is meant by this? What does this function do?

Does this mean the asynchronous USB transfer type is not actually providing correct feedback to the USB Host and just spoofing the feedback loop to the host? The function can be seen below. When debugging I noticed that this function is called many times which is what could be expected for something that is used as feedback loop to a USB host device. I just do not comprehend where or when this feedback is returned to the USB host device.

static void _as_sync_packet(struct usb_endpoint *ep) {
    assert(ep->current_transfer);
    DEBUG_PINS_SET(audio_timing, 2);
    DEBUG_PINS_CLR(audio_timing, 2);
    struct usb_buffer *buffer = usb_current_in_packet_buffer(ep);
    assert(buffer->data_max >= 3);
    buffer->data_len = 3;

    // todo lie thru our teeth for now
    uint feedback = (audio_state.freq << 14u) / 1000u;

    buffer->data[0] = feedback;
    buffer->data[1] = feedback >> 8u;
    buffer->data[2] = feedback >> 16u;

    printf("_as_sync_packet function --> data[0]: %d, data[1]: %d, data[2]: %d\n\r");

    // keep on truckin'
    usb_grow_transfer(ep->current_transfer, 1);
    usb_packet_done(ep);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant