add reset sketch and reorganize files

This commit is contained in:
r4
2022-04-19 16:44:54 +02:00
parent 4e90b217cb
commit 9420eb8293
9 changed files with 128 additions and 91 deletions

19
spybug/io.cpp Normal file
View File

@@ -0,0 +1,19 @@
#include "io.hh"
static int serial_putch(char c, FILE *f) {
(void)f;
return Serial.write(c) == 1 ? 0 : 1;
}
static int serial_getch(FILE *f) {
(void)f;
while(Serial.available() == 0);
return Serial.read();
}
static FILE serial_in_out;
void io_setup() {
fdev_setup_stream(&serial_in_out, serial_putch, serial_getch, _FDEV_SETUP_RW);
stdout = stdin = stderr = &serial_in_out;
}