Changeset 446
- Timestamp:
- 03/08/09 14:41:58 (3 years ago)
- Location:
- trunk/electronics/avr/killswitch
- Files:
-
- 1 removed
- 2 modified
-
killremote.c (modified) (4 diffs)
-
killremote.hex (deleted)
-
killrobot.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/electronics/avr/killswitch/killremote.c
r444 r446 43 43 { 44 44 DDRB = 0x0F; 45 DDRC = 0 x00;45 DDRC = 0b00011000; 46 46 DDRD = 0b11111110; 47 47 } … … 49 49 static void adc_init() 50 50 { 51 ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); 52 ADMUX |= (1 << REFS0); 53 ADMUX |= (1 << ADLAR); 54 ADCSRA |= (1 << ADFR); 55 ADCSRA |= (1 << ADEN); 56 ADCSRA |= (1 << ADIE); 51 ADCSRA |= (1 << ADPS2) | (1 << ADPS1) | (1 << ADPS0); // 128 ADC clock prescale, 62.5KHz @ 8MHz clock 52 ADMUX |= (1 << REFS0) | (1 << REFS1); // 1.1v internal ref 53 ADCSRA |= (1 << ADEN); // enable adc 54 ADCSRA |= (1 << ADIE); // enable interrupts 57 55 } 58 56 … … 66 64 sei(); 67 65 68 uint8_t c;69 70 66 while (1) { 71 uint8_t in = 'f'; 72 c = PINC; 73 c &= (1<<2); 74 usart_put(!c ? 's' : 'g'); 67 usart_put('g'); 75 68 _delay_ms(100); 76 69 77 70 if(UCSR0A & (1<<7)) { 78 71 in = usart_get(); 79 if(in == 'c') sbi(PORTB, 2);//PORTB |= 0x03;80 72 counter = 500; 81 73 } 82 74 83 if(!counter) cbi(PORTB, 2);//PORTB &= 0xFC; 84 if(!c) PORTB sbi(PORTB, 1);//&= 0xF3; 85 else cbi(PORTB, 1);//PORTB |= 0x0C; 75 if(!counter) cbi(PORTC, 4); 76 else cbi(PORTC, 4); 77 78 ADCSRA |= (1 << ADSC) | (1 << ADIE); 86 79 } 87 80 … … 97 90 ISR(ADC_vect) 98 91 { 99 if(ADCH < 128) sbi(PORTB, 0);100 else cbi(PORT B, 0);92 if(ADCH < 630) sbi(PORTC, 5); // low battery at 2.7V, minimum voltage for AVR and xbee 93 else cbi(PORTC, 5); 101 94 } -
trunk/electronics/avr/killswitch/killrobot.c
r423 r446 71 71 usart_put('c'); 72 72 } 73 else if( in == 's' ||!counter) {73 else if(!counter) { 74 74 PORTB = 0x00; 75 75 usart_put('c');

