Project

General

Profile

Statistics
| Revision:

root / branches / simulator / projects / libdragonfly / dragonfly_lib.c @ 1072

History | View | Annotate | Download (2.55 KB)

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_lib.c
29
 * @brief Dragonfly initialization
30
 *
31
 * Contains implementation of dragonfly_init.
32
 *
33
 * @author Colony Project, CMU Robotics Club
34
 **/
35

    
36
#include <dragonfly_lib.h>
37

    
38
#include <avr/io.h>
39
#include <avr/interrupt.h>
40
#include <util/delay.h>
41

    
42
/**
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
 * init_dragonfly (ANALOG | SERIAL | BUZZER);
50
 * Initialize ADC, USB, XBee, and Buzzer
51
 *
52
 * init_dragonfly (MOTORS | ORB);
53
 * Initialize the motors and ORB.
54
 **/
55

    
56

    
57
void dragonfly_init(int config) {
58
  sei();
59

    
60
  //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
  PORTG |= _BV(PING0)|_BV(PING1);
66

    
67
  if(config & ANALOG)
68
    analog_init(ADC_START);
69

    
70
  if(config & COMM) {
71
    //Both default to 115200. Check serial.h for more information.
72
    usb_init();
73
    xbee_init();
74
  }
75

    
76
  if(config & BUZZER) {
77
    buzzer_init();
78
  }
79

    
80
  if(config & ORB) {
81
    orb_init();
82
  }
83

    
84
  if(config & MOTORS)
85
    motors_init();
86

    
87
  if(config & LCD)
88
    lcd_init();
89

    
90
  // delay a bit for stability
91
  _delay_ms(1);
92
}
93

    
94

    
95
void simulator_do() {
96
  return;
97
}