Skip to content

Commit

Permalink
Tweaks & fixups
Browse files Browse the repository at this point in the history
  • Loading branch information
thinkyhead committed Dec 28, 2020
1 parent 72ba757 commit 4ac8cdd
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 46 deletions.
16 changes: 8 additions & 8 deletions Marlin/src/HAL/STM32/usb_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,14 @@ BulkStorage bulk(&usb);
static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id) {
switch(id) {
case HOST_USER_SELECT_CONFIGURATION:
//SERIAL_ECHOLN("APPLICATION_SELECT_CONFIGURATION");
//SERIAL_ECHOLNPGM("APPLICATION_SELECT_CONFIGURATION");
break;
case HOST_USER_DISCONNECTION:
// SERIAL_ECHOLN("APPLICATION_DISCONNECT");
// usb.setUsbTaskState(USB_STATE_RUNNING);
//SERIAL_ECHOLNPGM("APPLICATION_DISCONNECT");
//usb.setUsbTaskState(USB_STATE_RUNNING);
break;
case HOST_USER_CLASS_ACTIVE:
// SERIAL_ECHOLN("APPLICATION_READY");
//SERIAL_ECHOLNPGM("APPLICATION_READY");
usb.setUsbTaskState(USB_STATE_RUNNING);
break;
case HOST_USER_CONNECTION:
Expand All @@ -57,15 +57,15 @@ static void USBH_UserProcess(USBH_HandleTypeDef *phost, uint8_t id) {

bool USBHost::start() {
if (USBH_Init(&hUsbHost, USBH_UserProcess, TERN(USE_USB_HS_IN_FS, HOST_HS, HOST_FS)) != USBH_OK) {
SERIAL_ECHOLN("Error: USBH_Init");
SERIAL_ECHOLNPGM("Error: USBH_Init");
return false;
}
if (USBH_RegisterClass(&hUsbHost, USBH_MSC_CLASS) != USBH_OK) {
SERIAL_ECHOLN("Error: USBH_RegisterClass");
SERIAL_ECHOLNPGM("Error: USBH_RegisterClass");
return false;
}
if (USBH_Start(&hUsbHost) != USBH_OK) {
SERIAL_ECHOLN("Error: USBH_Start");
SERIAL_ECHOLNPGM("Error: USBH_Start");
return false;
}
return true;
Expand Down Expand Up @@ -113,5 +113,5 @@ uint8_t BulkStorage::Write(uint8_t lun, uint32_t addr, uint16_t bsize, uint8_t b
return USBH_MSC_Write(&hUsbHost, lun, addr, const_cast <uint8_t*>(buf), blocks) != USBH_OK;
}

#endif // BOTH(USE_OTG_USB_HOST, USBHOST)
#endif // USE_OTG_USB_HOST && USBHOST
#endif // ARDUINO_ARCH_STM32 && !STM32GENERIC
5 changes: 2 additions & 3 deletions Marlin/src/sd/usb_flashdrive/Sd2Card_FlashDrive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@
#include "../../core/serial.h"
#include "../../module/temperature.h"

#if DISABLED(USE_OTG_USB_HOST)
static_assert(USB_CS_PIN != -1, "USB_CS_PIN must be defined");
static_assert(USB_INTR_PIN != -1, "USB_INTR_PIN must be defined");
#if DISABLED(USE_OTG_USB_HOST) && !PINS_EXIST(USB_CS, USB_INTR)
#error "USB_FLASH_DRIVE_SUPPORT requires USB_CS_PIN and USB_INTR_PIN to be defined."
#endif

#if ENABLED(USE_UHS3_USB)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#undef HAL_IRDA_MODULE_ENABLED
#undef HAL_SMARTCARD_MODULE_ENABLED
#undef HAL_WWDG_MODULE_ENABLED
// #undef HAL_HCD_MODULE_ENABLED
//#undef HAL_HCD_MODULE_ENABLED
#undef HAL_FMPI2C_MODULE_ENABLED
#undef HAL_SPDIFRX_MODULE_ENABLED
#undef HAL_DFSDM_MODULE_ENABLED
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#undef HAL_IRDA_MODULE_ENABLED
#undef HAL_SMARTCARD_MODULE_ENABLED
#undef HAL_WWDG_MODULE_ENABLED
// #undef HAL_HCD_MODULE_ENABLED
//#undef HAL_HCD_MODULE_ENABLED
#undef HAL_FMPI2C_MODULE_ENABLED
#undef HAL_SPDIFRX_MODULE_ENABLED
#undef HAL_DFSDM_MODULE_ENABLED
Expand Down
51 changes: 18 additions & 33 deletions platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1277,19 +1277,19 @@ extra_scripts = ${common.extra_scripts}
debug_tool = stlink
debug_init_break =

[stm32_flash_drive]
platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip
build_flags = ${common_stm32.build_flags}
-DHAL_PCD_MODULE_ENABLED -DHAL_HCD_MODULE_ENABLED
-DUSBHOST -DUSBH_IRQ_PRIO=3 -DUSBH_IRQ_SUBPRIO=4

#
# BigTreeTech SKR Pro (STM32F407ZGT6 ARM Cortex-M4) with USB Flash Drive Support
#
[env:BIGTREE_SKR_PRO_usb_flash_drive]
extends = env:BIGTREE_SKR_PRO
platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip
build_flags = ${common_stm32.build_flags}
-DHAL_PCD_MODULE_ENABLED
-DUSBHOST
-DHAL_HCD_MODULE_ENABLED
-DUSBH_IRQ_PRIO=3
-DUSBH_IRQ_SUBPRIO=4

extends = env:BIGTREE_SKR_PRO
platform_packages = ${stm32_flash_drive.platform_packages}
build_flags = ${stm32_flash_drive.build_flags}

#
# Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4)
Expand All @@ -1307,14 +1307,9 @@ build_flags = ${common_stm32.build_flags}
# Bigtreetech GTR V1.0 (STM32F407IGT6 ARM Cortex-M4) with USB Flash Drive Support
#
[env:BIGTREE_GTR_V1_0_usb_flash_drive]
extends = env:BIGTREE_GTR_V1_0
platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip
build_flags = ${common_stm32.build_flags}
-DHAL_PCD_MODULE_ENABLED
-DUSBHOST
-DHAL_HCD_MODULE_ENABLED
-DUSBH_IRQ_PRIO=3
-DUSBH_IRQ_SUBPRIO=4
extends = env:BIGTREE_GTR_V1_0
platform_packages = ${stm32_flash_drive.platform_packages}
build_flags = ${stm32_flash_drive.build_flags}

#
# BigTreeTech BTT002 V1.0 (STM32F407VGT6 ARM Cortex-M4)
Expand Down Expand Up @@ -1418,22 +1413,17 @@ extra_scripts = ${common.extra_scripts}
#
[env:mks_robin_pro2]
platform = ${common_stm32.platform}
platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip
platform_packages = ${stm32_flash_drive.platform_packages}
extends = common_stm32
build_flags = ${common_stm32.build_flags}
-DHAL_PCD_MODULE_ENABLED
-DUSBHOST
-DHAL_HCD_MODULE_ENABLED
-DUSBH_IRQ_PRIO=3
-DUSBH_IRQ_SUBPRIO=4
build_flags = ${stm32_flash_drive.build_flags}
board = genericSTM32F407VET6
board_build.core = stm32
board_build.variant = MARLIN_F4x7Vx
board_build.ldscript = ldscript.ld
board_build.firmware = firmware.bin
board_build.offset = 0x0000
board_upload.offset_address = 0x08000000
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
build_unflags = ${common_stm32.build_unflags} -DUSBCON -DUSBD_USE_CDC
debug_tool = jlink
upload_protocol = jlink
extra_scripts = ${common.extra_scripts}
Expand Down Expand Up @@ -1466,16 +1456,11 @@ extra_scripts = ${common.extra_scripts}
# Currently, using a STM32duino fork, until USB Host get merged
#
[env:mks_robin_nano_v3_usb_flash_drive]
extends = env:mks_robin_nano_v3
platform_packages = framework-arduinoststm32@https://github.com/rhapsodyv/Arduino_Core_STM32/archive/usb-host-msc.zip
build_flags = ${common_stm32.build_flags}
-DHAL_PCD_MODULE_ENABLED
extends = env:mks_robin_nano_v3
platform_packages = ${stm32_flash_drive.platform_packages}
build_flags = ${stm32_flash_drive.build_flags}
-DUSBCON
-DUSBHOST
-DHAL_HCD_MODULE_ENABLED
-DUSE_USBHOST_HS
-DUSBH_IRQ_PRIO=3
-DUSBH_IRQ_SUBPRIO=4
-DUSBD_IRQ_PRIO=5
-DUSBD_IRQ_SUBPRIO=6
-DUSE_USB_HS_IN_FS
Expand Down

0 comments on commit 4ac8cdd

Please sign in to comment.