diff --git a/app/src/CMakeLists.txt b/app/src/CMakeLists.txt index 04dc798..dae10cf 100644 --- a/app/src/CMakeLists.txt +++ b/app/src/CMakeLists.txt @@ -10,7 +10,7 @@ target_sources(app PRIVATE daq_driver.c device_status.cpp dcdc.cpp - half_bridge.cpp + half_bridge.c hardware.cpp leds.cpp load.cpp diff --git a/app/src/ext/can.cpp b/app/src/ext/can.cpp index 09d9a9d..7db72d4 100644 --- a/app/src/ext/can.cpp +++ b/app/src/ext/can.cpp @@ -142,7 +142,7 @@ K_THREAD_DEFINE(can_isotp, RX_THREAD_STACK_SIZE, can_isotp_thread, NULL, NULL, N #define TS_CAN_SOURCE_GET(id) (((uint32_t)id & TS_CAN_SOURCE_MASK) >> TS_CAN_SOURCE_POS) #define TS_CAN_DATA_ID_GET(id) (((uint32_t)id & TS_CAN_DATA_ID_MASK) >> TS_CAN_DATA_ID_POS) -CAN_DEFINE_MSGQ(sub_msgq, 10); +CAN_MSGQ_DEFINE(sub_msgq, 10); const struct zcan_filter ctrl_filter = { .id = TS_CAN_BASE_CONTROL, @@ -168,7 +168,7 @@ void can_pub_send(uint32_t can_id, uint8_t can_data[8], uint8_t data_len) if (data_len >= 0) { frame.dlc = data_len; - if (can_send(can_dev, &frame, K_MSEC(10), can_pub_isr, NULL) != CAN_TX_OK) { + if (can_send(can_dev, &frame, K_MSEC(10), can_pub_isr, NULL) != 0) { LOG_DBG("Error sending CAN frame"); } } @@ -190,7 +190,7 @@ void can_pubsub_thread() return; } - int filter_id = can_attach_msgq(can_dev, &sub_msgq, &ctrl_filter); + int filter_id = can_add_rx_filter_msgq(can_dev, &sub_msgq, &ctrl_filter); if (filter_id < 0) { LOG_ERR("Unable to attach ISR [%d]", filter_id); return; diff --git a/app/src/half_bridge.cpp b/app/src/half_bridge.c similarity index 96% rename from app/src/half_bridge.cpp rename to app/src/half_bridge.c index bac7a82..e82fe46 100644 --- a/app/src/half_bridge.cpp +++ b/app/src/half_bridge.c @@ -4,25 +4,25 @@ * SPDX-License-Identifier: Apache-2.0 */ +#define DT_DRV_COMPAT half_bridge + #include "half_bridge.h" #include #include +#include "board.h" #include "mcu.h" -#include "setup.h" #ifdef CONFIG_SOC_FAMILY_STM32 -#include +#include #include #include #endif #if BOARD_HAS_DCDC -#define DT_DRV_COMPAT half_bridge - // Get address of used timer from board dts #define TIMER_ADDR DT_REG_ADDR(DT_PARENT(DT_DRV_INST(0))) @@ -46,13 +46,17 @@ static uint16_t clamp_ccr(uint16_t ccr_target) #ifdef CONFIG_SOC_FAMILY_STM32 -static const struct soc_gpio_pinctrl tim_pinctrl[] = ST_STM32_DT_INST_PINCTRL(0, 0); +#define PINCTRL_NODE DT_NODELABEL(halfbridge) + +PINCTRL_DT_DEFINE(PINCTRL_NODE); + +static const struct pinctrl_dev_config *pincfg = PINCTRL_DT_DEV_CONFIG_GET(PINCTRL_NODE); #if TIMER_ADDR == TIM3_BASE static void tim_init_registers(int freq_kHz) { - stm32_dt_pinctrl_configure(tim_pinctrl, ARRAY_SIZE(tim_pinctrl), TIMER_ADDR); + pinctrl_apply_state(pincfg, PINCTRL_STATE_DEFAULT); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3); @@ -128,7 +132,7 @@ bool half_bridge_enabled() static void tim_init_registers(int freq_kHz) { - stm32_dt_pinctrl_configure(tim_pinctrl, ARRAY_SIZE(tim_pinctrl), TIMER_ADDR); + pinctrl_apply_state(pincfg, PINCTRL_STATE_DEFAULT); #ifdef LL_APB2_GRP1_PERIPH_TIM1 LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_TIM1); @@ -234,7 +238,7 @@ bool half_bridge_enabled() static void tim_init_registers(int freq_kHz) { - stm32_dt_pinctrl_configure(tim_pinctrl, ARRAY_SIZE(tim_pinctrl), TIMER_ADDR); + pinctrl_apply_state(pincfg, PINCTRL_STATE_DEFAULT); LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_HRTIM1); diff --git a/app/src/half_bridge.h b/app/src/half_bridge.h index 6978c9e..1c6ae80 100644 --- a/app/src/half_bridge.h +++ b/app/src/half_bridge.h @@ -7,6 +7,11 @@ #ifndef HALF_BRIDGE_H_ #define HALF_BRIDGE_H_ +#ifdef __cplusplus +extern "C" { +#endif + +#include #include /** @@ -85,4 +90,8 @@ void half_bridge_stop(); */ bool half_bridge_enabled(); +#ifdef __cplusplus +} +#endif + #endif /* HALF_BRIDGE_H_ */ diff --git a/app/src/hardware.cpp b/app/src/hardware.cpp index 46a862e..a97ec64 100644 --- a/app/src/hardware.cpp +++ b/app/src/hardware.cpp @@ -20,7 +20,7 @@ #endif #include -#include +#include LOG_MODULE_REGISTER(hardware, CONFIG_HW_LOG_LEVEL); diff --git a/app/src/pwm_switch_driver.c b/app/src/pwm_switch_driver.c index 1f02208..94ea468 100644 --- a/app/src/pwm_switch_driver.c +++ b/app/src/pwm_switch_driver.c @@ -24,11 +24,9 @@ #include #include -#include +#include #include -#define DT_DRV_COMPAT st_stm32_pwm - // all PWM charge controllers use TIM3 at the moment static TIM_TypeDef *tim = TIM3; @@ -59,7 +57,11 @@ static TIM_TypeDef *tim = TIM3; #define PWM_GPIO_PIN_HIGH (GPIOC->IDR & GPIO_IDR_ID7) #endif -static const struct soc_gpio_pinctrl pwm_pinctrl[] = ST_STM32_DT_PINCTRL(pwm3, 0); +#define PINCTRL_NODE DT_NODELABEL(pwm3) + +PINCTRL_DT_DEFINE(PINCTRL_NODE); + +static const struct pinctrl_dev_config *pincfg = PINCTRL_DT_DEV_CONFIG_GET(PINCTRL_NODE); static bool _pwm_active; static int _pwm_resolution; @@ -77,7 +79,7 @@ static void TIM3_IRQHandler(void *args) void pwm_signal_init_registers(int freq_Hz) { - stm32_dt_pinctrl_configure(pwm_pinctrl, ARRAY_SIZE(pwm_pinctrl), (uint32_t)tim); + pinctrl_apply_state(pincfg, PINCTRL_STATE_DEFAULT); LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_TIM3); @@ -156,15 +158,20 @@ float pwm_signal_get_duty_cycle() return 0; } -void pwm_signal_set_duty_cycle(float duty) {} +void pwm_signal_set_duty_cycle(float duty) +{} -void pwm_signal_duty_cycle_step(int delta) {} +void pwm_signal_duty_cycle_step(int delta) +{} -void pwm_signal_init_registers(int freq_Hz) {} +void pwm_signal_init_registers(int freq_Hz) +{} -void pwm_signal_start(float pwm_duty) {} +void pwm_signal_start(float pwm_duty) +{} -void pwm_signal_stop() {} +void pwm_signal_stop() +{} bool pwm_signal_high() { diff --git a/boards/arm/mppt_1210_hus/mppt_1210_hus.dts b/boards/arm/mppt_1210_hus/mppt_1210_hus.dts index c06aca4..7efc1de 100644 --- a/boards/arm/mppt_1210_hus/mppt_1210_hus.dts +++ b/boards/arm/mppt_1210_hus/mppt_1210_hus.dts @@ -132,19 +132,6 @@ spi-uext = &spi1; i2c-uext = &i2c1; }; - - soc { - // not (yet) provided by Zephyr dts, but necessary for dcdc node - timers3: timers@40000400 { - compatible = "st,stm32-timers"; - reg = <0x40000400 0x400>; - clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000002>; - interrupts = <16 0>; - interrupt-names = "global"; - status = "disabled"; - label = "TIMERS_3"; - }; - }; }; &clk_hsi { @@ -168,6 +155,7 @@ &usart1 { pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -178,6 +166,7 @@ &usart2 { pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -188,12 +177,14 @@ &i2c1 { pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>; + pinctrl-names = "default"; clock-frequency = ; status = "okay"; }; &spi1 { pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>; + pinctrl-names = "default"; cs-gpios = <&gpioa 15 GPIO_ACTIVE_LOW>; status = "okay"; }; @@ -205,9 +196,10 @@ &timers3 { status = "okay"; - halfbridge { + halfbridge: halfbridge { compatible = "half-bridge"; pinctrl-0 = <&tim3_ch3_pb0 &tim3_ch4_pb1>; + pinctrl-names = "default"; frequency = <50000>; deadtime = <230>; }; diff --git a/boards/arm/mppt_1210_hus/mppt_1210_hus_defconfig b/boards/arm/mppt_1210_hus/mppt_1210_hus_defconfig index 0f05e44..7dfc53c 100644 --- a/boards/arm/mppt_1210_hus/mppt_1210_hus_defconfig +++ b/boards/arm/mppt_1210_hus/mppt_1210_hus_defconfig @@ -3,11 +3,9 @@ CONFIG_SOC_SERIES_STM32L0X=y CONFIG_SOC_STM32L072XX=y -#CONFIG_ARM_MPU=y - CONFIG_CLOCK_CONTROL=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_GPIO=y diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc.dts b/boards/arm/mppt_2420_hc/mppt_2420_hc.dts index dfcc3cc..4038a26 100644 --- a/boards/arm/mppt_2420_hc/mppt_2420_hc.dts +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc.dts @@ -147,6 +147,7 @@ &usart1 { pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -157,6 +158,7 @@ &usart2 { pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -167,18 +169,21 @@ &i2c1 { pinctrl-0 = <&i2c1_scl_pa15 &i2c1_sda_pb7>; + pinctrl-names = "default"; clock-frequency = ; status = "okay"; }; &spi1 { pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>; + pinctrl-names = "default"; cs-gpios = <&gpiob 6 GPIO_ACTIVE_LOW>; status = "okay"; }; &spi2 { pinctrl-0 = <&spi2_sck_pb13 &spi2_miso_pb14 &spi2_mosi_pb15>; + pinctrl-names = "default"; cs-gpios = <&gpioa 5 GPIO_ACTIVE_LOW>; status = "okay"; }; @@ -190,9 +195,10 @@ &timers1 { status = "okay"; - halfbridge { + halfbridge: halfbridge { compatible = "half-bridge"; pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pc13>; + pinctrl-names = "default"; frequency = <70000>; deadtime = <300>; }; @@ -201,15 +207,17 @@ /* TIM8 (CH2) used for charge pump */ &timers8 { status = "okay"; + st,prescaler = <149>; /* reduce counter clock frequency to 1 MHz */ pwm8: pwm { status = "okay"; - st,prescaler = <149>; /* reduce counter clock frequency to 1 MHz */ pinctrl-0 = <&tim8_ch2_pb8>; + pinctrl-names = "default"; }; }; &can1 { pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>; + pinctrl-names = "default"; bus-speed = <500000>; bus-speed-data = <500000>; sjw = <1>; diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc_0_1_0.overlay b/boards/arm/mppt_2420_hc/mppt_2420_hc_0_1_0.overlay index 371ff83..19df98a 100644 --- a/boards/arm/mppt_2420_hc/mppt_2420_hc_0_1_0.overlay +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc_0_1_0.overlay @@ -55,7 +55,7 @@ }; &timers1 { - halfbridge { + halfbridge: halfbridge { pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>; }; }; @@ -64,5 +64,6 @@ status = "disabled"; /delete-node/ pinctrl-0; + /delete-node/ pinctrl-names; /delete-node/ cs-gpios; }; diff --git a/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig b/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig index 819d91c..bdb1a26 100644 --- a/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig +++ b/boards/arm/mppt_2420_hc/mppt_2420_hc_defconfig @@ -4,11 +4,12 @@ CONFIG_SOC_SERIES_STM32G4X=y CONFIG_SOC_STM32G431XX=y CONFIG_ARM_MPU=y +CONFIG_HW_STACK_PROTECTION=y CONFIG_MPU_ALLOW_FLASH_WRITE=y CONFIG_CLOCK_CONTROL=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_GPIO=y diff --git a/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts b/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts index 433c74c..f5b6eb1 100644 --- a/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts +++ b/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts @@ -168,6 +168,7 @@ &usart1 { pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -178,6 +179,7 @@ &usart3 { pinctrl-0 = <&usart3_tx_pc10 &usart3_rx_pc11>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -188,11 +190,13 @@ &i2c1 { pinctrl-0 = <&i2c1_scl_pa15 &i2c1_sda_pb7>; + pinctrl-names = "default"; status = "okay"; }; &spi1 { pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>; + pinctrl-names = "default"; cs-gpios = <&gpiod 2 GPIO_ACTIVE_LOW>; status = "okay"; }; @@ -226,9 +230,10 @@ &timers1 { status = "okay"; - halfbridge { + halfbridge: halfbridge { compatible = "half-bridge"; pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>; + pinctrl-names = "default"; frequency = <70000>; deadtime = <300>; }; @@ -240,21 +245,24 @@ pwm3: pwm { status = "okay"; pinctrl-0 = <&tim3_ch2_pc7>; + pinctrl-names = "default"; }; }; /* TIM8 (CH1) used for charge pump */ &timers8 { status = "okay"; + st,prescaler = <149>; /* reduce counter clock frequency to 1 MHz */ pwm8: pwm { status = "okay"; - st,prescaler = <149>; /* reduce counter clock frequency to 1 MHz */ pinctrl-0 = <&tim8_ch1_pc6>; + pinctrl-names = "default"; }; }; &i2c3 { pinctrl-0 = <&i2c3_scl_pc8 &i2c3_sda_pc9>; + pinctrl-names = "default"; status = "okay"; clock-frequency = ; eeprom@50 { diff --git a/boards/arm/mppt_2420_hpx/mppt_2420_hpx_defconfig b/boards/arm/mppt_2420_hpx/mppt_2420_hpx_defconfig index 449faa2..6c5749b 100644 --- a/boards/arm/mppt_2420_hpx/mppt_2420_hpx_defconfig +++ b/boards/arm/mppt_2420_hpx/mppt_2420_hpx_defconfig @@ -4,10 +4,11 @@ CONFIG_SOC_SERIES_STM32G4X=y CONFIG_SOC_STM32G431XX=y CONFIG_ARM_MPU=y +CONFIG_HW_STACK_PROTECTION=y CONFIG_CLOCK_CONTROL=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_GPIO=y diff --git a/boards/arm/mppt_2420_lc/mppt_2420_lc.dts b/boards/arm/mppt_2420_lc/mppt_2420_lc.dts index d2222ca..a15f7eb 100644 --- a/boards/arm/mppt_2420_lc/mppt_2420_lc.dts +++ b/boards/arm/mppt_2420_lc/mppt_2420_lc.dts @@ -165,6 +165,7 @@ &usart1 { pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -175,6 +176,7 @@ &usart2 { pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -186,12 +188,14 @@ &i2c1 { status = "okay"; pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>; + pinctrl-names = "default"; clock-frequency = ; }; &i2c2 { status = "okay"; pinctrl-0 = <&i2c2_scl_pb10 &i2c2_sda_pb11>; + pinctrl-names = "default"; clock-frequency = ; eeprom@50 { // Microchip 24AA32A @@ -211,6 +215,7 @@ &spi1 { pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>; + pinctrl-names = "default"; cs-gpios = <&gpioc 13 GPIO_ACTIVE_LOW>; status = "okay"; }; @@ -222,9 +227,10 @@ &timers1 { status = "okay"; - halfbridge { + halfbridge: halfbridge { compatible = "half-bridge"; pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>; + pinctrl-names = "default"; frequency = <70000>; deadtime = <300>; }; @@ -232,6 +238,7 @@ &can1 { pinctrl-0 = <&can_rx_pb8 &can_tx_pb9>; + pinctrl-names = "default"; bus-speed = <500000>; status = "okay"; }; diff --git a/boards/arm/mppt_2420_lc/mppt_2420_lc_defconfig b/boards/arm/mppt_2420_lc/mppt_2420_lc_defconfig index 2c1294a..0a1721e 100644 --- a/boards/arm/mppt_2420_lc/mppt_2420_lc_defconfig +++ b/boards/arm/mppt_2420_lc/mppt_2420_lc_defconfig @@ -3,11 +3,9 @@ CONFIG_SOC_SERIES_STM32F0X=y CONFIG_SOC_STM32F072XB=y -#CONFIG_ARM_MPU=y - CONFIG_CLOCK_CONTROL=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_GPIO=y diff --git a/boards/arm/mppt_2420_rc/mppt_2420_rc.dts b/boards/arm/mppt_2420_rc/mppt_2420_rc.dts index b6e6954..02c44f7 100644 --- a/boards/arm/mppt_2420_rc/mppt_2420_rc.dts +++ b/boards/arm/mppt_2420_rc/mppt_2420_rc.dts @@ -139,6 +139,7 @@ &usart1 { pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -149,6 +150,7 @@ &usart2 { pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -159,6 +161,7 @@ &spi1 { pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pb4 &spi1_mosi_pb5>; + pinctrl-names = "default"; cs-gpios = <&gpiob 6 GPIO_ACTIVE_LOW>; status = "okay"; }; @@ -166,9 +169,10 @@ &timers1 { status = "okay"; - halfbridge { + halfbridge: halfbridge { compatible = "half-bridge"; pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>; + pinctrl-names = "default"; frequency = <70000>; deadtime = <300>; }; @@ -200,6 +204,7 @@ /* shared between UEXT and EEPROM */ status = "okay"; pinctrl-0 = <&i2c1_scl_pa15 &i2c1_sda_pb7>; + pinctrl-names = "default"; clock-frequency = ; eeprom@50 { // Microchip 24AA32A @@ -219,6 +224,7 @@ &can1 { pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>; + pinctrl-names = "default"; bus-speed = <500000>; bus-speed-data = <500000>; sjw = <1>; diff --git a/boards/arm/mppt_2420_rc/mppt_2420_rc_defconfig b/boards/arm/mppt_2420_rc/mppt_2420_rc_defconfig index 89fb9b8..2ce928e 100644 --- a/boards/arm/mppt_2420_rc/mppt_2420_rc_defconfig +++ b/boards/arm/mppt_2420_rc/mppt_2420_rc_defconfig @@ -4,10 +4,11 @@ CONFIG_SOC_SERIES_STM32G4X=y CONFIG_SOC_STM32G431XX=y CONFIG_ARM_MPU=y +CONFIG_HW_STACK_PROTECTION=y CONFIG_CLOCK_CONTROL=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_GPIO=y diff --git a/boards/arm/nucleo_g474re/nucleo_g474re.dts b/boards/arm/nucleo_g474re/nucleo_g474re.dts index 374b25b..b799f7f 100644 --- a/boards/arm/nucleo_g474re/nucleo_g474re.dts +++ b/boards/arm/nucleo_g474re/nucleo_g474re.dts @@ -185,6 +185,7 @@ &usart1 { pinctrl-0 = <&usart1_tx_pc4 &usart1_rx_pc5>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -195,6 +196,7 @@ &lpuart1 { pinctrl-0 = <&lpuart1_tx_pa2 &lpuart1_rx_pa3>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -205,21 +207,24 @@ &i2c1 { pinctrl-0 = <&i2c1_scl_pb8 &i2c1_sda_pb9>; + pinctrl-names = "default"; status = "okay"; }; &spi1 { pinctrl-0 = <&spi1_nss_pa4 &spi1_sck_pb3 &spi1_miso_pa6 &spi1_mosi_pa7>; + pinctrl-names = "default"; status = "okay"; }; &hrtim1 { status = "okay"; - halfbridge { + halfbridge: halfbridge { compatible = "half-bridge"; pinctrl-0 = <&hrtim1_cha1_pa8 &hrtim1_cha2_pa9>; + pinctrl-names = "default"; frequency = <70000>; deadtime = <300>; }; @@ -230,9 +235,10 @@ &timers1 { status = "okay"; - halfbridge { + halfbridge: halfbridge { compatible = "half-bridge"; pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pb13>; + pinctrl-names = "default"; frequency = <70000>; deadtime = <300>; }; @@ -271,11 +277,13 @@ &adc1 { pinctrl-0 = <&adc1_in1_pa0>; + pinctrl-names = "default"; status = "okay"; }; &can1 { pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>; + pinctrl-names = "default"; bus-speed = <500000>; bus-speed-data = <500000>; sjw = <1>; diff --git a/boards/arm/nucleo_g474re/nucleo_g474re_defconfig b/boards/arm/nucleo_g474re/nucleo_g474re_defconfig index 49a1284..b473f56 100644 --- a/boards/arm/nucleo_g474re/nucleo_g474re_defconfig +++ b/boards/arm/nucleo_g474re/nucleo_g474re_defconfig @@ -7,7 +7,7 @@ CONFIG_SOC_STM32G474XX=y CONFIG_SERIAL=y # enable pinmux -CONFIG_PINMUX=y +CONFIG_PINCTRL=y # enable GPIO CONFIG_GPIO=y diff --git a/boards/arm/pwm_2420_lus/pwm_2420_lus.dts b/boards/arm/pwm_2420_lus/pwm_2420_lus.dts index a1d5eb7..440d4d3 100644 --- a/boards/arm/pwm_2420_lus/pwm_2420_lus.dts +++ b/boards/arm/pwm_2420_lus/pwm_2420_lus.dts @@ -146,25 +146,6 @@ spi-uext = &spi1; i2c-uext = &i2c1; }; - - // this should normally go to Zephyr repo - soc { - timers3: timers@40000400 { - compatible = "st,stm32-timers"; - reg = <0x40000400 0x400>; - clocks = <&rcc STM32_CLOCK_BUS_APB1 0x00000002>; - status = "okay"; - label = "TIMERS_3"; - - pwm3: pwm { - compatible = "st,stm32-pwm"; - status = "okay"; - st,prescaler = <10000>; - label = "PWM_3"; - #pwm-cells = <3>; - }; - }; - }; }; &clk_hsi { @@ -188,6 +169,7 @@ &usart1 { pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -199,6 +181,7 @@ &usart2 { pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>; + pinctrl-names = "default"; current-speed = <115200>; status = "okay"; }; @@ -209,12 +192,14 @@ &i2c1 { pinctrl-0 = <&i2c1_scl_pb6 &i2c1_sda_pb7>; + pinctrl-names = "default"; status = "okay"; clock-frequency = ; }; &spi1 { pinctrl-0 = <&spi1_sck_pb3 &spi1_miso_pa11 &spi1_mosi_pa12>; + pinctrl-names = "default"; cs-gpios = <&gpioa 15 GPIO_ACTIVE_LOW>; status = "okay"; }; @@ -225,9 +210,11 @@ &timers3 { status = "okay"; + st,prescaler = <10000>; pwm3: pwm { status = "okay"; pinctrl-0 = <&tim3_ch4_pb1>; + pinctrl-names = "default"; }; }; diff --git a/boards/arm/pwm_2420_lus/pwm_2420_lus_defconfig b/boards/arm/pwm_2420_lus/pwm_2420_lus_defconfig index 0f05e44..7dfc53c 100644 --- a/boards/arm/pwm_2420_lus/pwm_2420_lus_defconfig +++ b/boards/arm/pwm_2420_lus/pwm_2420_lus_defconfig @@ -3,11 +3,9 @@ CONFIG_SOC_SERIES_STM32L0X=y CONFIG_SOC_STM32L072XX=y -#CONFIG_ARM_MPU=y - CONFIG_CLOCK_CONTROL=y -CONFIG_PINMUX=y +CONFIG_PINCTRL=y CONFIG_GPIO=y diff --git a/dts/bindings/half-bridge.yaml b/dts/bindings/half-bridge.yaml index 21942bd..75c6b9d 100644 --- a/dts/bindings/half-bridge.yaml +++ b/dts/bindings/half-bridge.yaml @@ -5,24 +5,15 @@ description: Half bridge, consisting of two coupled PWM outputs compatible: "half-bridge" -include: base.yaml +include: [base.yaml, pinctrl-device.yaml] properties: - frequency: - type: int - required: true - description: PWM frequency in Hz + frequency: + type: int + required: true + description: PWM frequency in Hz - deadtime: - type: int - required: true - description: Dead time for synchronous PWM generation in nanoseconds - - pinctrl-0: - type: phandles - required: false - description: | - GPIO pin configuration for PWM signal/s. We expect that the phandles - will reference pinctrl nodes, e.g. - - pinctrl-0 = <&tim1_ch1_pwm_pa8 &tim1_ch2_pwm_pa9>; + deadtime: + type: int + required: true + description: Dead time for synchronous PWM generation in nanoseconds diff --git a/tests/boards/native_posix.overlay b/tests/boards/native_posix.overlay index ebc8de8..1f33553 100644 --- a/tests/boards/native_posix.overlay +++ b/tests/boards/native_posix.overlay @@ -137,7 +137,7 @@ timers1: timers1 { status = "okay"; - halfbridge { + halfbridge: halfbridge { compatible = "half-bridge"; frequency = <70000>; deadtime = <300>; diff --git a/west.yml b/west.yml index 7db97e9..9a7f226 100644 --- a/west.yml +++ b/west.yml @@ -11,7 +11,7 @@ manifest: projects: - name: zephyr remote: zephyrproject - revision: v2.7-branch + revision: v3.0-branch import: name-allowlist: - cmsis