OXYGENHUB
◆ main enhanced-x16-emulator / src / vera_spi.h
1.3 KiB · Objective-C · last changed chore(): initial commit 25 days ago source blame history raw
1
// Commander X16 Emulator
2
// Copyright (c) 2019 Michael Steil
3
// All rights reserved. License: 2-clause BSD
4
5
#pragma once
6
7
#include <inttypes.h>
8
#include <stdbool.h>
9
10
#ifdef __cplusplus
11
extern "C" {
12
#endif
13
14
void vera_spi_init();
15
void vera_spi_step(int mhz, int clocks);
16
uint8_t vera_spi_read(uint8_t address);
17
// Side-effect-free read of the same registers, for debug views. Unlike
18
// vera_spi_read(), does not start an autotx transfer.
19
uint8_t vera_spi_peek(uint8_t address);
20
void vera_spi_write(uint8_t address, uint8_t value);
21
22
// ─── Debugger accessor ───────────────────────────────────────────────────────
23
// Side-effect-free snapshot of VERA SPI state. Safe to call every frame from
24
// the debugger while the emulation is running.
25
26
typedef struct {
27
	bool    ss;            // slave-select (chip-select) asserted
28
	bool    busy;          // transfer currently in flight
29
	bool    autotx;        // auto-transmit mode active
30
	uint8_t sending_byte;  // byte currently being clocked out
31
	uint8_t received_byte; // last byte received from card
32
	float   outcounter;    // clock-cycle progress toward transfer completion
33
} vera_spi_debug_state_t;
34
35
void vera_spi_debug_get_state(vera_spi_debug_state_t *out);
36
37
#ifdef __cplusplus
38
}
39
#endif