Skip to content

Commit

Permalink
add support for full-duplex comms with MOS
Browse files Browse the repository at this point in the history
enables flow control if a GP command is received with value 2
  • Loading branch information
stevesims committed Dec 3, 2024
1 parent a8d821c commit dad4205
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
6 changes: 5 additions & 1 deletion video/vdp_protocol.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,16 @@

#define VDPSerial Serial2

void setVDPProtocolDuplex(bool duplex) {
VDPSerial.setHwFlowCtrlMode(duplex ? HW_FLOWCTRL_CTS_RTS : HW_FLOWCTRL_RTS, 64);
}

void setupVDPProtocol() {
VDPSerial.end();
VDPSerial.setRxBufferSize(UART_RX_SIZE); // Can't be called when running
VDPSerial.begin(UART_BR, SERIAL_8N1, UART_RX, UART_TX);
VDPSerial.setHwFlowCtrlMode(HW_FLOWCTRL_RTS, 64); // Can be called whenever
VDPSerial.setPins(UART_NA, UART_NA, UART_CTS, UART_RTS); // Must be called after begin
setVDPProtocolDuplex(false); // Start with half-duplex
VDPSerial.setTimeout(COMMS_TIMEOUT);
}

Expand Down
7 changes: 7 additions & 0 deletions video/vdu_sys.h
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,13 @@ void VDUStreamProcessor::sendGeneralPoll() {
debug_log("sendGeneralPoll: Timeout\n\r");
return;
}
if (b == 2) {
// Full duplex mode requested
setVDPProtocolDuplex(true);
// NB if an application is running on a MOS that _isn't_ set up for full duplex
// and happens to send a GP with a value 2 this will break comms with MOS
debug_log("Full duplex mode requested\n\r");
}
uint8_t packet[] = {
(uint8_t) (b & 0xFF),
};
Expand Down

0 comments on commit dad4205

Please sign in to comment.