101 Codec(uint8_t bits_per_symbol,
102 uint16_t start_symbol,
103 uint8_t preamble_max = VWI::Transmitter::PREAMBLE_MAX);
111 virtual const uint8_t*
preamble() = 0;
119 virtual uint8_t
encode4(uint8_t nibble) = 0;
127 virtual uint8_t
decode4(uint8_t symbol) = 0;
138 return ((
decode4(symbol) << 4) | (
decode4(symbol >> BITS_PER_SYMBOL)));
229 int recv(uint8_t& src, uint8_t& port,
void* buf,
size_t len,
247 static const uint8_t RAMP_MAX = 160;
250 static const uint8_t INTEGRATOR_THRESHOLD = 5;
262 static const uint8_t RAMP_TRANSITION = RAMP_MAX / 2;
265 static const uint8_t RAMP_ADJUST = 9;
268 static const uint8_t RAMP_INC_RETARD = (RAMP_INC - RAMP_ADJUST);
271 static const uint8_t RAMP_INC_ADVANCE = (RAMP_INC + RAMP_ADJUST);
280 uint8_t m_last_sample;
293 uint8_t m_integrator;
302 volatile bool m_done;
320 volatile uint8_t m_length;
394 int send(uint8_t dest, uint8_t port,
const iovec_t* vec);
408 int send(uint8_t dest, uint8_t port,
const void* buf,
size_t len);
415 uint8_t m_buffer[(MESSAGE_MAX * 2) + PREAMBLE_MAX];
433 volatile uint8_t m_enabled;
472 VWI(int16_t net, uint8_t dev,
491 virtual bool begin(
const void* config =
NULL);
520 if (m_rx ==
NULL)
return (
false);
521 return (m_rx->available());
537 if (m_tx ==
NULL)
return (-1);
538 return (m_tx->send(dest, port, vec));
553 virtual int send(uint8_t dest, uint8_t port,
const void* buf,
size_t len)
555 if (m_tx ==
NULL)
return (-1);
556 return (m_tx->send(dest, port, buf, len));
575 virtual int recv(uint8_t& src, uint8_t& port,
576 void* buf,
size_t len,
579 if (m_rx ==
NULL)
return (-1);
580 return (m_rx->recv(src, port, buf, len, ms));
589 if (m_rx ==
NULL)
return (0);
590 return (m_rx->link_quality_indicator());
static const uint8_t MESSAGE_MAX
virtual int link_quality_indicator()
static const uint8_t SAMPLES_PER_BIT
virtual uint8_t encode4(uint8_t nibble)=0
const uint8_t BITS_PER_SYMBOL
virtual bool begin(const void *config=NULL)
const uint16_t START_SYMBOL
static const uint8_t PAYLOAD_MAX
virtual uint8_t decode4(uint8_t symbol)=0
VWI(int16_t net, uint8_t dev, uint16_t speed, Receiver *rx)
Transmitter(Board::DigitalPin pin, Codec *codec)
Receiver(Board::DigitalPin pin, Codec *codec)
VWI(int16_t net, uint8_t dev, uint16_t speed, Receiver *rx, Transmitter *tx)
virtual uint8_t decode8(uint16_t symbol)
virtual int recv(uint8_t &src, uint8_t &port, void *buf, size_t len, uint32_t ms=0L)
friend void TIMER1_COMPA_vect(void)
static const uint8_t MESSAGE_MIN
virtual int send(uint8_t dest, uint8_t port, const void *buf, size_t len)
const uint8_t PREAMBLE_MAX
Driver(int16_t network, uint8_t device)
Codec(uint8_t bits_per_symbol, uint16_t start_symbol, uint8_t preamble_max=VWI::Transmitter::PREAMBLE_MAX)
virtual const uint8_t * preamble()=0
IOStream & clear(IOStream &outs)
const uint8_t SYMBOL_MASK
virtual int send(uint8_t dest, uint8_t port, const iovec_t *vec)
VWI(int16_t net, uint8_t dev, uint16_t speed, Transmitter *tx)