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

Add support for SAMD21 HCD #2573

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ChrisDeadman
Copy link
Contributor

@ChrisDeadman ChrisDeadman commented Apr 4, 2024

This was written from scratch using the datasheet and tested on a SAMD21 (using SparkFun SAMD21 Mini Breakout).
However, it should also work with SAMD51 boards, I don't have one for testing though.

USB Hub Issue

For some reason, when compiling the host/hid_controller example from tinyusb (modified by setting CFG_TUH_HUB to 1), GET_DESCRIPTOR times out when connecting devices via USB hub.
When I use tinyusb within my platformio project (which uses framework-arduino-samd for device initialization), devices connected via HUBs work without any issues.

I've compared the runtime values of all registers that should matter for USB, but could not find any meaningful difference.
Nevertheless, I must have missed one or some, because HUB connections are always working with the arduino samd framework but never with the tinyusb example.

BIG EDIT:

Even tho I triple-checked, it might be possible that I am still not enabling the correct pin for power delivery since at that time I had no means of measuring it - and the failure description looks kinda like it.
I am using the same Sparkfun board as in my previous PR to add that board.

The (unfortunately board-dependent) code I've added for this can be found in my updated version of hw/bsp/samd21/family.c:

#if CFG_TUH_ENABLED
  #if defined(CFG_TUH_MAX3421) && CFG_TUH_MAX3421
    max3421_init();
  #else
    // VBUS Power
    gpio_set_pin_direction(PIN_PA28, GPIO_DIRECTION_OUT);
    gpio_set_pin_level(PIN_PA28, true);
  #endif
#endif

Hardcoded to PIN_PA28 because that is what I assumed to be the right pad that enables the host power delivery on my sparkfun board.

Hope I will have time in the near future to set everything up again and try an active USB hub to see if that is the issue, but I think that is one thing that should be improved before this PR is merged since it should support all kinds of boards.

@hathach
Copy link
Owner

hathach commented Apr 8, 2024

superb !! Thank you very much, let give me a bit of time for reviewing (still need to wrap up other work first).

@ChrisDeadman
Copy link
Contributor Author

ChrisDeadman commented Oct 20, 2024

Sorry that it has taken me so long time to rebase, but I did now. Also made some important edits to my initial comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants