-
Notifications
You must be signed in to change notification settings - Fork 511
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Composite USB device driver implementation for STM32F2 (Photon/Electron/P1) #902
Composite USB device driver implementation for STM32F2 (Photon/Electron/P1) #902
Conversation
…. Remote wakeup feature disabled. Debug messages removed
Nice to see things coming together 👍 Just a question of ignorance ;-) But more importantly for me: Will a composite CRC + Mouse + Keyboard be possible with this too?
|
@ScruffR I'm sure there could be numerous applications for a second USB serial. One of the use cases envisioned is providing easy access to possibly verbose debug logs without interfering with application utilizing As for Mouse/Keyboard, the linked example showcases exactly that. The device will run 3 USB classes in total: 2 instances of CDC (Serial) and one instance of HID (implementing both Mouse and Keyboard). |
Thanks for the clarification 👍 So I was just taking the "or" as "mutually exclusive or" rather than "and/or" - good to know. Any idea in what version we might see this public? |
…S mode. Switch back to FS core on Electron, add workarounds
In order not to break compatibility with tools that work with USB serial, the default behavior has been changed. The device will enable only Since the bootloader has been removed from system-part2 on Electron (404ceb8), this PR now doesn't overflow system-part2. Another caveat on Electron and P1: Electron and P1 use PA11 and PA12 for USB which are connected to USB FS core, unlike Photon, which uses PB14 and PB15 which are connected to USB HS core used in FS mode. Using USB HS core allows to use up to 5 bidirectional endpoints (5 in and 5 out), however USB FS core allows only 3 (3 in and 3 out) which puts a bit of a limitation and allows only either |
- Support for DTR/RTS - Electron 2x CDC + HID support on Win/Mac/Linux
be8a176
to
4ed891c
Compare
4ed891c
to
fdcdba8
Compare
…rings for Serial and USBSerial1
…erial buffer allocation
…without the need to perform a reattach
This should be ready for a review, but I would like to get #959 merged into develop first to safely enable USB drivers logging. Considerations for testing:
|
…Data, commented out DEBUG in usbd_composite.c
…ing with HAL_USB_Attach/Detach
907695b
to
8ff4970
Compare
@@ -46,7 +46,7 @@ class USBSerial : public Stream | |||
bool isEnabled(); | |||
bool isConnected(); | |||
|
|||
void begin(long speed); | |||
void begin(long speed = 9600); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the rationale is that the baudrate doesn't actually affect the transfer, and is only "virtual" in the linerate descriptor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is correct.
…osite Conflicts: hal/inc/hal_dynalib_usart.h wiring/inc/debug_output_handler.h
I seem to be unable to get Keyboard/Mouse to work on my Electron char str[64];
void setup()
{
Particle.function("type", kbdType);
Particle.function("move", mouseMove);
Serial.begin(115200);
//Serial.end();
Keyboard.begin();
Mouse.begin();
}
void loop()
{
static uint32_t ms;
if (strlen(str) && millis() - ms > 1000)
{
ms = millis();
Keyboard.print(str);
}
}
int kbdType(String cmd)
{
strcpy(str, cmd);
Serial.println(str);
return cmd.length();
}
int mouseMove(String cmd)
{
int x = 0;
int y = 0;
int b = 0;
sscanf(cmd, "%d,%d,%d", &x, &y, &b);
Serial.printlnf("%s: %4d / %4d (%d)", (const char*)cmd, x, y, b);
Mouse.move(x, y, b);
return cmd.length();
} This is the status of my device
|
It would also be nice if there was an absolute |
By default Photon/Electron and P1 now present themselves as a composite USB device with two USB Serials,
Serial
being the first and a newUSBSerial1
being the second one. This should work out of the box on Linux and Mac, Windows users will have to reinstall serial drivers. (This PR includes UNSIGNED drivers inmisc/driver/windows
, see 9b62479).This PR also implements HID support (closes #528). Calling Mouse.begin() or Keyboard.begin() will register HID class driver in Composite driver and cause the device to perform a reattach. After successfully attaching, the device will present itself as a composite USB device with two USB Serials + HID.
A very simple test app that showcases the new functionality can be found at https://gist.github.com/avtolstoy/996cb3bb174337744094
Doneness: