I´m struggling with the T4.0 USB implementation. I try to implement the MTPDISK feature, which I urgently need on T4.0.
So, I try to learn from existing implementation.
At the moment I fail to understand the following snippet
in particular, I do not understand the sequence
which I thought should read
Any clarification?
Can someone confirm that RAWHID works for T4.0?
Edit: Maybe because it is interrupt driven receive? Does bulk receive work at all?
So, I try to learn from existing implementation.
At the moment I fail to understand the following snippet
Code:
int usb_rawhid_recv(void *buffer, uint32_t timeout)
{
uint32_t wait_begin_at = systick_millis_count;
while (1) {
if (!usb_configuration) return -1; // usb not enumerated by host
uint32_t status = usb_transfer_status(rx_transfer);
if (!(status & 0x80)) break; // transfer descriptor ready
if (systick_millis_count - wait_begin_at > timeout) return 0;
yield();
}
memcpy(buffer, rx_buffer, RAWHID_RX_SIZE);
memset(rx_transfer, 0, sizeof(rx_transfer));
usb_prepare_transfer(rx_transfer + 0, rx_buffer, RAWHID_RX_SIZE, 0);
usb_receive(RAWHID_RX_ENDPOINT, rx_transfer + 0);
return RAWHID_RX_SIZE;
}
Code:
[B]memcpy(buffer, rx_buffer, RAWHID_RX_SIZE);[/B]
memset(rx_transfer, 0, sizeof(rx_transfer));
usb_prepare_transfer(rx_transfer + 0, rx_buffer, RAWHID_RX_SIZE, 0);
usb_receive(RAWHID_RX_ENDPOINT, rx_transfer + 0);
Code:
memset(rx_transfer, 0, sizeof(rx_transfer));
usb_prepare_transfer(rx_transfer + 0, rx_buffer, RAWHID_RX_SIZE, 0);
usb_receive(RAWHID_RX_ENDPOINT, rx_transfer + 0);
[B]memcpy(buffer, rx_buffer, RAWHID_RX_SIZE);[/B]
Any clarification?
Can someone confirm that RAWHID works for T4.0?
Edit: Maybe because it is interrupt driven receive? Does bulk receive work at all?