Skip to content

Commit bf90218

Browse files
committed
Portenta H7: squashed commits - spi, wire, pins, adc, plus
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. H7 - ADC hack for D19,D20 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 Update PinNames.cpp Remove debug Serial.print H7: Add in Dual pads into pin names PinName: digitalRead, analogRead, analogWrite Added a few more override functions. Brings up questions, with the analog ones. More on the PR 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? Portenta H7M7 - Add Camera and port table Start of Pin names stuff 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 Update arduino_portenta_h7_m7.conf to enable memc 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 Portenta H7: update digital-pin-gpios to be same as MBED version 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
1 parent 7fdcd38 commit bf90218

File tree

9 files changed

+1035
-27
lines changed

9 files changed

+1035
-27
lines changed

cores/arduino/zephyrCommon.cpp

+29-5
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,29 @@ const struct pwm_dt_spec arduino_pwm[] =
140140
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), pwms, PWM_DT_SPEC) };
141141

142142
/* pwm-pins node provides a mapping digital pin numbers to pwm channels */
143+
#if 1
144+
static const struct gpio_dt_spec arduino_pwm_pins[] = {DT_FOREACH_PROP_ELEM_SEP(
145+
DT_PATH(zephyr_user), pwm_pin_gpios, GPIO_DT_SPEC_GET_BY_IDX, (, ))};
146+
147+
size_t pwm_pin_index(pin_size_t pinNumber) {
148+
printk("pwm_pin_index: %u: ", pinNumber);
149+
if (pinNumber >= ARRAY_SIZE(arduino_pins)) {
150+
return (size_t)-1;
151+
}
152+
printk("(%p %u):", arduino_pins[pinNumber].port, arduino_pins[pinNumber].pin);
153+
for(size_t i=0; i<ARRAY_SIZE(arduino_pwm_pins); i++) {
154+
printk(" [%p,%u]", arduino_pwm_pins[i].port, arduino_pwm_pins[i].pin);
155+
if ((arduino_pwm_pins[i].port == arduino_pins[pinNumber].port) && (arduino_pwm_pins[i].pin == arduino_pins[pinNumber].pin)) {
156+
printk("\n");
157+
return i;
158+
}
159+
}
160+
printk("\n");
161+
return (size_t)-1;
162+
}
163+
164+
165+
#else
143166
const pin_size_t arduino_pwm_pins[] =
144167
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), pwm_pin_gpios, PWM_PINS) };
145168
@@ -151,7 +174,7 @@ size_t pwm_pin_index(pin_size_t pinNumber) {
151174
}
152175
return (size_t)-1;
153176
}
154-
177+
#endif
155178
#endif //CONFIG_PWM
156179

157180
#ifdef CONFIG_ADC
@@ -293,12 +316,13 @@ void delay(unsigned long ms) { k_sleep(K_MSEC(ms)); }
293316
void delayMicroseconds(unsigned int us) { k_sleep(K_USEC(us)); }
294317

295318
unsigned long micros(void) {
319+
296320
#ifdef CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER
297-
return k_cyc_to_us_floor32(k_cycle_get_64());
321+
return k_cyc_to_us_floor32(k_cycle_get_64());
298322
#else
299-
return k_cyc_to_us_floor32(k_cycle_get_32());
300-
#endif
301-
}
323+
return k_cyc_to_us_floor32(k_cycle_get_32());
324+
#endif
325+
}
302326

303327
unsigned long millis(void) { return k_uptime_get_32(); }
304328

loader/boards/arduino_portenta_h7_m7.conf

+21-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ CONFIG_CDC_ACM_DTE_RATE_CALLBACK_SUPPORT=y
1111

1212
CONFIG_LLEXT_STORAGE_WRITABLE=n
1313

14+
CONFIG_SHARED_MULTI_HEAP=y
15+
CONFIG_HEAP_MEM_POOL_SIZE=2048
16+
1417
CONFIG_FPU=y
1518
CONFIG_ICACHE=y
1619
CONFIG_DCACHE=y
@@ -24,8 +27,12 @@ CONFIG_SHELL_STACK_SIZE=32768
2427
CONFIG_MAIN_STACK_SIZE=32768
2528
CONFIG_LLEXT_HEAP_SIZE=128
2629

27-
#CONFIG_ADC=y
28-
#CONFIG_PWM=y
30+
CONFIG_ADC=y
31+
CONFIG_PWM=y
32+
CONFIG_DMA=y
33+
CONFIG_MEMC=y
34+
CONFIG_SPI_ASYNC=y
35+
CONFIG_SPI_STM32_INTERRUPT=y
2936

3037
CONFIG_NET_CORE_LOG_LEVEL_DBG=y
3138

@@ -78,3 +85,15 @@ CONFIG_MBEDTLS_HEAP_SIZE=60000
7885
CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=7168
7986
CONFIG_MBEDTLS_HASH_ALL_ENABLED=y
8087
CONFIG_MBEDTLS_CMAC=y
88+
89+
90+
CONFIG_VIDEO=y
91+
CONFIG_VIDEO_LOG_LEVEL_DBG=y
92+
CONFIG_VIDEO_STM32_DCMI=y
93+
CONFIG_VIDEO_BUFFER_POOL_NUM_MAX=3
94+
CONFIG_VIDEO_BUFFER_POOL_SZ_MAX=614400
95+
CONFIG_VIDEO_BUFFER_POOL_ALIGN=32
96+
CONFIG_VIDEO_BUFFER_USE_SHARED_MULTI_HEAP=y
97+
CONFIG_VIDEO_BUFFER_SMH_ATTRIBUTE=2
98+
CONFIG_VIDEO_GC2145=y
99+
CONFIG_FLASH=y

0 commit comments

Comments
 (0)