Project

General

Profile

Revision 1634

analog loop gone
A/D conversions now blocking
A/D clock sped up

View differences:

branches/analog/code/projects/libdragonfly/analog.c
94 94
	// Bit 5 - Enable Auto Trigger (for free running mode) NOT DOING THIS RIGHT NOW
95 95
	// Bit 4 - ADC interrupt flag, 0
96 96
	// Bit 3 - Enable ADC Interrupt (required to run free-running mode)
97
	// Bits 2-0 - Set to create a clock divisor of 128, to make ADC clock = 8,000,000/64 = 125kHz
97
	// Bits 2-0 - Set to create a clock divisor of 128, to make ADC clock = 8,000,000/64 = 125kHz EDIT: changed to 8MHz
98 98
	ADCSRA = 0;
99
	ADCSRA |= _BV(ADEN) | _BV(ADPS2) | _BV(ADPS1) | _BV(ADPS0);
99
	ADCSRA |= _BV(ADEN) | _BV(ADPS0);
100 100
	
101 101
	// Set external mux lines to outputs
102 102
	DDRG |= 0x1C;
......
106 106
	adc_current_port = AN1;
107 107

  
108 108
	//Start the conversion loop if requested
109
	if (start_conversion)
110
		analog_start_loop();
109
	//if (start_conversion)
110
		//analog_start_loop();
111 111
		
112 112
	//Conversion loop disabled by default
113 113
}	
......
296 296
 * @see analog_init
297 297
 **/
298 298
int wheel(void) {
299
	return analog8(WHEEL_PORT);
299
	return analog_get8(WHEEL_PORT);
300 300
}
301 301

  
302 302

  
......
323 323

  
324 324

  
325 325
ISR(ADC_vect) {
326
	int adc_h = 0;
326
	/*int adc_h = 0;
327 327
	int adc_l = 0;
328 328
	
329 329
	if(adc_loop_status != ADC_LOOP_RUNNING) return;
......
366 366
	}
367 367
	
368 368
	//Start next conversion
369
	ADCSRA |= _BV(ADSC);
369
	ADCSRA |= _BV(ADSC);*/
370 370
}
371 371

  
branches/analog/code/projects/libdragonfly/bom.c
201 201
 * see bom_refresh
202 202
 **/
203 203
int bom_get(int which) {
204
    return bom_val[which];
204
    //return bom_val[which];
205
	bom_select(which);
206
    return analog_get8(analog_pin);
205 207
}
206 208

  
207 209
/** 
......
212 214
 *    BOM_VALUE_THRESHOLD
213 215
 **/
214 216
int bom_get_max(void) {
215
    int i, lowest_val, lowest_i;
217
    int i, lowest_val, lowest_i, i_val;
216 218
    lowest_i = -1;
217 219
    lowest_val = 255;
218 220
    for(i = 0; i < NUM_BOM_LEDS; i++) {
219
        if(bom_val[i] < lowest_val) {
220
            lowest_val = bom_val[i];
221
		i_val = bom_get(i);
222
        if(i_val < lowest_val) {
223
            lowest_val = i_val;
221 224
            lowest_i = i;
222 225
        }
223 226
    }
......
316 319
 * @see analog_init
317 320
 **/
318 321
int get_max_bom(void) {
319
    bom_refresh(BOM_ALL);
322
    //bom_refresh(BOM_ALL);
320 323
    return bom_get_max();
321 324
}
322 325

  
branches/analog/code/projects/libdragonfly/rangefinder.c
129 129
 * @see range_init
130 130
 **/
131 131
int range_read_distance(int range_id) {
132
  return linearize_distance(analog8(range_id));
132
  return linearize_distance(analog_get8(range_id));
133 133
}
134 134

  
135 135
/**

Also available in: Unified diff