ESP32
This commit is contained in:
parent
6236d96b83
commit
8278c8d308
10 changed files with 119 additions and 19 deletions
1
ESP32/disk_backend.cpp
Symbolic link
1
ESP32/disk_backend.cpp
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../disk_backend.cpp
|
1
ESP32/disk_backend.h
Symbolic link
1
ESP32/disk_backend.h
Symbolic link
|
@ -0,0 +1 @@
|
||||||
|
../disk_backend.h
|
83
ESP32/disk_backend_esp32.cpp
Normal file
83
ESP32/disk_backend_esp32.cpp
Normal file
|
@ -0,0 +1,83 @@
|
||||||
|
#include <fcntl.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#include "disk_backend_esp32.h"
|
||||||
|
#include "error.h"
|
||||||
|
#include "log.h"
|
||||||
|
|
||||||
|
|
||||||
|
disk_backend_esp32::disk_backend_esp32(const std::string & filename) :
|
||||||
|
fh(new File32())
|
||||||
|
{
|
||||||
|
if (!fh->open(filename.c_str(), O_RDWR))
|
||||||
|
error_exit(true, "rk05: cannot open \"%s\"", filename.c_str());
|
||||||
|
}
|
||||||
|
|
||||||
|
disk_backend_esp32::~disk_backend_esp32()
|
||||||
|
{
|
||||||
|
fh->close();
|
||||||
|
|
||||||
|
delete fh;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool disk_backend_esp32::read(const off_t offset, const size_t n, uint8_t *const target)
|
||||||
|
{
|
||||||
|
DOLOG(debug, false, "disk_backend_esp32::read: read %zu bytes from offset %zu", n, offset);
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!fh->seek(offset))
|
||||||
|
DOLOG(ll_error, true, "seek error %s", strerror(errno));
|
||||||
|
|
||||||
|
yield();
|
||||||
|
|
||||||
|
if (fh->read(target, n) != size_t(n)) {
|
||||||
|
DOLOG(debug, true, "fread error: %s", strerror(errno));
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield();
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool disk_backend_esp32::write(const off_t offset, const size_t n, const uint8_t *const from)
|
||||||
|
{
|
||||||
|
DOLOG(debug, false, "disk_backend_esp32::write: write %zu bytes to offset %zu", n, offset);
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
digitalWrite(LED_BUILTIN, LOW);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
if (!fh->seek(offset))
|
||||||
|
DOLOG(ll_error, true, "seek error %s", strerror(errno));
|
||||||
|
|
||||||
|
yield();
|
||||||
|
|
||||||
|
if (fh->write(from, n) != n) {
|
||||||
|
DOLOG(ll_error, true, "RK05 fwrite error %s", strerror(errno));
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
yield();
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
digitalWrite(LED_BUILTIN, HIGH);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
19
ESP32/disk_backend_esp32.h
Normal file
19
ESP32/disk_backend_esp32.h
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "disk_backend.h"
|
||||||
|
#include "esp32.h"
|
||||||
|
|
||||||
|
|
||||||
|
class disk_backend_esp32 : public disk_backend
|
||||||
|
{
|
||||||
|
private:
|
||||||
|
File32 *const fh { nullptr };
|
||||||
|
|
||||||
|
public:
|
||||||
|
disk_backend_esp32(const std::string & filename);
|
||||||
|
virtual ~disk_backend_esp32();
|
||||||
|
|
||||||
|
bool read(const off_t offset, const size_t n, uint8_t *const target);
|
||||||
|
|
||||||
|
bool write(const off_t offset, const size_t n, const uint8_t *const from);
|
||||||
|
};
|
|
@ -1,7 +1,10 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
|
#include <Arduino.h>
|
||||||
|
|
||||||
#include <SPI.h>
|
#include <SPI.h>
|
||||||
|
|
||||||
#define USE_SDFAT
|
#define USE_SDFAT
|
||||||
#define SD_FAT_TYPE 1
|
#define SD_FAT_TYPE 1
|
||||||
#include <SdFat.h>
|
#include <SdFat.h>
|
||||||
|
|
|
@ -12,6 +12,8 @@
|
||||||
#include "console_esp32.h"
|
#include "console_esp32.h"
|
||||||
#include "cpu.h"
|
#include "cpu.h"
|
||||||
#include "debugger.h"
|
#include "debugger.h"
|
||||||
|
#include "disk_backend.h"
|
||||||
|
#include "disk_backend_esp32.h"
|
||||||
#include "error.h"
|
#include "error.h"
|
||||||
#include "esp32.h"
|
#include "esp32.h"
|
||||||
#include "gen.h"
|
#include "gen.h"
|
||||||
|
@ -104,7 +106,7 @@ void setup_wifi_stations()
|
||||||
}
|
}
|
||||||
|
|
||||||
// RK05, RL02 files
|
// RK05, RL02 files
|
||||||
std::pair<std::vector<std::string>, std::vector<std::string> > select_disk_files(console *const c)
|
std::pair<std::vector<disk_backend *>, std::vector<disk_backend *> > select_disk_files(console *const c)
|
||||||
{
|
{
|
||||||
c->debug("MISO: %d", int(MISO));
|
c->debug("MISO: %d", int(MISO));
|
||||||
c->debug("MOSI: %d", int(MOSI));
|
c->debug("MOSI: %d", int(MOSI));
|
||||||
|
@ -146,10 +148,10 @@ std::pair<std::vector<std::string>, std::vector<std::string> > select_disk_files
|
||||||
fh.close();
|
fh.close();
|
||||||
|
|
||||||
if (ch == '1')
|
if (ch == '1')
|
||||||
return { { selected_file }, { } };
|
return { { new disk_backend_esp32(selected_file) }, { } };
|
||||||
|
|
||||||
if (ch == '2')
|
if (ch == '2')
|
||||||
return { { }, { selected_file } };
|
return { { }, { new disk_backend_esp32(selected_file) } };
|
||||||
}
|
}
|
||||||
|
|
||||||
c->put_string_lf("open failed");
|
c->put_string_lf("open failed");
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
|
#include "esp32.h"
|
||||||
|
|
||||||
void setBootLoader(bus *const b);
|
void setBootLoader(bus *const b);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,11 @@
|
||||||
#include "kw11-l.h"
|
#include "kw11-l.h"
|
||||||
#include "utils.h"
|
#include "utils.h"
|
||||||
|
|
||||||
|
#if defined(ESP32)
|
||||||
|
#include "esp32.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#if defined(ESP32)
|
#if defined(ESP32)
|
||||||
void thread_wrapper_kw11(void *p)
|
void thread_wrapper_kw11(void *p)
|
||||||
{
|
{
|
||||||
|
|
8
rk05.cpp
8
rk05.cpp
|
@ -96,10 +96,6 @@ void rk05::writeByte(const uint16_t addr, const uint8_t v)
|
||||||
|
|
||||||
void rk05::writeWord(const uint16_t addr, uint16_t v)
|
void rk05::writeWord(const uint16_t addr, uint16_t v)
|
||||||
{
|
{
|
||||||
#if defined(ESP32)
|
|
||||||
digitalWrite(LED_BUILTIN, LOW);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
const int reg = (addr - RK05_BASE) / 2;
|
const int reg = (addr - RK05_BASE) / 2;
|
||||||
|
|
||||||
registers[reg] = v;
|
registers[reg] = v;
|
||||||
|
@ -228,8 +224,4 @@ void rk05::writeWord(const uint16_t addr, uint16_t v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ESP32)
|
|
||||||
digitalWrite(LED_BUILTIN, HIGH);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
8
rl02.cpp
8
rl02.cpp
|
@ -95,10 +95,6 @@ uint32_t rl02::calcOffset(const uint16_t da)
|
||||||
|
|
||||||
void rl02::writeWord(const uint16_t addr, uint16_t v)
|
void rl02::writeWord(const uint16_t addr, uint16_t v)
|
||||||
{
|
{
|
||||||
#if defined(ESP32)
|
|
||||||
digitalWrite(LED_BUILTIN, LOW);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
DOLOG(debug, true, "RL02 write %06o: %06o", addr, v);
|
DOLOG(debug, true, "RL02 write %06o: %06o", addr, v);
|
||||||
|
|
||||||
const int reg = (addr - RL02_BASE) / 2;
|
const int reg = (addr - RL02_BASE) / 2;
|
||||||
|
@ -157,8 +153,4 @@ void rl02::writeWord(const uint16_t addr, uint16_t v)
|
||||||
*disk_read_acitivity = false;
|
*disk_read_acitivity = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(ESP32)
|
|
||||||
digitalWrite(LED_BUILTIN, HIGH);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue