-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwireless.c
75 lines (72 loc) · 1.76 KB
/
wireless.c
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
63
64
65
66
67
68
69
70
71
72
73
74
75
//Includes
#include <mega32.h>
#include <./txrx.c>
#include <delay.h>
unsigned char a[6]={4,8,15,16,23,42};
unsigned char b[7]={1,2,4,8,16,32,64};
int mcswitch,i;
unsigned char trigger;
void main(void){
DDRA = 0x00;
DDRB = 0xff;
DDRC = 0xff;
PORTB = 0xff;
PORTC = 0x00;
TIMSK = 0;
delay_ms(500);
PORTC = 0xff;
delay_ms(500);
mcswitch = 0;
txrx_init(1,1,249,1);
delay_ms(10);
delay_ms(10);
rx_reset(30);
tx_me(a,6,5);
init_getrx();
while(1){
while(!rx_empty()) {PORTC = ~get_next_rx_data(); delay_ms(20);}
rx_reset(30);
init_getrx();
if(trigger == 1) tx_me(b,7,5);
if(trigger == 0) tx_me(a,6,5);
trigger = ~trigger & 0x01;
//PORTC.5=0;
//if(~PINA.0) PORTC = ~get_next_rx_data();
if(~PINA.0 && (mcswitch == 0)){
tx_me(a,6,5);
mcswitch++;
}
if(~PINA.1 && ((mcswitch == 1) || (mcswitch == 7))){
PORTC=~get_next_rx_data();
mcswitch++;
}
if(~PINA.2 && ((mcswitch == 2) || (mcswitch == 8))){
PORTC=~get_next_rx_data();
mcswitch++;
}
if(~PINA.3 && ((mcswitch == 3) || (mcswitch == 9))){
PORTC=~get_next_rx_data();
mcswitch++;
}
if(~PINA.4 && ((mcswitch == 4) || (mcswitch == 10))){
PORTC=~get_next_rx_data();
mcswitch++;
}
if(~PINA.5 && ((mcswitch == 5) || (mcswitch == 11))){
PORTC=~get_next_rx_data();
mcswitch++;
}
if(~PINA.6 && ((mcswitch == 6) || (mcswitch == 12))){
if(mcswitch == 12){
rx_reset(30);
mcswitch = 0;
txdone();
}
else{
PORTC=~get_next_rx_data();
mcswitch++;
}
}
//if(b[0] == 4) PORTB.7 = 0;*/
}
}