Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Sep 29, 2019
1 parent 57249ff commit 7ff1b8e
Show file tree
Hide file tree
Showing 65 changed files with 1,660 additions and 2,483 deletions.
28 changes: 6 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ set(header_files)
set(src_eez
src/eez/debug.cpp
src/eez/index.cpp
src/eez/main.cpp
src/eez/scripting.cpp
src/eez/sound.cpp
src/eez/system.cpp
Expand Down Expand Up @@ -117,14 +118,14 @@ list (APPEND header_files ${header_eez_apps_home})
source_group("eez\\apps\\home" FILES ${src_eez_apps_home} ${header_eez_apps_home})

set(src_eez_apps_psu
src/eez/apps/psu/board.cpp
src/eez/apps/psu/calibration.cpp
src/eez/apps/psu/channel.cpp
src/eez/apps/psu/channel_dispatcher.cpp
src/eez/apps/psu/datetime.cpp
src/eez/apps/psu/debug.cpp
src/eez/apps/psu/devices.cpp
src/eez/apps/psu/dlog.cpp
src/eez/apps/psu/eeprom.cpp
src/eez/apps/psu/ethernet.cpp
src/eez/apps/psu/event_queue.cpp
src/eez/apps/psu/idle.cpp
Expand All @@ -137,7 +138,9 @@ set(src_eez_apps_psu
src/eez/apps/psu/persist_conf.cpp
src/eez/apps/psu/profile.cpp
src/eez/apps/psu/psu.cpp
src/eez/apps/psu/rtc.cpp
src/eez/apps/psu/sd_card.cpp
src/eez/apps/psu/serial.cpp
src/eez/apps/psu/serial_psu.cpp
src/eez/apps/psu/temp_sensor.cpp
src/eez/apps/psu/temperature.cpp
Expand All @@ -153,14 +156,12 @@ set(header_eez_apps_psu
src/eez/apps/psu/channel_dispatcher.h
src/eez/apps/psu/conf.h
src/eez/apps/psu/conf_advanced.h
src/eez/apps/psu/conf_all.h
src/eez/apps/psu/conf_channel.h
src/eez/apps/psu/conf_user.h
src/eez/apps/psu/datetime.h
src/eez/apps/psu/debug.h
src/eez/apps/psu/devices.h
src/eez/apps/psu/dlog.h
src/eez/apps/psu/eeprom.h
src/eez/apps/psu/ethernet.h
src/eez/apps/psu/event_queue.h
src/eez/apps/psu/idle.h
Expand All @@ -180,7 +181,6 @@ set(header_eez_apps_psu
src/eez/apps/psu/timer.h
src/eez/apps/psu/trigger.h
src/eez/apps/psu/util.h
src/eez/apps/psu/watchdog.h
)
list (APPEND header_files ${header_eez_apps_psu})
source_group("eez\\apps\\psu" FILES ${src_eez_apps_psu} ${header_eez_apps_psu})
Expand Down Expand Up @@ -259,22 +259,6 @@ set(header_eez_apps_psu_scpi
list (APPEND header_files ${header_eez_apps_psu_scpi})
source_group("eez\\apps\\psu\\scpi" FILES ${src_eez_apps_psu_scpi} ${header_eez_apps_psu_scpi})

set(src_eez_apps_psu_simulator
src/eez/apps/psu/simulator/board.cpp
src/eez/apps/psu/simulator/psu.cpp
src/eez/apps/psu/simulator/rtc.cpp
src/eez/apps/psu/simulator/serial.cpp
src/eez/apps/psu/simulator/watchdog.cpp
)
list (APPEND src_files ${src_eez_apps_psu_simulator})
set(header_eez_apps_psu_simulator
src/eez/apps/psu/simulator/conf.h
src/eez/apps/psu/simulator/psu.h
src/eez/apps/psu/simulator/serial.h
)
list (APPEND header_files ${header_eez_apps_psu_simulator})
source_group("eez\\apps\\psu\\simulator" FILES ${src_eez_apps_psu_simulator} ${header_eez_apps_psu_simulator})

set(src_eez_apps_settings
src/eez/apps/settings/settings.cpp
)
Expand Down Expand Up @@ -421,13 +405,15 @@ source_group("eez\\modules\\bp3c" FILES ${src_eez_modules_bp3c} ${header_eez_mod
set(src_eez_modules_mcu
src/eez/modules/mcu/battery.cpp
src/eez/modules/mcu/display.cpp
src/eez/modules/mcu/eeprom.cpp
src/eez/modules/mcu/ethernet.cpp
src/eez/modules/mcu/encoder.cpp
src/eez/modules/mcu/sdram.cpp)
list (APPEND src_files ${src_eez_modules_mcu})
set(header_eez_modules_mcu
src/eez/modules/mcu/battery.h
src/eez/modules/mcu/display.h
src/eez/modules/mcu/eeprom.h
src/eez/modules/mcu/encoder.h
src/eez/modules/mcu/ethernet.h
src/eez/modules/mcu/sdram.h
Expand Down Expand Up @@ -474,8 +460,6 @@ set(src_eez_platform_simulator
src/eez/platform/simulator/cmsis_os.cpp
src/eez/platform/simulator/events.cpp
src/eez/platform/simulator/front_panel.cpp
src/eez/platform/simulator/main.cpp
src/eez/platform/simulator/system.cpp
src/eez/platform/simulator/texture.cpp
)
list (APPEND src_files ${src_eez_platform_simulator})
Expand Down
96 changes: 50 additions & 46 deletions src/eez/apps/psu/stm32/board.cpp → src/eez/apps/psu/board.cpp
Original file line number Diff line number Diff line change
@@ -1,46 +1,50 @@
/*
* EEZ Modular Firmware
* Copyright (C) 2015-present, Envox d.o.o.
*
* 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 <eez/system.h>

#include <eez/apps/psu/psu.h>

#include <eez/apps/psu/board.h>

#include <main.h>

namespace eez {
namespace psu {
namespace board {

void powerUp() {
HAL_GPIO_WritePin(PWR_SSTART_GPIO_Port, PWR_SSTART_Pin, GPIO_PIN_SET);
delay(700);

HAL_GPIO_WritePin(PWR_DIRECT_GPIO_Port, PWR_DIRECT_Pin, GPIO_PIN_SET);
delay(100);
}

void powerDown() {
HAL_GPIO_WritePin(PWR_DIRECT_GPIO_Port, PWR_DIRECT_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PWR_SSTART_GPIO_Port, PWR_SSTART_Pin, GPIO_PIN_RESET);
}

} // namespace board
} // namespace psu
} // namespace eez
/*
* EEZ Modular Firmware
* Copyright (C) 2015-present, Envox d.o.o.
*
* 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 <eez/apps/psu/psu.h>
#include <eez/apps/psu/board.h>

#if defined(EEZ_PLATFORM_STM32)
#include <eez/system.h>
#include <main.h>
#endif

namespace eez {
namespace psu {
namespace board {

void powerUp() {
#if defined(EEZ_PLATFORM_STM32)
HAL_GPIO_WritePin(PWR_SSTART_GPIO_Port, PWR_SSTART_Pin, GPIO_PIN_SET);
delay(700);

HAL_GPIO_WritePin(PWR_DIRECT_GPIO_Port, PWR_DIRECT_Pin, GPIO_PIN_SET);
delay(100);
#endif
}

void powerDown() {
#if defined(EEZ_PLATFORM_STM32)
HAL_GPIO_WritePin(PWR_DIRECT_GPIO_Port, PWR_DIRECT_Pin, GPIO_PIN_RESET);
HAL_GPIO_WritePin(PWR_SSTART_GPIO_Port, PWR_SSTART_Pin, GPIO_PIN_RESET);
#endif
}

} // namespace board
} // namespace psu
} // namespace eez
3 changes: 0 additions & 3 deletions src/eez/apps/psu/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,6 @@
#include <assert.h>

#include <eez/system.h>
#if OPTION_WATCHDOG
#include <eez/apps/psu/watchdog.h>
#endif
#include <eez/apps/psu/board.h>
#include <eez/apps/psu/calibration.h>
#include <eez/apps/psu/channel_dispatcher.h>
Expand Down
6 changes: 6 additions & 0 deletions src/eez/apps/psu/channel.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@
namespace eez {
namespace psu {

enum MaxCurrentLimitCause {
MAX_CURRENT_LIMIT_CAUSE_NONE,
MAX_CURRENT_LIMIT_CAUSE_FAN,
MAX_CURRENT_LIMIT_CAUSE_TEMPERATURE
};

extern int CH_NUM;

namespace calibration {
Expand Down
10 changes: 0 additions & 10 deletions src/eez/apps/psu/conf_advanced.h
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@
/// test.
#define FAN_OPTION_RPM_MEASUREMENT 1

/// Interval (in milliseconds) at which watchdog impulse will be sent
#define WATCHDOG_INTERVAL 250

/// Interval (in minutes) at which "on time" will be written to EEPROM
#define WRITE_ONTIME_INTERVAL 10

Expand All @@ -211,13 +208,6 @@
/// See DP_NEG_LEV.
#define DP_NEG_DELAY 5 // 5 s

/// Replace standard SPI transactions implementation with in-house implementation,
/// It is more simple version where all interrupts are disabled during SPI transactions.
/// We had some problems (WATCHDOG, ADC timeout and EEPROM errros) with SPI in the
/// past and when we used our SPI transactions implementation, problems disappeared.
/// But, unfortunately, now ethernet doesn't work.
#define REPLACE_SPI_TRANSACTIONS_IMPLEMENTATION 0

/// Number of history values shown in YT diagram. This value must be the same as
/// the width of YT widget.
#define CHANNEL_HISTORY_SIZE 352
Expand Down
40 changes: 0 additions & 40 deletions src/eez/apps/psu/conf_all.h

This file was deleted.

2 changes: 0 additions & 2 deletions src/eez/apps/psu/debug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ DebugVariable *g_variables[] = { &g_uDac[0], &g_uDac[1], &g_uMon[0],
#endif
&g_adcCounter };

bool g_debugWatchdog = true;

static uint32_t g_previousTickCount1sec;
static uint32_t g_previousTickCount10sec;

Expand Down
2 changes: 0 additions & 2 deletions src/eez/apps/psu/debug.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ extern DebugDurationVariable g_listTickDuration;
#endif
extern DebugCounterVariable g_adcCounter;

extern bool g_debugWatchdog;

void dumpVariables(char *buffer);

} // namespace debug
Expand Down
4 changes: 2 additions & 2 deletions src/eez/apps/psu/devices.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

#include <eez/apps/psu/devices.h>

#include <eez/apps/psu/eeprom.h>
#include <eez/modules/mcu/eeprom.h>

#if OPTION_SD_CARD
#include <eez/apps/psu/sd_card.h>
Expand Down Expand Up @@ -54,7 +54,7 @@ namespace devices {

Device devices[] = {
#if OPTION_EXT_EEPROM
{ "EEPROM", OPTION_EXT_EEPROM, &eeprom::g_testResult },
{ "EEPROM", OPTION_EXT_EEPROM, &mcu::eeprom::g_testResult },
#else
{ "EEPROM", 0, 0 },
#endif
Expand Down
10 changes: 0 additions & 10 deletions src/eez/apps/psu/dlog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <eez/apps/psu/scpi/psu.h>
#include <eez/apps/psu/sd_card.h>
#include <eez/system.h>
#include <eez/apps/psu/watchdog.h>
#include <eez/apps/psu/dlog.h>

namespace eez {
Expand Down Expand Up @@ -240,11 +239,6 @@ void log(uint32_t tickCount) {
g_currentTime = g_seconds + g_micros * 1E-6;

if (g_currentTime >= g_nextTime) {
#if OPTION_WATCHDOG
watchdog::disable();
#endif


while (1) {
g_nextTime = ++g_iSample * g_period;
if (g_currentTime < g_nextTime || g_nextTime > g_time) {
Expand Down Expand Up @@ -308,10 +302,6 @@ void log(uint32_t tickCount) {
g_file.sync();
}
}

#if OPTION_WATCHDOG
watchdog::enable();
#endif
}
}

Expand Down
1 change: 0 additions & 1 deletion src/eez/apps/psu/ethernet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
#include <eez/apps/psu/event_queue.h>
#include <eez/apps/psu/persist_conf.h>
#include <eez/apps/psu/serial_psu.h>
#include <eez/apps/psu/watchdog.h>

#include <eez/apps/psu/ethernet.h>

Expand Down
Loading

0 comments on commit 7ff1b8e

Please sign in to comment.