This commit is contained in:
bigalex 2012-10-01 22:11:28 +02:00
parent ebba9c2a59
commit 4dc176676f
3 changed files with 44 additions and 3 deletions

View File

@ -70,6 +70,15 @@ void init_switch(void){
return; return;
} }
bool switch_l(void){
return PIND & 0b00000010;
};
bool switch_r(void){
return PIND & 0b00000001;
};
void init_motor(void) void init_motor(void)
{ {
/* vibration motor on B1, initially off: */ /* vibration motor on B1, initially off: */

View File

@ -1,6 +1,8 @@
#ifndef BUGHAL_H #ifndef BUGHAL_H
#define BUGHAL_H #define BUGHAL_H
#include <stdbool.h>
/* Hardware abstraction layer for Pentabug hardware */ /* Hardware abstraction layer for Pentabug hardware */
enum { BUZZR_OUT, //initialize buzzer for OUTPUT mode (emmiting soundwaves) enum { BUZZR_OUT, //initialize buzzer for OUTPUT mode (emmiting soundwaves)
@ -23,9 +25,13 @@ void buzzr_off(void);
void buzzr_inv(void); void buzzr_inv(void);
void init_switch(void); void init_switch(void);
bool switch_l(void); //switch pressed?
bool switch_r(void); //switch pressed?
void init_motor(void); void init_motor(void);
void set_motor(int); void set_motor(int);
#endif #endif

View File

@ -32,7 +32,6 @@ main(void)
uint8_t ledmode =0; uint8_t ledmode =0;
uint16_t ct =0; uint16_t ct =0;
led_on(LED_R); led_on(LED_R);
timer_set(&t, 100); timer_set(&t, 100);
for(;;) /* ever */ { for(;;) /* ever */ {
//do something //do something
@ -48,9 +47,36 @@ main(void)
led_off(LED_L); led_off(LED_L);
}; };
timer_set(&t, 1);
USART0_crlf(); USART0_crlf();
USART0_put_uint16(ct); if (0==ct%3){
if (0==ct%5){
//fizzbug
USART0_putc('f');
USART0_putc('i');
USART0_putc('z');
USART0_putc('z');
USART0_putc('b');
USART0_putc('u');
USART0_putc('g');
} else {
//fizz
USART0_putc('f');
USART0_putc('i');
USART0_putc('z');
USART0_putc('z');
}
} else {
if (0==ct%5){
//bug
USART0_putc('b');
USART0_putc('u');
USART0_putc('g');
} else {
USART0_put_uint16(ct);
};
};
timer_set(&t, 50);
ct++; ct++;
}; //end if timer expired }; //end if timer expired