summaryrefslogtreecommitdiffstats
path: root/phy/transmitter.h
blob: b1d0bc9de85c361d86b4b518965295b75dbd43cd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef MYRADIO_PHY_TRANSMITTER_H_
#define MYRADIO_PHY_TRANSMITTER_H_

/* Lowlevel transmitter definitions.
 * These functions do poke with the actual TX hardware.
 */

#include <avr/io.h>

/* Our transmitter is a trivial radio transmitter module that
 * will amplitude- (or frequency-) modulate any bit that is set
 * immediately to the wireless medium.
 * We have two output pins on the digital PHY, which are connected
 * via a trivial R2R network to the Analog part of the PHY.
 * One of the digital pins is the transmitter-power pin and one is
 * the data bit signal.
 * So the way the radio sees the data on its pin is:
 * 0V = transmitter powered off
 * about 4V = Logical zero
 * 5V = Logical one
 * These voltage levels are generated by the analog (R2R network) from
 * the two digital transmitter pins.
 *
 * An example for a possible radio hardware is this:
 * http://www.conrad.de/goto.php?artikel=130428
 */

#define TRANSMITTER_PORT	PORTC
#define TRANSMITTER_DDR		DDRC
#define TRANSMITTER_POWERON	1 /* Power-ON bit */
#define TRANSMITTER_DATABIT	2 /* Data bit */


static inline void transmitter_data_bit_set(bool high)
{
	if (high)
		TRANSMITTER_PORT |= (1 << TRANSMITTER_DATABIT);
	else
		TRANSMITTER_PORT &= ~(1 << TRANSMITTER_DATABIT);
}

static inline void transmitter_enable(void)
{
	transmitter_data_bit_set(0);
	TRANSMITTER_PORT |= (1 << TRANSMITTER_POWERON);
}

static inline void transmitter_disable(void)
{
	transmitter_data_bit_set(0);
	TRANSMITTER_PORT &= ~(1 << TRANSMITTER_POWERON);
}

static inline void transmitter_initialize(void)
{
	transmitter_data_bit_set(0);
	TRANSMITTER_PORT &= ~(1 << TRANSMITTER_POWERON);
	TRANSMITTER_DDR |= (1 << TRANSMITTER_POWERON) | (1 << TRANSMITTER_DATABIT);
}


#endif /* MYRADIO_PHY_TRANSMITTER_H_ */
bues.ch cgit interface