VirtualWire
|
VirtualWire API. More...
#include <stdint.h>
#include "VirtualWire_Config.h"
Go to the source code of this file.
Macros | |
#define | VW_PLATFORM_ARDUINO 1 |
#define | VW_PLATFORM_MSP430 2 |
#define | VW_PLATFORM_STM32 3 |
#define | VW_PLATFORM_GENERIC_AVR8 4 |
#define | VW_PLATFORM_UNO32 5 |
#define | VW_MAX_MESSAGE_LEN 80 |
Maximum number of bytes in a message, counting the byte count and FCS. | |
#define | VW_RX_SAMPLES_PER_BIT 8 |
Number of samples per bit. | |
#define | VW_MAX_PAYLOAD VW_MAX_MESSAGE_LEN-3 |
The maximum payload length. | |
#define | VW_RX_RAMP_LEN 160 |
The size of the receiver ramp. Ramp wraps modulo this number. | |
#define | VW_RAMP_INC (VW_RX_RAMP_LEN/VW_RX_SAMPLES_PER_BIT) |
Internal ramp adjustment parameter. | |
#define | VW_RAMP_TRANSITION VW_RX_RAMP_LEN/2 |
Internal ramp adjustment parameter. | |
#define | VW_RAMP_ADJUST 9 |
Internal ramp adjustment parameter. | |
#define | VW_RAMP_INC_RETARD (VW_RAMP_INC-VW_RAMP_ADJUST) |
Internal ramp adjustment parameter. | |
#define | VW_RAMP_INC_ADVANCE (VW_RAMP_INC+VW_RAMP_ADJUST) |
Internal ramp adjustment parameter. | |
#define | VW_HEADER_LEN 8 |
Functions | |
void | vw_set_ptt_pin (uint8_t pin) |
void | vw_set_tx_pin (uint8_t pin) |
void | vw_set_rx_pin (uint8_t pin) |
void | vw_set_rx_inverted (uint8_t inverted) |
void | vw_set_ptt_inverted (uint8_t inverted) |
void | vw_setup (uint16_t speed) |
void | vw_rx_start () |
void | vw_rx_stop () |
uint8_t | vw_tx_active () |
void | vw_wait_tx () |
void | vw_wait_rx () |
uint8_t | vw_wait_rx_max (unsigned long milliseconds) |
uint8_t | vw_send (uint8_t *buf, uint8_t len) |
uint8_t | vw_have_message () |
uint8_t | vw_get_message (uint8_t *buf, uint8_t *len) |
uint8_t | vw_get_rx_good () |
uint8_t | vw_get_rx_bad () |
VirtualWire API.
To use the VirtualWire library, you must have
At the top of your sketch.
#define VW_HEADER_LEN 8 |
Outgoing message bits grouped as 6-bit words 36 alternating 1/0 bits, followed by 12 bits of start symbol Followed immediately by the 4-6 bit encoded byte count, message buffer and 2 byte FCS Each byte from the byte count on is translated into 2x6-bit words Caution, each symbol is transmitted LSBit first, but each byte is transmitted high nybble first
Referenced by vw_send().
uint8_t vw_get_message | ( | uint8_t * | buf, |
uint8_t * | len | ||
) |
If a message is available (good checksum or not), copies up to *len octets to buf.
[in] | buf | Pointer to location to save the read data (must be at least *len bytes. |
[in,out] | len | Available space in buf. Will be set to the actual number of octets read |
uint8_t vw_get_rx_bad | ( | ) |
Returns the count of bad messages received, ie messages with bogus lengths, indicating corruption or lost octets. Caution,: this is an 8 bit count and can easily overflow
uint8_t vw_get_rx_good | ( | ) |
Returns the count of good messages received Caution,: this is an 8 bit count and can easily overflow
uint8_t vw_have_message | ( | ) |
Returns true if an unread message is available
void vw_rx_start | ( | ) |
Start the Phase Locked Loop listening to the receiver Must do this before you can receive any messages When a message is available (good checksum or not), vw_have_message(); will return true.
void vw_rx_stop | ( | ) |
Stop the Phase Locked Loop listening to the receiver No messages will be received until vw_rx_start() is called again Saves interrupt processing cycles
uint8_t vw_send | ( | uint8_t * | buf, |
uint8_t | len | ||
) |
Send a message with the given length. Returns almost immediately, and message will be sent at the right timing by interrupts
[in] | buf | Pointer to the data to transmit |
[in] | len | Number of octetes to transmit |
References VW_HEADER_LEN, VW_MAX_PAYLOAD, and vw_wait_tx().
void vw_set_ptt_inverted | ( | uint8_t | inverted | ) |
By default the PTT pin goes high when the transmitter is enabled. This flag forces it low when the transmitter is enabled.
[in] | inverted | True to invert PTT |
void vw_set_ptt_pin | ( | uint8_t | pin | ) |
This pin will only be accessed if the transmitter is enabled
[in] | pin | The Arduino pin number to enable the transmitter. Defaults to 10. |
void vw_set_rx_inverted | ( | uint8_t | inverted | ) |
By default the RX pin is expected to be low when idle, and to pulse high for each data pulse. This flag forces it to be inverted. This may be necessary if your transport medium inverts the logic of your signal, such as happens with some types of A/V tramsmitter.
[in] | inverted | True to invert sense of receiver input |
void vw_set_rx_pin | ( | uint8_t | pin | ) |
Set the digital IO pin to be for receive data. This pin will only be accessed if the receiver is enabled
[in] | pin | The Arduino pin number for receiving data. Defaults to 11. |
void vw_set_tx_pin | ( | uint8_t | pin | ) |
Set the digital IO pin to be for transmit data. This pin will only be accessed if the transmitter is enabled
[in] | pin | The Arduino pin number for transmitting data. Defaults to 12. |
void vw_setup | ( | uint16_t | speed | ) |
Initialise the VirtualWire software, to operate at speed bits per second Call this one in your setup() after any vw_set_* calls Must call vw_rx_start() before you will get any messages
[in] | speed | Desired speed in bits per second |
uint8_t vw_tx_active | ( | ) |
Returns the state of the transmitter
void vw_wait_rx | ( | ) |
Block until a message is available then returns
uint8_t vw_wait_rx_max | ( | unsigned long | milliseconds | ) |
Block until a message is available or for a max time
[in] | milliseconds | Maximum time to wait in milliseconds. |
void vw_wait_tx | ( | ) |
Block until the transmitter is idle then returns
Referenced by vw_send().