@@ -433,7 +433,7 @@ void USB_WritePacket_EP0(uint8_t *src, uint16_t len) {
433
433
hexdump (src , len );
434
434
#endif
435
435
436
- uint16_t wplen = min (len , 0x40 );
436
+ uint16_t wplen = MIN (len , 0x40 );
437
437
USB_WritePacket (src , wplen , 0 );
438
438
439
439
if (wplen < len ) {
@@ -545,29 +545,29 @@ void usb_setup() {
545
545
//puts(" writing device descriptor\n");
546
546
547
547
// setup transfer
548
- USB_WritePacket (device_desc , min (sizeof (device_desc ), setup .b .wLength .w ), 0 );
548
+ USB_WritePacket (device_desc , MIN (sizeof (device_desc ), setup .b .wLength .w ), 0 );
549
549
USBx_OUTEP (0 )-> DOEPCTL |= USB_OTG_DOEPCTL_CNAK ;
550
550
551
551
//puts("D");
552
552
break ;
553
553
case USB_DESC_TYPE_CONFIGURATION :
554
- USB_WritePacket (configuration_desc , min (sizeof (configuration_desc ), setup .b .wLength .w ), 0 );
554
+ USB_WritePacket (configuration_desc , MIN (sizeof (configuration_desc ), setup .b .wLength .w ), 0 );
555
555
USBx_OUTEP (0 )-> DOEPCTL |= USB_OTG_DOEPCTL_CNAK ;
556
556
break ;
557
557
case USB_DESC_TYPE_DEVICE_QUALIFIER :
558
- USB_WritePacket (device_qualifier , min (sizeof (device_qualifier ), setup .b .wLength .w ), 0 );
558
+ USB_WritePacket (device_qualifier , MIN (sizeof (device_qualifier ), setup .b .wLength .w ), 0 );
559
559
USBx_OUTEP (0 )-> DOEPCTL |= USB_OTG_DOEPCTL_CNAK ;
560
560
break ;
561
561
case USB_DESC_TYPE_STRING :
562
562
switch (setup .b .wValue .bw .msb ) {
563
563
case STRING_OFFSET_LANGID :
564
- USB_WritePacket ((uint8_t * )string_language_desc , min (sizeof (string_language_desc ), setup .b .wLength .w ), 0 );
564
+ USB_WritePacket ((uint8_t * )string_language_desc , MIN (sizeof (string_language_desc ), setup .b .wLength .w ), 0 );
565
565
break ;
566
566
case STRING_OFFSET_IMANUFACTURER :
567
- USB_WritePacket ((uint8_t * )string_manufacturer_desc , min (sizeof (string_manufacturer_desc ), setup .b .wLength .w ), 0 );
567
+ USB_WritePacket ((uint8_t * )string_manufacturer_desc , MIN (sizeof (string_manufacturer_desc ), setup .b .wLength .w ), 0 );
568
568
break ;
569
569
case STRING_OFFSET_IPRODUCT :
570
- USB_WritePacket ((uint8_t * )string_product_desc , min (sizeof (string_product_desc ), setup .b .wLength .w ), 0 );
570
+ USB_WritePacket ((uint8_t * )string_product_desc , MIN (sizeof (string_product_desc ), setup .b .wLength .w ), 0 );
571
571
break ;
572
572
case STRING_OFFSET_ISERIAL :
573
573
#ifdef UID_BASE
@@ -583,16 +583,16 @@ void usb_setup() {
583
583
resp [2 + i * 4 + 3 ] = '\0' ;
584
584
}
585
585
586
- USB_WritePacket (resp , min (resp [0 ], setup .b .wLength .w ), 0 );
586
+ USB_WritePacket (resp , MIN (resp [0 ], setup .b .wLength .w ), 0 );
587
587
#else
588
- USB_WritePacket ((const uint8_t * )string_serial_desc , min (sizeof (string_serial_desc ), setup .b .wLength .w ), 0 );
588
+ USB_WritePacket ((const uint8_t * )string_serial_desc , MIN (sizeof (string_serial_desc ), setup .b .wLength .w ), 0 );
589
589
#endif
590
590
break ;
591
591
case STRING_OFFSET_ICONFIGURATION :
592
- USB_WritePacket ((uint8_t * )string_configuration_desc , min (sizeof (string_configuration_desc ), setup .b .wLength .w ), 0 );
592
+ USB_WritePacket ((uint8_t * )string_configuration_desc , MIN (sizeof (string_configuration_desc ), setup .b .wLength .w ), 0 );
593
593
break ;
594
594
case 238 :
595
- USB_WritePacket ((uint8_t * )string_238_desc , min (sizeof (string_238_desc ), setup .b .wLength .w ), 0 );
595
+ USB_WritePacket ((uint8_t * )string_238_desc , MIN (sizeof (string_238_desc ), setup .b .wLength .w ), 0 );
596
596
break ;
597
597
default :
598
598
// nothing
@@ -602,7 +602,7 @@ void usb_setup() {
602
602
USBx_OUTEP (0 )-> DOEPCTL |= USB_OTG_DOEPCTL_CNAK ;
603
603
break ;
604
604
case USB_DESC_TYPE_BINARY_OBJECT_STORE :
605
- USB_WritePacket (binary_object_store_desc , min (sizeof (binary_object_store_desc ), setup .b .wLength .w ), 0 );
605
+ USB_WritePacket (binary_object_store_desc , MIN (sizeof (binary_object_store_desc ), setup .b .wLength .w ), 0 );
606
606
USBx_OUTEP (0 )-> DOEPCTL |= USB_OTG_DOEPCTL_CNAK ;
607
607
break ;
608
608
default :
@@ -628,7 +628,7 @@ void usb_setup() {
628
628
case WEBUSB_VENDOR_CODE :
629
629
switch (setup .b .wIndex .w ) {
630
630
case WEBUSB_REQ_GET_URL :
631
- USB_WritePacket (webusb_url_descriptor , min (sizeof (webusb_url_descriptor ), setup .b .wLength .w ), 0 );
631
+ USB_WritePacket (webusb_url_descriptor , MIN (sizeof (webusb_url_descriptor ), setup .b .wLength .w ), 0 );
632
632
USBx_OUTEP (0 )-> DOEPCTL |= USB_OTG_DOEPCTL_CNAK ;
633
633
break ;
634
634
default :
@@ -642,23 +642,23 @@ void usb_setup() {
642
642
switch (setup .b .wIndex .w ) {
643
643
// winusb 2.0 descriptor from BOS
644
644
case WINUSB_REQ_GET_DESCRIPTOR :
645
- USB_WritePacket_EP0 ((uint8_t * )winusb_20_desc , min (sizeof (winusb_20_desc ), setup .b .wLength .w ));
645
+ USB_WritePacket_EP0 ((uint8_t * )winusb_20_desc , MIN (sizeof (winusb_20_desc ), setup .b .wLength .w ));
646
646
break ;
647
647
// Extended Compat ID OS Descriptor
648
648
case WINUSB_REQ_GET_COMPATID_DESCRIPTOR :
649
- USB_WritePacket_EP0 ((uint8_t * )winusb_ext_compatid_os_desc , min (sizeof (winusb_ext_compatid_os_desc ), setup .b .wLength .w ));
649
+ USB_WritePacket_EP0 ((uint8_t * )winusb_ext_compatid_os_desc , MIN (sizeof (winusb_ext_compatid_os_desc ), setup .b .wLength .w ));
650
650
break ;
651
651
// Extended Properties OS Descriptor
652
652
case WINUSB_REQ_GET_EXT_PROPS_OS :
653
- USB_WritePacket_EP0 ((uint8_t * )winusb_ext_prop_os_desc , min (sizeof (winusb_ext_prop_os_desc ), setup .b .wLength .w ));
653
+ USB_WritePacket_EP0 ((uint8_t * )winusb_ext_prop_os_desc , MIN (sizeof (winusb_ext_prop_os_desc ), setup .b .wLength .w ));
654
654
break ;
655
655
default :
656
656
USB_WritePacket_EP0 (0 , 0 );
657
657
}
658
658
break ;
659
659
default :
660
660
resp_len = usb_cb_control_msg (& setup , resp , 1 );
661
- USB_WritePacket (resp , min (resp_len , setup .b .wLength .w ), 0 );
661
+ USB_WritePacket (resp , MIN (resp_len , setup .b .wLength .w ), 0 );
662
662
USBx_OUTEP (0 )-> DOEPCTL |= USB_OTG_DOEPCTL_CNAK ;
663
663
}
664
664
}
@@ -972,7 +972,7 @@ void usb_irqhandler(void) {
972
972
#endif
973
973
974
974
if (ep0_txlen != 0 && (USBx_INEP (0 )-> DTXFSTS & USB_OTG_DTXFSTS_INEPTFSAV ) >= 0x40 ) {
975
- uint16_t len = min (ep0_txlen , 0x40 );
975
+ uint16_t len = MIN (ep0_txlen , 0x40 );
976
976
USB_WritePacket (ep0_txdata , len , 0 );
977
977
ep0_txdata += len ;
978
978
ep0_txlen -= len ;
0 commit comments