Skip to content

Commit

Permalink
OTP on channel fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
mvladic committed Mar 18, 2020
1 parent d6efb40 commit 5c0fe7a
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 54 deletions.
25 changes: 25 additions & 0 deletions src/eez/gui/app_context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

#include <math.h>
#include <assert.h>
#include <memory.h>

#include <eez/index.h>
#include <eez/sound.h>
Expand Down Expand Up @@ -195,6 +196,30 @@ void AppContext::popPage() {
}
}

void AppContext::removePageFromStack(int pageId) {
for (int i = m_pageNavigationStackPointer; i > 0; i--) {
if (m_pageNavigationStack[i].pageId == pageId) {
if (i == m_pageNavigationStackPointer) {
popPage();
} else {
if (m_pageNavigationStack[i].page) {
m_pageNavigationStack[i].page->pageFree();
}

for (int j = i + 1; j <= m_pageNavigationStackPointer; j++) {
memcpy(m_pageNavigationStack + j - 1, m_pageNavigationStack + j, sizeof(PageOnStack));
}

m_pageNavigationStack[m_pageNavigationStackPointer].page = nullptr;

--m_pageNavigationStackPointer;
}
refreshScreen();
break;
}
}
}

Page *AppContext::getPage(int pageId) {
for (int i = 0; i <= m_pageNavigationStackPointer; ++i) {
if (m_pageNavigationStack[i].pageId == pageId) {
Expand Down
1 change: 1 addition & 0 deletions src/eez/gui/app_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class AppContext {
void doPushPage();

void popPage();
void removePageFromStack(int pageId);

int getActivePageId();
Page *getActivePage();
Expand Down
7 changes: 6 additions & 1 deletion src/eez/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,12 @@ int main(int argc, char **argv) {
/* Clear reset flags */
RCC->CSR |= RCC_CSR_RMVF;
}
MX_IWDG_Init();

volatile unsigned int* const SCB_DHCSR = (volatile unsigned int *)0xE000EDF0;
bool debugger = *SCB_DHCSR & 1;
if (!debugger) {
MX_IWDG_Init();
}

HAL_Init();
SystemClock_Config();
Expand Down
2 changes: 1 addition & 1 deletion src/eez/modules/dcm220/channel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <eez/scpi/regs.h>
#include <eez/system.h>

#define CONF_MASTER_SYNC_TIMEOUT_MS 500
#define CONF_MASTER_SYNC_TIMEOUT_MS 1000
#define CONF_MASTER_SYNC_IRQ_TIMEOUT_MS 50

namespace eez {
Expand Down
81 changes: 38 additions & 43 deletions src/eez/modules/psu/channel_dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -134,64 +134,59 @@ void setCouplingTypeInPsuThread(CouplingType couplingType) {

disableOutputForAllChannels();

for (int i = 0; i < CH_NUM; ++i) {
for (int i = 0; i < 2; ++i) {
Channel &channel = Channel::get(i);

if (i < 2 && (couplingType == COUPLING_TYPE_PARALLEL || couplingType == COUPLING_TYPE_SERIES)) {
channel.remoteSensingEnable(false);
channel.remoteProgrammingEnable(false);

channel.setVoltageTriggerMode(TRIGGER_MODE_FIXED);
channel.setCurrentTriggerMode(TRIGGER_MODE_FIXED);
channel.setTriggerOutputState(true);
channel.setTriggerOnListStop(TRIGGER_ON_LIST_STOP_OUTPUT_OFF);
channel.remoteSensingEnable(false);
channel.remoteProgrammingEnable(false);

list::resetChannelList(channel);
channel.setVoltageTriggerMode(TRIGGER_MODE_FIXED);
channel.setCurrentTriggerMode(TRIGGER_MODE_FIXED);
channel.setTriggerOutputState(true);
channel.setTriggerOnListStop(TRIGGER_ON_LIST_STOP_OUTPUT_OFF);

channel.setVoltage(getUMin(channel));
channel.setVoltageLimit(MIN(Channel::get(0).getVoltageLimit(), Channel::get(1).getVoltageLimit()));
list::resetChannelList(channel);

channel.setCurrent(getIMin(channel));
channel.setCurrentLimit(MIN(Channel::get(0).getCurrentLimit(), Channel::get(1).getCurrentLimit()));
channel.setVoltage(getUMin(channel));
channel.setVoltageLimit(MIN(Channel::get(0).getVoltageLimit(), Channel::get(1).getVoltageLimit()));

trigger::setVoltage(channel, getUMin(channel));
trigger::setCurrent(channel, getIMin(channel));
channel.setCurrent(getIMin(channel));
channel.setCurrentLimit(MIN(Channel::get(0).getCurrentLimit(), Channel::get(1).getCurrentLimit()));

channel.prot_conf.flags.u_state = Channel::get(0).prot_conf.flags.u_state || Channel::get(1).prot_conf.flags.u_state ? 1 : 0;
if (channel.params.features & CH_FEATURE_HW_OVP) {
channel.prot_conf.flags.u_type = Channel::get(0).prot_conf.flags.u_type || Channel::get(1).prot_conf.flags.u_type ? 1 : 0;
}
channel.prot_conf.u_level = MIN(Channel::get(0).prot_conf.u_level, Channel::get(1).prot_conf.u_level);
channel.prot_conf.u_delay = MIN(Channel::get(0).prot_conf.u_delay, Channel::get(1).prot_conf.u_delay);
trigger::setVoltage(channel, getUMin(channel));
trigger::setCurrent(channel, getIMin(channel));

channel.prot_conf.flags.i_state = Channel::get(0).prot_conf.flags.i_state || Channel::get(1).prot_conf.flags.i_state ? 1 : 0;
channel.prot_conf.i_delay = MIN(Channel::get(0).prot_conf.i_delay, Channel::get(1).prot_conf.i_delay);
channel.prot_conf.flags.u_state = Channel::get(0).prot_conf.flags.u_state || Channel::get(1).prot_conf.flags.u_state ? 1 : 0;
if (channel.params.features & CH_FEATURE_HW_OVP) {
channel.prot_conf.flags.u_type = Channel::get(0).prot_conf.flags.u_type || Channel::get(1).prot_conf.flags.u_type ? 1 : 0;
}
channel.prot_conf.u_level = MIN(Channel::get(0).prot_conf.u_level, Channel::get(1).prot_conf.u_level);
channel.prot_conf.u_delay = MIN(Channel::get(0).prot_conf.u_delay, Channel::get(1).prot_conf.u_delay);

channel.prot_conf.flags.p_state = Channel::get(0).prot_conf.flags.p_state || Channel::get(1).prot_conf.flags.p_state ? 1 : 0;
channel.prot_conf.p_level = MIN(Channel::get(0).prot_conf.p_level, Channel::get(1).prot_conf.p_level);
channel.prot_conf.p_delay = MIN(Channel::get(0).prot_conf.p_delay, Channel::get(1).prot_conf.p_delay);
channel.prot_conf.flags.i_state = Channel::get(0).prot_conf.flags.i_state || Channel::get(1).prot_conf.flags.i_state ? 1 : 0;
channel.prot_conf.i_delay = MIN(Channel::get(0).prot_conf.i_delay, Channel::get(1).prot_conf.i_delay);

temperature::sensors[temp_sensor::CH1 + channel.channelIndex].prot_conf.state = temperature::sensors[temp_sensor::CH1].prot_conf.state || temperature::sensors[temp_sensor::CH2].prot_conf.state ? 1 : 0;
temperature::sensors[temp_sensor::CH1 + channel.channelIndex].prot_conf.level = MIN(temperature::sensors[temp_sensor::CH1].prot_conf.level, temperature::sensors[temp_sensor::CH2].prot_conf.level);
temperature::sensors[temp_sensor::CH1 + channel.channelIndex].prot_conf.delay = MIN(temperature::sensors[temp_sensor::CH1].prot_conf.delay, temperature::sensors[temp_sensor::CH2].prot_conf.delay);
channel.prot_conf.flags.p_state = Channel::get(0).prot_conf.flags.p_state || Channel::get(1).prot_conf.flags.p_state ? 1 : 0;
channel.prot_conf.p_level = MIN(Channel::get(0).prot_conf.p_level, Channel::get(1).prot_conf.p_level);
channel.prot_conf.p_delay = MIN(Channel::get(0).prot_conf.p_delay, Channel::get(1).prot_conf.p_delay);

if (i == 1) {
Channel &channel1 = Channel::get(0);
channel.flags.displayValue1 = channel1.flags.displayValue1;
channel.flags.displayValue2 = channel1.flags.displayValue2;
channel.ytViewRate = channel1.ytViewRate;
temperature::sensors[temp_sensor::CH1 + channel.channelIndex].prot_conf.state = temperature::sensors[temp_sensor::CH1].prot_conf.state || temperature::sensors[temp_sensor::CH2].prot_conf.state ? 1 : 0;
temperature::sensors[temp_sensor::CH1 + channel.channelIndex].prot_conf.level = MIN(temperature::sensors[temp_sensor::CH1].prot_conf.level, temperature::sensors[temp_sensor::CH2].prot_conf.level);
temperature::sensors[temp_sensor::CH1 + channel.channelIndex].prot_conf.delay = MIN(temperature::sensors[temp_sensor::CH1].prot_conf.delay, temperature::sensors[temp_sensor::CH2].prot_conf.delay);

}
if (i == 1) {
Channel &channel1 = Channel::get(0);
channel.flags.displayValue1 = channel1.flags.displayValue1;
channel.flags.displayValue2 = channel1.flags.displayValue2;
channel.ytViewRate = channel1.ytViewRate;
}

channel.setCurrentRangeSelectionMode(CURRENT_RANGE_SELECTION_USE_BOTH);
channel.enableAutoSelectCurrentRange(false);
channel.setCurrentRangeSelectionMode(CURRENT_RANGE_SELECTION_USE_BOTH);
channel.enableAutoSelectCurrentRange(false);

if (g_couplingType == COUPLING_TYPE_SERIES || g_couplingType == COUPLING_TYPE_PARALLEL) {
channel.flags.trackingEnabled = false;
}
channel.flags.trackingEnabled = false;

channel.resetHistory();
}
channel.resetHistory();
}

if (g_couplingType == COUPLING_TYPE_PARALLEL || g_couplingType == COUPLING_TYPE_SERIES) {
Expand Down
10 changes: 3 additions & 7 deletions src/eez/modules/psu/gui/psu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -665,7 +665,7 @@ bool PsuAppContext::isFocusWidget(const WidgetCursor &widgetCursor) {
}
}

return (widgetCursor.cursor == -1 || widgetCursor.cursor == g_focusCursor) && widgetCursor.widget->data == g_focusDataId && widgetCursor.widget->action != ACTION_ID_EDIT_NO_FOCUS;
return (widgetCursor.cursor == -1 || widgetCursor.cursor == g_focusCursor) && widgetCursor.widget->data == g_focusDataId && widgetCursor.widget->action != ACTION_ID_EDIT_NO_FOCUS && isEncoderEnabledInActivePage();
}

bool PsuAppContext::isAutoRepeatAction(int action) {
Expand Down Expand Up @@ -821,9 +821,7 @@ bool PsuAppContext::updateProgressPage(size_t processedSoFar, size_t totalSize)
}

void PsuAppContext::doHideProgressPage() {
if (getActivePageId() == (m_progressWithoutAbort ? PAGE_ID_PROGRESS_WITHOUT_ABORT : PAGE_ID_PROGRESS)) {
popPage();
}
removePageFromStack(m_progressWithoutAbort ? PAGE_ID_PROGRESS_WITHOUT_ABORT : PAGE_ID_PROGRESS);
m_popProgressPage = false;
}

Expand Down Expand Up @@ -868,9 +866,7 @@ void PsuAppContext::hideAsyncOperationInProgress() {
}

void PsuAppContext::doHideAsyncOperationInProgress() {
if (getActivePageId() == PAGE_ID_ASYNC_OPERATION_IN_PROGRESS) {
popPage();
}
removePageFromStack(PAGE_ID_ASYNC_OPERATION_IN_PROGRESS);
}

uint32_t PsuAppContext::getAsyncInProgressStartTime() {
Expand Down
8 changes: 6 additions & 2 deletions src/eez/modules/psu/temperature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,8 @@ void TempSensorTemperature::protection_enter(TempSensorTemperature &sensor) {
sensor.protection_enter();
}
}
} else {
sensor.protection_enter();
}
} else {
sensor.protection_enter();
Expand All @@ -278,13 +280,15 @@ void TempSensorTemperature::protection_enter() {
Channel *channel = temp_sensor::sensors[sensorIndex].getChannel();
if (channel) {
channel_dispatcher::outputEnable(*channel, false);

event_queue::pushEvent(event_queue::EVENT_ERROR_CH1_OTP_TRIPPED + channel->channelIndex);
} else {
channel_dispatcher::disableOutputForAllChannels();

event_queue::pushEvent(event_queue::EVENT_ERROR_AUX_OTP_TRIPPED);
}

set_otp_reg(true);

event_queue::pushEvent(event_queue::EVENT_ERROR_AUX_OTP_TRIPPED + sensorIndex);
}

} // namespace temperature
Expand Down

0 comments on commit 5c0fe7a

Please sign in to comment.