Skip to content

Commit

Permalink
Merge branch 'ArduinoDue' of github.com:collin80/GEVCU
Browse files Browse the repository at this point in the history
Conflicts:
	BrusaMotorController.cpp
	Device.h
	GEVCU.ino
	PotBrake.cpp
	PotThrottle.cpp
	Throttle.cpp
	config.h
  • Loading branch information
collin80 committed Oct 16, 2013
2 parents 3f6218d + d131c0d commit 0318ce8
Show file tree
Hide file tree
Showing 28 changed files with 1,090 additions and 874 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@ Release
*.elf
*.map
*.srec
*.vcx*
4 changes: 4 additions & 0 deletions BrusaMotorController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -243,3 +243,7 @@ DeviceId BrusaMotorController::getId() {
return BRUSA_DMC5;
}

uint32_t BrusaMotorController::getTickInterval() {
return CFG_TICK_INTERVAL_MOTOR_CONTROLLER_BRUSA;
}

1 change: 1 addition & 0 deletions BrusaMotorController.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ class BrusaMotorController: public MotorController, CanObserver {
void setup();
BrusaMotorController();
DeviceId getId();
virtual uint32_t getTickInterval();

private:
// DMC_TRQS2
Expand Down
63 changes: 36 additions & 27 deletions Device.cpp
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
/*
* Device.cpp
*
Copyright (c) 2013 Collin Kidder, Michael Neuweiler, Charles Galpin
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copyright (c) 2013 Collin Kidder, Michael Neuweiler, Charles Galpin
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "Device.h"

Device::Device() {
deviceConfiguration = NULL;
prefsHandler = NULL;
}

//Empty functions to handle these callbacks if the derived classes don't

void Device::setup() {

}

void Device::handleTick() {

}

//just bubbles up the value from the preference handler.
Expand All @@ -46,8 +46,7 @@ bool Device::isEnabled()
}

void Device::handleMessage(uint32_t msgType, void* message) {
switch (msgType)
{
switch (msgType) {
case MSG_STARTUP:
this->setup();
break;
Expand All @@ -62,7 +61,17 @@ DeviceId Device::getId() {
return INVALID;
}

uint32_t Device::getTickInterval()
{
return 0;
void Device::loadConfiguration() {
}

void Device::saveConfiguration() {
}

DeviceConfiguration *Device::getConfiguration() {
return this->deviceConfiguration;
}

void Device::setConfiguration(DeviceConfiguration *configuration) {
this->deviceConfiguration = configuration;
}

22 changes: 20 additions & 2 deletions Device.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,21 +34,39 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "PrefHandler.h"
#include "Sys_Messages.h"

class Device : public TickObserver {
/*
* A abstract class to hold device configuration. It is to be accessed
* by sub-classes via getConfiguration() and then cast into its
* correct sub-class.
*/
class DeviceConfiguration {

};

/*
* A abstract class for all Devices.
*/
class Device: public TickObserver {
public:
Device();
virtual void setup();
virtual void handleTick();
virtual void handleMessage(uint32_t msgType, void* message);
virtual void handleMessage(uint32_t, void* );
virtual DeviceType getType();
virtual DeviceId getId();
bool isEnabled();
virtual uint32_t getTickInterval();

virtual void loadConfiguration();
virtual void saveConfiguration();
DeviceConfiguration *getConfiguration();
void setConfiguration(DeviceConfiguration *);

protected:
PrefHandler *prefsHandler;

private:
DeviceConfiguration *deviceConfiguration; // reference to the currently active configuration
};

#endif /* DEVICE_H_ */
9 changes: 6 additions & 3 deletions GEVCU.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PreprocessorDefinitions>__SAM3X8E__;USB_PID=0x003e;USB_VID=0x2341;USBCON;ARDUINO=152;ARDUINO_MAIN;printf=iprintf;__SAM__;F_CPU=84000000L;__cplusplus;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessorDefinitions>__SAM3X8E__;USB_VID=0x2341;USB_PID=0x003e;USBCON;ARDUINO=154;ARDUINO_MAIN;printf=iprintf;__SAM__;F_CPU=84000000L;__cplusplus;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<WarningLevel>Level3</WarningLevel>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<Optimization>Disabled</Optimization>
<BrowseInformation>true</BrowseInformation>
<AdditionalIncludeDirectories>c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\cores\arduino;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\variants\arduino_due_x;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\libraries\due_rtc;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\libraries\due_rtc\utility;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\libraries\due_can;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\libraries\due_can\utility;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\libraries\due_wire;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\libraries\due_wire\utility;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\libraries\DueTimer;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\libraries\DueTimer\utility;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\system\CMSIS\CMSIS\Include\;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\system\CMSIS\Device\ATMEL\;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\system\libsam;c:\users\collin\desktop\Arduino-1.5.2\hardware\arduino\sam\system\libsam\include;c:\users\collin\desktop\Arduino-1.5.2/hardware/tools/g++_arm_none_eabi\arm-none-eabi\include;c:\users\collin\desktop\Arduino-1.5.2/hardware/tools/g++_arm_none_eabi\arm_none_eabi\include\;c:\users\collin\desktop\Arduino-1.5.2/hardware/tools/g++_arm_none_eabi\lib\gcc\arm-none-eabi\4.4.1\include;c:\users\collin\desktop\Arduino-1.5.2/hardware/tools/g++_arm_none_eabi\lib\gcc\arm-none-eabi\4.4.1\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<AdditionalIncludeDirectories>c:\arduino\hardware\arduino\sam\cores\arduino;c:\arduino\hardware\arduino\sam\variants\arduino_due_x;C:\Users\Collin\Documents\Arduino\libraries\due_rtc;C:\Users\Collin\Documents\Arduino\libraries\due_rtc\utility;C:\Users\Collin\Documents\Arduino\libraries\due_can;C:\Users\Collin\Documents\Arduino\libraries\due_can\utility;C:\Users\Collin\Documents\Arduino\libraries\due_wire;C:\Users\Collin\Documents\Arduino\libraries\due_wire\utility;C:\Users\Collin\Documents\Arduino\libraries\DueTimer;C:\Users\Collin\Documents\Arduino\libraries\DueTimer\utility;c:\arduino\hardware\arduino\sam\system\CMSIS\CMSIS\Include\;c:\arduino\hardware\arduino\sam\system\CMSIS\Device\ATMEL\;c:\arduino\hardware\arduino\sam\system\libsam;c:\arduino\hardware\arduino\sam\system\libsam\include;c:\arduino/hardware/tools/g++_arm_none_eabi\arm-none-eabi\include;c:\arduino/hardware/tools/g++_arm_none_eabi\arm_none_eabi\include\;c:\arduino/hardware/tools/g++_arm_none_eabi\lib\gcc\arm-none-eabi\4.4.1\include;c:\arduino/hardware/tools/g++_arm_none_eabi\lib\gcc\arm-none-eabi\4.4.1\include\;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<ForcedIncludeFiles>C:\Users\Collin\Desktop\GEVCU\Visual Micro\.GEVCU.vsarduino.h;%(ForcedIncludeFiles)</ForcedIncludeFiles>
<IgnoreStandardIncludePath>true</IgnoreStandardIncludePath>
</ClCompile>
Expand Down Expand Up @@ -87,6 +87,9 @@
<ClInclude Include="config.h" />
<ClInclude Include="Device.h" />
<ClInclude Include="DeviceManager.h" />
<ClInclude Include="DeviceTypes.h">
<FileType>CppCode</FileType>
</ClInclude>
<ClInclude Include="DmocMotorController.h" />
<ClInclude Include="eeprom_layout.h" />
<ClInclude Include="FaultHandler.h" />
Expand All @@ -98,7 +101,6 @@
<ClInclude Include="Logger.h" />
<ClInclude Include="MemCache.h" />
<ClInclude Include="MotorController.h" />
<ClInclude Include="Params.h" />
<ClInclude Include="PotBrake.h">
<FileType>CppCode</FileType>
</ClInclude>
Expand All @@ -108,6 +110,7 @@
<FileType>CppCode</FileType>
</ClInclude>
<ClInclude Include="sys_io.h" />
<ClInclude Include="Sys_Messages.h" />
<ClInclude Include="ThinkBatteryManager.h" />
<ClInclude Include="Throttle.h" />
<ClInclude Include="ThrottleDetector.h">
Expand Down
9 changes: 6 additions & 3 deletions GEVCU.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,6 @@
<ClInclude Include="SerialConsole.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Params.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="BrusaMotorController.h">
<Filter>Header Files</Filter>
</ClInclude>
Expand All @@ -96,6 +93,12 @@
<ClInclude Include="ThinkBatteryManager.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="Sys_Messages.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="DeviceTypes.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<Text Include="GEVCU.ino" />
Expand Down
8 changes: 8 additions & 0 deletions MotorController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -337,3 +337,11 @@ uint32_t MotorController::getStatusBitfield3() {
uint32_t MotorController::getStatusBitfield4() {
return statusBitfield4;
}

uint32_t MotorController::getTickInterval() {
return 0;
}

bool MotorController::isReady() {
return false;
}
1 change: 1 addition & 0 deletions MotorController.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ class MotorController: public Device {
DeviceType getType();
virtual void setup();
void handleTick();
virtual uint32_t getTickInterval();

bool isReady();
bool isRunning();
Expand Down
Loading

0 comments on commit 0318ce8

Please sign in to comment.