* USB Joystick implemented
* USB Mass storage mode removed from openTX (this is now supported by Bootloader)
This commit is contained in:
@@ -38,9 +38,20 @@
|
||||
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_dcd_int.h"
|
||||
#include "STM32_USB-Host-Device_Lib_V2.1.0/Libraries/STM32_USB_OTG_Driver/inc/usb_bsp.h"
|
||||
|
||||
int usbPlugged(void)
|
||||
uint8_t usbPlugged(void)
|
||||
{
|
||||
return GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS);
|
||||
//debounce
|
||||
static uint8_t debounced_state = 0;
|
||||
static uint8_t last_state = 0;
|
||||
if ( GPIO_ReadInputDataBit(GPIOA, PIN_FS_VBUS) ) {
|
||||
if (last_state) debounced_state = 1;
|
||||
last_state = 1;
|
||||
}
|
||||
else {
|
||||
if (!last_state) debounced_state = 0;
|
||||
last_state = 0;
|
||||
}
|
||||
return debounced_state;
|
||||
}
|
||||
|
||||
USB_OTG_CORE_HANDLE USB_OTG_dev;
|
||||
@@ -50,12 +61,24 @@ void OTG_FS_IRQHandler(void)
|
||||
USBD_OTG_ISR_Handler (&USB_OTG_dev);
|
||||
}
|
||||
|
||||
void usbInit()
|
||||
void usbInit(void)
|
||||
{
|
||||
USB_OTG_BSP_Init(&USB_OTG_dev);
|
||||
}
|
||||
|
||||
void usbStart()
|
||||
void usbStart(void)
|
||||
{
|
||||
#if !defined(BOOT)
|
||||
//intialize USB as HID device
|
||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_cb, &USR_cb);
|
||||
#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)
|
||||
}
|
||||
|
||||
|
||||
void usbStop(void)
|
||||
{
|
||||
USBD_DeInit(&USB_OTG_dev);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user