mirror of
https://github.com/opentx/opentx.git
synced 2025-07-25 17:25:13 +03:00
Re #4125: New functions usbStart() and usbStop() to make USB code cleaner
This commit is contained in:
parent
aecf53b3e1
commit
a4d899844e
7 changed files with 16 additions and 10 deletions
|
@ -31,7 +31,7 @@ void handleUsbConnection()
|
|||
|
||||
if (!usbStarted && usbPlugged()) {
|
||||
usbStarted = true;
|
||||
usbInit();
|
||||
usbStart();
|
||||
#if defined(USB_MASS_STORAGE)
|
||||
opentxClose(false);
|
||||
usbPluggedIn();
|
||||
|
@ -39,7 +39,7 @@ void handleUsbConnection()
|
|||
}
|
||||
if (usbStarted && !usbPlugged()) {
|
||||
usbStarted = false;
|
||||
usbDeInit();
|
||||
usbStop();
|
||||
#if defined(USB_MASS_STORAGE) && !defined(EEPROM)
|
||||
opentxResume();
|
||||
#endif
|
||||
|
|
|
@ -20,6 +20,7 @@
|
|||
|
||||
#include "board.h"
|
||||
#include "usb_dcd_int.h"
|
||||
#include "usb_bsp.h"
|
||||
#include "debug.h"
|
||||
|
||||
int usbPlugged(void)
|
||||
|
@ -52,6 +53,12 @@ void OTG_FS_IRQHandler(void)
|
|||
}
|
||||
|
||||
void usbInit(void)
|
||||
{
|
||||
// Initialize hardware
|
||||
USB_OTG_BSP_Init(&USB_OTG_dev);
|
||||
}
|
||||
|
||||
void usbStart(void)
|
||||
{
|
||||
#if defined(USB_JOYSTICK)
|
||||
// initialize USB as HID device
|
||||
|
@ -65,7 +72,7 @@ void usbInit(void)
|
|||
#endif
|
||||
}
|
||||
|
||||
void usbDeInit(void)
|
||||
void usbStop(void)
|
||||
{
|
||||
USBD_DeInit(&USB_OTG_dev);
|
||||
}
|
||||
|
|
|
@ -175,7 +175,6 @@ void boardInit()
|
|||
init2MhzTimer();
|
||||
init1msTimer();
|
||||
usbInit();
|
||||
usbDeInit();
|
||||
hapticInit();
|
||||
bluetoothInit(BLUETOOTH_FACTORY_BAUDRATE);
|
||||
gpsInit(GPS_USART_BAUDRATE);
|
||||
|
|
|
@ -376,7 +376,8 @@ void backlightEnable(uint8_t dutyCycle);
|
|||
// USB driver
|
||||
int usbPlugged(void);
|
||||
void usbInit(void);
|
||||
void usbDeInit(void);
|
||||
void usbStart(void);
|
||||
void usbStop(void);
|
||||
void usbSerialPutc(uint8_t c);
|
||||
#define USB_NAME "FrSky Horus"
|
||||
#define USB_MANUFACTURER 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ' /* 8 bytes */
|
||||
|
|
|
@ -138,7 +138,6 @@ void boardInit()
|
|||
__enable_irq();
|
||||
i2cInit();
|
||||
usbInit();
|
||||
usbDeInit();
|
||||
|
||||
#if defined(DEBUG) && !defined(PCBX7D)
|
||||
serial2Init(0, 0); // default serial mode (None if DEBUG not defined)
|
||||
|
|
|
@ -426,7 +426,8 @@ uint8_t isBacklightEnabled(void);
|
|||
// USB driver
|
||||
int usbPlugged(void);
|
||||
void usbInit(void);
|
||||
void usbDeInit(void);
|
||||
void usbStart(void);
|
||||
void usbStop(void);
|
||||
void usbSerialPutc(uint8_t c);
|
||||
#define USB_NAME "FrSky Taranis"
|
||||
#define USB_MANUFACTURER 'F', 'r', 'S', 'k', 'y', ' ', ' ', ' ' /* 8 bytes */
|
||||
|
|
|
@ -361,7 +361,6 @@ int main()
|
|||
// SD card detect pin
|
||||
sdInit();
|
||||
usbInit();
|
||||
usbDeInit();
|
||||
#endif
|
||||
|
||||
for (;;) {
|
||||
|
@ -384,7 +383,7 @@ int main()
|
|||
unlocked = 1;
|
||||
unlockFlash();
|
||||
}
|
||||
usbInit();
|
||||
usbStart();
|
||||
usbPluggedIn();
|
||||
}
|
||||
}
|
||||
|
@ -419,7 +418,7 @@ int main()
|
|||
lcdDrawTextAlignedLeft(4*FH, STR_USB_CONNECTED);
|
||||
if (usbPlugged() == 0) {
|
||||
vpos = 0;
|
||||
usbDeInit();
|
||||
usbStop();
|
||||
if (unlocked) {
|
||||
lockFlash();
|
||||
unlocked = 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue