57 Commits

Author SHA1 Message Date
Franck Jullien
d6bad27735 Allow more than one usbd_register_set_config_callback
In a composite device if one want to separate code
for each interface, usbd_register_set_config_callback
can now register more than one callback.

Signed-off-by: Franck Jullien <franck.jullien@gmail.com>
2014-07-14 14:04:58 +02:00
Pavol Rusnak
806ebb18fa add MSC (Mass Storage Class) support 2014-07-03 18:46:55 +02:00
Karl Palsson
a277abe2c1 [usb-f103] Use the "modern" /rcc include instead of f1.
The f103 usb core should be usable on the l1 as well, and the /f1/rcc
isn't explicitly required anymore.  This is an important change to be
able to share the driver.
2013-09-05 17:35:07 +00:00
Alexandru Gagniuc
0819a49411 usb_control: Mark the control pipe as IDLE after a STALL
After a STALL handshake is transmitted, a control pipe becomes idle. Not
marking the pipe as idle did not affect the STM32 family. Since it
distinguishes between OUT and SETUP tokens, it calls the setup handler
on a SETUP token, regardless of the state of the pipe.

Other families, such as LM4F do not distinguish in software between IN and
SETUP tokens, and need to decide which handler to call based on the state
of the pipe. On these chips, SETUP transactions will not be handled
properly after a transfer was STALLED, as the state machine of the pipe is
b0rked. Unb0rk it.

Signed-off-by: Alexandru Gagniuc <mr.nuke.me@gmail.com>
2013-07-07 17:04:38 -07:00
Federico Ruiz Ugalde
60bdf4eebd stm32f3: f1 usb header files moved to stm32 root directory.
- Now the f1 usb header files serve both the f1 and f3.
- usb_f103 modified to find the new headers file location.
2013-07-07 16:01:50 -07:00
Piotr Esden-Tempski
2f425af647 [Style] A small coding style fixing session. 2013-07-05 20:35:13 -07:00
Piotr Esden-Tempski
cabbd21329 Reverted the __packed and __aligned change.
We should not add compiler extensions, it is not our job. We are not a
selfcontained project as kernel is so we should not introduce things
like this.

If we need to add some abstraction for this in the future to support
compilers doing these things differently then we will do that the same
way we dealt with the depricated attribute.
2013-06-13 10:29:43 -07:00
Piotr Esden-Tempski
8da7fbd71e Changed to use accessors instead of casting to volatile pointers.
In places where we were defining memory mapped peripheral buffers we
were using directly a cast to "volatile int_type *". For consistency we
should use dereferenced accessor like: &MMIO32(address)
2013-06-12 21:37:55 -07:00
Piotr Esden-Tempski
39fa9e4c58 Stile fixes run, 80 char boundry. 2013-06-12 21:07:35 -07:00
Piotr Esden-Tempski
34de1e776e Changed to use stdint types. 2013-06-12 19:11:22 -07:00
Piotr Esden-Tempski
7df63fcae0 First coarse run to fix coding style in locm3.
Added --terse and --mailback options to the make stylecheck target. It
also does continue even if it enounters a possible error.

We decided on two exceptions from the linux kernel coding standard:
- Empty wait while loops may end with ; on the same line.
- All blocks after while, if, for have to be in brackets even if they
  only contain one statement. Otherwise it is easy to introduce an
  error.

Checkpatch needs to be adapted to reflect those changes.
2013-06-12 18:22:56 -07:00
Andrey Smirnov
113e5c22e6 Change the way buffer for control requests data is allocated
Current way of having a globally, but weakly defined static buffer has
several shortcomings:
 - It forces user to have a certain "magic" byte array variable if
   they want to have a control buffer of different size.
 - Having a globally defined static array and a separate function to
   tell USB core about its size is error prone.
 - Its inner workings are not easily understandable form cursory look
   at API and one needs to go and look at the implementation code to
   connect all the pieces into a solid picture of how it works

This commit adds two parameters to 'usbd_init' call that allow user to
specify the pointer to the area of memory and a size of that memory
which would be used by the USB core to store the data received during
DATA stage of control requests. This approach, while further
complicating the prototype of 'usbd_init', provides user with more
flexibility allowing for any custom area of memory of any size to be
used as control buffer. It also forces user to provide both address
and memory size at the same time thus avoiding the possibility of user
redefining 'usbd_control_buffer', but not calling
'usbd_set_control_buffer_size' after that.
2013-04-25 17:24:27 -07:00
Ken Sarkies
1374d2622b Place generic USB header and source files into the documentation tree. 2013-04-19 10:26:01 +09:30
Piotr Esden-Tempski
80fd23580a Fix all warnings for stm32f1 lib. 2013-02-26 17:14:31 -08:00
Jeff Ciesielski
db35fbb7ba Merge branch 'master' of git://github.com/libopencm3/libopencm3 into upstream-merge 2012-11-13 13:13:40 -08:00
Andrey Smirnov
720e85f850 Further re-factor USB string handling code
This commit refactors USB string code, making it, hopefully, less
buggy and more easier to understand. It also removes "magic" bit
manipulation and "magic" numbers;
2012-11-07 11:30:44 -08:00
Andrey Smirnov
c5c4db0196 Extend control hook framework
This commits adds a new error code that can be return from a
registered control callback: USBD_REQ_NEXT_CALLBACK. This return code
signifies that the callback is done processing the data successfully,
but user would like to have all matching callbacks down the callback
chain to be executed too.

This change allows for example to intercept standard requests like
GET_DESCRIPTOR, do some small action upon receiving of one, but still
have the standard callback executed and do it's job. This way user
doesn't have to re-implement standard GET_DESCRIPTOR functionality if
they want to intercept that request to do some small thing.
2012-11-07 10:33:51 -08:00
Andrey Smirnov
7a5da60e26 Change USB strings handling code
This commit add an extra field to the _usbd_device, that allows to
keep track of the number of USB strings  which allows simplify
boundaries checking code in usb_standard_get_descriptor.

This commit also changes the index base for strings in
usb_standard_get_descriptor which allows to get rid of necessity to
have a dummy one-character string in a strings array.
2012-11-06 16:46:55 -08:00
Jason Kotzin
34beeae925 USB core updated for reentrance based on Christian Cier-Zniewski's branch 2012-09-13 10:43:35 -07:00
Jason Kotzin
4958fae906 fixing usb and alignment issue 2012-09-13 10:43:26 -07:00
Piotr Esden-Tempski
43561de329 License change of the library to LGPL, version 3 or later.
Agreed to by all the significant contributors to the library.
2012-03-02 14:44:49 -08:00
Mike Smith
7da1967056 Add an interface for soft disconnection, and hook it up in the F107 driver. 2012-02-12 15:00:08 -08:00
Gareth McMullin
0731bba610 usb: Added support for Interface Association descriptors. 2011-12-28 21:05:41 +13:00
Gareth McMullin
651917aeb4 Added USB example for stm32f4.
Moved clock enable for OTG_FS back into applications.  This and gpio config
are the only differences between f107 and f2xx/f4xx.
2011-12-17 14:11:39 +13:00
Uwe Hermann
373794ab68 usb: Fix some Doxygen comments. 2011-11-17 00:12:47 +01:00
Uwe Hermann
3e9b9cb345 usb: Coding-style fixes. 2011-11-17 00:12:43 +01:00
Gareth McMullin
30e188cf07 Only allow one packet in TX fifos.
This fixes a problem where packets were written too quickly.
The hardware disabled the endpoint after the fist packet is sent,
and others just waited in the queue.
2011-11-12 21:44:37 +13:00
Gareth McMullin
e0fe43357d usb_f107: Fixed lost 4 bytes on control OUT transaction. 2011-10-31 14:09:41 -07:00
Uwe Hermann
788f3870c4 Merge remote-tracking branch 'fnoble/stm32f2' 2011-10-29 22:19:12 +02:00
Gareth McMullin
284be93037 Restored OTG clock enable in RCC in f107 usb init. 2011-10-29 23:57:10 +13:00
Gareth McMullin
b05a5dcf2a Fixed some F105/F107 USB issues. Added user callback on SOF.
Made examples depend on lib.
2011-10-29 21:30:26 +13:00
Fergus Noble
14dcda91b0 Fixing some more header references 2011-10-12 22:20:22 -04:00
Fergus Noble
7518bc83c1 Fixing some header references 2011-10-12 22:20:22 -04:00
Uwe Bonnes
32c276a708 Move enabling the USB Clock into stm32f10x_usbd_init 2011-07-13 10:04:03 +02:00
Gareth McMullin
7434d50fda Check index bounds on usb string descriptor request. 2011-04-24 14:28:16 +12:00
Gareth McMullin
3d820c6ed7 Fixed stm32f107 usb driver to allow calling usbd_poll from irq handler. 2011-04-04 17:39:05 +12:00
Gareth McMullin
ef0ff192f7 Added usbd_ep_nak_set() to force flow control on OUT endpoints. 2011-03-30 07:17:02 +13:00
Gareth McMullin
6bbc4c2f7c Fixed non-control endpoints for connectivity line USB. 2011-03-15 20:33:02 +13:00
Gareth McMullin
bf0d1a7b41 Connectivity line USB driver now enumerating correctly. 2011-03-14 20:31:32 +13:00
Gareth McMullin
554feb7f27 USB driver for Connectivity-line devices partially working. 2011-02-20 12:28:23 +13:00
Gareth McMullin
e64a9d2bf9 Minor cleanup of usb. Template driver for STM32F107 added. 2011-02-10 19:58:51 +13:00
Uwe Hermann
a0091f18c7 Cosmetics, consistency fixes, fix compiler warnings. 2011-01-30 22:43:33 +01:00
Gareth McMullin
aac65d8560 Abstracted USB driver interface to to allow driver selection. 2011-01-30 17:04:56 +13:00
Gareth McMullin
193a1ed3b8 Reset CTR flag for endpoint from usbd_poll if no callback. 2011-01-30 15:42:12 +13:00
Gareth McMullin
f87170e06e Clear user control request handlers on set_configuration request. 2011-01-30 15:41:23 +13:00
Uwe Hermann
8f251e8a9d Some more file/path restructuring.
All #includes now explicitly use the "<libopencm3/stm32/rcc.h>" format.
If you want to get rid of the "libopencm3" prefix in your local project you
can add a respective -I entry in your Makefile (not recommended though).

All .ld files and .a libs are installed in $(TOOLCHAIN_DIR)/lib
directly (as before), but are now renamed to avoid potential
conflicts now or in the future. Examples:

  libopencm3_lpc13xx.a
  libopencm3_lpc13xx.ld
  libopencm3_stm32.a
  libopencm3_stm32.ld
2010-12-31 18:18:39 +01:00
Uwe Hermann
18790a2454 More renames for libopenstm32 -> libopencm3. 2010-12-30 13:19:25 +01:00
Uwe Hermann
be2ac142d9 Rename include/libopenstm32 to include/stm32. 2010-12-30 02:23:51 +01:00
Uwe Hermann
17b2e87ba3 Factor out cm3/common.h and cm3/memorymap.h. 2010-12-30 00:53:52 +01:00
Uwe Hermann
b5727a6c73 USB: Cosmetics and coding-style fixes. 2010-12-29 18:00:32 +01:00