root / branches / encoders / code / lib / src / libdragonfly / dragonfly_lib.c @ 1345
History | View | Annotate | Download (1.7 KB)
1 | 7 | bcoltin | #include <dragonfly_lib.h> |
---|---|---|---|
2 | |||
3 | /* init_dragonfly - Initializes functions based on configuration parameters
|
||
4 | examples:
|
||
5 | |||
6 | init_dragonfly (0, 0, 0); - just initialize the digital IO (buttons, potentiometer)
|
||
7 | |||
8 | init_dragonfly (ANALOG | SERIAL | BUZZER, C0_C1_ANALOG, BAUD115200);
|
||
9 | Initialize ADC and set C0 and C1 as analog inputs. Initialize serial and set baud rate
|
||
10 | to 115200 bps. Initialize the buzzer.
|
||
11 | |||
12 | init_dragonfly (MOTORS | ORB, 0, 0);
|
||
13 | Initialize motor driving and the color fading abilities of the ORB. */
|
||
14 | |||
15 | /**
|
||
16 | * @defgroup dragonfly Dragonfly
|
||
17 | * @brief General Dragonfly Functions
|
||
18 | * General functions for the dragonfly. Include
|
||
19 | * dragonfly_lib.h to access these functions.
|
||
20 | *
|
||
21 | * @{
|
||
22 | **/
|
||
23 | |||
24 | /**
|
||
25 | * Initializes the components specified by config.
|
||
26 | *
|
||
27 | * @see analog_init, usb_init, xbee_init, buzzer_init,
|
||
28 | * bom_init, orb_init, motors_init, lcd_init
|
||
29 | **/
|
||
30 | void dragonfly_init(int config) |
||
31 | { |
||
32 | // Set directionality of various IO pins
|
||
33 | DDRG &= ~(_BV(PING0)|_BV(PING1)); |
||
34 | PORTG |= _BV(PING0)|_BV(PING1); |
||
35 | |||
36 | if(config & ANALOG) {
|
||
37 | analog_init(); |
||
38 | } |
||
39 | |||
40 | if(config & COMM) {
|
||
41 | //Defaults to 115200. Check serial.h for more information.
|
||
42 | sei(); |
||
43 | usb_init(); |
||
44 | xbee_init(); |
||
45 | } |
||
46 | |||
47 | if(config & BUZZER) {
|
||
48 | sei(); |
||
49 | buzzer_init(); |
||
50 | } |
||
51 | |||
52 | if(config & ORB) {
|
||
53 | sei(); |
||
54 | orb_init(); |
||
55 | } |
||
56 | |||
57 | if(config & MOTORS) {
|
||
58 | motors_init(); |
||
59 | } |
||
60 | |||
61 | if(config & SERVOS) {
|
||
62 | sei(); |
||
63 | //Servos not yet implemented
|
||
64 | //servo_init();
|
||
65 | } |
||
66 | |||
67 | if(config & LCD) {
|
||
68 | lcd_init(); |
||
69 | } |
||
70 | |||
71 | if(config & (SERVOS | ORB)) {
|
||
72 | sei(); |
||
73 | orb_init(); |
||
74 | //Servos not yet implemented
|
||
75 | } |
||
76 | |||
77 | // delay a bit for stability
|
||
78 | _delay_ms(1);
|
||
79 | } |
||
80 | |||
81 | |||
82 | /** @} **/ //end defgroup |