-
-
Notifications
You must be signed in to change notification settings - Fork 14
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
Portenta H7: Add spi and wire objects to overlay - Plus smaller GPIO pin list and PinNames #82
Conversation
This is a partial fix for: arduino#68 the spis line was not in the zephyr,user { section of the ovleray file. I added it with one entry: spis = <&spi2>; Updated: the GPIO table, that only the LEDS should be defined with GPIO_ACTIVE_LOW.
Added in the other two Wire objects to match the MBED version. i2cs = <&i2c3>, <&i2c1>, <&i2c4>; I checked it out with simple wire scanner sketch that checks Wire, Wire1 and Wire2. And then tried adding QWIIC Button first to the I2C0 section of breakout board and it was found on Wire. Moved it to I2C1 section and found with Wire1 and then moved to I2C2 section and found on Wire2
resolves: arduino#74 needed to add: CONFIG_MEMC=y to have the SDRAM enabled and as such not fault if you do anything with the SDRAM library. Also enabled CONFIG_DMA=y As not sure if that was needed but is in the GIGA .conf file Update arduino_portenta_h7_m7.overlay Add dma sections to remove the build warnings
@mjs513 and I added/modified the device tree for this board, with the tables to support PWM (analogWrite) and analogRead on some of the Analog pins. Note: there are some issues with A4/A5 in that those pins are also on the same pins that support SPI. And when SPI is enabled, the GPIOC pin configuration is setup by the device tree to be MODER to be set for Alternat function and their AF set to 5. The analogRead code does not does not update these tables and as such analogRead fails. We found that if y ou disable SPI then they work better. I currently left the SPI enabled. Probably need to add something that when analogRead is called that it updates the GPIO registers to make it work. I am ecurrently experimenting with a hack in my test sketch that appears to change the MODER of those pins back to 3, but so far that does not appear to be sufficent: ``` static const struct gpio_dt_spec arduino_pins[] = {DT_FOREACH_PROP_ELEM_SEP( DT_PATH(zephyr_user), digital_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))}; void pinModeAnalog(pin_size_t pinNumber) { gpio_pin_configure_dt(&arduino_pins[pinNumber], GPIO_INPUT /*| GPIO_ACTIVE_HIGH */ | GPIO_MODE_ANALOG); } ``` On the analogWrites, this code has optionally in place that allows duplicate pins in the device tree GPIO list, by changing how I read in the PWM table from the Tree, instead of summing all of the matches in the GPIO tree, it instead saves the GPIO Port and pin number and uses them for the compare. Again this depends on if we wish for the Pin numbers for the functions like digitalRead/digitalWrite to match those used by the MBED version. I still have the last 3 truncated K5-K7 which are used by the LEDs and fault but depending on directions, can find other solutions. enable spi2
Start of Pin names stuff
Note: the overload function definitions are in the PinNames.h PinNames.cpp - duplicates the pin table, as the main pin table is defined static within zephyrCommon.cpp Not sure if to move some up to there but sort of specific to Portenta H7 maybe X8, maybe GIGA... Also I sort of still have a lot of the MBED names within the pin names, Probably should be weeded out Maybe some place should define breakout board specific namings?
Added a few more override functions. Brings up questions, with the analog ones. More on the PR
Quick Update: Added some real default stuff for analogRead and analogWrite. so far ditto for analogRead - but I believe this shows, that we need to add items to the |
Quick update: I added in the Pin names like: PA_0C for analog on the complementary pins.
and the override readAnalog is sort of a hack. Could be better if some of the other tables and the like are exposed:
However I ran into a problem with some of the other pins, and debugging, this found same issue in doing a normal Analog Why? The PC_2 pin is duplicated on the Portenta H7. |
Remove debug Serial.print
This fixes issue where the constants A4 and A5 were computed as the sum of two pin numbers as PC_2 and PC_3 pins are duplicated on these boards. Note: accessing those pins directly by index like 18, 19 will probably not work
This is sort of a hand merge of PR arduino#82 which supersedes arduino#71 Adds in the SPI, Wire, Some Analog, some PWM, access to all of the pins. This has a reduced full pin table, but also introduced the use of pin names using slightly stripped down table that was used for MBED version
This is a replacement for PR: arduino#71 and arduino#82. All of the earlier commits were squashed into one. Then this was converted a few times during the arduino#85 pr time frame as things kept changing and moving around. It has now been updated to the released .3 version. I started off adding in the whole pin table as defined by the MBED version, which actually contained duplicate defines. I later reduced this set such that it now longer matches the MBED version, but does still include all of the pins that have external pins on some of the breakout boards. As for compatibility, most of the documentation for these show the PIN names and not numbers, so I imported the MBED Pin name table and have the start of allowing several different operations to be done, like pinMode, digitalWrite. We defined the additional SPI ports and Wire ports. We defined an initial setup for Analog pins. Have similar hack to GIGA version for pure Analog. Added additional hacks for duplicated pins. That is two of the analog Pins are the exact same pin as some other digital pins... Added some PWM support. Also added WIP: camera support. Co-Authored-By: Mike S <[email protected]>
replaced by #87 Converted to new layout and updated code with .3 release |
This is a replacement for PR: arduino#71 and arduino#82. All of the earlier commits were squashed into one. Then this was converted a few times during the arduino#85 pr time frame as things kept changing and moving around. It has now been updated to the released .3 version. I started off adding in the whole pin table as defined by the MBED version, which actually contained duplicate defines. I later reduced this set such that it now longer matches the MBED version, but does still include all of the pins that have external pins on some of the breakout boards. As for compatibility, most of the documentation for these show the PIN names and not numbers, so I imported the MBED Pin name table and have the start of allowing several different operations to be done, like pinMode, digitalWrite. We defined the additional SPI ports and Wire ports. We defined an initial setup for Analog pins. Have similar hack to GIGA version for pure Analog. Added additional hacks for duplicated pins. That is two of the analog Pins are the exact same pin as some other digital pins... Added some PWM support. Also added WIP: camera support. Co-Authored-By: Mike S <[email protected]>
This is a replacement for PR: arduino#71 and arduino#82. All of the earlier commits were squashed into one. Then this was converted a few times during the arduino#85 pr time frame as things kept changing and moving around. It has now been updated to the released .3 version. I started off adding in the whole pin table as defined by the MBED version, which actually contained duplicate defines. I later reduced this set such that it now longer matches the MBED version, but does still include all of the pins that have external pins on some of the breakout boards. As for compatibility, most of the documentation for these show the PIN names and not numbers, so I imported the MBED Pin name table and have the start of allowing several different operations to be done, like pinMode, digitalWrite. We defined the additional SPI ports and Wire ports. We defined an initial setup for Analog pins. Have similar hack to GIGA version for pure Analog. Added additional hacks for duplicated pins. That is two of the analog Pins are the exact same pin as some other digital pins... Added some PWM support. Also added WIP: camera support. Co-Authored-By: Mike S <[email protected]>
This is a replacement for PR: arduino#71 and arduino#82. All of the earlier commits were squashed into one. Then this was converted a few times during the arduino#85 pr time frame as things kept changing and moving around. It has now been updated to the released .3 version. I started off adding in the whole pin table as defined by the MBED version, which actually contained duplicate defines. I later reduced this set such that it now longer matches the MBED version, but does still include all of the pins that have external pins on some of the breakout boards. As for compatibility, most of the documentation for these show the PIN names and not numbers, so I imported the MBED Pin name table and have the start of allowing several different operations to be done, like pinMode, digitalWrite. We defined the additional SPI ports and Wire ports. We defined an initial setup for Analog pins. Have similar hack to GIGA version for pure Analog. Added additional hacks for duplicated pins. That is two of the analog Pins are the exact same pin as some other digital pins... Added some PWM support. Also added WIP: camera support. Co-Authored-By: Mike S <[email protected]>
This maybe resolves #68
And includes at least a partial implementation of the stuff I mentioned in the last few postings on that issue.
This is an alternative PR to #71
This is a combination PR from stuff that @mjs513 and I have done to start to flesh out the H7 variant.
There is now code/overlay/PWM and ...
This branch also added some WIP support for some different cameras. I believe it is currently configured in the
overlay and config file for the GC2145
Where this PR defers from the #71 is that the GPIO pin list has been reduced to the first 26 items plus any others
that are exported on the two High Density connectors that connect the board to the shields. In particular only those
that the exposed to the user on one or more plug in pins. Like all of them on the breakout board. Plus I then also
removed any of these which maps to the same GPIO port/pin as the ones in the first 26.
In addition, I then added a PinNames.h file to the Portenta H7_M7 variant, which has most of the entries that the same logical file had on the MBED version, but I stripped out all of those which had a | something like | ALT0 or | |DUAL_PAD.
So far I have added only a small subset of overloaded APIs that use these, like: pinMode, digitalWrite, plus the mapping functions
that map PinNameToindex and digitalPinToPinName. Soon will add a few more, like digitalRead.
As I mentioned in the issue, currently I am using a simple table I added to the overlay, that I can use to find the addresses
of the different objects like GPIOA, GPIOB...
Currently I have the overloaded function definitions at the end of the PinNames.h file in the variant.
Not sure what is the right way for Overloads specific to a subset of variants?
Likewise, I have all of that code currently in the variant in the PinNames.cpp. Which currently has it duplicating the GPIO table that is in zephyrCommon.cpp as that table is defined as static.
I started off with a simple test sketch which included tabs with the PinNames.h and .cpp files before I added them to this
PR branch.
The include of PinNames.h in this sketch is not necessary using this fork as I added the include in variants.h and the local tab has a check for the same #define so in this case it does nothing. I did add an extra define in the sketch one, such that the
sketches .cpp file will see this other define and not include any additional code.
As another test, I updated my version of my ILI9341 driver for Zephyr and if it sees that the Pin names file was included, it
add alternate constructors, which allows me to pass in PinNames for the CS, DC, and reset pins. If you pass in pin numbers it will convert those to PinNames. And I tried it out on my test sketch that tries to display a camera image onto the display.
The test sketches as well as the updated ILI9341 library are up in my github project:
https://github.com/KurtE/Arduino_GIGA-stuff
I probably will not add much more to this branch, until we have some feedback on if this is the going in an
appropriate direction.
Kurt