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,16 +17,6 @@ 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));
//TCCR2A = (1 << WGM21);
//TCCR2B = (1 << CS20)|(1 << CS21);
//OCR2A = 255; /* TOP */
// TCNT2 = 0;
// /*enable interrupt*/
// TIMSK2 |= (1<<OCIE2A);
return; return;
}; };
@ -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,21 +75,12 @@ void set_motor(int val){
}; };
void init_switch(){
return;
};
void __attribute__((noreturn)) void blinkrattlebeep(){
main(void) led_off(LED_L|LED_R);
{
init_motor();
init_buzzr();
init_leds();
/* hardware initialisation: */
for(;;) /* ever */ {
//do something
// led_off(LED_L|LED_R);
_delay_ms(100); _delay_ms(100);
led_on(LED_L); led_on(LED_L);
_delay_ms(100); _delay_ms(100);
@ -113,14 +91,40 @@ main(void)
set_motor(MOTOR_ON); set_motor(MOTOR_ON);
_delay_ms(200); _delay_ms(200);
set_motor(MOTOR_OFF); set_motor(MOTOR_OFF);
buzzr_up(); buzzr_up();
for (int i=0; i<100; i++){ for (int i=0; i<100; i++){
_delay_ms(2); _delay_ms(2);
buzzr_inv(); buzzr_inv();
}; };
buzzr_off(); buzzr_off();
};
void __attribute__((noreturn))
main(void)
{
/* hardware initialisation: */
init_motor();
init_buzzr();
init_leds();
uint8_t mode = 0;
for(;;) /* ever */ {
//do something
//TODO: check switches and change mode
switch(mode){
case 1 : led_on(LED_L|LED_R); _delay_ms(500); led_off(LED_L|LED_R); break;
case 2 : break;
default : blinkrattlebeep();
};
} }
/* never return 0; */ /* never return 0; */
} }