diff --git a/boards/Kconfig b/boards/Kconfig new file mode 100644 index 0000000..ad694f2 --- /dev/null +++ b/boards/Kconfig @@ -0,0 +1,32 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2019 Martin Jaeger (Libre Solar) +# +# Generic Libre Solar Charge Controller configuration +# + +# Invisible (hardware-specific) Kconfig symbols + +config HAS_DCDC_CONVERTER + bool + help + "Board has a DC/DC converter" + +config HAS_PWM_SWITCH + bool + help + "PCB has PWM power switch" + +config HAS_LOAD_OUTPUT + bool + help + "PCB has a load output" + +config NUM_LED_PINS + int + help + "Number of LED pins for charlieplexing" + +# Visible (user-configurable) Kconfig symbols + +config OLED_DISPLAY + bool "OLED display connected via UEXT" diff --git a/boards/README.md b/boards/README.md new file mode 100644 index 0000000..6d27284 --- /dev/null +++ b/boards/README.md @@ -0,0 +1,21 @@ +# Configuration of supported boards + +## Zephyr board definition + +The definitions found in `boards/arm/my-board/` folders are used directly by Zephyr. + +More detiails can be found in Zephyr +[porting guide](https://docs.zephyrproject.org/latest/guides/porting/board_porting.html) and +[Kconfig description](https://docs.zephyrproject.org/latest/guides/kconfig/setting.html#the-initial-configuration). + +- `board.cmake`, `CMakeLists.txt`: CMake definitions for board, normally don't need to be touched. +- `Kconfig.board`: Defines the name of the board as used in DTS config. +- `Kconfig.defconfig`: Configuration of invisible Kconfig symbols, i.e. symbols that should not be adjustable by the user via menuconfig. +- `_defconfig`: Default configuration of the board (can be overwritten by prj.conf) +- `.dts`: Main board device tree specification. +- `.yaml`: +- `pinmux.c`: Defines which pins should be used for peripherals like SPI1, SPI2, SPI3 if selected by the user. + +## PlatformIO configuration + +PlatformIO needs an additional definition file for each board. It is stored as `boards/my-board.json` diff --git a/boards/arm/mppt1210hus_0v4/Kconfig b/boards/arm/mppt1210hus_0v4/Kconfig new file mode 100644 index 0000000..9cddfe1 --- /dev/null +++ b/boards/arm/mppt1210hus_0v4/Kconfig @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: Apache-2.0 +# Copyright (c) 2019 Martin Jäger / Libre Solar + +# include generic charge controller Kconfig +source "$(BOARD_DIR)/../../Kconfig" diff --git a/boards/arm/mppt1210hus_0v4/Kconfig.board b/boards/arm/mppt1210hus_0v4/Kconfig.board index d50f13b..f3f1cf0 100755 --- a/boards/arm/mppt1210hus_0v4/Kconfig.board +++ b/boards/arm/mppt1210hus_0v4/Kconfig.board @@ -1,9 +1,5 @@ -# Kconfig - Libre Solar MPPT 1210 HUS v0.4 -# -# Copyright (c) 2019 Martin Jäger (Libre Solar) -# # SPDX-License-Identifier: Apache-2.0 -# +# Copyright (c) 2019 Martin Jäger / Libre Solar config BOARD_MPPT1210HUS_0V4 bool "Libre Solar MPPT 1210 HUS v0.4" diff --git a/boards/arm/mppt1210hus_0v4/Kconfig.defconfig b/boards/arm/mppt1210hus_0v4/Kconfig.defconfig index 50a9905..184e408 100755 --- a/boards/arm/mppt1210hus_0v4/Kconfig.defconfig +++ b/boards/arm/mppt1210hus_0v4/Kconfig.defconfig @@ -1,15 +1,20 @@ -# Kconfig - Libre Solar MPPT 1210 HUS v0.4 -# -# Copyright (c) 2019 Martin Jäger (Libre Solar) -# # SPDX-License-Identifier: Apache-2.0 -# +# Copyright (c) 2019 Martin Jäger / Libre Solar if BOARD_MPPT1210HUS_0V4 config BOARD default "mppt1210hus_0v4" +config HAS_DCDC_CONVERTER + default y + +config HAS_LOAD_OUTPUT + default y + +config NUM_LED_PINS + default 5 + if UART_CONSOLE config UART_2 diff --git a/boards/arm/mppt1210hus_0v4/mppt1210hus_0v4.dts b/boards/arm/mppt1210hus_0v4/mppt1210hus_0v4.dts index 7adc46c..e9aa5d2 100755 --- a/boards/arm/mppt1210hus_0v4/mppt1210hus_0v4.dts +++ b/boards/arm/mppt1210hus_0v4/mppt1210hus_0v4.dts @@ -1,7 +1,7 @@ /* - * Copyright (c) 2019 Martin Jäger (Libre Solar) - * * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2019 Martin Jäger / Libre Solar */ /dts-v1/; diff --git a/boards/arm/mppt1210hus_0v4/pinmux.c b/boards/arm/mppt1210hus_0v4/pinmux.c index dc1475b..103adbc 100755 --- a/boards/arm/mppt1210hus_0v4/pinmux.c +++ b/boards/arm/mppt1210hus_0v4/pinmux.c @@ -1,7 +1,7 @@ /* - * Copyright (c) 2019 Martin Jäger / Libre Solar - * * SPDX-License-Identifier: Apache-2.0 + * + * Copyright (c) 2019 Martin Jäger / Libre Solar */ #include @@ -58,3 +58,18 @@ static int pinmux_stm32_init(struct device *port) SYS_INIT(pinmux_stm32_init, PRE_KERNEL_1, CONFIG_PINMUX_STM32_DEVICE_INITIALIZATION_PRIORITY); + +const char *led_ports[CONFIG_NUM_LED_PINS] = { + DT_ALIAS_LED_A_GPIOS_CONTROLLER, + DT_ALIAS_LED_B_GPIOS_CONTROLLER, + DT_ALIAS_LED_C_GPIOS_CONTROLLER, + DT_ALIAS_LED_D_GPIOS_CONTROLLER, + DT_ALIAS_LED_E_GPIOS_CONTROLLER +}; +const int led_pins[CONFIG_NUM_LED_PINS] = { + DT_ALIAS_LED_A_GPIOS_PIN, // GND + DT_ALIAS_LED_B_GPIOS_PIN, // SOC12 + DT_ALIAS_LED_C_GPIOS_PIN, // SOC3 + DT_ALIAS_LED_D_GPIOS_PIN, // RXTX + DT_ALIAS_LED_E_GPIOS_PIN // LOAD +}; diff --git a/boards/arm/mppt1210hus_0v4/support/openocd.cfg b/boards/arm/mppt1210hus_0v4/support/openocd.cfg index 00f68a6..b2f37ca 100755 --- a/boards/arm/mppt1210hus_0v4/support/openocd.cfg +++ b/boards/arm/mppt1210hus_0v4/support/openocd.cfg @@ -1,5 +1,5 @@ -# This is an ST NUCLEO-L073RZ board with single STM32L073RZ chip. -# http://www.st.com/en/evaluation-tools/nucleo-l073rz.html +# STM32L072 MCU + source [find interface/stlink.cfg] transport select hla_swd diff --git a/src/pcbs/mppt_1210_hus_0v4.h b/src/pcbs/mppt_1210_hus_0v4.h index 6a915a5..1b742b6 100644 --- a/src/pcbs/mppt_1210_hus_0v4.h +++ b/src/pcbs/mppt_1210_hus_0v4.h @@ -69,23 +69,12 @@ static const PinName led_pins[NUM_LED_PINS] = { PB_14, PB_13, PB_2, PB_11, PB_10 }; #elif defined(__ZEPHYR__) -static const char *led_ports[NUM_LED_PINS] = { - DT_ALIAS_LED_A_GPIOS_CONTROLLER, - DT_ALIAS_LED_B_GPIOS_CONTROLLER, - DT_ALIAS_LED_C_GPIOS_CONTROLLER, - DT_ALIAS_LED_D_GPIOS_CONTROLLER, - DT_ALIAS_LED_E_GPIOS_CONTROLLER -}; -static const int led_pins[NUM_LED_PINS] = { - DT_ALIAS_LED_A_GPIOS_PIN, // GND - DT_ALIAS_LED_B_GPIOS_PIN, // SOC12 - DT_ALIAS_LED_C_GPIOS_PIN, // SOC3 - DT_ALIAS_LED_D_GPIOS_PIN, // RXTX - DT_ALIAS_LED_E_GPIOS_PIN // LOAD -}; +// defined in boar 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 pin_state_t led_pin_setup[NUM_LEDS][NUM_LED_PINS] = { +const pin_state_t led_pin_setup[NUM_LEDS][NUM_LED_PINS] = { { PIN_HIGH, PIN_LOW, PIN_LOW, PIN_LOW, PIN_LOW }, // LED1 { PIN_LOW, PIN_HIGH, PIN_LOW, PIN_LOW, PIN_LOW }, // LED2 { PIN_LOW, PIN_LOW, PIN_HIGH, PIN_LOW, PIN_LOW }, // LED3