Charger-specific features added to Zephyr board spec
Hardware features like PWM switch, DC/DC converter and LED config are now configured in the board definition. Actual source files still need to be changed to use defines with CONFIG_ prefix instead of defines from pcb.h.
This commit is contained in:
@@ -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"
|
||||
@@ -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.
|
||||
- `<BOARD>_defconfig`: Default configuration of the board (can be overwritten by prj.conf)
|
||||
- `<BOARD>.dts`: Main board device tree specification.
|
||||
- `<BOARD>.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`
|
||||
@@ -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"
|
||||
@@ -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"
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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/;
|
||||
|
||||
@@ -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 <kernel.h>
|
||||
@@ -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
|
||||
};
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user