Skip to content

Commit

Permalink
dcm220 fw download
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Jan 28, 2020
1 parent 7ddf955 commit 226ae50
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 24 deletions.
63 changes: 63 additions & 0 deletions modular-psu-firmware.eez-project
Original file line number Diff line number Diff line change
Expand Up @@ -9755,6 +9755,69 @@
"width": 360,
"height": 88
},
{
"name": "yes_no_flash_slave",
"description": "Confirmation message",
"style": "yes_no",
"widgets": [
{
"type": "MultilineText",
"style": {
"inheritFrom": "default",
"font": "Oswald17",
"color": "text_regular",
"backgroundColor": "popup_background_warning",
"activeColor": "popup_background_warning",
"activeBackgroundColor": "text_regular"
},
"left": 0,
"top": 8,
"width": 340,
"height": 65,
"text": "All modules will be disabled during firmware downloading",
"firstLineIndent": 0,
"hangingIndent": 0
},
{
"type": "Text",
"style": {
"inheritFrom": "yes_no_button",
"color": "text_enabled",
"backgroundColor": "popup_background_warning",
"activeColor": "popup_background_warning",
"activeBackgroundColor": "text_enabled"
},
"action": "yes",
"left": 68,
"top": 76,
"width": 100,
"height": 32,
"text": "Continue",
"focusStyle": {}
},
{
"type": "Text",
"style": {
"inheritFrom": "yes_no_button",
"color": "text_enabled",
"backgroundColor": "popup_background_warning",
"activeColor": "popup_background_warning",
"activeBackgroundColor": "text_enabled"
},
"action": "no",
"left": 182,
"top": 76,
"width": 100,
"height": 32,
"text": "Cancel",
"focusStyle": {}
}
],
"left": 65,
"top": 78,
"width": 350,
"height": 116
},
{
"name": "text_message",
"description": "Textual message",
Expand Down
8 changes: 8 additions & 0 deletions src/eez/firmware.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -269,10 +269,18 @@ bool testMaster() {
bool test() {
bool testResult = true;

psu::profile::saveAtLocation(10);
bool wasSaveProfileEnabled = psu::profile::enableSave(false);
psu::psuReset();

testResult &= testMaster();

testResult &= psu::testChannels();

psu::profile::enableSave(wasSaveProfileEnabled);
int err;
psu::profile::recall(10, &err);

if (!testResult) {
sound::playBeep();
}
Expand Down
6 changes: 5 additions & 1 deletion src/eez/gui/action_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1332,10 +1332,14 @@ void onFirmwareSelected(const char *filePath) {
}
}

void action_channel_update_firmware() {
void onSelectFirmware() {
file_manager::browseForFile("Select DCM220 firmware file", "/Updates", FILE_TYPE_HEX, onFirmwareSelected);
}

void action_channel_update_firmware() {
yesNoDialog(PAGE_ID_YES_NO_FLASH_SLAVE, nullptr, onSelectFirmware, nullptr, nullptr);
}

} // namespace gui
} // namespace eez

Expand Down
13 changes: 11 additions & 2 deletions src/eez/modules/bp3c/flash_slave.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@
#include "eez/modules/psu/psu.h"
#include "eez/modules/psu/io_pins.h"
#include "eez/modules/psu/datetime.h"
#include "eez/modules/psu/profile.h"
#include "eez/modules/psu/channel_dispatcher.h"
#include <eez/modules/psu/scpi/psu.h>
#include <eez/modules/psu/gui/psu.h>
#include <eez/modules/bp3c/io_exp.h>
Expand Down Expand Up @@ -321,6 +323,8 @@ void enterBootloaderMode(int slotIndex) {
g_bootloaderMode = true;

#if defined(EEZ_PLATFORM_STM32)
psu::profile::saveAtLocation(10);

reset();

// power down channels
Expand Down Expand Up @@ -373,13 +377,16 @@ void leaveBootloaderMode() {

psu::initChannels();
psu::testChannels();

HAL_UART_DeInit(phuart);
#endif

g_bootloaderMode = false;

#if defined(EEZ_PLATFORM_STM32)
int err;
psu::profile::recall(10, &err);

HAL_UART_DeInit(phuart);

psu::io_pins::refresh();
#endif
}
Expand Down Expand Up @@ -445,6 +452,8 @@ bool readHexRecord(File &file, HexRecord &hexRecord) {
}

bool start(int slotIndex, const char *hexFilePath, int *err) {
psu::channel_dispatcher::disableOutputForAllChannels();

enterBootloaderMode(slotIndex);

if (!syncWithSlave()) {
Expand Down
6 changes: 1 addition & 5 deletions src/eez/modules/dcpX05/ioexp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,10 +220,6 @@ void IOExpander::init() {
#endif

#endif

#if defined(EEZ_PLATFORM_STM32)
gpio = 0B0000000100000000; // 5A
#endif
}

bool IOExpander::test() {
Expand Down Expand Up @@ -384,9 +380,9 @@ void IOExpander::changeBit(int io_bit, bool set) {
write(REG_GPIOB, newValue);
}
}
#endif

gpio = set ? (gpio | (1 << io_bit)) : (gpio & ~(1 << io_bit));
#endif
}

#if defined(EEZ_PLATFORM_STM32)
Expand Down
11 changes: 9 additions & 2 deletions src/eez/modules/psu/event_queue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@

#include <scpi/scpi.h>

#include <eez/firmware.h>
#include <eez/sound.h>

#include <eez/scpi/scpi.h>

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

#include <eez/modules/psu/datetime.h>
#include <eez/modules/psu/event_queue.h>
#include <eez/sound.h>
#include <eez/scpi/scpi.h>

#if OPTION_ETHERNET
#include <eez/modules/mcu/ethernet.h>
Expand Down Expand Up @@ -247,6 +250,10 @@ void pushEvent(int16_t eventId) {
#if OPTION_ETHERNET
eez::mcu::ethernet::pushEvent(eventId);
#endif

if (!g_isBooted) {
tick();
}
}

void markAsRead() {
Expand Down
15 changes: 2 additions & 13 deletions src/eez/modules/psu/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,10 +282,6 @@ bool testChannels() {
return true;
}

psu::profile::saveAtLocation(10);
psuReset();
bool wasSaveProfileEnabled = profile::enableSave(false);

bool result = true;

channel_dispatcher::disableOutputForAllChannels();
Expand All @@ -294,10 +290,6 @@ bool testChannels() {
result &= Channel::get(i).test();
}

profile::enableSave(wasSaveProfileEnabled);
int err;
psu::profile::recall(10, &err);

return result;
}

Expand Down Expand Up @@ -528,15 +520,12 @@ bool powerUp() {
eez::gui::showWelcomePage();
#endif

// reset channels
for (int i = 0; i < CH_NUM; ++i) {
Channel::get(i).reset();
}

// turn power on
board::powerUp();
g_powerIsUp = true;

psuReset();

ontime::g_mcuCounter.start();
for (int slotIndex = 0; slotIndex < NUM_SLOTS; slotIndex++) {
if (g_slots[slotIndex].moduleInfo->moduleType != MODULE_TYPE_NONE) {
Expand Down
8 changes: 7 additions & 1 deletion src/eez/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
#endif

#include <eez/sound.h>
#include <eez/firmware.h>
#include <eez/system.h>
#include <eez/memory.h>
#include <eez/modules/psu/psu.h>
Expand Down Expand Up @@ -1614,7 +1615,12 @@ void tick() {
static void playTune(int iTune) {
if (iTune > g_playNextTuneIndex && iTune > g_currentTuneIndex) {
g_playNextTuneIndex = iTune;
if (osThreadGetId() == scpi::g_scpiTaskHandle || osThreadGetId() == psu::g_psuTaskHandle || g_playNextTuneIndex == POWER_UP_TUNE) {
if (
osThreadGetId() == scpi::g_scpiTaskHandle ||
osThreadGetId() == psu::g_psuTaskHandle ||
g_playNextTuneIndex == POWER_UP_TUNE ||
(g_playNextTuneIndex == BEEP_TUNE && !g_isBooted)
) {
tick();
}
}
Expand Down

0 comments on commit 226ae50

Please sign in to comment.