Get default Pins for Serial, SPI, I2C #7702
Replies: 7 comments 1 reply
-
That sounds like a good plan. On STM32 we have some functionality already that provides help if you use a pin that's not supported (in fact it's in the main Espruino codebase).
So you could just put a line in for ESP32 to do that? Although my understanding was on ESP32 you can generally use any hardware peripheral on any pin, it's just that some pins were marginally faster that others for very high speed stuff? It's not been an issue on nRF52 because any peripheral can go anywhere. We do also have documentation auto-generated for all the boards, eg https://www.espruino.com/ESP32#gpio-pins |
Beta Was this translation helpful? Give feedback.
-
Hmm, will take a closer look into these. One solution would be to ask the board for the pins. Thats what I tried first. |
Beta Was this translation helpful? Give feedback.
-
Actually one more thing I remembered which does exist, is So I believe right now you could iterate over all the pins in the board, something like:
And check that the function provided matches what you want - I think that works on everything. It actually makes a little more sense than |
Beta Was this translation helpful? Give feedback.
-
It was a kind of surprise to check your suggestion on an ESP32 board.
There are only a few lines. After digging through some scripts and sources,
the reason is in boards/ESP32.py
I've added some lines, see attached file.
Would be great if you could check my changes in attached file.
@mark, please take a closer look also
Am Di., 11. März 2025 um 14:09 Uhr schrieb Gordon Williams <
***@***.***>:
… Actually one more thing I remembered which does exist, is
pin.getInfo().functions
So I believe right now you could iterate over all the pins in the board,
something like:
for (var i=0;Pin(i);i++) print(Pin(i).getInfo().functions)
And check that the function provided matches what you want - I think that
works on everything. It actually makes a little more sense than
Serial1.getPins() because on devices like STM32, Serial1 can usually be
in *two* distinct places - so getPins would have to return an array anyway
—
Reply to this email directly, view it on GitHub
<#7702 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAPYNHQSGJRF2EURZCF7WNT2T3N77AVCNFSM6AAAAABYYKVPROVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTENBWGE3TGMA>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
-
Sorry, github doesn't like my uploaded file (?) |
Beta Was this translation helpful? Give feedback.
-
I'm not sure I understand why you changed UART1 to UART0 and re-ordered everything? I'm wondering whether actually you we using an out of date version of Espruino which didn't have those changes in? See the current one: https://github.com/espruino/Espruino/blob/master/boards/ESP32.py The current version already seems to contain most of this stuff and the UART0->1 change was because UART0 isn't valid - it was added 2 months ago and maybe your fork doesn't have the code? |
Beta Was this translation helpful? Give feedback.
-
Sorry, my fault, I was still working with V2_24. Thanks for guiding me back to the road. There is only one question left in ESP32.py, SERIAL2 or USART2 is missing. |
Beta Was this translation helpful? Give feedback.
-
I'm using Espruino on several boards.
Questions often coming up are like "which pins are TX/RX on Serial1"
My idea was to add a function to Serial Class for that "Serial1.getPins" that returns an object with tx, rx, ...
Got this running (tested on ESP32 only, yet).
Next step was to code something similiar for SPI and I2C, and failed. Found a way to getPins after calling setup only.
Any idea ?
Beta Was this translation helpful? Give feedback.
All reactions