Skip to content

Portenta H7: Add spis/wires to overlay plus fix GPIOS #71

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

Closed
wants to merge 6 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 29 additions & 5 deletions cores/arduino/zephyrCommon.cpp
Original file line number Diff line number Diff line change
@@ -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<ARRAY_SIZE(arduino_pwm_pins); i++) {
printk(" [%p,%u]", arduino_pwm_pins[i].port, arduino_pwm_pins[i].pin);
if ((arduino_pwm_pins[i].port == arduino_pins[pinNumber].port) && (arduino_pwm_pins[i].pin == arduino_pins[pinNumber].pin)) {
printk("\n");
return i;
}
}
printk("\n");
return (size_t)-1;
}


#else
const pin_size_t arduino_pwm_pins[] =
{ DT_FOREACH_PROP_ELEM(DT_PATH(zephyr_user), pwm_pin_gpios, PWM_PINS) };

@@ -151,7 +174,7 @@ size_t pwm_pin_index(pin_size_t pinNumber) {
}
return (size_t)-1;
}

#endif
#endif //CONFIG_PWM

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

unsigned long micros(void) {

#ifdef CONFIG_TIMER_HAS_64BIT_CYCLE_COUNTER
return k_cyc_to_us_floor32(k_cycle_get_64());
return k_cyc_to_us_floor32(k_cycle_get_64());
#else
return k_cyc_to_us_floor32(k_cycle_get_32());
#endif
}
return k_cyc_to_us_floor32(k_cycle_get_32());
#endif
}

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

8 changes: 6 additions & 2 deletions loader/boards/arduino_portenta_h7_m7.conf
Original file line number Diff line number Diff line change
@@ -24,8 +24,12 @@ CONFIG_SHELL_STACK_SIZE=32768
CONFIG_MAIN_STACK_SIZE=32768
CONFIG_LLEXT_HEAP_SIZE=128

#CONFIG_ADC=y
#CONFIG_PWM=y
CONFIG_ADC=y
CONFIG_PWM=y
CONFIG_DMA=y
CONFIG_MEMC=y
CONFIG_SPI_ASYNC=y
CONFIG_SPI_STM32_INTERRUPT=y

CONFIG_NET_CORE_LOG_LEVEL_DBG=y

Loading