-
-
Notifications
You must be signed in to change notification settings - Fork 8.2k
stmhal: Add I2S support to make-pins.py #1362
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
0880bb0
to
d83d5a1
Compare
Looks okay, just 2 points:
|
@dpgeorge - The naming scheme for I2S stuff is a bit funny and inconsistent, which I think is a result of I2S not really being a first-class peripheral in the STM32F architecture. Specifically, in simplex (one-directional) operation, I2S is just a special configuration of SPI, and the HAL just uses SPIx rather than I2Sx as the instance name. For duplex operation, the hardware provides a second stripped-down SPI instance which can only be configured as a slave-mode I2S peripheral; this instance is named I2S(x)_ext in the HAL. |
TI seems to call the pins DX and RX rather than SD and extSD. I can change the AF's to be uppercase. I couldn't find any other examples, but I'm not realy familiar with i2S.
Yeah - I was just going with the flow on this count. If we decide to change thing, it feels more logical to do it as a separate patch. |
d83d5a1
to
cda6743
Compare
I changed extSD to EXTSD |
Ok, there is a problem: the constants MICROPY_HW_ENABLE_I2S2 and MICROPY_HW_ENABLE_I2S3 are not defined in any mpconfigboard.h files and are used as @blmorris are there any configuration values that are needed for I2S, or is it simply that it's enabled/disabled for a given board? If so we could just use For convenience in your i2s.c file you can optionally define MICROPY_HW_ENABLE_I2S, so it doesn't require too many changes. |
I do have the two values added together in mpconfigport.h to determine how many slots to reserve in the root pointer array, but I can find another way to do that. |
Hmm. I was relying on the fact that you can use: #if FOBAR and if FOOBAR isn't defined then its assumed to be zero. Or do we have some warning or something that's preventing that? I didn't run into any problems locally. Otherwise, I could have make-pins.py just wrap those like this:
|
GCC explicitly documents #if FOO where FOO is not defined at being legal: It looks like an explicit -Wundef would cause grief, but I'm not seeing that used anywhere. |
I'm just as happy to assume that MICROPY_HW_ENABLE_I2S2 and MICROPY_HW_ENABLE_I2S3 |
@dhylands you are right that it compiles ok as-is, but I'd rather keep it clean to prevent any unforseen errors. As you say, it's easy to just make it |
cda6743
to
e15ce61
Compare
ok - updated make-pins.py to output
if MICROPY_ENABLE_FOOBAR contains the word ENABLE, otherwise if just outputs:
if MICROPY_FOOBAR_SOMETHING_ELSE doesn't contain the work ENABLE @blmorris So this means that you should be able to leave MICROPY_HW_ENABLE_I2S2 #defined to a (0) or (1) and we don't need to define it everywhere else. The SPI macros already behave the same way. |
Thanks! Merged in 11115e4. |
@dhylands - Thanks for this! |
I think it makes sense to make the PIN_TYPE_xxx values unique as part of your patch, since this is where the function to use them would be introduced. |
But at least make them a separate commit. |
How about I make a separate PR that also adds a new |
If you need such a function for I2S then, yes, that sounds good. |
Yes, though ultimately it could offer a clean way for other peripherals to do what I am proposing for I2S, which is to take a list of pin names and configure the peripheral to use those pins after confirming that they will work. (You have a comment in |
This adds support for I2S pins (which adds 400 bytes to the image when I2S is enabled).
I also introduced the notion of conditional pins. For example, if MICROPY_HW_ENABLE_SPI3 is set to 0, then it won't define the alternate functions for SPI3.
The addition of conditional pins drops 264 bytes off the pyboard image (without I2S), and saves 92 bytes on the ESPRUINO_PICO image.