mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-16 12:55:19 +03:00
Add Composite CDC+HID device option. (#5478)
* Add Composite CDC+HID device option. - It passes on though HID interface 8 channels received from TX - Endpoints are reconfigured to support HID interface - Potentially this can slow down SPI Flash transfer though CDC interface... - This could be addressed by support for MSC when using SPI Flash (emulating FATFS) * Different way to handle MIN redefine
This commit is contained in:
parent
b2e807be6c
commit
4786e1a333
11 changed files with 1209 additions and 7 deletions
|
@ -30,6 +30,9 @@
|
|||
#if defined(STM32F4)
|
||||
#include "usb_core.h"
|
||||
#include "usbd_cdc_vcp.h"
|
||||
#ifdef USB_CDC_HID
|
||||
#include "usbd_hid_cdc_wrapper.h"
|
||||
#endif
|
||||
#include "usb_io.h"
|
||||
#elif defined(STM32F7)
|
||||
#include "vcp_hal/usbd_cdc_interface.h"
|
||||
|
@ -211,7 +214,11 @@ serialPort_t *usbVcpOpen(void)
|
|||
|
||||
IOInit(IOGetByTag(IO_TAG(PA11)), OWNER_USB, 0);
|
||||
IOInit(IOGetByTag(IO_TAG(PA12)), OWNER_USB, 0);
|
||||
#ifdef USB_CDC_HID
|
||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_HID_CDC_cb, &USR_cb);
|
||||
#else
|
||||
USBD_Init(&USB_OTG_dev, USB_OTG_FS_CORE_ID, &USR_desc, &USBD_CDC_cb, &USR_cb);
|
||||
#endif
|
||||
#elif defined(STM32F7)
|
||||
usbGenerateDisconnectPulse();
|
||||
|
||||
|
|
|
@ -85,6 +85,12 @@
|
|||
|
||||
#include "telemetry/telemetry.h"
|
||||
|
||||
#ifdef USB_CDC_HID
|
||||
//TODO: Make it platform independent in the future
|
||||
#include "vcpf4/usbd_cdc_vcp.h"
|
||||
#include "usbd_hid_core.h"
|
||||
#endif
|
||||
|
||||
#ifdef USE_BST
|
||||
void taskBstMasterProcess(timeUs_t currentTimeUs);
|
||||
#endif
|
||||
|
@ -139,6 +145,16 @@ static void taskUpdateRxMain(timeUs_t currentTimeUs)
|
|||
|
||||
isRXDataNew = true;
|
||||
|
||||
#ifdef USB_CDC_HID
|
||||
if (!ARMING_FLAG(ARMED)) {
|
||||
int8_t report[8];
|
||||
for (int i = 0; i < 8; i++) {
|
||||
report[i] = scaleRange(constrain(rcData[i], 1000, 2000), 1000, 2000, -127, 127);
|
||||
}
|
||||
USBD_HID_SendReport(&USB_OTG_dev, (uint8_t*)report, sizeof(report));
|
||||
}
|
||||
#endif
|
||||
|
||||
#if !defined(USE_ALT_HOLD)
|
||||
// updateRcCommands sets rcCommand, which is needed by updateAltHoldState and updateSonarAltHoldState
|
||||
updateRcCommands();
|
||||
|
|
|
@ -51,6 +51,7 @@
|
|||
#define USE_GYRO_DATA_ANALYSE
|
||||
#define USE_ADC
|
||||
#define USE_ADC_INTERNAL
|
||||
#define USB_CDC_HID
|
||||
|
||||
#if defined(STM32F40_41xxx) || defined(STM32F411xE)
|
||||
#define USE_OVERCLOCK
|
||||
|
|
|
@ -161,12 +161,10 @@
|
|||
/****************** USB OTG FS CONFIGURATION **********************************/
|
||||
#ifdef USB_OTG_FS_CORE
|
||||
#define RX_FIFO_FS_SIZE 128
|
||||
#define TX0_FIFO_FS_SIZE 64
|
||||
#define TX1_FIFO_FS_SIZE 128
|
||||
#define TX0_FIFO_FS_SIZE 32
|
||||
#define TX1_FIFO_FS_SIZE 64
|
||||
#define TX2_FIFO_FS_SIZE 0
|
||||
#define TX3_FIFO_FS_SIZE 0
|
||||
#define TXH_NP_FS_FIFOSIZ 96
|
||||
#define TXH_P_FS_FIFOSIZ 96
|
||||
#define TX3_FIFO_FS_SIZE 64
|
||||
|
||||
//#define USB_OTG_FS_LOW_PWR_MGMT_SUPPORT
|
||||
//#define USB_OTG_FS_SOF_OUTPUT_ENABLED
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
*/
|
||||
#define USBD_CFG_MAX_NUM 1
|
||||
#define USBD_ITF_MAX_NUM 1
|
||||
#define USB_MAX_STR_DESC_SIZ 50
|
||||
#define USB_MAX_STR_DESC_SIZ 255
|
||||
|
||||
/** @defgroup USB_VCP_Class_Layer_Parameter
|
||||
* @{
|
||||
|
@ -40,6 +40,9 @@
|
|||
#define CDC_OUT_EP 0x01 /* EP1 for data OUT */
|
||||
#define CDC_CMD_EP 0x82 /* EP2 for CDC commands */
|
||||
|
||||
#define HID_IN_EP 0x83
|
||||
#define HID_IN_PACKET 8
|
||||
|
||||
/* CDC Endpoints parameters: you can fine tune these values depending on the needed baudrates and performance. */
|
||||
#ifdef USE_USB_OTG_HS
|
||||
#define CDC_DATA_MAX_PACKET_SIZE 512 /* Endpoint IN & OUT Packet size */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue