Project

General

Profile

Revision 1543

Added by Brad Neuman over 14 years ago

Added a bunch of debug prints to the library

View differences:

dragonfly_lib.c
69 69
{
70 70
  int ret = 0;
71 71

  
72
  DRAGONFLY_DEBUG_PRINT("in dragonfly_init\r\n");
73

  
72 74
    sei();
73 75
    // Set directionality of various IO pins
74 76
    DDRG &= ~(_BV(PING0)|_BV(PING1));
75 77
    PORTG |= _BV(PING0)|_BV(PING1);
76 78
    
77 79
    if(config & ANALOG) {
78
      analog_init(ADC_START);
80
      if((ret = analog_init(ADC_START))) {
81
	DRAGONFLY_DEBUG_PRINT("analog_init returned ");
82
	DRAGONFLY_DEBUG_PRINT_INT(ret);
83
	DRAGONFLY_DEBUG_PRINT_STR("\r\n");
84
      }
85
      /*TODO: return error already init'd or maybe something else if
86
	one of these inits returns that? */
79 87
    }
80 88
    
81 89
    if(config & COMM)
82 90
    {
83 91
        //Defaults to 115200. Check serial.h for more information.
84
        usb_init();
85
        xbee_init();
92
      if((ret =  usb_init())) {
93
	DRAGONFLY_DEBUG_PRINT("usb_init returned ");
94
	DRAGONFLY_DEBUG_PRINT_INT(ret);
95
	DRAGONFLY_DEBUG_PRINT_STR("\r\n");
96
      }
97
      if((ret =  xbee_init())) {
98
	DRAGONFLY_DEBUG_PRINT("xbee_init returned ");
99
	DRAGONFLY_DEBUG_PRINT_INT(ret);
100
	DRAGONFLY_DEBUG_PRINT_STR("\r\n");
101
      }
86 102
    }
87 103
    
88 104
    if(config & BUZZER)
89 105
    {
90
        sei();
91
        buzzer_init();
106
      //sei(); This is already done above
107
      buzzer_init();
92 108
    }
93 109
    
94 110
    if(config & ORB)
95 111
    {
96
        sei();
97
        orb_init();
112
      //sei(); This is already done above
113
      orb_init();
98 114
    }
99 115
    
100
    if(config & MOTORS)
101
        motors_init();
116
    if(config & MOTORS) {
117
      if((ret =  motors_init())) {
118
	DRAGONFLY_DEBUG_PRINT("motors_init returned ");
119
	DRAGONFLY_DEBUG_PRINT_INT(ret);
120
	DRAGONFLY_DEBUG_PRINT_STR("\r\n");
121
      }
122
    }
102 123

  
103
    if(config & LCD)
104
        lcd_init();
124
    if(config & LCD) {
125
      lcd_init();
126
    }
105 127
    
106
    if(config & RANGE)
107
        range_init();
128
    if(config & RANGE) {
129
      
130
      if((ret =  range_init())) {
131
	DRAGONFLY_DEBUG_PRINT("range_init returned ");
132
	DRAGONFLY_DEBUG_PRINT_INT(ret);
133
	DRAGONFLY_DEBUG_PRINT_STR("\r\n");
134
      }
135
    }
108 136
        
109 137
    if(config & BOM)
110 138
    {
111 139
        unsigned char bom_read = get_bom_type();
140
	DRAGONFLY_DEBUG_PRINT("Got BOM type ");
141
	DRAGONFLY_DEBUG_PRINT_INT(bom_read);
142
	DRAGONFLY_DEBUG_PRINT_STR("\r\n");
143

  
112 144
        if(bom_read == 0xFF) {
113
            //warn that bom initialization failed
114
            flash_red();
115
            return ERROR_INIT_FAILED;
145
	  //warn that bom initialization failed
146
	  DRAGONFLY_DEBUG_PRINT("WARNING: invalid BOM type!\r\n");
147
	  flash_red();
148
	  return ERROR_INIT_FAILED;
116 149
        }
117
        else
118
          if (bom_init(bom_read) != 0)
150
        else {
151
          if ((ret = bom_init(bom_read))) {
152
	    DRAGONFLY_DEBUG_PRINT("bom_init returned ");
153
	    DRAGONFLY_DEBUG_PRINT_INT(ret);
154
	    DRAGONFLY_DEBUG_PRINT_STR("\r\n");
119 155
            return ERROR_INIT_FAILED;
156
	  }
157
	}
120 158
    }
121 159

  
122 160
    if (config & ENCODERS)
123 161
    {
124
        encoders_init();
162
      if((ret =  encoders_init())) {
163
	DRAGONFLY_DEBUG_PRINT("encoders_init returned ");
164
	DRAGONFLY_DEBUG_PRINT_INT(ret);
165
	DRAGONFLY_DEBUG_PRINT_STR("\r\n");
166
      }
167

  
125 168
    }
126 169

  
170
    DRAGONFLY_DEBUG_PRINT("dragonfly_init complete\r\n");
171

  
127 172
    // delay a bit for stability
128 173
    _delay_ms(1);
129 174
    

Also available in: Unified diff