Skip to content

Commit

Permalink
Merge pull request #17 from anarkiwi/fio
Browse files Browse the repository at this point in the history
 Don't drain transmit buffer right after MIDI receive activity to avoid a slow I/O direction change
  • Loading branch information
anarkiwi committed May 13, 2021
2 parents 2ec6eb3 + b3161b3 commit 67740aa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ Upgrading firmware
------------------

The Arduino IDE can be used to reflash Vessel via the onboard USB-C port.
You should select the right port in the Tools menu before uploading.
You should select the right port in the Tools menu before uploading
(Vessel will show as an Arduino Due, native port). You will also need
the "MIDI Library" (by Francois Best) installed, via Tools/Manage Libraries,
and support for SAM boards installed (Tools/Board Manager).

NOTE: you will need to add the following to to WInterrupts.c:

Expand All @@ -208,7 +211,8 @@ On Linux this can be located with the following command.
josh@vek-x:~$ find .arduino15 -name WInterrupts.c
.arduino15/packages/arduino/hardware/sam/1.6.12/cores/arduino/WInterrupts.c

If you will upgrade the IDE you will have to change this file again.
If you will upgrade the IDE you will have to change this file again. Be careful
to change the WInterrupts.c file in the "sam" directory, NOT the "avr" directory.


Vesselmon
Expand Down
11 changes: 7 additions & 4 deletions vessel.ino
Original file line number Diff line number Diff line change
Expand Up @@ -335,19 +335,21 @@ inline bool inBufWaiting() {

inline void drainInBuf() {
// Avoid buffering, ensure we write direct to UART without waiting.
if (uartTxready() && inBufWaiting()) {
if (inBufWaiting() && uartTxready()) {
uartWrite(inBuf[++inBufWritePtr]);
blink();
}
}

inline void drainOutBuf() {
inline bool drainOutBuf() {
if (uartRxready()) {
fs.set(uartRead());
MIDI.read();
flagPin.write(LOW);
blink();
return true;
}
return false;
}

inline void resetWritePtrs() {
Expand All @@ -361,8 +363,9 @@ inline void inputMode() {
isrMode = ISR_INPUT;
interrupts();
while (inInputMode()) {
drainOutBuf();
drainInBuf();
if (!drainOutBuf()) {
drainInBuf();
}
}
}

Expand Down

0 comments on commit 67740aa

Please sign in to comment.