From 50d2e598814cb61bec3d67fd1ecba59bbcd7b253 Mon Sep 17 00:00:00 2001 From: Michael McMaster Date: Mon, 15 Feb 2021 21:45:26 +1000 Subject: [PATCH] More USB fixes --- src/firmware/usb_device/usbd_composite.c | 11 ++++++++++- src/firmware/usb_device/usbd_msc_storage_sd.c | 8 ++++---- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/firmware/usb_device/usbd_composite.c b/src/firmware/usb_device/usbd_composite.c index 87715b84..aea505da 100755 --- a/src/firmware/usb_device/usbd_composite.c +++ b/src/firmware/usb_device/usbd_composite.c @@ -31,8 +31,12 @@ // Support 2 USB devices. +#ifdef S2S_USB_FS __ALIGN_BEGIN static USBD_CompositeClassData fsClassData __ALIGN_END; +#endif +#ifdef S2S_USB_HS __ALIGN_BEGIN static USBD_CompositeClassData hsClassData __ALIGN_END; +#endif static uint8_t USBD_Composite_Init (USBD_HandleTypeDef *pdev, uint8_t cfgidx); @@ -270,6 +274,7 @@ static uint8_t USBD_Composite_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) USBD_LL_OpenEP(pdev, HID_EPOUT_ADDR, USBD_EP_TYPE_INTR, HID_EPOUT_SIZE); USBD_CompositeClassData* classData; +#ifdef S2S_USB_HS if(pdev->dev_speed == USBD_SPEED_HIGH) { classData = &hsClassData; @@ -278,7 +283,9 @@ static uint8_t USBD_Composite_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) USBD_LL_OpenEP(pdev, MSC_EPOUT_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_HS_PACKET); USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_HS_PACKET); } - else +#endif +#ifdef S2S_USB_FS + if(pdev->dev_speed != USBD_SPEED_HIGH) { classData = &fsClassData; @@ -286,6 +293,8 @@ static uint8_t USBD_Composite_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) USBD_LL_OpenEP(pdev, MSC_EPOUT_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET); USBD_LL_OpenEP(pdev, MSC_EPIN_ADDR, USBD_EP_TYPE_BULK, MSC_MAX_FS_PACKET); } +#endif + classData->hid.state = HID_IDLE; classData->hid.reportReady = 0; classData->DataInReady = 0; diff --git a/src/firmware/usb_device/usbd_msc_storage_sd.c b/src/firmware/usb_device/usbd_msc_storage_sd.c index afa86e67..132d7a56 100755 --- a/src/firmware/usb_device/usbd_msc_storage_sd.c +++ b/src/firmware/usb_device/usbd_msc_storage_sd.c @@ -151,7 +151,7 @@ int8_t s2s_usbd_storage_Read (uint8_t lun, { BSP_SD_ReadBlocks_DMA( buf, - (cfg->sdSectorStart + blk_addr) * 512ll, + cfg->sdSectorStart + blk_addr, blk_len); } else @@ -166,7 +166,7 @@ int8_t s2s_usbd_storage_Read (uint8_t lun, uint8_t partial[512] S2S_DMA_ALIGN; BSP_SD_ReadBlocks_DMA( partial, - sdSectorNum * 512LL, + sdSectorNum, 1); sdSectorNum++; @@ -197,7 +197,7 @@ int8_t s2s_usbd_storage_Write (uint8_t lun, { BSP_SD_WriteBlocks_DMA( buf, - (cfg->sdSectorStart + blk_addr) * 512ll, + cfg->sdSectorStart + blk_addr, blk_len); } else @@ -214,7 +214,7 @@ int8_t s2s_usbd_storage_Write (uint8_t lun, BSP_SD_WriteBlocks_DMA( partial, - sdSectorNum * 512LL, + sdSectorNum, 1); sdSectorNum++; -- 2.38.5