Revision 1452

trunk/code/lib/include/libwireless/wl_basic.h (revision 1452)
21 21
#ifndef WL_BASIC_H
22 22
#define WL_BASIC_H
23 23

  
24
#include <wireless.h>
24
#include "wireless.h"
25 25

  
26 26
/** @brief default wireless group for basic sending and receiving packets **/
27 27
#define WL_BASIC_GROUP 8
trunk/code/lib/include/libwireless/xbee.h (revision 1452)
93 93
unsigned int xbee_get_address(void);
94 94
/**@brief Set the com port on a computer, undefined on the robot**/
95 95
void xbee_set_com_port(char* port);
96
/**@brief Reset XBee **/
97
int xbee_reset(void);
96 98

  
97 99
/**@}**/ //end defgroup
98 100

  
trunk/code/lib/include/libdragonfly/dragonfly_lib.h (revision 1452)
75 75
/** @} **/ //end addtogroup
76 76

  
77 77
#include <inttypes.h>
78
#include <stdio.h>
79
#include <stdlib.h>
80 78
#include <avr/io.h>
81 79
#include <avr/interrupt.h>
82 80
#include <util/delay.h>
......
86 84
// missing from the AVR libc distribution.
87 85
#include "atomic.h"
88 86

  
89
#include <analog.h>
90
#include <dio.h>
91
#include <time.h>
92
#include <lcd.h>
93
#include <lights.h>
94
#include <motor.h>
95
#include <serial.h>
96
#include <buzzer.h>
97
#include <rangefinder.h>
98
#include <bom.h>
99
#include <encoders.h>
100
#include <move.h>
101
#include <reset.h>
102
#include <math.h>
103
#include <eeprom.h>
87
#include "analog.h"
88
#include "dio.h"
89
#include "time.h"
90
#include "lcd.h"
91
#include "lights.h"
92
#include "motor.h"
93
#include "serial.h"
94
#include "buzzer.h"
95
#include "rangefinder.h"
96
#include "bom.h"
97
#include "encoders.h"
98
#include "move.h"
99
#include "reset.h"
100
#include "math.h"
101
#include "eeprom.h"
102

  
103
#include <stddef.h>
104 104
#include <stdbool.h>
105 105

  
106 106
/** @brief shortcut for ATOMIC_BLOCK(ATOMIC_RESTORESTATE) **/
trunk/code/lib/include/libdragonfly/bom.h (revision 1452)
68 68
/** @brief Compares all the values in bom_val[] and returns the index to the highest value element. **/
69 69
int bom_get_max(void);
70 70

  
71
/** @brief Computes the weighted average of all the bom readings to estimate the position and distance of another robot. **/
72
int bom_get_max10(int *dist);
73

  
71 74
/** @brief Enables the selected bom leds on a BOM1.5 **/
72 75
void bom_set_leds(int bit_field);
73 76

  
trunk/code/lib/include/libdragonfly/i2c.h (revision 1452)
36 36
#ifndef _I2C_H_
37 37
#define _I2C_H_
38 38

  
39
#include <stddef.h>
40

  
41 39
/** @brief Address of slave receive handler function **/
42 40
typedef void (*fun_srecv_t)(char);
43 41

  
......
48 46
typedef char (*fun_send_t)(void);
49 47

  
50 48
int i2c_init(char addr, fun_mrecv_t master_recv, fun_srecv_t slave_recv, fun_send_t slave_send);
51
int i2c_send(char dest, char* data, size_t bytes);
49
int i2c_send(char dest, char* data, unsigned int bytes);
52 50
int i2c_request(char dest);
53 51

  
54 52
void i2c_packet_rec (char i2c_byte);
trunk/code/lib/include/libdragonfly/eeprom.h (revision 1452)
10 10
 #ifndef _EEPROM_H_
11 11
 #define _EEPROM_H_
12 12
 
13
 #include <bom.h>
14
 
15 13
 #define EEPROM_ROBOT_ID_ADDR 0x10
16 14
 #define EEPROM_BOM_TYPE_ADDR 0x14
17 15
 
trunk/code/projects/test/test_tokenring.c (revision 1452)
25 25
  wl_token_ring_register();
26 26
  wl_token_ring_join(); // join token ring
27 27
  usb_puts("token ring joined\r\n");
28
  int* robotList = (int*)malloc(sizeof(int)*MAX_ROBOTS);
28
  int robotList[sizeof(int)*MAX_ROBOTS];
29 29
  int numRobots = 0;
30 30
  delay_ms(1000);
31 31
  
trunk/code/projects/test/test_rangefinder.c (revision 1452)
26 26
#define ON_DELAY 500	// duration of flashes at beginning and end (in ms)
27 27
#define OFF_DELAY 250	// delay between flashes at beginning and end (in ms)
28 28

  
29
int testrangefinder() {
29
int testrangefinder(void) {
30 30
    int i;  // index
31 31
    int sensor[5] = {IR4, IR3, IR2, IR1, IR5};
32 32
    int color[5] = {RED, ORANGE, YELLOW, GREEN, BLUE};
trunk/code/projects/libwireless/lib/wl_token_ring.c (revision 1452)
35 35
#include <wl_token_ring.h>
36 36

  
37 37
#include <stdlib.h>
38
#include <stdio.h>
39 38

  
40 39
#include <wl_defs.h>
41 40
#include <wireless.h>
......
270 269
		{
271 270
			WL_DEBUG_PRINT("Attempting to join the token ring again.\r\n");
272 271
			//attempt to rejoin with a random delay
272
      //TODO: should we use the constant JOIN_DELAY ?
273 273
			wl_token_ring_join();
274 274
			joinDelay = rand() / (RAND_MAX / JOIN_DELAY) + 1;
275 275
		}
trunk/code/projects/libwireless/lib/wl_basic.c (revision 1452)
7 7
 * @author Christopher Mar, Colony Project, CMU Robotics Club
8 8
 **/
9 9

  
10
#include <wireless.h>
11 10
#include "wl_basic.h"
12 11

  
13 12
/**
trunk/code/projects/libwireless/lib/xbee.c (revision 1452)
42 42
#include <pthread.h>
43 43
#include <errno.h>
44 44
#include <termios.h>
45
#include <stdio.h>
46
#include <stdlib.h>
45 47

  
46 48
#else
47 49

  
......
51 53

  
52 54
#endif
53 55

  
54
#include <stdio.h>
55
#include <stdlib.h>
56 56
#include <string.h>
57 57

  
58 58
#define XBEE_FRAME_START 0x7E
trunk/code/projects/libwireless/lib/wl_error_group.c (revision 1452)
33 33
 **/
34 34

  
35 35
#include "wl_error_group.h"
36
#include "wireless.h"
37
#include "wl_defs.h"
36 38

  
37
#include <wireless.h>
38
#include <wl_defs.h>
39
#include <stdio.h>
40 39
#include <string.h>
41 40

  
42 41

  
42

  
43 43
void wl_error_response_receive(int frame, int received);
44 44
void wl_error_handle_receive(char type, int source, unsigned char* packet,
45 45
							int length);
trunk/code/projects/libwireless/lib/sensor_matrix.c (revision 1452)
32 32
 * @author Brian Coltin, Colony Project, CMU Robotics Club
33 33
 **/
34 34

  
35
#include <stdlib.h>
36
#include <stdio.h>
37
#include <wl_defs.h>
38

  
35
#include "wl_defs.h"
39 36
#include "sensor_matrix.h"
40 37

  
41 38
// the global sensor matrix
trunk/code/projects/libwireless/lib/wireless.c (revision 1452)
34 34

  
35 35
#include "wireless.h"
36 36
#include "xbee.h"
37
#include <stdlib.h>
37

  
38
#include <stddef.h>
39

  
40
#ifdef WL_DEBUG
38 41
#include <stdio.h>
42
#endif
39 43

  
40 44
#include "wl_defs.h"
41 45

  
......
461 465
	else
462 466
	{
463 467
		WL_DEBUG_PRINT("Unexpected packet received from XBee.\r\n");
464
		printf("0x%2X\n", wl_buf[0]);
465
		printf("%c%c%d\n", wl_buf[2], wl_buf[3], wl_buf[4]);
468
		#ifdef WL_DEBUG
469
      #ifndef ROBOT
470
      printf("0x%2X\n", wl_buf[0]);
471
      printf("%c%c%d\n", wl_buf[2], wl_buf[3], wl_buf[4]);
472
      #endif
473
    #endif
466 474
	}
467 475
}
468 476

  
trunk/code/projects/libdragonfly/dragonfly_lib.c (revision 1452)
33 33
 * @author Colony Project, CMU Robotics Club
34 34
 **/
35 35

  
36
#include <dragonfly_lib.h>
36
#include "dragonfly_lib.h"
37 37

  
38 38
/* init_dragonfly - Initializes functions based on configuration parameters
39 39
   examples:
trunk/code/projects/libdragonfly/i2c.c (revision 1452)
138 138
 *
139 139
 * @return zero for success, nonzero for failure
140 140
 **/
141
int i2c_send(char dest, char *data, size_t bytes) {
141
int i2c_send(char dest, char *data, unsigned int bytes) {
142 142
    int i;
143 143

  
144 144
    /* adding data to be sent to ring buffers is not atomic,
trunk/code/projects/libdragonfly/serial.c (revision 1452)
34 34
 **/
35 35

  
36 36
#include <avr/io.h>
37
#include <stdio.h>
38 37
#include "serial.h"
39 38

  
39
#ifdef USE_STDIO
40

  
41
#include <stdio.h>
42

  
40 43
/**
41 44
 * For use with fprintf() and related stdio functions
42 45
 **/
......
47 50
 **/
48 51
FILE *xbee_fd;
49 52

  
53
#endif
54

  
50 55
/**
51 56
 * Initializes communication over the USB serial port.
52 57
 * This must be called before any other usb function
trunk/code/projects/libdragonfly/dragonfly_lib.h (revision 1452)
75 75
/** @} **/ //end addtogroup
76 76

  
77 77
#include <inttypes.h>
78
#include <stdio.h>
79
#include <stdlib.h>
80 78
#include <avr/io.h>
81 79
#include <avr/interrupt.h>
82 80
#include <util/delay.h>
......
86 84
// missing from the AVR libc distribution.
87 85
#include "atomic.h"
88 86

  
89
#include <analog.h>
90
#include <dio.h>
91
#include <time.h>
92
#include <lcd.h>
93
#include <lights.h>
94
#include <motor.h>
95
#include <serial.h>
96
#include <buzzer.h>
97
#include <rangefinder.h>
98
#include <bom.h>
99
#include <encoders.h>
100
#include <move.h>
101
#include <reset.h>
102
#include <math.h>
103
#include <eeprom.h>
87
#include "analog.h"
88
#include "dio.h"
89
#include "time.h"
90
#include "lcd.h"
91
#include "lights.h"
92
#include "motor.h"
93
#include "serial.h"
94
#include "buzzer.h"
95
#include "rangefinder.h"
96
#include "bom.h"
97
#include "encoders.h"
98
#include "move.h"
99
#include "reset.h"
100
#include "math.h"
101
#include "eeprom.h"
102

  
103
#include <stddef.h>
104 104
#include <stdbool.h>
105 105

  
106 106
/** @brief shortcut for ATOMIC_BLOCK(ATOMIC_RESTORESTATE) **/
trunk/code/projects/libdragonfly/buzzer.c (revision 1452)
36 36
 **/
37 37

  
38 38
#include <avr/io.h>
39
#include <buzzer.h>
40
#include <time.h>
39
#include "buzzer.h"
40
#include "time.h"
41 41

  
42 42
/**
43 43
 * @defgroup buzzer Buzzer
trunk/code/projects/libdragonfly/i2c.h (revision 1452)
36 36
#ifndef _I2C_H_
37 37
#define _I2C_H_
38 38

  
39
#include <stddef.h>
40

  
41 39
/** @brief Address of slave receive handler function **/
42 40
typedef void (*fun_srecv_t)(char);
43 41

  
......
48 46
typedef char (*fun_send_t)(void);
49 47

  
50 48
int i2c_init(char addr, fun_mrecv_t master_recv, fun_srecv_t slave_recv, fun_send_t slave_send);
51
int i2c_send(char dest, char* data, size_t bytes);
49
int i2c_send(char dest, char* data, unsigned int bytes);
52 50
int i2c_request(char dest);
53 51

  
54 52
void i2c_packet_rec (char i2c_byte);
trunk/code/projects/libdragonfly/spi.c (revision 1452)
6 6
 **/
7 7

  
8 8
#include <avr/interrupt.h>
9
#include <dragonfly_lib.h>
10 9
#include "spi.h"
11 10

  
12 11

  
trunk/code/projects/libdragonfly/eeprom.h (revision 1452)
10 10
 #ifndef _EEPROM_H_
11 11
 #define _EEPROM_H_
12 12
 
13
 #include <bom.h>
14
 
15 13
 #define EEPROM_ROBOT_ID_ADDR 0x10
16 14
 #define EEPROM_BOM_TYPE_ADDR 0x14
17 15
 
trunk/code/projects/libdragonfly/time.c (revision 1452)
58 58
*/
59 59
#include <avr/interrupt.h>
60 60
#include <util/delay.h>
61
#include <time.h>
62
#include <serial.h>
61
#include "time.h"
62

  
63 63

  
64 64
/* Calculate how many cycles to delay for to get 1 ms. Based on F_CPU which should be defined by the makefile */
65 65
#ifdef F_CPU
trunk/code/projects/libdragonfly/encoders.c (revision 1452)
1 1
#include "encoders.h"
2 2
#include "spi.h"
3
#include "dragonfly_lib.h"
4 3
#include "ring_buffer.h"
4
#include <avr/io.h>
5 5

  
6 6
unsigned int left_data_buf;
7 7
unsigned int right_data_buf;
trunk/code/projects/libdragonfly/lcd.c (revision 1452)
33 33
 * @author Colony Project, CMU Robotics Club
34 34
 **/
35 35
#include <avr/io.h>
36
#include <lcd.h>
37
#include <time.h>
36
#include "lcd.h"
37
#include "time.h"
38 38

  
39 39
//LCD defines
40 40
#define RST _BV(4)  // pd4 (GPIO)
trunk/code/projects/libdragonfly/odometry.c (revision 1452)
1 1
#include "odometry.h"
2
#include <encoders.h>
2
#include "encoders.h"
3 3
#include <math.h>
4 4
#include <avr/interrupt.h>
5
#include <dragonfly_lib.h>
5
#include "time.h"
6
#include "serial.h"
6 7

  
7 8
long lround(double d);
8 9

  
......
79 80
	//Angle swept through in a time step CCW-
80 81
	double theta, rl, dc;
81 82
	long dr,dl;
82
	char buf[100];
83 83
	
84 84
	//Get the change in wheel positions
85 85
	{	
......
111 111
		diff_x += lround(dl*cos(angle)/1000.0); //mm
112 112
		diff_y += lround(dl*sin(angle)/1000.0); //mm
113 113
		velocity = lround((dl * 1000.0)/(ODOMETRY_CLK*TIME_SCALE)); //um / ms = mm/s
114
		sprintf(buf,"dc: %ld, velocity: %ld\r\n mm/s",dl,velocity);
115
		usb_puts(buf);
114
    usb_puts("dc: ");
115
    usb_puti(dl);
116
    usb_puts("um, velocity: ");
117
    usb_puti(velocity);
118
		usb_puts("\r\n mm/s");
116 119
		return;
117 120
	}
118 121
	
......
123 126
	//Distance the center has traveled.
124 127
	dc = (theta * (rl - ROBOT_WIDTH_UM)) / 2.0; //um
125 128
	velocity = lround( dc * 1000 /(ODOMETRY_CLK*TIME_SCALE));
126
	sprintf(buf,"dc: %lfum, velocity: %ld\r\n mm/s",dc,velocity);
127
	usb_puts(buf);
129
	usb_puts("dc: ");
130
  usb_puti(dl);
131
  usb_puts("um, velocity: ");
132
  usb_puti(velocity);
133
  usb_puts("\r\n mm/s");
128 134
	
129 135
	//angle is necessarily CCW+, so subtract.
130 136
	angle -= ANGLE_SCALE * theta; 
trunk/code/projects/libdragonfly/move.c (revision 1452)
33 33
 * @author Colony Project, CMU Robotics Club
34 34
 **/
35 35

  
36
#include "dragonfly_lib.h"
37

  
38 36
#include "move.h"
37
#include "motor.h"
39 38
#include "rangefinder.h"
40 39

  
41 40

  
trunk/code/projects/libdragonfly/dio.c (revision 1452)
34 34
 **/
35 35

  
36 36
#include <avr/interrupt.h>
37
#include <dio.h>
38
#include <time.h>
39
#include <lights.h>
37
#include "dio.h"
38
#include "time.h"
39
#include "lights.h"
40 40

  
41 41
/**
42 42
 * @defgroup dio Digital Input / Output
trunk/code/projects/libdragonfly/bom.c (revision 1452)
33 33
 * @author Colony Project, CMU Robotics Club
34 34
 **/
35 35

  
36
#include <dragonfly_lib.h>
37 36
#include "bom.h"
38 37
#include "dio.h"
39 38
#include "serial.h"
......
114 113
 **/
115 114

  
116 115
static unsigned int bom_val[NUM_BOM_LEDS];
117
static volatile char bom_type = BOM;
116
static volatile char bom_type = BOM10;
118 117
static int select_pins[4];
119 118
static int analog_pin;
120 119

  
trunk/code/projects/libdragonfly/reset.c (revision 1452)
34 34
 **/
35 35
#include <avr/interrupt.h>
36 36
#include <util/delay.h>
37
#include <reset.h>
37
#include "reset.h"
38 38

  
39 39
/**
40 40
 * @defgroup reset Reset
trunk/code/projects/libdragonfly/rangefinder.c (revision 1452)
58 58

  
59 59
*/
60 60

  
61
#include "dragonfly_lib.h"
62 61
#include "rangefinder.h"
62
#include "analog.h"
63
#include "dio.h"
63 64

  
64 65
/*
65 66
  read_distance returns the 8-bit reading from the rangefinder
trunk/code/projects/libdragonfly/lights.c (revision 1452)
71 71
 * When code is changed, the performance measurements above should be redone.
72 72
 */
73 73

  
74

  
75

  
74
#include "dragonfly_lib.h"
76 75
#include "lights.h"
77 76

  
78
#include <avr/interrupt.h>
79

  
80
#include "dragonfly_lib.h"
81

  
82

  
83 77
// ***************
84 78
// ** Constants **
85 79
// ***************

Also available in: Unified diff