summaryrefslogtreecommitdiffstats
path: root/source/AVR_Studio/Soccer/hal/board.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/AVR_Studio/Soccer/hal/board.c')
-rwxr-xr-xsource/AVR_Studio/Soccer/hal/board.c47
1 files changed, 21 insertions, 26 deletions
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<<ICNC1) | (1<<CS12) | (1<<CS10); // set clock/prescaler 1/1024 -> enable counter
+ TCCR1B = (1<<ICNC1) | (1<<CS11); // | (1<<CS12) | (1<<CS10); // set clock/prescaler 1/1024 -> enable counter
// aktiviere Kanal A+B auf PWM3 mit 8Bit
TCCR3A = (1<< COM3A1) | (1<< COM3B1) | (1<< WGM10);
- TCCR3B = (1<<ICNC3) | (1<<CS32) | (1<<CS30); // set clock/prescaler 1/1024 -> enable counter
+ TCCR3B = (1<<ICNC3) | (1<<CS31); // | (1<<CS32) | (1<<CS30); // set clock/prescaler 1/1024 -> 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)
{