From 4a2ba4b7105d168932163cbd07a062fdf2ba00e9 Mon Sep 17 00:00:00 2001 From: sicarius Date: Sat, 17 Feb 2007 00:35:01 +0000 Subject: +++ enhanced framework hardware interface --- source/AVR_Studio/Soccer/hal/board.c | 47 ++++++++++++++++-------------------- 1 file changed, 21 insertions(+), 26 deletions(-) (limited to 'source/AVR_Studio/Soccer/hal/board.c') diff --git a/source/AVR_Studio/Soccer/hal/board.c b/source/AVR_Studio/Soccer/hal/board.c index 458ed03..9d895e8 100755 --- a/source/AVR_Studio/Soccer/hal/board.c +++ b/source/AVR_Studio/Soccer/hal/board.c @@ -16,7 +16,7 @@ Board::Board() { PORTC = 0; // Alle Low, kein Pollup // Alle Ausgänge bis auf PD0+1(I2C) + 2+3(RS232) - DDRD = (1 << PD2) | (1 << PD3) | (1 << PD4) | (1 << PD5) | (1 << PD6) | (1 << PD7); + DDRD = (1 << PD3) | (1 << PD4) | (1 << PD5) | (1 << PD6) | (1 << PD7); PORTD = (1 << PD0) | (1 << PD1); // Pollup-Widerstand an PD0+1 aktivieren // PE5 ist eingang @@ -33,11 +33,11 @@ Board::Board() { // aktiviere Kanal A+B auf PWM1 mit 8Bit TCCR1A = (1<< COM1A1) | (1<< COM1B1) | (1<< WGM10); - TCCR1B = (1< enable counter + TCCR1B = (1< enable counter // aktiviere Kanal A+B auf PWM3 mit 8Bit TCCR3A = (1<< COM3A1) | (1<< COM3B1) | (1<< WGM10); - TCCR3B = (1< enable counter + TCCR3B = (1< enable counter // Schalte Motoren auf 0 motor(0,0); @@ -49,8 +49,11 @@ Board::Board() { PORTE &= ~(1 << PE6); // Pin2 low PORTA |= (1 << PA2); // Pin1 high - // Uart-Interface einschalten - uart1_init( 10); // 9600 BAUD bei 16MHz Atmel + // Dribbler-richtung einstellen + DRIBBLER_PORT |= DRIBBLER_A; // Pin1 high + DRIBBLER_PORT &= ~DRIBBLER_B; // Pin2 low + + // aktiviere interrupt sei(); @@ -202,27 +205,6 @@ void Board::motor(int i, int speed) MOTOR2_PORT |= MOTOR2_A;//In 1 ein } } - else if(i == 3) // Dribbler... hier haben wir kein PWM - { - if(speed > 0) - { - DRIBBLER_PORT |= DRIBBLER_A;//In 1 ein - DRIBBLER_PORT &= ~DRIBBLER_B;//In 2 aus - DRIBBLER_PWMPORT |= DRIBBLER_PWM; - } - else if(speed < 0) - { - DRIBBLER_PORT |= DRIBBLER_B;//In 2 ein - DRIBBLER_PORT &= ~DRIBBLER_A;//In 1 aus - DRIBBLER_PWMPORT |= DRIBBLER_PWM; - } - else - { - DRIBBLER_PORT |= DRIBBLER_B;//In 2 ein - DRIBBLER_PORT |= DRIBBLER_A;//In 1 ein - DRIBBLER_PWMPORT &= ~DRIBBLER_PWM; - } - } } void Board::kicker() { @@ -231,6 +213,19 @@ void Board::kicker() { KICKER_AUS } +void Board::dribblerOn() { + DRIBBLER_AN +} + +void Board::dribblerOff() { + DRIBBLER_AUS +} + +void Board::dribbler(bool status) { + if(status) dribblerOn(); + else dribblerOff(); +} + //PWM routine für den Beeper ISR (TIMER0_OVF_vect) { -- cgit v1.2.3