Zephyr: MPPT 1210 HUS 0v7 board added

This commit is contained in:
Martin Jaeger
2020-02-05 18:05:55 +01:00
parent 3a8103457f
commit 83d7c36778
14 changed files with 383 additions and 7 deletions
+7
View File
@@ -0,0 +1,7 @@
# SPDX-License-Identifier: Apache-2.0
if(CONFIG_PINMUX)
zephyr_library()
zephyr_library_sources(pinmux.c)
zephyr_library_include_directories(${ZEPHYR_BASE}/drivers)
endif()
+5
View File
@@ -0,0 +1,5 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Martin Jäger / Libre Solar
# include generic charge controller Kconfig
rsource "../../Kconfig"
+6
View File
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Martin Jäger / Libre Solar
config BOARD_MPPT_1210_HUS_0V7
bool "Libre Solar MPPT 1210 HUS v0.7"
depends on SOC_STM32L073XX
+48
View File
@@ -0,0 +1,48 @@
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2019 Martin Jäger / Libre Solar
if BOARD_MPPT_1210_HUS_0V7
config BOARD
default "mppt_1210_hus_0v7"
config HAS_DCDC_CONVERTER
default y
config DCDC_PWM_FREQUENCY_KHZ
default 50
config DCDC_PWM_DEADTIME_NS
default 230
config HAS_LOAD_OUTPUT
default y
config NUM_LED_PINS
default 3
if UART_CONSOLE
config UART_2
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_1210_HUS_0V7
+6
View File
@@ -0,0 +1,6 @@
# SPDX-License-Identifier: Apache-2.0
board_runner_args(jlink "--device=STM32L073RZ" "--speed=4000")
include(${ZEPHYR_BASE}/boards/common/openocd.board.cmake)
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
+86
View File
@@ -0,0 +1,86 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2020 Martin Jäger / Libre Solar
*/
/dts-v1/;
#include <st/l0/stm32l073Xz.dtsi>
/ {
model = "Libre Solar MPPT 1210 HUS v0.7";
compatible = "st,stm32l073";
chosen {
zephyr,console = &usart1;
zephyr,shell-uart = &usart1;
zephyr,sram = &sram0;
zephyr,flash = &flash0;
};
leds {
compatible = "gpio-leds";
a {
gpios = <&gpiob 13 GPIO_INT_ACTIVE_HIGH>;
label = "LED pin A";
};
b {
gpios = <&gpiob 14 GPIO_INT_ACTIVE_HIGH>;
label = "LED pin B";
};
c {
gpios = <&gpiob 2 GPIO_INT_ACTIVE_HIGH>;
label = "LED pin C";
};
};
switches {
compatible = "switch";
load-en {
gpios = <&gpioc 13 GPIO_DIR_IN>;
label = "Load enable";
};
usb-pwr-en {
gpios = <&gpiob 10 GPIO_DIR_IN>;
label = "USB charging port enable";
};
v-solar-en {
gpios = <&gpioc 14 GPIO_DIR_IN>;
label = "Solar voltage measurement enable";
};
};
aliases {
uart-dbg = &usart1;
uext-uart = &usart2;
spi-uext = &spi1;
i2c-uext = &i2c1;
};
};
&usart1 {
current-speed = <115200>;
status = "okay";
};
&usart2 {
current-speed = <115200>;
status = "okay";
};
&i2c1 {
status = "okay";
clock-frequency = <I2C_BITRATE_FAST>;
};
&spi1 {
status = "okay";
};
&iwdg {
status = "okay";
};
&adc1 {
status = "okay";
};
+17
View File
@@ -0,0 +1,17 @@
identifier: mppt_1210_hus_0v7
name: MPPT-1210-HUS-0V7
type: mcu
arch: arm
toolchain:
- zephyr
- gnuarmemb
- xtools
ram: 20
flash: 192
supported:
- arduino_i2c
- gpio
- i2c
- spi
- watchdog
- adc
+37
View File
@@ -0,0 +1,37 @@
# SPDX-License-Identifier: Apache-2.0
# Zephyr Kernel Configuration
CONFIG_ARM=y
CONFIG_SOC_SERIES_STM32L0X=y
# Platform Configuration
CONFIG_SOC_STM32L073XX=y
# General Kernel Options
CONFIG_CORTEX_M_SYSTICK=y
CONFIG_SYS_CLOCK_HW_CYCLES_PER_SEC=32000000
# Serial Drivers
CONFIG_SERIAL=y
CONFIG_UART_INTERRUPT_DRIVEN=y
# enable console
CONFIG_CONSOLE=y
CONFIG_UART_CONSOLE=y
# Pinmux Driver
CONFIG_PINMUX=y
# GPIO Controller
CONFIG_GPIO=y
# Clock configuration
CONFIG_CLOCK_CONTROL=y
# SYSCLK selection
CONFIG_CLOCK_STM32_SYSCLK_SRC_PLL=y
# PLL configuration
CONFIG_CLOCK_STM32_PLL_SRC_HSI=y
CONFIG_CLOCK_STM32_PLL_MULTIPLIER=4
CONFIG_CLOCK_STM32_PLL_DIVISOR=2
CONFIG_CLOCK_STM32_AHB_PRESCALER=1
CONFIG_CLOCK_STM32_APB1_PRESCALER=1
+74
View File
@@ -0,0 +1,74 @@
/*
* SPDX-License-Identifier: Apache-2.0
*
* Copyright (c) 2019 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>
// 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
{STM32_PIN_PA9, STM32L0_PINMUX_FUNC_PA9_USART1_TX},
{STM32_PIN_PA10, STM32L0_PINMUX_FUNC_PA10_USART1_RX},
#endif /* CONFIG_UART_1 */
#ifdef CONFIG_UART_2
{STM32_PIN_PA2, STM32L0_PINMUX_FUNC_PA2_USART2_TX},
{STM32_PIN_PA3, STM32L0_PINMUX_FUNC_PA3_USART2_RX},
#endif /* CONFIG_UART_2 */
#ifdef CONFIG_I2C_1
{STM32_PIN_PB6, STM32L0_PINMUX_FUNC_PB6_I2C1_SCL},
{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},
#endif /* CONFIG_SPI_1 */
#ifdef CONFIG_ADC_1
{STM32_PIN_PA0, STM32L0_PINMUX_FUNC_PA0_ADC_IN0},
#endif /* CONFIG_ADC_1 */
#ifdef CONFIG_DAC_1
{STM32_PIN_PA4, STM32L0_PINMUX_FUNC_PA4_DAC_OUT1},
#endif /* CONFIG_ADC_1 */
};
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[CONFIG_NUM_LED_PINS] = {
DT_GPIO_LEDS_A_GPIOS_CONTROLLER,
DT_GPIO_LEDS_C_GPIOS_CONTROLLER,
DT_GPIO_LEDS_B_GPIOS_CONTROLLER,
};
const int led_pins[CONFIG_NUM_LED_PINS] = {
DT_GPIO_LEDS_A_GPIOS_PIN,
DT_GPIO_LEDS_C_GPIOS_PIN,
DT_GPIO_LEDS_B_GPIOS_PIN,
};
+27
View File
@@ -0,0 +1,27 @@
# STM32L072 MCU
source [find interface/stlink.cfg]
transport select hla_swd
set WORKAREASIZE 0x2000
source [find target/stm32l0.cfg]
# Add the second flash bank.
set _FLASHNAME $_CHIPNAME.flash1
flash bank $_FLASHNAME stm32lx 0 0 0 0 $_TARGETNAME
# There is only system reset line and JTAG/SWD command can be issued when SRST
reset_config srst_only
$_TARGETNAME configure -event gdb-attach {
echo "Debugger attaching: halting execution"
reset halt
gdb_breakpoint_override hard
}
$_TARGETNAME configure -event gdb-detach {
echo "Debugger detaching: resuming execution"
resume
}
@@ -40,7 +40,7 @@
gpios = <&gpiob 2 GPIO_DIR_IN>;
label = "Load disable";
};
usb-dis {
usb-pwr-dis {
gpios = <&gpiob 5 GPIO_DIR_IN>;
label = "USB charging port disable";
};
+43
View File
@@ -0,0 +1,43 @@
{
"build": {
"cpu": "cortex-m0plus",
"extra_flags": "-DSTM32L073xx",
"f_cpu": "32000000L",
"framework_extra_flags": {
"arduino": "-D__CORTEX_SC=0"
},
"mcu": "stm32l073rz",
"variant": "MPPT-1210-HUS"
},
"debug": {
"default_tools": [
"stlink"
],
"jlink_device": "STM32L073RZ",
"onboard_tools": [
"stlink"
],
"openocd_board": "st_nucleo_l073rz",
"svd_path": "STM32L07x.svd"
},
"frameworks": [
"arduino",
"mbed",
"stm32cube",
"zephyr"
],
"name": "Libre Solar MPPT 1210 HUS v0.7",
"upload": {
"maximum_ram_size": 20480,
"maximum_size": 196608,
"protocol": "stlink",
"protocols": [
"jlink",
"stlink",
"blackmagic",
"mbed"
]
},
"url": "http://libre.solar/",
"vendor": "Libre Solar"
}
+12
View File
@@ -17,6 +17,7 @@ default_envs =
# mppt-1210-hus-v0.6
# mppt-1210-hus-v0.7
# mppt-1210-hus-v0.4-zephyr
# mppt-1210-hus-v0.7-zephyr
# pwm-2420-lus-v0.2
# pwm-2420-lus-v0.3
# pwm-2420-lus-v0.3-bl
@@ -125,6 +126,17 @@ platform = https://github.com/platformio/platform-ststm32.git
lib_ignore = ESP32
extra_scripts = generate_version_file.py
[env:mppt-1210-hus-v0.7-zephyr]
board = mppt_1210_hus_0v7
framework = zephyr
build_flags =
-std=gnu++17
-fsingle-precision-constant
-Wl,-Map,memory.map
platform = https://github.com/platformio/platform-ststm32.git
lib_ignore = ESP32
extra_scripts = generate_version_file.py
[env:mppt-2420-hpx-v0.1-zephyr]
board = mppt_2420_hpx
framework = zephyr
+14 -6
View File
@@ -7,13 +7,15 @@
#ifndef MPPT_1210_HUS_0V7_H
#define MPPT_1210_HUS_0V7_H
#define DEVICE_TYPE "MPPT-1210-HUS"
#define HARDWARE_VERSION "v0.7.1"
#ifdef __MBED__
#include "mbed.h"
#elif defined(__ZEPHYR__)
#include <zephyr.h>
#endif
#define DEVICE_TYPE "MPPT-1210-HUS"
#define HARDWARE_VERSION "v0.7.1"
// specify features of charge controller
#define CONFIG_HAS_DCDC_CONVERTER 1
#define CONFIG_HAS_PWM_SWITCH 0
@@ -67,21 +69,27 @@ enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
#define LED_LOAD 3 // LED4
#define LED_RXTX 4 // LED5, used to indicate when sending data
#ifdef __MBED__
// LED pins and pin state configuration to switch above LEDs on
#define NUM_LED_PINS 3
#ifdef __MBED__
static const PinName led_pins[NUM_LED_PINS] = {
// A B C
PB_13, PB_2, PB_14
};
static const pin_state_t led_pin_setup[NUM_LEDS][NUM_LED_PINS] = {
#elif defined(__ZEPHYR__)
// defined in board definition pinmux.c
extern const char *led_ports[CONFIG_NUM_LED_PINS];
extern const int led_pins[CONFIG_NUM_LED_PINS];
#endif // MBED or ZEPHYR
static const enum pin_state_t led_pin_setup[NUM_LEDS][NUM_LED_PINS] = {
{ PIN_HIGH, PIN_LOW, PIN_FLOAT }, // LED1
{ PIN_LOW, PIN_HIGH, PIN_FLOAT }, // LED2
{ PIN_HIGH, PIN_FLOAT, PIN_LOW }, // LED3
{ PIN_FLOAT, PIN_HIGH, PIN_LOW }, // LED4
{ PIN_FLOAT, PIN_LOW, PIN_HIGH } // LED5
};
#endif // __MBED__
// pin definition only needed in adc_dma.cpp to detect if they are present on the PCB
#define PIN_ADC_TEMP_BAT