| 1 |
#ifndef SMXWIFI_HH |
| 2 |
#define SMXWIFI_HH |
| 3 |
|
| 4 |
#include "BooleanSetting.hh" |
| 5 |
#include "EmulatedEsp32.hh" |
| 6 |
#include "MSXCPU.hh" |
| 7 |
#include "MSXDevice.hh" |
| 8 |
#include "RS232Connector.hh" |
| 9 |
#include "Rom.hh" |
| 10 |
|
| 11 |
#include "circular_buffer.hh" |
| 12 |
|
| 13 |
#include <cstdint> |
| 14 |
#include <memory> |
| 15 |
#include <mutex> |
| 16 |
#include <span> |
| 17 |
|
| 18 |
namespace openmsx { |
| 19 |
|
| 20 |
class SMXWiFi final : public MSXDevice, public RS232Connector |
| 21 |
{ |
| 22 |
public: |
| 23 |
explicit SMXWiFi(DeviceConfig& config); |
| 24 |
~SMXWiFi() override; |
| 25 |
|
| 26 |
|
| 27 |
void powerDown(EmuTime time) override; |
| 28 |
void reset(EmuTime time) override; |
| 29 |
[[nodiscard]] uint8_t readIO(uint16_t port, EmuTime time) override; |
| 30 |
[[nodiscard]] uint8_t peekIO(uint16_t port, EmuTime time) const override; |
| 31 |
void writeIO(uint16_t port, uint8_t value, EmuTime time) override; |
| 32 |
[[nodiscard]] uint8_t readMem(uint16_t address, EmuTime time) override; |
| 33 |
[[nodiscard]] uint8_t peekMem(uint16_t address, EmuTime time) const override; |
| 34 |
[[nodiscard]] const uint8_t* getReadCacheLine(uint16_t start) const override; |
| 35 |
|
| 36 |
|
| 37 |
void plug(Pluggable& device, EmuTime time) override; |
| 38 |
void unplug(EmuTime time) override; |
| 39 |
|
| 40 |
|
| 41 |
void setDataBits(DataBits bits) override; |
| 42 |
void setStopBits(StopBits bits) override; |
| 43 |
void setParityBit(bool enable, Parity parity) override; |
| 44 |
void recvByte(uint8_t value, EmuTime time) override; |
| 45 |
[[nodiscard]] bool ready() override; |
| 46 |
[[nodiscard]] bool acceptsData() override; |
| 47 |
[[nodiscard]] bool directByteDelivery() const override; |
| 48 |
|
| 49 |
template<typename Archive> |
| 50 |
void serialize(Archive& ar, unsigned version); |
| 51 |
|
| 52 |
private: |
| 53 |
[[nodiscard]] uint8_t readFIFO(EmuTime time); |
| 54 |
[[nodiscard]] uint8_t peekFIFO() const; |
| 55 |
[[nodiscard]] uint8_t readStatus(); |
| 56 |
[[nodiscard]] uint8_t peekStatus() const; |
| 57 |
[[nodiscard]] uint8_t peekStatusLocked() const; |
| 58 |
void writeCommand(uint8_t value, EmuTime time); |
| 59 |
void resetFIFO(); |
| 60 |
void pushToFifo(std::span<const uint8_t> data); |
| 61 |
|
| 62 |
|
| 63 |
|
| 64 |
|
| 65 |
[[nodiscard]] bool isRealEndpoint() const; |
| 66 |
void updateEndpoint(EmuTime time); |
| 67 |
|
| 68 |
|
| 69 |
void applyParamsToReal(EmuTime time) const; |
| 70 |
|
| 71 |
cb_queue<uint8_t> fifo; |
| 72 |
mutable std::mutex fifoMutex; |
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
std::unique_ptr<EmulatedEsp32> emulated; |
| 78 |
|
| 79 |
|
| 80 |
Rom rom; |
| 81 |
|
| 82 |
|
| 83 |
MSXCPU& cpu; |
| 84 |
|
| 85 |
|
| 86 |
|
| 87 |
BooleanSetting quickRcvSetting; |
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
unsigned uartSpeed = 0; |
| 92 |
bool underrun = false; |
| 93 |
|
| 94 |
|
| 95 |
bool realEndpointActive = false; |
| 96 |
}; |
| 97 |
|
| 98 |
} |
| 99 |
|
| 100 |
#endif |