Skip to content

Commit

Permalink
update rts dtr setup in other places
Browse files Browse the repository at this point in the history
  • Loading branch information
cubicap committed Oct 12, 2023
1 parent d0fe986 commit bc53a4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions examples/typescript/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,10 @@ resetButton.onclick = async () => {
}

await transport.setDTR(false);
await transport.writeRTSDTR();
await new Promise((resolve) => setTimeout(resolve, 100));
await transport.setDTR(true);
await transport.writeRTSDTR();
};

eraseButton.onclick = async () => {
Expand Down
10 changes: 9 additions & 1 deletion src/reset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,47 @@ function sleep(ms: number): Promise<void> {
export async function classicReset(transport: Transport, resetDelay = DEFAULT_RESET_DELAY) {
await transport.setDTR(false);
await transport.setRTS(true);
await transport.writeRTSDTR();
await sleep(100);
await transport.setDTR(true);
await transport.setRTS(false);
await transport.writeRTSDTR();
await sleep(resetDelay);
await transport.setDTR(false);
await transport.writeRTSDTR();
}

export async function usbJTAGSerialReset(transport: Transport) {
await transport.setRTS(false);
await transport.setDTR(false);
await transport.writeRTSDTR();
await sleep(100);

await transport.setDTR(true);
await transport.setRTS(false);
await transport.writeRTSDTR();
await sleep(100);

await transport.setRTS(true);
await transport.setDTR(false);
await transport.setRTS(true);
await transport.writeRTSDTR();

await sleep(100);
await transport.setRTS(false);
await transport.setDTR(false);
await transport.writeRTSDTR();
}

export async function hardReset(transport: Transport, usingUsbOtg = false) {
if (usingUsbOtg) {
await sleep(200);
await transport.setRTS(false);
await transport.writeRTSDTR();
await sleep(200);
} else {
await sleep(100);
await transport.setRTS(false);
await transport.writeRTSDTR();
}
}

Expand Down

0 comments on commit bc53a4e

Please sign in to comment.