Revision 1625
Got xbee interrupt to work in command mode (API mode 0 off)
Still working on API mode 1 ON
test_xbee.c | ||
---|---|---|
10 | 10 |
* |
11 | 11 |
* |
12 | 12 |
*/ |
13 |
/* |
|
14 |
// test interrupt |
|
15 |
ISR(USART1_RX_vect) { |
|
16 |
WL_DEBUG_PRINT("in interrupt|"); |
|
17 |
char c = UDR1; |
|
18 |
WL_DEBUG_PRINT_HEX(c); |
|
19 |
WL_DEBUG_PRINT("|in interrupt"); |
|
20 |
}*/ |
|
13 | 21 |
|
22 |
//int8_t xbee_putc(uint8_t c) { |
|
23 |
|
|
24 |
// Wait until buffer is clear for sending |
|
25 |
// Then load buffer with your character |
|
26 |
|
|
27 |
|
|
28 |
/*#ifdef FIREFLY |
|
29 |
loop_until_bit_is_set(UCSR0A, UDRE0); |
|
30 |
UDR0 = c; |
|
31 |
#else*/ |
|
32 |
/* loop_until_bit_is_set(UCSR1A, UDRE1); |
|
33 |
UDR1 = c; |
|
34 |
//#endif |
|
35 |
WL_DEBUG_PRINT("xbee_putc:"); |
|
36 |
WL_DEBUG_PRINT_HEX(c); |
|
37 |
WL_DEBUG_PRINT("|\r\n"); |
|
38 |
|
|
39 |
return WL_SUCCESS; |
|
40 |
}*/ |
|
14 | 41 |
|
15 | 42 |
int testxbee(void) { |
16 | 43 |
|
... | ... | |
20 | 47 |
usb_init(); |
21 | 48 |
usb_puts("usb turned on, test starting:\r\n"); |
22 | 49 |
|
50 |
/*UBRR1H = 0x00; // baud rate |
|
51 |
UBRR1L = 103; // baud rate |
|
52 |
UCSR1A |= (1<<U2X1); // double transmit speed |
|
53 |
//Enable receiver and transmitter on USART1 |
|
54 |
UCSR1B |= (1<<RXEN1)|(1<<TXEN1); |
|
55 |
|
|
56 |
// Set frame format: 8data, 1stop bit, asynchronous normal mode |
|
57 |
//UCSR1C |= (1<<UCSZ10) | (1<<UCSZ11); |
|
58 |
|
|
59 |
//UCSR1C |= (1<<UMSEL1) | (1<<UCSZ10) | (1<<UCSZ11); |
|
60 |
//UCSR1C |= (1 << URSEL) | (1 << UCSZ0) | (1 << UCSZ1); |
|
61 |
UCSR1B |= (1<<RXCIE1); // enable receive, transmit (1<<RXCIE) |
|
62 |
WL_DEBUG_PRINT("receive interrupt flag="); |
|
63 |
WL_DEBUG_PRINT_HEX(UCSR1B&(1<<RXCIE1)); |
|
64 |
WL_DEBUG_PRINT("|\r\n"); |
|
65 |
sei(); |
|
66 |
|
|
67 |
|
|
68 |
xbee_putc('+'); |
|
69 |
xbee_putc('+'); |
|
70 |
xbee_putc('+');*/ |
|
71 |
|
|
23 | 72 |
int ret = xbee_init(); |
24 | 73 |
|
25 | 74 |
if (ret != WL_SUCCESS) { |
... | ... | |
30 | 79 |
} else { |
31 | 80 |
usb_puts("xbee_init successful\r\n"); |
32 | 81 |
} |
82 |
|
|
33 | 83 |
|
34 | 84 |
usb_puts("\r\n\n"); |
35 | 85 |
delay_ms(1000); |
... | ... | |
108 | 158 |
}*/ |
109 | 159 |
|
110 | 160 |
// end of tests |
111 |
if (xbee_terminate() != 0) { |
|
161 |
/*if (xbee_terminate() != 0) {
|
|
112 | 162 |
usb_puts("xbee_terminate error\r\n"); |
113 | 163 |
} else { |
114 | 164 |
usb_puts("xbee_terminate success\r\n"); |
115 |
} |
|
165 |
}*/
|
|
116 | 166 |
usb_puts("testxbee done\r\n\r\n"); |
117 | 167 |
|
118 | 168 |
return 0; |
Also available in: Unified diff