diff --git a/radio/src/targets/taranis/bootloader/Makefile b/radio/src/targets/taranis/bootloader/Makefile index 7c536c6c5..a31f87ddf 100755 --- a/radio/src/targets/taranis/bootloader/Makefile +++ b/radio/src/targets/taranis/bootloader/Makefile @@ -94,7 +94,7 @@ ifeq ($(PCB), TARANIS) LDSCRIPT = ../stm32_ramboot.ld TRGT = arm-none-eabi- CPPDEFS += -DHSE_VALUE=12000000 - CPPDEFS += -DPCBTARANIS -DEEPROM_RLC + CPPDEFS += -DPCBTARANIS -DEEPROM_RLC -DUSB_MASS_STORAGE FULL_PRJ = $(PROJECT)_ramBoot ifeq ($(PCBREV), REV9E) CPPDEFS += -DSTM32F40_41xxx diff --git a/radio/src/targets/taranis/usb_driver.c b/radio/src/targets/taranis/usb_driver.c index cada14b7b..97963ce06 100644 --- a/radio/src/targets/taranis/usb_driver.c +++ b/radio/src/targets/taranis/usb_driver.c @@ -40,16 +40,20 @@ int usbPlugged(void) { - //debounce + // debounce static uint8_t debounced_state = 0; static uint8_t last_state = 0; - if ( GPIO_ReadInputDataBit(USB_GPIO, USB_GPIO_PIN_VBUS) ) { - if (last_state) debounced_state = 1; + if (GPIO_ReadInputDataBit(USB_GPIO, USB_GPIO_PIN_VBUS)) { + if (last_state) { + debounced_state = 1; + } last_state = 1; } else { - if (!last_state) debounced_state = 0; + if (!last_state) { + debounced_state = 0; + } last_state = 0; } return debounced_state; @@ -69,18 +73,13 @@ void usbInit(void) void usbStart(void) { -#if !defined(BOOT) #if defined(USB_JOYSTICK) - //intialize USB as HID device + // initialize USB as HID device USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_cb, &USR_cb); #elif defined(USB_MASS_STORAGE) - //intialize USB as MSC device + // initialize USB as MSC device USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb); #endif -#else - //intialize USB as MSC device - USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_MSC_cb, &USR_cb); -#endif //!defined(BOOT) } #if defined(USB_JOYSTICK) @@ -89,4 +88,3 @@ void usbStop(void) USBD_DeInit(&USB_OTG_dev); } #endif - diff --git a/radio/src/targets/taranis/usbd_desc.c b/radio/src/targets/taranis/usbd_desc.c index d9e8b353e..f61065a2a 100644 --- a/radio/src/targets/taranis/usbd_desc.c +++ b/radio/src/targets/taranis/usbd_desc.c @@ -68,8 +68,7 @@ #define USBD_PRODUCT_FS_STRING "FrSky Taranis Bootloader" #define USBD_CONFIGURATION_FS_STRING "MSC Config" #define USBD_INTERFACE_FS_STRING "MSC Interface" -#else -#if defined(USB_JOYSTICK) +#elif defined(USB_JOYSTICK) #define USBD_PID 0x5710 #define USBD_PRODUCT_FS_STRING "FrSky Taranis Joystick" #define USBD_CONFIGURATION_FS_STRING "HID Config" @@ -80,7 +79,6 @@ #define USBD_CONFIGURATION_FS_STRING "MSC Config" #define USBD_INTERFACE_FS_STRING "MSC Interface" #endif -#endif const USBD_DEVICE USR_desc = { @@ -95,26 +93,26 @@ const USBD_DEVICE USR_desc = /* USB Standard Device Descriptor */ __ALIGN_BEGIN const uint8_t USBD_DeviceDesc[USB_SIZ_DEVICE_DESC] __ALIGN_END = - { - 0x12, /*bLength */ - USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ - 0x00, /*bcdUSB */ - 0x02, - 0x00, /*bDeviceClass*/ - 0x00, /*bDeviceSubClass*/ - 0x00, /*bDeviceProtocol*/ - USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/ - LOBYTE(USBD_VID), /*idVendor*/ - HIBYTE(USBD_VID), /*idVendor*/ - LOBYTE(USBD_PID), /*idVendor*/ - HIBYTE(USBD_PID), /*idVendor*/ - 0x00, /*bcdDevice rel. 2.00*/ - 0x02, - USBD_IDX_MFC_STR, /*Index of manufacturer string*/ - USBD_IDX_PRODUCT_STR, /*Index of product string*/ - USBD_IDX_SERIAL_STR, /*Index of serial number string*/ - USBD_CFG_MAX_NUM /*bNumConfigurations*/ - } ; /* USB_DeviceDescriptor */ +{ + USB_SIZ_DEVICE_DESC, /*bLength */ + USB_DEVICE_DESCRIPTOR_TYPE, /*bDescriptorType*/ + 0x00, /*bcdUSB */ + 0x02, + 0x00, /*bDeviceClass*/ + 0x00, /*bDeviceSubClass*/ + 0x00, /*bDeviceProtocol*/ + USB_OTG_MAX_EP0_SIZE, /*bMaxPacketSize*/ + LOBYTE(USBD_VID), /*idVendor*/ + HIBYTE(USBD_VID), /*idVendor*/ + LOBYTE(USBD_PID), /*idVendor*/ + HIBYTE(USBD_PID), /*idVendor*/ + 0x00, /*bcdDevice rel. 2.00*/ + 0x02, + USBD_IDX_MFC_STR, /*Index of manufacturer string*/ + USBD_IDX_PRODUCT_STR, /*Index of product string*/ + USBD_IDX_SERIAL_STR, /*Index of serial number string*/ + USBD_CFG_MAX_NUM /*bNumConfigurations*/ +}; /* USB_DeviceDescriptor */ /* USB Standard Device Descriptor */ __ALIGN_BEGIN const uint8_t USBD_DeviceQualifierDesc[USB_LEN_DEV_QUALIFIER_DESC] __ALIGN_END =