initial commit
This commit is contained in:
166
Software/.cproject
Normal file
166
Software/.cproject
Normal file
@ -0,0 +1,166 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<?fileVersion 4.0.0?><cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="de.innot.avreclipse.configuration.app.debug.1427179435">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="de.innot.avreclipse.configuration.app.debug.1427179435" moduleId="org.eclipse.cdt.core.settings" name="Debug">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="de.innot.avreclipse.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=de.innot.avreclipse.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.debug" description="" id="de.innot.avreclipse.configuration.app.debug.1427179435" name="Debug" parent="de.innot.avreclipse.configuration.app.debug">
|
||||
<folderInfo id="de.innot.avreclipse.configuration.app.debug.1427179435." name="/" resourcePath="">
|
||||
<toolChain id="de.innot.avreclipse.toolchain.winavr.app.debug.1978605780" name="AVR-GCC Toolchain" superClass="de.innot.avreclipse.toolchain.winavr.app.debug">
|
||||
<option id="de.innot.avreclipse.toolchain.options.toolchain.objcopy.flash.app.debug.2009251621" name="Generate HEX file for Flash memory" superClass="de.innot.avreclipse.toolchain.options.toolchain.objcopy.flash.app.debug" value="true" valueType="boolean"/>
|
||||
<option id="de.innot.avreclipse.toolchain.options.toolchain.objcopy.eeprom.app.debug.835121431" name="Generate HEX file for EEPROM" superClass="de.innot.avreclipse.toolchain.options.toolchain.objcopy.eeprom.app.debug"/>
|
||||
<option id="de.innot.avreclipse.toolchain.options.toolchain.objdump.app.debug.1695375897" name="Generate Extended Listing (Source + generated Assembler)" superClass="de.innot.avreclipse.toolchain.options.toolchain.objdump.app.debug"/>
|
||||
<option id="de.innot.avreclipse.toolchain.options.toolchain.size.app.debug.2067657557" name="Print Size" superClass="de.innot.avreclipse.toolchain.options.toolchain.size.app.debug"/>
|
||||
<option id="de.innot.avreclipse.toolchain.options.toolchain.avrdude.app.debug.549047469" name="AVRDude" superClass="de.innot.avreclipse.toolchain.options.toolchain.avrdude.app.debug"/>
|
||||
<targetPlatform id="de.innot.avreclipse.targetplatform.winavr.app.debug.1506165090" name="AVR Cross-Target" superClass="de.innot.avreclipse.targetplatform.winavr.app.debug"/>
|
||||
<builder buildPath="${workspace_loc:/openChargeMicro}/Debug" id="de.innot.avreclipse.target.builder.winavr.app.debug.1802160882" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="AVR GNU Make Builder" superClass="de.innot.avreclipse.target.builder.winavr.app.debug"/>
|
||||
<tool id="de.innot.avreclipse.tool.assembler.winavr.app.debug.2973573" name="AVR Assembler" superClass="de.innot.avreclipse.tool.assembler.winavr.app.debug">
|
||||
<option id="de.innot.avreclipse.assembler.option.debug.level.1730166117" name="Generate Debugging Info" superClass="de.innot.avreclipse.assembler.option.debug.level"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="de.innot.avreclipse.asm.option.include.paths.609228093" name="#include paths for preprocessor(-I)" superClass="de.innot.avreclipse.asm.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/avr/sys-root/include/"/>
|
||||
</option>
|
||||
<inputType id="de.innot.avreclipse.tool.assembler.input.1688645027" superClass="de.innot.avreclipse.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="de.innot.avreclipse.tool.compiler.winavr.app.debug.2133252740" name="AVR Compiler" superClass="de.innot.avreclipse.tool.compiler.winavr.app.debug">
|
||||
<option id="de.innot.avreclipse.compiler.option.debug.level.1241513296" name="Generate Debugging Info" superClass="de.innot.avreclipse.compiler.option.debug.level"/>
|
||||
<option id="de.innot.avreclipse.compiler.option.optimize.156807761" name="Optimization Level" superClass="de.innot.avreclipse.compiler.option.optimize"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="de.innot.avreclipse.compiler.option.incpath.2022106753" name="Include Paths (-I)" superClass="de.innot.avreclipse.compiler.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/avr/sys-root/include/"/>
|
||||
</option>
|
||||
<inputType id="de.innot.avreclipse.compiler.winavr.input.507254525" name="C Source Files" superClass="de.innot.avreclipse.compiler.winavr.input"/>
|
||||
</tool>
|
||||
<tool id="de.innot.avreclipse.tool.cppcompiler.app.debug.1143634285" name="AVR C++ Compiler" superClass="de.innot.avreclipse.tool.cppcompiler.app.debug">
|
||||
<option id="de.innot.avreclipse.cppcompiler.option.debug.level.503422737" name="Generate Debugging Info" superClass="de.innot.avreclipse.cppcompiler.option.debug.level"/>
|
||||
<option id="de.innot.avreclipse.cppcompiler.option.optimize.155779868" name="Optimization Level" superClass="de.innot.avreclipse.cppcompiler.option.optimize"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="de.innot.avreclipse.cppcompiler.option.incpath.823066655" name="Include Paths (-I)" superClass="de.innot.avreclipse.cppcompiler.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/avr/sys-root/include/"/>
|
||||
</option>
|
||||
<inputType id="de.innot.avreclipse.cppcompiler.input.250930691" superClass="de.innot.avreclipse.cppcompiler.input"/>
|
||||
</tool>
|
||||
<tool id="de.innot.avreclipse.tool.linker.winavr.app.debug.853456894" name="AVR C Linker" superClass="de.innot.avreclipse.tool.linker.winavr.app.debug"/>
|
||||
<tool id="de.innot.avreclipse.tool.cpplinker.app.debug.903398008" name="AVR C++ Linker" superClass="de.innot.avreclipse.tool.cpplinker.app.debug">
|
||||
<inputType id="de.innot.avreclipse.tool.cpplinker.input.65952620" name="OBJ Files" superClass="de.innot.avreclipse.tool.cpplinker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="de.innot.avreclipse.tool.archiver.winavr.base.800620483" name="AVR Archiver" superClass="de.innot.avreclipse.tool.archiver.winavr.base"/>
|
||||
<tool id="de.innot.avreclipse.tool.objdump.winavr.app.debug.1372201036" name="AVR Create Extended Listing" superClass="de.innot.avreclipse.tool.objdump.winavr.app.debug"/>
|
||||
<tool id="de.innot.avreclipse.tool.objcopy.flash.winavr.app.debug.1647373475" name="AVR Create Flash image" superClass="de.innot.avreclipse.tool.objcopy.flash.winavr.app.debug"/>
|
||||
<tool id="de.innot.avreclipse.tool.objcopy.eeprom.winavr.app.debug.1462807145" name="AVR Create EEPROM image" superClass="de.innot.avreclipse.tool.objcopy.eeprom.winavr.app.debug"/>
|
||||
<tool id="de.innot.avreclipse.tool.size.winavr.app.debug.705422082" name="Print Size" superClass="de.innot.avreclipse.tool.size.winavr.app.debug"/>
|
||||
<tool id="de.innot.avreclipse.tool.avrdude.app.debug.1553302162" name="AVRDude" superClass="de.innot.avreclipse.tool.avrdude.app.debug"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
<cconfiguration id="de.innot.avreclipse.configuration.app.release.1977445521">
|
||||
<storageModule buildSystemId="org.eclipse.cdt.managedbuilder.core.configurationDataProvider" id="de.innot.avreclipse.configuration.app.release.1977445521" moduleId="org.eclipse.cdt.core.settings" name="Release">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GASErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GLDErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.MakeErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
<extension id="org.eclipse.cdt.core.GCCErrorParser" point="org.eclipse.cdt.core.ErrorParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<configuration artifactName="${ProjName}" buildArtefactType="de.innot.avreclipse.buildArtefactType.app" buildProperties="org.eclipse.cdt.build.core.buildArtefactType=de.innot.avreclipse.buildArtefactType.app,org.eclipse.cdt.build.core.buildType=org.eclipse.cdt.build.core.buildType.release" description="" id="de.innot.avreclipse.configuration.app.release.1977445521" name="Release" parent="de.innot.avreclipse.configuration.app.release">
|
||||
<folderInfo id="de.innot.avreclipse.configuration.app.release.1977445521." name="/" resourcePath="">
|
||||
<toolChain id="de.innot.avreclipse.toolchain.winavr.app.release.1633344275" name="AVR-GCC Toolchain" superClass="de.innot.avreclipse.toolchain.winavr.app.release">
|
||||
<option id="de.innot.avreclipse.toolchain.options.toolchain.objcopy.flash.app.release.1628712508" name="Generate HEX file for Flash memory" superClass="de.innot.avreclipse.toolchain.options.toolchain.objcopy.flash.app.release"/>
|
||||
<option id="de.innot.avreclipse.toolchain.options.toolchain.objcopy.eeprom.app.release.761603768" name="Generate HEX file for EEPROM" superClass="de.innot.avreclipse.toolchain.options.toolchain.objcopy.eeprom.app.release"/>
|
||||
<option id="de.innot.avreclipse.toolchain.options.toolchain.objdump.app.release.774199864" name="Generate Extended Listing (Source + generated Assembler)" superClass="de.innot.avreclipse.toolchain.options.toolchain.objdump.app.release"/>
|
||||
<option id="de.innot.avreclipse.toolchain.options.toolchain.size.app.release.716684797" name="Print Size" superClass="de.innot.avreclipse.toolchain.options.toolchain.size.app.release"/>
|
||||
<option id="de.innot.avreclipse.toolchain.options.toolchain.avrdude.app.release.790992888" name="AVRDude" superClass="de.innot.avreclipse.toolchain.options.toolchain.avrdude.app.release"/>
|
||||
<targetPlatform id="de.innot.avreclipse.targetplatform.winavr.app.release.1454696610" name="AVR Cross-Target" superClass="de.innot.avreclipse.targetplatform.winavr.app.release"/>
|
||||
<builder buildPath="${workspace_loc:/openChargeMicro}/Release" id="de.innot.avreclipse.target.builder.winavr.app.release.267231778" keepEnvironmentInBuildfile="false" managedBuildOn="true" name="AVR GNU Make Builder" superClass="de.innot.avreclipse.target.builder.winavr.app.release"/>
|
||||
<tool id="de.innot.avreclipse.tool.assembler.winavr.app.release.390233255" name="AVR Assembler" superClass="de.innot.avreclipse.tool.assembler.winavr.app.release">
|
||||
<option id="de.innot.avreclipse.assembler.option.debug.level.270978030" name="Generate Debugging Info" superClass="de.innot.avreclipse.assembler.option.debug.level" value="de.innot.avreclipse.assembler.option.debug.level.none" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="de.innot.avreclipse.asm.option.include.paths.183896263" name="#include paths for preprocessor(-I)" superClass="de.innot.avreclipse.asm.option.include.paths" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/avr/sys-root/include/"/>
|
||||
</option>
|
||||
<inputType id="de.innot.avreclipse.tool.assembler.input.103058488" superClass="de.innot.avreclipse.tool.assembler.input"/>
|
||||
</tool>
|
||||
<tool id="de.innot.avreclipse.tool.compiler.winavr.app.release.1599960695" name="AVR Compiler" superClass="de.innot.avreclipse.tool.compiler.winavr.app.release">
|
||||
<option id="de.innot.avreclipse.compiler.option.debug.level.1506999036" name="Generate Debugging Info" superClass="de.innot.avreclipse.compiler.option.debug.level" value="de.innot.avreclipse.compiler.option.debug.level.none" valueType="enumerated"/>
|
||||
<option id="de.innot.avreclipse.compiler.option.optimize.989197945" name="Optimization Level" superClass="de.innot.avreclipse.compiler.option.optimize" value="de.innot.avreclipse.compiler.optimize.size" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="de.innot.avreclipse.compiler.option.incpath.634667513" name="Include Paths (-I)" superClass="de.innot.avreclipse.compiler.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/avr/sys-root/include/"/>
|
||||
</option>
|
||||
<inputType id="de.innot.avreclipse.compiler.winavr.input.1619452791" name="C Source Files" superClass="de.innot.avreclipse.compiler.winavr.input"/>
|
||||
</tool>
|
||||
<tool id="de.innot.avreclipse.tool.cppcompiler.app.release.374758438" name="AVR C++ Compiler" superClass="de.innot.avreclipse.tool.cppcompiler.app.release">
|
||||
<option id="de.innot.avreclipse.cppcompiler.option.debug.level.398659815" name="Generate Debugging Info" superClass="de.innot.avreclipse.cppcompiler.option.debug.level" value="de.innot.avreclipse.cppcompiler.option.debug.level.none" valueType="enumerated"/>
|
||||
<option id="de.innot.avreclipse.cppcompiler.option.optimize.1835169824" name="Optimization Level" superClass="de.innot.avreclipse.cppcompiler.option.optimize" value="de.innot.avreclipse.cppcompiler.optimize.size" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="de.innot.avreclipse.cppcompiler.option.incpath.373421266" name="Include Paths (-I)" superClass="de.innot.avreclipse.cppcompiler.option.incpath" valueType="includePath">
|
||||
<listOptionValue builtIn="false" value="/usr/avr/sys-root/include/"/>
|
||||
</option>
|
||||
<inputType id="de.innot.avreclipse.cppcompiler.input.639428088" superClass="de.innot.avreclipse.cppcompiler.input"/>
|
||||
</tool>
|
||||
<tool id="de.innot.avreclipse.tool.linker.winavr.app.release.1898125859" name="AVR C Linker" superClass="de.innot.avreclipse.tool.linker.winavr.app.release"/>
|
||||
<tool id="de.innot.avreclipse.tool.cpplinker.app.release.394362153" name="AVR C++ Linker" superClass="de.innot.avreclipse.tool.cpplinker.app.release">
|
||||
<inputType id="de.innot.avreclipse.tool.cpplinker.input.203838715" name="OBJ Files" superClass="de.innot.avreclipse.tool.cpplinker.input">
|
||||
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
|
||||
<additionalInput kind="additionalinput" paths="$(LIBS)"/>
|
||||
</inputType>
|
||||
</tool>
|
||||
<tool id="de.innot.avreclipse.tool.archiver.winavr.base.1110636129" name="AVR Archiver" superClass="de.innot.avreclipse.tool.archiver.winavr.base"/>
|
||||
<tool id="de.innot.avreclipse.tool.objdump.winavr.app.release.1100926224" name="AVR Create Extended Listing" superClass="de.innot.avreclipse.tool.objdump.winavr.app.release"/>
|
||||
<tool id="de.innot.avreclipse.tool.objcopy.flash.winavr.app.release.1917597264" name="AVR Create Flash image" superClass="de.innot.avreclipse.tool.objcopy.flash.winavr.app.release"/>
|
||||
<tool id="de.innot.avreclipse.tool.objcopy.eeprom.winavr.app.release.497869666" name="AVR Create EEPROM image" superClass="de.innot.avreclipse.tool.objcopy.eeprom.winavr.app.release"/>
|
||||
<tool id="de.innot.avreclipse.tool.size.winavr.app.release.394474476" name="Print Size" superClass="de.innot.avreclipse.tool.size.winavr.app.release"/>
|
||||
<tool id="de.innot.avreclipse.tool.avrdude.app.release.257247556" name="AVRDude" superClass="de.innot.avreclipse.tool.avrdude.app.release"/>
|
||||
</toolChain>
|
||||
</folderInfo>
|
||||
<sourceEntries>
|
||||
<entry excluding="src" flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name=""/>
|
||||
<entry flags="VALUE_WORKSPACE_PATH|RESOLVED" kind="sourcePath" name="src"/>
|
||||
</sourceEntries>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.externalSettings"/>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdtBuildSystem" version="4.0.0">
|
||||
<project id="openChargeMicro.de.innot.avreclipse.project.winavr.elf_2.1.0.1725973903" name="AVR Cross Target Application" projectType="de.innot.avreclipse.project.winavr.elf_2.1.0"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.core.LanguageSettingsProviders"/>
|
||||
<storageModule moduleId="refreshScope" versionNumber="2">
|
||||
<configuration configurationName="Debug">
|
||||
<resource resourceType="PROJECT" workspacePath="/openChargeMicro"/>
|
||||
</configuration>
|
||||
<configuration configurationName="Release">
|
||||
<resource resourceType="PROJECT" workspacePath="/openChargeMicro"/>
|
||||
</configuration>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.make.core.buildtargets"/>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId=""/>
|
||||
<scannerConfigBuildInfo instanceId="de.innot.avreclipse.configuration.app.debug.1427179435;de.innot.avreclipse.configuration.app.debug.1427179435.;de.innot.avreclipse.tool.cppcompiler.app.debug.1143634285;de.innot.avreclipse.cppcompiler.input.250930691">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="de.innot.avreclipse.core.AVRGCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="de.innot.avreclipse.configuration.app.release.1977445521;de.innot.avreclipse.configuration.app.release.1977445521.;de.innot.avreclipse.tool.compiler.winavr.app.release.1599960695;de.innot.avreclipse.compiler.winavr.input.1619452791">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="de.innot.avreclipse.core.AVRGCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="de.innot.avreclipse.configuration.app.debug.1427179435;de.innot.avreclipse.configuration.app.debug.1427179435.;de.innot.avreclipse.tool.compiler.winavr.app.debug.2133252740;de.innot.avreclipse.compiler.winavr.input.507254525">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="de.innot.avreclipse.core.AVRGCCManagedMakePerProjectProfileC"/>
|
||||
</scannerConfigBuildInfo>
|
||||
<scannerConfigBuildInfo instanceId="de.innot.avreclipse.configuration.app.release.1977445521;de.innot.avreclipse.configuration.app.release.1977445521.;de.innot.avreclipse.tool.cppcompiler.app.release.374758438;de.innot.avreclipse.cppcompiler.input.639428088">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="de.innot.avreclipse.core.AVRGCCManagedMakePerProjectProfileCPP"/>
|
||||
</scannerConfigBuildInfo>
|
||||
</storageModule>
|
||||
<storageModule moduleId="org.eclipse.cdt.internal.ui.text.commentOwnerProjectMappings"/>
|
||||
</cproject>
|
48
Software/src/charger.cpp
Normal file
48
Software/src/charger.cpp
Normal file
@ -0,0 +1,48 @@
|
||||
/*
|
||||
* Charger.cpp
|
||||
*
|
||||
* Created on: 19.11.2018
|
||||
* Author: Hendrik Schutter
|
||||
*/
|
||||
|
||||
#include "openChargeMicro.h"
|
||||
|
||||
charger::charger(struct s_charger pCharger) {
|
||||
charger_settings = pCharger;
|
||||
}
|
||||
|
||||
charger::~charger() {
|
||||
|
||||
}
|
||||
|
||||
double charger::getCurrent() {
|
||||
mux.setChannel(charger_settings.chI);
|
||||
int tmp = (int) io.readAdc(0);
|
||||
double ret = ((double) tmp) * 1.00; //TODO calibration and testing
|
||||
return ret;
|
||||
}
|
||||
|
||||
double charger::getVoltage() {
|
||||
mux.setChannel(charger_settings.chU);
|
||||
int tmp = (int) io.readAdc(0);
|
||||
double ret = ((double) tmp) * 1.00; //TODO calibration and testing
|
||||
return ret;
|
||||
}
|
||||
|
||||
double charger::getCapacity() {
|
||||
//TODO
|
||||
return 1.1;
|
||||
}
|
||||
|
||||
double charger::getChargeTime() {
|
||||
//TODO
|
||||
return 1.1;
|
||||
}
|
||||
|
||||
void charger::getInfo() {
|
||||
char buffer[50];
|
||||
sprintf(buffer, "Nr: %i - Uch %i - Ich %i\r\n", charger_settings.nr,
|
||||
charger_settings.chU, charger_settings.chI);
|
||||
serialSend(buffer);
|
||||
}
|
||||
|
34
Software/src/charger.h
Normal file
34
Software/src/charger.h
Normal file
@ -0,0 +1,34 @@
|
||||
/*
|
||||
* charger.h
|
||||
*
|
||||
* Created on: 20.11.2018
|
||||
* Author: Hendrik Schutter
|
||||
*/
|
||||
|
||||
#ifndef SRC_CHARGER_H_
|
||||
#define SRC_CHARGER_H_
|
||||
|
||||
struct s_charger {
|
||||
int nr;
|
||||
int chU;
|
||||
int chI;
|
||||
};
|
||||
|
||||
class charger {
|
||||
|
||||
private:
|
||||
struct s_charger charger_settings;
|
||||
ioController io;
|
||||
multiplexer mux;
|
||||
|
||||
public:
|
||||
charger(struct s_charger pCharger);
|
||||
~charger();
|
||||
double getCurrent();
|
||||
double getVoltage();
|
||||
double getCapacity();
|
||||
double getChargeTime();
|
||||
void getInfo();
|
||||
};
|
||||
|
||||
#endif /* SRC_CHARGER_H_ */
|
96
Software/src/ioController.cpp
Normal file
96
Software/src/ioController.cpp
Normal file
@ -0,0 +1,96 @@
|
||||
/*
|
||||
* ioController.cpp
|
||||
*
|
||||
* Created on: 20.11.2018
|
||||
* Author: Hendrik Schutter
|
||||
*/
|
||||
|
||||
#include "openChargeMicro.h"
|
||||
|
||||
ioController::ioController() {
|
||||
ports_init();
|
||||
adc_init();
|
||||
}
|
||||
|
||||
ioController::~ioController() {
|
||||
|
||||
}
|
||||
|
||||
double ioController::get5VProbe() {
|
||||
int tmp = (int) readAdc(2);
|
||||
double ret = ((double) tmp) * 0.006242;
|
||||
return ret;
|
||||
}
|
||||
|
||||
double ioController::get15VProbe() {
|
||||
int tmp = (int) readAdc(1);
|
||||
double ret = ((double) tmp) * 0.014968;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ioController::ports_init() {
|
||||
DDRD |= 1 << WS2812B;
|
||||
DDRB |= 1 << ACTIVELED;
|
||||
DDRB |= 1 << BUZZER;
|
||||
DDRB |= 1 << POWERON;
|
||||
DDRD |= 1 << S2;
|
||||
DDRD |= 1 << S1;
|
||||
DDRD |= 1 << S0;
|
||||
|
||||
DDRC &= ~(1 << PROBE15V);
|
||||
DDRC &= ~(1 << PROBE5V);
|
||||
DDRC &= ~(1 << Z);
|
||||
}
|
||||
|
||||
void ioController::activateChargers() {
|
||||
|
||||
PORTB &= ~(1 << POWERON); //OFF
|
||||
}
|
||||
|
||||
void ioController::deactivateChargers() {
|
||||
PORTB |= (1 << POWERON); //ON
|
||||
}
|
||||
|
||||
void ioController::setActiveLED(bool pBool) {
|
||||
if (pBool) {
|
||||
PORTB |= (1 << ACTIVELED); //ON
|
||||
} else {
|
||||
PORTB &= ~(1 << ACTIVELED); //OFF
|
||||
}
|
||||
}
|
||||
|
||||
void ioController::adc_init(void) {
|
||||
ADMUX = (1 << REFS0); //select AVCC as reference
|
||||
ADCSRA = (1 << ADEN) | 7; //enable and prescale = 128 (16MHz/128 = 125kHz)
|
||||
}
|
||||
|
||||
int ioController::readAdc(char ch) {
|
||||
ADMUX = (1 << REFS0) | (ch & 0x0f); //select input and ref
|
||||
ADCSRA |= (1 << ADSC); //start the conversion
|
||||
while (ADCSRA & (1 << ADSC))
|
||||
; //wait for end of conversion
|
||||
return ADCW;
|
||||
}
|
||||
|
||||
void ioController::setMultiplexer(bool pS2, bool pS1, bool pS0) {
|
||||
|
||||
if (pS0) {
|
||||
PORTD |= (1 << S0); //ON
|
||||
} else {
|
||||
PORTD &= ~(1 << S0); //OFF
|
||||
}
|
||||
|
||||
if (pS1) {
|
||||
PORTD |= (1 << S1); //ON
|
||||
} else {
|
||||
PORTD &= ~(1 << S1); //OFF
|
||||
}
|
||||
|
||||
if (pS2) {
|
||||
PORTD |= (1 << S2); //ON
|
||||
} else {
|
||||
PORTD &= ~(1 << S2); //OFF
|
||||
}
|
||||
|
||||
}
|
||||
|
29
Software/src/ioController.h
Normal file
29
Software/src/ioController.h
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* ioController.h
|
||||
*
|
||||
* Created on: 20.11.2018
|
||||
* Author: Hendrik Schutter
|
||||
*/
|
||||
|
||||
#ifndef SRC_IOCONTROLLER_H_
|
||||
#define SRC_IOCONTROLLER_H_
|
||||
|
||||
class ioController {
|
||||
|
||||
private:
|
||||
|
||||
public:
|
||||
ioController();
|
||||
~ioController();
|
||||
double get5VProbe();
|
||||
double get15VProbe();
|
||||
void ports_init();
|
||||
void activateChargers();
|
||||
void deactivateChargers();
|
||||
void setActiveLED(bool pBool);
|
||||
void adc_init(void);
|
||||
int readAdc(char chan);
|
||||
void setMultiplexer(bool pS2, bool pS1, bool pS0);
|
||||
};
|
||||
|
||||
#endif /* SRC_IOCONTROLLER_H_ */
|
113
Software/src/main.cpp
Normal file
113
Software/src/main.cpp
Normal file
@ -0,0 +1,113 @@
|
||||
#include "openChargeMicro.h"
|
||||
|
||||
int main(void) {
|
||||
|
||||
serialSetup();
|
||||
serialSend("Hello World\r\n");
|
||||
|
||||
ioController io;
|
||||
|
||||
io.deactivateChargers();
|
||||
|
||||
_delay_ms(1000); //Startup delay
|
||||
|
||||
io.setActiveLED(true);
|
||||
io.activateChargers();
|
||||
|
||||
/* create charger */
|
||||
|
||||
s_charger charger_settings;
|
||||
|
||||
charger_settings.chU = 0;
|
||||
charger_settings.chI = 4;
|
||||
charger_settings.nr = 0;
|
||||
charger charger01 = charger(charger_settings);
|
||||
charger01.getInfo();
|
||||
|
||||
charger_settings.chU = 1;
|
||||
charger_settings.chI = 5;
|
||||
charger_settings.nr = 1;
|
||||
charger charger02 = charger(charger_settings);
|
||||
charger02.getInfo();
|
||||
|
||||
charger_settings.chU = 2;
|
||||
charger_settings.chI = 6;
|
||||
charger_settings.nr = 2;
|
||||
charger charger03 = charger(charger_settings);
|
||||
charger03.getInfo();
|
||||
|
||||
charger_settings.chU = 3;
|
||||
charger_settings.chI = 7;
|
||||
charger_settings.nr = 3;
|
||||
charger charger04 = charger(charger_settings);
|
||||
charger04.getInfo();
|
||||
|
||||
/* create charger */
|
||||
|
||||
while (true) {
|
||||
char charVal[10];
|
||||
dtostrf(charger01.getVoltage(), 4, 2, charVal);
|
||||
serialSend("Charger01 - ");
|
||||
serialSend(charVal);
|
||||
serialSend(" Volt\r\n");
|
||||
|
||||
dtostrf(charger01.getCurrent(), 4, 2, charVal);
|
||||
serialSend("Charger01 - ");
|
||||
serialSend(charVal);
|
||||
serialSend(" mAh\r\n");
|
||||
|
||||
dtostrf(charger02.getVoltage(), 4, 2, charVal);
|
||||
serialSend("Charger02 - ");
|
||||
serialSend(charVal);
|
||||
serialSend(" Volt\r\n");
|
||||
dtostrf(charger02.getCurrent(), 4, 2, charVal);
|
||||
serialSend("Charger02 - ");
|
||||
serialSend(charVal);
|
||||
serialSend(" mAh\r\n");
|
||||
|
||||
dtostrf(charger03.getVoltage(), 4, 2, charVal);
|
||||
serialSend("Charger03 - ");
|
||||
serialSend(charVal);
|
||||
serialSend(" Volt\r\n");
|
||||
dtostrf(charger03.getCurrent(), 4, 2, charVal);
|
||||
serialSend("Charger03 - ");
|
||||
serialSend(charVal);
|
||||
serialSend(" mAh\r\n");
|
||||
|
||||
dtostrf(charger04.getVoltage(), 4, 2, charVal);
|
||||
serialSend("Charger04 - ");
|
||||
serialSend(charVal);
|
||||
serialSend(" Volt\r\n");
|
||||
|
||||
dtostrf(charger04.getCurrent(), 4, 2, charVal);
|
||||
serialSend("Charger04 - ");
|
||||
serialSend(charVal);
|
||||
serialSend(" mAh\r\n");
|
||||
|
||||
serialSend("\r\n");
|
||||
|
||||
_delay_ms(1000);
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void serialSetup(void) {
|
||||
//Register settings
|
||||
//High and low bits
|
||||
UBRR0H = (BUAD_RATE_CALC >> 8);
|
||||
UBRR0L = BUAD_RATE_CALC;
|
||||
//transimit and recieve enable
|
||||
UCSR0B = (1 << TXEN0) | (1 << TXCIE0) | (1 << RXEN0) | (1 << RXCIE0);
|
||||
UCSR0C = (1 << UCSZ01) | (1 << UCSZ00); //8 bit data format
|
||||
}
|
||||
|
||||
void serialSend(const char* sendString) {
|
||||
for (unsigned int i = 0; i < strlen(sendString); i++) {
|
||||
while (( UCSR0A & (1 << UDRE0)) == 0) {
|
||||
};
|
||||
UDR0 = sendString[i];
|
||||
}
|
||||
}
|
||||
|
50
Software/src/multiplexer.cpp
Normal file
50
Software/src/multiplexer.cpp
Normal file
@ -0,0 +1,50 @@
|
||||
/*
|
||||
* multiplexer.cpp
|
||||
*
|
||||
* Created on: 20.11.2018
|
||||
* Author: Hendrik Schutter
|
||||
*/
|
||||
|
||||
#include "openChargeMicro.h"
|
||||
|
||||
multiplexer::multiplexer() {
|
||||
|
||||
}
|
||||
multiplexer::~multiplexer() {
|
||||
|
||||
}
|
||||
void multiplexer::setChannel(int pCh) {
|
||||
// see http://www.ti.com/lit/ds/symlink/cd4051b.pdf
|
||||
switch (pCh) {
|
||||
case 0:
|
||||
io.setMultiplexer(0, 0, 0);
|
||||
break;
|
||||
case 1:
|
||||
io.setMultiplexer(0, 0, 1);
|
||||
break;
|
||||
case 2:
|
||||
io.setMultiplexer(0, 1, 0);
|
||||
break;
|
||||
case 3:
|
||||
io.setMultiplexer(0, 1, 1);
|
||||
break;
|
||||
case 4:
|
||||
io.setMultiplexer(1, 0, 0);
|
||||
break;
|
||||
case 5:
|
||||
io.setMultiplexer(1, 0, 1);
|
||||
break;
|
||||
case 6:
|
||||
io.setMultiplexer(1, 1, 0);
|
||||
break;
|
||||
case 7:
|
||||
io.setMultiplexer(1, 1, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
io.setMultiplexer(0, 0, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
22
Software/src/multiplexer.h
Normal file
22
Software/src/multiplexer.h
Normal file
@ -0,0 +1,22 @@
|
||||
/*
|
||||
* multiplexer.h
|
||||
*
|
||||
* Created on: 20.11.2018
|
||||
* Author: Hendrik Schutter
|
||||
*/
|
||||
|
||||
#ifndef SRC_MULTIPLEXER_H_
|
||||
#define SRC_MULTIPLEXER_H_
|
||||
|
||||
class multiplexer {
|
||||
|
||||
private:
|
||||
ioController io;
|
||||
|
||||
public:
|
||||
multiplexer();
|
||||
~multiplexer();
|
||||
void setChannel(int pCh);
|
||||
};
|
||||
|
||||
#endif /* SRC_MULTIPLEXER_H_ */
|
31
Software/src/openChargeMicro.h
Normal file
31
Software/src/openChargeMicro.h
Normal file
@ -0,0 +1,31 @@
|
||||
#include <avr/io.h>
|
||||
#include <string.h>
|
||||
#include <util/delay.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "ioController.h"
|
||||
#include "multiplexer.h"
|
||||
#include "charger.h"
|
||||
|
||||
/* PINS */
|
||||
#define WS2812B PD2
|
||||
#define ACTIVELED PB5
|
||||
#define PROBE15V PC1
|
||||
#define PROBE5V PC2
|
||||
#define Z PC0
|
||||
#define VTX PB3
|
||||
#define VRX PB2
|
||||
#define BUZZER PB1
|
||||
#define POWERON PB0
|
||||
#define S2 PD7
|
||||
#define S1 PD6
|
||||
#define S0 PD5
|
||||
|
||||
#define BUAD 9600
|
||||
#define BUAD_RATE_CALC ((F_CPU/16/BUAD) - 1)
|
||||
|
||||
void serialSetup(void);
|
||||
void serialSend(const char* sendString);
|
||||
|
Reference in New Issue
Block a user