Skip to content

Commit d507632

Browse files
committed
support larger endpoint size
see raspberrypi/pico-extras#78
1 parent fe5529a commit d507632

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

main.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,15 +639,21 @@ static void __not_in_flash_func(_as_audio_packet)(struct usb_endpoint *ep) { //
639639
switch (cur_alt)
640640
{
641641
case 1: // 32bit
642-
count = (usb_buffer->data_len + 256) / 8; // the packet size is overflowing!!!
642+
if (sizeof(usb_buffer->data_len) > 1) // for pico_extras with fixed EP buffer size limit https://github.com/raspberrypi/pico-extras/pull/78
643+
count = usb_buffer->data_len / 8;
644+
else
645+
count = (usb_buffer->data_len + 256) / 8; // the packet size is overflowing!!!
643646
{
644647
int32_t *in = (int32_t *) usb_buffer->data;
645648
for (int i = 0; i < count * 2; i++)
646649
buf0[i] = in[i] >> HEADROOM; // divide by 2, allow some headroom in case the filters need it
647650
}
648651
break;
649652
case 2: // 24bit
650-
count = (usb_buffer->data_len + 256) / 6; // the packet size is overflowing!!!
653+
if (sizeof(usb_buffer->data_len) > 1) // for pico_extras with fixed EP buffer size limit https://github.com/raspberrypi/pico-extras/pull/78
654+
count = usb_buffer->data_len / 6;
655+
else
656+
count = (usb_buffer->data_len + 256) / 6; // the packet size is overflowing!!!
651657
{
652658
uint8_t *in = (uint8_t *) usb_buffer->data;
653659
for (int i = 0; i < count * 2; i += 2) {

0 commit comments

Comments
 (0)