diff options
Diffstat (limited to 'source/AVR_Studio/Soccer/hal')
-rwxr-xr-x | source/AVR_Studio/Soccer/hal/board.c | 47 | ||||
-rwxr-xr-x | source/AVR_Studio/Soccer/hal/board.h | 14 | ||||
-rwxr-xr-x | source/AVR_Studio/Soccer/hal/keylcd.c | 15 | ||||
-rwxr-xr-x | source/AVR_Studio/Soccer/hal/keylcd.h | 8 |
4 files changed, 37 insertions, 47 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)
{
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 <avr/io.h>
#include <avr/interrupt.h>
#include <stdlib.h>
-#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<len; i++) buf[i] = uint8_t(data[i]);
-
- i2c.send(I2C_KEYLCD, buf, len);
+ uart1_puts(data);
}
// Löscht das keyLCD
@@ -23,6 +19,3 @@ void KeyLCD::clear() { }
-uint8_t KeyLCD::error() {
- return i2c.error();
-}
diff --git a/source/AVR_Studio/Soccer/hal/keylcd.h b/source/AVR_Studio/Soccer/hal/keylcd.h index 590c0cb..9403aa6 100755 --- a/source/AVR_Studio/Soccer/hal/keylcd.h +++ b/source/AVR_Studio/Soccer/hal/keylcd.h @@ -1,22 +1,18 @@ #ifndef _KEYLCD_H_
#define _KEYLCD_H_
-#include "i2c.h"
+//#include "i2c.h"
#include "string.h"
-
-#define I2C_KEYLCD 2
-#define LCD_CMD_PRINTSTR 0
+#include "uart.h"
class KeyLCD
{
private:
- I2C i2c;
public:
KeyLCD();
~KeyLCD();
void print(char* data);
- uint8_t error();
void clear();
};
|