Commit Graph

50 Commits

Author SHA1 Message Date
Nico 7f2ca6ee28 Fix CDC Serial buffer size determination 2015-09-20 11:08:49 +02:00
Cristian Maglie 621580d83b Merge branch 'cdc-settings' of https://github.com/matthijskooijman/Arduino 2015-08-14 13:37:00 +02:00
NicoHood 39ed7be747 Precised USB Endpoint definitions 2015-08-12 17:48:17 +02:00
NicoHood d1fe40060e Added 16 byte endpoint support 2015-08-12 17:48:17 +02:00
Peter Van Hoyweghen 3baff3b411 Add Serial_::availableForWrite().
This makes the CDC "Serial" object on the Leonardo and similar boards
support this recently introduced method as well. The CDC code in the sam
core is not changed.
2015-07-31 14:06:20 +02:00
Matthijs Kooijman 31e0c94124 Add Serial_::readBreak() to process SEND_BREAK requests
This allows detecting when the USB host sends a break request and what
the value of the request was. See the comments in USBAPI.h for details.

This just modifies the avr core, not the sam core.
2015-07-31 14:06:19 +02:00
Matthijs Kooijman acb1a47a78 Expose serial settings from CDC virtual serial port
This allows a sketch to find out the settings chosen by the USB host
(computer) and act accordingly.

Other than reading the DTR flag and checking if the baudrate is 1200,
the regular CDC code doesn't actually use any of these settings.

By exposing these settings to the sketch, it can for example copy them
to the hardware UART, turning the Leonardo into a proper USB-to-serial
device. This can be useful to let the computer directly talk to whatever
device is connected to the hardware serial port (like an XBee module).

The Teensy core already supported these methods. This code was
independently developed, but the method names were chosen to match the
Teensy code, for compatibility (except that `dtr()` and `rtr()` return
`bool`, while the Teensy version return a `uint8_t`).

This change is applied to both the avr and sam cores, which have a very
similar CDC implementation.
2015-07-31 13:40:43 +02:00
Martino Facchin 3cf30dff25 rename Setup typedef struct to USBSetup
was really too common
2015-07-16 13:13:52 +02:00
Martino Facchin 3ee0fa1265 Add support for waking up a host via USB HID
this is a rework of commit fbcf94801b8bba7f1c8c79cc7ae402b6b9dbb2d3
2015-07-16 13:13:51 +02:00
Martino Facchin f1973e73cb Move EP defines to header 2015-07-16 13:12:13 +02:00
Martino Facchin ea2a421570 Remove HID core library 2015-07-16 13:12:13 +02:00
Nico 2e90af7ab6 RX and TX Serial buffer sizes can now be defined independently
Fixes #2597
2015-05-12 15:09:48 +02:00
Cristian Maglie b70269a303 Added license to USBAPI.h
Close #1847
2014-09-12 12:27:39 +02:00
Cristian Maglie 55000f4b72 Merge branch 'master' into ide-1.5.x 2014-06-19 17:01:53 +02:00
Cristian Maglie f599d51996 Fixed regression in USBAPI and CDC (xaljox)
See:
9ac7e30252 (commitcomment-6718676)
2014-06-19 16:52:48 +02:00
Cristian Maglie fca64de387 Merge branch 'master' into HEAD 2014-06-13 10:29:12 +02:00
Embedded Micro 12219b37d5 Update USBAPI.h
Fixes bug where Serial.read() would always return 0 as the first byte.
2014-06-10 08:48:23 -07:00
Cristian Maglie 2fd1c5b428 Merge branch 'usbcdc-improved' into ide-1.5.x 2014-05-26 13:38:07 +02:00
Paul Brook 5962f155f7 Improve CDC read code
Read CDC data from USB FIFO on demand instead of in ISR.
Remove superfluous ring buffer.

Signed-off-by: Paul Brook <paul@nowt.org>
2014-05-24 00:34:56 +02:00
Justin Rajewski 872c88bb5f improved USB write speeds 2014-05-24 00:34:56 +02:00
Matthijs Kooijman 99f7ef7c67 Centrally decide which hardware UARTS are available
Before, this decision was made in few different places, based on
sometimes different register defines.

Now, HardwareSerial.h decides wich UARTS are available, defines
USE_HWSERIALn macros and HardwareSerial.cpp simply checks these macros
(together with some #ifs to decide which registers to use for UART 0).
For consistency, USBAPI.h also defines a HAVE_CDCSERIAL macro when
applicable.

For supported targets, this should change any behaviour. For unsupported
targets, the error messages might subtly change because some checks are
moved or changed.

Additionally, this moves the USBAPI.h include form HardareSerial.h into
Arduino.h and raises an error when both CDC serial and UART0 are
available (previously this would silently use UART0 instead of CDC, but
there is not currently any Atmel chip available for which this would
occur).
2014-01-22 09:38:34 +01:00
Cristian Maglie d7ed6ec361 Merge branch 'master' into ide-1.5.x 2013-09-30 16:25:10 +02:00
Paul Brook 0ade989a2d USB CDC two argument begin()
Add two argument form of Serial_::begin

Signed-off-by: Paul Brook <paul@nowt.org>
2013-09-02 19:15:12 +01:00
Paul Brook c2a0030473 USB serial baud arg type
Make USB Serial_::begin() function take an unsigned long argument for
consistency with HardwareSerial.

Signed-off-by: Paul Brook <paul@nowt.org>
2013-09-02 19:02:55 +01:00
Cristian Maglie 4de497b725 Move buffers into USB CDC (look #947 and #1369 for reference) 2013-07-27 12:06:42 +02:00
Cristian Maglie 090d53a74e Fixed compile problem for Leonardo after 0bd6a2d20fb9664255b20e0db11dd4586ebe9007 2013-07-26 12:50:17 +02:00
David A. Mellis 29ff4f779a Adding write(str) and write(buf, size) for USB CDC.
So that they work on the Leonardo.

http://code.google.com/p/arduino/issues/detail?id=958
2012-06-14 15:54:13 +01:00
Zach Eveland efa7593772 Mouse.isPressed() now checks only for left button by default
if no argument is given now checks left button by default to be consistent with press() and release() (thanks, David Mellis)
2012-05-15 15:48:51 -04:00
Zach Eveland 757a77ab67 renamed Leonardo USB_ class to USBDevice_ to be unambiguous. renamed "USB" object to "USBDevice" to prevent conflict with USB Host library (thanks Massimo) 2012-05-01 11:18:15 -04:00
Zach Eveland a984b581a8 added Boolean operators to HardwareSerial and CDC to test whether the port is ready to send data.
Mostly useful for Leonardo - simple way to test whether the port is actually opened by an application and ready to receive data.  For Serial objects attached to real UARTs always returns true.
2012-04-01 12:54:35 -04:00
Zach Eveland 83feb14013 removed horrible multi-key Keyboard.press() and Keyboard.release() methods
Saves 924 bytes of Flash
2012-03-28 18:46:10 -04:00
Zach Eveland d3eabc9c01 eliminated Keyboard.type() - unnecessary duplication of Keyboard.write() (David Mellis). Also edit KeyboardReprogram example which was the only example using type() 2012-03-28 18:35:26 -04:00
Zach Eveland 58c36f76d5 added methods to Keyboard to handle multiple simultaneous key presses or releases (up to six each) 2012-03-26 17:28:02 -04:00
Zach Eveland 9c040a8a2b added stub methods for begin() and end() to Mouse and Keyboard 2012-03-26 16:02:40 -04:00
Zach Eveland 1566006871 Added Keyboard support for all modifier and all common non-printing keys. 2012-03-03 23:37:39 -05:00
Zach Eveland 54fb0bf3f5 Removed support for key mapping in Keyboard.
Was no longer being used and would be damn near impossible to support with the new scheme for handling modifiers and non-printing keyboard characters.
2012-03-03 23:06:44 -05:00
Zach Eveland fbea67532a added Keyboard methods press(), release(), and releaseAll()
Changes mean that a single, persistent key report must be used so keys can be added or removed.  Also reimplemented type() using the new methods.
2012-03-03 22:54:45 -05:00
Zach Eveland 8f5869009c fixed minor compilation warnings for Leonardo 2012-03-03 13:26:57 -05:00
Zach Eveland 4e9fb924b2 changed Keyboard write() method to type(). Made write() an alias for type() to allow subclassing by Stream. 2011-12-20 17:09:44 -05:00
Zach Eveland e405a6eb60 Revert "changed Keyboard write() method to type(). Made write() an alias for type() to allow subclassing by Stream."
This reverts commit de1d5fc0cb82874c0dcb766c5fb27ab36c5cb32c.
2011-12-20 17:08:07 -05:00
Zach Eveland e4930f866d changed Keyboard write() method to type(). Made write() an alias for type() to allow subclassing by Stream. 2011-12-20 17:00:19 -05:00
Zach Eveland 58fc0d17cc added asynchronous buffering of received CDC characters
This fixes the issue Federico reported where bytes written by host but not read by sketch would cause serial connection to lock up.  Ring buffer implementation is based on HardwareSerial.cpp.

Adds public accept() method to CDC.
2011-12-18 17:52:35 -05:00
Zach Eveland d004d6a9b4 added Mouse.isPressed() method 2011-09-16 16:59:14 -04:00
Zach Eveland 3287477db1 made some Keyboard methods private 2011-09-16 16:43:07 -04:00
Zach Eveland 15c4c96929 fixed Mouse button assignments 2011-09-13 21:37:46 -04:00
Zach Eveland d3c96622b3 made Mouse.buttons() private. removed MOUSE_ALL macro 2011-09-12 08:14:13 -04:00
Zach Eveland 90ea0707e6 added Mouse press() and release() 2011-08-30 20:23:06 -04:00
Zach Eveland af635024db support for non-Leonardo boards is back! 2011-08-30 11:50:08 -04:00
Zach Eveland 481fdeab79 CDC and HID write() routines now return non-void - brought in line with new write behavior 2011-08-30 11:04:34 -04:00
Zach Eveland ddd3418a4f Serial via USB works
Integrated rest of Peter's USB implementation
2011-08-14 16:59:34 -04:00