Revision 774
Cleaned up some of Jason's tickets for dragonfly_lib. Now it should suck less.
trunk/code/projects/libdragonfly/dragonfly_lib.c | ||
---|---|---|
35 | 35 |
|
36 | 36 |
#include <dragonfly_lib.h> |
37 | 37 |
|
38 |
/* init_dragonfly - Initializes functions based on configuration parameters |
|
39 |
examples: |
|
38 |
/** |
|
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 |
**/ |
|
40 | 51 |
|
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 | 52 |
/** |
51 | 53 |
* @defgroup dragonfly Dragonfly |
52 | 54 |
* @brief General Dragonfly Functions |
... | ... | |
57 | 59 |
**/ |
58 | 60 |
|
59 | 61 |
/** |
60 |
* Initializes the components specified by config. |
|
62 |
* 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. |
|
61 | 67 |
* |
62 | 68 |
* @see analog_init, usb_init, xbee_init, buzzer_init, |
63 | 69 |
* bom_init, orb_init, motors_init, lcd_init |
... | ... | |
65 | 71 |
void dragonfly_init(int config) { |
66 | 72 |
sei(); |
67 | 73 |
|
68 |
// Set directionality of various IO pins |
|
69 |
//TODO: add comments for what these ports control |
|
70 |
DDRG &= ~(_BV(PING0)|_BV(PING1)); |
|
74 |
//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)); |
|
71 | 79 |
PORTG |= _BV(PING0)|_BV(PING1); |
72 | 80 |
|
73 | 81 |
if(config & ANALOG) |
74 | 82 |
analog_init(ADC_START); |
75 | 83 |
|
76 | 84 |
if(config & COMM) { |
77 |
//TODO: xbee doesn't default to 115200 does it? |
|
78 |
//TODO: is serial 115200 or 56k-ish, whatever that number is? |
|
79 |
//Defaults to 115200. Check serial.h for more information. |
|
85 |
//Both default to 115200. Check serial.h for more information. |
|
80 | 86 |
usb_init(); |
81 | 87 |
xbee_init(); |
82 | 88 |
} |
83 | 89 |
|
84 | 90 |
if(config & BUZZER) { |
85 |
sei(); |
|
86 | 91 |
buzzer_init(); |
87 | 92 |
} |
88 | 93 |
|
89 | 94 |
if(config & ORB) { |
90 |
sei(); |
|
91 | 95 |
orb_init(); |
92 | 96 |
} |
93 | 97 |
|
... | ... | |
96 | 100 |
|
97 | 101 |
if(config & LCD) |
98 | 102 |
lcd_init(); |
99 |
|
|
103 |
|
|
100 | 104 |
// delay a bit for stability |
101 | 105 |
_delay_ms(1); |
102 | 106 |
} |
trunk/code/projects/libdragonfly/dragonfly_lib.h | ||
---|---|---|
54 | 54 |
#define ORB 0x04 |
55 | 55 |
/** @brief Initialize the motors **/ |
56 | 56 |
#define MOTORS 0x08 |
57 |
/** @brief Initialize I2C **/ |
|
58 |
#define I2C 0x20 |
|
59 | 57 |
/** @brief Initialize the buzzer **/ |
60 |
#define BUZZER 0x40
|
|
58 |
#define BUZZER 0x10
|
|
61 | 59 |
/** @brief Initialize the LCD screen **/ |
62 |
#define LCD 0x80
|
|
60 |
#define LCD 0x20
|
|
63 | 61 |
/** @brief Initialize everything **/ |
64 | 62 |
#define ALL_ON 0xFF |
65 | 63 |
|
Also available in: Unified diff