Skip to content

Commit

Permalink
Make C3 out of CQ3
Browse files Browse the repository at this point in the history
  • Loading branch information
mskvortsov committed Jul 19, 2024
1 parent 686daec commit 61fe9d5
Show file tree
Hide file tree
Showing 13 changed files with 194 additions and 96 deletions.
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)
1 change: 1 addition & 0 deletions src/hardware/nuvoton-M051/cpu/IO.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
//#define OUTPUT GPIO_PMD_OUTPUT
#define OUTPUT GPIO_PMD_QUASI
//#define OUTPUT_QUASI GPIO_PMD_QUASI
#define OUTPUT_PUSH_PULL GPIO_PMD_OUTPUT
#define INPUT GPIO_PMD_QUASI
#define ANALOG_INPUT 200
#define ANALOG_INPUT_DISCHARGE 201
Expand Down
78 changes: 78 additions & 0 deletions src/hardware/nuvoton-M051/generic/ev-peak-c3/C3-pins.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/*
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/>.
*/
#ifndef PINS_H_
#define PINS_H_

#define V_IN_PIN 1

#define OUTPUT_VOLTAGE_POLARITY_PIN 36
#define OUTPUT_VOLTAGE_PIN 43
#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 22
#define SMPS_DISABLE_PIN 25
#define SMPS_BOOST_DISABLE_PIN 24
#define SMPS_CURRENT_PIN 44

#define UART_TX_PIN 7
#define BUZZER_PIN 12
#define BACKLIGHT_PIN 21
#define FAN_ENABLE 26

#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 BALANCER1_LOAD_PIN 40
#define BALANCER2_LOAD_PIN 39
#define BALANCER3_LOAD_PIN 38
#define BALANCER4_LOAD_PIN 37
#define BALANCER5_LOAD_PIN 35
#define BALANCER6_LOAD_PIN 34

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

#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 MADDR_V_GND_REF 6
#define MADDR_V_OUTMUX 7

#define T_EXTERNAL_PIN 3
#define T_INTERNAL_PIN 3+128

#endif /* PINS_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
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 "CQ3.h"
#include "C3.h"
#include "SMPS_PID.h"
#include "AnalogInputsADC.h"
#include "SerialLog.h"
Expand Down
89 changes: 0 additions & 89 deletions src/hardware/nuvoton-M051/generic/ev-peak-c3/CQ3-pins.h

This file was deleted.

2 changes: 1 addition & 1 deletion src/hardware/nuvoton-M051/generic/ev-peak-c3/Hardware.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
#ifndef HARDWARE_H_
#define HARDWARE_H_

#include "CQ3.h"
#include "C3.h"

#endif /* HARDWARE_H_ */
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,6 @@
#define ANALOG_INPUTS_MAX_ADC_Vout_plus_pin ANALOG_INPUTS_MAX_ADC_VALUE

#define CHEALI_CHARGER_ARCHITECTURE_GENERIC 1
#define CHEALI_CHARGER_ARCHITECTURE_GENERIC_STRING "100W"
#define CHEALI_CHARGER_ARCHITECTURE_GENERIC_STRING "50W"

#endif /* HARDWARE_CONFIG_GENERIC_H_ */
6 changes: 3 additions & 3 deletions src/hardware/nuvoton-M051/generic/ev-peak-c3/generic.cmake
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@

set(GENERIC_SOURCE
CQ3.cpp
CQ3.h
CQ3-pins.h
C3.cpp
C3.h
C3-pins.h
SMPS_PID.h
SMPS_PID.cpp
AnalogInputsADC.cpp
Expand Down
2 changes: 1 addition & 1 deletion src/hardware/nuvoton-M051/generic/ev-peak-c3/outputPWM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "debug.h"

extern "C" {
#include "NUC029xAN.h"
#include "M051Series.h"
}

#define PWM_GET_CNR(pwm, u32ChannelNum) (*((__IO uint32_t *) ((((uint32_t)&((pwm)->CNR0)) + (u32ChannelNum) * 12))))
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(ev-peak-c3)

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

CHEALI_GENERATE_ARM_EXEC()
47 changes: 47 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,47 @@
/*
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"
#include "C3-pins.h"

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

// #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



#endif /* HARDWARE_CONFIG_H_ */
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
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 = {
{{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);

0 comments on commit 61fe9d5

Please sign in to comment.