KEK/kw11-l.h
folkert van heusden 9a858fbe7a
KW11-L state
2024-05-10 20:35:35 +02:00

54 lines
1.1 KiB
C++

// (C) 2018-2024 by Folkert van Heusden
// Released under MIT license
#include <atomic>
#include <thread>
#include "bus.h"
#include "console.h"
#include "device.h"
#include "gen.h"
class kw11_l: public device
{
private:
bus *const b { nullptr };
console *cnsl { nullptr };
#if defined(BUILD_FOR_RP2040)
SemaphoreHandle_t lf_csr_lock { xSemaphoreCreateBinary() };
#else
std::thread *th { nullptr };
std::mutex lf_csr_lock;
#endif
uint16_t lf_csr { 0 };
std::atomic_bool stop_flag { false };
uint8_t get_lf_crs();
void set_lf_crs_b7();
void do_interrupt();
public:
kw11_l(bus *const b);
virtual ~kw11_l();
void reset();
void show_state(console *const cnsl) const override;
#if IS_POSIX
json_t *serialize();
static kw11_l *deserialize(const json_t *const j, bus *const b, console *const cnsl);
#endif
void begin(console *const cnsl);
void operator()();
uint16_t read_word (const uint16_t a);
void write_byte(const uint16_t addr, const uint8_t v);
void write_word(const uint16_t a, const uint16_t v);
};