root / trunk / code / projects / libdragonfly / dragonfly_lib.c @ 903
History | View | Annotate | Download (3.01 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 | 903 | cmar | if(config & ANALOG) {
|
82 | 378 | jknichel | analog_init(ADC_START); |
83 | 903 | cmar | range_init(); |
84 | } |
||
85 | 8 | bcoltin | |
86 | 378 | jknichel | if(config & COMM) {
|
87 | 774 | kwoo | //Both default to 115200. Check serial.h for more information.
|
88 | 378 | jknichel | usb_init(); |
89 | xbee_init(); |
||
90 | } |
||
91 | 8 | bcoltin | |
92 | 378 | jknichel | if(config & BUZZER) {
|
93 | buzzer_init(); |
||
94 | } |
||
95 | 8 | bcoltin | |
96 | 378 | jknichel | if(config & ORB) {
|
97 | orb_init(); |
||
98 | } |
||
99 | 8 | bcoltin | |
100 | 378 | jknichel | if(config & MOTORS)
|
101 | motors_init(); |
||
102 | 8 | bcoltin | |
103 | 378 | jknichel | if(config & LCD)
|
104 | lcd_init(); |
||
105 | 774 | kwoo | |
106 | 378 | jknichel | // delay a bit for stability
|
107 | _delay_ms(1);
|
||
108 | 8 | bcoltin | } |
109 | |||
110 | |||
111 | /** @} **/ //end defgroup |