-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
samd: Allow using default devices for UART, I2C and SPI. #16735
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
Conversation
Code size report:
|
9400584
to
d12a801
Compare
aefc63d
to
92be84c
Compare
92be84c
to
dcec041
Compare
9abc2d4
to
8c21b89
Compare
If a board configures a default I2C instance and/or SCL/SDA pins, then these no longer need to be given in the constructor. This allows the user to easily construct the default I2C instance via `machine.I2C()` and that will work on the default pins as designated on the board silkscreen. Signed-off-by: robert-hh <robert@hammelrath.com>
If a board configures a default SPI instance and/or SCK/MOSI/MISO pins, then the user can create a default SPI object using `machine.SPI()`. Also, if MISO is not going to be used, then MISO can be set to `None` with `miso=None`. Signed-off-by: robert-hh <robert@hammelrath.com>
If a board configures a default UART instance and/or TX/RX pins then the user can create a default UART object using `machine.UART()`. Signed-off-by: robert-hh <robert@hammelrath.com>
These were missing and are needed to support UART/I2C/SPI default pins. Signed-off-by: robert-hh <robert@hammelrath.com>
In combination with the defautl Pins the default device can now be instantiated e.g. as: uart = UART(). Similar for I2C and SPI. Signed-off-by: robert-hh <robert@hammelrath.com>
Changes are: - Add the RX/TX pins to the table. In most cases these are the D0/D1 pins. - Document the ability for the instantiation of the default devices without submitting ID or pins. - Improve the example script creating the pin list to show multiple name assigments to the same pin. - Fix errors in the pinout document. Signed-off-by: robert-hh <robert@hammelrath.com>
8c21b89
to
016ae19
Compare
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.
Thanks for updating. I tested this on ADAFRUIT_ITSYBITSY_M0_EXPRESS and it works well.
I think this is a really nice improvement to the user experience, you no longer need to know about instance IDs to get started using the board. You can just create the default I2C/UART/SPI and it'll work correctly on the pins printed on the silkscreen. You only need to know about instance IDs if you want to delve deeper.
Thank you for your careful review and merging. Yes, it's more convenient now. I had to look up the ID numbers myself when testing with one of the rarely used boards. |
You're welcome! I did massage the commits a little before merging, because there were some review fix-ups in latter commits that belonged in earlier commits. |
Thank you. I noticed that and was confused at first. It looks better now. |
Summary
Some of the SAMD boards show pin names for UART, I2C and SPI on their silkscreen. At these
boards Pin name aliases existed already to use e.g. "SCL" or "TX" as pin name wherever a Pin had to be specified. This PR allows to omit the device ID and Pin definitions in the constructor if
the default device is going to be used. So the default UART, I2C or SPI device can be instantiated
with:
The documentation was updated accordingly to reflect the changes and fix bugs.
Testing
The change has been tested to return the proper device with:
Adafruit Feather M0
Adafruit Feather M4
Adafruit ItsyBitsy M0
Adafruit ItsyBitsy M4
Adafruit Metro Express M4
Adafruit Trinket M0
Adafruit QT PY
Seeed XIAO SAMD21
Seeed WIO terminal
Minisam M4
Sparkfun SAMD51 Thing plus
It has been tested to raise an error if the device is NOT fully specified with the SAMD Generic builds.