COSA
An Object-Oriented Platform for Arduino Programming
VWI::Receiver Class Reference

#include <VWI.hh>

Inheritance diagram for VWI::Receiver:
Inheritance graph
Collaboration diagram for VWI::Receiver:
Collaboration graph

Public Member Functions

 Receiver (Board::DigitalPin pin, Codec *codec)
 
void begin ()
 
void end ()
 
bool available () const
 
int recv (uint8_t &src, uint8_t &port, void *buf, size_t len, uint32_t ms=0L)
 
int link_quality_indicator ()
 

Private Types

enum  Mode { NORMAL_MODE = 0, PULLUP_MODE = 1 }
 
enum  Direction { MSB_FIRST = 0, LSB_FIRST = 1 }
 

Private Member Functions

Mode mode () const
 
volatile uint8_t * PIN () const
 
volatile uint8_t * DDR () const
 
volatile uint8_t * PORT () const
 
uint8_t pin () const
 
bool is_set () const
 
bool is_high () const
 
bool is_on () const
 
bool is_clear () const
 
bool is_low () const
 
bool is_off () const
 
bool read () const
 
uint8_t read (OutputPin &clk, Direction order=MSB_FIRST) const
 
 operator bool () const
 
Pinoperator>> (uint8_t &var)
 
volatile uint8_t * PCIMR () const
 

Static Private Member Functions

static void mode (Board::DigitalPin pin, Mode mode)
 
static Mode mode (Board::DigitalPin pin)
 
static uint8_t MASK (uint8_t pin)
 
static volatile uint8_t * PIN (uint8_t pin)
 
static volatile uint8_t * DDR (uint8_t pin)
 
static volatile uint8_t * PORT (uint8_t pin)
 
static bool read (Board::DigitalPin pin)
 

Private Attributes

volatile uint8_t *const m_sfr
 
const uint8_t m_mask
 
const uint8_t m_pin
 

Friends

void TIMER1_COMPA_vect (void)
 

Detailed Description

Virtual Wire Receiver.

Definition at line 174 of file VWI.hh.

Constructor & Destructor Documentation

VWI::Receiver::Receiver ( Board::DigitalPin  pin,
Codec codec 
)
inline

Construct VWI Receiver instance connected to the given pin.

Parameters
[in]rxinput pin.
[in]codecfor the receiver.

Definition at line 181 of file VWI.hh.

Member Function Documentation

bool VWI::Receiver::available ( ) const
inline

Returns true if an unread message is available. May have a bad check-sum.

Returns
true(1) if a message is available to read.

Definition at line 212 of file VWI.hh.

void VWI::Receiver::begin ( )
inline

Start the Phase Locked Loop listening for the receiver. Must do this before receiving any messages,

Definition at line 191 of file VWI.hh.

void VWI::Receiver::end ( )
inline

Stop the Phase Locked Loop listening to the receiver. No messages will be received until begin() is called again. Saves interrupt processing cycles.

Definition at line 202 of file VWI.hh.

int VWI::Receiver::link_quality_indicator ( )

Return link quality indicator; milli-seconds that the receiver pin is low after receiving a message. RF433 RX modules will increase gain until noise is detected. The lower the gain during the latest message the longer the delay before noise. Typical values are 200 when transmitter (3.7V) is 10 cm from the receiver, 150 at 50 cm, 100 at 5 m. For this measurement to be valid a new message should not be sent in the automatic gain control time slot (time until noise).

Returns
milli-seconds.

Definition at line 156 of file VWI_Receiver.cpp.

int VWI::Receiver::recv ( uint8_t &  src,
uint8_t &  port,
void *  buf,
size_t  len,
uint32_t  ms = 0L 
)

If a message is available (good checksum or not), copies up to len bytes to the given buffer, buf. Returns number of bytes received/copied, zero(0) for timeout or negative error code; bad checksum(-1), and in enhanced mode did not match address(-2).

Parameters
[out]srcsource network address.
[out]portdevice port (or message type).
[in]bufpointer to location to save the read data.
[in]lenavailable space in buf.
[in]mstimeout period (zero for blocking)
Returns
number of bytes received or negative error code.

Definition at line 119 of file VWI_Receiver.cpp.

Friends And Related Function Documentation

void TIMER1_COMPA_vect ( void  )
friend

Interrupt Service Routine.

Interrupt Service Routines.


The documentation for this class was generated from the following files: