--- /dev/null
+#include "ETBalanceRunner.h"\r
+#include "Motor.h"\r
+#include "GyroSensor.h"\r
+#include "Nxt.h"\r
+\r
+extern "C" {\r
+#include "balancer.h"\r
+}\r
+\r
+namespace ecrobot{\r
+\r
+ETBalanceRunner::ETBalanceRunner(Motor& motorL, Motor& motorR, GyroSensor& gyro, Nxt& nxt)\r
+ : m_motorL(motorL), m_motorR(motorR), m_gyro(gyro), m_nxt(nxt), m_gyrooffset(610)\r
+{\r
+}\r
+ETBalanceRunner::~ETBalanceRunner(void)\r
+{\r
+}\r
+void ETBalanceRunner::Run(int forward, int turn)\r
+{\r
+ S8 r,l;\r
+ balance_control(forward,turn,m_gyro.getAnglerVelocity(),m_gyrooffset,m_motorL.getCount(),m_motorR.getCount(),m_nxt.getBattMv(),&l,&r);\r
+ m_motorL.setPWM(l);\r
+ m_motorR.setPWM(r);\r
+}\r
+void ETBalanceRunner::SetGyroOffset(int offset)\r
+{\r
+ m_gyrooffset = offset;\r
+}\r
+\r
+}\r
--- /dev/null
+#pragma once\r
+#include "Runner.h"\r
+\r
+namespace ecrobot{\r
+\r
+class Motor;\r
+class GyroSensor;\r
+class Nxt;\r
+\r
+class ETBalanceRunner : public Runner\r
+{\r
+ Motor& m_motorL;\r
+ Motor& m_motorR;\r
+ GyroSensor& m_gyro;\r
+ Nxt& m_nxt;\r
+ int m_gyrooffset;\r
+public:\r
+ ETBalanceRunner(Motor& motorL, Motor& motorR, GyroSensor& gyro, Nxt& nxt);\r
+ virtual ~ETBalanceRunner(void);\r
+ //\r
+ virtual void Run(int forward, int turn);\r
+ void SetGyroOffset(int offset);\r
+};\r
+\r
+}\r
--- /dev/null
+#include "ETLinePos.h"\r
+#include "LightSensor.h"\r
+\r
+namespace ecrobot{\r
+\r
+ETLinePos::ETLinePos(LightSensor& light)\r
+ : m_light(light), m_black(0), m_white(1000)\r
+{\r
+}\r
+ETLinePos::~ETLinePos(void)\r
+{\r
+}\r
+int ETLinePos::GetLinePos()\r
+{\r
+ static const int range = 100; // -range <= result <= range \82É\90³\8bK\89»\82µ\82Ü\82·\r
+ return (m_light.getBrightness() - (m_white + m_black) / 2) * range / (m_white - m_black);\r
+}\r
+void ETLinePos::SetBlack(int value)\r
+{\r
+ m_black = value;\r
+}\r
+void ETLinePos::SetWhite(int value)\r
+{\r
+ m_white = value;\r
+}\r
+\r
+}\r
--- /dev/null
+#pragma once\r
+#include "LinePos.h"\r
+\r
+namespace ecrobot{\r
+\r
+class LightSensor;\r
+\r
+class ETLinePos : public LinePos\r
+{\r
+ LightSensor& m_light;\r
+ int m_black;\r
+ int m_white;\r
+public:\r
+ ETLinePos(LightSensor& light);\r
+ virtual ~ETLinePos(void);\r
+ //\r
+ virtual int GetLinePos();\r
+ void SetBlack(int value);\r
+ void SetWhite(int value);\r
+};\r
+\r
+}\r
--- /dev/null
+#include "ETLineTracer.h"\r
+\r
+ETLineTracer::ETLineTracer(LinePos& linepos, Runner& runner)\r
+ : LineTracer(linepos,runner)\r
+{\r
+}\r
+ETLineTracer::~ETLineTracer(void)\r
+{\r
+}\r
+void ETLineTracer::CalcOutput(int speed, int linepos, int& forward, int& turn)\r
+{\r
+ // \82Æ\82è\82 \82¦\82¸\82Ì\8eÀ\91\95\r
+ forward = speed * 3 / 10;\r
+ if(linepos > 0){\r
+ turn = 50;\r
+ }else{\r
+ turn = -50;\r
+ }\r
+}\r
--- /dev/null
+#pragma once\r
+#include "LineTracer.h"\r
+class ETLineTracer : public LineTracer\r
+{\r
+public:\r
+ ETLineTracer(LinePos& linepos, Runner& runner);\r
+ virtual ~ETLineTracer(void);\r
+ //\r
+private:\r
+ virtual void CalcOutput(int speed, int linepos, int& forward, int& turn);\r
+};\r
--- /dev/null
+#include "LinePos.h"\r
+\r
+LinePos::LinePos(void)\r
+{\r
+}\r
+LinePos::~LinePos(void)\r
+{\r
+}\r
--- /dev/null
+#pragma once\r
+class LinePos\r
+{\r
+public:\r
+ LinePos(void);\r
+ virtual ~LinePos(void);\r
+ //\r
+ virtual int GetLinePos() = 0;\r
+};\r
--- /dev/null
+#include "LineTracer.h"\r
+#include "LinePos.h"\r
+#include "Runner.h"\r
+\r
+LineTracer::LineTracer(LinePos& linepos, Runner& runner)\r
+ : m_linepos(linepos), m_runner(runner)\r
+{\r
+}\r
+LineTracer::~LineTracer(void)\r
+{\r
+}\r
+void LineTracer::RunTrace(int speed)\r
+{\r
+ int forward = 0;\r
+ int turn = 0;\r
+ CalcOutput(speed,m_linepos.GetLinePos(),forward,turn);\r
+ m_runner.Run(forward,turn);\r
+}\r
--- /dev/null
+#pragma once\r
+\r
+class LinePos;\r
+class Runner;\r
+\r
+class LineTracer\r
+{\r
+ LinePos& m_linepos;\r
+ Runner& m_runner;\r
+public:\r
+ LineTracer(LinePos& linepos, Runner& runner);\r
+ virtual ~LineTracer(void);\r
+ //\r
+ void RunTrace(int speed);\r
+private:\r
+ virtual void CalcOutput(int speed, int linepos, int& forward, int& turn) = 0;\r
+};\r
+\r
--- /dev/null
+#include "Runner.h"\r
+\r
+Runner::Runner(void)\r
+{\r
+}\r
+Runner::~Runner(void)\r
+{\r
+}\r
--- /dev/null
+#pragma once\r
+class Runner\r
+{\r
+public:\r
+ Runner(void);\r
+ virtual ~Runner(void);\r
+ //\r
+ virtual void Run(int forward,int turn) = 0;\r
+};\r
--- /dev/null
+\r
+Microsoft Visual Studio Solution File, Format Version 12.00\r
+# Visual Studio Express 2012 for Windows Desktop\r
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Tonden", "Tonden.vcxproj", "{F7231682-384E-4B78-A729-5CAED4A512F1}"\r
+EndProject\r
+Global\r
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution\r
+ Debug|Win32 = Debug|Win32\r
+ Release|Win32 = Release|Win32\r
+ EndGlobalSection\r
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution\r
+ {F7231682-384E-4B78-A729-5CAED4A512F1}.Debug|Win32.ActiveCfg = Debug|Win32\r
+ {F7231682-384E-4B78-A729-5CAED4A512F1}.Debug|Win32.Build.0 = Debug|Win32\r
+ {F7231682-384E-4B78-A729-5CAED4A512F1}.Release|Win32.ActiveCfg = Release|Win32\r
+ {F7231682-384E-4B78-A729-5CAED4A512F1}.Release|Win32.Build.0 = Release|Win32\r
+ EndGlobalSection\r
+ GlobalSection(SolutionProperties) = preSolution\r
+ HideSolutionNode = FALSE\r
+ EndGlobalSection\r
+EndGlobal\r
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <ItemGroup Label="ProjectConfigurations">\r
+ <ProjectConfiguration Include="Debug|Win32">\r
+ <Configuration>Debug</Configuration>\r
+ <Platform>Win32</Platform>\r
+ </ProjectConfiguration>\r
+ <ProjectConfiguration Include="Release|Win32">\r
+ <Configuration>Release</Configuration>\r
+ <Platform>Win32</Platform>\r
+ </ProjectConfiguration>\r
+ </ItemGroup>\r
+ <PropertyGroup Label="Globals">\r
+ <ProjectGuid>{F7231682-384E-4B78-A729-5CAED4A512F1}</ProjectGuid>\r
+ <Keyword>MakeFileProj</Keyword>\r
+ </PropertyGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">\r
+ <ConfigurationType>Makefile</ConfigurationType>\r
+ <UseDebugLibraries>true</UseDebugLibraries>\r
+ <PlatformToolset>v110</PlatformToolset>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">\r
+ <ConfigurationType>Makefile</ConfigurationType>\r
+ <UseDebugLibraries>false</UseDebugLibraries>\r
+ <PlatformToolset>v110</PlatformToolset>\r
+ </PropertyGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />\r
+ <ImportGroup Label="ExtensionSettings">\r
+ </ImportGroup>\r
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+ </ImportGroup>\r
+ <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />\r
+ </ImportGroup>\r
+ <PropertyGroup Label="UserMacros" />\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">\r
+ <NMakeBuildCommandLine>make all</NMakeBuildCommandLine>\r
+ <NMakeCleanCommandLine>make clean</NMakeCleanCommandLine>\r
+ <NMakeReBuildCommandLine>make all</NMakeReBuildCommandLine>\r
+ <NMakePreprocessorDefinitions>WIN32;_DEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>\r
+ <IncludePath>C:\cygwin\nxtOSEK\lejos_nxj\src\nxtvm\platform\nxt;C:\cygwin\nxtOSEK\toppers_osek\kernel;C:\cygwin\nxtOSEK\toppers_osek\include;C:\cygwin\nxtOSEK\ecrobot\nxtway_gs_balancer;C:\cygwin\nxtOSEK\ecrobot\c;C:\cygwin\nxtOSEK\ecrobot\c++\device;$(IncludePath)</IncludePath>\r
+ </PropertyGroup>\r
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">\r
+ <NMakeBuildCommandLine>make all</NMakeBuildCommandLine>\r
+ <NMakeOutput>rxeflash.sh</NMakeOutput>\r
+ <NMakeCleanCommandLine>make clean</NMakeCleanCommandLine>\r
+ <NMakeReBuildCommandLine>make all</NMakeReBuildCommandLine>\r
+ <NMakePreprocessorDefinitions>WIN32;NDEBUG;$(NMakePreprocessorDefinitions)</NMakePreprocessorDefinitions>\r
+ <IncludePath>C:\cygwin\nxtOSEK\lejos_nxj\src\nxtvm\platform\nxt;C:\cygwin\nxtOSEK\toppers_osek\kernel;C:\cygwin\nxtOSEK\toppers_osek\include;C:\cygwin\nxtOSEK\ecrobot\nxtway_gs_balancer;C:\cygwin\nxtOSEK\ecrobot\c;C:\cygwin\nxtOSEK\ecrobot\c++\device;$(IncludePath)</IncludePath>\r
+ </PropertyGroup>\r
+ <ItemDefinitionGroup>\r
+ </ItemDefinitionGroup>\r
+ <ItemGroup>\r
+ <Text Include="readme.txt" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <None Include="main.oil" />\r
+ <None Include="Makefile" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ClCompile Include="balancer_param.c" />\r
+ <ClCompile Include="ETBalanceRunner.cpp" />\r
+ <ClCompile Include="ETLinePos.cpp" />\r
+ <ClCompile Include="ETLineTracer.cpp" />\r
+ <ClCompile Include="LinePos.cpp" />\r
+ <ClCompile Include="LineTracer.cpp" />\r
+ <ClCompile Include="main.cpp" />\r
+ <ClCompile Include="Runner.cpp" />\r
+ <ClCompile Include="tsprintf.c" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ClInclude Include="ETBalanceRunner.h" />\r
+ <ClInclude Include="ETLinePos.h" />\r
+ <ClInclude Include="ETLineTracer.h" />\r
+ <ClInclude Include="LinePos.h" />\r
+ <ClInclude Include="LineTracer.h" />\r
+ <ClInclude Include="Runner.h" />\r
+ <ClInclude Include="tsprintf.h" />\r
+ </ItemGroup>\r
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />\r
+ <ImportGroup Label="ExtensionTargets">\r
+ </ImportGroup>\r
+</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <ItemGroup>\r
+ <Filter Include="ソース ファイル">\r
+ <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\r
+ <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\r
+ </Filter>\r
+ <Filter Include="ヘッダー ファイル">\r
+ <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\r
+ <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\r
+ </Filter>\r
+ <Filter Include="リソース ファイル">\r
+ <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\r
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\r
+ </Filter>\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <Text Include="readme.txt" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <None Include="Makefile" />\r
+ <None Include="main.oil" />\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ClCompile Include="main.cpp">\r
+ <Filter>ソース ファイル</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="tsprintf.c">\r
+ <Filter>ソース ファイル</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="LineTracer.cpp">\r
+ <Filter>ソース ファイル</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="ETLineTracer.cpp">\r
+ <Filter>ソース ファイル</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="LinePos.cpp">\r
+ <Filter>ソース ファイル</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="Runner.cpp">\r
+ <Filter>ソース ファイル</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="ETLinePos.cpp">\r
+ <Filter>ソース ファイル</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="ETBalanceRunner.cpp">\r
+ <Filter>ソース ファイル</Filter>\r
+ </ClCompile>\r
+ <ClCompile Include="balancer_param.c">\r
+ <Filter>ソース ファイル</Filter>\r
+ </ClCompile>\r
+ </ItemGroup>\r
+ <ItemGroup>\r
+ <ClInclude Include="tsprintf.h">\r
+ <Filter>ヘッダー ファイル</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="LineTracer.h">\r
+ <Filter>ヘッダー ファイル</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="ETLineTracer.h">\r
+ <Filter>ヘッダー ファイル</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="LinePos.h">\r
+ <Filter>ヘッダー ファイル</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="Runner.h">\r
+ <Filter>ヘッダー ファイル</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="ETLinePos.h">\r
+ <Filter>ヘッダー ファイル</Filter>\r
+ </ClInclude>\r
+ <ClInclude Include="ETBalanceRunner.h">\r
+ <Filter>ヘッダー ファイル</Filter>\r
+ </ClInclude>\r
+ </ItemGroup>\r
+</Project>
\ No newline at end of file
--- /dev/null
+<?xml version="1.0" encoding="utf-8"?>\r
+<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">\r
+ <PropertyGroup />\r
+</Project>
\ No newline at end of file
--- /dev/null
+/**\r
+ *******************************************************************************\r
+ ** \83t\83@\83C\83\8b\96¼ : balancer_param.c\r
+ **\r
+ ** \8aT\97v : \93|\97§\90U\8eq\90§\8cä\83p\83\89\83\81\81[\83^\r
+ **\r
+ ** \92\8d\8bL : \93|\97§\90U\8eq\90§\8cä\83p\83\89\83\81\81[\83^\82Í\90§\8cä\93Á\90«\82É\91å\82«\82È\89e\8b¿\82ð\97^\82¦\82Ü\82·\81B\r
+ **\r
+ *******************************************************************************\r
+ **/\r
+\r
+/*============================================================================\r
+ * \83f\81[\83^\92è\8b`\r
+ *===========================================================================*/\r
+float A_D = 0.8F; /* \83\8d\81[\83p\83X\83t\83B\83\8b\83^\8cW\90\94(\8d¶\89E\8eÔ\97Ö\82Ì\95½\8bÏ\89ñ\93]\8ap\93x\97p) */\r
+float A_R = 0.996F; /* \83\8d\81[\83p\83X\83t\83B\83\8b\83^\8cW\90\94(\8d¶\89E\8eÔ\97Ö\82Ì\96Ú\95W\95½\8bÏ\89ñ\93]\8ap\93x\97p) */\r
+\r
+/* \8fó\91Ô\83t\83B\81[\83h\83o\83b\83N\8cW\90\94\r
+ * K_F[0]: \8eÔ\97Ö\89ñ\93]\8ap\93x\8cW\90\94\r
+ * K_F[1]: \8eÔ\91Ì\8cX\8eÎ\8ap\93x\8cW\90\94\r
+ * K_F[2]: \8eÔ\97Ö\89ñ\93]\8ap\91¬\93x\8cW\90\94\r
+ * K_F[3]: \8eÔ\91Ì\8cX\8eÎ\8ap\91¬\93x\8cW\90\94\r
+ */\r
+float K_F[4] = {-0.870303F, -31.9978F, -1.1566F, -2.78873F};\r
+float K_I = -0.44721F; /* \83T\81[\83{\90§\8cä\97p\90Ï\95ª\83t\83B\81[\83h\83o\83b\83N\8cW\90\94 */\r
+\r
+//float K_PHIDOT = 25.0F; /* \8eÔ\91Ì\96Ú\95W\90ù\89ñ\8ap\91¬\93x\8cW\90\94 */\r
+float K_PHIDOT = 25.0F*2.5F; /* \8eÔ\91Ì\96Ú\95W\90ù\89ñ\8ap\91¬\93x\8cW\90\94 */\r
+float K_THETADOT = 7.5F; /* \83\82\81[\83^\96Ú\95W\89ñ\93]\8ap\91¬\93x\8cW\90\94 */\r
+\r
+const float BATTERY_GAIN = 0.001089F; /* PWM\8fo\97Í\8eZ\8fo\97p\83o\83b\83e\83\8a\93d\88³\95â\90³\8cW\90\94 */\r
+const float BATTERY_OFFSET = 0.625F; /* PWM\8fo\97Í\8eZ\8fo\97p\83o\83b\83e\83\8a\93d\88³\95â\90³\83I\83t\83Z\83b\83g */\r
+\r
+/******************************** END OF FILE ********************************/\r
--- /dev/null
+/* main.cpp for TOPPERS/ATK(OSEK) */ \r
+\r
+// ECRobot++ API\r
+#include "Lcd.h"\r
+#include "BlueTooth.h"\r
+#include "Clock.h"\r
+#include "GyroSensor.h"\r
+#include "LightSensor.h"\r
+#include "Motor.h"\r
+#include "Nxt.h"\r
+#include "SonarSensor.h"\r
+#include "Speaker.h"\r
+#include "TouchSensor.h"\r
+\r
+#include "tsprintf.h"\r
+#include "ETLineTracer.h"\r
+#include "ETLinePos.h"\r
+#include "ETBalanceRunner.h"\r
+\r
+using namespace ecrobot;\r
+\r
+extern "C"\r
+{\r
+#include "kernel.h"\r
+#include "kernel_id.h"\r
+#include "ecrobot_interface.h"\r
+\r
+DeclareCounter(SysTimerCnt);//Alarm\97\98\97p\8e\9e\95K\97v\r
+\r
+// global object instances\r
+Nxt nxt;\r
+Lcd lcd;\r
+Speaker speaker;\r
+Bluetooth bt;\r
+Clock clock;\r
+GyroSensor gyro(PORT_1);\r
+SonarSensor sonar(PORT_2);\r
+LightSensor light(PORT_3);\r
+TouchSensor touch(PORT_4);\r
+Motor motorT(PORT_A);\r
+Motor motorR(PORT_B);\r
+Motor motorL(PORT_C);\r
+\r
+ETBalanceRunner runner(motorL,motorR,gyro,nxt);\r
+ETLinePos linepos(light);\r
+ETLineTracer tracer(linepos,runner);\r
+\r
+// nxtOSEK hook to be invoked from an ISR in category 2\r
+void user_1ms_isr_type2(void)\r
+{\r
+ // //Sleep\97\98\97p\8e\9e\95K\97v\r
+ SleeperMonitor();\r
+ // //Alarm\97\98\97p\8e\9e\95K\97v\r
+ StatusType ercd;\r
+ ercd = SignalCounter(SysTimerCnt);\r
+ if (ercd != E_OK) {\r
+ ShutdownOS(ercd);\r
+ }\r
+}\r
+\r
+TASK(TaskMain)\r
+{\r
+ lcd.clear();\r
+ lcd.putf("s", "Hello World");\r
+ lcd.disp();\r
+\r
+ TerminateTask();\r
+}\r
+\r
+TASK(Task4ms)\r
+{\r
+ static int cnt = 0;\r
+ char str[16+1];\r
+ lcd.clear();\r
+ tsprintf(str,"cnt = %d",cnt++); // tsprintf \8eg\97p\97á\r
+ lcd.putf("s",str);\r
+ lcd.disp();\r
+\r
+ tracer.RunTrace(100);\r
+\r
+ TerminateTask();\r
+}\r
+\r
+int __cxa_pure_virtual(){\r
+ // \8f\83\90\88\89¼\91z\8aÖ\90\94\82ª\83I\81[\83o\81[\83\89\83C\83h\82µ\82È\82¢\82Å\8cÄ\82Ñ\8fo\82³\82ê\82½\8e\9e\82Ì\83G\83\89\81[\83n\83\93\83h\83\89\82ð\8bó\8eÀ\91\95\r
+ // \82±\82ê\82ð\93ü\82ê\82È\82¢\82Æram\8eg\97p\97Ê\82ª\82Æ\82Ä\82à\91\9d\82¦\82é\81E\81E\81E\r
+ return 0;\r
+}\r
+\r
+} // extern "C"\r
--- /dev/null
+#include "implementation.oil"\r
+\r
+CPU ATMEL_AT91SAM7S256\r
+{\r
+ OS LEJOS_OSEK\r
+ {\r
+ STATUS = EXTENDED;\r
+ STARTUPHOOK = FALSE;\r
+ ERRORHOOK = FALSE;\r
+ SHUTDOWNHOOK = FALSE;\r
+ PRETASKHOOK = FALSE;\r
+ POSTTASKHOOK = FALSE;\r
+ USEGETSERVICEID = FALSE;\r
+ USEPARAMETERACCESS = FALSE;\r
+ USERESSCHEDULER = FALSE;\r
+ };\r
+\r
+ /* Definition of application mode */\r
+ APPMODE appmode1{}; \r
+\r
+ /* Definition of Events */\r
+ //Sleep\8eg\97p\8e\9e\8eg\82¤\83C\83x\83\93\83g\82Ì\83e\83\93\83v\83\8c\81[\83g \r
+ EVENT EventSleepI2C{MASK = AUTO;};\r
+ EVENT EventSleep{MASK = AUTO;};\r
+\r
+ /* Definition of TaskMain */\r
+ TASK TaskMain\r
+ {\r
+ AUTOSTART = TRUE\r
+ {\r
+ APPMODE = appmode1;\r
+ };\r
+ PRIORITY = 1; /* lowest priority */\r
+ ACTIVATION = 1;\r
+ SCHEDULE = FULL;\r
+ STACKSIZE = 512;\r
+ };\r
+\r
+ /* Definition of OSEK Alarm Counter */\r
+ COUNTER SysTimerCnt\r
+ {\r
+ MINCYCLE = 1;\r
+ MAXALLOWEDVALUE = 10000;\r
+ TICKSPERBASE = 1; /* One tick is equal to 1msec */ \r
+ };\r
+ \r
+ TASK Task4ms\r
+ {\r
+ AUTOSTART = FALSE;\r
+ PRIORITY = 1; \r
+ ACTIVATION = 1;\r
+ SCHEDULE = FULL;\r
+ STACKSIZE = 512;\r
+ };\r
+ ALARM Alarm4ms\r
+ {\r
+ COUNTER = SysTimerCnt;\r
+ ACTION = ACTIVATETASK{TASK = Task4ms;};\r
+ AUTOSTART = TRUE {\r
+ ALARMTIME = 1;//\8dÅ\8f\89\82Ìtick (ms) \96¾\8e¦\82Ì\82½\82ß0\8bÖ\8e~\r
+ CYCLETIME = 4;//\8eü\8aútick(ms)\r
+ APPMODE = appmode1; \r
+ };\r
+ };\r
+\r
+};\r
--- /dev/null
+========================================================================\r
+ メイクファイル プロジェクト: Tonden プロジェクトの概要\r
+========================================================================\r
+\r
+この Tonden プロジェクトは、AppWizard により作成されました。\r
+\r
+このファイルには、Tonden プロジェクトを構成する各ファイルの内容の概略が記述されています。\r
+\r
+\r
+Tonden.vcxproj\r
+ これは、アプリケーション ウィザードを使用して生成された VC++ プロジェクトのメイン プロジェクト ファイルです。ファイルを生成した Visual C++ のバージョンに関する情報と、アプリケーション ウィザードで選択されたプラットフォーム、構成、およびプロジェクト機能に関する情報が含まれています。\r
+\r
+Tonden.vcxproj.filters\r
+ これは、アプリケーション ウィザードで生成された VC++ プロジェクトのフィルター ファイルです。このファイルには、プロジェクト内のファイルとフィルターとの間の関連付けに関する情報が含まれています。この関連付けは、特定のノードで同様の拡張子を持つファイルのグループ化を示すために IDE で使用されます (たとえば、".cpp" ファイルは "ソース ファイル" フィルターに関連付けられています)。\r
+\r
+このプロジェクトは、ウィザードで入力したコマンドを呼び出すことにより、Visual Studio からビルド/クリーン/再ビルドできます。ビルド コマンドには、nmake などの任意のツールを使用できます。\r
+\r
+このプロジェクトにはファイルが含まれないため、ソリューション エクスプローラーには何も表示されません。\r
+\r
+/////////////////////////////////////////////////////////////////////////////\r
--- /dev/null
+/*\r
+ Tiny sprintf module\r
+ for Embedded microcontrollers\r
+ File Version : 1.0\r
+ Yasuhiro ISHII 2005\r
+\r
+ \81y\83o\81[\83W\83\87\83\93\83A\83b\83v\97\9a\97ð\81z\r
+ 0.1 : \82Æ\82è\82 \82¦\82¸\82È\82ñ\82©\93®\82¢\82½\94Å\r
+ 0.2 : decimal\82Ì0\95\\8e¦\91Î\89\9e 20050313\r
+ 0.3 : hexa decimal\82Ì0\95\\8e¦\91Î\89\9e 20050313\r
+ 0.4 : \83\\81[\83X\92\86\82Ì\95Ï\82È\83R\81[\83h(^M)\82ð\8dí\8f\9c\82µ\82½ 20050503\r
+ 0.5 : tsprintf\8aÖ\90\94\82Ì\95Ï\90\94 size\82ð\8f\89\8aú\89»\82·\82é\82æ\82¤\82É\82µ\82½ 20050503\r
+ 0.6 : %d\82Ì\95\89\90\94\91Î\89\9e,%x\82Ìunsigned\8f\88\97\9d\89» 20050522\r
+ 0.7 : %d,%x\82Ì\8c\85\90\94\8ew\92è(%[n]d)/0\95â\8a®\8ew\92è(%0[n]d)\91Î\89\9e 20050522\r
+ 0.8 : va_list\82Å\93n\82·vtsprintf\82ð\8dì\90¬\82µ\81Avsprintf\82ðvtsprintf\82Ì\90e\8aÖ\90\94\82É\82µ\82½ 20050522\r
+ 0.9 : hex\82Å\81A\92l\82ª0\82Ì\8e\9e\82É\8c\85\82ª1\82É\82È\82Á\82Ä\82µ\82Ü\82¤\83o\83O\8fC\90³ 20050526\r
+ 1.0 : dec\82Å\81A\92l\82ª0\82Ì\8e\9e\82É\8c\85\82ª1\82É\82È\82Á\82Ä\82µ\82Ü\82¤\83o\83O\8fC\90³ 20050629\r
+ \r
+ printf\82Ì\8f\91\8e®\90Ý\92è\82ð\8aÈ\88Õ\93I\82È\82à\82Ì\82É\82µ\82Ä\8eÀ\91\95\82µ\82Ä\82 \82é\82Ì\82Å\8eg\97p\8e\9e\82É\82Í\r
+ \90à\96¾\8f\91\82ð\8am\94F\82µ\82Ä\89º\82³\82¢\81B\r
+\r
+*/\r
+\r
+#include <stdarg.h>\r
+\r
+int tsprintf(char* ,char* , ...);\r
+int vtsprintf(char* buff,char* fmt,va_list arg);\r
+\r
+static int tsprintf_string(char* ,char* );\r
+static int tsprintf_char(int ,char* );\r
+static int tsprintf_decimal(signed long,char* ,int ,int );\r
+static int tsprintf_hexadecimal(unsigned long ,char* ,int ,int ,int );\r
+\r
+/*\r
+ Tiny sprintf\8aÖ\90\94\r
+*/\r
+int tsprintf(char* buff,char* fmt, ...){\r
+ va_list arg;\r
+ int len;\r
+\r
+ len = 0;\r
+ va_start(arg, fmt);\r
+\r
+ len = vtsprintf(buff,fmt,arg);\r
+ \r
+ va_end(arg);\r
+ return len;\r
+}\r
+\r
+int vtsprintf(char* buff,char* fmt,va_list arg){\r
+ int len;\r
+ int size;\r
+ int zeroflag,width;\r
+\r
+ size = 0;\r
+ len = 0;\r
+\r
+ while(*fmt){\r
+ if(*fmt=='%'){ /* % \82É\8aÖ\82·\82é\8f\88\97\9d */\r
+ zeroflag = width = 0;\r
+ fmt++;\r
+\r
+ if (*fmt == '0'){\r
+ fmt++;\r
+ zeroflag = 1;\r
+ }\r
+ if ((*fmt >= '0') && (*fmt <= '9')){\r
+ width = *(fmt++) - '0';\r
+ }\r
+\r
+ /* printf ("zerof = %d,width = %d\n",zeroflag,width); */\r
+\r
+ switch(*fmt){\r
+ case 'd': /* 10\90i\90\94 */\r
+ size = tsprintf_decimal(va_arg(arg,signed long),buff,zeroflag,width);\r
+ break;\r
+ case 'x': /* 16\90i\90\94 0-f */\r
+ size = tsprintf_hexadecimal(va_arg(arg,unsigned long),buff,0,zeroflag,width);\r
+ break;\r
+ case 'X': /* 16\90i\90\94 0-F */\r
+ size = tsprintf_hexadecimal(va_arg(arg,unsigned long),buff,1,zeroflag,width);\r
+ break;\r
+ case 'c': /* \83L\83\83\83\89\83N\83^\81[ */\r
+ size = tsprintf_char(va_arg(arg,int),buff);\r
+ break;\r
+ case 's': /* ASCIIZ\95¶\8e\9a\97ñ */\r
+ size = tsprintf_string(va_arg(arg,char*),buff);\r
+ break;\r
+ default: /* \83R\83\93\83g\83\8d\81[\83\8b\83R\81[\83h\88È\8aO\82Ì\95¶\8e\9a */\r
+ /* %%(%\82É\91Î\89\9e)\82Í\82±\82±\82Å\91Î\89\9e\82³\82ê\82é */\r
+ len++;\r
+ *(buff++) = *fmt;\r
+ break;\r
+ }\r
+ len += size;\r
+ buff += size;\r
+ fmt++;\r
+ } else {\r
+ *(buff++) = *(fmt++);\r
+ len++;\r
+ }\r
+ }\r
+\r
+ *buff = '\0'; /* \8fI\92[\82ð\93ü\82ê\82é */\r
+\r
+ va_end(arg);\r
+ return (len);\r
+}\r
+\r
+\r
+\r
+\r
+/*\r
+ \90\94\92l => 10\90i\95¶\8e\9a\97ñ\95Ï\8a·\r
+*/\r
+static int tsprintf_decimal(signed long val,char* buff,int zf,int wd){\r
+ int i;\r
+ char tmp[10];\r
+ char* ptmp = tmp + 9;\r
+ int len = 0;\r
+ int minus = 0;\r
+\r
+ if (!val){ /* \8ew\92è\92l\82ª0\82Ì\8fê\8d\87 */\r
+ *(ptmp--) = '0';\r
+ len++;\r
+ } else {\r
+ /* \83}\83C\83i\83X\82Ì\92l\82Ì\8fê\8d\87\82É\82Í2\82Ì\95â\90\94\82ð\8eæ\82é */\r
+ if (val < 0){\r
+ val = ~val;\r
+ val++;\r
+ minus = 1;\r
+ }\r
+ while (val){\r
+ /* \83o\83b\83t\83@\83A\83\93\83_\81[\83t\83\8d\81[\91Î\8dô */\r
+ if (len >= 8){\r
+ break;\r
+ }\r
+ \r
+ *ptmp = (val % 10) + '0';\r
+ val /= 10;\r
+ ptmp--;\r
+ len++;\r
+ }\r
+\r
+ }\r
+\r
+ /* \95\84\8d\86\81A\8c\85\8d\87\82í\82¹\82É\8aÖ\82·\82é\8f\88\97\9d */\r
+ if (zf){\r
+ if (minus){\r
+ wd--;\r
+ }\r
+ while (len < wd){\r
+ *(ptmp--) = '0';\r
+ len++;\r
+ }\r
+ if (minus){\r
+ *(ptmp--) = '-';\r
+ len++;\r
+ }\r
+ } else {\r
+ if (minus){\r
+ *(ptmp--) = '-';\r
+ len++;\r
+ }\r
+ while (len < wd){\r
+ *(ptmp--) = ' ';\r
+ len++;\r
+ }\r
+ }\r
+\r
+ /* \90¶\90¬\95¶\8e\9a\97ñ\82Ì\83o\83b\83t\83@\83R\83s\81[ */\r
+ for (i=0;i<len;i++){\r
+ *(buff++) = *(++ptmp);\r
+ }\r
+\r
+ return (len);\r
+}\r
+\r
+/*\r
+ \90\94\92l => 16\90i\95¶\8e\9a\97ñ\95Ï\8a·\r
+*/\r
+static int tsprintf_hexadecimal(unsigned long val,char* buff,\r
+ int capital,int zf,int wd){\r
+ int i;\r
+ char tmp[10];\r
+ char* ptmp = tmp + 9;\r
+ int len = 0;\r
+ char str_a;\r
+\r
+ /* A\81`F\82ð\91å\95¶\8e\9a\82É\82·\82é\82©\8f¬\95¶\8e\9a\82É\82·\82é\82©\90Ø\82è\91Ö\82¦\82é */\r
+ if (capital){\r
+ str_a = 'A';\r
+ } else {\r
+ str_a = 'a';\r
+ }\r
+ \r
+ if (!val){ /* \8ew\92è\92l\82ª0\82Ì\8fê\8d\87 */\r
+ *(ptmp--) = '0';\r
+ len++;\r
+ } else {\r
+ while (val){\r
+ /* \83o\83b\83t\83@\83A\83\93\83_\81[\83t\83\8d\81[\91Î\8dô */\r
+ if (len >= 8){\r
+ break;\r
+ }\r
+\r
+ *ptmp = (val % 16);\r
+ if (*ptmp > 9){\r
+ *ptmp += str_a - 10;\r
+ } else {\r
+ *ptmp += '0';\r
+ }\r
+ \r
+ val >>= 4; /* 16\82Å\8a\84\82é */\r
+ ptmp--;\r
+ len++;\r
+ }\r
+ }\r
+ while (len < wd){\r
+ *(ptmp--) = zf ? '0' : ' ';\r
+ len++;\r
+ }\r
+ \r
+ for (i=0;i<len;i++){\r
+ *(buff++) = *(++ptmp);\r
+ }\r
+\r
+ return(len);\r
+}\r
+\r
+/*\r
+ \90\94\92l => 1\95¶\8e\9a\83L\83\83\83\89\83N\83^\95Ï\8a·\r
+*/\r
+static int tsprintf_char(int ch,char* buff){\r
+ *buff = (char)ch;\r
+ return(1);\r
+}\r
+\r
+/*\r
+ \90\94\92l => ASCIIZ\95¶\8e\9a\97ñ\95Ï\8a·\r
+*/\r
+static int tsprintf_string(char* str,char* buff){\r
+ int count = 0;\r
+ while(*str){\r
+ *(buff++) = *str;\r
+ str++;\r
+ count++;\r
+ }\r
+ return(count);\r
+}\r
+\r
--- /dev/null
+/*\r
+ Tiny sprintf module\r
+ for Embedded microcontrollers\r
+\r
+ (Ver 1.0)\r
+*/\r
+\r
+#ifndef _TSPRINTF_H_\r
+#define _TSPRINTF_H_\r
+\r
+#include <stdarg.h>\r
+\r
+#ifdef __cplusplus \r
+extern "C"{\r
+#endif /* __cplusplus */\r
+\r
+extern int tsprintf(char* ,char* , ...);\r
+extern int vtsprintf(char* buff,char* fmt,va_list arg);\r
+\r
+#ifdef __cplusplus \r
+}\r
+#endif /* __cplusplus */\r
+\r
+#endif /* _TSPRINTF_H_ */\r