-
Notifications
You must be signed in to change notification settings - Fork 1k
Compiler option for selecting output implementation #1326
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
base: dev
Are you sure you want to change the base?
Conversation
|
I have hit a more general problem too. Enabling the UART on Nordic chips means a lot of current is constantly consumed. I fixed this in a battery powered application by disabling the UART, but it's not ideal. So I see three options here:
You could imagine other options such as ARM SemiHosting, which may be useful if the extra UART connection is inconvenient or unavailable. |
|
Strawman proposal: add a What do you think? |
Good idea. |
|
I agree, I think it is a good proposal, especially if we add that option as something that can be specified in the target JSON file (and overridden from the command line of course). As long as we are considering general cases, one other configuration would be to allow for a custom |
|
Yes, now you say it, that should definitely be possible. I've considered it before but didn't see a good way to do it. However, I think this would work, perhaps with // +build output.custom
package runtime
var customOutput func(c char)
func putchar(c char) {
if customOutput != nil {
customOutput(c)
}
}
func SetOutput(putchar func(c char)) {
customOutput = putchar
}Regarding implementation, I would propose the following:
This design also avoids odd things like the following, by using the tinygo/src/runtime/runtime_arm7tdmi.go Lines 12 to 14 in 26a0819
|
|
Yes, in my opinion that is a good design that can be implemented cleanly. I can go ahead and get started implementing this and have it ready for review pretty soon |
6025656 to
841eaa3
Compare
I would like feedback on this as a possible mechanism for allowing to disable the USB CDC implementation on boards where it is the default output for
print()This is useful for devices/applications that need more control over the USB interface. Such a capability is probably a necessity in order to be able to implement other USB interface classes such as HID, MSD, etc.
This draft implementation utilizes a build tag named
no_default_usbwhich causesUART0(used as the destination for putchar) to be a UART implementation instead of configuring/using USB CDC. Right now I've only implemented this for samd targets, but if it looks good it will be easy to do the same for nrf52840 (which I believe is only other chipset with USB CDC support at the moment)