Skip to content

Commit 0f3f244

Browse files
committed
new handshaking serial protocol
1 parent 4e45255 commit 0f3f244

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

hardware.h

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@
8585
#define SS_BIT 0
8686
#define SS_PIN PINB
8787

88+
#define TOGGLE(p) p ## _PORT = (p ## _PORT ^ (1 << p ## _BIT))
8889
#define SET(p, v) p ## _PORT = (p ## _PORT & ~(1 << p ## _BIT)) | (v << p ## _BIT)
8990
#define VALUE(p) (p ## _PIN & (1 << p ## _BIT))
9091
#define OUT(p) p ## _DDR |= (1 << p ## _BIT)

mojo_loader.ino

+5-3
Original file line numberDiff line numberDiff line change
@@ -419,7 +419,7 @@ void uartTask() {
419419
}
420420

421421
if (RingBuffer_GetCount(&serialBuffer) < 1000) {
422-
SET(TX_BUSY, LOW); // re-enable the serial port
422+
TOGGLE(TX_BUSY); // re-enable the serial port
423423
serialRXEnable();
424424
}
425425

@@ -437,11 +437,12 @@ ISR(USART1_RX_vect) { // new serial data!
437437
serialBuffer.In = serialBuffer.Start;
438438

439439
serialBuffer.Count++;
440-
440+
441441
if (serialBuffer.Count >= 1000) { // are we almost out of space?
442-
SET(TX_BUSY, HIGH); // signal we can't take any more
443442
if (serialBuffer.Count > 1020)
444443
serialRXDisable(); // if our flag is ignored disable the serial port so it doesn't clog things up
444+
} else {
445+
TOGGLE(TX_BUSY);
445446
}
446447
}
447448

@@ -458,3 +459,4 @@ ISR(USART1_RX_vect) { // new serial data!
458459

459460

460461

462+

0 commit comments

Comments
 (0)