Been sort of goofing off today
sort of experimenting.
Wondered ways to remove need to call mtp.begin()...
First/current approach or hack :lol:
Added some code to core: usb_mtp.h/c
Code:
static uint8_t usb_mtp_first_rx = 1;
void usb_mtp_first_rx_cb() __attribute__((weak));
void usb_mtp_first_rx_cb(void) {};
static void rx_event(transfer_t *t)
{
int i = t->callback_param;
//printf("rx event i=%d\n", i);
// received a packet with data
if (usb_mtp_first_rx) {
usb_mtp_first_rx = 0;
usb_mtp_first_rx_cb();
}
uint32_t head = rx_head;
if (++head > RX_NUM) head = 0;
rx_list[head] = i;
// remember how many bytes were actually sent by host...
int len = rx_packet_size - ((t->status >> 16) & 0x7FFF);
rx_list_transfer_len[head] = len;
rx_head = head;
}
So on first message that we receive on MTP will call a function and I provided a default weak one... Later does not need to be if code bundled correctly...
I pushed this up into my mtp_serial branch which also has possible start for MTP+Serial.
then in MTP.teensy, I put a version of this function which calls MTP.begin(); automagically
Then was playing with starting up the MTP stuff quickly... So again wondered if the sketches add their storages quickly, before the MTP code ask for storage list, we were part way there. But they returned we are busy when
asked for GetStorageInfo, so I let this be processed.
Then in a few of the sketches, I rearranged things like don't wait on Serial, before we add our storage list... And it may be just me, but I think it does now come up pretty quick
These changes are in the branch fast_start.