aboutsummaryrefslogtreecommitdiff
path: root/ports/stm32/usbdev/class/src
AgeCommit message (Collapse)Author
2020-07-25stm32/usbdev: Fix calculation of SCSI LUN size with multiple LUNs.Damien George
The SCSI driver calls GetCapacity to get the block size and number of blocks of the underlying block-device/LUN. It caches these values and uses them later on to verify that reads/writes are within the bounds of the LUN. But, prior to this commit, there was only one set of cached values for all LUNs, so the bounds checking for a LUN could use incorrect values, values from one of the other LUNs that most recently updated the cached values. This would lead to failed SCSI requests. This commit fixes this issue by having separate cached values for each LUN. Signed-off-by: Damien George <damien@micropython.org>
2019-10-05stm32/usbdev: Fix compile error if MICROPY_HW_USB_CDC_NUM is set to 2.Martin Fischer
Fixes regression introduced by 6705767da1f7dba7a04e1d16c380a650f1f1074f
2019-09-11stm32/usb: Verify number of used endpoints doesn't exceed maximum.Damien George
2019-09-11stm32/usb: Add support for VCP+MSC+HID mode, incl 2xVCP and 3xVCP.Damien George
2019-07-25stm32/usbd_hid_interface: Rewrite USB HID interface code.Damien George
The previous version did not work on MCUs that only had USB device mode (compared to OTG) because of the handling of NAK. And this previous handling of NAK had a race condition where a new packet could come in before USBD_HID_SetNAK was called (since USBD_HID_ReceivePacket clears NAK as part of its operation). Furthermore, the double buffering of incoming reports was not working, only one buffer could be used at a time. This commit rewrites the HID interface code to have a single incoming buffer, and only calls USBD_HID_ReceivePacket after the user has read the incoming report (similar to how the VCP does its flow control). As such, USBD_HID_SetNAK and USBD_HID_ClearNAK are no longer needed. API functionality from the user's point of view should be unchanged with this commit.
2019-07-16stm32/usb: Add config options to disable USB MSC and/or HID.Damien George
The new configurations MICROPY_HW_USB_MSC and MICROPY_HW_USB_HID can be used by a board to enabled or disable MSC and/or HID. They are both enabled by default.
2019-07-03stm32: Update components to work with new H7xx HAL.Damien George
2019-06-11stm32/usbd_msc: Provide Mode Sense response data in MSC interface.Damien George
Eventually these responses could be filled in by a function to make their contents dynamic, depending on the attached logical units. But for now they are fixed, and this patch fixes the MODE SENSE(6) responses so it is the correct length with the correct header.
2019-06-11stm32/usbd_msc: Provide custom irquiry processing by MSC interface.Damien George
So the MSC interface can customise the inquiry response based on the attached logical units.
2019-05-31stm32/usb: Support up to 3 VCP interfaces on USB device peripheral.Damien George
To enable define MICROPY_HW_USB_CDC_NUM to 3.
2019-05-30stm32/usb: Refactor CDC VCP code to enable N CDC interfaces.Damien George
The board config option MICROPY_HW_USB_ENABLE_CDC2 is now changed to MICROPY_HW_USB_CDC_NUM, and the latter should be defined to the maximum number of CDC interfaces to support (defaults to 1).
2019-04-28stm32/usb: Add USB device mode for VCP+VCP without MSC.Andrew Leech
Selectable via pyb.usb_mode('VCP+VCP').
2019-04-26stm32/usbdev: Make USB device descriptors at runtime rather than static.Damien George
2019-01-31stm32/usb: Add flow control option for USB VCP data received from host.Andrew Leech
It's off by default and can be enabled at run-time with: pyb.USB_VCP().init(flow=pyb.USB_VCP.RTS)
2019-01-27stm32/usbdev: Add USB config option for max power drawn by the board.Damien George
The new compile-time option is MICROPY_HW_USB_MAX_POWER_MA. Set this in the board configuration file to the maximum current in mA that the board will draw over USB. The default is 500mA.
2019-01-27stm32/usbdev: Add USB config option for board being self powered.Damien George
The new compile-time option is MICROPY_HW_USB_SELF_POWERED. Set this option to 1 in the board configuration file to indicate that the USB device is self powered. This option is disabled by default (previous behaviour).
2018-10-15stm32/usbd_cdc_interface: Refactor USB CDC tx code to not use SOF IRQ.Damien George
Prior to this commit the USB CDC used the USB start-of-frame (SOF) IRQ to regularly check if buffered data needed to be sent out to the USB host. This wasted resources (CPU, power) if no data needed to be sent. This commit changes how the USB CDC transmits buffered data: - When new data is first available to send the data is queued immediately on the USB IN endpoint, ready to be sent as soon as possible. - Subsequent additions to the buffer (via usbd_cdc_try_tx()) will wait. - When the low-level USB driver has finished sending out the data queued in the USB IN endpoint it calls usbd_cdc_tx_ready() which immediately queues any outstanding data, waiting for the next IN frame. The benefits on this new approach are: - SOF IRQ does not need to run continuously so device has a better chance to sleep for longer, and be more responsive to other IRQs. - Because SOF IRQ is off, current consumption is reduced by a small amount, roughly 200uA when USB is connected (measured on PYBv1.0). - CDC tx throughput (USB IN) on PYBv1.0 is about 2.3 faster (USB OUT is unchanged). - When USB is connected, Python code that is executing is slightly faster because SOF IRQ no longer interrupts continuously. - On F733 with USB HS, CDC tx throughput is about the same as prior to this commit. - On F733 with USB HS, Python code is about 5% faster because of no SOF. As part of this refactor, the serial port should no longer echo initial characters when the serial port is first opened (this only used to happen rarely on USB FS, but on USB HS is was more evident).
2018-10-15stm32/usbd_cdc_interface: Handle disconnect IRQ to set VCP disconnected.Damien George
pyb.USB_VCP().isconnected() will now return False if the USB is disconnected after having previously been connected. See issue #4210.
2018-05-28stm32/usb: Guard USB device code with #if for whether USB is enabled.Damien George
With this change, all the USB source code can now be passed through the compiler even if the MCU does not have a USB peripheral.
2018-05-15stm32/usb: Initialise cdc variable to prevent compiler warnings.Damien George
Some compilers cannot deduce that cdc will always be written before being used.
2018-05-14stm32/usb: Add ability to have 2x VCP interfaces on the one USB device.Damien George
This patch adds the configuration MICROPY_HW_USB_ENABLE_CDC2 which enables a new USB device configuration at runtime: VCP+VCP+MSC. It will give two independent VCP interfaces available via pyb.USB_VCP(0) and pyb.USB_VCP(1). The first one is the usual one and has the REPL on it. The second one is available for general use. This configuration is disabled by default because if the mode is not used then it takes up about 2200 bytes of RAM. Also, F4 MCUs can't support this mode on their USB FS peripheral (eg PYBv1.x) because they don't have enough endpoints. The USB HS peripheral of an F4 supports it, as well as both the USB FS and USB HS peripherals of F7 MCUs.
2018-05-14stm32/usb: Change HID report funcs to take HID state, not usbdev state.Damien George
2018-05-14stm32/usb: Change CDC tx/rx funcs to take CDC state, not usbdev state.Damien George
2018-05-14stm32/usb: Make CDC endpoint definitions private to core usbdev driver.Damien George
2018-05-14stm32/usb: Combine HID lower-layer and interface state into one struct.Damien George
2018-05-14stm32/usb: Combine CDC lower-layer and interface state into one struct.Damien George
2018-05-14stm32/usbdev: Be honest about data not being written to HID endpoint.Peter D. Gray
USB_HID.send() should now return 0 if it could not send the report to the host.
2018-05-11stm32/usbdev: Remove unused RxState variable, and unused struct.Damien George
2018-05-11stm32/usbdev: Convert files to unix line endings.Damien George
Also remove trailing whitespace and convert tabs to spaces.
2018-02-12stm32/usbdev: Fix USBD setup request handler to use correct recipient.Damien George
Prior to this patch the USBD driver did not handle the recipient correctly for setup requests. It was not interpreting the req->wIndex field in the right way: in some cases this field indicates the endpoint number but the code was assuming it always indicated the interface number. This patch fixes this. The only noticeable change is to the MSC interface, which should now correctly respond to the USB_REQ_CLEAR_FEATURE request and hence unmount properly from the host when requested.
2018-02-01stm32/usbdev: Add support for high-speed USB device mode.Damien George
This patch adds support in the USBD configuration and CDC-MSC-HID class for high-speed USB mode. To enable it the board configuration must define USE_USB_HS, and either not define USE_USB_HS_IN_FS, or be an STM32F723 or STM32F733 MCU which have a built-in HS PHY. High-speed mode is then selected dynamically by passing "high_speed=True" to the pyb.usb_mode() function, otherwise it defaults to full-speed mode. This patch has been tested on an STM32F733.
2018-02-01stm32/usbdev: Add support for MSC-only USB device class.Damien George
Select this mode in boot.py via: pyb.usb_mode('MSC')
2018-02-01stm32/usbdev: Reduce dependency on py header files.Damien George
2017-12-13stm32/usbdev: Pass thru correct val for SCSI PreventAllowMediumRemoval.Damien George
This value is "1" when the medium should not be removed, "0" otherwise.
2017-09-21stm32/usbdev: Simplify pointers to MSC state and block dev operations.Damien George
2017-09-21stm32/usbdev: Put all state for the USB device driver in a struct.Damien George
2017-09-21stm32/usbdev: Simplify HID tx/rx buffer passing.Damien George
2017-09-21stm32/usbdev: Simplify CDC tx/rx buffer passing.Damien George
2017-09-21stm32/usbdev: Put all HID state in a struct.Damien George
2017-09-21stm32/usbdev: Put all CDC state in a struct.Damien George
2017-09-20stm32/usbdev: Make the USBD callback struct const so it can go in ROM.Damien George
2017-09-06stm32: Remove unused usbd_msc.c file.Damien George
2017-09-06ports: Make new ports/ sub-directory and move all ports there.Damien George
This is to keep the top-level directory clean, to make it clear what is core and what is a port, and to allow the repository to grow with new ports in a sustainable way.