mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-14 20:10:18 +03:00
Merge pull request #6788 from jflyper/bfdev-usb-refactor-for-generic-target
Refactor USB toward generic target
This commit is contained in:
commit
adddd0976c
5 changed files with 20 additions and 16 deletions
|
@ -30,9 +30,8 @@
|
|||
#include "usb_io.h"
|
||||
#include "sdcard.h"
|
||||
|
||||
|
||||
#ifdef USE_USB_DETECT
|
||||
static IO_t usbDetectPin = IO_NONE;
|
||||
static IO_t usbDetectPin;
|
||||
#endif
|
||||
|
||||
void usbCableDetectDeinit(void)
|
||||
|
@ -47,9 +46,6 @@ void usbCableDetectDeinit(void)
|
|||
void usbCableDetectInit(void)
|
||||
{
|
||||
#ifdef USE_USB_DETECT
|
||||
#ifndef USB_DETECT_PIN
|
||||
#define USB_DETECT_PIN NONE
|
||||
#endif
|
||||
usbDetectPin = IOGetByTag(IO_TAG(USB_DETECT_PIN));
|
||||
|
||||
IOInit(usbDetectPin, OWNER_USB_DETECT, 0);
|
||||
|
|
|
@ -3840,6 +3840,9 @@ const cliResourceValue_t resourceTable[] = {
|
|||
DEFS( OWNER_RX_SPI_CS, PG_RX_SPI_CONFIG, rxSpiConfig_t, csnTag ),
|
||||
#endif
|
||||
DEFW( OWNER_GYRO_CS, PG_GYRO_DEVICE_CONFIG, gyroDeviceConfig_t, csnTag, 2 ),
|
||||
#ifdef USE_USB_DETECT
|
||||
DEFS( OWNER_USB_DETECT, PG_USB_CONFIG, usbDev_t, detectPin ),
|
||||
#endif
|
||||
};
|
||||
|
||||
#undef DEFS
|
||||
|
|
|
@ -20,28 +20,20 @@
|
|||
|
||||
#include "platform.h"
|
||||
|
||||
#if defined(USE_USB_ADVANCED_PROFILES)
|
||||
#ifdef USE_VCP
|
||||
|
||||
#include "drivers/io.h"
|
||||
|
||||
#include "pg/pg_ids.h"
|
||||
|
||||
#include "usb.h"
|
||||
|
||||
#if !defined(USB_MSC_BUTTON_PIN)
|
||||
#define USB_MSC_BUTTON_PIN NONE
|
||||
#endif
|
||||
|
||||
#if defined(USE_USB_MSC_BUTTON_IPU)
|
||||
#define MSC_BUTTON_IPU true
|
||||
#else
|
||||
#define MSC_BUTTON_IPU false
|
||||
#endif
|
||||
|
||||
PG_REGISTER_WITH_RESET_TEMPLATE(usbDev_t, usbDevConfig, PG_USB_CONFIG, 0);
|
||||
|
||||
PG_RESET_TEMPLATE(usbDev_t, usbDevConfig,
|
||||
.type = DEFAULT,
|
||||
.mscButtonPin = IO_TAG(USB_MSC_BUTTON_PIN),
|
||||
.mscButtonUsePullup = MSC_BUTTON_IPU,
|
||||
.detectPin = IO_TAG(USB_DETECT_PIN),
|
||||
);
|
||||
#endif
|
||||
|
|
|
@ -33,6 +33,7 @@ typedef struct usbDev_s {
|
|||
uint8_t type;
|
||||
ioTag_t mscButtonPin;
|
||||
uint8_t mscButtonUsePullup;
|
||||
ioTag_t detectPin;
|
||||
} usbDev_t;
|
||||
|
||||
PG_DECLARE(usbDev_t, usbDevConfig);
|
||||
|
|
|
@ -257,3 +257,15 @@
|
|||
#else
|
||||
#define MAX_GYRODEV_COUNT 1
|
||||
#endif
|
||||
|
||||
#ifdef USE_VCP
|
||||
#ifndef USB_DETECT_PIN
|
||||
#define USB_DETECT_PIN NONE
|
||||
#endif
|
||||
#ifndef USB_MSC_BUTTON_PIN
|
||||
#define USB_MSC_BUTTON_PIN NONE
|
||||
#endif
|
||||
#if !defined(MSC_BUTTON_IPU)
|
||||
#define MSC_BUTTON_IPU true
|
||||
#endif
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue