From 62bea8d896c681c117d3b35b266b7e82f578edf2 Mon Sep 17 00:00:00 2001 From: bigalex Date: Thu, 6 Sep 2012 23:09:20 +0200 Subject: [PATCH] ggrcntrbug FTW! --- firmware/lib/bughal.c | 46 ++++++++++++++++++++++++++++++++++++++++--- firmware/lib/bughal.h | 18 +++++++++++++++-- firmware/main.c | 43 +++++++++++++++++++++++++++++++--------- 3 files changed, 93 insertions(+), 14 deletions(-) diff --git a/firmware/lib/bughal.c b/firmware/lib/bughal.c index a12c8ae..f8f093d 100644 --- a/firmware/lib/bughal.c +++ b/firmware/lib/bughal.c @@ -11,7 +11,7 @@ void init_leds(void){ //enable LED channels as output DDRC |= (1 << PORTC0) | (1 << PORTC1) | (1 << PORTC2) | (1 << PORTC3); // both LEDs off - PORTC &= ~(1 << PORTC0) | (1 << PORTC1) | (1 << PORTC2) | (1 << PORTC3); + PORTC &= ~((1 << PORTC0) | (1 << PORTC1) | (1 << PORTC2) | (1 << PORTC3)); //TCCR2A = (1 << WGM21); @@ -25,10 +25,44 @@ void init_leds(void){ return; }; -void init_buzzr(int mode){ - return; +void inline led_on(int leds){ + PORTC |= leds; }; +void inline led_off(int leds){ + PORTC &= ~leds; +}; + + + +void init_buzzr(){ + //its on B2 and C5, for reasons + DDRC |= (1 << PORTC5); + DDRB |= (1 << PORTB2); + //switch it off + buzzr_off(); + return; +}; + +void buzzr_up(){ + PORTC &= ~(1 << PORTC5); + PORTB |= (1 << PORTB2); + return; +}; + +void buzzr_down(){ + PORTC |= (1 << PORTC5); + PORTB &= ~(1 << PORTB2); +}; + +void inline buzzr_off(){ + PORTC &= ~(1 << PORTC5); + PORTB &= ~(1 << PORTB2); +}; +void buzzr_inv(){ + PORTC ^= (1 << PORTC5); + PORTB ^= (1 << PORTB2); +}; void init_switch(){ return; @@ -42,3 +76,9 @@ void init_motor(void) return; } +void set_motor(int val){ + PORTB = ~(val); + PORTB = PORTB; + return; +}; + diff --git a/firmware/lib/bughal.h b/firmware/lib/bughal.h index ef86cad..bbcfdd2 100644 --- a/firmware/lib/bughal.h +++ b/firmware/lib/bughal.h @@ -7,11 +7,25 @@ enum { BUZZR_OUT, //initialize buzzer for OUTPUT mode (emmiting soundwaves) BUZZR_IN //initialize buzzer for INPUT mode (registering soundwaves) }; - +#define LED_L (1 << PORTC0) +#define LED_R (1 << PORTC2) +#define MOTOR_ON (0<