-
-
Notifications
You must be signed in to change notification settings - Fork 8.4k
stm32/usb: Add support for using TinyUSB stack. #15592
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
andrewleech
wants to merge
2
commits into
micropython:master
Choose a base branch
from
andrewleech:stm32_tinyusb
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+417
−216
Open
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -136,6 +136,24 @@ | |
#define MICROPY_HW_ENABLE_USB (0) | ||
#endif | ||
|
||
#if MICROPY_HW_ENABLE_USB | ||
#define MICROPY_HW_USB_CDC (1) | ||
#define MICROPY_HW_USB_FS (1) | ||
|
||
// Select whether TinyUSB or legacy STM stack is used to provide USB. | ||
#ifndef MICROPY_HW_TINYUSB_STACK | ||
#define MICROPY_HW_TINYUSB_STACK (0) | ||
#endif | ||
|
||
// Central definition for STM USB stack (when not using TinyUSB) | ||
#define MICROPY_HW_STM_USB_STACK (MICROPY_HW_ENABLE_USB && !MICROPY_HW_TINYUSB_STACK) | ||
|
||
#if MICROPY_HW_TINYUSB_STACK | ||
#define MICROPY_HW_ENABLE_USBDEV (1) | ||
#endif | ||
|
||
#endif // MICROPY_HW_ENABLE_USB | ||
|
||
// Whether to enable the PA0-PA3 servo driver, exposed as pyb.Servo | ||
#ifndef MICROPY_HW_ENABLE_SERVO | ||
#define MICROPY_HW_ENABLE_SERVO (0) | ||
|
@@ -256,6 +274,8 @@ | |
// Windows needs a different PID to distinguish different device configurations. | ||
#ifndef MICROPY_HW_USB_VID | ||
#define MICROPY_HW_USB_VID (0xf055) | ||
#define MICROPY_HW_USB_PID (0x9802) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe add a comment that this is only used in the TinyUSB configuration (and eventually we'll need to change this value depending on whether MSC is enabled etc). |
||
|
||
#define MICROPY_HW_USB_PID_CDC_MSC (0x9800) | ||
#define MICROPY_HW_USB_PID_CDC_HID (0x9801) | ||
#define MICROPY_HW_USB_PID_CDC (0x9802) | ||
|
@@ -369,6 +389,8 @@ | |
#endif | ||
#define MICROPY_HW_MAX_LPUART (0) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32F4 | ||
|
||
// Configuration for STM32F7 series | ||
#elif defined(STM32F7) | ||
|
||
|
@@ -384,6 +406,8 @@ | |
#define MICROPY_HW_MAX_UART (8) | ||
#define MICROPY_HW_MAX_LPUART (0) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32F7 | ||
|
||
// Configuration for STM32G0 series | ||
#elif defined(STM32G0) | ||
|
||
|
@@ -394,6 +418,8 @@ | |
#define MICROPY_HW_MAX_UART (6) | ||
#define MICROPY_HW_MAX_LPUART (2) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32G0 | ||
|
||
// Configuration for STM32G4 series | ||
#elif defined(STM32G4) | ||
|
||
|
@@ -404,6 +430,8 @@ | |
#define MICROPY_HW_MAX_UART (5) // UART1-5 + LPUART1 | ||
#define MICROPY_HW_MAX_LPUART (1) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32G4 | ||
|
||
// Configuration for STM32H5 series | ||
#elif defined(STM32H5) | ||
|
||
|
@@ -414,6 +442,8 @@ | |
#define MICROPY_HW_MAX_UART (12) | ||
#define MICROPY_HW_MAX_LPUART (1) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32H5 | ||
|
||
// Configuration for STM32H7A3/B3 series | ||
#elif defined(STM32H7A3xx) || defined(STM32H7A3xxQ) || \ | ||
defined(STM32H7B3xx) || defined(STM32H7B3xxQ) | ||
|
@@ -425,6 +455,8 @@ | |
#define MICROPY_HW_MAX_UART (10) | ||
#define MICROPY_HW_MAX_LPUART (1) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32H7 | ||
|
||
// Configuration for STM32H7 series | ||
#elif defined(STM32H7) | ||
|
||
|
@@ -435,6 +467,8 @@ | |
#define MICROPY_HW_MAX_UART (8) | ||
#define MICROPY_HW_MAX_LPUART (1) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32H7 | ||
|
||
#if defined(MICROPY_HW_ANALOG_SWITCH_PA0) \ | ||
|| defined(MICROPY_HW_ANALOG_SWITCH_PA1) \ | ||
|| defined(MICROPY_HW_ANALOG_SWITCH_PC2) \ | ||
|
@@ -454,6 +488,8 @@ | |
#define MICROPY_HW_MAX_UART (5) | ||
#define MICROPY_HW_MAX_LPUART (1) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32L0 | ||
|
||
// Configuration for STM32L1 series | ||
#elif defined(STM32L1) | ||
#define MP_HAL_UNIQUE_ID_ADDRESS (UID_BASE) | ||
|
@@ -464,6 +500,8 @@ | |
#define MICROPY_HW_MAX_UART (5) | ||
#define MICROPY_HW_MAX_LPUART (0) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32L1 | ||
|
||
// Configuration for STM32L4 series | ||
#elif defined(STM32L4) | ||
|
||
|
@@ -474,6 +512,8 @@ | |
#define MICROPY_HW_MAX_UART (5) | ||
#define MICROPY_HW_MAX_LPUART (1) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32L4 | ||
|
||
// Configuration for STM32N6 series | ||
#elif defined(STM32N6) | ||
|
||
|
@@ -494,6 +534,8 @@ | |
#define MICROPY_HW_MAX_UART (1) | ||
#define MICROPY_HW_MAX_LPUART (1) | ||
|
||
#define CFG_TUSB_MCU OPT_MCU_STM32WB | ||
|
||
#ifndef MICROPY_HW_STM32WB_FLASH_SYNCRONISATION | ||
#define MICROPY_HW_STM32WB_FLASH_SYNCRONISATION (1) | ||
#endif | ||
|
@@ -699,10 +741,10 @@ | |
#define MICROPY_HW_USB_CDC_NUM (1) | ||
#endif | ||
#ifndef MICROPY_HW_USB_MSC | ||
#define MICROPY_HW_USB_MSC (MICROPY_HW_ENABLE_USB) | ||
#define MICROPY_HW_USB_MSC (MICROPY_HW_STM_USB_STACK) | ||
#endif | ||
#ifndef MICROPY_HW_USB_HID | ||
#define MICROPY_HW_USB_HID (MICROPY_HW_ENABLE_USB) | ||
#define MICROPY_HW_USB_HID (MICROPY_HW_STM_USB_STACK) | ||
#endif | ||
|
||
// Pin definition header file | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These options cannot be enabled unconditionally, because they may clash with board configurations (when using the STM USB stack).
Either just remove these lines (my preference, if that works) or at least only enable them if
MICROPY_HW_TINYUSB_STACK
is enabled.