Project

General

Profile

Revision 86

Updated wireless library, fixing bug and now works for a firefly if FIREFLY is defined.

View differences:

trunk/code/lib/src/libwireless/wl_token_ring.c
9 9
#include <queue.h>
10 10

  
11 11
#ifdef ROBOT
12
#ifndef FIREFLY
12 13
#include <bom.h>
14
#endif
13 15
#include <time.h>
14 16
#endif
15 17

  
......
73 75
//current robot to check in the iterator
74 76
int iteratorCount = 0;
75 77

  
78
void do_nothing(void) {}
79
int get_nothing(void) {return -1;}
80

  
76 81
#ifdef ROBOT
82
#ifndef FIREFLY
77 83
void (*bom_on_function) (void) = bom_on;
78 84
void (*bom_off_function) (void) = bom_off;
79 85
int (*get_max_bom_function) (void) = get_max_bom;
80 86
#else
81
void do_nothing(void) {}
82
int get_nothing(void) {return -1;}
83 87
void (*bom_on_function) (void) = do_nothing;
84 88
void (*bom_off_function) (void) = do_nothing;
85 89
int (*get_max_bom_function) (void) = get_nothing;
86 90
#endif
91
#else
92
void (*bom_on_function) (void) = do_nothing;
93
void (*bom_off_function) (void) = do_nothing;
94
int (*get_max_bom_function) (void) = get_nothing;
95
#endif
87 96

  
88 97
PacketGroupHandler wl_token_ring_handler =
89 98
		{WL_TOKEN_RING_GROUP, wl_token_ring_timeout_handler,
......
736 745
 **/
737 746
void wl_token_iterator_begin(void)
738 747
{
739
	int i;
748
	int i = 0;
740 749
	iteratorCount = 0;
741 750
	while (!sensor_matrix_get_in_ring(sensorMatrix, i) &&
742 751
			i < sensor_matrix_get_size(sensorMatrix))
trunk/code/lib/src/libwireless/xbee.c
92 92
 * Interrupt for the robot. Adds bytes received from the xbee
93 93
 * to the queue.
94 94
 **/
95
#ifndef FIREFLY
95 96
ISR(USART1_RX_vect)
96 97
{
97 98
	char c = UDR1;
98 99
	queue_add(xbee_queue, (void*)(int)c);
99 100
}
101
#else
102
SIGNAL(SIG_USART0_RECV)
103
{
104
	char c = UDR0;
105
	queue_add(xbee_queue, (void*)(int)c);
106
}
107
#endif
100 108

  
101 109
#else
102 110

  
......
129 137
	#ifdef ROBOT
130 138

  
131 139
	//enable the receiving interrupt
140
	#ifdef FIREFLY
141
	UCSR0B |= _BV(RXCIE) | _BV(RXEN);
142
	#else
132 143
	UCSR1B |= _BV(RXCIE);
144
	#endif
133 145
	sei();
134 146
	#else
135 147
	xbee_stream = open("/dev/ttyUSB0", O_RDWR);
trunk/code/lib/src/libwireless/wireless.c
10 10
#include <signal.h>
11 11
#else
12 12
#include <time.h>
13
#ifndef FIREFLY
13 14
#include <bom.h>
14 15
#endif
16
#endif
15 17

  
16 18
/*Function Prototypes*/
17 19

  
......
65 67
	
66 68
	//begin timeout timer
67 69
	#ifdef ROBOT
70
	#ifdef FIREFLY
71
	rtc_init(PRESCALE_DIV_128, 32, &wl_do_timeout);
72
	#else
68 73
	rtc_init(HALF_SECOND, &wl_do_timeout); 
74
	#endif
69 75
	#else
70 76
	//create a timer to trigger every half second
71 77
	struct sigevent evp;
trunk/code/projects/libwireless/lib/wl_token_ring.c
9 9
#include <queue.h>
10 10

  
11 11
#ifdef ROBOT
12
#ifndef FIREFLY
12 13
#include <bom.h>
14
#endif
13 15
#include <time.h>
14 16
#endif
15 17

  
......
73 75
//current robot to check in the iterator
74 76
int iteratorCount = 0;
75 77

  
78
void do_nothing(void) {}
79
int get_nothing(void) {return -1;}
80

  
76 81
#ifdef ROBOT
82
#ifndef FIREFLY
77 83
void (*bom_on_function) (void) = bom_on;
78 84
void (*bom_off_function) (void) = bom_off;
79 85
int (*get_max_bom_function) (void) = get_max_bom;
80 86
#else
81
void do_nothing(void) {}
82
int get_nothing(void) {return -1;}
83 87
void (*bom_on_function) (void) = do_nothing;
84 88
void (*bom_off_function) (void) = do_nothing;
85 89
int (*get_max_bom_function) (void) = get_nothing;
86 90
#endif
91
#else
92
void (*bom_on_function) (void) = do_nothing;
93
void (*bom_off_function) (void) = do_nothing;
94
int (*get_max_bom_function) (void) = get_nothing;
95
#endif
87 96

  
88 97
PacketGroupHandler wl_token_ring_handler =
89 98
		{WL_TOKEN_RING_GROUP, wl_token_ring_timeout_handler,
......
736 745
 **/
737 746
void wl_token_iterator_begin(void)
738 747
{
739
	int i;
748
	int i = 0;
740 749
	iteratorCount = 0;
741 750
	while (!sensor_matrix_get_in_ring(sensorMatrix, i) &&
742 751
			i < sensor_matrix_get_size(sensorMatrix))
trunk/code/projects/libwireless/lib/xbee.c
92 92
 * Interrupt for the robot. Adds bytes received from the xbee
93 93
 * to the queue.
94 94
 **/
95
#ifndef FIREFLY
95 96
ISR(USART1_RX_vect)
96 97
{
97 98
	char c = UDR1;
98 99
	queue_add(xbee_queue, (void*)(int)c);
99 100
}
101
#else
102
SIGNAL(SIG_USART0_RECV)
103
{
104
	char c = UDR0;
105
	queue_add(xbee_queue, (void*)(int)c);
106
}
107
#endif
100 108

  
101 109
#else
102 110

  
......
129 137
	#ifdef ROBOT
130 138

  
131 139
	//enable the receiving interrupt
140
	#ifdef FIREFLY
141
	UCSR0B |= _BV(RXCIE) | _BV(RXEN);
142
	#else
132 143
	UCSR1B |= _BV(RXCIE);
144
	#endif
133 145
	sei();
134 146
	#else
135 147
	xbee_stream = open("/dev/ttyUSB0", O_RDWR);
trunk/code/projects/libwireless/lib/wireless.c
10 10
#include <signal.h>
11 11
#else
12 12
#include <time.h>
13
#ifndef FIREFLY
13 14
#include <bom.h>
14 15
#endif
16
#endif
15 17

  
16 18
/*Function Prototypes*/
17 19

  
......
65 67
	
66 68
	//begin timeout timer
67 69
	#ifdef ROBOT
70
	#ifdef FIREFLY
71
	rtc_init(PRESCALE_DIV_128, 32, &wl_do_timeout);
72
	#else
68 73
	rtc_init(HALF_SECOND, &wl_do_timeout); 
74
	#endif
69 75
	#else
70 76
	//create a timer to trigger every half second
71 77
	struct sigevent evp;

Also available in: Unified diff