mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-15 20:35:33 +03:00
Refactor USB toward generic target
- Move conditionals from pg/usb.c to common_defaults_post.h - Add detectPin to usbDev_s. - Bump PG version for usbDev_s. - Add resource manipulation for USB_DETECT.
This commit is contained in:
parent
27cbf0515d
commit
a2f39c8844
5 changed files with 24 additions and 17 deletions
|
@ -30,9 +30,8 @@
|
||||||
#include "usb_io.h"
|
#include "usb_io.h"
|
||||||
#include "sdcard.h"
|
#include "sdcard.h"
|
||||||
|
|
||||||
|
|
||||||
#ifdef USE_USB_DETECT
|
#ifdef USE_USB_DETECT
|
||||||
static IO_t usbDetectPin = IO_NONE;
|
static IO_t usbDetectPin;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void usbCableDetectDeinit(void)
|
void usbCableDetectDeinit(void)
|
||||||
|
@ -47,9 +46,6 @@ void usbCableDetectDeinit(void)
|
||||||
void usbCableDetectInit(void)
|
void usbCableDetectInit(void)
|
||||||
{
|
{
|
||||||
#ifdef USE_USB_DETECT
|
#ifdef USE_USB_DETECT
|
||||||
#ifndef USB_DETECT_PIN
|
|
||||||
#define USB_DETECT_PIN NONE
|
|
||||||
#endif
|
|
||||||
usbDetectPin = IOGetByTag(IO_TAG(USB_DETECT_PIN));
|
usbDetectPin = IOGetByTag(IO_TAG(USB_DETECT_PIN));
|
||||||
|
|
||||||
IOInit(usbDetectPin, OWNER_USB_DETECT, 0);
|
IOInit(usbDetectPin, OWNER_USB_DETECT, 0);
|
||||||
|
|
|
@ -3825,6 +3825,9 @@ const cliResourceValue_t resourceTable[] = {
|
||||||
DEFS( OWNER_RX_SPI_CS, PG_RX_SPI_CONFIG, rxSpiConfig_t, csnTag ),
|
DEFS( OWNER_RX_SPI_CS, PG_RX_SPI_CONFIG, rxSpiConfig_t, csnTag ),
|
||||||
#endif
|
#endif
|
||||||
DEFW( OWNER_GYRO_CS, PG_GYRO_DEVICE_CONFIG, gyroDeviceConfig_t, csnTag, 2 ),
|
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
|
#undef DEFS
|
||||||
|
|
|
@ -20,28 +20,20 @@
|
||||||
|
|
||||||
#include "platform.h"
|
#include "platform.h"
|
||||||
|
|
||||||
#if defined(USE_USB_ADVANCED_PROFILES)
|
#ifdef USE_VCP
|
||||||
|
|
||||||
#include "drivers/io.h"
|
#include "drivers/io.h"
|
||||||
|
|
||||||
#include "pg/pg_ids.h"
|
#include "pg/pg_ids.h"
|
||||||
|
|
||||||
#include "usb.h"
|
#include "usb.h"
|
||||||
|
|
||||||
#if !defined(USB_MSC_BUTTON_PIN)
|
PG_REGISTER_WITH_RESET_TEMPLATE(usbDev_t, usbDevConfig, PG_USB_CONFIG, 1);
|
||||||
#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,
|
PG_RESET_TEMPLATE(usbDev_t, usbDevConfig,
|
||||||
.type = DEFAULT,
|
.type = DEFAULT,
|
||||||
.mscButtonPin = IO_TAG(USB_MSC_BUTTON_PIN),
|
.mscButtonPin = IO_TAG(USB_MSC_BUTTON_PIN),
|
||||||
.mscButtonUsePullup = MSC_BUTTON_IPU,
|
.mscButtonUsePullup = MSC_BUTTON_IPU,
|
||||||
|
.detectPin = IO_TAG(USB_DETECT_PIN),
|
||||||
);
|
);
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,6 +33,7 @@ typedef struct usbDev_s {
|
||||||
uint8_t type;
|
uint8_t type;
|
||||||
ioTag_t mscButtonPin;
|
ioTag_t mscButtonPin;
|
||||||
uint8_t mscButtonUsePullup;
|
uint8_t mscButtonUsePullup;
|
||||||
|
ioTag_t detectPin;
|
||||||
} usbDev_t;
|
} usbDev_t;
|
||||||
|
|
||||||
PG_DECLARE(usbDev_t, usbDevConfig);
|
PG_DECLARE(usbDev_t, usbDevConfig);
|
||||||
|
|
|
@ -257,3 +257,18 @@
|
||||||
#else
|
#else
|
||||||
#define MAX_GYRODEV_COUNT 1
|
#define MAX_GYRODEV_COUNT 1
|
||||||
#endif
|
#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(USE_USB_MSC_BUTTON_IPU) && !defined(MSC_BUTTON_IPU)
|
||||||
|
#define MSC_BUTTON_IPU true
|
||||||
|
#else
|
||||||
|
#define MSC_BUTTON_IPU false
|
||||||
|
#endif
|
||||||
|
#endif
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue