libopencm3/libopencm3 — pull request #115 by aspalmer (2013-03-01 01:05:10+00:00)
Title: 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.