Commit graph

25 commits

Author SHA1 Message Date
Manuel Odendahl cea8158e97 Check if the last packet sent was the full endpoint size, in this case flush the host buffers by sending a 0 byte packet
Signed-off-by: Manuel Odendahl <wesen@ruinwesen.com>
2013-01-17 21:23:37 +01:00
Marti Bolivar 2022b933be usb_serial.cpp: Hackishly silence spurious warnings on VLDiscovery.
Guard hooks with BOARD_HAVE_SERIALUSB to keep GCC quiet.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-27 16:50:57 -04:00
Marti Bolivar 64e8a234bf usb_serial.cpp: Neaten up reset signal RX hook.
Move magic bytes from stack to Flash. De-magic-number sizeof magic
byte buffer. Use uintptr_t instead of unsigned int when casting
address of wait_reset().

Based on a patch by Michael Hope.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-08-22 13:26:43 -04:00
Marti Bolivar 365f45679b Move bootloader reset signal detection to Wirish.
Use usb_cdcacm hooks to move the DTR edge and "1EAF" magic packet
detection to usb_serial.cpp. We'll later be able to extend this system
to support Leonardo-style reset signalling.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-31 15:04:49 -04:00
Marti Bolivar 77efc209f9 usb_serial.cpp: Minor tweak.
Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-07-25 17:19:41 -04:00
Marti Bolivar 8796a81efc Slightly improve and generify the USB infrastructure.
The good news is that <libmaple/usb.h> and <libmaple/usb_cdcacm.h> did
turn out generic enough in what they specify to go on unchanged.

However, we can't just go on assuming that there's USB just because
we're on an F1. Now that there's value line in the tree, we need to be
more careful (value line F1s don't have USB peripherals). To that end,
make all the F1 board-includes/*.mk files specify what line their MCU
is with an MCU_F1_LINE variable. Use that to hack
libmaple/usb/rules.mk so we only try to build the USB module under
appropriate circumstances.

While we're at it, add a vector_symbols.inc for value line MCUs under
support/ld/. We need this to get the target-config.mk modifications
implied by the addition of MCU_F1_LINE. We'll fix up some other
performance-line-isms under libmaple/stm32f1 in a separate commit.

Also in libmaple/usb/:

- Move everything into a new stm32f1 directory. Due to aforementioned
  rules.mk hacks, there is no immediate need for an stm32f2
  directory (USB support doesn't exist there).

- Update the README for style and content.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-06-03 22:40:39 -04:00
Marti Bolivar 04760fa17b Make USB its own submodule.
Add libmaple/usb/rules.mk, which compiles the USB FS device firmware
submodule. Move the logic for compiling the USB stack from
libmaple/rules.mk into libmaple/usb/rules.mk.

Move libmaple/usb/usb_cdacm.h to libmaple/include/libmaple/. Its API
is sufficiently general that we'll be able to port it over to USB
OTG (either FS or HS) eventually, and that lets us include it from
Wirish using the new style for libmaple headers.

Fix the includes for public libmaple headers within libmaple/usb.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:51 -04:00
Marti Bolivar 954f9e5065 Move public headers to include directories; related cleanups.
Move libmaple/*.h to (new) libmaple/include/libmaple/. The new
accepted way to include a libmaple header foo.h is with:

    #include <libmaple/foo.h>

This is more polite in terms of the include namespace. It also allows
us to e.g. implement the Arduino SPI library at all (which has header
SPI.h; providing it was previously impossible on case-insensitive
filesystems due to libmaple's spi.h).

Similarly for Wirish.

The old include style (#include "header.h") is now deprecated.

libmaple/*.h:

- Change include guard #defines from _FOO_H_ to _LIBMAPLE_FOO_H_.
- Add license headers where they're missing
- Add conditional extern "C" { ... } blocks where they're missing
  (they aren't always necessary, but we might was well do it against
  the future, while we're at it.).
- Change includes from #include "foo.h" to #include <libmaple/foo.h>.
- Move includes after extern "C".
- Remove extra trailing newlines

Note that this doesn't include the headers under libmaple/usb/ or
libmaple/usb/usb_lib. These will get fixed later.

libmaple/*.c:

- Change includes from #include "foo.h" to #include <libmaple/foo.h>.

Makefile:

- Add I$(LIBMAPLE_PATH)/include/libmaple to GLOBAL_FLAGS.  This allows
  for users (including Wirish) to migrate their code, but should go
  away ASAP, since it slows down compilation.

Wirish:

- Move wirish/**/*.h to (new) wirish/include/wirish/.  This ignores
  the USB headers, which, as usual, are getting handled after
  everything else.

- Similarly generify wirish/boards/ structure. For each supported
  board "foo", move wirish/boards/foo.h and wirish/boards/foo.cpp to
  wirish/boards/foo/include/board/board.h and
  wirish/boards/foo/board.cpp, respectively. Also remove the #ifdef
  hacks around the .cpp files.

- wirish/rules.mk: put wirish/boards/foo/include in the include path
  (and add wirish/boards/foo/board.cpp to the list of sources to be
  compiled). This allows saying:

      #include <board/board.h>

  instead of the hack currently in place. We can allow the user to
  override this setting later to make adding custom board definitions
  easier.

- Disable -Werror in libmaple/rules.mk, as the current USB warnings
  don't let the olimex_stm32_h103 board compile. We can re-enable
  -Werror once we've moved the board-specific bits out of libmaple
  proper.

libraries, examples:

- Update includes accordingly.
- Miscellaneous cosmetic fixups.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2012-04-11 16:56:50 -04:00
Marti Bolivar 9be44ebd86 USB: API cleanups.
Modify usb.h functions (changing their names in some cases) to also
take a usblib_dev* argument, to fit in better with the rest of
libmaple.

Store an rcc_clk_id in struct usblib_dev for the same reason.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-10-21 18:13:05 -04:00
Marti Bolivar 494f05b236 usb: Disentangle CDC ACM functionality.
Add new usb_cdcacm.h, which provides the virtual serial port API.
This file (and new usb_cdcacm.c) consolidate the VCOM support, which
was previously distributed through descriptors.[hc], usb.[hc],
usb_callbacks.[hc], and usb_config.h.

Add usb_init_usblib() to usb.h, as a way of initializing the USB
peripheral in terms of the data structures required by usb_lib.  This
is used by the new usb_cdcacm_enable().

Create new usb_lib_globals.h, with declarations for the usb_lib global
state which is most used throughout the rest of the libmaple USB stack.

Remove descriptors.c and usb_callbacks.[hc]; they are no longer
necessary.

Update the USB README accordingly.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-10-18 13:30:18 -04:00
Marti Bolivar 17e67dff76 usb: Cleanups and renames.
Rename setupUSB() and disableUSB() to usb_cdcacm_enable() and
usb_cdcacm_disable(), respectively.

Remove usbSendHello(). This shouldn't exist.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-10-18 13:30:17 -04:00
Marti Bolivar 545aae4459 usb: Move some board-specific configuration to Wirish.
Create new BOARD_USB_DISC_DEV and BOARD_USB_DISC_BIT board-specific
values.  Use these as arguments to setupUSB() and disableUSB().  This
helps make the USB stack more generic, and goes towards the resolution
of an important FIXME.

Signed-off-by: Marti Bolivar <mbolivar@leaflabs.com>
2011-10-18 13:30:17 -04:00
Marti Bolivar e7d5f4c167 SerialUSB fixups. 2011-05-04 13:31:53 -04:00
Marti Bolivar 837e649dba Fixing USBSerial::read(void*, uint32). 2011-05-04 13:31:53 -04:00
AJM ffc963692e fixed broken build from usb_serial.cpp
oops
2010-12-13 22:33:22 -05:00
AJM 13be968982 made SerialUSB.read blocking
it should have been blocking before but wasnt. see bug #49
2010-12-13 22:09:12 -05:00
Marti Bolivar 1d3f7c7831 more sphinx docs 2010-10-11 23:39:50 -04:00
Marti Bolivar 849bc0f8f6 wirish reformatted and code-styled 2010-09-26 21:47:55 -04:00
bnewbold 31f9eb2364 last usbserial change... please? 2010-07-22 20:33:53 -04:00
bnewbold 99c251b846 added isConnected() to serialusb 2010-07-22 18:24:51 -04:00
bnewbold f728985846 went with 50ms SerialUSB timeout 2010-07-20 22:03:52 -04:00
bnewbold 52cbd2f1a1 working serialUSB with timeout
as a temporary workaround for the fact that SerialUSB is often blocking,
this crude implementation makes the low-level C usbSendBytes function
non-blocking (with a return code of bytes sent) and implements a 2ms
timeout in the wirish write() function.

also adds begin(), end(), getDTR(), getRTS(), pending(). device is still
initialized the old fashioned way during init() so that, eg, autoreset
will work. includes a simple multi-test program.
2010-07-19 00:38:36 -04:00
AJM cb1a6fbc21 added getDTR and getRTS to usb.h, subtly modded how sendBytes checks for connection
flip flopped back and forth on how much work should be done here. For now its like 5 lines of changes
2010-06-11 13:03:09 -04:00
Perry Hung 717060ef8c USB Serial read() fix:
stupid, stupid mistake.
2010-06-05 22:35:43 -04:00
Perry Hung 88d4b095e4 Preliminary wirish USBSerial implementation.
-updated examples
-removed HardwareUSB
-cleaned up a handful of includes
2010-06-04 00:43:21 -04:00
Renamed from wirish/comm/HardwareUsb.cpp (Browse further)