@@ -474,33 +474,33 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
474
474
(void )USBD_LL_OpenEP (pdev , CDC_IN_EP , USBD_EP_TYPE_BULK ,
475
475
CDC_DATA_HS_IN_PACKET_SIZE );
476
476
477
- pdev -> ep_in [CDC_IN_EP & 0xFU ].is_used = 1U ;
477
+ pdev -> ep_in [CDC_IN_EP & 0xFU ].is_used = 1U ;
478
478
479
- /* Open EP OUT */
480
- (void )USBD_LL_OpenEP (pdev , CDC_OUT_EP , USBD_EP_TYPE_BULK ,
481
- CDC_DATA_HS_OUT_PACKET_SIZE );
479
+ /* Open EP OUT */
480
+ (void )USBD_LL_OpenEP (pdev , CDC_OUT_EP , USBD_EP_TYPE_BULK ,
481
+ CDC_DATA_HS_OUT_PACKET_SIZE );
482
482
483
- pdev -> ep_out [CDC_OUT_EP & 0xFU ].is_used = 1U ;
483
+ pdev -> ep_out [CDC_OUT_EP & 0xFU ].is_used = 1U ;
484
484
485
- /* Set bInterval for CDC CMD Endpoint */
486
- pdev -> ep_in [CDC_CMD_EP & 0xFU ].bInterval = CDC_HS_BINTERVAL ;
485
+ /* Set bInterval for CDC CMD Endpoint */
486
+ pdev -> ep_in [CDC_CMD_EP & 0xFU ].bInterval = CDC_HS_BINTERVAL ;
487
487
}
488
488
else
489
489
{
490
490
/* Open EP IN */
491
491
(void )USBD_LL_OpenEP (pdev , CDC_IN_EP , USBD_EP_TYPE_BULK ,
492
492
CDC_DATA_FS_IN_PACKET_SIZE );
493
493
494
- pdev -> ep_in [CDC_IN_EP & 0xFU ].is_used = 1U ;
494
+ pdev -> ep_in [CDC_IN_EP & 0xFU ].is_used = 1U ;
495
495
496
- /* Open EP OUT */
497
- (void )USBD_LL_OpenEP (pdev , CDC_OUT_EP , USBD_EP_TYPE_BULK ,
498
- CDC_DATA_FS_OUT_PACKET_SIZE );
496
+ /* Open EP OUT */
497
+ (void )USBD_LL_OpenEP (pdev , CDC_OUT_EP , USBD_EP_TYPE_BULK ,
498
+ CDC_DATA_FS_OUT_PACKET_SIZE );
499
499
500
- pdev -> ep_out [CDC_OUT_EP & 0xFU ].is_used = 1U ;
500
+ pdev -> ep_out [CDC_OUT_EP & 0xFU ].is_used = 1U ;
501
501
502
- /* Set bInterval for CMD Endpoint */
503
- pdev -> ep_in [CDC_CMD_EP & 0xFU ].bInterval = CDC_FS_BINTERVAL ;
502
+ /* Set bInterval for CMD Endpoint */
503
+ pdev -> ep_in [CDC_CMD_EP & 0xFU ].bInterval = CDC_FS_BINTERVAL ;
504
504
}
505
505
506
506
/* Open Command IN EP */
@@ -540,7 +540,6 @@ static uint8_t USBD_CDC_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
540
540
static uint8_t USBD_CDC_DeInit (USBD_HandleTypeDef * pdev , uint8_t cfgidx )
541
541
{
542
542
UNUSED (cfgidx );
543
- uint8_t ret = 0U ;
544
543
545
544
/* Close EP IN */
546
545
(void )USBD_LL_CloseEP (pdev , CDC_IN_EP );
@@ -563,7 +562,7 @@ static uint8_t USBD_CDC_DeInit(USBD_HandleTypeDef *pdev, uint8_t cfgidx)
563
562
pdev -> pClassData = NULL ;
564
563
}
565
564
566
- return ret ;
565
+ return ( uint8_t ) USBD_OK ;
567
566
}
568
567
569
568
/**
@@ -583,81 +582,81 @@ static uint8_t USBD_CDC_Setup(USBD_HandleTypeDef *pdev,
583
582
584
583
switch (req -> bmRequest & USB_REQ_TYPE_MASK )
585
584
{
586
- case USB_REQ_TYPE_CLASS :
587
- if (req -> wLength != 0U )
588
- {
589
- if ((req -> bmRequest & 0x80U ) != 0U )
585
+ case USB_REQ_TYPE_CLASS :
586
+ if (req -> wLength != 0U )
590
587
{
591
- ((USBD_CDC_ItfTypeDef * )pdev -> pUserData )-> Control (req -> bRequest ,
592
- (uint8_t * )hcdc -> data ,
593
- req -> wLength );
588
+ if ((req -> bmRequest & 0x80U ) != 0U )
589
+ {
590
+ ((USBD_CDC_ItfTypeDef * )pdev -> pUserData )-> Control (req -> bRequest ,
591
+ (uint8_t * )hcdc -> data ,
592
+ req -> wLength );
594
593
595
594
(void )USBD_CtlSendData (pdev , (uint8_t * )hcdc -> data , req -> wLength );
595
+ }
596
+ else
597
+ {
598
+ hcdc -> CmdOpCode = req -> bRequest ;
599
+ hcdc -> CmdLength = (uint8_t )req -> wLength ;
600
+
601
+ (void )USBD_CtlPrepareRx (pdev , (uint8_t * )hcdc -> data , req -> wLength );
602
+ }
596
603
}
597
604
else
598
605
{
599
- hcdc -> CmdOpCode = req -> bRequest ;
600
- hcdc -> CmdLength = (uint8_t )req -> wLength ;
601
-
602
- (void )USBD_CtlPrepareRx (pdev , (uint8_t * )hcdc -> data , req -> wLength );
603
- }
604
- }
605
- else
606
- {
607
- ((USBD_CDC_ItfTypeDef * )pdev -> pUserData )-> Control (req -> bRequest ,
608
- (uint8_t * )req , 0U );
609
- }
610
- break ;
611
-
612
- case USB_REQ_TYPE_STANDARD :
613
- switch (req -> bRequest )
614
- {
615
- case USB_REQ_GET_STATUS :
616
- if (pdev -> dev_state == USBD_STATE_CONFIGURED )
617
- {
618
- (void )USBD_CtlSendData (pdev , (uint8_t * )& status_info , 2U );
619
- }
620
- else
621
- {
622
- USBD_CtlError (pdev , req );
623
- ret = USBD_FAIL ;
624
- }
625
- break ;
626
-
627
- case USB_REQ_GET_INTERFACE :
628
- if (pdev -> dev_state == USBD_STATE_CONFIGURED )
629
- {
630
- (void )USBD_CtlSendData (pdev , & ifalt , 1U );
631
- }
632
- else
633
- {
634
- USBD_CtlError (pdev , req );
635
- ret = USBD_FAIL ;
606
+ ((USBD_CDC_ItfTypeDef * )pdev -> pUserData )-> Control (req -> bRequest ,
607
+ (uint8_t * )req , 0U );
636
608
}
637
609
break ;
638
610
639
- case USB_REQ_SET_INTERFACE :
640
- if ( pdev -> dev_state != USBD_STATE_CONFIGURED )
611
+ case USB_REQ_TYPE_STANDARD :
612
+ switch ( req -> bRequest )
641
613
{
642
- USBD_CtlError (pdev , req );
643
- ret = USBD_FAIL ;
614
+ case USB_REQ_GET_STATUS :
615
+ if (pdev -> dev_state == USBD_STATE_CONFIGURED )
616
+ {
617
+ (void )USBD_CtlSendData (pdev , (uint8_t * )& status_info , 2U );
618
+ }
619
+ else
620
+ {
621
+ USBD_CtlError (pdev , req );
622
+ ret = USBD_FAIL ;
623
+ }
624
+ break ;
625
+
626
+ case USB_REQ_GET_INTERFACE :
627
+ if (pdev -> dev_state == USBD_STATE_CONFIGURED )
628
+ {
629
+ (void )USBD_CtlSendData (pdev , & ifalt , 1U );
630
+ }
631
+ else
632
+ {
633
+ USBD_CtlError (pdev , req );
634
+ ret = USBD_FAIL ;
635
+ }
636
+ break ;
637
+
638
+ case USB_REQ_SET_INTERFACE :
639
+ if (pdev -> dev_state != USBD_STATE_CONFIGURED )
640
+ {
641
+ USBD_CtlError (pdev , req );
642
+ ret = USBD_FAIL ;
643
+ }
644
+ break ;
645
+
646
+ case USB_REQ_CLEAR_FEATURE :
647
+ break ;
648
+
649
+ default :
650
+ USBD_CtlError (pdev , req );
651
+ ret = USBD_FAIL ;
652
+ break ;
644
653
}
645
654
break ;
646
655
647
- case USB_REQ_CLEAR_FEATURE :
648
- break ;
649
-
650
656
default :
651
657
USBD_CtlError (pdev , req );
652
658
ret = USBD_FAIL ;
653
659
break ;
654
- }
655
- break ;
656
-
657
- default :
658
- USBD_CtlError (pdev , req );
659
- ret = USBD_FAIL ;
660
- break ;
661
660
}
662
661
663
662
return (uint8_t )ret ;
@@ -694,7 +693,11 @@ static uint8_t USBD_CDC_DataIn(USBD_HandleTypeDef *pdev, uint8_t epnum)
694
693
else
695
694
{
696
695
hcdc -> TxState = 0U ;
697
- ((USBD_CDC_ItfTypeDef * )pdev -> pUserData )-> TransmitCplt (hcdc -> TxBuffer , & hcdc -> TxLength , epnum );
696
+
697
+ if (((USBD_CDC_ItfTypeDef * )pdev -> pUserData )-> TransmitCplt != NULL )
698
+ {
699
+ ((USBD_CDC_ItfTypeDef * )pdev -> pUserData )-> TransmitCplt (hcdc -> TxBuffer , & hcdc -> TxLength , epnum );
700
+ }
698
701
}
699
702
700
703
return (uint8_t )USBD_OK ;
@@ -743,7 +746,6 @@ static uint8_t USBD_CDC_EP0_RxReady(USBD_HandleTypeDef *pdev)
743
746
(uint8_t * )hcdc -> data ,
744
747
(uint16_t )hcdc -> CmdLength );
745
748
hcdc -> CmdOpCode = 0xFFU ;
746
-
747
749
}
748
750
749
751
return (uint8_t )USBD_OK ;
@@ -778,7 +780,7 @@ static uint8_t *USBD_CDC_GetHSCfgDesc(uint16_t *length)
778
780
}
779
781
780
782
/**
781
- * @brief USBD_CDC_GetCfgDesc
783
+ * @brief USBD_CDC_GetOtherSpeedCfgDesc
782
784
* Return configuration descriptor
783
785
* @param speed : current device speed
784
786
* @param length : pointer data length
@@ -792,11 +794,11 @@ static uint8_t *USBD_CDC_GetOtherSpeedCfgDesc(uint16_t *length)
792
794
}
793
795
794
796
/**
795
- * @brief DeviceQualifierDescriptor
796
- * return Device Qualifier descriptor
797
- * @param length : pointer data length
798
- * @retval pointer to descriptor buffer
799
- */
797
+ * @brief USBD_CDC_GetDeviceQualifierDescriptor
798
+ * return Device Qualifier descriptor
799
+ * @param length : pointer data length
800
+ * @retval pointer to descriptor buffer
801
+ */
800
802
uint8_t * USBD_CDC_GetDeviceQualifierDescriptor (uint16_t * length )
801
803
{
802
804
* length = (uint16_t )sizeof (USBD_CDC_DeviceQualifierDesc );
@@ -805,7 +807,7 @@ uint8_t *USBD_CDC_GetDeviceQualifierDescriptor(uint16_t *length)
805
807
}
806
808
807
809
/**
808
- * @brief USBD_CDC_RegisterInterface
810
+ * @brief USBD_CDC_RegisterInterface
809
811
* @param pdev: device instance
810
812
* @param fops: CD Interface callback
811
813
* @retval status
@@ -840,7 +842,6 @@ uint8_t USBD_CDC_SetTxBuffer(USBD_HandleTypeDef *pdev,
840
842
return (uint8_t )USBD_OK ;
841
843
}
842
844
843
-
844
845
/**
845
846
* @brief USBD_CDC_SetRxBuffer
846
847
* @param pdev: device instance
@@ -889,7 +890,6 @@ uint8_t USBD_CDC_TransmitPacket(USBD_HandleTypeDef *pdev)
889
890
return (uint8_t )ret ;
890
891
}
891
892
892
-
893
893
/**
894
894
* @brief USBD_CDC_ReceivePacket
895
895
* prepare OUT Endpoint for reception
0 commit comments