prepared some code for different modes

This commit is contained in:
bigalex 2012-09-20 21:20:51 +02:00
parent a7cc44b1a6
commit 25e923311c

View File

@ -17,17 +17,7 @@ void init_leds(void){
DDRC |= (1 << PORTC0) | (1 << PORTC1) | (1 << PORTC2) | (1 << PORTC3); DDRC |= (1 << PORTC0) | (1 << PORTC1) | (1 << PORTC2) | (1 << PORTC3);
// both LEDs off // both LEDs off
PORTC &= ~((1 << PORTC0) | (1 << PORTC1) | (1 << PORTC2) | (1 << PORTC3)); PORTC &= ~((1 << PORTC0) | (1 << PORTC1) | (1 << PORTC2) | (1 << PORTC3));
return;
//TCCR2A = (1 << WGM21);
//TCCR2B = (1 << CS20)|(1 << CS21);
//OCR2A = 255; /* TOP */
// TCNT2 = 0;
// /*enable interrupt*/
// TIMSK2 |= (1<<OCIE2A);
return;
}; };
void inline led_on(int leds){ void inline led_on(int leds){
@ -69,9 +59,6 @@ void buzzr_inv(){
PORTB ^= (1 << PORTB2); PORTB ^= (1 << PORTB2);
}; };
void init_switch(){
return;
};
void init_motor(void) void init_motor(void)
{ {
@ -88,39 +75,56 @@ void set_motor(int val){
}; };
void init_switch(){
return;
};
void blinkrattlebeep(){
led_off(LED_L|LED_R);
_delay_ms(100);
led_on(LED_L);
_delay_ms(100);
led_off(LED_L);
led_on(LED_R);
_delay_ms(100);
led_off(LED_R);
set_motor(MOTOR_ON);
_delay_ms(200);
set_motor(MOTOR_OFF);
buzzr_up();
for (int i=0; i<100; i++){
_delay_ms(2);
buzzr_inv();
};
buzzr_off();
};
void __attribute__((noreturn)) void __attribute__((noreturn))
main(void) main(void)
{ {
/* hardware initialisation: */
init_motor(); init_motor();
init_buzzr(); init_buzzr();
init_leds(); init_leds();
uint8_t mode = 0;
/* hardware initialisation: */
for(;;) /* ever */ { for(;;) /* ever */ {
//do something //do something
// led_off(LED_L|LED_R);
_delay_ms(100); //TODO: check switches and change mode
led_on(LED_L);
_delay_ms(100); switch(mode){
led_off(LED_L); case 1 : led_on(LED_L|LED_R); _delay_ms(500); led_off(LED_L|LED_R); break;
led_on(LED_R); case 2 : break;
_delay_ms(100); default : blinkrattlebeep();
led_off(LED_R);
set_motor(MOTOR_ON);
_delay_ms(200);
set_motor(MOTOR_OFF);
buzzr_up();
for (int i=0; i<100; i++){
_delay_ms(2);
buzzr_inv();
}; };
buzzr_off();
} }
/* never return 0; */ /* never return 0; */
} }