diff --git a/boards/arm/mppt_1210_hus/board.h b/boards/arm/mppt_1210_hus/board.h index 79e46f3..801499e 100644 --- a/boards/arm/mppt_1210_hus/board.h +++ b/boards/arm/mppt_1210_hus/board.h @@ -7,20 +7,6 @@ #ifndef MPPT_1210_HUS_H #define MPPT_1210_HUS_H -#define PIN_UEXT_TX PA_2 -#define PIN_UEXT_RX PA_3 -#define PIN_UEXT_SCL PB_6 -#define PIN_UEXT_SDA PB_7 -#define PIN_UEXT_MISO PB_4 -#define PIN_UEXT_MOSI PB_5 -#define PIN_UEXT_SCK PB_3 -#define PIN_UEXT_SSEL PA_15 - -#define PIN_SWD_TX PA_9 -#define PIN_SWD_RX PA_10 - -#define PIN_REF_I_DCDC PA_4 - enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT }; // assignment LED numbers on PCB to their meaning diff --git a/boards/arm/mppt_1210_hus/mppt_1210_hus.dts b/boards/arm/mppt_1210_hus/mppt_1210_hus.dts index e43b15e..0785e97 100755 --- a/boards/arm/mppt_1210_hus/mppt_1210_hus.dts +++ b/boards/arm/mppt_1210_hus/mppt_1210_hus.dts @@ -75,7 +75,7 @@ aliases { uart-dbg = &usart1; - uext-uart = &usart2; + uart-uext = &usart2; spi-uext = &spi1; i2c-uext = &i2c1; }; @@ -92,11 +92,12 @@ }; &i2c1 { - status = "okay"; clock-frequency = ; + status = "okay"; }; &spi1 { + cs-gpios = <&gpioa 15 GPIO_ACTIVE_LOW>; status = "okay"; }; diff --git a/boards/arm/mppt_1210_hus/pinmux.c b/boards/arm/mppt_1210_hus/pinmux.c index 556f766..bac244d 100755 --- a/boards/arm/mppt_1210_hus/pinmux.c +++ b/boards/arm/mppt_1210_hus/pinmux.c @@ -12,17 +12,6 @@ #include -// preliminary fix until PR for pinmux_stm32l0.h got accepted and merged to Zephyr master branch, -// see also here: https://github.com/zephyrproject-rtos/zephyr/pull/20997 -#ifndef STM32L0_PINMUX_FUNC_PB6_I2C1_SCL -#define STM32L0_PINMUX_FUNC_PB6_I2C1_SCL \ - (STM32_PINMUX_ALT_FUNC_1 | STM32_OPENDRAIN_PULLUP) -#endif -#ifndef STM32L0_PINMUX_FUNC_PB7_I2C1_SDA -#define STM32L0_PINMUX_FUNC_PB7_I2C1_SDA \ - (STM32_PINMUX_ALT_FUNC_1 | STM32_OPENDRAIN_PULLUP) -#endif - /* pin assignments for NUCLEO-L073RZ board */ static const struct pin_config pinconf[] = { #ifdef CONFIG_UART_1 diff --git a/boards/arm/mppt_2420_hpx/board.h b/boards/arm/mppt_2420_hpx/board.h index cb9fc36..3a0f43b 100644 --- a/boards/arm/mppt_2420_hpx/board.h +++ b/boards/arm/mppt_2420_hpx/board.h @@ -9,23 +9,6 @@ #include -#define PIN_UEXT_TX PA_2 -#define PIN_UEXT_RX PA_3 -#define PIN_UEXT_SCL PB_6 -#define PIN_UEXT_SDA PB_7 -#define PIN_UEXT_MISO PB_4 -#define PIN_UEXT_MOSI PB_5 -#define PIN_UEXT_SCK PB_3 -#define PIN_UEXT_SSEL PA_15 - -#define PIN_SWD_TX PA_9 -#define PIN_SWD_RX PA_10 - -#define PIN_LOAD_EN PC_13 -#define PIN_USB_PWR_EN PB_12 - -#define PIN_REF_I_DCDC PA_4 - enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT }; // assignment LED numbers on PCB to their meaning diff --git a/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts b/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts index 599f83b..1dbc5ba 100644 --- a/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts +++ b/boards/arm/mppt_2420_hpx/mppt_2420_hpx.dts @@ -65,7 +65,7 @@ aliases { uart-dbg = &usart1; - uext-uart = &usart3; + uart-uext = &usart3; spi-uext = &spi1; i2c-uext = &i2c1; }; @@ -86,6 +86,7 @@ }; &spi1 { + cs-gpios = <&gpiod 2 GPIO_ACTIVE_LOW>; status = "okay"; }; diff --git a/boards/arm/mppt_2420_hpx/pinmux.c b/boards/arm/mppt_2420_hpx/pinmux.c index 783773e..b8b5bd4 100644 --- a/boards/arm/mppt_2420_hpx/pinmux.c +++ b/boards/arm/mppt_2420_hpx/pinmux.c @@ -23,7 +23,7 @@ static const struct pin_config pinconf[] = { #ifdef CONFIG_UART_3 {STM32_PIN_PC10, STM32G4X_PINMUX_FUNC_PC10_USART3_TX}, {STM32_PIN_PC11, STM32G4X_PINMUX_FUNC_PC11_USART3_RX}, -#endif /* CONFIG_UART_2 */ +#endif /* CONFIG_UART_3 */ #ifdef CONFIG_I2C_1 {STM32_PIN_PA15, STM32G4X_PINMUX_FUNC_PA15_I2C1_SCL}, {STM32_PIN_PB7, STM32G4X_PINMUX_FUNC_PB7_I2C1_SDA}, @@ -31,10 +31,7 @@ static const struct pin_config pinconf[] = { #ifdef CONFIG_I2C_3 {STM32_PIN_PC8, STM32G4X_PINMUX_FUNC_PC8_I2C3_SCL}, {STM32_PIN_PC9, STM32G4X_PINMUX_FUNC_PC9_I2C3_SDA}, -#endif /* CONFIG_I2C_1 */ -#ifdef CONFIG_PWM_STM32_2 - {STM32_PIN_PA5, STM32G4X_PINMUX_FUNC_PA5_PWM2_CH1}, -#endif /* CONFIG_PWM_STM32_2 */ +#endif /* CONFIG_I2C_3 */ #ifdef CONFIG_PWM_STM32_3 {STM32_PIN_PC6, STM32G4X_PINMUX_FUNC_PC6_PWM3_CH1}, #endif /* CONFIG_PWM_STM32_3 */ @@ -42,40 +39,14 @@ static const struct pin_config pinconf[] = { {STM32_PIN_PC6, STM32G4X_PINMUX_FUNC_PC6_PWM8_CH1}, #endif /* CONFIG_PWM_STM32_8 */ #ifdef CONFIG_SPI_1 - /* SPI1 on the Arduino connectors pins A2, D3, D11, D12 */ -#ifdef CONFIG_SPI_STM32_USE_HW_SS - {STM32_PIN_PA4, STM32G4X_PINMUX_FUNC_PA4_SPI1_NSS}, -#endif /* CONFIG_SPI_STM32_USE_HW_SS */ - /* SPI1_SCK should output on PA5, but is used for LD2 */ {STM32_PIN_PB3, STM32G4X_PINMUX_FUNC_PB3_SPI1_SCK}, - {STM32_PIN_PA6, STM32G4X_PINMUX_FUNC_PA6_SPI1_MISO}, - {STM32_PIN_PA7, STM32G4X_PINMUX_FUNC_PA7_SPI1_MOSI}, + {STM32_PIN_PB4, STM32G4X_PINMUX_FUNC_PB4_SPI1_MISO}, + {STM32_PIN_PB5, STM32G4X_PINMUX_FUNC_PB5_SPI1_MOSI}, #endif /* CONFIG_SPI_1 */ -#ifdef CONFIG_SPI_2 - /* SPI2 on the ST Morpho Connector CN10 pins 16, 30, 28, 26*/ -#ifdef CONFIG_SPI_STM32_USE_HW_SS - {STM32_PIN_PB12, STM32G4X_PINMUX_FUNC_PB12_SPI2_NSS}, -#endif /* CONFIG_SPI_STM32_USE_HW_SS */ - {STM32_PIN_PB13, STM32G4X_PINMUX_FUNC_PB13_SPI2_SCK}, - {STM32_PIN_PB14, STM32G4X_PINMUX_FUNC_PB14_SPI2_MISO}, - {STM32_PIN_PB15, STM32G4X_PINMUX_FUNC_PB15_SPI2_MOSI}, -#endif /* CONFIG_SPI_1 */ -#ifdef CONFIG_SPI_3 - /* SPI3 on the ST Morpho Connector CN7 pins 17, 1, 2, 3*/ -#ifdef CONFIG_SPI_STM32_USE_HW_SS - {STM32_PIN_PA15, STM32G4X_PINMUX_FUNC_PA15_SPI3_NSS}, -#endif /* CONFIG_SPI_STM32_USE_HW_SS */ - {STM32_PIN_PC10, STM32G4X_PINMUX_FUNC_PC10_SPI3_SCK}, - {STM32_PIN_PC11, STM32G4X_PINMUX_FUNC_PC11_SPI3_MISO}, - {STM32_PIN_PC12, STM32G4X_PINMUX_FUNC_PC12_SPI3_MOSI}, -#endif /* CONFIG_SPI_3 */ #ifdef CONFIG_USB_DC_STM32 {STM32_PIN_PA11, STM32G4X_PINMUX_FUNC_PA11_USB_DM}, {STM32_PIN_PA12, STM32G4X_PINMUX_FUNC_PA12_USB_DP}, #endif /* CONFIG_USB_DC_STM32 */ -#ifdef CONFIG_ADC_2 - {STM32_PIN_PA4, STM32G4X_PINMUX_FUNC_PA4_ADC2_IN17}, -#endif /* CONFIG_ADC_2 */ }; static int pinmux_stm32_init(struct device *port) diff --git a/boards/arm/mppt_2420_lc/board.h b/boards/arm/mppt_2420_lc/board.h index 1109650..a867fdd 100644 --- a/boards/arm/mppt_2420_lc/board.h +++ b/boards/arm/mppt_2420_lc/board.h @@ -7,37 +7,6 @@ #ifndef MPPT_2420_LC_H #define MPPT_2420_LC_H -#define PIN_UEXT_DIS PC_14 // starting from rev. 0.10 -#define PIN_UEXT_TX PA_2 -#define PIN_UEXT_RX PA_3 -#define PIN_UEXT_SCL PB_6 -#define PIN_UEXT_SDA PB_7 -#define PIN_UEXT_MISO PB_4 -#define PIN_UEXT_MOSI PB_5 -#define PIN_UEXT_SCK PB_3 -#define PIN_UEXT_SSEL PC_13 // PCB rev 0.6: PA_0 - -#define PIN_SWD_TX PA_9 -#define PIN_SWD_RX PA_10 -/* -#define PIN_LED_PWR PB_14 -#define PIN_LED_LOAD PB_15 -*/ -#define PIN_LOAD_DIS PB_2 -//#define PIN_5V_OUT_EN PB_12 -#define PIN_USB_PWR_EN PB_12 // normally should be named 5V_OUT_EN, as no USB is existing here -//#define PIN_USB_PWR_FLG PC_14 -#define PIN_CAN_RX PB_8 -#define PIN_CAN_TX PB_9 -#define PIN_CAN_STB PA_15 -#define PIN_V_BUS_DIS PC_15 // bus power supply disable, starting from rev. 0.10 - -#define PIN_REF_I_DCDC PA_4 - -#define PIN_EEPROM_SCL PB_10 -#define PIN_EEPROM_SDA PB_11 - -#define EEPROM_24AA32 #define CONFIG_CAN 1 enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT }; diff --git a/boards/arm/mppt_2420_lc/mppt_2420_lc.dts b/boards/arm/mppt_2420_lc/mppt_2420_lc.dts index 6ecef82..5e16132 100755 --- a/boards/arm/mppt_2420_lc/mppt_2420_lc.dts +++ b/boards/arm/mppt_2420_lc/mppt_2420_lc.dts @@ -63,11 +63,19 @@ label = "CAN disable / standby"; gpios = <&gpioa 15 GPIO_ACTIVE_LOW>; }; + aux_en { + label = "5V output enable"; + gpios = <&gpiob 12 GPIO_ACTIVE_HIGH>; + }; + vbus_en { + label = "CAN bus power supply enable"; + gpios = <&gpioc 15 GPIO_ACTIVE_LOW>; + }; }; aliases { uart-dbg = &usart1; - uext-uart = &usart2; + uart-uext = &usart2; spi-uext = &spi1; i2c-uext = &i2c1; }; @@ -108,6 +116,7 @@ }; &spi1 { + cs-gpios = <&gpioc 13 GPIO_ACTIVE_LOW>; status = "okay"; }; diff --git a/boards/arm/mppt_2420_lc/pinmux.c b/boards/arm/mppt_2420_lc/pinmux.c index 001bca3..e05abd0 100755 --- a/boards/arm/mppt_2420_lc/pinmux.c +++ b/boards/arm/mppt_2420_lc/pinmux.c @@ -44,12 +44,6 @@ static const struct pin_config pinconf[] = { {STM32_PIN_PB4, STM32F0_PINMUX_FUNC_PB4_SPI1_MISO}, {STM32_PIN_PB5, STM32F0_PINMUX_FUNC_PB5_SPI1_MOSI}, #endif /* CONFIG_SPI_1 */ -#ifdef CONFIG_ADC_1 - {STM32_PIN_PA0, STM32F0_PINMUX_FUNC_PA0_ADC_IN0}, -#endif /* CONFIG_ADC_1 */ -#ifdef CONFIG_DAC_1 - {STM32_PIN_PA4, STM32F0_PINMUX_FUNC_PA4_DAC_OUT1}, -#endif /* CONFIG_ADC_1 */ #ifdef CONFIG_CAN_1 {STM32_PIN_PB8, STM32F0_PINMUX_FUNC_PB8_CAN_RX}, {STM32_PIN_PB9, STM32F0_PINMUX_FUNC_PB9_CAN_TX}, diff --git a/boards/arm/pwm_2420_lus/board.h b/boards/arm/pwm_2420_lus/board.h index bc271ac..834fdab 100644 --- a/boards/arm/pwm_2420_lus/board.h +++ b/boards/arm/pwm_2420_lus/board.h @@ -7,30 +7,9 @@ #ifndef PWM_2420_LUS_H #define PWM_2420_LUS_H -#define PIN_UEXT_TX PA_2 -#define PIN_UEXT_RX PA_3 -#define PIN_UEXT_SCL PB_6 -#define PIN_UEXT_SDA PB_7 -#define PIN_UEXT_MISO PA_11 -#define PIN_UEXT_MOSI PA_12 -#define PIN_UEXT_SCK PB_3 -#define PIN_UEXT_SSEL PA_15 - -#define PIN_SWD_TX PA_9 -#define PIN_SWD_RX PA_10 - -#define PIN_LOAD_DIS PB_2 -#define PIN_USB_PWR_DIS PB_5 #define PIN_I_LOAD_COMP PB_4 #define PIN_EXT_BTN PB_12 -#define PIN_BOOT0_EN PB_12 - -#define PIN_REF_I_DCDC PA_4 - -// Internal NTC temperature currently ignored by firmware as it is similar to MCU temperature and -// does not reflect external battery temperature. Feature will be removed in future HW revisions. -#define PIN_TEMP_INT_PD PA_8 enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT }; diff --git a/boards/arm/pwm_2420_lus/pinmux.c b/boards/arm/pwm_2420_lus/pinmux.c index 281af75..2c6c532 100644 --- a/boards/arm/pwm_2420_lus/pinmux.c +++ b/boards/arm/pwm_2420_lus/pinmux.c @@ -12,13 +12,6 @@ #include -// preliminary fix until PR for pinmux_stm32l0.h got accepted and merged to Zephyr master branch, -// see also here: https://github.com/zephyrproject-rtos/zephyr/pull/20997 -#define STM32L0_PINMUX_FUNC_PB6_I2C1_SCL \ - (STM32_PINMUX_ALT_FUNC_1 | STM32_OPENDRAIN_PULLUP) -#define STM32L0_PINMUX_FUNC_PB7_I2C1_SDA \ - (STM32_PINMUX_ALT_FUNC_1 | STM32_OPENDRAIN_PULLUP) - /* pin assignments for NUCLEO-L073RZ board */ static const struct pin_config pinconf[] = { #ifdef CONFIG_UART_1 @@ -34,13 +27,10 @@ static const struct pin_config pinconf[] = { {STM32_PIN_PB7, STM32L0_PINMUX_FUNC_PB7_I2C1_SDA}, #endif /* CONFIG_I2C_1 */ #ifdef CONFIG_SPI_1 - {STM32_PIN_PA5, STM32L0_PINMUX_FUNC_PA5_SPI1_SCK}, - {STM32_PIN_PA6, STM32L0_PINMUX_FUNC_PA6_SPI1_MISO}, - {STM32_PIN_PA7, STM32L0_PINMUX_FUNC_PA7_SPI1_MOSI}, + {STM32_PIN_PB3, STM32L0_PINMUX_FUNC_PB3_SPI1_SCK}, + {STM32_PIN_PA11, STM32L0_PINMUX_FUNC_PA11_SPI1_MISO}, + {STM32_PIN_PA12, STM32L0_PINMUX_FUNC_PA12_SPI1_MOSI}, #endif /* CONFIG_SPI_1 */ -#ifdef CONFIG_ADC_1 - {STM32_PIN_PA0, STM32L0_PINMUX_FUNC_PA0_ADC_IN0}, -#endif /* CONFIG_ADC_1 */ }; static int pinmux_stm32_init(struct device *port) diff --git a/boards/arm/pwm_2420_lus/pwm_2420_lus.dts b/boards/arm/pwm_2420_lus/pwm_2420_lus.dts index a893ee5..9a1b6d7 100644 --- a/boards/arm/pwm_2420_lus/pwm_2420_lus.dts +++ b/boards/arm/pwm_2420_lus/pwm_2420_lus.dts @@ -77,7 +77,7 @@ aliases { uart-dbg = &usart1; - uext-uart = &usart2; + uart-uext = &usart2; spi-uext = &spi1; i2c-uext = &i2c1; }; @@ -118,6 +118,7 @@ }; &spi1 { + cs-gpios = <&gpioa 15 GPIO_ACTIVE_LOW>; status = "okay"; }; diff --git a/src/daq_driver.c b/src/daq_driver.c index 824f2de..2725d9c 100644 --- a/src/daq_driver.c +++ b/src/daq_driver.c @@ -100,6 +100,7 @@ static void vref_setup() static void dac_setup() { #if defined(CONFIG_SOC_SERIES_STM32F0X) || defined(CONFIG_SOC_SERIES_STM32L0X) + /* DAC1 at PA4 for load and DC/DC / PWM switch current measurement * VCC */ LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_DAC1); LL_DAC_SetOutputBuffer(DAC1, LL_DAC_CHANNEL_1, LL_DAC_OUTPUT_BUFFER_ENABLE); LL_DAC_Enable(DAC1, LL_DAC_CHANNEL_1);