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 ++++++++++++++++------------------- source/AVR_Studio/Soccer/hal/board.h | 14 ++++++++--- source/AVR_Studio/Soccer/hal/keylcd.c | 15 +++-------- source/AVR_Studio/Soccer/hal/keylcd.h | 8 ++---- 4 files changed, 37 insertions(+), 47 deletions(-) (limited to 'source/AVR_Studio/Soccer/hal') 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) { diff --git a/source/AVR_Studio/Soccer/hal/board.h b/source/AVR_Studio/Soccer/hal/board.h index a76aeb7..e608836 100755 --- a/source/AVR_Studio/Soccer/hal/board.h +++ b/source/AVR_Studio/Soccer/hal/board.h @@ -4,7 +4,7 @@ #include #include #include -#include "uart.h" +//#include "uart.h" #include "../global.h" //#define abs(a) ((a < 0)? -a : a) @@ -26,10 +26,12 @@ #define MOTOR2_PWM OCR3A #define MOTOR2_A (1 << 5) #define MOTOR2_B (1 << 4) - + + +// Dribbler #define DRIBBLER_PORT PORTD -#define DRIBBLER_PWMPORT PORTA -#define DRIBBLER_PWM (1 << 5) +#define DRIBBLER_AN PORTA |= (1 << 5); +#define DRIBBLER_AUS PORTA &= ~(1 << 5); #define DRIBBLER_A (1 << 6) #define DRIBBLER_B (1 << 7) @@ -62,6 +64,10 @@ public: void led(bool status); void motor(int i, int speed); void kicker(); + + void dribbler(bool status); + void dribblerOn(); + void dribblerOff(); }; #endif diff --git a/source/AVR_Studio/Soccer/hal/keylcd.c b/source/AVR_Studio/Soccer/hal/keylcd.c index fb2efa6..4b98f75 100755 --- a/source/AVR_Studio/Soccer/hal/keylcd.c +++ b/source/AVR_Studio/Soccer/hal/keylcd.c @@ -1,7 +1,8 @@ #include "keylcd.h" -KeyLCD::KeyLCD() : i2c() { - +KeyLCD::KeyLCD() { + // Uart-Interface einschalten + uart1_init( 103); // 9600 BAUD bei 16MHz Atmel } KeyLCD::~KeyLCD() { @@ -10,12 +11,7 @@ KeyLCD::~KeyLCD() { // Gibt Daten auf dem keyLCD aus void KeyLCD::print(char *data) { - int len=strlen(data); - uint8_t buf[len+1]; - - for (int i=0; i