mirror of
https://github.com/opentx/opentx.git
synced 2025-07-24 00:35:18 +03:00
Projectkk2glider/usb hardening (#4125)
* USB fixes: * USB initialized when USB cable is inserted and de-initialized when disconnected (this was the original way, which proved itself unreliable in the past. Now with the new USB library it appears to work without any problems. Used in this way result in safer operation - USB controller is disabled while unconnected) Works without force device mod * Serial: initialization of global variables * Reduced RAM usage - data moved to FLASH * Detailed USB interrupt counters (+ debug print fix)
This commit is contained in:
parent
c3238ee38c
commit
29c43d9e33
16 changed files with 157 additions and 69 deletions
|
@ -31,22 +31,7 @@ void handleUsbConnection()
|
|||
|
||||
if (!usbStarted && usbPlugged()) {
|
||||
usbStarted = true;
|
||||
|
||||
/*
|
||||
We used to initialize USB peripheral and driver here.
|
||||
According to my tests this is way too late. The USB peripheral
|
||||
therefore does not have enough information to start responding to
|
||||
USB host request, which causes very slow USB device recognition,
|
||||
multiple USB device resets, etc...
|
||||
|
||||
If we want to change the USB profile, the procedure is simple:
|
||||
* USB cable must be disconnected
|
||||
* call usbDeInit();
|
||||
* call usbUnit(); which initializes USB with the new profile.
|
||||
Obviously the usbInit() should be modified to have a runtime
|
||||
selection of the USB profile.
|
||||
*/
|
||||
|
||||
usbInit();
|
||||
#if defined(USB_MASS_STORAGE)
|
||||
opentxClose(false);
|
||||
usbPluggedIn();
|
||||
|
@ -54,6 +39,7 @@ void handleUsbConnection()
|
|||
}
|
||||
if (usbStarted && !usbPlugged()) {
|
||||
usbStarted = false;
|
||||
usbDeInit();
|
||||
#if defined(USB_MASS_STORAGE) && !defined(EEPROM)
|
||||
opentxResume();
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue