1
0
mirror of https://github.com/jscrane/r65emu.git synced 2024-12-27 05:32:04 +00:00
r65emu/serial_filer.cpp

44 lines
756 B
C++
Raw Normal View History

2019-02-12 18:19:09 +00:00
#include <Arduino.h>
#include <stdint.h>
#include "hardware.h"
#include "serialio.h"
#include "filer.h"
#include "serial_filer.h"
2019-02-14 07:58:51 +00:00
const unsigned speeds[] = {
115200, 57600, 19200, 9600, 4800, 2400
};
const char *serial_filer::advance() {
static char buf[16];
2019-02-14 18:02:26 +00:00
unsigned s = speeds[_currsp];
2019-03-26 19:27:25 +00:00
_serial.begin(s);
2019-02-14 18:02:26 +00:00
_currsp++;
if (_currsp == sizeof(speeds)/sizeof(speeds[0]))
_currsp = 0;
2019-02-14 07:58:51 +00:00
return itoa(s, buf, 10);
2019-02-12 18:19:09 +00:00
}
void serial_filer::write(uint8_t b) {
2019-03-26 19:27:25 +00:00
_serial.write(b);
2019-02-12 18:19:09 +00:00
}
uint8_t serial_filer::read() {
2019-03-26 19:27:25 +00:00
return _serial.read();
2019-02-12 18:19:09 +00:00
}
bool serial_filer::more() {
2019-03-26 19:27:25 +00:00
return _serial.available() > 0;
2019-02-12 18:19:09 +00:00
}
2019-02-24 11:50:10 +00:00
#if !defined(NO_CHECKPOINT)
2019-02-12 18:19:09 +00:00
const char *serial_filer::checkpoint() {
2019-02-12 21:53:03 +00:00
// FIXME
2019-02-12 18:19:09 +00:00
return 0;
}
void serial_filer::restore(const char *) {
2019-02-12 21:53:03 +00:00
// FIXME
2019-02-12 18:19:09 +00:00
}
2019-02-24 11:50:10 +00:00
#endif