mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-09-25 13:22:06 +00:00
Refactor peripheral/bus/phy APIs (prep for pico/PIO)
- Refactor PHY to be higher-level with a field focus (controller/peripheral address,
control byte, etc)
- Phy layer is now device address aware (ACK's automatically) (Hardens
previously ~implicit design to only support emulating one AVCLAN
unit per mockingboard build)
- Redesign `phy_active` => `phy_frame_pending` (to allow
asynchronous/buffered frame reads on pico) and embed within
Peripheral::read
- Add `deafen` function: like mute, but also ignore incoming messages (i.e.
don't receive/process at all). Makes `Bus::is_active` always return
`false`.
- Add debug bus driving functions
Assisted-by: Claude Code (Opus 5)
This commit is contained in:
+15
-3
@@ -69,18 +69,29 @@ public:
|
||||
Bus(const Bus &) = delete;
|
||||
Bus &operator=(const Bus &) = delete;
|
||||
|
||||
void init();
|
||||
// `address` is our own peripheral address; the phy keeps it and acknowledges
|
||||
// frames addressed to it without further instruction. One address per bus.
|
||||
void init(uint16_t address);
|
||||
|
||||
// True when there is a frame to read and we aren't deafened. Depending on the
|
||||
// target that means the bus has gone dominant or a frame is already buffered.
|
||||
bool is_active() const;
|
||||
|
||||
// Prevent the device from being active on the bus
|
||||
void mute(bool mute);
|
||||
bool is_muted() const { return muted_; };
|
||||
|
||||
// Set the device to be deaf to (ie ignore) bus activity
|
||||
void deafen(bool deaf);
|
||||
|
||||
#ifndef NDEBUG
|
||||
void measure();
|
||||
detail::Error::Send sendbyte(uint8_t byte, bool ack = false);
|
||||
void set_dominant();
|
||||
void set_recessive();
|
||||
#endif
|
||||
|
||||
expected<std::unique_ptr<Frame>, Error::Read> read(uint16_t address,
|
||||
Frame::Print print);
|
||||
expected<std::unique_ptr<Frame>, Error::Read> read(Frame::Print print);
|
||||
Error::Send send(const Frame &out, Frame::Print print);
|
||||
|
||||
private:
|
||||
@@ -89,6 +100,7 @@ private:
|
||||
|
||||
// Assume mute after default ctor; only viable after init call
|
||||
bool muted_ = true;
|
||||
bool deafened_ = false;
|
||||
bool inited_ = false;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user