root / trunk / code / projects / libdragonfly / dragonfly_lib.c @ 864
History | View | Annotate | Download (2.99 KB)
1 | 241 | bcoltin | /**
|
---|---|---|---|
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_lib.c
|
||
29 | * @brief Dragonfly initialization
|
||
30 | *
|
||
31 | * Contains implementation of dragonfly_init.
|
||
32 | *
|
||
33 | * @author Colony Project, CMU Robotics Club
|
||
34 | **/
|
||
35 | |||
36 | 8 | bcoltin | #include <dragonfly_lib.h> |
37 | |||
38 | 774 | kwoo | /**
|
39 | * init_dragonfly - Initializes functions based on configuration parameters
|
||
40 | * examples:
|
||
41 | *
|
||
42 | * init_dragonfly (ALL_ON); - Turns on all basic subsystems. More complex ones that require
|
||
43 | * their own configuration parameters must still be called on their own.
|
||
44 | *
|
||
45 | * init_dragonfly (ANALOG | SERIAL | BUZZER);
|
||
46 | * Initialize ADC, USB, XBee, and Buzzer
|
||
47 | *
|
||
48 | * init_dragonfly (MOTORS | ORB);
|
||
49 | * Initialize the motors and ORB.
|
||
50 | **/
|
||
51 | 8 | bcoltin | |
52 | /**
|
||
53 | * @defgroup dragonfly Dragonfly
|
||
54 | * @brief General Dragonfly Functions
|
||
55 | * General functions for the dragonfly. Include
|
||
56 | * dragonfly_lib.h to access these functions.
|
||
57 | *
|
||
58 | * @{
|
||
59 | **/
|
||
60 | |||
61 | /**
|
||
62 | 774 | kwoo | * Initializes the components specified by config. Will turn on interrupts
|
63 | * automatically.
|
||
64 | *
|
||
65 | * @param config The subsystems that you wish to turn on. Check dragonfly_lib.h for
|
||
66 | * valid values.
|
||
67 | 8 | bcoltin | *
|
68 | * @see analog_init, usb_init, xbee_init, buzzer_init,
|
||
69 | * bom_init, orb_init, motors_init, lcd_init
|
||
70 | **/
|
||
71 | 378 | jknichel | void dragonfly_init(int config) { |
72 | sei(); |
||
73 | 338 | bcoltin | |
74 | 774 | kwoo | //Enables the hardware buttons on the board as input pins
|
75 | // with internal pullups enabled.
|
||
76 | //Pin G0 is button 1
|
||
77 | //Pin G1 is button 2
|
||
78 | DDRG &= ~(_BV(PING0)|_BV(PING1)); |
||
79 | 378 | jknichel | PORTG |= _BV(PING0)|_BV(PING1); |
80 | 8 | bcoltin | |
81 | 378 | jknichel | if(config & ANALOG)
|
82 | analog_init(ADC_START); |
||
83 | 8 | bcoltin | |
84 | 378 | jknichel | if(config & COMM) {
|
85 | 774 | kwoo | //Both default to 115200. Check serial.h for more information.
|
86 | 378 | jknichel | usb_init(); |
87 | xbee_init(); |
||
88 | } |
||
89 | 8 | bcoltin | |
90 | 378 | jknichel | if(config & BUZZER) {
|
91 | buzzer_init(); |
||
92 | } |
||
93 | 8 | bcoltin | |
94 | 378 | jknichel | if(config & ORB) {
|
95 | orb_init(); |
||
96 | } |
||
97 | 8 | bcoltin | |
98 | 378 | jknichel | if(config & MOTORS)
|
99 | motors_init(); |
||
100 | 8 | bcoltin | |
101 | 378 | jknichel | if(config & LCD)
|
102 | lcd_init(); |
||
103 | 774 | kwoo | |
104 | 378 | jknichel | // delay a bit for stability
|
105 | _delay_ms(1);
|
||
106 | 8 | bcoltin | } |
107 | |||
108 | |||
109 | /** @} **/ //end defgroup |