Project

General

Profile

Revision 871

Recommitting the library so encoders work for other people as well.

View differences:

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
  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));
70 79
  PORTG |= _BV(PING0)|_BV(PING1);
71 80
	
72 81
  if(config & ANALOG)
73 82
    analog_init(ADC_START);
74 83
	
75 84
  if(config & COMM) {
76
    //Defaults to 115200. Check serial.h for more information.
85
    //Both default to 115200. Check serial.h for more information.
77 86
    usb_init();
78 87
    xbee_init();
79 88
  }
80 89
	
81 90
  if(config & BUZZER) {
82
    sei();
83 91
    buzzer_init();
84 92
  }
85 93
	
86 94
  if(config & ORB) {
87
    sei();
88 95
    orb_init();
89 96
  }
90 97
	
......
93 100

  
94 101
  if(config & LCD)
95 102
    lcd_init();
96
    
103
   
97 104
  // delay a bit for stability
98 105
  _delay_ms(1);
99 106
}

Also available in: Unified diff