Move PCB and user config to board Kconfig

Files in src/pcbs/xyz.h are moved to boards/xyz/board.h. User settings from
src/config.h are also configured via Kconfig, so the file is removed.
This commit is contained in:
Martin Jäger
2020-04-30 10:53:58 +02:00
parent 2d74a3a554
commit 2a71d02aeb
46 changed files with 108 additions and 463 deletions
+1 -2
View File
@@ -9,8 +9,7 @@
#include <math.h> // for fabs function
#include <stdio.h>
#include "config.h"
#include "pcb.h"
#include "board.h"
#include "helper.h"
#include "device_status.h"
-2
View File
@@ -11,8 +11,6 @@
#ifdef BOOTLOADER_ENABLED
#include "config.h"
#include <cstdint>
/** Length of the bootloader name string (including \0 termination) */
-95
View File
@@ -1,95 +0,0 @@
/*
* Copyright (c) 2017 Martin Jäger / Libre Solar
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef CONFIG_H
#define CONFIG_H
#ifndef __ZEPHYR__
#include "pcb.h"
/** @file
*
* @brief
* Used to define personal settings, e.g. which type of interface at the UEXT port should be used.
*/
// PWM charge controller
#define CONFIG_PWM_TERMINAL_SOLAR CONFIG_HAS_PWM_SWITCH
// MPPT buck/boost or nanogrid mode
#define CONFIG_HV_TERMINAL_SOLAR CONFIG_HAS_DCDC_CONVERTER
#define CONFIG_HV_TERMINAL_NANOGRID 0
// battery always assumed to be at low-voltage terminal (might need to be changed for boost mode)
#define CONFIG_LV_TERMINAL_BATTERY 1
// basic battery configuration
#define BATTERY_TYPE BAT_TYPE_GEL ///< GEL most suitable for general batteries (see bat_charger.h for other types)
#define BATTERY_NUM_CELLS 6 ///< For lead-acid batteries: 6 for 12V system, 12 for 24V system
#define BATTERY_CAPACITY 40 ///< Cell capacity or sum of parallel cells capacity (Ah)
#define CONFIG_DEVICE_ID 12345678
// This enables a safety-feature for the MPPT charge controllers to blow the fuse and disable
// charging in case the HS MOSFET was shorted (e.g. by someone connecting a solar panel with
// too high voltage).
#define CONFIG_HS_MOSFET_FAIL_SAFE_PROTECTION 1
#define THINGSET_USER_PASSWORD "user123"
#define THINGSET_MAKER_PASSWORD "maker456"
// can be used to configure custom data objects in separate file instead (e.g. data_objects_custom.cpp)
//#define CUSTOM_DATA_OBJECTS_FILE
// OLED display at UEXT port
#define CONFIG_EXT_OLED_DISPLAY 1
// OLED Brightness (value 0x01-0xff or 1-255)
// leave undefined to use default
#define OLED_BRIGHTNESS 0x1
// UART serial at SWD connector
#define CONFIG_EXT_THINGSET_SERIAL 1
// CAN bus drivers (not supported by all charge controllers)
#define CONFIG_EXT_THINGSET_CAN 0
// LoRa board RFM9x connected to UEXT port
// https://github.com/LibreSolar/UEXT_LoRa
//#define LORA_ENABLED
// GSM board based on SIM800L connected to UEXT port
// https://github.com/LibreSolar/UEXT_GSM
//#define GSM_ENABLED
#define GSM_APN "internet.t-d1.de" // Access point name of network provider
#define GSM_NUMBER "" // empty if not needed
#define GSM_PIN "1234" // empty if not needed
#define GSM_USER "" // empty if not needed
#define GSM_PASS "" // empty if not needed
// WiFi board based on ESP32 connected to UEXT port
//#define WIFI_ENABLED
#define WIFI_SSID "ssid"
#define WIFI_PASS "pass"
// OpenEnergyMonitor emoncms configuration (used in WiFi interface)
#define EMONCMS_ENABLED
#define EMONCMS_HOST ""
#define EMONCMS_APIKEY "" // get from emoncms webinterface
#define EMONCMS_NODE "mppt" // name of your device
// MQTT server configuration (used in GSM or WiFi interface)
#define MQTT_ENABLED
#define MQTT_HOST "your-host-or-ip"
#define MQTT_PORT "1883"
#define MQTT_USER "you"
#define MQTT_PASS "pass"
#define MQTT_PUBLISH_TOPIC "nodes2server/report"
#define MQTT_SUBSCRIBE_TOPIC "server2node/state-req"
#endif
#endif /* CONFIG_H */
+1 -9
View File
@@ -9,18 +9,10 @@
#include <math.h> // log for thermistor calculation
#include <assert.h>
#ifdef __MBED__
#include "mbed.h"
#endif
#include "mcu.h"
#include "setup.h"
#include "debug.h"
#include "pcb.h" // contains defines for pins
#if defined(__MBED__) && defined(PIN_REF_I_DCDC)
AnalogOut ref_i_dcdc(PIN_REF_I_DCDC);
#endif
#include "board.h" // contains defines for pins
static float solar_current_offset;
static float load_current_offset;
+1 -1
View File
@@ -34,7 +34,7 @@
#include <stm32g4xx_ll_bus.h>
#endif
#include "pcb.h"
#include "board.h"
#include "debug.h"
#if !defined(CONFIG_SOC_SERIES_STM32F0X) && !defined(CONFIG_SOC_SERIES_STM32L0X)
+1 -2
View File
@@ -8,8 +8,7 @@
#include "setup.h"
#include "pcb.h"
#include "config.h"
#include "board.h"
#include "version.h"
// can be used to configure custom data objects in separate file instead
+4 -4
View File
@@ -10,7 +10,7 @@
#include <stdlib.h> // for min/max function
#include <stdio.h>
#include "pcb.h"
#include "board.h"
#include "device_status.h"
#include "debug.h"
#include "helper.h"
@@ -190,7 +190,7 @@ void Dcdc::control()
// high-side MOSFET must be broken --> set flag and let main() decide
// what to do... (e.g. call dcdc_self_destruction)
current_debounce_counter++;
if (current_debounce_counter > CONTROL_FREQUENCY) { // waited 1s before setting the flag
if (current_debounce_counter > CONFIG_CONTROL_FREQUENCY) { // waited 1s before setting the flag
dev_stat.set_error(ERR_DCDC_HS_MOSFET_SHORT);
}
}
@@ -201,7 +201,7 @@ void Dcdc::control()
// wait at least 100 ms for voltages to settle
static const int num_wait_calls =
(CONTROL_FREQUENCY / 10 >= 1) ? (CONTROL_FREQUENCY / 10) : 1;
(CONFIG_CONTROL_FREQUENCY / 10 >= 1) ? (CONFIG_CONTROL_FREQUENCY / 10) : 1;
int startup_mode = check_start_conditions();
@@ -246,7 +246,7 @@ void Dcdc::test()
// wait at least 100 ms for voltages to settle
static const int num_wait_calls =
(CONTROL_FREQUENCY / 10 >= 1) ? (CONTROL_FREQUENCY / 10) : 1;
(CONFIG_CONTROL_FREQUENCY / 10 >= 1) ? (CONFIG_CONTROL_FREQUENCY / 10) : 1;
if (startup_delay_counter > num_wait_calls) {
if (check_start_conditions() != 0) {
+1 -2
View File
@@ -9,8 +9,7 @@
#include <math.h> // for fabs function
#include <stdio.h>
#include "config.h"
#include "pcb.h"
#include "board.h"
#include "setup.h"
#include "helper.h"
+1 -1
View File
@@ -9,7 +9,7 @@
#include <stdio.h>
#include "mcu.h"
#include "pcb.h"
#include "board.h"
#include "thingset.h"
#include "helper.h"
+1 -3
View File
@@ -6,8 +6,6 @@
#ifndef UNIT_TEST
#include "config.h"
#if CONFIG_EXT_THINGSET_CAN
#include "ext.h"
@@ -22,7 +20,7 @@
#include "mbed.h"
#endif
#include "pcb.h"
#include "board.h"
#include "thingset.h"
#include "data_objects.h"
#include "can_msg_queue.h"
-2
View File
@@ -6,8 +6,6 @@
#ifndef UNIT_TEST
#include "config.h"
#if CONFIG_EXT_THINGSET_CAN
#include "ext/can_msg_queue.h"
+1 -3
View File
@@ -6,8 +6,6 @@
#ifndef UNIT_TEST
#include "config.h"
#if CONFIG_EXT_OLED_DISPLAY // otherwise don't compile code to reduce firmware size
#include "ext/ext.h"
@@ -21,7 +19,7 @@
#include "setup.h"
#include "half_bridge.h"
#include "pcb.h"
#include "board.h"
#include "oled_ssd1306.h"
// implement specific extension inherited from ExtInterface
-2
View File
@@ -6,8 +6,6 @@
#ifndef UNIT_TEST
#include "config.h"
#if CONFIG_EXT_THINGSET_SERIAL // otherwise don't compile code to reduce firmware size
#include "ext.h"
-2
View File
@@ -4,8 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "config.h"
/** EXT interface description template
*
* The UEXT port can be used to connect several different extension modules to the charge controller.
+1 -3
View File
@@ -6,15 +6,13 @@
#ifndef UNIT_TEST
#include "config.h"
#ifdef WIFI_ENABLED
#include <inttypes.h>
#include "load.h"
#include "thingset.h"
#include "pcb.h"
#include "board.h"
#include "ESP32.h"
UARTSerial uext_serial(PIN_UEXT_TX, PIN_UEXT_RX, 115200);
+1 -2
View File
@@ -9,8 +9,7 @@
#include <stdio.h>
#include "mcu.h"
#include "pcb.h"
#include "config.h"
#include "board.h"
static int _pwm_resolution;
static float _min_duty;
+1 -1
View File
@@ -7,7 +7,7 @@
#include "hardware.h"
#include "mcu.h"
#include "pcb.h"
#include "board.h"
#include "load.h"
#include "half_bridge.h"
#include "leds.h"
+1 -1
View File
@@ -6,7 +6,7 @@
#include "leds.h"
#include "pcb.h"
#include "board.h"
static int led_states[NUM_LEDS]; // must be one of enum LedState
static int trigger_timeout[NUM_LEDS]; // seconds until trigger should end
+5 -6
View File
@@ -6,8 +6,7 @@
#include "load.h"
#include "pcb.h"
#include "config.h"
#include "board.h"
#include "leds.h"
#include "device_status.h"
#include "debug.h"
@@ -43,10 +42,10 @@ void LoadOutput::control()
dev_stat.internal_temp - junction_temperature +
current * current /
(LOAD_CURRENT_MAX * LOAD_CURRENT_MAX) *
(MOSFET_MAX_JUNCTION_TEMP - INTERNAL_MAX_REFERENCE_TEMP)
) / (MOSFET_THERMAL_TIME_CONSTANT * CONTROL_FREQUENCY);
(CONFIG_MOSFET_MAX_JUNCTION_TEMP - CONFIG_INTERNAL_MAX_REFERENCE_TEMP)
) / (CONFIG_MOSFET_THERMAL_TIME_CONSTANT * CONFIG_CONTROL_FREQUENCY);
if (junction_temperature > MOSFET_MAX_JUNCTION_TEMP || current > LOAD_CURRENT_MAX * 2) {
if (junction_temperature > CONFIG_MOSFET_MAX_JUNCTION_TEMP || current > LOAD_CURRENT_MAX * 2) {
flags_set(&error_flags, ERR_LOAD_OVERCURRENT);
oc_timestamp = uptime();
}
@@ -65,7 +64,7 @@ void LoadOutput::control()
// off the solar input instead of the load output)
if (bus->voltage > overvoltage || bus->voltage > LOW_SIDE_VOLTAGE_MAX) {
ov_debounce_counter++;
if (ov_debounce_counter > CONTROL_FREQUENCY) { // waited 1s before setting the flag
if (ov_debounce_counter > CONFIG_CONTROL_FREQUENCY) { // waited 1s before setting the flag
flags_set(&error_flags, ERR_LOAD_OVERVOLTAGE);
}
}
+1 -2
View File
@@ -29,8 +29,7 @@ static struct device *dev_usb;
#endif // UNIT_TEST
#include "pcb.h"
#include "config.h"
#include "board.h"
#include "hardware.h"
#include "leds.h"
#include "device_status.h"
+1 -2
View File
@@ -12,8 +12,7 @@
#include <drivers/gpio.h>
#include "thingset.h" // handles access to internal data via communication interfaces
#include "pcb.h" // hardware-specific settings
#include "config.h" // user-specific configuration
#include "board.h" // hardware-specific settings
#include "setup.h"
#include "helper.h"
-81
View File
@@ -1,81 +0,0 @@
/*
* Copyright (c) 2017 Martin Jäger / Libre Solar
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef PCB_H
#define PCB_H
/** @file
*
* @brief
* Includes PCB hardware specific settings like pin names depending on the compiler flags set in platformio.ini.
*/
// specific board settings
///////////////////////////////////////////////////////////////////////////////
#if defined(CONFIG_BOARD_MPPT_2420_LC_0V10)
#include "pcbs/mppt_2420_lc_0v10.h"
#elif defined(CONFIG_BOARD_MPPT_1210_HUS_0V2)
#include "pcbs/mppt_1210_hus_0v2.h"
#elif defined(CONFIG_BOARD_MPPT_1210_HUS_0V4)
#include "pcbs/mppt_1210_hus_0v4.h"
#elif defined(CONFIG_BOARD_MPPT_1210_HUS_0V7)
#include "pcbs/mppt_1210_hus_0v7.h"
#elif defined(CONFIG_BOARD_MPPT_2420_HPX)
#include "pcbs/mppt_2420_hpx_0v1.h"
#elif defined(CONFIG_BOARD_PWM_2420_LUS_0V2) || defined(CONFIG_BOARD_PWM_2420_LUS_0V3)
#include "pcbs/pwm_2420_lus.h"
#elif defined(UNIT_TEST)
#include "pcbs/pcb_stub.h"
#else
#error "PCB has to be specified!"
#endif
// generic default settings (if not defined different in board config)
///////////////////////////////////////////////////////////////////////////////
/** Main control function frequency (Hz)
*
* Frequencies higher than 10 Hz caused issues with MPPT control during lab test with
* PV simulator. Might be different with actual solar panel.
*/
#ifndef CONTROL_FREQUENCY
#define CONTROL_FREQUENCY 10
#endif
/** Maximum Tj of MOSFETs (°C)
*
* This value is used for model-based control of overcurrent protection. It represents
* the steady-state junction temperature for max. continuous current at ambient
* temperature of 25°C.
*/
#ifndef MOSFET_MAX_JUNCTION_TEMP
#define MOSFET_MAX_JUNCTION_TEMP 120
#endif
/** Internal reference temperature at full load (°C)
*
* This value is used for model-based control of overcurrent protection. It represents
* the steady-state internal temperature for max. continuous current at ambient
* temperature of 25°C. Value here is conservative and can be overwritten in PCB configuration.
*/
#ifndef INTERNAL_MAX_REFERENCE_TEMP
#define INTERNAL_MAX_REFERENCE_TEMP 50
#endif
/** Thermal time constant junction to ambient (s)
*
* This value is used for model-based control of overcurrent protection. It does not reflect
* the much lower MOSFET-internal time constant junction to case, but includes thermal inertia
* of the board.
*
* Around 5s seems to be a good conservative estimation for 5x6 type SMD MOSFETs
*/
#ifndef MOSFET_THERMAL_TIME_CONSTANT
#define MOSFET_THERMAL_TIME_CONSTANT 5
#endif
#endif /* PCB_H */
-119
View File
@@ -1,119 +0,0 @@
/*
* Copyright (c) 2018 Martin Jäger / Libre Solar
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef MPPT_1210_HUS_0V2_H
#define MPPT_1210_HUS_0V2_H
#define DEVICE_TYPE "MPPT-1210-HUS"
#define HARDWARE_VERSION "v0.2"
#include "mbed.h"
// specify features of charge controller
#define CONFIG_HAS_DCDC_CONVERTER 1
#define CONFIG_HAS_PWM_SWITCH 0
#define CONFIG_HAS_LOAD_OUTPUT 1
#define CONFIG_HAS_USB_PWR_OUTPUT 1
// DC/DC converter settings
#define PWM_FREQUENCY 50 // kHz 50 = better for cloud solar to increase efficiency
#define PWM_DEADTIME 300 // ns
#define PWM_TIM 1 // use TIM1 timer
#define DCDC_CURRENT_MAX 8 // PCB maximum DCDC output current
#define LOAD_CURRENT_MAX 10 // PCB maximum load switch current
#define LOW_SIDE_VOLTAGE_MAX 16 // Maximum voltage at battery port (V)
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
#define PIN_UEXT_SDA PB_7
#define PIN_UEXT_MISO PB_4
#define PIN_UEXT_MOSI PB_5
#define PIN_UEXT_SCK PB_3
#define PIN_UEXT_SSEL PA_15 // different than 20A MPPT
#define PIN_SWD_TX PA_9
#define PIN_SWD_RX PA_10
/*
#define PIN_LED_PWR PB_14 // LED1
//#define PIN_LED_DCDC PB_15 // LED2
#define PIN_LED_RXTX PB_15 // LED2
#define PIN_LED_LOAD PB_12 // LED3
*/
#define PIN_LOAD_DIS PB_2
#define PIN_USB_PWR_EN PC_13
#define PIN_USB_PWR_FLG PC_14
#define PIN_REF_I_DCDC PA_4
#define PIN_EEPROM_SCL PB_10
#define PIN_EEPROM_SDA PB_11
#define EEPROM_24AA32
enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
// assignment LED numbers on PCB to their meaning
#define NUM_LEDS 3
#define LED_PWR 0 // LED1
#define LED_RXTX 1 // LED2, used to indicate when sending data
#define LED_LOAD 2 // LED3
// LED pins and pin state configuration to switch above LEDs on
#define NUM_LED_PINS 3
static const PinName led_pins[NUM_LED_PINS] = {
// PWR RXTX LOAD
PB_14, PB_15, PB_12
};
static const pin_state_t led_pin_setup[NUM_LEDS][NUM_LED_PINS] = {
{ PIN_HIGH, PIN_LOW, PIN_LOW }, // LED1
{ PIN_LOW, PIN_HIGH, PIN_LOW }, // LED2
{ PIN_LOW, PIN_LOW, PIN_HIGH } // LED3
};
// typical value for Semitec 103AT-5 thermistor: 3435
#define NTC_BETA_VALUE 3435
#define NTC_SERIES_RESISTOR 10000.0
#define ADC_GAIN_V_LOW (110.0 / 10 ) // battery voltage divider 100k + 10k
#define ADC_GAIN_V_HIGH (105.6 / 5.6) // solar voltage divider: 100k + 5.6k
#define ADC_GAIN_I_LOAD (1000 / 4 / (1500.0 / 22.0)) // op amp gain: 150/2.2 = 68.2, resistor: 4 mOhm
#define ADC_GAIN_I_DCDC (1000 / 4 / (1500.0 / 22.0))
// position in the array written by the DMA controller
enum {
ADC_POS_TEMP_BAT, // ADC 0
ADC_POS_TEMP_FETS, // ADC 1
ADC_POS_V_REF, // ADC 5
ADC_POS_V_LOW, // ADC 6
ADC_POS_V_HIGH, // ADC 7
ADC_POS_I_LOAD, // ADC 8
ADC_POS_I_DCDC, // ADC 9
ADC_POS_TEMP_MCU, // ADC 16
ADC_POS_VREF_MCU, // ADC 17
NUM_ADC_CH // trick to get the number of enums
};
#define NUM_ADC_1_CH NUM_ADC_CH
// selected ADC channels (has to match with above enum)
#define ADC_CHSEL ( \
ADC_CHSELR_CHSEL0 | \
ADC_CHSELR_CHSEL1 | \
ADC_CHSELR_CHSEL5 | \
ADC_CHSELR_CHSEL6 | \
ADC_CHSELR_CHSEL7 | \
ADC_CHSELR_CHSEL8 | \
ADC_CHSELR_CHSEL9 | \
ADC_CHSELR_CHSEL16 | \
ADC_CHSELR_CHSEL17 \
)
#endif
-140
View File
@@ -1,140 +0,0 @@
/*
* Copyright (c) 2018 Martin Jäger / Libre Solar
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef MPPT_1210_HUS_0V4_H
#define MPPT_1210_HUS_0V4_H
#ifdef __MBED__
#include "mbed.h"
#elif defined(__ZEPHYR__)
#include <zephyr.h>
#endif
#define DEVICE_TYPE "MPPT-1210-HUS"
#define HARDWARE_VERSION "v0.4"
// specify features of charge controller
#define CONFIG_HAS_DCDC_CONVERTER 1
#define CONFIG_HAS_PWM_SWITCH 0
#define CONFIG_HAS_LOAD_OUTPUT 1
#define CONFIG_HAS_USB_PWR_OUTPUT 1
// DC/DC converter settings
#define PWM_FREQUENCY 50 // kHz 50 = better for cloud solar to increase efficiency
#define PWM_DEADTIME 230 // ns
#define PWM_TIM 3 // use TIM3 timer
#define DCDC_CURRENT_MAX 10 // PCB maximum DCDC output current
#define LOAD_CURRENT_MAX 10 // PCB maximum load switch current
#define LOW_SIDE_VOLTAGE_MAX 16 // Maximum voltage at battery port (V)
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
#define PIN_UEXT_SDA PB_7
#define PIN_UEXT_MISO PB_4
#define PIN_UEXT_MOSI PB_5
#define PIN_UEXT_SCK PB_3
#define PIN_UEXT_SSEL PA_15
#define PIN_SWD_TX PA_9
#define PIN_SWD_RX PA_10
#define PIN_LOAD_EN PC_13
#define PIN_USB_PWR_EN PB_12
#define PIN_REF_I_DCDC PA_4
enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
// assignment LED numbers on PCB to their meaning
#define NUM_LEDS 5
#define LED_SOC_1 0 // LED1
#define LED_SOC_2 1 // LED2
#define LED_SOC_3 2 // LED3
#define LED_RXTX 3 // LED4, used to indicate when sending data
#define LED_LOAD 4 // LED5
// LED pins and pin state configuration to switch above LEDs on
#define NUM_LED_PINS 5
#ifdef __MBED__
static const PinName led_pins[NUM_LED_PINS] = {
// GND SOC12 SOC3 RXTX LOAD
PB_14, PB_13, PB_2, PB_11, PB_10
};
#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
const enum 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
{ PIN_LOW, PIN_LOW, PIN_LOW, PIN_HIGH, PIN_LOW }, // LED4
{ PIN_LOW, PIN_LOW, PIN_LOW, PIN_LOW, PIN_HIGH } // LED5
};
// pin definition only needed in adc_dma.cpp to detect if they are present on the PCB
#define PIN_ADC_TEMP_FETS PA_5
// typical value for Semitec 103AT-5 thermistor: 3435
#define NTC_BETA_VALUE 3435
#define NTC_SERIES_RESISTOR 10000.0
#define ADC_GAIN_V_LOW (105.6 / 5.6) // both voltage dividers: 100k + 5.6k
#define ADC_GAIN_V_HIGH (105.6 / 5.6)
#define ADC_GAIN_I_LOAD (1000 / 4 / 50) // amp gain: 50, resistor: 4 mOhm
#define ADC_GAIN_I_DCDC (1000 / 4 / 50)
// position in the array written by the DMA controller
enum {
ADC_POS_V_LOW, // ADC 0 (PA_0)
ADC_POS_V_HIGH, // ADC 1 (PA_1)
ADC_POS_TEMP_FETS, // ADC 5 (PA_5)
ADC_POS_I_LOAD, // ADC 6 (PA_6)
ADC_POS_I_DCDC, // ADC 7 (PA_7)
#if defined(STM32F0) || defined(CONFIG_SOC_SERIES_STM32F0X)
ADC_POS_TEMP_MCU, // ADC 16
ADC_POS_VREF_MCU, // ADC 17
#elif defined(STM32L0) || defined(CONFIG_SOC_SERIES_STM32L0X)
ADC_POS_VREF_MCU, // ADC 17
ADC_POS_TEMP_MCU, // ADC 18
#endif
NUM_ADC_CH // trick to get the number of elements
};
#define NUM_ADC_1_CH NUM_ADC_CH
// selected ADC channels (has to match with above enum)
#if defined(STM32F0) || defined(CONFIG_SOC_SERIES_STM32F0X)
#define ADC_CHSEL ( \
ADC_CHSELR_CHSEL0 | \
ADC_CHSELR_CHSEL1 | \
ADC_CHSELR_CHSEL5 | \
ADC_CHSELR_CHSEL6 | \
ADC_CHSELR_CHSEL7 | \
ADC_CHSELR_CHSEL16 | \
ADC_CHSELR_CHSEL17 \
)
#elif defined(STM32L0) || defined(CONFIG_SOC_SERIES_STM32L0X)
#define ADC_CHSEL ( \
ADC_CHSELR_CHSEL0 | \
ADC_CHSELR_CHSEL1 | \
ADC_CHSELR_CHSEL5 | \
ADC_CHSELR_CHSEL6 | \
ADC_CHSELR_CHSEL7 | \
ADC_CHSELR_CHSEL17 | \
ADC_CHSELR_CHSEL18 \
)
#endif
#endif
-132
View File
@@ -1,132 +0,0 @@
/*
* Copyright (c) 2019 Martin Jäger / Libre Solar
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef MPPT_1210_HUS_0V7_H
#define MPPT_1210_HUS_0V7_H
#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
#define CONFIG_HAS_LOAD_OUTPUT 1
#define CONFIG_HAS_USB_PWR_OUTPUT 1
// DC/DC converter settings
#define PWM_FREQUENCY 50 // kHz 50 = better for cloud solar to increase efficiency
#define PWM_DEADTIME 230 // ns
#define PWM_TIM 3 // use TIM3 timer
#define DCDC_CURRENT_MAX 10 // PCB maximum DCDC output current
#define LOAD_CURRENT_MAX 10 // PCB maximum load switch current
#define LOW_SIDE_VOLTAGE_MAX 16 // Maximum voltage at battery port (V)
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
#define PIN_UEXT_SDA PB_7
#define PIN_UEXT_MISO PB_4
#define PIN_UEXT_MOSI PB_5
#define PIN_UEXT_SCK PB_3
#define PIN_UEXT_SSEL PA_15
#define PIN_SWD_TX PA_9
#define PIN_SWD_RX PA_10
#define PIN_LOAD_EN PC_13
#define PIN_USB_PWR_EN PB_10
#define PIN_V_SOLAR_EN PC_14
#define PIN_5V_PGOOD PC_15
#define PIN_EXT_BTN PB_12
#define PIN_BOOT0_EN PB_12
#define PIN_REF_I_DCDC PA_4
// Internal NTC temperature currently ignored by firmware as it is similar to MCU temperature and
// does not reflect external battery temperature. Feature will be removed in future HW revisions.
#define PIN_TEMP_INT_PD PA_8
enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
// assignment LED numbers on PCB to their meaning
#define NUM_LEDS 5
#define LED_SOC_1 0 // LED1
#define LED_SOC_2 1 // LED2
#define LED_SOC_3 2 // LED3
#define LED_LOAD 3 // LED4
#define LED_RXTX 4 // LED5, used to indicate when sending data
// 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
};
#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
};
// pin definition only needed in adc_dma.cpp to detect if they are present on the PCB
#define PIN_ADC_TEMP_BAT
// typical value for Semitec 103AT-5 thermistor: 3435
#define NTC_BETA_VALUE 3435
#define NTC_SERIES_RESISTOR 10000.0
#define ADC_GAIN_V_LOW (105.6 / 5.6) // both voltage dividers: 100k + 5.6k
#define ADC_GAIN_V_HIGH (105.6 / 5.6)
#define ADC_GAIN_I_LOAD (1000.0 / 3.0 / 50.0) // amp gain: 50, resistor: 3 mOhm
#define ADC_GAIN_I_DCDC (1000.0 / 3.0 / 50.0)
// position in the array written by the DMA controller
enum {
ADC_POS_V_LOW, // ADC 0 (PA_0)
ADC_POS_V_HIGH, // ADC 1 (PA_1)
ADC_POS_I_LOAD, // ADC 5 (PA_5)
ADC_POS_I_DCDC, // ADC 6 (PA_6)
ADC_POS_TEMP_BAT, // ADC 7 (PA_7)
ADC_POS_VREF_MCU, // ADC 17
ADC_POS_TEMP_MCU, // ADC 18
NUM_ADC_CH // trick to get the number of elements
};
#define NUM_ADC_1_CH NUM_ADC_CH
// selected ADC channels (has to match with above enum)
#define ADC_CHSEL ( \
ADC_CHSELR_CHSEL0 | \
ADC_CHSELR_CHSEL1 | \
ADC_CHSELR_CHSEL5 | \
ADC_CHSELR_CHSEL6 | \
ADC_CHSELR_CHSEL7 | \
ADC_CHSELR_CHSEL17 | \
ADC_CHSELR_CHSEL18 \
)
#endif
-128
View File
@@ -1,128 +0,0 @@
/*
* Copyright (c) 2020 Martin Jäger / Libre Solar
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef MPPT_2420_HPX_0V1_H
#define MPPT_2420_HPX_0V1_H
#ifdef __MBED__
#include "mbed.h"
#elif defined(__ZEPHYR__)
#include <zephyr.h>
#endif
#define DEVICE_TYPE "MPPT-2420-HPX"
#define HARDWARE_VERSION "v0.1"
// specify features of charge controller
#define CONFIG_HAS_DCDC_CONVERTER 1
#define CONFIG_HAS_PWM_SWITCH 0
#define CONFIG_HAS_LOAD_OUTPUT 1
#define CONFIG_HAS_USB_PWR_OUTPUT 0
// DC/DC converter settings
#define PWM_FREQUENCY 70 // kHz
#define PWM_DEADTIME 300 // ns
#define PWM_TIM 1 // use TIM1 timer
#define DCDC_CURRENT_MAX 20 // PCB maximum DCDC output current
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
#define LOW_SIDE_VOLTAGE_MAX 16 // Maximum voltage at battery port (V)
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
#define PIN_UEXT_SDA PB_7
#define PIN_UEXT_MISO PB_4
#define PIN_UEXT_MOSI PB_5
#define PIN_UEXT_SCK PB_3
#define PIN_UEXT_SSEL PA_15
#define PIN_SWD_TX PA_9
#define PIN_SWD_RX PA_10
#define PIN_LOAD_EN PC_13
#define PIN_USB_PWR_EN PB_12
#define PIN_REF_I_DCDC PA_4
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[CONFIG_NUM_LED_PINS];
extern const int led_pins[CONFIG_NUM_LED_PINS];
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_5
// typical value for Semitec 103AT-5 thermistor: 3435
#define NTC_BETA_VALUE 3435
#define NTC_SERIES_RESISTOR 10000.0
#define ADC_GAIN_V_LOW (105.6 / 5.6)
#define ADC_GAIN_V_HIGH (102.2 / 2.2)
#define ADC_GAIN_V_PWM (1 + 120/12 + 120/8.2)
#define ADC_GAIN_I_DCDC (1000 / 2 / 20) // amp gain: 20, resistor: 2 mOhm
// op amp gain: 68/2.2, resistor: 2 mOhm
#define ADC_GAIN_I_LOAD (1000 / 2 / (68/2.2))
#define ADC_GAIN_I_PWM (1000 / 2 / (68/2.2))
// to be multiplied with VREF to get absolute voltage offset
#define ADC_OFFSET_V_PWM (-120.0 / 8.2)
// 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_V_PWM,
ADC_POS_TEMP_FETS,
ADC_POS_VREF_MCU,
ADC_POS_TEMP_MCU,
// ADC2
ADC_POS_I_DCDC,
ADC_POS_I_LOAD,
ADC_POS_I_PWM,
NUM_ADC_CH // trick to get the number of elements
};
// selected ADC channels (has to match with below arrays)
#define NUM_ADC_1_CH 7
#define NUM_ADC_2_CH 3
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_4, // V_PWM
LL_ADC_CHANNEL_6, // TEMP_FETS
LL_ADC_CHANNEL_VREFINT, // VREF_MCU
LL_ADC_CHANNEL_TEMPSENSOR_ADC1, // TEMP_MCU
};
const uint32_t adc_2_sequence[] = {
LL_ADC_CHANNEL_1, // I_DCDC
LL_ADC_CHANNEL_2, // I_LOAD
LL_ADC_CHANNEL_5, // I_PWM
};
#endif
-138
View File
@@ -1,138 +0,0 @@
/*
* Copyright (c) 2017 Martin Jäger / Libre Solar
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef MPPT_2420_LC_0V10_H
#define MPPT_2420_LC_0V10_H
#define DEVICE_TYPE "MPPT-2420-LC"
#define HARDWARE_VERSION "v0.10"
#ifdef __MBED__
#include "mbed.h"
#elif defined(__ZEPHYR__)
#include <zephyr.h>
#endif
// specify features of charge controller
#define CONFIG_HAS_DCDC_CONVERTER 1
#define CONFIG_HAS_PWM_SWITCH 0
#define CONFIG_HAS_LOAD_OUTPUT 1
#define CONFIG_HAS_USB_PWR_OUTPUT 0
// DC/DC converter settings
#define PWM_FREQUENCY 70 // kHz 70 = good compromise between output ripple and efficiency
#define PWM_DEADTIME 300 // ns
#define PWM_TIM 1 // use TIM1 timer
#define DCDC_CURRENT_MAX 20 // PCB maximum DCDC output current
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
#define LOW_SIDE_VOLTAGE_MAX 32 // Maximum voltage at battery port (V)
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
#define PIN_UEXT_DIS PC_14 // starting from rev. 0.10
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
#define PIN_UEXT_SDA PB_7
#define PIN_UEXT_MISO PB_4
#define PIN_UEXT_MOSI PB_5
#define PIN_UEXT_SCK PB_3
#define PIN_UEXT_SSEL PC_13 // PCB rev 0.6: PA_0
#define PIN_SWD_TX PA_9
#define PIN_SWD_RX PA_10
/*
#define PIN_LED_PWR PB_14
#define PIN_LED_LOAD PB_15
*/
#define PIN_LOAD_DIS PB_2
//#define PIN_5V_OUT_EN PB_12
#define PIN_USB_PWR_EN PB_12 // normally should be named 5V_OUT_EN, as no USB is existing here
//#define PIN_USB_PWR_FLG PC_14
#define PIN_CAN_RX PB_8
#define PIN_CAN_TX PB_9
#define PIN_CAN_STB PA_15
#define PIN_V_BUS_DIS PC_15 // bus power supply disable, starting from rev. 0.10
#define PIN_REF_I_DCDC PA_4
#define PIN_EEPROM_SCL PB_10
#define PIN_EEPROM_SDA PB_11
#define EEPROM_24AA32
#define CONFIG_CAN 1
enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
// assignment LED numbers on PCB to their meaning
#define NUM_LEDS 2
#define LED_PWR 0 // LED1
#define LED_LOAD 1 // LED2
// LED pins and pin state configuration to switch above LEDs on
#define NUM_LED_PINS 2
#ifdef __MBED__
static const PinName led_pins[NUM_LED_PINS] = {
// PWR LOAD
PB_14, PB_15
};
#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 }, // LED1
{ PIN_LOW, PIN_HIGH } // LED2
};
// pin definition only needed in adc_dma.cpp to detect if they are present on the PCB
#define PIN_ADC_TEMP_BAT PA_0
#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
#define ADC_GAIN_V_LOW (110.0 / 10 ) // battery voltage divider 100k + 10k
#define ADC_GAIN_V_HIGH (105.6 / 5.6) // solar voltage divider: 100k + 5.6k
#define ADC_GAIN_I_LOAD (1000 / 2 / (1500.0 / 22.0)) // op amp gain: 150/2.2 = 68.2, resistor: 2 mOhm
#define ADC_GAIN_I_DCDC (1000 / 2 / (1500.0 / 22.0))
// position in the array written by the DMA controller
enum {
ADC_POS_TEMP_BAT, // ADC 0 (PA_0)
ADC_POS_TEMP_FETS, // ADC 1 (PA_1)
ADC_POS_V_REF, // ADC 5 (PA_5)
ADC_POS_V_LOW, // ADC 6 (PA_6)
ADC_POS_V_HIGH, // ADC 7 (PA_7)
ADC_POS_I_LOAD, // ADC 8 (PB_0)
ADC_POS_I_DCDC, // ADC 9 (PB_1)
ADC_POS_TEMP_MCU, // ADC 16
ADC_POS_VREF_MCU, // ADC 17
NUM_ADC_CH // trick to get the number of enums
};
#define NUM_ADC_1_CH NUM_ADC_CH
// selected ADC channels (has to match with above enum)
#define ADC_CHSEL ( \
ADC_CHSELR_CHSEL0 | \
ADC_CHSELR_CHSEL1 | \
ADC_CHSELR_CHSEL5 | \
ADC_CHSELR_CHSEL6 | \
ADC_CHSELR_CHSEL7 | \
ADC_CHSELR_CHSEL8 | \
ADC_CHSELR_CHSEL9 | \
ADC_CHSELR_CHSEL16 | \
ADC_CHSELR_CHSEL17 \
)
#endif
-101
View File
@@ -1,101 +0,0 @@
/*
* Copyright (c) 2018 Martin Jäger / Libre Solar
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef PCB_STUB_H
#define PCB_STUB_H
#define DEVICE_TYPE "PCB-STUB"
#define HARDWARE_VERSION "v0.1"
// specify features of charge controller
#define CONFIG_HAS_DCDC_CONVERTER 1
#define CONFIG_HAS_PWM_SWITCH 1
#define CONFIG_HAS_LOAD_OUTPUT 1
#define CONFIG_HAS_USB_PWR_OUTPUT 1
#define PWM_FREQUENCY 50 // kHz
#define PWM_DEADTIME 230 // ns
#define PWM_CURRENT_MAX 15 // PCB maximum PWM switch (solar) current
#define DCDC_CURRENT_MAX 20 // PCB maximum DCDC output current
#define LOAD_CURRENT_MAX 20 // PCB maximum load switch current
#define LOW_SIDE_VOLTAGE_MAX 32 // Maximum voltage at battery port (V)
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
#define PIN_UEXT_TX 0
#define PIN_UEXT_RX 0
#define PIN_UEXT_SCL 0
#define PIN_UEXT_SDA 0
#define PIN_UEXT_MISO 0
#define PIN_UEXT_MOSI 0
#define PIN_UEXT_SCK 0
#define PIN_UEXT_SSEL 0
#define PIN_SWD_TX 0
#define PIN_SWD_RX 0
//#define PIN_LOAD_DIS 0
//#define PIN_USB_PWR_DIS 0
enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
// assignment LED numbers on PCB to their meaning
#define NUM_LEDS 5
#define LED_SOC_1 0 // LED1
#define LED_SOC_2 1 // LED2
#define LED_SOC_3 2 // LED3
#define LED_LOAD 3 // LED4
#define LED_RXTX 4 // LED5, used to indicate when sending data
// LED pins and pin state configuration to switch above LEDs on
#define NUM_LED_PINS 3
static const int led_pins[NUM_LED_PINS] = {
// A B C
0, 0, 0
};
static const 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
};
// pin definition only needed in adc_dma.cpp to detect if they are present on the PCB
#define PIN_ADC_TEMP_BAT
// typical value for Semitec 103AT-5 thermistor: 3435
#define NTC_BETA_VALUE 3435
#define NTC_SERIES_RESISTOR 8200.0
#define ADC_GAIN_V_LOW (105.6 / 5.6) // both voltage dividers: 100k + 5.6k
#define ADC_GAIN_V_HIGH (105.6 / 5.6)
#define ADC_GAIN_V_PWM (105.6 / 5.6)
#define ADC_GAIN_I_LOAD (1000 / 4 / 50) // amp gain: 50, resistor: 4 mOhm
#define ADC_GAIN_I_DCDC (1000 / 4 / 50)
#define ADC_GAIN_I_PWM (1000 / 4 / 50)
#define ADC_OFFSET_V_PWM (-120.0 / 8.2) // to be multiplied with VDDA to get absolute voltage offset
// position in the array written by the DMA controller
enum {
ADC_POS_V_LOW, // ADC 0 (PA_0)
ADC_POS_V_HIGH, // ADC 1 (PA_1)
ADC_POS_V_PWM, // ADC 3 (PA_2)
ADC_POS_I_PWM, // ADC 4 (PA_4)
ADC_POS_I_LOAD, // ADC 5 (PA_5)
ADC_POS_I_DCDC, // ADC 6 (PA_6)
ADC_POS_TEMP_BAT, // ADC 7 (PA_7)
ADC_POS_VREF_MCU, // ADC 17
ADC_POS_TEMP_MCU, // ADC 18
NUM_ADC_CH // trick to get the number of elements
};
#define NUM_ADC_1_CH NUM_ADC_CH
#endif
-163
View File
@@ -1,163 +0,0 @@
/*
* Copyright (c) 2018 Martin Jäger / Libre Solar
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef PWM_2420_LUS_H
#define PWM_2420_LUS_H
#ifdef __MBED__
#include "mbed.h"
#elif defined(__ZEPHYR__)
#include <zephyr.h>
#endif
#define DEVICE_TYPE "PWM-2420-LUS"
#ifdef CONFIG_BOARD_PWM_2420_LUS_0V2
#define HARDWARE_VERSION "v0.2"
#elif defined(CONFIG_BOARD_PWM_2420_LUS_0V3)
#define HARDWARE_VERSION "v0.3"
#endif
// specify features of charge controller
#define CONFIG_HAS_DCDC_CONVERTER 0
#define CONFIG_HAS_PWM_SWITCH 1
#define CONFIG_HAS_LOAD_OUTPUT 1
#define CONFIG_HAS_USB_PWR_OUTPUT 1
#define PWM_TIM 3 // use TIM3 timer
#define PWM_FREQUENCY 50 // Hz
// Current reduced to 15A. Increase to 20A PCB max values only if attached to a big heat sink.
#define PWM_CURRENT_MAX 15 // PCB maximum PWM switch (solar) current
#define LOAD_CURRENT_MAX 15 // PCB maximum load switch current
#define LOW_SIDE_VOLTAGE_MAX 32 // Maximum voltage at battery port (V)
#define HIGH_SIDE_VOLTAGE_MAX 55 // Maximum voltage at PV input port (V)
// The MCU, where internal temperature is measured, is close to the MOSFETs. Tests showed that
// temperature at heat sink is only 10-20°C above measured internal temp. As PWM CC doesn't
// use electrolytic cap for core charging function, internal temperature of 70°C can be allowed.
// This value is used for thermal overcurrent model.
#define INTERNAL_MAX_REFERENCE_TEMP 70
#define PIN_UEXT_TX PA_2
#define PIN_UEXT_RX PA_3
#define PIN_UEXT_SCL PB_6
#define PIN_UEXT_SDA PB_7
#define PIN_UEXT_MISO PA_11
#define PIN_UEXT_MOSI PA_12
#define PIN_UEXT_SCK PB_3
#define PIN_UEXT_SSEL PA_15
#define PIN_SWD_TX PA_9
#define PIN_SWD_RX PA_10
#define PIN_LOAD_DIS PB_2
#define PIN_USB_PWR_DIS PB_5
#define PIN_I_LOAD_COMP PB_4
#define PIN_EXT_BTN PB_12
#define PIN_BOOT0_EN PB_12
#define PIN_REF_I_DCDC PA_4
// Internal NTC temperature currently ignored by firmware as it is similar to MCU temperature and
// does not reflect external battery temperature. Feature will be removed in future HW revisions.
#define PIN_TEMP_INT_PD PA_8
enum pin_state_t { PIN_HIGH, PIN_LOW, PIN_FLOAT };
// assignment LED numbers on PCB to their meaning
#define NUM_LEDS 5
#define LED_SOC_1 0 // LED1
#define LED_SOC_2 1 // LED2
#define LED_SOC_3 2 // LED3
#define LED_LOAD 3 // LED4
#define LED_RXTX 4 // LED5, used to indicate when sending data
// 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_14, PB_15
};
#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
#ifndef LEDS_WRONG_POLARITY
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
};
#else
// LEDs with wrong polarity
static const enum pin_state_t led_pin_setup[NUM_LEDS][NUM_LED_PINS] = {
{ PIN_LOW, PIN_HIGH, PIN_FLOAT }, // LED1
{ PIN_HIGH, PIN_LOW, PIN_FLOAT }, // LED2
{ PIN_LOW, PIN_FLOAT, PIN_HIGH }, // LED3
{ PIN_FLOAT, PIN_LOW, PIN_HIGH }, // LED4
{ PIN_FLOAT, PIN_HIGH, PIN_LOW } // LED5
};
#endif
// pin definition only needed in adc_dma.cpp to detect if they are present on the PCB
#define PIN_ADC_TEMP_BAT
// typical value for Semitec 103AT-5 thermistor: 3435
#define NTC_BETA_VALUE 3435
#define NTC_SERIES_RESISTOR 8200.0
#define ADC_GAIN_V_LOW (132 / 12)
#define ADC_GAIN_V_PWM (1 + 120/12 + 120/8.2)
#ifdef CONFIG_BOARD_PWM_2420_LUS_0V2
// op amp gain: 68/2.2, resistor: 2 mOhm
#define ADC_GAIN_I_LOAD (1000 / 2 / (68/2.2))
#elif defined(CONFIG_BOARD_PWM_2420_LUS_0V3)
// fix for hardware bug in overcurrent comparator voltage divider wiring
#define ADC_GAIN_I_LOAD (1000 / 2 / (68/2.2) * (39+12+8.2) / (12+8.2))
#endif
#define ADC_GAIN_I_PWM (1000 / 2 / (68/2.2))
#define ADC_OFFSET_V_PWM (-120.0 / 8.2) // to be multiplied with VDDA to get absolute voltage offset
// position in the array written by the DMA controller
enum {
ADC_POS_V_LOW, // ADC 0 (PA_0)
ADC_POS_V_PWM, // ADC 1 (PA_1)
ADC_POS_I_LOAD, // ADC 5 (PA_5)
ADC_POS_I_PWM, // ADC 6 (PA_6)
ADC_POS_TEMP_BAT, // ADC 7 (PA_7)
ADC_POS_VREF_MCU, // ADC 17
ADC_POS_TEMP_MCU, // ADC 18
NUM_ADC_CH // trick to get the number of elements
};
#define NUM_ADC_1_CH NUM_ADC_CH
// selected ADC channels (has to match with above enum)
#define ADC_CHSEL ( \
ADC_CHSELR_CHSEL0 | \
ADC_CHSELR_CHSEL1 | \
ADC_CHSELR_CHSEL5 | \
ADC_CHSELR_CHSEL6 | \
ADC_CHSELR_CHSEL7 | \
ADC_CHSELR_CHSEL17 | \
ADC_CHSELR_CHSEL18 \
)
#endif
+1 -2
View File
@@ -9,8 +9,7 @@
#include <stdio.h>
#include <time.h>
#include "config.h"
#include "pcb.h"
#include "board.h"
#include "daq.h"
#include "debug.h"
#include "helper.h"
+1 -2
View File
@@ -10,8 +10,7 @@
*/
#include "thingset.h" // handles access to internal data via communication interfaces
#include "pcb.h" // hardware-specific settings
#include "config.h" // user-specific configuration
#include "board.h" // hardware-specific settings
#include "half_bridge.h" // PWM generation for DC/DC converter
#include "hardware.h" // hardware-related functions like load switch, LED control, watchdog, etc.
+1 -2
View File
@@ -4,8 +4,6 @@
* SPDX-License-Identifier: Apache-2.0
*/
#include "config.h"
#include <stdio.h>
#include "bat_charger.h"
@@ -14,6 +12,7 @@
#include "power_port.h"
#include "pwm_switch.h"
#include "thingset.h"
#include "board.h"
extern DcBus lv_bus;
extern PowerPort lv_terminal;