Revision 1462
moved dragonfly definitions to separate header file
trunk/code/lib/include/libdragonfly/spi.h | ||
---|---|---|
12 | 12 |
#ifndef __SPI_H__ |
13 | 13 |
#define __SPI_H__ |
14 | 14 |
|
15 |
#include<dragonfly_lib.h> |
|
16 |
|
|
17 | 15 |
#define DOUBLE_SCK 1 |
18 | 16 |
#define SPR0_BIT 1 |
19 | 17 |
|
... | ... | |
25 | 23 |
#define SS _BV(PB0) |
26 | 24 |
#define SCLK _BV(PB1) |
27 | 25 |
|
28 |
typedef void (*spi_fun_recv_t)(char);
|
|
26 |
typedef int (*spi_fun_recv_t)(char);
|
|
29 | 27 |
typedef void (*spi_fun_recv_complete_t)(void); |
30 | 28 |
|
31 | 29 |
/** |
trunk/code/lib/include/libdragonfly/time.h | ||
---|---|---|
37 | 37 |
#ifndef _TIME_H_ |
38 | 38 |
#define _TIME_H_ |
39 | 39 |
|
40 |
#include <dragonfly_lib.h> |
|
41 | 40 |
|
42 | 41 |
/* Predefined times for prescale_opt in time.c. |
43 | 42 |
To make you own, know that a pulse is 1/16th of a second. You cannot get less than this. To get more, you need |
trunk/code/lib/include/libdragonfly/motor.h | ||
---|---|---|
38 | 38 |
#ifndef _MOTOR_H |
39 | 39 |
#define _MOTOR_H |
40 | 40 |
|
41 |
#include <dragonfly_lib.h> |
|
42 | 41 |
#include <avr/io.h> |
42 |
|
|
43 | 43 |
/** |
44 | 44 |
* @addtogroup motors |
45 | 45 |
* @{ |
trunk/code/lib/include/libdragonfly/encoders.h | ||
---|---|---|
1 | 1 |
/** |
2 |
* Copyright (c) 2007 Colony Project |
|
2 | 3 |
* |
4 |
* Permission is hereby granted, free of charge, to any person |
|
5 |
* obtaining a copy of this software and associated documentation |
|
6 |
* files (the "Software"), to deal in the Software without |
|
7 |
* restriction, including without limitation the rights to use, |
|
8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9 |
* copies of the Software, and to permit persons to whom the |
|
10 |
* Software is furnished to do so, subject to the following |
|
11 |
* conditions: |
|
12 |
* |
|
13 |
* The above copyright notice and this permission notice shall be |
|
14 |
* included in all copies or substantial portions of the Software. |
|
15 |
* |
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
23 |
* OTHER DEALINGS IN THE SOFTWARE. |
|
24 |
**/ |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
3 | 28 |
* @file encoders.h |
4 | 29 |
* @brief Contains functions for reading encoder values. |
5 | 30 |
* |
trunk/code/lib/include/libdragonfly/dragonfly_lib.h | ||
---|---|---|
41 | 41 |
* @{ |
42 | 42 |
**/ |
43 | 43 |
|
44 |
//return value definitions |
|
45 |
#define ERROR_INIT_FAILED 1 |
|
46 |
#define ERROR_INIT_ALREADY_INITD 2 |
|
47 |
|
|
48 |
#define ERROR_LIBRARY_NOT_INITD 3 |
|
49 |
|
|
50 |
// Configuration definitions |
|
51 |
/** @brief Initialize analog **/ |
|
52 |
#define ANALOG 0x01 |
|
53 |
/** @brief Initialize serial communications **/ |
|
54 |
#define SERIAL 0x02 |
|
55 |
/** @brief Initialize USB communications **/ |
|
56 |
#define USB 0x02 |
|
57 |
/** @brief Initialize communications **/ |
|
58 |
#define COMM 0x02 |
|
59 |
/** @brief Initialize the orb **/ |
|
60 |
#define ORB 0x04 |
|
61 |
/** @brief Initialize the motors **/ |
|
62 |
#define MOTORS 0x08 |
|
63 |
/** @brief Initialize I2C **/ |
|
64 |
#define I2C 0x20 |
|
65 |
/** @brief Initialize the buzzer **/ |
|
66 |
#define BUZZER 0x40 |
|
67 |
/** @brief Initialize the LCD screen **/ |
|
68 |
#define LCD 0x80 |
|
69 |
/** @brief Initialize the rangefinders **/ |
|
70 |
#define RANGE 0x0100 |
|
71 |
/** @brief Initialize the BOM **/ |
|
72 |
#define BOM 0x0200 |
|
73 |
/** @brief Initilize encoders **/ |
|
74 |
#define ENCODERS 0x400 |
|
75 |
/** @brief Initialize everything **/ |
|
76 |
#define ALL_ON 0x07FF |
|
77 |
|
|
78 | 44 |
/** @brief Initialize the board **/ |
79 | 45 |
void dragonfly_init(int config); |
80 | 46 |
|
... | ... | |
90 | 56 |
// missing from the AVR libc distribution. |
91 | 57 |
#include "atomic.h" |
92 | 58 |
|
59 |
#include "dragonfly_defs.h" |
|
93 | 60 |
#include "analog.h" |
94 | 61 |
#include "dio.h" |
95 | 62 |
#include "time.h" |
... | ... | |
109 | 76 |
#include <stddef.h> |
110 | 77 |
#include <stdbool.h> |
111 | 78 |
|
112 |
/** @brief shortcut for ATOMIC_BLOCK(ATOMIC_RESTORESTATE) **/ |
|
113 |
#define SYNC ATOMIC_BLOCK(ATOMIC_RESTORESTATE) |
|
114 |
|
|
115 |
/** @brief atomically grab a lock if it is free, return otherwise **/ |
|
116 |
#define REQUIRE_LOCK_OR_RETURN(LOCK) do { SYNC { if (LOCK) return; LOCK=1; } } while (0) |
|
117 |
|
|
118 |
/** @brief atomically release a lock **/ |
|
119 |
#define RELEASE_LOCK(LOCK) do { LOCK=0; } while (0) |
|
120 |
|
|
121 |
|
|
122 |
|
|
123 | 79 |
#endif |
124 | 80 |
|
trunk/code/lib/include/libdragonfly/serial.h | ||
---|---|---|
68 | 68 |
#ifndef _SERIAL_H |
69 | 69 |
#define _SERIAL_H |
70 | 70 |
|
71 |
#include <dragonfly_lib.h> |
|
72 | 71 |
#include <inttypes.h> |
73 | 72 |
#include <avr/pgmspace.h> |
74 | 73 |
|
trunk/code/lib/include/libdragonfly/rangefinder.h | ||
---|---|---|
37 | 37 |
#ifndef _RANGEFINDER_H_ |
38 | 38 |
#define _RANGEFINDER_H_ |
39 | 39 |
|
40 |
#include <dragonfly_lib.h> |
|
41 |
|
|
42 | 40 |
/** |
43 | 41 |
* @addtogroup rangefinder |
44 | 42 |
* @{ |
trunk/code/lib/include/libdragonfly/dragonfly_defs.h | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (c) 2007 Colony Project |
|
3 |
* |
|
4 |
* Permission is hereby granted, free of charge, to any person |
|
5 |
* obtaining a copy of this software and associated documentation |
|
6 |
* files (the "Software"), to deal in the Software without |
|
7 |
* restriction, including without limitation the rights to use, |
|
8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9 |
* copies of the Software, and to permit persons to whom the |
|
10 |
* Software is furnished to do so, subject to the following |
|
11 |
* conditions: |
|
12 |
* |
|
13 |
* The above copyright notice and this permission notice shall be |
|
14 |
* included in all copies or substantial portions of the Software. |
|
15 |
* |
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
23 |
* OTHER DEALINGS IN THE SOFTWARE. |
|
24 |
**/ |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* @file dragonfly_def.h |
|
29 |
* @brief Contains definitions for dragonfly library |
|
30 |
* |
|
31 |
* Should be included in all dragonfly library source files. |
|
32 |
* Does not need to be included by user programs. |
|
33 |
* |
|
34 |
* @author Colony Project, CMU Robotics Club |
|
35 |
**/ |
|
36 |
|
|
37 |
#ifndef _DRAGONFLY_DEFS_H_ |
|
38 |
#define _DRAGONFLY_DEFS_H_ |
|
39 |
|
|
40 |
/** |
|
41 |
* @addtogroup dragonfly |
|
42 |
* @{ |
|
43 |
**/ |
|
44 |
|
|
45 |
//return value definitions |
|
46 |
/** @brief Error code for init failure **/ |
|
47 |
#define ERROR_INIT_FAILED 1 |
|
48 |
/** @brief Error code for duplicate init calls **/ |
|
49 |
#define ERROR_INIT_ALREADY_INITD 2 |
|
50 |
/** @brief Error code for not calling init **/ |
|
51 |
#define ERROR_LIBRARY_NOT_INITD 3 |
|
52 |
|
|
53 |
// Configuration definitions |
|
54 |
/** @brief Initialize analog **/ |
|
55 |
#define ANALOG 0x01 |
|
56 |
/** @brief Initialize serial communications **/ |
|
57 |
#define SERIAL 0x02 |
|
58 |
/** @brief Initialize USB communications **/ |
|
59 |
#define USB 0x02 |
|
60 |
/** @brief Initialize communications **/ |
|
61 |
#define COMM 0x02 |
|
62 |
/** @brief Initialize the orb **/ |
|
63 |
#define ORB 0x04 |
|
64 |
/** @brief Initialize the motors **/ |
|
65 |
#define MOTORS 0x08 |
|
66 |
/** @brief Initialize I2C **/ |
|
67 |
#define I2C 0x20 |
|
68 |
/** @brief Initialize the buzzer **/ |
|
69 |
#define BUZZER 0x40 |
|
70 |
/** @brief Initialize the LCD screen **/ |
|
71 |
#define LCD 0x80 |
|
72 |
/** @brief Initialize the rangefinders **/ |
|
73 |
#define RANGE 0x0100 |
|
74 |
/** @brief Initialize the BOM **/ |
|
75 |
#define BOM 0x0200 |
|
76 |
/** @brief Initilize encoders **/ |
|
77 |
#define ENCODERS 0x400 |
|
78 |
/** @brief Initialize everything **/ |
|
79 |
#define ALL_ON 0x07FF |
|
80 |
|
|
81 |
/** @} **/ //end addtogroup |
|
82 |
|
|
83 |
/** @brief shortcut for ATOMIC_BLOCK(ATOMIC_RESTORESTATE) **/ |
|
84 |
#define SYNC ATOMIC_BLOCK(ATOMIC_RESTORESTATE) |
|
85 |
|
|
86 |
/** @brief atomically grab a lock if it is free, return otherwise **/ |
|
87 |
#define REQUIRE_LOCK_OR_RETURN(LOCK) do { SYNC { if (LOCK) return; LOCK=1; } } while (0) |
|
88 |
|
|
89 |
/** @brief atomically release a lock **/ |
|
90 |
#define RELEASE_LOCK(LOCK) do { LOCK=0; } while (0) |
|
91 |
|
|
92 |
|
|
93 |
#endif |
trunk/code/projects/test/main.c | ||
---|---|---|
3 | 3 |
#define RUN_TEST(f) extern int f(void); f(); |
4 | 4 |
|
5 | 5 |
int main(void) { |
6 |
RUN_TEST(testinits); |
|
6 |
//RUN_TEST(testinits);
|
|
7 | 7 |
|
8 | 8 |
dragonfly_init(ALL_ON); |
9 | 9 |
|
trunk/code/projects/libdragonfly/motor.c | ||
---|---|---|
34 | 34 |
* Much of this is taken from FWR's library, author: Tom Lauwers |
35 | 35 |
**/ |
36 | 36 |
|
37 |
#include "dragonfly_defs.h" |
|
37 | 38 |
#include "motor.h" |
38 | 39 |
|
39 | 40 |
/** |
trunk/code/projects/libdragonfly/motor.h | ||
---|---|---|
38 | 38 |
#ifndef _MOTOR_H |
39 | 39 |
#define _MOTOR_H |
40 | 40 |
|
41 |
#include <dragonfly_lib.h> |
|
42 | 41 |
#include <avr/io.h> |
42 |
|
|
43 | 43 |
/** |
44 | 44 |
* @addtogroup motors |
45 | 45 |
* @{ |
trunk/code/projects/libdragonfly/serial.c | ||
---|---|---|
34 | 34 |
**/ |
35 | 35 |
|
36 | 36 |
#include <avr/io.h> |
37 |
|
|
38 |
#include "dragonfly_defs.h" |
|
37 | 39 |
#include "serial.h" |
38 | 40 |
|
39 | 41 |
unsigned char usb_initd=0; |
trunk/code/projects/libdragonfly/dragonfly_lib.h | ||
---|---|---|
41 | 41 |
* @{ |
42 | 42 |
**/ |
43 | 43 |
|
44 |
//return value definitions |
|
45 |
#define ERROR_INIT_FAILED 1 |
|
46 |
#define ERROR_INIT_ALREADY_INITD 2 |
|
47 |
|
|
48 |
#define ERROR_LIBRARY_NOT_INITD 3 |
|
49 |
|
|
50 |
// Configuration definitions |
|
51 |
/** @brief Initialize analog **/ |
|
52 |
#define ANALOG 0x01 |
|
53 |
/** @brief Initialize serial communications **/ |
|
54 |
#define SERIAL 0x02 |
|
55 |
/** @brief Initialize USB communications **/ |
|
56 |
#define USB 0x02 |
|
57 |
/** @brief Initialize communications **/ |
|
58 |
#define COMM 0x02 |
|
59 |
/** @brief Initialize the orb **/ |
|
60 |
#define ORB 0x04 |
|
61 |
/** @brief Initialize the motors **/ |
|
62 |
#define MOTORS 0x08 |
|
63 |
/** @brief Initialize I2C **/ |
|
64 |
#define I2C 0x20 |
|
65 |
/** @brief Initialize the buzzer **/ |
|
66 |
#define BUZZER 0x40 |
|
67 |
/** @brief Initialize the LCD screen **/ |
|
68 |
#define LCD 0x80 |
|
69 |
/** @brief Initialize the rangefinders **/ |
|
70 |
#define RANGE 0x0100 |
|
71 |
/** @brief Initialize the BOM **/ |
|
72 |
#define BOM 0x0200 |
|
73 |
/** @brief Initilize encoders **/ |
|
74 |
#define ENCODERS 0x400 |
|
75 |
/** @brief Initialize everything **/ |
|
76 |
#define ALL_ON 0x07FF |
|
77 |
|
|
78 | 44 |
/** @brief Initialize the board **/ |
79 | 45 |
void dragonfly_init(int config); |
80 | 46 |
|
... | ... | |
90 | 56 |
// missing from the AVR libc distribution. |
91 | 57 |
#include "atomic.h" |
92 | 58 |
|
59 |
#include "dragonfly_defs.h" |
|
93 | 60 |
#include "analog.h" |
94 | 61 |
#include "dio.h" |
95 | 62 |
#include "time.h" |
... | ... | |
109 | 76 |
#include <stddef.h> |
110 | 77 |
#include <stdbool.h> |
111 | 78 |
|
112 |
/** @brief shortcut for ATOMIC_BLOCK(ATOMIC_RESTORESTATE) **/ |
|
113 |
#define SYNC ATOMIC_BLOCK(ATOMIC_RESTORESTATE) |
|
114 |
|
|
115 |
/** @brief atomically grab a lock if it is free, return otherwise **/ |
|
116 |
#define REQUIRE_LOCK_OR_RETURN(LOCK) do { SYNC { if (LOCK) return; LOCK=1; } } while (0) |
|
117 |
|
|
118 |
/** @brief atomically release a lock **/ |
|
119 |
#define RELEASE_LOCK(LOCK) do { LOCK=0; } while (0) |
|
120 |
|
|
121 |
|
|
122 |
|
|
123 | 79 |
#endif |
124 | 80 |
|
trunk/code/projects/libdragonfly/serial.h | ||
---|---|---|
68 | 68 |
#ifndef _SERIAL_H |
69 | 69 |
#define _SERIAL_H |
70 | 70 |
|
71 |
#include <dragonfly_lib.h> |
|
72 | 71 |
#include <inttypes.h> |
73 | 72 |
#include <avr/pgmspace.h> |
74 | 73 |
|
trunk/code/projects/libdragonfly/spi.c | ||
---|---|---|
6 | 6 |
**/ |
7 | 7 |
|
8 | 8 |
#include <avr/interrupt.h> |
9 |
|
|
10 |
#include "dragonfly_defs.h" |
|
9 | 11 |
#include "spi.h" |
10 | 12 |
|
11 | 13 |
unsigned char spi_initd=0; |
trunk/code/projects/libdragonfly/time.c | ||
---|---|---|
58 | 58 |
*/ |
59 | 59 |
#include <avr/interrupt.h> |
60 | 60 |
#include <util/delay.h> |
61 |
|
|
62 |
#include "dragonfly_defs.h" |
|
61 | 63 |
#include "time.h" |
62 | 64 |
|
63 | 65 |
|
trunk/code/projects/libdragonfly/spi.h | ||
---|---|---|
12 | 12 |
#ifndef __SPI_H__ |
13 | 13 |
#define __SPI_H__ |
14 | 14 |
|
15 |
#include<dragonfly_lib.h> |
|
16 |
|
|
17 | 15 |
#define DOUBLE_SCK 1 |
18 | 16 |
#define SPR0_BIT 1 |
19 | 17 |
|
... | ... | |
25 | 23 |
#define SS _BV(PB0) |
26 | 24 |
#define SCLK _BV(PB1) |
27 | 25 |
|
28 |
typedef void (*spi_fun_recv_t)(char);
|
|
26 |
typedef int (*spi_fun_recv_t)(char);
|
|
29 | 27 |
typedef void (*spi_fun_recv_complete_t)(void); |
30 | 28 |
|
31 | 29 |
/** |
trunk/code/projects/libdragonfly/analog.c | ||
---|---|---|
36 | 36 |
|
37 | 37 |
#include <util/delay.h> |
38 | 38 |
#include <avr/interrupt.h> |
39 |
|
|
40 |
|
|
41 |
#include "dragonfly_defs.h" |
|
42 |
#include "serial.h" |
|
39 | 43 |
#include "analog.h" |
40 |
#include "serial.h" |
|
41 | 44 |
// Internal Function Prototypes |
42 | 45 |
void set_adc_mux(int which); |
43 | 46 |
|
trunk/code/projects/libdragonfly/encoders.c | ||
---|---|---|
1 |
#include "encoders.h" |
|
1 |
/** |
|
2 |
* Copyright (c) 2007 Colony Project |
|
3 |
* |
|
4 |
* Permission is hereby granted, free of charge, to any person |
|
5 |
* obtaining a copy of this software and associated documentation |
|
6 |
* files (the "Software"), to deal in the Software without |
|
7 |
* restriction, including without limitation the rights to use, |
|
8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9 |
* copies of the Software, and to permit persons to whom the |
|
10 |
* Software is furnished to do so, subject to the following |
|
11 |
* conditions: |
|
12 |
* |
|
13 |
* The above copyright notice and this permission notice shall be |
|
14 |
* included in all copies or substantial portions of the Software. |
|
15 |
* |
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
23 |
* OTHER DEALINGS IN THE SOFTWARE. |
|
24 |
**/ |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* @file encoders.c |
|
29 |
* @brief Encoders |
|
30 |
* |
|
31 |
* Implementation of functions for encoders. |
|
32 |
* |
|
33 |
* @author Colony Project, CMU Robotics Club |
|
34 |
**/ |
|
35 |
|
|
36 |
#include <avr/io.h> |
|
37 |
|
|
38 |
#include "dragonfly_defs.h" |
|
2 | 39 |
#include "spi.h" |
3 | 40 |
#include "ring_buffer.h" |
4 |
#include <avr/io.h>
|
|
41 |
#include "encoders.h"
|
|
5 | 42 |
|
6 | 43 |
unsigned char encoders_initd=0; |
7 | 44 |
|
trunk/code/projects/libdragonfly/time.h | ||
---|---|---|
37 | 37 |
#ifndef _TIME_H_ |
38 | 38 |
#define _TIME_H_ |
39 | 39 |
|
40 |
#include <dragonfly_lib.h> |
|
41 | 40 |
|
42 | 41 |
/* Predefined times for prescale_opt in time.c. |
43 | 42 |
To make you own, know that a pulse is 1/16th of a second. You cannot get less than this. To get more, you need |
trunk/code/projects/libdragonfly/encoders.h | ||
---|---|---|
1 | 1 |
/** |
2 |
* Copyright (c) 2007 Colony Project |
|
2 | 3 |
* |
4 |
* Permission is hereby granted, free of charge, to any person |
|
5 |
* obtaining a copy of this software and associated documentation |
|
6 |
* files (the "Software"), to deal in the Software without |
|
7 |
* restriction, including without limitation the rights to use, |
|
8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9 |
* copies of the Software, and to permit persons to whom the |
|
10 |
* Software is furnished to do so, subject to the following |
|
11 |
* conditions: |
|
12 |
* |
|
13 |
* The above copyright notice and this permission notice shall be |
|
14 |
* included in all copies or substantial portions of the Software. |
|
15 |
* |
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
23 |
* OTHER DEALINGS IN THE SOFTWARE. |
|
24 |
**/ |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
3 | 28 |
* @file encoders.h |
4 | 29 |
* @brief Contains functions for reading encoder values. |
5 | 30 |
* |
trunk/code/projects/libdragonfly/bom.c | ||
---|---|---|
33 | 33 |
* @author Colony Project, CMU Robotics Club |
34 | 34 |
**/ |
35 | 35 |
|
36 |
#include "bom.h"
|
|
36 |
#include "dragonfly_defs.h"
|
|
37 | 37 |
#include "dio.h" |
38 | 38 |
#include "serial.h" |
39 | 39 |
#include "analog.h" |
40 |
#include "bom.h" |
|
40 | 41 |
|
41 | 42 |
//On the original BOM1.0, the emmitter angular order does not match the analog mux order |
42 | 43 |
//so you need to iterate through the mux index in the following order if you want to get |
trunk/code/projects/libdragonfly/rangefinder.c | ||
---|---|---|
59 | 59 |
*/ |
60 | 60 |
#include <avr/pgmspace.h> |
61 | 61 |
|
62 |
#include "rangefinder.h"
|
|
62 |
#include "dragonfly_defs.h"
|
|
63 | 63 |
#include "analog.h" |
64 | 64 |
#include "dio.h" |
65 |
#include "rangefinder.h" |
|
65 | 66 |
|
66 | 67 |
unsigned char range_initd=0; |
67 | 68 |
|
trunk/code/projects/libdragonfly/rangefinder.h | ||
---|---|---|
37 | 37 |
#ifndef _RANGEFINDER_H_ |
38 | 38 |
#define _RANGEFINDER_H_ |
39 | 39 |
|
40 |
#include <dragonfly_lib.h> |
|
41 |
|
|
42 | 40 |
/** |
43 | 41 |
* @addtogroup rangefinder |
44 | 42 |
* @{ |
trunk/code/projects/libdragonfly/dragonfly_defs.h | ||
---|---|---|
1 |
/** |
|
2 |
* Copyright (c) 2007 Colony Project |
|
3 |
* |
|
4 |
* Permission is hereby granted, free of charge, to any person |
|
5 |
* obtaining a copy of this software and associated documentation |
|
6 |
* files (the "Software"), to deal in the Software without |
|
7 |
* restriction, including without limitation the rights to use, |
|
8 |
* copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
9 |
* copies of the Software, and to permit persons to whom the |
|
10 |
* Software is furnished to do so, subject to the following |
|
11 |
* conditions: |
|
12 |
* |
|
13 |
* The above copyright notice and this permission notice shall be |
|
14 |
* included in all copies or substantial portions of the Software. |
|
15 |
* |
|
16 |
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
17 |
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES |
|
18 |
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
19 |
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT |
|
20 |
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, |
|
21 |
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
|
22 |
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
|
23 |
* OTHER DEALINGS IN THE SOFTWARE. |
|
24 |
**/ |
|
25 |
|
|
26 |
|
|
27 |
/** |
|
28 |
* @file dragonfly_def.h |
|
29 |
* @brief Contains definitions for dragonfly library |
|
30 |
* |
|
31 |
* Should be included in all dragonfly library source files. |
|
32 |
* Does not need to be included by user programs. |
|
33 |
* |
|
34 |
* @author Colony Project, CMU Robotics Club |
|
35 |
**/ |
|
36 |
|
|
37 |
#ifndef _DRAGONFLY_DEFS_H_ |
|
38 |
#define _DRAGONFLY_DEFS_H_ |
|
39 |
|
|
40 |
/** |
|
41 |
* @addtogroup dragonfly |
|
42 |
* @{ |
|
43 |
**/ |
|
44 |
|
|
45 |
//return value definitions |
|
46 |
/** @brief Error code for init failure **/ |
|
47 |
#define ERROR_INIT_FAILED 1 |
|
48 |
/** @brief Error code for duplicate init calls **/ |
|
49 |
#define ERROR_INIT_ALREADY_INITD 2 |
|
50 |
/** @brief Error code for not calling init **/ |
|
51 |
#define ERROR_LIBRARY_NOT_INITD 3 |
|
52 |
|
|
53 |
// Configuration definitions |
|
54 |
/** @brief Initialize analog **/ |
|
55 |
#define ANALOG 0x01 |
|
56 |
/** @brief Initialize serial communications **/ |
|
57 |
#define SERIAL 0x02 |
|
58 |
/** @brief Initialize USB communications **/ |
|
59 |
#define USB 0x02 |
|
60 |
/** @brief Initialize communications **/ |
|
61 |
#define COMM 0x02 |
|
62 |
/** @brief Initialize the orb **/ |
|
63 |
#define ORB 0x04 |
|
64 |
/** @brief Initialize the motors **/ |
|
65 |
#define MOTORS 0x08 |
|
66 |
/** @brief Initialize I2C **/ |
|
67 |
#define I2C 0x20 |
|
68 |
/** @brief Initialize the buzzer **/ |
|
69 |
#define BUZZER 0x40 |
|
70 |
/** @brief Initialize the LCD screen **/ |
|
71 |
#define LCD 0x80 |
|
72 |
/** @brief Initialize the rangefinders **/ |
|
73 |
#define RANGE 0x0100 |
|
74 |
/** @brief Initialize the BOM **/ |
|
75 |
#define BOM 0x0200 |
|
76 |
/** @brief Initilize encoders **/ |
|
77 |
#define ENCODERS 0x400 |
|
78 |
/** @brief Initialize everything **/ |
|
79 |
#define ALL_ON 0x07FF |
|
80 |
|
|
81 |
/** @} **/ //end addtogroup |
|
82 |
|
|
83 |
/** @brief shortcut for ATOMIC_BLOCK(ATOMIC_RESTORESTATE) **/ |
|
84 |
#define SYNC ATOMIC_BLOCK(ATOMIC_RESTORESTATE) |
|
85 |
|
|
86 |
/** @brief atomically grab a lock if it is free, return otherwise **/ |
|
87 |
#define REQUIRE_LOCK_OR_RETURN(LOCK) do { SYNC { if (LOCK) return; LOCK=1; } } while (0) |
|
88 |
|
|
89 |
/** @brief atomically release a lock **/ |
|
90 |
#define RELEASE_LOCK(LOCK) do { LOCK=0; } while (0) |
|
91 |
|
|
92 |
|
|
93 |
#endif |
Also available in: Unified diff