root / branches / simulator / projects / libdragonfly / dragonfly_lib.c @ 1076
History | View | Annotate | Download (2.55 KB)
1 | 241 | bcoltin | /**
|
---|---|---|---|
2 | * Copyright (c) 2007 Colony Project
|
||
3 | 1072 | bneuman | *
|
4 | 241 | bcoltin | * 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 | 1072 | bneuman | *
|
13 | 241 | bcoltin | * The above copyright notice and this permission notice shall be
|
14 | * included in all copies or substantial portions of the Software.
|
||
15 | 1072 | bneuman | *
|
16 | 241 | bcoltin | * 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 | 943 | bcoltin | #include <avr/io.h> |
39 | #include <avr/interrupt.h> |
||
40 | #include <util/delay.h> |
||
41 | |||
42 | 774 | kwoo | /**
|
43 | * init_dragonfly - Initializes functions based on configuration parameters
|
||
44 | * examples:
|
||
45 | *
|
||
46 | * init_dragonfly (ALL_ON); - Turns on all basic subsystems. More complex ones that require
|
||
47 | * their own configuration parameters must still be called on their own.
|
||
48 | *
|
||
49 | 1072 | bneuman | * init_dragonfly (ANALOG | SERIAL | BUZZER);
|
50 | 774 | kwoo | * Initialize ADC, USB, XBee, and Buzzer
|
51 | 1072 | bneuman | *
|
52 | 774 | kwoo | * init_dragonfly (MOTORS | ORB);
|
53 | 1072 | bneuman | * Initialize the motors and ORB.
|
54 | 774 | kwoo | **/
|
55 | 8 | bcoltin | |
56 | |||
57 | 378 | jknichel | void dragonfly_init(int config) { |
58 | sei(); |
||
59 | 338 | bcoltin | |
60 | 774 | kwoo | //Enables the hardware buttons on the board as input pins
|
61 | // with internal pullups enabled.
|
||
62 | //Pin G0 is button 1
|
||
63 | //Pin G1 is button 2
|
||
64 | DDRG &= ~(_BV(PING0)|_BV(PING1)); |
||
65 | 378 | jknichel | PORTG |= _BV(PING0)|_BV(PING1); |
66 | 1072 | bneuman | |
67 | 378 | jknichel | if(config & ANALOG)
|
68 | analog_init(ADC_START); |
||
69 | 1072 | bneuman | |
70 | 378 | jknichel | if(config & COMM) {
|
71 | 774 | kwoo | //Both default to 115200. Check serial.h for more information.
|
72 | 378 | jknichel | usb_init(); |
73 | xbee_init(); |
||
74 | } |
||
75 | 1072 | bneuman | |
76 | 378 | jknichel | if(config & BUZZER) {
|
77 | buzzer_init(); |
||
78 | } |
||
79 | 1072 | bneuman | |
80 | 378 | jknichel | if(config & ORB) {
|
81 | orb_init(); |
||
82 | } |
||
83 | 1072 | bneuman | |
84 | 378 | jknichel | if(config & MOTORS)
|
85 | motors_init(); |
||
86 | 8 | bcoltin | |
87 | 378 | jknichel | if(config & LCD)
|
88 | lcd_init(); |
||
89 | 1072 | bneuman | |
90 | 378 | jknichel | // delay a bit for stability
|
91 | _delay_ms(1);
|
||
92 | 8 | bcoltin | } |
93 | |||
94 | 1072 | bneuman | |
95 | void simulator_do() {
|
||
96 | return;
|
||
97 | } |