From e5f4dba28e36ed1a95804d05a9710230a2413f47 Mon Sep 17 00:00:00 2001 From: kurte Date: Sat, 8 Feb 2025 14:38:24 -0800 Subject: [PATCH 01/12] Portenta H7: Add spis to overlay plus fix GPIOS This is a partial fix for: #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. --- loader/boards/arduino_portenta_h7_m7.conf | 2 + loader/boards/arduino_portenta_h7_m7.overlay | 42 ++++++++++++-------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/loader/boards/arduino_portenta_h7_m7.conf b/loader/boards/arduino_portenta_h7_m7.conf index acee48b1..1f624ad2 100644 --- a/loader/boards/arduino_portenta_h7_m7.conf +++ b/loader/boards/arduino_portenta_h7_m7.conf @@ -26,6 +26,8 @@ CONFIG_LLEXT_HEAP_SIZE=128 #CONFIG_ADC=y #CONFIG_PWM=y +CONFIG_SPI_ASYNC=y +CONFIG_SPI_STM32_INTERRUPT=y CONFIG_NET_CORE_LOG_LEVEL_DBG=y diff --git a/loader/boards/arduino_portenta_h7_m7.overlay b/loader/boards/arduino_portenta_h7_m7.overlay index d5f0aea8..c013ee43 100644 --- a/loader/boards/arduino_portenta_h7_m7.overlay +++ b/loader/boards/arduino_portenta_h7_m7.overlay @@ -25,6 +25,13 @@ status = "okay"; }; +&spi2 { + status = "okay"; + pinctrl-0 = <&spi2_sck_pi1 + &spi2_miso_pc2 &spi2_mosi_pc3>; + pinctrl-names = "default"; +}; + &rng { status = "okay"; }; @@ -66,22 +73,24 @@ / { zephyr,user { - digital-pin-gpios = <&gpioh 15 GPIO_ACTIVE_LOW>, - <&gpiok 1 GPIO_ACTIVE_LOW>, - <&gpioj 11 GPIO_ACTIVE_LOW>, - <&gpiog 7 GPIO_ACTIVE_LOW>, - <&gpioc 7 GPIO_ACTIVE_LOW>, - <&gpioc 6 GPIO_ACTIVE_LOW>, - <&gpioa 8 GPIO_ACTIVE_LOW>, - <&gpioi 0 GPIO_ACTIVE_LOW>, - <&gpioc 3 GPIO_ACTIVE_LOW>, - <&gpioi 1 GPIO_ACTIVE_LOW>, - <&gpioc 2 GPIO_ACTIVE_LOW>, - <&gpioh 8 GPIO_ACTIVE_LOW>, - <&gpioh 7 GPIO_ACTIVE_LOW>, - <&gpioa 10 GPIO_ACTIVE_LOW>, - <&gpioa 9 GPIO_ACTIVE_LOW>, - <&gpiok 5 GPIO_ACTIVE_LOW>; // LEDR + digital-pin-gpios = <&gpioh 15 0>, + <&gpiok 1 0>, + <&gpioj 11 0>, + <&gpiog 7 0>, + <&gpioc 7 0>, + <&gpioc 6 0>, + <&gpioa 8 0>, + <&gpioi 0 0>, + <&gpioc 3 0>, + <&gpioi 1 0>, + <&gpioc 2 0>, + <&gpioh 8 0>, + <&gpioh 7 0>, + <&gpioa 10 0>, + <&gpioa 9 0>, + <&gpiok 5 GPIO_ACTIVE_LOW>, // LEDR + <&gpiok 6 GPIO_ACTIVE_LOW>, + <&gpiok 7 GPIO_ACTIVE_LOW>; builtin-led-gpios = <&gpiok 5 GPIO_ACTIVE_LOW>, <&gpiok 6 GPIO_ACTIVE_LOW>, @@ -90,5 +99,6 @@ serials = <&cdc_acm_uart0>,<&usart6>, <&usart1>, <&uart4>; cdc-acm = <&cdc_acm_uart0>; i2cs = <&i2c4>; + spis = <&spi2>; }; }; From 56b9506e88c6c518fce096c30dab52a25212fdd0 Mon Sep 17 00:00:00 2001 From: kurte Date: Sat, 8 Feb 2025 15:52:17 -0800 Subject: [PATCH 02/12] Update arduino_portenta_h7_m7.overlay 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 --- loader/boards/arduino_portenta_h7_m7.overlay | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/loader/boards/arduino_portenta_h7_m7.overlay b/loader/boards/arduino_portenta_h7_m7.overlay index c013ee43..125f2bed 100644 --- a/loader/boards/arduino_portenta_h7_m7.overlay +++ b/loader/boards/arduino_portenta_h7_m7.overlay @@ -21,6 +21,14 @@ status = "okay"; }; +&i2c3 { + status = "okay"; +}; + +&i2c1 { + status = "okay"; +}; + &i2c4 { status = "okay"; }; @@ -98,7 +106,7 @@ serials = <&cdc_acm_uart0>,<&usart6>, <&usart1>, <&uart4>; cdc-acm = <&cdc_acm_uart0>; - i2cs = <&i2c4>; + i2cs = <&i2c3>, <&i2c1>, <&i2c4>; spis = <&spi2>; }; }; From c0de1e36c2bb433998f666dac5c10d4e3c44c94a Mon Sep 17 00:00:00 2001 From: kurte Date: Mon, 10 Feb 2025 05:37:32 -0800 Subject: [PATCH 03/12] Portenta H7: update digital-pin-gpios to be same as MBED version --- loader/boards/arduino_portenta_h7_m7.overlay | 202 ++++++++++++++++++- 1 file changed, 197 insertions(+), 5 deletions(-) diff --git a/loader/boards/arduino_portenta_h7_m7.overlay b/loader/boards/arduino_portenta_h7_m7.overlay index 125f2bed..f4204f76 100644 --- a/loader/boards/arduino_portenta_h7_m7.overlay +++ b/loader/boards/arduino_portenta_h7_m7.overlay @@ -50,6 +50,16 @@ zephyr,shell-uart = &usart6; zephyr,cdc-acm-uart0 = &usart6; }; + + /* used to overcome problems with _C analog pins */ + gpioz: gpio@deadbeef { + compatible = "vnd,gpio"; + gpio-controller; + reg = <0xdeadbeef 0x1000>; + #gpio-cells = <0x2>; + status = "okay"; + }; + }; / { @@ -81,7 +91,7 @@ / { zephyr,user { - digital-pin-gpios = <&gpioh 15 0>, + digital-pin-gpios = <&gpioh 15 0>, /* D0 */ <&gpiok 1 0>, <&gpioj 11 0>, <&gpiog 7 0>, @@ -95,10 +105,192 @@ <&gpioh 8 0>, <&gpioh 7 0>, <&gpioa 10 0>, - <&gpioa 9 0>, - <&gpiok 5 GPIO_ACTIVE_LOW>, // LEDR - <&gpiok 6 GPIO_ACTIVE_LOW>, - <&gpiok 7 GPIO_ACTIVE_LOW>; + <&gpioa 9 0>, /* D14 */ + + <&gpioz 0 0>, /* A0 ADC2_INP0 */ + <&gpioz 1 0>, /* A1 ADC2_INP1 */ + <&gpioz 2 0>, /* A2 ADC3_INP0 */ + <&gpioz 3 0>, /* A3 ADC3_INP1 */ + <&gpioc 2 0>, /* A4 _ALT0? ADC1_INP12 */ + <&gpioc 3 0>, /* A5 _ALT0? ADC1_INP13 */ + <&gpioa 4 0>, /* A6 ADC1_INP18 */ + <&gpioa 6 0>, /* A7 ADC1_INP7 */ + + + <&gpiok 5 GPIO_ACTIVE_LOW>, // LEDR + <&gpiok 6 GPIO_ACTIVE_LOW>, // LEDG + <&gpiok 7 GPIO_ACTIVE_LOW>, // LEDB + + <&gpioa 0 0>, + <&gpioa 1 0>, + <&gpioa 2 0>, + <&gpioa 3 0>, + <&gpioa 4 0>, + <&gpioa 5 0>, + <&gpioa 6 0>, + <&gpioa 7 0>, + <&gpioa 8 0>, + <&gpioa 9 0>, + <&gpioa 10 0>, + <&gpioa 11 0>, + <&gpioa 12 0>, + <&gpioa 13 0>, + <&gpioa 14 0>, + <&gpioa 15 0>, + <&gpiob 0 0>, + <&gpiob 1 0>, + <&gpiob 2 0>, + <&gpiob 3 0>, + <&gpiob 4 0>, + <&gpiob 5 0>, + <&gpiob 6 0>, + <&gpiob 7 0>, + <&gpiob 8 0>, + <&gpiob 9 0>, + <&gpiob 10 0>, + <&gpiob 11 0>, + <&gpiob 12 0>, + <&gpiob 13 0>, + <&gpiob 14 0>, + <&gpiob 15 0>, + <&gpioc 0 0>, + <&gpioc 1 0>, + <&gpioc 2 0>, + <&gpioc 3 0>, + <&gpioc 4 0>, + <&gpioc 5 0>, + <&gpioc 6 0>, + <&gpioc 7 0>, + <&gpioc 8 0>, + <&gpioc 9 0>, + <&gpioc 10 0>, + <&gpioc 11 0>, + <&gpioc 12 0>, + <&gpioc 13 0>, + <&gpioc 14 0>, + <&gpioc 15 0>, + <&gpiod 0 0>, + <&gpiod 1 0>, + <&gpiod 2 0>, + <&gpiod 3 0>, + <&gpiod 4 0>, + <&gpiod 5 0>, + <&gpiod 6 0>, + <&gpiod 7 0>, + <&gpiod 8 0>, + <&gpiod 9 0>, + <&gpiod 10 0>, + <&gpiod 11 0>, + <&gpiod 12 0>, + <&gpiod 13 0>, + <&gpiod 14 0>, + <&gpiod 15 0>, + <&gpioe 0 0>, + <&gpioe 1 0>, + <&gpioe 2 0>, + <&gpioe 3 0>, + <&gpioe 4 0>, + <&gpioe 5 0>, + <&gpioe 6 0>, + <&gpioe 7 0>, + <&gpioe 8 0>, + <&gpioe 9 0>, + <&gpioe 10 0>, + <&gpioe 11 0>, + <&gpioe 12 0>, + <&gpioe 13 0>, + <&gpioe 14 0>, + <&gpioe 15 0>, + <&gpiof 0 0>, + <&gpiof 1 0>, + <&gpiof 2 0>, + <&gpiof 3 0>, + <&gpiof 4 0>, + <&gpiof 5 0>, + <&gpiof 6 0>, + <&gpiof 7 0>, + <&gpiof 8 0>, + <&gpiof 9 0>, + <&gpiof 10 0>, + <&gpiof 11 0>, + <&gpiof 12 0>, + <&gpiof 13 0>, + <&gpiof 14 0>, + <&gpiof 15 0>, + <&gpiog 0 0>, + <&gpiog 1 0>, + <&gpiog 2 0>, + <&gpiog 3 0>, + <&gpiog 4 0>, + <&gpiog 5 0>, + <&gpiog 6 0>, + <&gpiog 7 0>, + <&gpiog 8 0>, + <&gpiog 9 0>, + <&gpiog 10 0>, + <&gpiog 11 0>, + <&gpiog 12 0>, + <&gpiog 13 0>, + <&gpiog 14 0>, + <&gpiog 15 0>, + <&gpioh 0 0>, + <&gpioh 1 0>, + <&gpioh 2 0>, + <&gpioh 3 0>, + <&gpioh 4 0>, + <&gpioh 5 0>, + <&gpioh 6 0>, + <&gpioh 7 0>, + <&gpioh 8 0>, + <&gpioh 9 0>, + <&gpioh 10 0>, + <&gpioh 11 0>, + <&gpioh 12 0>, + <&gpioh 13 0>, + <&gpioh 14 0>, + <&gpioh 15 0>, + <&gpioi 0 0>, + <&gpioi 1 0>, + <&gpioi 2 0>, + <&gpioi 3 0>, + <&gpioi 4 0>, + <&gpioi 5 0>, + <&gpioi 6 0>, + <&gpioi 7 0>, + <&gpioi 8 0>, + <&gpioi 9 0>, + <&gpioi 10 0>, + <&gpioi 11 0>, + <&gpioi 12 0>, + <&gpioi 13 0>, + <&gpioi 14 0>, + <&gpioi 15 0>, + <&gpioj 0 0>, + <&gpioj 1 0>, + <&gpioj 2 0>, + <&gpioj 3 0>, + <&gpioj 4 0>, + <&gpioj 5 0>, + <&gpioj 6 0>, + <&gpioj 7 0>, + <&gpioj 8 0>, + <&gpioj 9 0>, + <&gpioj 10 0>, + <&gpioj 11 0>, + <&gpioj 12 0>, + <&gpioj 13 0>, + <&gpioj 14 0>, + <&gpioj 15 0>, + <&gpiok 0 0>, + <&gpiok 1 0>, + <&gpiok 2 0>, + <&gpiok 3 0>, + <&gpiok 4 0>, + <&gpiok 5 0>, + <&gpiok 6 0>, + <&gpiok 7 0>; + + builtin-led-gpios = <&gpiok 5 GPIO_ACTIVE_LOW>, <&gpiok 6 GPIO_ACTIVE_LOW>, From 7da8a97f929041dc1c7183a59218882bd7ed5e88 Mon Sep 17 00:00:00 2001 From: kurte Date: Wed, 12 Feb 2025 06:57:49 -0800 Subject: [PATCH 04/12] Update arduino_portenta_h7_m7.conf to enable memc resolves: #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 --- loader/boards/arduino_portenta_h7_m7.conf | 2 ++ loader/boards/arduino_portenta_h7_m7.overlay | 8 ++++++++ 2 files changed, 10 insertions(+) diff --git a/loader/boards/arduino_portenta_h7_m7.conf b/loader/boards/arduino_portenta_h7_m7.conf index 1f624ad2..d148b1b1 100644 --- a/loader/boards/arduino_portenta_h7_m7.conf +++ b/loader/boards/arduino_portenta_h7_m7.conf @@ -26,6 +26,8 @@ CONFIG_LLEXT_HEAP_SIZE=128 #CONFIG_ADC=y #CONFIG_PWM=y +CONFIG_DMA=y +CONFIG_MEMC=y CONFIG_SPI_ASYNC=y CONFIG_SPI_STM32_INTERRUPT=y diff --git a/loader/boards/arduino_portenta_h7_m7.overlay b/loader/boards/arduino_portenta_h7_m7.overlay index f4204f76..a03190d0 100644 --- a/loader/boards/arduino_portenta_h7_m7.overlay +++ b/loader/boards/arduino_portenta_h7_m7.overlay @@ -40,6 +40,14 @@ pinctrl-names = "default"; }; +&dmamux1 { + status = "okay"; +}; + +&dma1 { + status = "okay"; +}; + &rng { status = "okay"; }; From c2f829ba9c6daaa460ac172e686573828182f214 Mon Sep 17 00:00:00 2001 From: kurte Date: Sat, 22 Feb 2025 10:51:44 -0800 Subject: [PATCH 05/12] Portenta H7M7 support for analogWrite/analogRead @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 --- cores/arduino/zephyrCommon.cpp | 34 ++- loader/boards/arduino_portenta_h7_m7.conf | 4 +- loader/boards/arduino_portenta_h7_m7.overlay | 203 +++++++++++++++++- .../arduino_portenta_h7/pure_analog_pins.cpp | 17 ++ .../arduino_portenta_h7/pure_analog_pins.h | 57 +++++ variants/arduino_portenta_h7/variant.h | 1 + 6 files changed, 300 insertions(+), 16 deletions(-) create mode 100644 variants/arduino_portenta_h7/pure_analog_pins.cpp create mode 100644 variants/arduino_portenta_h7/pure_analog_pins.h diff --git a/cores/arduino/zephyrCommon.cpp b/cores/arduino/zephyrCommon.cpp index 4dd834cf..3263d8d2 100644 --- a/cores/arduino/zephyrCommon.cpp +++ b/cores/arduino/zephyrCommon.cpp @@ -140,6 +140,29 @@ const struct pwm_dt_spec arduino_pwm[] = { DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), pwms, PWM_DT_SPEC) }; /* pwm-pins node provides a mapping digital pin numbers to pwm channels */ +#if 1 +static const struct gpio_dt_spec arduino_pwm_pins[] = {DT_FOREACH_PROP_ELEM_SEP( + DT_PATH(zephyr_user), pwm_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))}; + +size_t pwm_pin_index(pin_size_t pinNumber) { + printk("pwm_pin_index: %u: ", pinNumber); + if (pinNumber >= ARRAY_SIZE(arduino_pins)) { + return (size_t)-1; + } + printk("(%p %u):", arduino_pins[pinNumber].port, arduino_pins[pinNumber].pin); + for(size_t i=0; i; + + pwm1: pwm { + status = "okay"; + pinctrl-0 = <&tim1_ch1_pk1 &tim1_ch2_pj11>; + pinctrl-names = "default"; + }; }; -&dma1 { +&timers3 { + status = "okay"; + st,prescaler = <100>; + + pwm3: pwm { + status = "okay"; + pinctrl-0 = <&tim3_ch1_pc6 &tim3_ch2_pc7>; + pinctrl-names = "default"; + }; +}; + +&timers8 { + status = "okay"; + st,prescaler = <100>; + + pwm8: pwm { + status = "okay"; + pinctrl-0 = <&tim8_ch3n_ph15 &tim8_ch2_pj10 &tim8_ch2n_pj7>; + pinctrl-names = "default"; + }; +}; + +&timers12 { status = "okay"; + st,prescaler = <100>; + + pwm12: pwm { + status = "okay"; + pinctrl-0 = <&tim12_ch1_ph6>; + pinctrl-names = "default"; + }; +}; + +&pwm1 { + /* Use the pwmclock node to start the clock generation */ + pwmclock: pwmclock { + status = "okay"; + compatible = "pwm-clock"; + clock-frequency = <0>; + #clock-cells = <1>; + pwms = <&pwm1 2 PWM_HZ(12000000) PWM_POLARITY_NORMAL>; + }; }; &rng { status = "okay"; }; +&dmamux1 { + status = "okay"; +}; + +&dma1 { + status = "okay"; +}; + + +&adc1 { + pinctrl-0 = <&adc1_inp12_pc2 + &adc1_inp13_pc3 + &adc1_inp18_pa4 + &adc1_inp3_pa6 + &adc1_inp0_pa0_c + &adc1_inp1_pa1_c>; + pinctrl-names = "default"; + st,adc-clock-source = ; + st,adc-prescaler = <4>; + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + + channel@c { + reg = <12>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <16>; + }; + channel@d { + reg = <13>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <16>; + }; + channel@12 { + reg = <18>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <16>; + }; + channel@3 { + reg = <3>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <16>; + }; + + /* PA0_C and PA1_C */ + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <16>; + }; + channel@1 { + reg = <1>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <16>; + }; +}; + +&adc3 { + pinctrl-0 = <&adc3_inp0_pc2_c + &adc3_inp1_pc3_c>; + pinctrl-names = "default"; + st,adc-clock-source = ; + st,adc-prescaler = <4>; + status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + + channel@0 { + reg = <0>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <16>; + }; + channel@1 { + reg = <1>; + zephyr,gain = "ADC_GAIN_1"; + zephyr,reference = "ADC_REF_INTERNAL"; + zephyr,acquisition-time = ; + zephyr,resolution = <16>; + }; +}; + + / { chosen { zephyr,console = &usart6; @@ -293,20 +438,60 @@ <&gpiok 1 0>, <&gpiok 2 0>, <&gpiok 3 0>, - <&gpiok 4 0>, - <&gpiok 5 0>, - <&gpiok 6 0>, - <&gpiok 7 0>; + <&gpiok 4 0>; + + /* commented out for now to allow LEDs to work + /* <&gpiok 5 0>, */ + /* <&gpiok 6 0>, */ + /* <&gpiok 7 0>; */ builtin-led-gpios = <&gpiok 5 GPIO_ACTIVE_LOW>, - <&gpiok 6 GPIO_ACTIVE_LOW>, - <&gpiok 7 GPIO_ACTIVE_LOW>; - + <&gpiok 6 GPIO_ACTIVE_LOW>, + <&gpiok 7 GPIO_ACTIVE_LOW>; + + pwm-pin-gpios = //<&gpioa 8 0>, + <&gpioc 6 0>, + <&gpioc 7 0>, + //<&gpiog 7 0>, + <&gpioj 11 0>, + <&gpiok 1 0>, + <&gpioh 15 0>, + <&gpioj 7 0>, + <&gpioj 10 0>, + <&gpioh 6 0>; + + adc-pin-gpios = <&gpioz 0 0>, /* analog only */ + <&gpioz 1 0>, /* analog only */ + <&gpioz 2 0>, /* analog only */ + <&gpioz 3 0>, /* analog only */ + <&gpioc 2 0>, + <&gpioc 3 0>, + <&gpioa 4 0>, + <&gpioa 6 0>; + serials = <&cdc_acm_uart0>,<&usart6>, <&usart1>, <&uart4>; cdc-acm = <&cdc_acm_uart0>; i2cs = <&i2c3>, <&i2c1>, <&i2c4>; spis = <&spi2>; + pwms = //<&pwm8 1 PWM_HZ(500) PWM_POLARITY_NORMAL>, + <&pwm3 1 PWM_HZ(500) PWM_POLARITY_NORMAL>, + <&pwm3 2 PWM_HZ(500) PWM_POLARITY_NORMAL>, + <&pwm1 2 PWM_HZ(12000000) PWM_POLARITY_NORMAL>, + <&pwm1 1 PWM_HZ(5000) PWM_POLARITY_NORMAL>, + <&pwm8 1 PWM_HZ(500) PWM_POLARITY_INVERTED>, + <&pwm8 3 PWM_HZ(500) PWM_POLARITY_INVERTED>, + <&pwm8 2 PWM_HZ(500) PWM_POLARITY_NORMAL>, + <&pwm12 1 PWM_HZ(500) PWM_POLARITY_NORMAL>; + + io-channels = <&adc1 0>, + <&adc1 1>, + <&adc3 0>, + <&adc3 1>, + <&adc1 12>, + <&adc1 13>, + <&adc1 18>, + <&adc1 3>; }; }; diff --git a/variants/arduino_portenta_h7/pure_analog_pins.cpp b/variants/arduino_portenta_h7/pure_analog_pins.cpp new file mode 100644 index 00000000..83548487 --- /dev/null +++ b/variants/arduino_portenta_h7/pure_analog_pins.cpp @@ -0,0 +1,17 @@ +#include "pure_analog_pins.h" + +#undef A0 +#undef A1 +#undef A2 +#undef A3 + +PureAnalogPin A0_PURE(0); +PureAnalogPin A1_PURE(1); +PureAnalogPin A2_PURE(2); +PureAnalogPin A3_PURE(3); + +int getAnalogReadResolution(); + +int analogRead(PureAnalogPin pin) { + return ::analogRead(A0 + pin.get()); +} diff --git a/variants/arduino_portenta_h7/pure_analog_pins.h b/variants/arduino_portenta_h7/pure_analog_pins.h new file mode 100644 index 00000000..b949a069 --- /dev/null +++ b/variants/arduino_portenta_h7/pure_analog_pins.h @@ -0,0 +1,57 @@ +#ifndef _PURE_ANALOG_PINS_ +#define _PURE_ANALOG_PINS_ + +/****************************************************************************** + * INCLUDE + ******************************************************************************/ + +#include "Arduino.h" + +/****************************************************************************** + * PREPROCESSOR-MAGIC + ******************************************************************************/ + +#define PURE_ANALOG_AS_DIGITAL_ATTRIBUTE __attribute__ ((error("Can't use pins A0-A3 as digital"))) + +/****************************************************************************** + * TYPEDEF + ******************************************************************************/ + +class PureAnalogPin { +public: + PureAnalogPin(int _pin) : pin(_pin) {}; + int get() { + return pin; + }; + bool operator== (PureAnalogPin const & other) const { + return pin == other.pin; + } + //operator int() = delete; + __attribute__ ((error("Change me to a #define"))) operator int(); +private: + int pin; +}; + +extern PureAnalogPin A0_PURE; +extern PureAnalogPin A1_PURE; +extern PureAnalogPin A2_PURE; +extern PureAnalogPin A3_PURE; + +#define A0 A0_PURE +#define A1 A1_PURE +#define A2 A2_PURE +#define A3 A3_PURE + +/****************************************************************************** + * FUNCTION DECLARATION + ******************************************************************************/ + +void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE pinMode (PureAnalogPin pin, PinMode mode); +PinStatus PURE_ANALOG_AS_DIGITAL_ATTRIBUTE digitalRead (PureAnalogPin pin); +void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE digitalWrite(PureAnalogPin pin, PinStatus value); +int analogRead (PureAnalogPin pin); +void PURE_ANALOG_AS_DIGITAL_ATTRIBUTE analogWrite (PureAnalogPin pin, int value); + +#undef PURE_ANALOG_AS_DIGITAL_ATTRIBUTE + +#endif /* _PURE_ANALOG_PINS_ */ diff --git a/variants/arduino_portenta_h7/variant.h b/variants/arduino_portenta_h7/variant.h index 68c33a89..9c1abf2e 100644 --- a/variants/arduino_portenta_h7/variant.h +++ b/variants/arduino_portenta_h7/variant.h @@ -3,6 +3,7 @@ * * SPDX-License-Identifier: Apache-2.0 */ +#include "pure_analog_pins.h" // TODO: correctly handle these legacy defines #define MOSI 0 From 6cb0bf27f4a75a83c97856d326ad43966e82b900 Mon Sep 17 00:00:00 2001 From: kurte Date: Sat, 8 Mar 2025 05:48:33 -0800 Subject: [PATCH 06/12] Portenta H7M7 - Add Camera and port table Start of Pin names stuff --- loader/boards/arduino_portenta_h7_m7.conf | 15 + loader/boards/arduino_portenta_h7_m7.overlay | 335 +++++++++++-------- loader/fixups.c | 2 +- 3 files changed, 212 insertions(+), 140 deletions(-) diff --git a/loader/boards/arduino_portenta_h7_m7.conf b/loader/boards/arduino_portenta_h7_m7.conf index 69908494..567c7e2f 100644 --- a/loader/boards/arduino_portenta_h7_m7.conf +++ b/loader/boards/arduino_portenta_h7_m7.conf @@ -11,6 +11,9 @@ CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT=y CONFIG_LLEXT_STORAGE_WRITABLE=n +CONFIG_SHARED_MULTI_HEAP=y +CONFIG_HEAP_MEM_POOL_SIZE=2048 + CONFIG_FPU=y CONFIG_ICACHE=y CONFIG_DCACHE=y @@ -82,3 +85,15 @@ CONFIG_MBEDTLS_HEAP_SIZE=60000 CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=7168 CONFIG_MBEDTLS_HASH_ALL_ENABLED=y CONFIG_MBEDTLS_CMAC=y + + +CONFIG_VIDEO=y +CONFIG_VIDEO_LOG_LEVEL_DBG=y +CONFIG_VIDEO_STM32_DCMI=y +CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=3 +CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=614400 +CONFIG_VIDEO_BUFFER_POOL_ALIGN=32 +CONFIG_VIDEO_BUFFER_USE_SHARED_MULTI_HEAP=y +CONFIG_VIDEO_BUFFER_SMH_ATTRIBUTE=2 +CONFIG_VIDEO_GC2145=y +CONFIG_FLASH=y diff --git a/loader/boards/arduino_portenta_h7_m7.overlay b/loader/boards/arduino_portenta_h7_m7.overlay index 3a7a1786..3a96b7df 100644 --- a/loader/boards/arduino_portenta_h7_m7.overlay +++ b/loader/boards/arduino_portenta_h7_m7.overlay @@ -23,6 +23,22 @@ &i2c3 { status = "okay"; + gc2145: gc2145@3c { + compatible = "galaxycore,gc2145"; + reg = <0x3c>; + //ov7670: ov7670@21 { + // compatible = "ovti,ov7670"; + // reg = <0x21>; + reset-gpios = <&gpioe 3 GPIO_ACTIVE_LOW>; + pwdn-gpios = <&gpiod 5 GPIO_ACTIVE_LOW>; + + port { + gc2145_ep_out: endpoint { + //ov7670_ep_out: endpoint { + remote-endpoint = <&dcmi_ep_in>; + }; + }; + }; }; &i2c1 { @@ -46,7 +62,7 @@ pwm1: pwm { status = "okay"; - pinctrl-0 = <&tim1_ch1_pk1 &tim1_ch2_pj11>; + pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch2_pj11>; pinctrl-names = "default"; }; }; @@ -91,7 +107,8 @@ compatible = "pwm-clock"; clock-frequency = <0>; #clock-cells = <1>; - pwms = <&pwm1 2 PWM_HZ(12000000) PWM_POLARITY_NORMAL>; + pwms = <&pwm1 1 PWM_HZ(11000000) PWM_POLARITY_NORMAL>; + //12mhz for 7670, default is also 12MHz }; }; @@ -107,6 +124,33 @@ status = "okay"; }; +&dcmi { + status = "okay"; + sensor = <&gc2145>; + //sensor = <&ov7670>; + /* ext-sdram = <&sdram1>; */ + pinctrl-0 = <&dcmi_hsync_pa4 &dcmi_pixclk_pa6 &dcmi_vsync_pi5 + &dcmi_d0_ph9 &dcmi_d1_ph10 &dcmi_d2_ph11 &dcmi_d3_ph12 + &dcmi_d4_ph14 &dcmi_d5_pi4 &dcmi_d6_pi6 &dcmi_d7_pi7>; + pinctrl-names = "default"; + bus-width = <8>; + hsync-active = <0>; + vsync-active = <0>; + pixelclk-active = <0>; + capture-rate = <1>; + dmas = <&dma1 0 75 (STM32_DMA_PERIPH_TO_MEMORY | STM32_DMA_PERIPH_NO_INC | + STM32_DMA_MEM_INC | STM32_DMA_PERIPH_32BITS | STM32_DMA_MEM_32BITS | + STM32_DMA_PRIORITY_HIGH) STM32_DMA_FIFO_FULL>; + //FULL for 7670, default FIFO_1_4 + + port { + dcmi_ep_in: endpoint { + remote-endpoint = <&gc2145_ep_out>; + //remote-endpoint = <&ov7670_ep_out>; + }; + }; +}; + &adc1 { pinctrl-0 = <&adc1_inp12_pc2 @@ -199,6 +243,7 @@ / { chosen { + zephyr,camera = &dcmi; zephyr,console = &usart6; zephyr,shell-uart = &usart6; zephyr,cdc-acm-uart0 = &usart6; @@ -245,19 +290,19 @@ / { zephyr,user { digital-pin-gpios = <&gpioh 15 0>, /* D0 */ - <&gpiok 1 0>, - <&gpioj 11 0>, - <&gpiog 7 0>, - <&gpioc 7 0>, - <&gpioc 6 0>, - <&gpioa 8 0>, - <&gpioi 0 0>, - <&gpioc 3 0>, - <&gpioi 1 0>, - <&gpioc 2 0>, - <&gpioh 8 0>, - <&gpioh 7 0>, - <&gpioa 10 0>, + <&gpiok 1 0>, /* D1 */ + <&gpioj 11 0>, /* D2 */ + <&gpiog 7 0>, /* D3 */ + <&gpioc 7 0>, /* D4 */ + <&gpioc 6 0>, /* D5 */ + <&gpioa 8 0>, /* D6 */ + <&gpioi 0 0>, /* D7 */ + <&gpioc 3 0>, /* D8 */ + <&gpioi 1 0>, /* D9 */ + <&gpioc 2 0>, /* D10 */ + <&gpioh 8 0>, /* D11 */ + <&gpioh 7 0>, /* D12 */ + <&gpioa 10 0>, /* D13 */ <&gpioa 9 0>, /* D14 */ <&gpioz 0 0>, /* A0 ADC2_INP0 */ @@ -275,135 +320,135 @@ <&gpiok 7 GPIO_ACTIVE_LOW>, // LEDB <&gpioa 0 0>, - <&gpioa 1 0>, - <&gpioa 2 0>, - <&gpioa 3 0>, - <&gpioa 4 0>, - <&gpioa 5 0>, - <&gpioa 6 0>, - <&gpioa 7 0>, - <&gpioa 8 0>, - <&gpioa 9 0>, - <&gpioa 10 0>, + /* <&gpioa 1 0>, */ + /* <&gpioa 2 0>, */ + /* <&gpioa 3 0>, */ + /* D21 <&gpioa 4 0>, */ + /* <&gpioa 5 0>, */ + /* D22 <&gpioa 6 0>, */ + /* <&gpioa 7 0>, */ + /* D6 <&gpioa 8 0>, */ + /* D14<&gpioa 9 0>, */ + /* D13 <&gpioa 10 0>, */ <&gpioa 11 0>, <&gpioa 12 0>, <&gpioa 13 0>, <&gpioa 14 0>, - <&gpioa 15 0>, - <&gpiob 0 0>, - <&gpiob 1 0>, + /* <&gpioa 15 0>, */ + /* <&gpiob 0 0>, */ + /* <&gpiob 1 0>, */ <&gpiob 2 0>, <&gpiob 3 0>, <&gpiob 4 0>, - <&gpiob 5 0>, + /* <&gpiob 5 0>, */ <&gpiob 6 0>, <&gpiob 7 0>, <&gpiob 8 0>, <&gpiob 9 0>, - <&gpiob 10 0>, - <&gpiob 11 0>, - <&gpiob 12 0>, - <&gpiob 13 0>, + /* <&gpiob 10 0>, */ + /* <&gpiob 11 0>, */ + /* <&gpiob 12 0>, */ + /* <&gpiob 13 0>, */ <&gpiob 14 0>, <&gpiob 15 0>, - <&gpioc 0 0>, - <&gpioc 1 0>, - <&gpioc 2 0>, - <&gpioc 3 0>, - <&gpioc 4 0>, - <&gpioc 5 0>, - <&gpioc 6 0>, - <&gpioc 7 0>, - <&gpioc 8 0>, - <&gpioc 9 0>, - <&gpioc 10 0>, - <&gpioc 11 0>, - <&gpioc 12 0>, + /* <&gpioc 0 0>, */ + /* <&gpioc 1 0>, */ + /* D10 <&gpioc 2 0>, */ + /* D8 <&gpioc 3 0>, */ + /* <&gpioc 4 0>, */ + /* <&gpioc 5 0>, */ + /* D5<&gpioc 6 0>, */ + /* D4<&gpioc 7 0>, */ + /* <&gpioc 8 0>, */ + /* <&gpioc 9 0>, */ + /* <&gpioc 10 0>, */ + /* <&gpioc 11 0>, */ + /* <&gpioc 12 0>, */ <&gpioc 13 0>, - <&gpioc 14 0>, + /* <&gpioc 14 0>, */ <&gpioc 15 0>, - <&gpiod 0 0>, - <&gpiod 1 0>, - <&gpiod 2 0>, + /* <&gpiod 0 0>, */ + /* <&gpiod 1 0>, */ + /* <&gpiod 2 0>, */ <&gpiod 3 0>, <&gpiod 4 0>, <&gpiod 5 0>, <&gpiod 6 0>, <&gpiod 7 0>, - <&gpiod 8 0>, - <&gpiod 9 0>, - <&gpiod 10 0>, - <&gpiod 11 0>, - <&gpiod 12 0>, - <&gpiod 13 0>, - <&gpiod 14 0>, - <&gpiod 15 0>, - <&gpioe 0 0>, - <&gpioe 1 0>, + /* <&gpiod 8 0>, */ + /* <&gpiod 9 0>, */ + /* <&gpiod 10 0>, */ + /* <&gpiod 11 0>, */ + /* <&gpiod 12 0>, */ + /* <&gpiod 13 0>, */ + /* <&gpiod 14 0>, */ + /* <&gpiod 15 0>, */ + /* <&gpioe 0 0>, */ + /* <&gpioe 1 0>, */ <&gpioe 2 0>, <&gpioe 3 0>, - <&gpioe 4 0>, - <&gpioe 5 0>, - <&gpioe 6 0>, - <&gpioe 7 0>, - <&gpioe 8 0>, - <&gpioe 9 0>, - <&gpioe 10 0>, - <&gpioe 11 0>, - <&gpioe 12 0>, - <&gpioe 13 0>, - <&gpioe 14 0>, - <&gpioe 15 0>, - <&gpiof 0 0>, - <&gpiof 1 0>, - <&gpiof 2 0>, - <&gpiof 3 0>, - <&gpiof 4 0>, - <&gpiof 5 0>, - <&gpiof 6 0>, - <&gpiof 7 0>, - <&gpiof 8 0>, - <&gpiof 9 0>, - <&gpiof 10 0>, - <&gpiof 11 0>, - <&gpiof 12 0>, - <&gpiof 13 0>, - <&gpiof 14 0>, - <&gpiof 15 0>, - <&gpiog 0 0>, - <&gpiog 1 0>, - <&gpiog 2 0>, + /* <&gpioe 4 0>, */ + /* <&gpioe 5 0>, */ + /* <&gpioe 6 0>, */ + /* <&gpioe 7 0>, */ + /* <&gpioe 8 0>, */ + /* <&gpioe 9 0>, */ + /* <&gpioe 10 0>, */ + /* <&gpioe 11 0>, */ + /* <&gpioe 12 0>, */ + /* <&gpioe 13 0>, */ + /* <&gpioe 14 0>, */ + /* <&gpioe 15 0>, */ + /* <&gpiof 0 0>, */ + /* <&gpiof 1 0>, */ + /* <&gpiof 2 0>, */ + /* <&gpiof 3 0>, */ + /* <&gpiof 4 0>, */ + /* <&gpiof 5 0>, */ + /* <&gpiof 6 0>, */ + /* <&gpiof 7 0>, */ + /* <&gpiof 8 0>, */ + /* <&gpiof 9 0>, */ + /* <&gpiof 10 0>, */ + /* <&gpiof 11 0>, */ + /* <&gpiof 12 0>, */ + /* <&gpiof 13 0>, */ + /* <&gpiof 14 0>, */ + /* <&gpiof 15 0>, */ + /* <&gpiog 0 0>, */ + /* <&gpiog 1 0>, */ + /* <&gpiog 2 0>, */ <&gpiog 3 0>, - <&gpiog 4 0>, - <&gpiog 5 0>, - <&gpiog 6 0>, - <&gpiog 7 0>, - <&gpiog 8 0>, + /* <&gpiog 4 0>, */ + /* <&gpiog 5 0>, */ + /* <&gpiog 6 0>, */ + /* D3 <&gpiog 7 0>, */ + /* <&gpiog 8 0>, */ <&gpiog 9 0>, <&gpiog 10 0>, - <&gpiog 11 0>, - <&gpiog 12 0>, - <&gpiog 13 0>, + /* <&gpiog 11 0>, */ + /* <&gpiog 12 0>, */ + /* <&gpiog 13 0>, */ <&gpiog 14 0>, - <&gpiog 15 0>, - <&gpioh 0 0>, - <&gpioh 1 0>, - <&gpioh 2 0>, - <&gpioh 3 0>, - <&gpioh 4 0>, - <&gpioh 5 0>, + /* <&gpiog 15 0>, */ + /* <&gpioh 0 0>, */ + /* <&gpioh 1 0>, */ + /* <&gpioh 2 0>, */ + /* <&gpioh 3 0>, */ + /* <&gpioh 4 0>, */ + /* <&gpioh 5 0>, */ <&gpioh 6 0>, - <&gpioh 7 0>, - <&gpioh 8 0>, + /* D12 <&gpioh 7 0>, */ + /* D11 <&gpioh 8 0>, */ <&gpioh 9 0>, <&gpioh 10 0>, <&gpioh 11 0>, <&gpioh 12 0>, <&gpioh 13 0>, <&gpioh 14 0>, - <&gpioh 15 0>, - <&gpioi 0 0>, - <&gpioi 1 0>, + /* D0 <&gpioh 15 0>, */ + /* D7 <&gpioi 0 0>, */ + /* D9<&gpioi 1 0>, */ <&gpioi 2 0>, <&gpioi 3 0>, <&gpioi 4 0>, @@ -413,37 +458,38 @@ <&gpioi 8 0>, <&gpioi 9 0>, <&gpioi 10 0>, - <&gpioi 11 0>, - <&gpioi 12 0>, + /* <&gpioi 11 0>, */ + /* <&gpioi 12 0>, */ <&gpioi 13 0>, <&gpioi 14 0>, <&gpioi 15 0>, - <&gpioj 0 0>, - <&gpioj 1 0>, - <&gpioj 2 0>, - <&gpioj 3 0>, - <&gpioj 4 0>, - <&gpioj 5 0>, + /* <&gpioj 0 0>, */ + /* <&gpioj 1 0>, */ + /* <&gpioj 2 0>, */ + /* <&gpioj 3 0>, */ + /* <&gpioj 4 0>, */ + /* <&gpioj 5 0>, */ <&gpioj 6 0>, <&gpioj 7 0>, <&gpioj 8 0>, <&gpioj 9 0>, - <&gpioj 10 0>, - <&gpioj 11 0>, - <&gpioj 12 0>, - <&gpioj 13 0>, - <&gpioj 14 0>, - <&gpioj 15 0>, - <&gpiok 0 0>, - <&gpiok 1 0>, - <&gpiok 2 0>, - <&gpiok 3 0>, - <&gpiok 4 0>; + <&gpioj 10 0>; + /* D2 <&gpioj 11 0>, */ + /* <&gpioj 12 0>, */ + /* <&gpioj 13 0>, */ + /* <&gpioj 14 0>, */ + /* <&gpioj 15 0>, */ + /* <&gpiok 0 0>, */ + /* D1 <&gpiok 1 0>; */ + + /* <&gpiok 2 0>, */ + /* <&gpiok 3 0>, */ + /* <&gpiok 4 0>; */ /* commented out for now to allow LEDs to work - /* <&gpiok 5 0>, */ - /* <&gpiok 6 0>, */ - /* <&gpiok 7 0>; */ + /* LEDR <&gpiok 5 0>, */ + /* LEDG <&gpiok 6 0>, */ + /* LEDB <&gpiok 7 0>; */ @@ -451,16 +497,28 @@ <&gpiok 6 GPIO_ACTIVE_LOW>, <&gpiok 7 GPIO_ACTIVE_LOW>; - pwm-pin-gpios = //<&gpioa 8 0>, + pwm-pin-gpios = <&gpioa 8 0>, <&gpioc 6 0>, <&gpioc 7 0>, //<&gpiog 7 0>, <&gpioj 11 0>, - <&gpiok 1 0>, + //<&gpiok 1 0>, <&gpioh 15 0>, <&gpioj 7 0>, <&gpioj 10 0>, <&gpioh 6 0>; + + port-pin-gpios = <&gpioa 0 0>, + <&gpiob 0 0>, + <&gpioc 0 0>, + <&gpiod 0 0>, + <&gpioe 0 0>, + <&gpiof 0 0>, + <&gpiog 0 0>, + <&gpioh 0 0>, + <&gpioi 0 0>, + <&gpioj 0 0>, + <&gpiok 0 0>; adc-pin-gpios = <&gpioz 0 0>, /* analog only */ <&gpioz 1 0>, /* analog only */ @@ -475,13 +533,12 @@ cdc-acm = <&cdc_acm_uart0>; i2cs = <&i2c3>, <&i2c1>, <&i2c4>; spis = <&spi2>; - pwms = //<&pwm8 1 PWM_HZ(500) PWM_POLARITY_NORMAL>, + pwms = <&pwm1 1 PWM_HZ(11000000) PWM_POLARITY_NORMAL>, //12mhz default <&pwm3 1 PWM_HZ(500) PWM_POLARITY_NORMAL>, <&pwm3 2 PWM_HZ(500) PWM_POLARITY_NORMAL>, - <&pwm1 2 PWM_HZ(12000000) PWM_POLARITY_NORMAL>, - <&pwm1 1 PWM_HZ(5000) PWM_POLARITY_NORMAL>, - <&pwm8 1 PWM_HZ(500) PWM_POLARITY_INVERTED>, + <&pwm1 2 PWM_HZ(5000) PWM_POLARITY_NORMAL>, <&pwm8 3 PWM_HZ(500) PWM_POLARITY_INVERTED>, + <&pwm8 2 PWM_HZ(500) PWM_POLARITY_INVERTED>, <&pwm8 2 PWM_HZ(500) PWM_POLARITY_NORMAL>, <&pwm12 1 PWM_HZ(500) PWM_POLARITY_NORMAL>; diff --git a/loader/fixups.c b/loader/fixups.c index aca88c15..34934642 100644 --- a/loader/fixups.c +++ b/loader/fixups.c @@ -39,7 +39,7 @@ SYS_INIT(disable_bootloader_mpu, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAU SYS_INIT(disable_mpu_rasr_xn, PRE_KERNEL_1, CONFIG_KERNEL_INIT_PRIORITY_DEFAULT); #endif -#if defined(CONFIG_BOARD_ARDUINO_GIGA_R1) && defined(CONFIG_VIDEO) +#if (defined(CONFIG_BOARD_ARDUINO_GIGA_R1) || defined(CONFIG_BOARD_ARDUINO_PORTENTA_H7)) && defined(CONFIG_VIDEO) #include #include #include From a0b41d69da36ccd728a98d56c176f9ec8149d458 Mon Sep 17 00:00:00 2001 From: kurte Date: Sat, 8 Mar 2025 07:07:18 -0800 Subject: [PATCH 07/12] Portenta H7: First cut add PinNames to the H7M7 variant 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? --- variants/arduino_portenta_h7/PinNames.cpp | 61 +++++ variants/arduino_portenta_h7/PinNames.h | 308 ++++++++++++++++++++++ variants/arduino_portenta_h7/variant.h | 1 + 3 files changed, 370 insertions(+) create mode 100644 variants/arduino_portenta_h7/PinNames.cpp create mode 100644 variants/arduino_portenta_h7/PinNames.h diff --git a/variants/arduino_portenta_h7/PinNames.cpp b/variants/arduino_portenta_h7/PinNames.cpp new file mode 100644 index 00000000..3ddffb75 --- /dev/null +++ b/variants/arduino_portenta_h7/PinNames.cpp @@ -0,0 +1,61 @@ +#include +#include "zephyrInternal.h" +#include "PinNames.h" + +// duplicate of one in zephyr common +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, (, )) }; + +static const struct gpio_dt_spec arduino_ports[] = { DT_FOREACH_PROP_ELEM_SEP( + DT_PATH(zephyr_user), port_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, )) }; + + +void pinMode(PinName pinNumber, PinMode mode) { + // See if the pinName maps to a real pin number if so use the pin number version + int pin_index = PinNameToIndex(pinNumber); + if (pin_index != -1) { + // this will grab any settings out of the device tree. + pinMode((pin_size_t)pin_index, mode); + return; + } + + if (mode == INPUT) { // input mode + gpio_pin_configure(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf, + GPIO_INPUT | GPIO_ACTIVE_HIGH); + } else if (mode == INPUT_PULLUP) { // input with internal pull-up + gpio_pin_configure(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf, + GPIO_INPUT | GPIO_PULL_UP | GPIO_ACTIVE_HIGH); + } else if (mode == INPUT_PULLDOWN) { // input with internal pull-down + gpio_pin_configure(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf, + GPIO_INPUT | GPIO_PULL_DOWN | GPIO_ACTIVE_HIGH); + } else if (mode == OUTPUT) { // output mode + gpio_pin_configure(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf, + GPIO_OUTPUT_LOW | GPIO_ACTIVE_HIGH); + } +} + +void digitalWrite(PinName pinNumber, PinStatus status) { + gpio_pin_set(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf, status); +} + + +int PinNameToIndex(PinName P) { + for (size_t i = 0; i < ARRAY_SIZE(arduino_pins); i++) { + if ((arduino_ports[P >> 4].port == arduino_pins[i].port) && ((P & 0xf) == arduino_pins[i].pin)) { + return i; + } + } + return -1; +} + +PinName digitalPinToPinName(pin_size_t P) { + if (P < ARRAY_SIZE(arduino_pins)) { + // Convert the pins port into an index into our port's list + for (uint8_t port_index = 0; port_index < ARRAY_SIZE(arduino_ports); port_index++) { + if (arduino_pins[P].port == arduino_ports[port_index].port) { + return (PinName)((port_index << 4) | arduino_pins[P].pin); + } + } + } + return PinName::NC; +} diff --git a/variants/arduino_portenta_h7/PinNames.h b/variants/arduino_portenta_h7/PinNames.h new file mode 100644 index 00000000..40a0eaa3 --- /dev/null +++ b/variants/arduino_portenta_h7/PinNames.h @@ -0,0 +1,308 @@ + +#ifndef ZEPHYR_PINNAMES_H +#define ZEPHYR_PINNAMES_H + +#ifdef __cplusplus +extern "C" { +#endif + +typedef enum { + PA_0 = 0x00, + PA_1 = 0x01, + PA_2 = 0x02, + PA_3 = 0x03, + PA_4 = 0x04, + PA_5 = 0x05, + PA_6 = 0x06, + PA_7 = 0x07, + PA_8 = 0x08, + PA_9 = 0x09, + PA_10 = 0x0A, + PA_11 = 0x0B, + PA_12 = 0x0C, + PA_13 = 0x0D, + PA_14 = 0x0E, + PA_15 = 0x0F, + PB_0 = 0x10, + PB_1 = 0x11, + PB_2 = 0x12, + PB_3 = 0x13, + PB_4 = 0x14, + PB_5 = 0x15, + PB_6 = 0x16, + PB_7 = 0x17, + PB_8 = 0x18, + PB_9 = 0x19, + PB_10 = 0x1A, + PB_11 = 0x1B, + PB_12 = 0x1C, + PB_13 = 0x1D, + PB_14 = 0x1E, + PB_15 = 0x1F, + PC_0 = 0x20, + PC_1 = 0x21, + PC_2 = 0x22, + PC_3 = 0x23, + PC_4 = 0x24, + PC_5 = 0x25, + PC_6 = 0x26, + PC_7 = 0x27, + PC_8 = 0x28, + PC_9 = 0x29, + PC_10 = 0x2A, + PC_11 = 0x2B, + PC_12 = 0x2C, + PC_13 = 0x2D, + PC_14 = 0x2E, + PC_15 = 0x2F, + PD_0 = 0x30, + PD_1 = 0x31, + PD_2 = 0x32, + PD_3 = 0x33, + PD_4 = 0x34, + PD_5 = 0x35, + PD_6 = 0x36, + PD_7 = 0x37, + PD_8 = 0x38, + PD_9 = 0x39, + PD_10 = 0x3A, + PD_11 = 0x3B, + PD_12 = 0x3C, + PD_13 = 0x3D, + PD_14 = 0x3E, + PD_15 = 0x3F, + PE_0 = 0x40, + PE_1 = 0x41, + PE_2 = 0x42, + PE_3 = 0x43, + PE_4 = 0x44, + PE_5 = 0x45, + PE_6 = 0x46, + PE_7 = 0x47, + PE_8 = 0x48, + PE_9 = 0x49, + PE_10 = 0x4A, + PE_11 = 0x4B, + PE_12 = 0x4C, + PE_13 = 0x4D, + PE_14 = 0x4E, + PE_15 = 0x4F, + PF_0 = 0x50, + PF_1 = 0x51, + PF_2 = 0x52, + PF_3 = 0x53, + PF_4 = 0x54, + PF_5 = 0x55, + PF_6 = 0x56, + PF_7 = 0x57, + PF_8 = 0x58, + PF_9 = 0x59, + PF_10 = 0x5A, + PF_11 = 0x5B, + PF_12 = 0x5C, + PF_13 = 0x5D, + PF_14 = 0x5E, + PF_15 = 0x5F, + PG_0 = 0x60, + PG_1 = 0x61, + PG_2 = 0x62, + PG_3 = 0x63, + PG_4 = 0x64, + PG_5 = 0x65, + PG_6 = 0x66, + PG_7 = 0x67, + PG_8 = 0x68, + PG_9 = 0x69, + PG_10 = 0x6A, + PG_11 = 0x6B, + PG_12 = 0x6C, + PG_13 = 0x6D, + PG_14 = 0x6E, + PG_15 = 0x6F, + PH_0 = 0x70, + PH_1 = 0x71, + PH_2 = 0x72, + PH_3 = 0x73, + PH_4 = 0x74, + PH_5 = 0x75, + PH_6 = 0x76, + PH_7 = 0x77, + PH_8 = 0x78, + PH_9 = 0x79, + PH_10 = 0x7A, + PH_11 = 0x7B, + PH_12 = 0x7C, + PH_13 = 0x7D, + PH_14 = 0x7E, + PH_15 = 0x7F, + PI_0 = 0x80, + PI_1 = 0x81, + PI_2 = 0x82, + PI_3 = 0x83, + PI_4 = 0x84, + PI_5 = 0x85, + PI_6 = 0x86, + PI_7 = 0x87, + PI_8 = 0x88, + PI_9 = 0x89, + PI_10 = 0x8A, + PI_11 = 0x8B, + PI_12 = 0x8C, + PI_13 = 0x8D, + PI_14 = 0x8E, + PI_15 = 0x8F, + PJ_0 = 0x90, + PJ_1 = 0x91, + PJ_2 = 0x92, + PJ_3 = 0x93, + PJ_4 = 0x94, + PJ_5 = 0x95, + PJ_6 = 0x96, + PJ_7 = 0x97, + PJ_8 = 0x98, + PJ_9 = 0x99, + PJ_10 = 0x9A, + PJ_11 = 0x9B, + PJ_12 = 0x9C, + PJ_13 = 0x9D, + PJ_14 = 0x9E, + PJ_15 = 0x9F, + PK_0 = 0xA0, + PK_1 = 0xA1, + PK_2 = 0xA2, + PK_3 = 0xA3, + PK_4 = 0xA4, + PK_5 = 0xA5, + PK_6 = 0xA6, + PK_7 = 0xA7, + + WL_REG_ON = PJ_1, + WL_HOST_WAKE = PJ_5, + WL_SDIO_0 = PC_8, + WL_SDIO_1 = PC_9, + WL_SDIO_2 = PC_10, + WL_SDIO_3 = PC_11, + WL_SDIO_CMD = PD_2, + WL_SDIO_CLK = PC_12, + + /**** ADC internal channels ****/ + + ADC_TEMP = 0xF0, // Internal pin virtual value + ADC_VREF = 0xF1, // Internal pin virtual value + ADC_VBAT = 0xF2, // Internal pin virtual value + + //Led mappings + LED_RED = PK_5, //Red + LED_GREEN = PK_6, //Green + LED_BLUE = PK_7, //Blue + + CYBSP_BT_UART_RX = PF_6, + CYBSP_BT_UART_TX = PA_15, + CYBSP_BT_UART_RTS = PF_8, + CYBSP_BT_UART_CTS = PF_9, + + CYBSP_BT_POWER = PJ_12, + CYBSP_BT_HOST_WAKE = PJ_13, + CYBSP_BT_DEVICE_WAKE = PJ_14, + + /**** QSPI FLASH pins ****/ + QSPI_FLASH1_IO0 = PD_11, + QSPI_FLASH1_IO1 = PD_12, + QSPI_FLASH1_IO2 = PF_7, + QSPI_FLASH1_IO3 = PD_13, + QSPI_FLASH1_SCK = PF_10, + QSPI_FLASH1_CSN = PG_6, + + /**** USB FS pins ****/ + USB_OTG_FS_DM = PA_11, + USB_OTG_FS_DP = PA_12, + USB_OTG_FS_ID = PA_10, + USB_OTG_FS_SOF = PA_8, + USB_OTG_FS_VBUS = PA_9, + + /**** USB HS pins ****/ + USB_OTG_HS_DM = PB_14, + USB_OTG_HS_DP = PB_15, + USB_OTG_HS_ID = PB_12, + USB_OTG_HS_SOF = PA_4, + USB_OTG_HS_ULPI_CK = PA_5, + USB_OTG_HS_ULPI_D0 = PA_3, + USB_OTG_HS_ULPI_D1 = PB_0, + USB_OTG_HS_ULPI_D2 = PB_1, + USB_OTG_HS_ULPI_D3 = PB_10, + USB_OTG_HS_ULPI_D4 = PB_11, + USB_OTG_HS_ULPI_D5 = PB_12, + USB_OTG_HS_ULPI_D6 = PB_13, + USB_OTG_HS_ULPI_D7 = PB_5, + USB_OTG_HS_ULPI_DIR = PC_2, + USB_OTG_HS_ULPI_NXT = PC_3, + USB_OTG_HS_ULPI_STP = PC_0, + USB_OTG_HS_VBUS = PB_13, + + /**** ETHERNET pins ****/ + ETH_MDC = PC_1, + ETH_MDIO = PA_2, + ETH_CRS_DV = PA_7, + ETH_REF_CLK = PA_1, + ETH_RXD0 = PC_4, + ETH_RXD1 = PC_5, + ETH_RX_CLK = PA_1, + ETH_TXD0 = PG_13, + ETH_TXD1 = PG_12, + ETH_TX_EN = PG_11, + + /**** OSCILLATOR pins ****/ + RCC_OSC32_IN = PC_14, + RCC_OSC32_OUT = PC_15, + RCC_OSC_IN = PH_0, + RCC_OSC_OUT = PH_1, + + /**** DEBUG pins ****/ + SYS_JTCK_SWCLK = PA_14, + SYS_JTDI = PA_15, + SYS_JTDO_SWO = PB_3, + SYS_JTMS_SWDIO = PA_13, + SYS_JTRST = PB_4, + SYS_PVD_IN = PB_7, + SYS_TRACECLK = PE_2, + SYS_TRACED0 = PE_3, + SYS_TRACED0_ALT0 = PC_1, + SYS_TRACED0_ALT1 = PG_13, + SYS_TRACED1 = PE_4, + SYS_TRACED1_ALT0 = PC_8, + SYS_TRACED1_ALT1 = PG_14, + SYS_TRACED2 = PE_5, + SYS_TRACED2_ALT0 = PD_2, + SYS_TRACED3 = PE_6, + SYS_TRACED3_ALT0 = PC_12, + SYS_TRGIO = PC_7, + SYS_WKUP0 = PA_0, + SYS_WKUP1 = PA_2, + SYS_WKUP2 = PC_13, + SYS_WKUP5 = PC_1, + + // Not connected + NC = (int)0xFFFFFFFF +} PinName; + +// Standardized LED and button names +#define LED1 LED_RED +#define LED2 LED_GREEN +#define LED3 LED_BLUE +#define BUTTON1 PC_13 + + + +#ifdef __cplusplus + +} + +// overloads - only cpp as c does not allow overloads of functions +void pinMode(PinName pinNumber, PinMode mode); +void digitalWrite(PinName pinNumber, PinStatus status); +int PinNameToIndex(PinName P); +PinName digitalPinToPinName(pin_size_t P); + +#endif + +#endif diff --git a/variants/arduino_portenta_h7/variant.h b/variants/arduino_portenta_h7/variant.h index 9c1abf2e..336ffa3d 100644 --- a/variants/arduino_portenta_h7/variant.h +++ b/variants/arduino_portenta_h7/variant.h @@ -4,6 +4,7 @@ * SPDX-License-Identifier: Apache-2.0 */ #include "pure_analog_pins.h" +#include "PinNames.h" // TODO: correctly handle these legacy defines #define MOSI 0 From 438dae9bd46fbfb797c6357c037e90868ce69388 Mon Sep 17 00:00:00 2001 From: kurte Date: Sat, 8 Mar 2025 12:07:55 -0800 Subject: [PATCH 08/12] PinName: digitalRead, analogRead, analogWrite Added a few more override functions. Brings up questions, with the analog ones. More on the PR --- variants/arduino_portenta_h7/PinNames.cpp | 26 +++++++++++++++++++++++ variants/arduino_portenta_h7/PinNames.h | 3 +++ 2 files changed, 29 insertions(+) diff --git a/variants/arduino_portenta_h7/PinNames.cpp b/variants/arduino_portenta_h7/PinNames.cpp index 3ddffb75..19bb4340 100644 --- a/variants/arduino_portenta_h7/PinNames.cpp +++ b/variants/arduino_portenta_h7/PinNames.cpp @@ -39,6 +39,32 @@ void digitalWrite(PinName pinNumber, PinStatus status) { } +PinStatus digitalRead(PinName pinNumber) { + return (gpio_pin_get(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf) == 1) ? HIGH : LOW; +} + +int analogRead(PinName pinNumber) { + // Not sure what to do here, does anyone do something like: + // analogRead(PA_0c); or analogRead(PC2_ALT0)? + // first pass only support ones on pins. + int pin_index = PinNameToIndex(pinNumber); + if (pin_index != -1) { + return analogRead(pin_index); + } + return -1; +} + + +void analogWrite(PinName pinNumber, int value) { + // first pass only support ones on pins. + int pin_index = PinNameToIndex(pinNumber); + if (pin_index != -1) { + analogWrite(pin_index, value); + } +} + + + int PinNameToIndex(PinName P) { for (size_t i = 0; i < ARRAY_SIZE(arduino_pins); i++) { if ((arduino_ports[P >> 4].port == arduino_pins[i].port) && ((P & 0xf) == arduino_pins[i].pin)) { diff --git a/variants/arduino_portenta_h7/PinNames.h b/variants/arduino_portenta_h7/PinNames.h index 40a0eaa3..b446c232 100644 --- a/variants/arduino_portenta_h7/PinNames.h +++ b/variants/arduino_portenta_h7/PinNames.h @@ -302,6 +302,9 @@ void pinMode(PinName pinNumber, PinMode mode); void digitalWrite(PinName pinNumber, PinStatus status); int PinNameToIndex(PinName P); PinName digitalPinToPinName(pin_size_t P); +PinStatus digitalRead(PinName pinNumber); +int analogRead(PinName pinNumber); +void analogWrite(PinName pinNumber, int value); #endif From ab555f7e4ba90e4b730e76cd0e338fd5f2b292f6 Mon Sep 17 00:00:00 2001 From: kurte Date: Sun, 9 Mar 2025 16:23:06 -0700 Subject: [PATCH 09/12] H7: Add in Dual pads into pin names --- variants/arduino_portenta_h7/PinNames.cpp | 17 +++++++++++++++++ variants/arduino_portenta_h7/PinNames.h | 9 +++++++++ 2 files changed, 26 insertions(+) diff --git a/variants/arduino_portenta_h7/PinNames.cpp b/variants/arduino_portenta_h7/PinNames.cpp index 19bb4340..7969d619 100644 --- a/variants/arduino_portenta_h7/PinNames.cpp +++ b/variants/arduino_portenta_h7/PinNames.cpp @@ -19,6 +19,8 @@ void pinMode(PinName pinNumber, PinMode mode) { return; } + if (pinNumber & DUAL_PAD) return; + if (mode == INPUT) { // input mode gpio_pin_configure(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf, GPIO_INPUT | GPIO_ACTIVE_HIGH); @@ -35,11 +37,13 @@ void pinMode(PinName pinNumber, PinMode mode) { } void digitalWrite(PinName pinNumber, PinStatus status) { + if (pinNumber & DUAL_PAD) return; gpio_pin_set(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf, status); } PinStatus digitalRead(PinName pinNumber) { + if (pinNumber & DUAL_PAD) return LOW; return (gpio_pin_get(arduino_ports[pinNumber >> 4].port, pinNumber & 0xf) == 1) ? HIGH : LOW; } @@ -47,8 +51,19 @@ int analogRead(PinName pinNumber) { // Not sure what to do here, does anyone do something like: // analogRead(PA_0c); or analogRead(PC2_ALT0)? // first pass only support ones on pins. + if (pinNumber & DUAL_PAD) { + switch (pinNumber & 0xf) { + case 0: Serial.print(""); return analogRead(A0); + case 1: Serial.print(""); return analogRead(A1); + case 2: Serial.print(""); return analogRead(A2); + case 3: Serial.print(""); return analogRead(A3); + default: return -1; + } + + } int pin_index = PinNameToIndex(pinNumber); if (pin_index != -1) { + Serial.write('<'); Serial.print(pin_index); Serial.write('>'); return analogRead(pin_index); } return -1; @@ -57,6 +72,7 @@ int analogRead(PinName pinNumber) { void analogWrite(PinName pinNumber, int value) { // first pass only support ones on pins. + if (pinNumber & DUAL_PAD) return; int pin_index = PinNameToIndex(pinNumber); if (pin_index != -1) { analogWrite(pin_index, value); @@ -66,6 +82,7 @@ void analogWrite(PinName pinNumber, int value) { int PinNameToIndex(PinName P) { + if (P & DUAL_PAD) return -1; for (size_t i = 0; i < ARRAY_SIZE(arduino_pins); i++) { if ((arduino_ports[P >> 4].port == arduino_pins[i].port) && ((P & 0xf) == arduino_pins[i].pin)) { return i; diff --git a/variants/arduino_portenta_h7/PinNames.h b/variants/arduino_portenta_h7/PinNames.h index b446c232..826ac0fa 100644 --- a/variants/arduino_portenta_h7/PinNames.h +++ b/variants/arduino_portenta_h7/PinNames.h @@ -6,6 +6,8 @@ extern "C" { #endif +#define DUAL_PAD 0x800 + typedef enum { PA_0 = 0x00, PA_1 = 0x01, @@ -176,6 +178,13 @@ typedef enum { PK_6 = 0xA6, PK_7 = 0xA7, + // Lets add the Analog only pins, will name them like the schematic, but number like + PA_0C = 0X00 | DUAL_PAD, + PA_1C = 0X01 | DUAL_PAD, + PC_2C = 0X02 | DUAL_PAD, + PC_3C = 0X03 | DUAL_PAD, + + WL_REG_ON = PJ_1, WL_HOST_WAKE = PJ_5, WL_SDIO_0 = PC_8, From 40f8554568214e09ca5d7edf30bc2516b2863b5c Mon Sep 17 00:00:00 2001 From: kurte Date: Sun, 9 Mar 2025 16:45:06 -0700 Subject: [PATCH 10/12] Update PinNames.cpp Remove debug Serial.print --- variants/arduino_portenta_h7/PinNames.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/variants/arduino_portenta_h7/PinNames.cpp b/variants/arduino_portenta_h7/PinNames.cpp index 7969d619..57676699 100644 --- a/variants/arduino_portenta_h7/PinNames.cpp +++ b/variants/arduino_portenta_h7/PinNames.cpp @@ -53,17 +53,16 @@ int analogRead(PinName pinNumber) { // first pass only support ones on pins. if (pinNumber & DUAL_PAD) { switch (pinNumber & 0xf) { - case 0: Serial.print(""); return analogRead(A0); - case 1: Serial.print(""); return analogRead(A1); - case 2: Serial.print(""); return analogRead(A2); - case 3: Serial.print(""); return analogRead(A3); + case 0: return analogRead(A0); + case 1: return analogRead(A1); + case 2: return analogRead(A2); + case 3: return analogRead(A3); default: return -1; } } int pin_index = PinNameToIndex(pinNumber); if (pin_index != -1) { - Serial.write('<'); Serial.print(pin_index); Serial.write('>'); return analogRead(pin_index); } return -1; From 2469431837f09b03b4a7eaae0c491a3ef019ccdd Mon Sep 17 00:00:00 2001 From: kurte Date: Tue, 11 Mar 2025 08:23:03 -0700 Subject: [PATCH 11/12] Hack the two pins for A4 and A5 to say they are Z pins 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 --- loader/boards/arduino_portenta_h7_m7.overlay | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/loader/boards/arduino_portenta_h7_m7.overlay b/loader/boards/arduino_portenta_h7_m7.overlay index 3a96b7df..138e1a48 100644 --- a/loader/boards/arduino_portenta_h7_m7.overlay +++ b/loader/boards/arduino_portenta_h7_m7.overlay @@ -309,8 +309,10 @@ <&gpioz 1 0>, /* A1 ADC2_INP1 */ <&gpioz 2 0>, /* A2 ADC3_INP0 */ <&gpioz 3 0>, /* A3 ADC3_INP1 */ - <&gpioc 2 0>, /* A4 _ALT0? ADC1_INP12 */ - <&gpioc 3 0>, /* A5 _ALT0? ADC1_INP13 */ + <&gpioz 4 0>, /* A4 hack for duplicate PC_2 */ + <&gpioz 5 0>, /* A5 hack for duplicate PC_3 */ + /* <&gpioc 2 0>, A4 _ALT0? ADC1_INP12 */ + /* <&gpioc 3 0>, A5 _ALT0? ADC1_INP13 */ <&gpioa 4 0>, /* A6 ADC1_INP18 */ <&gpioa 6 0>, /* A7 ADC1_INP7 */ From 22624b5d784a67c41776291f746e0cde833bddde Mon Sep 17 00:00:00 2001 From: kurte Date: Tue, 11 Mar 2025 11:29:07 -0700 Subject: [PATCH 12/12] H7 - ADC hack for D19,D20 --- loader/boards/arduino_portenta_h7_m7.overlay | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/loader/boards/arduino_portenta_h7_m7.overlay b/loader/boards/arduino_portenta_h7_m7.overlay index 138e1a48..19654b02 100644 --- a/loader/boards/arduino_portenta_h7_m7.overlay +++ b/loader/boards/arduino_portenta_h7_m7.overlay @@ -107,7 +107,7 @@ compatible = "pwm-clock"; clock-frequency = <0>; #clock-cells = <1>; - pwms = <&pwm1 1 PWM_HZ(11000000) PWM_POLARITY_NORMAL>; + pwms = <&pwm1 1 PWM_HZ(12000000) PWM_POLARITY_NORMAL>; //12mhz for 7670, default is also 12MHz }; }; @@ -529,13 +529,15 @@ <&gpioc 2 0>, <&gpioc 3 0>, <&gpioa 4 0>, - <&gpioa 6 0>; + <&gpioa 6 0>, + <&gpioz 4 0>, /* Hack for D19 */ + <&gpioz 5 0>; /* Hack for D20 */ serials = <&cdc_acm_uart0>,<&usart6>, <&usart1>, <&uart4>; cdc-acm = <&cdc_acm_uart0>; i2cs = <&i2c3>, <&i2c1>, <&i2c4>; spis = <&spi2>; - pwms = <&pwm1 1 PWM_HZ(11000000) PWM_POLARITY_NORMAL>, //12mhz default + pwms = <&pwm1 1 PWM_HZ(12000000) PWM_POLARITY_NORMAL>, //12mhz default <&pwm3 1 PWM_HZ(500) PWM_POLARITY_NORMAL>, <&pwm3 2 PWM_HZ(500) PWM_POLARITY_NORMAL>, <&pwm1 2 PWM_HZ(5000) PWM_POLARITY_NORMAL>, @@ -551,6 +553,8 @@ <&adc1 12>, <&adc1 13>, <&adc1 18>, - <&adc1 3>; + <&adc1 3>, + <&adc1 12>, /* Hack for D19 */ + <&adc1 13>; /* Hack for D20 */ }; };