mirror of
https://github.com/halleysfifthinc/AVCLAN-Mockingboard.git
synced 2026-08-07 01:13:18 +00:00
Add C++ Peripheral class
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
// copyright (C) 2006 Marcin Slonicki <marcin@softservice.com.pl>
|
||||
// copyright (C) 2007 Louis Frigon
|
||||
// Copyright (C) 2015 Allen Hill <allenofthehills@gmail.com>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
#pragma once
|
||||
|
||||
#include "avclan_defs.h"
|
||||
#include <cstdint>
|
||||
|
||||
namespace avclan {
|
||||
class Peripheral {
|
||||
public:
|
||||
struct Error {
|
||||
// Error enums are ordered such that a lower numeric value corresponds to
|
||||
// more progress/success before an error occured, with 0 being no errors
|
||||
enum class Read : uint8_t {
|
||||
BAD_DATA_PARITY = rBAD_DATA_PARITY, // = 0x01
|
||||
BAD_LENGTH_RANGE = rBAD_LENGTH_RANGE,
|
||||
BAD_LENGTH_PARITY = rBAD_LENGTH_PARITY,
|
||||
BAD_PERIPHERAL_PARITY = rBAD_PERIPHERAL_PARITY,
|
||||
BAD_CONTROLLER_PARITY = rBAD_CONTROLLER_PARITY,
|
||||
BAD_CONTROL_PARITY = rBAD_CONTROL_PARITY,
|
||||
STARTBIT_TOO_SHORT = rSTARTBIT_TOO_SHORT,
|
||||
STARTBIT_TOO_LONG = rSTARTBIT_TOO_LONG,
|
||||
BAD_STARTBIT = rLATCHED_COMPARATOR,
|
||||
};
|
||||
|
||||
enum class Send : uint8_t {
|
||||
NAK_DATA = sNAK_DATA, // = 0x01
|
||||
NAK_MESSAGE_LENGTH = sNAK_MESSAGE_LENGTH,
|
||||
NAK_CONTROL = sNAK_CONTROL,
|
||||
NAK_ADDRESS = sNAK_ADDRESS,
|
||||
BUSY = sBUSY,
|
||||
MUTED = sMUTED,
|
||||
};
|
||||
};
|
||||
|
||||
Peripheral(uint16_t address) : address{address} {}
|
||||
|
||||
Error::Read read(AVCLAN_frame_t *in, log_t print);
|
||||
Error::Send send(const AVCLAN_frame_t *out, log_t print);
|
||||
|
||||
private:
|
||||
const uint16_t address;
|
||||
};
|
||||
} // namespace avclan
|
||||
Reference in New Issue
Block a user