From ba182f0ee0d0dbc798e4c782655f440339dcffdd Mon Sep 17 00:00:00 2001 From: masterm Date: Fri, 16 Feb 2007 15:22:03 +0000 Subject: +++ added AVR_Studio compatibility for framework --- source/Concept/Framework/RoboCode.aps | 1 + source/Concept/Framework/atmega128io.h | 3 + source/Concept/Framework/default/Makefile | 103 ++++++++++++++++++++++++++++++ source/Concept/Framework/defines.h | 2 +- source/Concept/Framework/engine.h | 6 +- source/Concept/Framework/robot.cpp | 7 +- source/Concept/Framework/stdafx.h | 3 +- source/Concept/Framework/tools.cpp | 4 +- source/Concept/Framework/tools.h | 6 +- 9 files changed, 124 insertions(+), 11 deletions(-) create mode 100644 source/Concept/Framework/RoboCode.aps create mode 100644 source/Concept/Framework/default/Makefile (limited to 'source') diff --git a/source/Concept/Framework/RoboCode.aps b/source/Concept/Framework/RoboCode.aps new file mode 100644 index 0000000..3864c4f --- /dev/null +++ b/source/Concept/Framework/RoboCode.aps @@ -0,0 +1 @@ +RoboCode16-Feb-2007 15:16:4616-Feb-2007 16:19:25241016-Feb-2007 15:16:4644, 12, 0, 462AVR GCCdefault\RoboCode.elfI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\falseR00R01R02R03R04R05R06R07R08R09R10R11R12R13R14R15R16R17R18R19R20R21R22R23R24R25R26R27R28R29R30R31000main.cppsensor.cpptools.cppatmega128io.cppdistance_sensor.cppengine.cppio_module.cppir_sensor.cppkicker.cppled.cpprobot.cppsensor.hstdafx.htools.hatmega128io.hdefines.hdistance_sensor.hengine.hio_module.hir_sensor.hkicker.hled.hrobot.hdefault\MakefiledefaultYESdefault\Makefileatmega128100RoboCode.elfdefault\1-Wall -gdwarf-2 -O0 -fsigned-chardefault1G:\_Tools\Winavr\bin\avr-gcc.exeG:\_Tools\Winavr\utils\bin\make.exeI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\sensor.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\stdafx.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\tools.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\atmega128io.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\defines.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\distance_sensor.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\engine.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\io_module.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\ir_sensor.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\kicker.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\led.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\robot.hI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\main.cppI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\sensor.cppI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\tools.cppI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\atmega128io.cppI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\distance_sensor.cppI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\engine.cppI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\io_module.cppI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\ir_sensor.cppI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\kicker.cppI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\led.cppI:\Projects\RoboCup WM 2006 07\trunk\rc2007-soccer\source\Concept\Framework\robot.cpp00000stdafx.h100001engine.h100002defines.h100003io_module.h100004robot.h100005robot.cpp100006atmega128io.h100007main.cpp100008tools.cpp100009tools.h1331 119 937 3937 24353 141 953 387123 3375 163 975 409107 8397 185 997 43116 0419 207 1019 4533 19309 97 909 34344 0353 141 953 3874 26375 163 975 4095 0397 185 997 4312 11419 207 1019 4535 11 diff --git a/source/Concept/Framework/atmega128io.h b/source/Concept/Framework/atmega128io.h index 94912b6..a6044c4 100644 --- a/source/Concept/Framework/atmega128io.h +++ b/source/Concept/Framework/atmega128io.h @@ -1,6 +1,9 @@ #ifndef _ATMEGA128IO_H #define _ATMEGA128IO_H +#include +#include + namespace hardware { diff --git a/source/Concept/Framework/default/Makefile b/source/Concept/Framework/default/Makefile new file mode 100644 index 0000000..ca32983 --- /dev/null +++ b/source/Concept/Framework/default/Makefile @@ -0,0 +1,103 @@ +############################################################################### +# Makefile for the project RoboCode +############################################################################### + +## General Flags +PROJECT = RoboCode +MCU = atmega128 +TARGET = RoboCode.elf +CC = avr-gcc.exe + +## Options common to compile, link and assembly rules +COMMON = -mmcu=$(MCU) + +## Compile options common for all C compilation units. +CFLAGS = $(COMMON) +CFLAGS += -Wall -gdwarf-2 -O0 +CFLAGS += -MD -MP -MT $(*F).o -MF dep/$(@F).d + +## Assembly specific flags +ASMFLAGS = $(COMMON) +ASMFLAGS += -x assembler-with-cpp -Wa,-gdwarf2 + +## Linker flags +LDFLAGS = $(COMMON) +LDFLAGS += + + +## Intel Hex file production flags +HEX_FLASH_FLAGS = -R .eeprom + +HEX_EEPROM_FLAGS = -j .eeprom +HEX_EEPROM_FLAGS += --set-section-flags=.eeprom="alloc,load" +HEX_EEPROM_FLAGS += --change-section-lma .eeprom=0 + + +## Objects that must be built in order to link +OBJECTS = main.o sensor.o tools.o atmega128io.o distance_sensor.o engine.o io_module.o ir_sensor.o kicker.o led.o robot.o + +## Objects explicitly added by the user +LINKONLYOBJECTS = + +## Build +all: $(TARGET) RoboCode.hex RoboCode.eep size + +## Compile +main.o: ../main.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +tools.o: ../tools.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +io_module.o: ../io_module.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +robot.o: ../robot.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +sensor.o: ../sensor.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +engine.o: ../engine.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +led.o: ../led.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +ir_sensor.o: ../ir_sensor.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +distance_sensor.o: ../distance_sensor.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +kicker.o: ../kicker.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +atmega128io.o: ../atmega128io.cpp + $(CC) $(INCLUDES) $(CFLAGS) -c $< + +##Link +$(TARGET): $(OBJECTS) + $(CC) $(LDFLAGS) $(OBJECTS) $(LINKONLYOBJECTS) $(LIBDIRS) $(LIBS) -o $(TARGET) + +%.hex: $(TARGET) + avr-objcopy -O ihex $(HEX_FLASH_FLAGS) $< $@ + +%.eep: $(TARGET) + avr-objcopy $(HEX_EEPROM_FLAGS) -O ihex $< $@ + +%.lss: $(TARGET) + avr-objdump -h -S $< > $@ + +size: ${TARGET} + @echo + @avr-size -C --mcu=${MCU} ${TARGET} + +## Clean target +.PHONY: clean +clean: + -rm -rf $(OBJECTS) RoboCode.elf dep/* RoboCode.hex RoboCode.eep + +## Other dependencies +-include $(shell mkdir dep 2>/dev/null) $(wildcard dep/*) + diff --git a/source/Concept/Framework/defines.h b/source/Concept/Framework/defines.h index 15e6c35..1b14aa7 100644 --- a/source/Concept/Framework/defines.h +++ b/source/Concept/Framework/defines.h @@ -18,7 +18,7 @@ #ifdef __int16 #define int16 __int16 #else - #define int16 short + #define int16 int #endif #endif diff --git a/source/Concept/Framework/engine.h b/source/Concept/Framework/engine.h index 6454a32..2d8c409 100644 --- a/source/Concept/Framework/engine.h +++ b/source/Concept/Framework/engine.h @@ -120,15 +120,15 @@ public: if(pwmSpeed) { - *pwmSpeed = uint16(abs(newSpeed / SPEED_PER_PWM)); + *pwmSpeed = abs(newSpeed / SPEED_PER_PWM); } - else if(pwmPort && uint16(abs(newSpeed / SPEED_PER_PWM))) + else if(pwmPort && (uint16)(abs(newSpeed / SPEED_PER_PWM))) { *pwmPort |= pinPwm; } else if(pwmPort) { - *pwmPort &= ~pinPwn; + *pwmPort &= ~pinPwm; } UpdateDirection(); diff --git a/source/Concept/Framework/robot.cpp b/source/Concept/Framework/robot.cpp index 3d3ae48..f14f2f7 100644 --- a/source/Concept/Framework/robot.cpp +++ b/source/Concept/Framework/robot.cpp @@ -45,7 +45,10 @@ Robot::Robot() sei(); //Interface - memset(modules, NULL, sizeof(modules)); + for(uint8 i = 0; i < IO_END; i++) + { + modules[i] = NULL; + } } //----------------------------------------------------------------------------- @@ -120,7 +123,7 @@ uint16 Robot::GetADCValue(uint8 channel) result /= 3; - return uint16(result); + return (uint16)(result); } //--- EOF --- diff --git a/source/Concept/Framework/stdafx.h b/source/Concept/Framework/stdafx.h index 436f117..218b774 100644 --- a/source/Concept/Framework/stdafx.h +++ b/source/Concept/Framework/stdafx.h @@ -4,7 +4,8 @@ #include #endif -#include "defines.h" +#include "defines.h" +#include "atmega128io.h" #include "tools.h" #include "io_module.h" #include "sensor.h" diff --git a/source/Concept/Framework/tools.cpp b/source/Concept/Framework/tools.cpp index 625ef20..6fd107c 100644 --- a/source/Concept/Framework/tools.cpp +++ b/source/Concept/Framework/tools.cpp @@ -1,6 +1,6 @@ #include "tools.h" -#ifndef __cplusplus +#ifndef new //----------------------------------------------------------------------------- void* operator new(size_t sz) @@ -14,4 +14,4 @@ void operator delete(void* p) free(p); } -#endif \ No newline at end of file +#endif diff --git a/source/Concept/Framework/tools.h b/source/Concept/Framework/tools.h index 9cd38f2..2af60df 100644 --- a/source/Concept/Framework/tools.h +++ b/source/Concept/Framework/tools.h @@ -1,7 +1,9 @@ #ifndef _TOOLS_H -#define _TOOLS_H +#define _TOOLS_H + +#include -#ifndef __cplusplus +#ifndef new void* operator new(size_t sz); void operator delete(void* p); #endif -- cgit v1.2.3