-
Notifications
You must be signed in to change notification settings - Fork 0
/
wireless.c
63 lines (57 loc) · 955 Bytes
/
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
/*
* Wireless.c
*
* Created: 2012/10/14 9:36:47
* Author: Genius
*/
#include "m_general.h"
#include "m_usb.h"
#include "wirelessX.h"
volatile int ConvertFinishFlag=0;
volatile char buffer[packLength]={0};
int main(void)
{
char value[packLength]={0};
int m;
m_clockdivide(0);
wirelessinitial();
m_usb_init();
while(!m_usb_isconnected()); // wait for a connection
sei();
m=0;
while(1)
{
if (m_usb_rx_available())
{
value[m]=m_usb_rx_char();
m++;
if (m==packLength-1){
wireless_string(value,8);
value={null,null,null,null,null,null,null,null};
}
}
if (ConvertFinishFlag==1)
{
for (int i=0;i<packLength;i++)
{
if (buffer[i])
{
m_usb_tx_char(buffer[i]);
}
}
ConvertFinishFlag=0;
}
}
}
ISR(INT2_vect )
{
int success;
success = m_rf_read(buffer, packLength);
if ((success==1)&&(buffer[0]!=0))
{
m_green(ON);
ConvertFinishFlag=1;
}else{
m_green(OFF);
}
}