Revision 277
more cleanup
dragonfly_lib.c | ||
---|---|---|
36 | 36 |
#include <dragonfly_lib.h> |
37 | 37 |
|
38 | 38 |
/* init_dragonfly - Initializes functions based on configuration parameters |
39 |
examples: |
|
39 |
* examples: |
|
40 |
* |
|
41 |
* init_dragonfly (0, 0, 0); - just initialize the digital IO (buttons, potentiometer) |
|
42 |
* |
|
43 |
* init_dragonfly (ANALOG | SERIAL | BUZZER, C0_C1_ANALOG, BAUD115200); |
|
44 |
* Initialize ADC and set C0 and C1 as analog inputs. Initialize serial and set baud rate |
|
45 |
* to 115200 bps. Initialize the buzzer. |
|
46 |
* |
|
47 |
* init_dragonfly (MOTORS | ORB, 0, 0); |
|
48 |
* Initialize motor driving and the color fading abilities of the ORB. |
|
49 |
*/ |
|
40 | 50 |
|
41 |
init_dragonfly (0, 0, 0); - just initialize the digital IO (buttons, potentiometer) |
|
42 |
|
|
43 |
init_dragonfly (ANALOG | SERIAL | BUZZER, C0_C1_ANALOG, BAUD115200); |
|
44 |
Initialize ADC and set C0 and C1 as analog inputs. Initialize serial and set baud rate |
|
45 |
to 115200 bps. Initialize the buzzer. |
|
46 |
|
|
47 |
init_dragonfly (MOTORS | ORB, 0, 0); |
|
48 |
Initialize motor driving and the color fading abilities of the ORB. */ |
|
49 |
|
|
50 | 51 |
/** |
51 | 52 |
* @defgroup dragonfly Dragonfly |
52 | 53 |
* @brief General Dragonfly Functions |
... | ... | |
64 | 65 |
**/ |
65 | 66 |
void dragonfly_init(int config) |
66 | 67 |
{ |
67 |
// Set directionality of various IO pins
|
|
68 |
DDRG &= ~(_BV(PING0)|_BV(PING1));
|
|
69 |
PORTG |= _BV(PING0)|_BV(PING1);
|
|
68 |
// Set directionality of various IO pins
|
|
69 |
DDRG &= ~(_BV(PING0)|_BV(PING1));
|
|
70 |
PORTG |= _BV(PING0)|_BV(PING1);
|
|
70 | 71 |
|
71 |
if(config & ANALOG) |
|
72 |
analog_init(); |
|
72 |
if (config & ANALOG) { |
|
73 |
analog_init(); |
|
74 |
} |
|
73 | 75 |
|
74 |
if(config & COMM) |
|
75 |
{ |
|
76 |
//Defaults to 115200. Check serial.h for more information. |
|
77 |
sei(); |
|
78 |
usb_init(); |
|
79 |
xbee_init(); |
|
80 |
} |
|
76 |
if (config & COMM) { |
|
77 |
//Defaults to 115200. Check serial.h for more information. |
|
78 |
sei(); |
|
79 |
usb_init(); |
|
80 |
xbee_init(); |
|
81 |
} |
|
81 | 82 |
|
82 |
if(config & BUZZER) |
|
83 |
{ |
|
84 |
sei(); |
|
85 |
buzzer_init(); |
|
86 |
} |
|
83 |
if (config & BUZZER) { |
|
84 |
sei(); |
|
85 |
buzzer_init(); |
|
86 |
} |
|
87 | 87 |
|
88 |
if(config & ORB) |
|
89 |
{ |
|
90 |
sei(); |
|
91 |
orb_init(); |
|
92 |
} |
|
88 |
if (config & ORB) { |
|
89 |
sei(); |
|
90 |
orb_init(); |
|
91 |
} |
|
93 | 92 |
|
94 |
if(config & MOTORS) |
|
95 |
motors_init(); |
|
93 |
if (config & MOTORS) { |
|
94 |
motors_init(); |
|
95 |
} |
|
96 | 96 |
|
97 |
if(config & LCD) |
|
98 |
lcd_init(); |
|
97 |
if (config & LCD) { |
|
98 |
lcd_init(); |
|
99 |
} |
|
99 | 100 |
|
100 |
// delay a bit for stability
|
|
101 |
_delay_ms(1);
|
|
101 |
// delay a bit for stability
|
|
102 |
_delay_ms(1);
|
|
102 | 103 |
} |
103 | 104 |
|
104 |
|
|
105 | 105 |
/** @} **/ //end defgroup |
106 |
|
Also available in: Unified diff