-
Notifications
You must be signed in to change notification settings - Fork 52
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
Add tinyusb builtin-core support with menu selection #121
Conversation
@@ -4,6 +4,10 @@ | |||
#include "variant.h" | |||
#include "HardwareSerial.h" | |||
|
|||
#if defined(USE_TINYUSB) | |||
#include "Adafruit_USBD_CDC.h" | |||
#define Serial SerialTinyUSB |
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.
define Serial as TinyUSB's virtual com
@@ -79,7 +79,8 @@ compiler.elf2lst.extra_flags= | |||
|
|||
# USB Flags | |||
# --------- | |||
build.usb_flags=-DUSBCON {build.usb_speed} -DUSBD_VID={build.vid} -DUSBD_PID={build.pid} -DHAL_PCD_MODULE_ENABLED | |||
#build.usb_flags=-DUSBCON {build.usb_speed} -DUSBD_VID={build.vid} -DUSBD_PID={build.pid} -DHAL_PCD_MODULE_ENABLED | |||
build.usb_flags= |
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.
build.usb_flags
is definned by menu selection, user can choose which usb controller they want to use as device: usbd, usbfs, usbhs
CH32X035_EVT.menu.pnum.CH32X035G8U=CH32X035G8U EVT | ||
CH32X035_EVT.menu.pnum.CH32X035G8U.node=NODE_X035G8 | ||
CH32X035_EVT.menu.pnum.CH32X035G8U.node=NODE_X035G8U |
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.
node typo ? is NODE_X035G8U correct ?
CH32X035_EVT.menu.clock.24MHz_HSI.build.flags.clock=-DSYSCLK_FREQ_16MHz_HSI=16000000 | ||
CH32X035_EVT.menu.clock.24MHz_HSI=12MHz Internal | ||
CH32X035_EVT.menu.clock.24MHz_HSI.build.flags.clock=-DSYSCLK_FREQ_12MHz_HSI=12000000 | ||
CH32X035_EVT.menu.clock.16MHz_HSI=16MHz Internal |
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.
16mhz_hsi typo catched by script
CH32V10x_EVT.menu.clock.72MHz_HSI=72MHz Internal | ||
CH32V10x_EVT.menu.clock.72MHz_HSI.build.flags.clock=-DSYSCLK_FREQ_72MHz_HSI=72000000 | ||
CH32V10x_EVT.menu.clock.56MHz_HSI=56MHz Internal | ||
CH32V10x_EVT.menu.clock.56MHz_HSI.build.flags.clock=-DSYSCLK_FREQ_56MHz_HSI=56000000 | ||
CH32V10x_EVT.menu.clock.48MHz_HSI=48MHz Internal | ||
CH32V10x_EVT.menu.clock.48MHz_HSI.build.flags.clock=-DSYSCLK_FREQ_48MHz_HSI=48000000 | ||
CH32V10x_EVT.menu.clock.8MHz_HSI=8MHz Internal | ||
CH32V10x_EVT.menu.clock.8MHz_HSI.build.flags.clock=-DSYSCLK_FREQ_HSI=8000000 | ||
CH32V10x_EVT.menu.clock.8MHz_HSI.build.flags.clock=-DSYSCLK_FREQ_8MHz_HSI=8000000 |
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.
is this typo? should it be -DSYSCLK_FREQ_HSI/HSE=8000000 or -DSYSCLK_FREQ_8MHz_HSI/HSE=8000000 to be consistent with above defines
CH32V20x_EVT.menu.pnum.CH32V203C6.build.IQ_math_RV32= | ||
CH32V20x_EVT.menu.pnum.CH32V203C6.build.ch_extra_lib=-lprintf | ||
|
||
|
||
# USB support |
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.
usb menu selection for v20x
|
||
|
||
# USB support |
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.
usb selection for v307
This is awesome! |
Special thanks for your contribution, it's awesome!!
This is really convenient and very friendly to me. But what I'm worried about is that if someone doesn't have a py environment, he might add a board by directly copying it.
What I know is that if you want to use USBHS for ch32v307, you must use HSE, because the internal HSI has frequency offset and may not be applicable to all
I haven't found out what the problem is yet. |
@TianpeiLee thank you for the merge, no worry for python it is rather universal and easy to install for windows (for linux/mac it comes with the OS).
Ah, glad to know that, I will do more test with other freq configuration (96/48 etc ..) so far I only tested with 144Mhz HSE. Will put some error/note message for this later on
feel free to make an PR if you figure out anything. |
This PR add TinyUSB library support for ch32 core with minimal changes as possible. These are tested and worked with Ch32v203 with both USBD and USBFS, and ch32v307 both USBFS and USBHS (need 144Mhz HSE since I am familliar with highspeed clock setup).
libraries/
as submodules, this is required for having Serial to include and declare as USB virtual come instead of UART. (this require git submodule update --init), and the zip package should also clone this for a new core releasepython tools/makeboards.py > boards.txt
. It does catch some of your existing typo, please let us know if this looks good to you. Otherwise we can skip this, and just copy/paste & modify manually.Ch32v203: only USBD and USBFS are available
Ch32v307: only USBFS and USBHS are available
Limitation:
Note: this uses adafruit/Adafruit_TinyUSB_Arduino#429, once this PR is approved and merged, we will release a new version for tinyusb and make an following up PR so that this core use an official new release.
@ladyada