Skip to content

Commit

Permalink
#48
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Aug 28, 2020
1 parent 0fde019 commit 90a5502
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 1 deletion.
21 changes: 21 additions & 0 deletions src/eez/modules/psu/profile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,28 @@ static void saveState(Parameters &profile, List *lists) {
profile.flags.isValid = true;
}

static struct {
Parameters *profile;
List *lists;
int recallOptions;
int *err;
bool result;
} g_recallStateParams;

void recallStateFromPsuThread() {
g_recallStateParams.result = recallState(*g_recallStateParams.profile, g_recallStateParams.lists, g_recallStateParams.recallOptions, g_recallStateParams.err);
}

static bool recallState(Parameters &profile, List *lists, int recallOptions, int *err) {
if (g_isBooted && !isPsuThread()) {
g_recallStateParams.profile = &profile;
g_recallStateParams.lists = lists;
g_recallStateParams.recallOptions = recallOptions;
g_recallStateParams.err= err;
sendMessageToPsu(PSU_MESSAGE_RECALL_STATE);
return g_recallStateParams.result;
}

if (!(recallOptions & RECALL_OPTION_IGNORE_POWER)) {
if (profile.flags.powerIsUp) {
if (!powerUp()) {
Expand Down
2 changes: 2 additions & 0 deletions src/eez/modules/psu/profile.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ bool recallFromLocation(int location);
bool recallFromLocation(int location, int recallOptions, bool showProgress, int *err);
bool recallFromFile(const char *filePath, int recallOptions, bool showProgress, int *err);

void recallStateFromPsuThread();

bool saveToLocation(int location);
bool saveToLocation(int location, const char *name, bool showProgress, int *err);
bool saveToFile(const char *filePath, bool showProgress, int *err);
Expand Down
2 changes: 2 additions & 0 deletions src/eez/modules/psu/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,8 @@ void onThreadMessage(uint8_t type, uint32_t param) {
bp3c::flash_slave::doStart();
} else if (type == PSU_MESSAGE_FLASH_SLAVE_LEAVE_BOOTLOADER_MODE) {
bp3c::flash_slave::leaveBootloaderMode();
} else if (type == PSU_MESSAGE_RECALL_STATE) {
profile::recallStateFromPsuThread();
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/eez/tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ enum HighPriorityThreadMessage {
PSU_MESSAGE_CALIBRATION_SELECT_CURRENT_RANGE,
PSU_MESSAGE_CALIBRATION_STOP,
PSU_MESSAGE_FLASH_SLAVE_START,
PSU_MESSAGE_FLASH_SLAVE_LEAVE_BOOTLOADER_MODE
PSU_MESSAGE_FLASH_SLAVE_LEAVE_BOOTLOADER_MODE,
PSU_MESSAGE_RECALL_STATE
};

enum LowPriorityThreadMessage {
Expand Down

0 comments on commit 90a5502

Please sign in to comment.