VirtualWire
Main Page
Files
Examples
File List
Globals
VirtualWire_Config.h
1
#ifndef VirtualWire_Config_h
2
#define VirtualWire_Config_h
3
//////////////////////////////////////////////////////////////////////////
4
// The following configurations are intented only if VW_PLATFORM == VW_PLATFORM_GENERIC_AVR8
5
6
// Uncomment this to select the platform as generic AVR8
7
//#define VW_PLATFORM VW_PLATFORM_GENERIC_AVR8
8
9
// OPTIONAL: Define the IO pin used for PTT (push to talk)
10
// If no PTT port will be defined, the PTT feature will be disabled
11
//#define VW_PTT_PORT PORT#
12
//#define VW_PTT_DDR DDR#
13
//#define VW_PTT_PIN PIN#?
14
15
// Define the IO pin used for transmitting data
16
//#define VW_TX_PORT PORT#
17
//#define VW_TX_DDR DDR#
18
//#define VW_TX_PIN PIN#?
19
20
// Define the IO pin used for receiving data
21
//#define VW_RX_PORT PIN#
22
//#define VW_RX_DDR DDR#
23
//#define VW_RX_PIN PIN#?
24
25
// Define the 16 bits timer index to be used by the library (e.g. 1)
26
// The default timer configuration will use TIMSKn as interrupt mask register,
27
// OCRnA as compare register and TIMERn_COMPA_vect as interrupt vector
28
// If one of the above doesn't suite your current platform, please redefine
29
// the timer setup routine, as indicated below
30
//#define VW_TIMER_INDEX 1
31
32
//
33
// EXAMPLE: configuration suitable for At90USB162 or ATMega32U2
34
//
35
36
/*
37
// Select AVR8 platform
38
#define VW_PLATFORM VW_PLATFORM_GENERIC_AVR8
39
40
// My radio doesn't have PTT feature => VW_PTT_PORT/DDR/PIN will be left undefined
41
//#define VW_PTT_PORT
42
//#define VW_PTT_DDR
43
//#define VW_PTT_PIN
44
45
// VirtualWire TX
46
#define VW_TX_PORT PORTD
47
#define VW_TX_DDR DDRD
48
#define VW_TX_PIN PIND7
49
50
// VirtualWire RX
51
#define VW_RX_PORT PIND
52
#define VW_RX_DDR DDRD
53
#define VW_RX_PIN PIND6
54
55
// Reduce message length, saves up memory
56
#define VW_MAX_MESSAGE_LEN 40
57
58
// Select Timer 1 as the 16 bits timer used by the library
59
#define VW_TIMER_INDEX 1
60
*/
61
62
//
63
// OPTIONAL: Alternative pin setup for advanced configurations
64
// Instead of defining VW_PTT_PORT/DDR/PIN, VW_TX_PORT/DDR/PIN or VW_RX_PORT/DDR/PIN
65
// the user can use the following preprocessor directives to control the way
66
// VirtualWire library reads the RX and writes to the TX or PTT
67
//
68
69
//#define vw_pinSetup()
70
//#define vw_digitalWrite_ptt(value)
71
//#define vw_digitalRead_rx()
72
//#define vw_digitalWrite_tx(value)
73
74
//
75
// EXAMPLE: Advanced pin configuration that lights up a LED when PTT is high
76
// RX=PORTD7, PTT=PORTD6, LED=PORTD5, TX=PORTD4
77
//
78
79
/*
80
// Select AVR8 platform
81
#define VW_PLATFORM VW_PLATFORM_GENERIC_AVR8
82
83
#define vw_pinSetup()\
84
DDRD |= (1<<PORTD6)|(1<<PORTD5)|(1<<PORTD4);\
85
DDRD &= ~(1<<PORTD7);
86
87
#define vw_digitalWrite_ptt(value)\
88
((value)? PORTD |= (1<<PORTD6)|(1<<PORTD5) : PORTD &= ~((1<<PORTD6)|(1<<PORTD5))
89
#define vw_digitalRead_rx() \
90
(PORTD & (1<<PORTD7) ? 1 : 0)
91
#define vw_digitalWrite_tx(value) \
92
((value) ? PORTD |= (1<<PORTD4) : PORTD &= ~(1<<PORTD4))
93
*/
94
95
//
96
// OPTIONAL: Alternative timer configuration
97
// If the default timer setup doesn't suite the platform you are using, you can
98
// rewrite the timer setup routine and define the timer vector used by the ISR
99
// implemented within the library
100
//
101
102
//#define vw_timerSetup(speed)
103
//#define VW_TIMER_VECTOR
104
105
//
106
// EXAMPLE: Setting up a user defined timer configuration for VirtualWire
107
// that uses OCR1B as compare register instead of OCR1A
108
//
109
110
/*
111
#include <stdint.h>
112
113
// Select AVR8 platform
114
#define VW_PLATFORM VW_PLATFORM_GENERIC_AVR8
115
116
// Declare my own timer setup function
117
static inline void my_vw_timerSetup(uint8_t speed) __attribute__ ((always_inline));
118
119
// VirtualWire has a special routine for detecting prescaler and the number of ticks
120
// automatically, but needs to be declared first in order to be used
121
uint8_t vw_timer_calc(uint16_t speed, uint16_t max_ticks, uint16_t *nticks);
122
123
// Instruct VirtualWire to use my timer setup routine and my interrupt vector
124
#define vw_timerSetup(speed) my_vw_timerSetup(speed);
125
#define VW_TIMER_VECTOR TIMER1_COMPB_vect
126
127
// Define my setup timer routine, that uses OCR1B as compare register
128
static inline void my_vw_timerSetup(uint8_t speed)
129
{
130
// Figure out prescaler value and counter match value
131
prescaler = vw_timer_calc(speed, (uint16_t)-1, &nticks);
132
if (!prescaler)
133
{
134
return; // fault
135
}
136
137
TCCR1A = 0; // Output Compare pins disconnected
138
TCCR1B = _BV(WGM12); // Turn on CTC mode
139
140
// Convert prescaler index to TCCR1B prescaler bits CS10, CS11, CS12
141
TCCR1B |= prescaler;
142
143
// Caution: special procedures for setting 16 bit regs
144
// is handled by the compiler
145
OCR1B = nticks;
146
147
// Enable interrupt
148
TIMSK1 |= _BV(OCIE1B);
149
}
150
*/
151
152
#endif
/* VirtualWire_Config_h */
Generated by
1.8.5