Author | Rob Jansen, Copyright © 2018..2019, all rights reserved. |
Adapted-by | |
Compiler | 2.5r2 |
This is the receive only version of Virtual_Wire, see the file virtual_wire.jal for all changes compared to the original Virtual_Wire library and more information.
http://www.airspayce.com/mikem/arduino/VirtualWire.pdf
-
No dependency found
var byte vw_rx_bit_count
var bit vw_rx_last_sample
var byte vw_rx_len
var byte vw_rx_pll_ramp
var bit vw_rx_active
const byte VW_RAMP_TRANSITION = VW_RX_RAMP_LEN/2
var word data_2
var bit vw_rx_enabled
var byte vw_rx_integrator
var word vw_rx_bits
const byte VW_RX_SAMPLES_PER_BIT = 8
const byte VW_MAX_PAYLOAD = VW_MAX_MESSAGE_LEN - 3
const byte VW_RAMP_INC = (VW_RX_RAMP_LEN/VW_RX_SAMPLES_PER_BIT)
const byte VW_RAMP_ADJUST = 9
const byte symbols_d[] =
var byte vw_rx_count
const byte VW_RAMP_INC_ADVANCE = (VW_RAMP_INC + VW_RAMP_ADJUST)
const byte VW_RAMP_INC_RETARD = (VW_RAMP_INC - VW_RAMP_ADJUST)
var byte vw_rx_return_buf[VW_MAX_PAYLOAD]
var bit vw_rx_sample
var byte this_byte
var byte vw_tx_rx_buf[VW_MAX_MESSAGE_LEN * 2]
const byte VW_RX_RAMP_LEN = 160
var bit vw_rx_done
var byte vw_rx_bit_count
How many bits of message we have received. Ranges from 0 to 12
var bit vw_rx_last_sample
Last receivers sample.
var byte vw_rx_len
The incoming message buffer length received so far
var byte vw_rx_pll_ramp
PLL ramp, varies between 0 and VW_RX_RAMP_LEN-1 (159) over VW_RX_SAMPLES_PER_BIT (8) samples per nominal bit time. When the PLL is synchronised, bit transitions happen at about the 0 mark.
var bit vw_rx_active
Flag indicates if we have seen the start symbol of a new message and are in the processes of reading and decoding it
const byte VW_RAMP_TRANSITION = VW_RX_RAMP_LEN/2
Internal ramp adjustment parameter
var word data_2
No documentation found
var bit vw_rx_enabled
Flag to indicate the receiver PLL is to run
var byte vw_rx_integrator
This is the integrate and dump integral. If there are <5 0 samples in the PLL cycle the bit is declared a 0, else a 1
var word vw_rx_bits
Last 12 bits received, so we can look for the start symbol
const byte VW_RX_SAMPLES_PER_BIT = 8
Number of samples per bit.
const byte VW_MAX_PAYLOAD = VW_MAX_MESSAGE_LEN - 3
The maximum payload length, count (1) and FCS (2) must be subtracted.
const byte VW_RAMP_INC = (VW_RX_RAMP_LEN/VW_RX_SAMPLES_PER_BIT)
Ramp adjustment parameters Standard is if a transition occurs before VW_RAMP_TRANSITION (80) in the ramp, the ramp is retarded by adding VW_RAMP_INC_RETARD (11) else by adding VW_RAMP_INC_ADVANCE (29) If there is no transition it is adjusted by VW_RAMP_INC (20) Internal ramp adjustment parameter
const byte VW_RAMP_ADJUST = 9
Internal ramp adjustment parameter
const byte symbols_d[] =
Conversion table for 6 to 4 symbol decoding using a lookup table. We only need to indicate the values from the encoding table. Without lookup table the conversion would take too long.
var byte vw_rx_count
The incoming message expected length
const byte VW_RAMP_INC_ADVANCE = (VW_RAMP_INC + VW_RAMP_ADJUST)
Internal ramp adjustment parameter
const byte VW_RAMP_INC_RETARD = (VW_RAMP_INC - VW_RAMP_ADJUST)
Internal ramp adjustment parameter
var byte vw_rx_return_buf[VW_MAX_PAYLOAD]
The buffer to copy the return message to for the main program. This buffer is smaller than the combined vw_tx_rx_buf since it only holds data no symbol.s
var bit vw_rx_sample
Current receiver sample
var byte this_byte
No documentation found
var byte vw_tx_rx_buf[VW_MAX_MESSAGE_LEN * 2]
Transmit and receive buffer. The symbol buffer for transmission is combined with the data buffer for reception.
const byte VW_RX_RAMP_LEN = 160
The size of the receiver ramp. Ramp wraps modulo this number
var bit vw_rx_done
Flag to indicate that a new message is available
vw_rx_start()
Enable the receiver. When a message becomes available, vw_rx_done flag is set, and vw_wait_rx() will return.
vw_service()
This is the service routine that must be called by the main program when the timer overflows. Its job is to call the PLL code if the receiver is enabled.
vw_rx_stop()
Disable the receiver
vw_wait_rx()
Wait for the receiver to get a message Busy-wait loop until the ISR says a message is available can then call vw_get_message()
vw_init()
Initialize the virtual wire driver.
_vw_pll()
Called 8 times per bit period by the timer interrupt routine Phase locked loop tries to synchronise with the transmitter so that bit transitions occur at about the time vw_rx_pll_ramp is 0 Then the average is computed over each bit period to deduce the bit value
vw_have_message() return bit
Return true if there is a message available
vw_get_message(byte in out len) return bit
Get the last message received (without byte count or FCS) Copy at most *len bytes, set *len to the actual number copied Return true if there is a message and the FCS is OK The data is copied to a receive buffer.
_vw_calc_crc(word in crc, byte in data) return word
Calculate new crc over given data. Formula is: Xexp16 + Xexp12 + Xexp5 + 1
12f617 | 12f617_virtual_wire_receiver.jal |