Skip to content

Commit

Permalink
Support EV-PEAK C3
Browse files Browse the repository at this point in the history
  • Loading branch information
mskvortsov committed Jul 16, 2024
1 parent 0125c8f commit 7c376dd
Show file tree
Hide file tree
Showing 7 changed files with 193 additions and 2 deletions.
25 changes: 25 additions & 0 deletions arm-toolchain-macos.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# 1. brew install --cask gcc-arm-embedded
# 2. make sure the underlying filesystem used for building is case-sensitive
# 3. mkdir build
# cd build
# cmake -DCMAKE_TOOLCHAIN_FILE=../arm-toolchain.cmake -G Ninja ..
# ninja
# 4. openocd -f interface/stlink.cfg -f target/numicro.cfg -c "init; halt"
# 5. telnet localhost 4444
# program firmware.bin verify; exit

set(TOOLCHAIN arm-none-eabi)

set(CMAKE_SYSTEM_NAME Generic)
set(CMAKE_SYSTEM_PROCESSOR ARM)

set(CMAKE_TRY_COMPILE_TARGET_TYPE STATIC_LIBRARY)

SET(CMAKE_C_COMPILER ${TOOLCHAIN}-gcc)
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN}-g++)

set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)

SET(ARM-Cortex-M0 ON)
1 change: 1 addition & 0 deletions src/hardware/nuvoton-M051/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
add_subdirectory(targets/imaxB6-clone)
add_subdirectory(targets/imaxB6-80W)
add_subdirectory(targets/imaxB6-50W-BOA6)
add_subdirectory(targets/ev-peak-c3)
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// ----------------------------------------------------------------------------

int errno;
extern int errno;
void *__dso_handle __attribute__ ((weak));

// ----------------------------------------------------------------------------
Expand Down
14 changes: 14 additions & 0 deletions src/hardware/nuvoton-M051/targets/ev-peak-c3/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@

set(hardware ev-peak-c3)

set(SOURCE_FILES
defaultCalibration.cpp
HardwareConfig.h
)

CHEALI_CPU(nuvoton-M051)
CHEALI_GENERIC_CHARGER(50W)

add_definitions(-D__HXT=12000000UL) # External Crystal Clock Frequency

CHEALI_GENERATE_ARM_EXEC()
102 changes: 102 additions & 0 deletions src/hardware/nuvoton-M051/targets/ev-peak-c3/HardwareConfig.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/*
cheali-charger - open source firmware for a variety of LiPo chargers
Copyright (C) 2013 Paweł Stawicki. All right reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef HARDWARE_CONFIG_H_
#define HARDWARE_CONFIG_H_

#include "GlobalConfig.h"
#include "HardwareConfigGeneric.h"

// workaround for building, remove
#ifndef PINS_H_
#define PINS_H_
#endif

#define ENABLE_SERIAL_LOG 1
// #define ENABLE_HELPER
// #define ENABLE_HELPER_ANALOG_INPUTS_ANALYZER

#define MAX_CHARGE_V ANALOG_VOLT(27.000)
#define MAX_CHARGE_I ANALOG_AMP(5.000)
#define MAX_CHARGE_P ANALOG_WATT(50.000)

#define MAX_DISCHARGE_P ANALOG_WATT(5.000)
#define MAX_DISCHARGE_I ANALOG_AMP(1.000)

//1-13? correlation
#define SMPS_UPPERBOUND_VALUE (60000)
//TODO: ?? pwm_n in outputPWM.cpp
#define DISCHARGER_UPPERBOUND_VALUE 32760



#define V_IN_PIN 1

#define OUTPUT_VOLTAGE_MINUS_PIN 21 // workaround, MCU:21 is connected to ground through R113 2KOhm
#define OUTPUT_VOLTAGE_PLUS_PIN 43 // unclear
#define OUTPUT_DISABLE_PIN 32

#define DISCHARGE_CURRENT_PIN 45
#define DISCHARGE_VALUE_PIN 23
#define DISCHARGE_DISABLE_PIN 33

#define SMPS_VALUE_BOOST_PIN 23
#define SMPS_VALUE_BUCK_PIN 24
#define SMPS_DISABLE_PIN 25
#define SMPS_CURRENT_PIN 44

#define TX_HW_SERIAL_PIN 7
#define UART_TX_PIN 27 // workaround for building, remove? (27 in NC)

#define BUZZER_PIN 12

#define LCD_D0_PIN 10
#define LCD_D1_PIN 11
#define LCD_D2_PIN 13
#define LCD_D3_PIN 14
#define LCD_ENABLE_PIN 19
#define LCD_RS_PIN 20

#define BUTTON_STOP_PIN 28
#define BUTTON_DEC_PIN 29
#define BUTTON_INC_PIN 30
#define BUTTON_START_PIN 31

#define BALANCER5_LOAD_PIN 35
#define BALANCER4_LOAD_PIN 37
#define BALANCER3_LOAD_PIN 38
#define BALANCER2_LOAD_PIN 39
#define BALANCER6_LOAD_PIN 34
#define BALANCER1_LOAD_PIN 40

#define MUX_ADR2_PIN 48
#define MUX_ADR1_PIN 8
#define MUX_ADR0_PIN 9
#define MUX0_Z_D_PIN 47

#define MADDR_V_BALANSER_BATT_MINUS 6 // workaround, MUX:6 is connected to ground
#define MADDR_V_BALANSER1 0
#define MADDR_V_BALANSER2 1
#define MADDR_V_BALANSER3 2
#define MADDR_V_BALANSER4 3
#define MADDR_V_BALANSER5 4
#define MADDR_V_BALANSER6 5

#define T_EXTERNAL_PIN 3
#define T_INTERNAL_PIN 3+128

#endif /* HARDWARE_CONFIG_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
cheali-charger - open source firmware for a variety of LiPo chargers
Copyright (C) 2014 Paweł Stawicki. All right reserved.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#include "AnalogInputsPrivate.h"
#include "memory.h"
#include "Utils.h"

const AnalogInputs::DefaultValues AnalogInputs::inputsP_[] PROGMEM = {

//info: for some reason the ADC has a 50mV shift, see https://groups.google.com/d/msg/cheali-charger/3q0wF0qCGio/oCG1BMjol0QJ
{{0, 50}, {25540, 23735}}, //Vout_plus_pin
{{0, 50}, {25540, 23735}}, //Vout_minus_pin
{{417, 100}, {5062, 1000}}, //Ismps
{{1983, 100}, {5839, 300}}, //Idischarge

{{0, 0}, {1, 1}}, //VoutMux
{{8000, 5940}, {8642, 3479}}, //Tintern
{{0, 0}, {23492, 14052}}, //Vin
{{4701, 3660}, {0, 0}}, //Textern

{{0, 0}, {25219, 3946}}, //Vb0_pin
{{0, 0}, {25219, 3946}}, //Vb1_pin
{{0, 0}, {50664, 7892}}, //Vb2_pin
{{0, 0}, {26372, 4082}}, //Vb3_pin
{{0, 0}, {25184, 3912}}, //Vb4_pin
{{0, 0}, {25169, 3916}}, //Vb5_pin
{{0, 0}, {25405, 3933}}, //Vb6_pin


{{415, 100}, {5066, 1000}}, //IsmpsSet
{{3175, 100}, {9278, 300}}, //IdischargeSet
};

STATIC_ASSERT(sizeOfArray(AnalogInputs::inputsP_) == AnalogInputs::PHYSICAL_INPUTS);
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

// ----------------------------------------------------------------------------

int errno;
extern int errno;
void *__dso_handle __attribute__ ((weak));

// ----------------------------------------------------------------------------
Expand Down

0 comments on commit 7c376dd

Please sign in to comment.