Skip to content
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

USBHID implementation for Digispark #3650

Open
BrunoTeixeira1996 opened this issue Apr 12, 2023 · 7 comments
Open

USBHID implementation for Digispark #3650

BrunoTeixeira1996 opened this issue Apr 12, 2023 · 7 comments
Labels
avr AVR (Arduino Uno, etc.) enhancement New feature or request

Comments

@BrunoTeixeira1996
Copy link

BrunoTeixeira1996 commented Apr 12, 2023

Hi guys,
I was playing with the USBHID feature in a Digispark device and I was following the #2889.
In my case looks like there's no machine.BUTTON and if I want to flash the device with the following code Ill get an error for undefined variables.

package main

import (
	"machine"
	"machine/usb/hid/keyboard"
)

func main() {
	button := machine.BUTTON // UNDEFINED machine.BUTTON

	kb := keyboard.New()
	for {
		if button.Get() {
			kb.Write([]byte("tinygo"))
		}
	}
}

Flashing

$ tinygo flash -target=digispark main.go 
# machine/usb/hid
/usr/local/lib/tinygo/src/machine/usb/hid/hid.go:35:11: undefined: machine.EnableHID
/usr/local/lib/tinygo/src/machine/usb/hid/hid.go:56:11: undefined: machine.SendZlp
/usr/local/lib/tinygo/src/machine/usb/hid/hid.go:64:10: undefined: machine.SendUSBInPacket
$ tinygo version
tinygo version 0.27.0 linux/amd64 (using go version go1.20.2 and LLVM version 15.0.0)

Any idea how I can solve this?

@BrunoTeixeira1996
Copy link
Author

I used the same code but for a XIAO microcontroler and the error does not appear anymore.
I guess this means the digispark support is not yet finished.
Is there a way I could help coding this support? any guide or something?

@BrunoTeixeira1996
Copy link
Author

https://github.com/digistump/DigistumpArduino/releases/download/1.6.7/digistump-avr-1.6.7.zip

This might help. In arduino they are using the DigiKeyboard.h file

@deadprogram deadprogram changed the title USBHID not working in Digispark USBHID implementation for Digispark Apr 17, 2023
@deadprogram deadprogram added enhancement New feature or request avr AVR (Arduino Uno, etc.) labels Apr 17, 2023
@BrunoTeixeira1996
Copy link
Author

@deadprogram Thanks for the enhancement, I am available to help in this if needed.
I never did something similar but I can use my device to test code or even code anything in case it's needed.

@aykevl
Copy link
Member

aykevl commented May 3, 2023

While it is technically possible, I am not sure our current USB stack is lean enough for the Digispark, which does not have USB hardware (so it needs to be bit-banged) and only has 512 bytes of RAM and 8kB of flash. It would still be cool to have USB support, though.

@BrunoTeixeira1996
Copy link
Author

@aykevl do you think its something plan for the future?

@aykevl
Copy link
Member

aykevl commented May 3, 2023

I'm not going to add support for this, but maybe someone else will?

@BrunoTeixeira1996
Copy link
Author

Ok sure, Ill wait since I have no clue on how I can help developing this :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
avr AVR (Arduino Uno, etc.) enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants