Skip to content

Commit

Permalink
fixed chromadeck updi disable after command
Browse files Browse the repository at this point in the history
  • Loading branch information
Unreal-Dan committed Jan 5, 2025
1 parent d93e743 commit e09c56a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions VortexEngine/src/Menus/MenuList/EditorConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,6 +379,7 @@ void EditorConnection::handleState()
}
// the trick is to send header after the modes so the reset comes at the end
UPDI::reset();
UPDI::disable();
// success modes were received send the done
SerialComs::write(EDITOR_VERB_PUSH_CHROMA_HDR_ACK);
m_receiveBuffer.clear();
Expand Down Expand Up @@ -480,6 +481,8 @@ bool EditorConnection::pullHeaderChromalink()
ByteStream saveHeader;
// doesn't matter if reading the header fails, we still need to send it
bool success = UPDI::readHeader(saveHeader);
UPDI::reset();
UPDI::disable();
// send whatever we read, might be empty buffer if it failed
SerialComs::write(saveHeader);
// return whether reading the header was successful
Expand All @@ -496,6 +499,8 @@ bool EditorConnection::pushHeaderChromalink()
if (!UPDI::writeHeader(buf)) {
return false;
}
UPDI::reset();
UPDI::disable();
return true;
}

Expand All @@ -513,6 +518,8 @@ bool EditorConnection::pullModeChromalink()
bool success = UPDI::readMode(modeIdx, modeBuffer);
// send the mode, could be empty buffer if reading failed
SerialComs::write(modeBuffer);
UPDI::reset();
UPDI::disable();
// return whether reading the mode was successful
return success;
}
Expand All @@ -527,6 +534,9 @@ bool EditorConnection::pushModeChromalink()
if (!UPDI::writeMode(m_chromaModeIdx, buf)) {
return false;
}
// the trick is to send header after the modes so the reset comes at the end
UPDI::reset();
UPDI::disable();
return true;
}

Expand All @@ -542,7 +552,9 @@ bool EditorConnection::writeDuoFirmware()
}
m_firmwareOffset += buf.size();
if (m_firmwareOffset >= m_firmwareSize) {
// done
UPDI::reset();
UPDI::disable();
}
// create a progress bar I guess
Leds::setAll(RGB_RED0);
Expand Down
9 changes: 9 additions & 0 deletions VortexEngine/src/UPDI/updi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,15 @@ bool UPDI::reset()
#endif
}

bool UPDI::disable()
{
#ifdef VORTEX_EMBEDDED
// UPDIDIS bit to CTRLB
stcs(Control_B, 0x2);
#endif
return true;
}

#ifdef VORTEX_EMBEDDED

void UPDI::enterProgrammingMode()
Expand Down
3 changes: 3 additions & 0 deletions VortexEngine/src/UPDI/updi.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ class UPDI
static bool eraseMemory();
static bool reset();

// end the updi connection and reset the chip
static bool disable();

private:

#ifdef VORTEX_EMBEDDED
Expand Down

0 comments on commit e09c56a

Please sign in to comment.