1 Commits
Author SHA1 Message Date
Martin Jäger 89374f4a90 Add Solaris version of MPPT 2420 HC 2026-05-02 12:52:46 +02:00
8 changed files with 312 additions and 1 deletions
+1 -1
View File
@@ -829,7 +829,7 @@ THINGSET_ADD_ITEM_BOOL(ID_LOAD, 0x8B7, "sEnableDefault", &load.enable,
"de": "Abschaltspannung Lastausgang"
}
}*/
THINGSET_ADD_ITEM_FLOAT(ID_LOAD, 0x8B8, "sDisconnectVoltage_V",
THINGSET_ADD_ITEM_FLOAT(ID_LOAD, 0xB8, "sDisconnectVoltage_V",
&bat_conf_user.load_disconnect_voltage, 2, THINGSET_ANY_R | THINGSET_ANY_W,
TS_SUBSET_NVM);
@@ -0,0 +1,9 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
if BOARD_MPPT_2420_SOLARIS
config LIBRE_SOLAR_TYPE_ID
default 8
endif # BOARD_MPPT_2420_SOLARIS
@@ -0,0 +1,5 @@
# Copyright (c) The Libre Solar Project Contributors
# SPDX-License-Identifier: Apache-2.0
config BOARD_MPPT_2420_SOLARIS
select SOC_STM32G491XX
@@ -0,0 +1,8 @@
# SPDX-License-Identifier: Apache-2.0
board_runner_args(pyocd "--target=stm32g491cctx")
board_runner_args(jlink "--device=STM32G491CC" "--speed=4000" "--reset-after-load")
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
@@ -0,0 +1,6 @@
board:
name: mppt_2420_solaris
full_name: Libre Solar MPPT 2420 SOLARIS
vendor: libresolar
socs:
- name: stm32g491xx
@@ -0,0 +1,233 @@
/*
* Copyright (c) The Libre Solar Project Contributors
*
* SPDX-License-Identifier: Apache-2.0
*/
/dts-v1/;
#include <st/g4/stm32g491Xc.dtsi>
#include <st/g4/stm32g491c(c-e)tx-pinctrl.dtsi>
/ {
model = "Libre Solar MPPT 2420 SOLARIS";
compatible = "st,stm32g491";
pcb {
compatible = "charge-controller";
type = "MPPT 2420 SOLARIS";
version-str = "v0.1";
version-num = <1>;
hs-voltage-max = <90>;
ls-voltage-max = <32>;
dcdc-current-max = <20>;
};
chosen {
thingset,can = &fdcan1;
thingset,serial = &usart2;
zephyr,console = &usart1;
zephyr,shell-uart = &usart1;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
zephyr,code-partition = &slot0_partition;
};
/* temporary solution only using green color LED */
leds {
compatible = "charlieplexing-leds";
gpios = <&gpioa 6 GPIO_ACTIVE_LOW>, /* chg red */
<&gpioc 14 GPIO_ACTIVE_LOW>, /* chg green */
<&gpiob 9 GPIO_ACTIVE_LOW>, /* dis red */
<&gpioc 15 GPIO_ACTIVE_LOW>; /* dis green */
pwr {
states = <0 1 0 0>;
};
};
outputs {
compatible = "outputs";
can_en {
gpios = <&gpiob 11 GPIO_ACTIVE_LOW>;
};
};
adc-inputs {
compatible = "adc-inputs";
v-low {
io-channels = <&adc1 12>;
multiplier = <105600>;
divider = <5600>;
};
v-high {
io-channels = <&adc1 15>;
multiplier = <102200>;
divider = <2200>;
};
temp-fets {
io-channels = <&adc1 11>;
multiplier = <10000>; // 10k NTC series resistor
divider = <1>;
};
vref-mcu {
io-channels = <&adc1 18>;
multiplier = <1>;
divider = <1>;
};
temp-mcu {
io-channels = <&adc1 16>;
multiplier = <1>;
divider = <1>;
};
i-dcdc {
io-channels = <&adc2 1>;
// amp gain: 25, resistor: 2 mOhm
multiplier = <1000>; // 1000
divider = <50>; // 2*25
};
};
aliases {
uart-dbg = &usart1;
uart-uext = &usart2;
spi-uext = &spi1;
i2c-uext = &i2c1;
};
};
&clk_hse {
clock-frequency = <DT_FREQ_M(8)>;
status = "okay";
};
&clk_hsi48 {
status = "okay";
};
&pll {
div-m = <2>;
mul-n = <75>;
div-p = <7>;
div-q = <2>;
div-r = <2>;
clocks = <&clk_hse>;
status = "okay";
};
&rcc {
clocks = <&pll>;
clock-frequency = <DT_FREQ_M(150)>;
ahb-prescaler = <1>;
apb1-prescaler = <1>;
apb2-prescaler = <1>;
};
&rng {
clocks = <&rcc STM32_CLOCK(AHB2, 26)>,
<&rcc STM32_SRC_HSI48 CLK48_SEL(0)>;
status = "okay";
};
&usart1 {
pinctrl-0 = <&usart1_tx_pa9 &usart1_rx_pa10>;
pinctrl-names = "default";
current-speed = <115200>;
status = "okay";
};
&usart1_rx_pa10 {
bias-pull-up; // avoid junk characters if pin is left floating
};
&usart2 {
pinctrl-0 = <&usart2_tx_pa2 &usart2_rx_pa3>;
pinctrl-names = "default";
current-speed = <115200>;
status = "okay";
};
&usart2_rx_pa3 {
bias-pull-up; // avoid junk characters if pin is left floating
};
&i2c1 {
pinctrl-0 = <&i2c1_scl_pa15 &i2c1_sda_pb7>;
pinctrl-names = "default";
clock-frequency = <I2C_BITRATE_STANDARD>;
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";
};
&iwdg {
status = "okay";
};
&timers1 {
status = "okay";
halfbridge: halfbridge {
compatible = "half-bridge";
pinctrl-0 = <&tim1_ch1_pa8 &tim1_ch1n_pc13>;
pinctrl-names = "default";
frequency = <70000>;
deadtime = <300>;
};
};
&fdcan1 {
clocks = <&rcc STM32_CLOCK(APB1, 25)>,
<&rcc STM32_SRC_PLL_Q FDCAN_SEL(1)>;
pinctrl-0 = <&fdcan1_rx_pa11 &fdcan1_tx_pa12>;
pinctrl-names = "default";
bitrate = <500000>;
bitrate-data = <2000000>;
status = "okay";
};
/*
* Below partition layout allows to use MCUboot if CONFIG_BOOTLOADER_MCUBOOT is enabled. Otherwise,
* the code will just use the entire available flash of the MCU.
*/
&flash0 {
partitions {
compatible = "fixed-partitions";
#address-cells = <1>;
#size-cells = <1>;
boot_partition: partition@0 {
label = "mcuboot";
reg = <0x00000000 DT_SIZE_K(32)>;
};
slot0_partition: partition@8000 {
label = "image-0";
reg = <0x00008000 DT_SIZE_K(112)>;
};
slot1_partition: partition@24000 {
label = "image-1";
reg = <0x00024000 DT_SIZE_K(108)>;
};
/* Set 4Kb of storage at the end of the 256Kb of flash */
storage_partition: partition@3f000 {
label = "storage";
reg = <0x0003f000 DT_SIZE_K(4)>;
};
};
};
@@ -0,0 +1,18 @@
identifier: mppt_2420_solaris
name: MPPT-2420-SOLARIS
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 112
flash: 256
supported:
- nvs
- pwm
- i2c
- gpio
- usb device
- counter
- spi
@@ -0,0 +1,32 @@
# SPDX-License-Identifier: Apache-2.0
CONFIG_ARM_MPU=y
CONFIG_HW_STACK_PROTECTION=y
CONFIG_MPU_ALLOW_FLASH_WRITE=y
CONFIG_CLOCK_CONTROL=y
CONFIG_PINCTRL=y
CONFIG_GPIO=y
CONFIG_SERIAL=y
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# RNG required for automatic CAN node address assignment
CONFIG_ENTROPY_GENERATOR=y
CONFIG_ENTROPY_DEVICE_RANDOM_GENERATOR=y
CONFIG_CAN=y
CONFIG_ISOTP=y
CONFIG_ISOTP_FAST=y
CONFIG_THINGSET_CAN=y
CONFIG_FLASH=y
CONFIG_FLASH_PAGE_LAYOUT=y
CONFIG_FLASH_LOG_LEVEL_WRN=y
CONFIG_NVS=y
CONFIG_NVS_LOG_LEVEL_WRN=y