Add MPPT 2420 RC board
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
if(CONFIG_PINMUX)
|
||||
zephyr_library()
|
||||
zephyr_library_sources(pinmux.c)
|
||||
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
|
||||
endif()
|
||||
|
||||
zephyr_include_directories(.)
|
||||
@@ -0,0 +1,5 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright (c) 2020 Martin Jäger / Libre Solar
|
||||
|
||||
# include generic charge controller Kconfig
|
||||
rsource "../../Kconfig"
|
||||
@@ -0,0 +1,6 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright (c) 2020 Martin Jäger / Libre Solar
|
||||
|
||||
config BOARD_MPPT_2420_RC
|
||||
bool "Libre Solar MPPT 2420 RC"
|
||||
depends on SOC_STM32G431XX
|
||||
@@ -0,0 +1,37 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
# Copyright (c) 2019 Martin Jäger / Libre Solar
|
||||
|
||||
if BOARD_MPPT_2420_RC
|
||||
|
||||
config BOARD
|
||||
default "mppt_2420_rc"
|
||||
|
||||
config LIBRE_SOLAR_TYPE_ID
|
||||
default 0
|
||||
|
||||
if UART_CONSOLE
|
||||
|
||||
#config UART_1
|
||||
# bool
|
||||
# default y
|
||||
|
||||
endif # UART_CONSOLE
|
||||
|
||||
if I2C
|
||||
|
||||
config I2C_1
|
||||
default y
|
||||
|
||||
endif # I2C
|
||||
|
||||
if SPI
|
||||
|
||||
config SPI_1
|
||||
default y
|
||||
|
||||
config SPI_STM32_INTERRUPT
|
||||
default y
|
||||
|
||||
endif # SPI
|
||||
|
||||
endif # BOARD_MPPT_2420_RC
|
||||
@@ -0,0 +1,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
board_runner_args(pyocd "--target=stm32g431rbtx")
|
||||
board_runner_args(jlink "--device=STM32G431RB" "--speed=4000" "--reset-after-load")
|
||||
|
||||
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
|
||||
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
|
||||
@@ -0,0 +1,69 @@
|
||||
/*
|
||||
* Copyright (c) 2020 Martin Jäger / Libre Solar
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#ifndef MPPT_2420_RC_H
|
||||
#define MPPT_2420_RC_H
|
||||
|
||||
#include <zephyr.h>
|
||||
|
||||
enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
|
||||
|
||||
// assignment LED numbers on PCB to their meaning
|
||||
#define NUM_LEDS 1
|
||||
|
||||
#define LED_PWR 0 // LED1
|
||||
|
||||
// LED pins and pin state configuration to switch above LEDs on
|
||||
#define NUM_LED_PINS 1
|
||||
|
||||
// defined in board definition pinmux.c
|
||||
extern const char *led_ports[NUM_LED_PINS];
|
||||
extern const int led_pins[NUM_LED_PINS];
|
||||
|
||||
static const enum pin_state_t led_pin_setup[NUM_LEDS][NUM_LED_PINS] = {
|
||||
{ PIN_HIGH }, // LED1
|
||||
};
|
||||
|
||||
// pin definition only needed in adc_dma.cpp to detect if they are present on the PCB
|
||||
#define PIN_ADC_TEMP_FETS PA_1
|
||||
|
||||
// typical value for Semitec 103AT-5 thermistor: 3435
|
||||
#define NTC_BETA_VALUE 3435
|
||||
#define NTC_SERIES_RESISTOR 10000.0
|
||||
|
||||
// position in the array written by the DMA controller
|
||||
enum {
|
||||
// ADC1
|
||||
ADC_POS_V_LOW,
|
||||
ADC_POS_V_HIGH,
|
||||
ADC_POS_V_SC_SENSE,
|
||||
ADC_POS_TEMP_FETS,
|
||||
ADC_POS_VREF_MCU,
|
||||
ADC_POS_TEMP_MCU,
|
||||
// ADC2
|
||||
ADC_POS_I_DCDC,
|
||||
// trick to get the total number of elements
|
||||
NUM_ADC_CH
|
||||
};
|
||||
|
||||
// selected ADC channels (has to match with below arrays)
|
||||
#define NUM_ADC_1_CH 6
|
||||
#define NUM_ADC_2_CH 1
|
||||
|
||||
static const uint32_t adc_1_sequence[] = {
|
||||
LL_ADC_CHANNEL_12, // V_LOW
|
||||
LL_ADC_CHANNEL_15, // V_HIGH
|
||||
LL_ADC_CHANNEL_11, // V_SC_SENSE
|
||||
LL_ADC_CHANNEL_2, // TEMP_FETS
|
||||
LL_ADC_CHANNEL_VREFINT, // VREF_MCU
|
||||
LL_ADC_CHANNEL_TEMPSENSOR_ADC1, // TEMP_MCU
|
||||
};
|
||||
|
||||
static const uint32_t adc_2_sequence[] = {
|
||||
LL_ADC_CHANNEL_1, // I_DCDC
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2020 Martin Jäger / Libre Solar
|
||||
*/
|
||||
|
||||
/dts-v1/;
|
||||
#include <st/g4/stm32g431Xb.dtsi>
|
||||
|
||||
/ {
|
||||
model = "Libre Solar MPPT 2420 RC";
|
||||
compatible = "st,stm32g431";
|
||||
|
||||
pcb {
|
||||
compatible = "charge-controller";
|
||||
|
||||
type = "MPPT 2420 RC";
|
||||
version-str = "v0.1";
|
||||
version-num = <1>;
|
||||
|
||||
hs-voltage-max = <80>;
|
||||
ls-voltage-max = <32>;
|
||||
};
|
||||
|
||||
dcdc {
|
||||
compatible = "dcdc";
|
||||
pwm-frequency = <70000>;
|
||||
pwm-deadtime = <300>;
|
||||
current-max = <20>;
|
||||
};
|
||||
|
||||
chosen {
|
||||
zephyr,console = &usart2;
|
||||
zephyr,shell-uart = &usart2;
|
||||
zephyr,sram = &sram0;
|
||||
zephyr,flash = &flash0;
|
||||
};
|
||||
|
||||
leds {
|
||||
compatible = "gpio-leds";
|
||||
pwr {
|
||||
gpios = <&gpiob 15 GPIO_ACTIVE_HIGH>;
|
||||
label = "Power LED";
|
||||
};
|
||||
};
|
||||
|
||||
v-low {
|
||||
compatible = "adc-gain";
|
||||
io-channels = <&adc1 12>;
|
||||
numerator = <105600>;
|
||||
denominator = <5600>;
|
||||
};
|
||||
|
||||
v-high {
|
||||
compatible = "adc-gain";
|
||||
io-channels = <&adc1 15>;
|
||||
numerator = <102200>;
|
||||
denominator = <2200>;
|
||||
};
|
||||
|
||||
i-dcdc {
|
||||
compatible = "adc-gain";
|
||||
io-channels = <&adc2 1>;
|
||||
// amp gain: 68/2.2, resistor: 2 mOhm
|
||||
numerator = <2200>; // 1000*2.2
|
||||
denominator = <136>; // 2*68
|
||||
};
|
||||
|
||||
soc {
|
||||
// ADC nodes not yet provided by Zephyr, but needed for adc-gain compatibles
|
||||
adc1: adc@50000000 {
|
||||
compatible = "st,stm32-adc";
|
||||
reg = <0x50000000 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00002000>;
|
||||
interrupts = <18 0>;
|
||||
status = "disabled";
|
||||
label = "ADC_1";
|
||||
#io-channel-cells = <1>;
|
||||
};
|
||||
|
||||
adc2: adc@50000100 {
|
||||
compatible = "st,stm32-adc";
|
||||
reg = <0x50000100 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00002000>;
|
||||
interrupts = <18 0>;
|
||||
status = "disabled";
|
||||
label = "ADC_2";
|
||||
#io-channel-cells = <1>;
|
||||
};
|
||||
|
||||
dac1: dac@50000800 {
|
||||
compatible = "st,stm32-dac";
|
||||
reg = <0x50000800 0x400>;
|
||||
clocks = <&rcc STM32_CLOCK_BUS_AHB2 0x00010000>;
|
||||
status = "disabled";
|
||||
label = "DAC_1";
|
||||
#io-channel-cells = <1>;
|
||||
};
|
||||
};
|
||||
|
||||
aliases {
|
||||
uart-dbg = &usart2;
|
||||
uart-uext = &usart2;
|
||||
spi-uext = &spi1;
|
||||
i2c-uext = &i2c1;
|
||||
};
|
||||
};
|
||||
|
||||
&usart1 {
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&usart2 {
|
||||
current-speed = <115200>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&spi1 {
|
||||
cs-gpios = <&gpiob 6 GPIO_ACTIVE_LOW>;
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&rtc {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&flash0 {
|
||||
/*
|
||||
* For more information, see:
|
||||
* http://docs.zephyrproject.org/latest/guides/dts/index.html#flash-partitions
|
||||
*/
|
||||
partitions {
|
||||
compatible = "fixed-partitions";
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
/* Set 4Kb of storage at the end of the 128Kb of flash */
|
||||
storage_partition: partition@1f000 {
|
||||
label = "storage";
|
||||
reg = <0x0001f000 0x00001000>;
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
&iwdg {
|
||||
status = "okay";
|
||||
};
|
||||
|
||||
&i2c1 {
|
||||
/* shared between UEXT and EEPROM */
|
||||
status = "okay";
|
||||
clock-frequency = <I2C_BITRATE_STANDARD>;
|
||||
eeprom@50 {
|
||||
// Microchip 24AA32A
|
||||
compatible = "atmel,at24";
|
||||
reg = <0x50>;
|
||||
label = "EEPROM_0";
|
||||
size = <32768>;
|
||||
pagesize = <32>;
|
||||
address-width = <16>;
|
||||
/*
|
||||
* timeout of 5 ms as suggested in datasheet seems too optimistic
|
||||
* (several write errors occured during testing)
|
||||
*/
|
||||
timeout = <7>;
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,18 @@
|
||||
identifier: mppt_2420_rc
|
||||
name: MPPT-2420-RC
|
||||
type: mcu
|
||||
arch: arm
|
||||
toolchain:
|
||||
- zephyr
|
||||
- gnuarmemb
|
||||
- xtools
|
||||
ram: 32
|
||||
flash: 128
|
||||
supported:
|
||||
- nvs
|
||||
- pwm
|
||||
- i2c
|
||||
- gpio
|
||||
- usb device
|
||||
- counter
|
||||
- spi
|
||||
@@ -0,0 +1,62 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
CONFIG_SOC_SERIES_STM32G4X=y
|
||||
CONFIG_SOC_STM32G431XX=y
|
||||
|
||||
# 170MHz system clock only in 'boost power' mode. RM0440, section
|
||||
# 5.1.5 states that the R1MODE bit must be cleared before system can
|
||||
# be 170MHz. This requires an update to the stm32 clock control
|
||||
# driver, so default to 150MHz until then.
|
||||
# CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=170000000
|
||||
|
||||
# 150MHz system clock in 'normal power' mode
|
||||
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=150000000
|
||||
|
||||
# enable uart driver
|
||||
CONFIG_SERIAL=y
|
||||
|
||||
# enable pinmux
|
||||
CONFIG_PINMUX=y
|
||||
|
||||
# enable GPIO
|
||||
CONFIG_GPIO=y
|
||||
|
||||
# clock configuration
|
||||
CONFIG_CLOCK_CONTROL=y
|
||||
|
||||
# Use PLLCLK for SYSCLK
|
||||
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
|
||||
|
||||
# Use HSI (16MHz) to feed into PLL
|
||||
CONFIG_CLOCK_STM32_PLL_SRC_HSI=y
|
||||
|
||||
CONFIG_CLOCK_STM32_PLL_M_DIVISOR=4
|
||||
CONFIG_CLOCK_STM32_PLL_P_DIVISOR=7
|
||||
CONFIG_CLOCK_STM32_PLL_Q_DIVISOR=2
|
||||
CONFIG_CLOCK_STM32_PLL_R_DIVISOR=2
|
||||
|
||||
# Produce 150MHz clock at PLLCLK output
|
||||
CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=75
|
||||
|
||||
# Comment out above and uncomment below for 170MHz. Note that you
|
||||
# must have configured the mcu for boost power mode.
|
||||
# CONFIG_CLOCK_STM32_PLL_N_MULTIPLIER=85
|
||||
|
||||
# Produce Max (150MHz or 170MHz) HCLK
|
||||
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
|
||||
|
||||
# Produce Max (150MHz or 170MHz) APB1 clocks and APB2 clocks
|
||||
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
|
||||
CONFIG_CLOCK_STM32_APB2_PRESCALER=1
|
||||
|
||||
# Console
|
||||
CONFIG_CONSOLE=y
|
||||
CONFIG_UART_CONSOLE=y
|
||||
|
||||
# Enable MPU
|
||||
CONFIG_ARM_MPU=y
|
||||
|
||||
CONFIG_I2C=y
|
||||
CONFIG_I2C_1=y
|
||||
CONFIG_EEPROM=y
|
||||
CONFIG_EEPROM_AT24=y
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Copyright (c) 2020 Martin Jäger / Libre Solar
|
||||
*/
|
||||
|
||||
#include <kernel.h>
|
||||
#include <device.h>
|
||||
#include <init.h>
|
||||
#include <drivers/pinmux.h>
|
||||
#include <sys/sys_io.h>
|
||||
|
||||
#include <pinmux/stm32/pinmux_stm32.h>
|
||||
|
||||
static const struct pin_config pinconf[] = {
|
||||
{STM32_PIN_PA9, STM32G4X_PINMUX_FUNC_PA9_USART1_TX},
|
||||
{STM32_PIN_PA10, STM32G4X_PINMUX_FUNC_PA10_USART1_RX},
|
||||
{STM32_PIN_PA2, STM32G4X_PINMUX_FUNC_PA2_USART2_TX},
|
||||
{STM32_PIN_PA3, STM32G4X_PINMUX_FUNC_PA3_USART2_RX},
|
||||
#ifdef CONFIG_I2C_1
|
||||
{STM32_PIN_PA15, STM32G4X_PINMUX_FUNC_PA15_I2C1_SCL},
|
||||
{STM32_PIN_PB7, STM32G4X_PINMUX_FUNC_PB7_I2C1_SDA},
|
||||
#endif /* CONFIG_I2C_1 */
|
||||
#ifdef CONFIG_SPI_1
|
||||
{STM32_PIN_PB3, STM32G4X_PINMUX_FUNC_PB3_SPI1_SCK},
|
||||
{STM32_PIN_PB4, STM32G4X_PINMUX_FUNC_PB4_SPI1_MISO},
|
||||
{STM32_PIN_PB5, STM32G4X_PINMUX_FUNC_PB5_SPI1_MOSI},
|
||||
#endif /* CONFIG_SPI_1 */
|
||||
#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 */
|
||||
};
|
||||
|
||||
static int pinmux_stm32_init(struct device *port)
|
||||
{
|
||||
ARG_UNUSED(port);
|
||||
|
||||
stm32_setup_pins(pinconf, ARRAY_SIZE(pinconf));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1,
|
||||
CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY);
|
||||
|
||||
|
||||
const char *led_ports[] = {
|
||||
DT_GPIO_LEDS_PWR_GPIOS_CONTROLLER,
|
||||
};
|
||||
const int led_pins[] = {
|
||||
DT_GPIO_LEDS_PWR_GPIOS_PIN,
|
||||
};
|
||||
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"build": {
|
||||
"cpu": "cortex-m4",
|
||||
"extra_flags": "-DSTM32G4xx -DSTM32G431xx",
|
||||
"f_cpu": "150000000L",
|
||||
"mcu": "stm32g431rb",
|
||||
"variant": "MPPT-2420-RC"
|
||||
},
|
||||
"connectivity": [
|
||||
"can"
|
||||
],
|
||||
"debug": {
|
||||
"default_tools": [
|
||||
"jlink"
|
||||
],
|
||||
"jlink_device": "STM32G431RB",
|
||||
"onboard_tools": [
|
||||
"stlink"
|
||||
],
|
||||
"openocd_board": "st_nucleo_g431rb",
|
||||
"svd_path": "STM32G431xx.svd"
|
||||
},
|
||||
"frameworks": [
|
||||
"arduino",
|
||||
"stm32cube",
|
||||
"zephyr"
|
||||
],
|
||||
"name": "Libre Solar MPPT 2420 RC",
|
||||
"upload": {
|
||||
"maximum_ram_size": 32768,
|
||||
"maximum_size": 131072,
|
||||
"protocol": "jlink",
|
||||
"protocols": [
|
||||
"jlink",
|
||||
"stlink",
|
||||
"blackmagic",
|
||||
"mbed"
|
||||
]
|
||||
},
|
||||
"url": "http://libre.solar/",
|
||||
"vendor": "Libre Solar"
|
||||
}
|
||||
@@ -10,6 +10,7 @@
|
||||
# Select the charge controller hardware by uncommenting one of the following lines
|
||||
default_envs =
|
||||
# mppt_2420_lc
|
||||
# mppt_2420_rc
|
||||
# mppt_2420_hpx
|
||||
# mppt_1210_hus
|
||||
# pwm_2420_lus
|
||||
@@ -61,6 +62,10 @@ check_flags =
|
||||
[env:mppt_2420_lc]
|
||||
board = mppt_2420_lc
|
||||
|
||||
# https://github.com/LibreSolar/mppt-2420-rc
|
||||
[env:mppt_2420_rc]
|
||||
board = mppt_2420_rc
|
||||
|
||||
# https://github.com/LibreSolar/MPPT-1210-HUS
|
||||
[env:mppt_1210_hus]
|
||||
board = mppt_1210_hus
|
||||
|
||||
Reference in New Issue
Block a user