From a7ca3a7cbd04c6c8ec7f6ee37e6601448c37c1c6 Mon Sep 17 00:00:00 2001 From: Oskar Weigl Date: Fri, 7 Sep 2018 20:56:36 -0700 Subject: [PATCH] fix one of my bugs, and one of STM --- .../ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c | 5 +++-- Firmware/communication/interface_usb.cpp | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/Firmware/Board/v3/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c b/Firmware/Board/v3/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c index 631bb392..73313522 100644 --- a/Firmware/Board/v3/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c +++ b/Firmware/Board/v3/Middlewares/ST/STM32_USB_Device_Library/Class/CDC/Src/usbd_cdc.c @@ -570,9 +570,10 @@ static uint8_t USBD_CDC_DataIn (USBD_HandleTypeDef *pdev, uint8_t epnum) if(pdev->pClassData != NULL) { - if (epnum == CDC_IN_EP) + // NOTE: We would logically expect xx_IN_EP here, but we actually get the xx_OUT_EP + if (epnum == CDC_OUT_EP) hcdc->CDC_Tx.State = 0; - if (epnum == ODRIVE_IN_EP) + if (epnum == ODRIVE_OUT_EP) hcdc->ODRIVE_Tx.State = 0; //Note: We could use independent semaphores for simoultainous USB transmission. osSemaphoreRelease(sem_usb_tx); diff --git a/Firmware/communication/interface_usb.cpp b/Firmware/communication/interface_usb.cpp index ba1decc1..d6e38948 100644 --- a/Firmware/communication/interface_usb.cpp +++ b/Firmware/communication/interface_usb.cpp @@ -18,7 +18,7 @@ USBStats_t usb_stats_ = {0}; class USBSender : public PacketSink { public: - USBSender(uint8_t endpoint_pair, osSemaphoreId sem_usb_tx) + USBSender(uint8_t endpoint_pair, const osSemaphoreId& sem_usb_tx) : endpoint_pair_(endpoint_pair), sem_usb_tx_(sem_usb_tx) {} int process_packet(const uint8_t* buffer, size_t length) { @@ -46,7 +46,7 @@ public: } private: uint8_t endpoint_pair_; - osSemaphoreId sem_usb_tx_; + const osSemaphoreId& sem_usb_tx_; }; // Note we could have independent semaphores here to allow concurrent transmission