commit 3178911eef51a6e6a898786292a7191f38c3f3db Author: Brad Miller Date: Sun Dec 15 18:30:16 2013 -0500 Initial checkin of unified hierarchy of WPILib 2015 diff --git a/eclipse-plugins/.gitattributes b/eclipse-plugins/.gitattributes new file mode 100644 index 0000000000..02d56eff39 --- /dev/null +++ b/eclipse-plugins/.gitattributes @@ -0,0 +1,3 @@ +*runcppprogram text eol=lf +*runjavaprogram text eol=lf + diff --git a/eclipse-plugins/.gitignore b/eclipse-plugins/.gitignore new file mode 100644 index 0000000000..0a395394eb --- /dev/null +++ b/eclipse-plugins/.gitignore @@ -0,0 +1,4 @@ +*~ +target/ +bin/ +.settings/ \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/.project new file mode 100644 index 0000000000..ade1d91b15 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/.project @@ -0,0 +1,17 @@ + + + edu.wpi.first.wpilib.plugins.core.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/feature.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/feature.xml new file mode 100644 index 0000000000..793fff3221 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/feature.xml @@ -0,0 +1,55 @@ + + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. Redistributions in binary form must reproduce the +* above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. Neither the name of the FIRST nor the +* names of its contributors may be used to endorse or promote +* products derived from this software without specific prior +* written permission. +* +* THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +* EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/pom.xml new file mode 100644 index 0000000000..492382a065 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core.feature/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.core.feature + eclipse-feature + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/.classpath b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/.classpath new file mode 100644 index 0000000000..c0b4c7e112 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/.project new file mode 100644 index 0000000000..10ca0d4f03 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/.project @@ -0,0 +1,28 @@ + + + edu.wpi.first.wpilib.plugins.core + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/META-INF/MANIFEST.MF b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..e79abfe16a --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/META-INF/MANIFEST.MF @@ -0,0 +1,34 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: edu.wpi.first.wpilib.plugins.core +Bundle-SymbolicName: edu.wpi.first.wpilib.plugins.core;singleton:=true +Bundle-Version: 0.1.0.qualifier +Bundle-Activator: edu.wpi.first.wpilib.plugins.core.WPILibCore +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.jface.text, + org.eclipse.core.resources, + org.eclipse.ui.editors, + org.eclipse.ui.ide, + org.eclipse.ant.core;bundle-version="3.2.400", + org.eclipse.ant.launching;bundle-version="1.0.200", + org.eclipse.debug.core;bundle-version="3.7.100", + org.eclipse.core.externaltools;bundle-version="1.0.100", + org.eclipse.debug.ui;bundle-version="3.8.1", + org.eclipse.ui.externaltools;bundle-version="3.2.100", + org.eclipse.ant.ui;bundle-version="3.5.300", + org.eclipse.ui.console;bundle-version="3.5.100", + org.eclipse.ui.navigator;bundle-version="3.5.200", + org.eclipse.ui.navigator.resources;bundle-version="3.4.400", + org.eclipse.ui.intro, + org.eclipse.ui.intro.universal, + org.eclipse.core.expressions;bundle-version="3.4.400" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Export-Package: edu.wpi.first.wpilib.plugins.core, + edu.wpi.first.wpilib.plugins.core.ant, + edu.wpi.first.wpilib.plugins.core.installer, + edu.wpi.first.wpilib.plugins.core.launching, + edu.wpi.first.wpilib.plugins.core.nature, + edu.wpi.first.wpilib.plugins.core.preferences, + edu.wpi.first.wpilib.plugins.core.wizards diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/css/graphics/sample.gif b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/css/graphics/sample.gif new file mode 100644 index 0000000000..5ff1ffc674 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/css/graphics/sample.gif differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/css/graphics/sample_hov.gif b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/css/graphics/sample_hov.gif new file mode 100644 index 0000000000..6874164f5b Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/css/graphics/sample_hov.gif differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/css/sample.css b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/css/sample.css new file mode 100644 index 0000000000..9a094d3b51 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/css/sample.css @@ -0,0 +1,3 @@ + +a#WPILibRobotDevelopment-introLink img { background-image : url(graphics/sample.gif); } +a#WPILibRobotDevelopment-introLink:hover img { background-image : url(graphics/sample_hov.gif); } \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/sample.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/sample.xml new file mode 100644 index 0000000000..ac8bf973f0 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/WPILib Intro/sample.xml @@ -0,0 +1,10 @@ + + + + + + Documentation of how WPILib and it's associated tools work. (Internet Connection Needed) + + + + \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/build.properties new file mode 100644 index 0000000000..6bf048fba1 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/build.properties @@ -0,0 +1,10 @@ +source.. = src/main/java/ +output.. = bin/ +bin.includes = plugin.xml,\ + META-INF/,\ + .,\ + icons/,\ + resources/ +buildDirectory = build/ +plugin.destination = ${basedir}/repository +eclipse.home = /usr/lib/eclipse diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/outlineviewer16x16.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/outlineviewer16x16.png new file mode 100644 index 0000000000..630829e4d7 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/outlineviewer16x16.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/robotbuilder.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/robotbuilder.png new file mode 100644 index 0000000000..feb6e2b768 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/robotbuilder.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/robotbuilder16x16.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/robotbuilder16x16.png new file mode 100644 index 0000000000..042c16252b Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/robotbuilder16x16.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/sample.gif b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/sample.gif new file mode 100644 index 0000000000..34fb3c9d8c Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/sample.gif differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/sfxdashboard16x16.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/sfxdashboard16x16.png new file mode 100644 index 0000000000..82fcb87d56 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/sfxdashboard16x16.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/smartdashboard16x16.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/smartdashboard16x16.png new file mode 100644 index 0000000000..6caef2380f Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/smartdashboard16x16.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/wpi.ico b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/wpi.ico new file mode 100644 index 0000000000..a6de9245f9 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/icons/wpi.ico differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/plugin.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/plugin.xml new file mode 100644 index 0000000000..5447c8b870 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/plugin.xml @@ -0,0 +1,87 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/pom.xml new file mode 100644 index 0000000000..d5113624c9 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.core + eclipse-plugin + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/resources/tools.zip b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/resources/tools.zip new file mode 100644 index 0000000000..0fe1052626 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/resources/tools.zip differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/WPILibCore.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/WPILibCore.java new file mode 100644 index 0000000000..ab8eb09325 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/WPILibCore.java @@ -0,0 +1,130 @@ +package edu.wpi.first.wpilib.plugins.core; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import edu.wpi.first.wpilib.plugins.core.ant.AntPropertiesParser; +import edu.wpi.first.wpilib.plugins.core.installer.ToolsInstaller; +import edu.wpi.first.wpilib.plugins.core.preferences.PreferenceConstants; + +/** + * The activator class controls the plug-in life cycle + */ +public class WPILibCore extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "edu.wpi.first.wpilib.plugins.core"; //$NON-NLS-1$ + + // The shared instance + private static WPILibCore plugin; + + /** + * The constructor + */ + public WPILibCore() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + + new ToolsInstaller(getDefaultVersion()).installIfNecessary(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static WPILibCore getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } + + public Properties getProjectProperties(IProject project) { + List streams = new ArrayList(); + try { + if (project != null) { + try { + streams.add(project.getFile("build.properties").getContents()); + } catch (CoreException e) {} // No properties file + } + File file = new File(getWPILibBaseDir()+"/wpilib.properties"); + streams.add(new FileInputStream(file)); + return new AntPropertiesParser(streams).getProperties(); + } catch (Exception e) { + e.printStackTrace(); + return new Properties(); + } + } + + public void saveGlobalProperties(Properties props) { + try { + props.store(new FileOutputStream(new File(WPILibCore.getDefault().getWPILibBaseDir()+"/wpilib.properties")), + "Don't add new properties, they will be deleted by the eclipse plugin."); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + public int getTeamNumber(IProject project) { + return Integer.parseInt(getProjectProperties(project).getProperty("team-number", "0")); + } + + public String getTargetIP(IProject project) { + String target = getProjectProperties(project).getProperty("target"); + if (target != null) return target; + else { + int teamNumber = getTeamNumber(project); + return "10."+(teamNumber/100)+"."+(teamNumber%100)+".2"; + } + } + + public String getWPILibBaseDir() { + return System.getProperty("user.home")+"/wpilib"; + } + + public String getDefaultVersion() { + return "2013-test-0.4"; + } + + public String getCurrentVersion() { + return getPreferenceStore().getString(PreferenceConstants.TOOLS_VERSION); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunOutlineViewerAction.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunOutlineViewerAction.java new file mode 100644 index 0000000000..ef8f8896f7 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunOutlineViewerAction.java @@ -0,0 +1,71 @@ +package edu.wpi.first.wpilib.plugins.core.actions; + +import java.io.File; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; + +/** + * Our sample action implements workbench action delegate. + * The action proxy will be created by the workbench and + * shown in the UI. When the user tries to use the action, + * this delegate will be created and execution will be + * delegated to it. + * @see IWorkbenchWindowActionDelegate + */ +public class RunOutlineViewerAction implements IWorkbenchWindowActionDelegate { + /** + * The constructor. + */ + public RunOutlineViewerAction() { + } + + /** + * The action has been activated. The argument of the + * method represents the 'real' action sitting + * in the workbench UI. + * @see IWorkbenchWindowActionDelegate#run + */ + public void run(IAction action) { + String jarFile = WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"tools"+File.separator + +WPILibCore.getDefault().getCurrentVersion()+File.separator+"OutlineViewer-with-dependencies.jar"; + String[] cmd = {"java", "-jar", jarFile}; + try { + DebugPlugin.exec(cmd, new File(System.getProperty("user.home"))); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + /** + * Selection in the workbench has been changed. We + * can change the state of the 'real' action here + * if we want, but this can only happen after + * the delegate has been created. + * @see IWorkbenchWindowActionDelegate#selectionChanged + */ + public void selectionChanged(IAction action, ISelection selection) { + } + + /** + * We can use this method to dispose of any system + * resources we previously allocated. + * @see IWorkbenchWindowActionDelegate#dispose + */ + public void dispose() { + } + + /** + * We will cache window object in order to + * be able to provide parent shell for the message dialog. + * @see IWorkbenchWindowActionDelegate#init + */ + public void init(IWorkbenchWindow window) { + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunRobotBuilderAction.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunRobotBuilderAction.java new file mode 100644 index 0000000000..93c8f9ead9 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunRobotBuilderAction.java @@ -0,0 +1,78 @@ +package edu.wpi.first.wpilib.plugins.core.actions; + +import java.io.File; +import java.io.FilenameFilter; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; + +/** + * Our sample action implements workbench action delegate. + * The action proxy will be created by the workbench and + * shown in the UI. When the user tries to use the action, + * this delegate will be created and execution will be + * delegated to it. + * @see IWorkbenchWindowActionDelegate + */ +public class RunRobotBuilderAction implements IWorkbenchWindowActionDelegate { + /** + * The constructor. + */ + public RunRobotBuilderAction() { + } + + /** + * The action has been activated. The argument of the + * method represents the 'real' action sitting + * in the workbench UI. + * @see IWorkbenchWindowActionDelegate#run + */ + public void run(IAction action) { + File dir = new File(WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"tools"+File.separator + +WPILibCore.getDefault().getCurrentVersion()); + File[] files = dir.listFiles(new FilenameFilter() { + @Override public boolean accept(File dir, String name) { + return name.startsWith("RobotBuilder") && name.endsWith(".jar"); + } + }); + if (files.length < 1) return; + String[] cmd = {"java", "-jar", files[0].getAbsolutePath()}; + try { + DebugPlugin.exec(cmd, new File(System.getProperty("user.home"))); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + /** + * Selection in the workbench has been changed. We + * can change the state of the 'real' action here + * if we want, but this can only happen after + * the delegate has been created. + * @see IWorkbenchWindowActionDelegate#selectionChanged + */ + public void selectionChanged(IAction action, ISelection selection) { + } + + /** + * We can use this method to dispose of any system + * resources we previously allocated. + * @see IWorkbenchWindowActionDelegate#dispose + */ + public void dispose() { + } + + /** + * We will cache window object in order to + * be able to provide parent shell for the message dialog. + * @see IWorkbenchWindowActionDelegate#init + */ + public void init(IWorkbenchWindow window) { + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunSFXDashboardAction.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunSFXDashboardAction.java new file mode 100644 index 0000000000..1d64ad916a --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunSFXDashboardAction.java @@ -0,0 +1,71 @@ +package edu.wpi.first.wpilib.plugins.core.actions; + +import java.io.File; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; + +/** + * Our sample action implements workbench action delegate. + * The action proxy will be created by the workbench and + * shown in the UI. When the user tries to use the action, + * this delegate will be created and execution will be + * delegated to it. + * @see IWorkbenchWindowActionDelegate + */ +public class RunSFXDashboardAction implements IWorkbenchWindowActionDelegate { + /** + * The constructor. + */ + public RunSFXDashboardAction() { + } + + /** + * The action has been activated. The argument of the + * method represents the 'real' action sitting + * in the workbench UI. + * @see IWorkbenchWindowActionDelegate#run + */ + public void run(IAction action) { + String jarFile = WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"tools"+File.separator + +WPILibCore.getDefault().getCurrentVersion()+File.separator+"sfx.jar"; + String[] cmd = {"java", "-jar", jarFile}; + try { + DebugPlugin.exec(cmd, new File(System.getProperty("user.home"))); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + /** + * Selection in the workbench has been changed. We + * can change the state of the 'real' action here + * if we want, but this can only happen after + * the delegate has been created. + * @see IWorkbenchWindowActionDelegate#selectionChanged + */ + public void selectionChanged(IAction action, ISelection selection) { + } + + /** + * We can use this method to dispose of any system + * resources we previously allocated. + * @see IWorkbenchWindowActionDelegate#dispose + */ + public void dispose() { + } + + /** + * We will cache window object in order to + * be able to provide parent shell for the message dialog. + * @see IWorkbenchWindowActionDelegate#init + */ + public void init(IWorkbenchWindow window) { + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunSmartDashboardAction.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunSmartDashboardAction.java new file mode 100644 index 0000000000..3f66b3d6eb --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/actions/RunSmartDashboardAction.java @@ -0,0 +1,71 @@ +package edu.wpi.first.wpilib.plugins.core.actions; + +import java.io.File; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.IWorkbenchWindowActionDelegate; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; + +/** + * Our sample action implements workbench action delegate. + * The action proxy will be created by the workbench and + * shown in the UI. When the user tries to use the action, + * this delegate will be created and execution will be + * delegated to it. + * @see IWorkbenchWindowActionDelegate + */ +public class RunSmartDashboardAction implements IWorkbenchWindowActionDelegate { + /** + * The constructor. + */ + public RunSmartDashboardAction() { + } + + /** + * The action has been activated. The argument of the + * method represents the 'real' action sitting + * in the workbench UI. + * @see IWorkbenchWindowActionDelegate#run + */ + public void run(IAction action) { + String jarFile = WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"tools"+File.separator + +WPILibCore.getDefault().getCurrentVersion()+File.separator+"SmartDashboard.jar"; + String[] cmd = {"java", "-jar", jarFile}; + try { + DebugPlugin.exec(cmd, new File(System.getProperty("user.home"))); + } catch (CoreException e) { + e.printStackTrace(); + } + } + + /** + * Selection in the workbench has been changed. We + * can change the state of the 'real' action here + * if we want, but this can only happen after + * the delegate has been created. + * @see IWorkbenchWindowActionDelegate#selectionChanged + */ + public void selectionChanged(IAction action, ISelection selection) { + } + + /** + * We can use this method to dispose of any system + * resources we previously allocated. + * @see IWorkbenchWindowActionDelegate#dispose + */ + public void dispose() { + } + + /** + * We will cache window object in order to + * be able to provide parent shell for the message dialog. + * @see IWorkbenchWindowActionDelegate#init + */ + public void init(IWorkbenchWindow window) { + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/ant/AntPropertiesParser.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/ant/AntPropertiesParser.java new file mode 100644 index 0000000000..e23dc96e53 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/ant/AntPropertiesParser.java @@ -0,0 +1,82 @@ +package edu.wpi.first.wpilib.plugins.core.ant; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Status; + +public class AntPropertiesParser { + List files; + + public AntPropertiesParser(List files) { + this.files = files; + } + + @SuppressWarnings("serial") + public AntPropertiesParser(final InputStream file) { + this(new ArrayList() {{add(file);}}); + } + + public Properties getProperties() throws CoreException { + return getProperties(null); + } + + + public Properties getProperties(Properties defaults) throws CoreException { + Properties props = defaults; + + for (int i = files.size()-1; i >= 0; i--) { + props = getPropertyFile(files.get(i), props); + } + + return props; + } + + public Properties getPropertyFile(InputStream resource, Properties defaults) throws CoreException { + Properties props; + if (defaults == null) props = new Properties(); + else props = new Properties(defaults); + try { + props.load(resource); + } catch (IOException e1) { + System.out.println("Issue loading file: "+resource); + e1.printStackTrace(); + return null; + } + + // TODO: Improve parsing of ant properties + boolean overflow = false; + for (Object key : props.keySet().toArray()) { + int count = 0; + while (props.getProperty((String) key).toString().contains("$") && count < 10) { + Pattern pattern = Pattern.compile( "\\$\\{(.*?)\\}" ); + Matcher matcher = pattern.matcher( props.getProperty((String) key).toString() ); + StringBuffer sb = new StringBuffer(); + while ( matcher.find() ) { + String prop = matcher.group().substring(2, matcher.group().length()-1); + if (props.getProperty(prop) != null) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(props.getProperty(prop))); + } else if (prop.equals("user.home")) { + matcher.appendReplacement(sb, Matcher.quoteReplacement(System.getProperty("user.home"))); + } else { + throw new CoreException(new Status(0, "WPI", "Could not parse build.properties file, unsupported property: "+prop)); + } + } + matcher.appendTail( sb ); + props.setProperty((String) key, sb.toString()); + + count++; + } + if (count >= 50) overflow = true; + } + if (overflow) throw new CoreException(new Status(0, "WPI", "Could not parse build.properties file")); + + return props; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java new file mode 100644 index 0000000000..ac474b0173 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/AbstractInstaller.java @@ -0,0 +1,178 @@ +package edu.wpi.first.wpilib.plugins.core.installer; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.zip.ZipEntry; +import java.util.zip.ZipInputStream; + +import javax.swing.JOptionPane; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.omg.CORBA.Environment; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; + +public abstract class AbstractInstaller { + protected File installLocation; + protected String version; + + public AbstractInstaller(String version) { + this.installLocation = new File(WPILibCore.getDefault().getWPILibBaseDir() + + File.separator + getFeatureName() + File.separator + version); + this.version = version; + } + + /** + * @return The name of the feature being installed. + */ + protected abstract String getFeatureName(); + + /** + * Update the installed version to the latest version. + * @param version The latest version installed. + */ + protected abstract void updateInstalledVersion(String version); + + /** + * @return The input stream to the zip file being installed. + */ + protected abstract InputStream getInstallResourceStream(); + + public void installIfNecessary() { + System.out.println("Installing "+getFeatureName()+" if necessary"); + try { + System.out.println("Install Location: " + + installLocation.getCanonicalPath()); + } catch (IOException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + + + if (!isInstalled()) { + System.out.println("Install necessary"); + try { + install(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + updateInstalledVersion(version); + System.out.println("Installed"); + } + + /** + * This function has been updated to guarantee that the wpilib folder date + * is older than the jar file being run, which ensures up to date tools. + * + * @return True for is there and newer, false otherwise. + */ + public boolean isInstalled() { + if(installLocation.exists()) + { + File coreJar = new File(AbstractInstaller.class.getProtectionDomain() + .getCodeSource().getLocation().getPath()); + if(installLocation.lastModified() <= coreJar.lastModified()) + { + return false; + } + else return true; + } + else return false; + } + + /** + * This function will delete an old wpilib subfolder if necessary and then copy + * the resource stream to the intended directory. + * + * @throws IOException if bad things happen ... + */ + public void install() throws IOException { + if(installLocation.exists()) { + if(!removeFileHandler(installLocation, true)) { + JOptionPane.showMessageDialog(null, + String.format("Could not update the old wpilib folder.%n" + + "Please close any WPILib tools and restart Eclipse.")); + } + else + removeFileHandler(installLocation, false); + } + + installLocation.mkdirs(); + if (System.getProperty("os.name").startsWith("Mac OS X")) { // MACs are special... + InputStream zip = getInstallResourceStream(); + File tmpFile = File.createTempFile(getFeatureName()+"-", ".zip"); + FileOutputStream fout = new FileOutputStream(tmpFile); + copyStreams(zip, fout); + zip.close(); + fout.close(); + String[] cmd = {"unzip", tmpFile.getAbsolutePath(), "-d", installLocation.getAbsolutePath()}; + System.out.println("unzip "+tmpFile.getAbsolutePath()+" -d "+installLocation.getAbsolutePath()); + try { + InputStream is = DebugPlugin.exec(cmd, installLocation).getInputStream(); + copyStreams(is, System.out); + } catch (CoreException e) { + e.printStackTrace(); + } + } else { + ZipInputStream zip = new ZipInputStream(getInstallResourceStream()); + ZipEntry entry = zip.getNextEntry(); + while (entry != null) { + System.out.println("\tZipEntry " + entry + ": " + entry.getSize()); + File f = new File(installLocation, entry.getName()); + if (entry.isDirectory()) { + f.mkdirs(); + } else { + FileOutputStream fo = new FileOutputStream(f); + copyStreams(zip, fo); + fo.close(); + } + + zip.closeEntry(); + entry = zip.getNextEntry(); + } + zip.close(); + } + } + + private static void copyStreams(InputStream source, OutputStream destination) throws IOException { + byte[] buffer = new byte[1024]; + int len; + + while((len = source.read(buffer)) >= 0){ + destination.write(buffer,0,len); + } + } + + /** + * Recursively remove all of the files and folders described by this file handler. + * + * @param file The file to remove + * @param testRun True to just test if the files can be deleted + * @return True if this and all subFiles were removed, false otherwise. + */ + private static boolean removeFileHandler(File file, boolean testRun) { + // if normal files (data files and the like) + if(file.isFile()) { + if(testRun) return file.getParentFile().canWrite(); + else return file.delete(); + } + // if folders + else if(file.isDirectory()) { + for(File f : file.listFiles()) { + if(!removeFileHandler(f, testRun)) + return false; + } + if(testRun) return file.getParentFile().canWrite(); + else return file.delete(); + } + // I'm not sure what to do if the file is not normal or a directory ... + else return false; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/ToolsInstaller.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/ToolsInstaller.java new file mode 100644 index 0000000000..b36ab8b922 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/installer/ToolsInstaller.java @@ -0,0 +1,38 @@ +package edu.wpi.first.wpilib.plugins.core.installer; + +import java.io.InputStream; +import java.util.Properties; + +import org.eclipse.jface.preference.IPreferenceStore; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.preferences.PreferenceConstants; + +public class ToolsInstaller extends AbstractInstaller { + + public ToolsInstaller(String version) { + super(version); + } + + @Override + protected String getFeatureName() { + return "tools"; + } + + @Override + protected void updateInstalledVersion(String version) { + IPreferenceStore prefs = WPILibCore.getDefault().getPreferenceStore(); + if (prefs.getBoolean(PreferenceConstants.UPDATE_TOOLS_VERSION)) { + System.out.println("Forcing library version to "+version); + Properties props = WPILibCore.getDefault().getProjectProperties(null); + props.setProperty("version", version); + WPILibCore.getDefault().saveGlobalProperties(props); + prefs.setValue(PreferenceConstants.TOOLS_VERSION, version); + } + } + + @Override + protected InputStream getInstallResourceStream() { + return ToolsInstaller.class.getResourceAsStream("/resources/tools.zip"); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/launching/AntLauncher.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/launching/AntLauncher.java new file mode 100644 index 0000000000..8f1b363a93 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/launching/AntLauncher.java @@ -0,0 +1,144 @@ +package edu.wpi.first.wpilib.plugins.core.launching; + +import java.io.File; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.ant.internal.ui.launchConfigurations.AntLaunchShortcut; +import org.eclipse.ant.launching.IAntLaunchConstants; +import org.eclipse.core.externaltools.internal.IExternalToolConstants; +import org.eclipse.core.runtime.Path; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfiguration; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.ui.IWorkbenchPage; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.console.IConsoleConstants; + +/** + * Contains functions to launch ant scripts while having the output sent to the + * console. Allows for the use of arguments, the specification of targets, and + * the choice of launch modes + * + * @author Ryan O'Meara + */ +@SuppressWarnings("restriction") +public class AntLauncher { + private static boolean installing = false; + + /** + * Runs an ant script's target's with the given arguments, in the given launch mode + * @param antScript A java.io.File representation of the ant file to execute + * @param targets A String of the ant targets to run. For multiple targets, + * format if "target1,target2". For no targets, this argument can be null. This + * method will assume output should be sent to the console, same as calling + * runAntFile(antScript, targets, arguments, mode, true) + * @param arguments A String of arguments to run the file with. Format is + * "-argument1 -argument2". For no arguments, this argument can be null + * @param mode String, either "run" or "debug". If an invalid input is given, + * defaults to "run" + * @return The ILaunch started, or null if it failed to start + */ + public static ILaunch runAntFile(File antScript, String targets, String arguments, String mode){ + return runAntFile(antScript, targets, arguments, mode, true); + } + + /** + * Runs an ant script's target's with the given arguments, in the given launch mode + * @param antScript A java.io.File representation of the ant file to execute + * @param targets A String of the ant targets to run. For multiple targets, + * format if "target1,target2". For no targets, this argument can be null. Allows + * choice of outputting to the console + * @param arguments A String of arguments to run the file with. Format is + * "-argument1 -argument2". For no arguments, this argument can be null + * @param mode String, either "run" or "debug". If an invalid input is given, + * defaults to "run" + * @param outputToConsole If true, output will be sent to console, if false it will not + * @return The ILaunch started, or null if it failed to start + */ + public static ILaunch runAntFile(File antScript, String targets, String arguments, String mode, boolean outputToConsole){ + //Input error checking + if((mode == null)||(!mode.equalsIgnoreCase(ILaunchManager.DEBUG_MODE))){mode = ILaunchManager.RUN_MODE;} //Launcher only accepts run or debug + if((targets != null)&&(targets.equalsIgnoreCase(""))){targets = null;} //Standardize representation of "none" + if((arguments != null)&&(arguments.equalsIgnoreCase(""))){arguments = null;} + + if(antScript.getAbsolutePath().indexOf("install.xml") != -1){ + installing = true; + }else{ + installing = false; + } + + ILaunch ret = null; + + try{ + + //Show the console + if(outputToConsole){ + try{ + final IWorkbenchPage activePage = PlatformUI.getWorkbench() + .getActiveWorkbenchWindow() + .getActivePage(); + activePage.showView(IConsoleConstants.ID_CONSOLE_VIEW); + }catch(Exception e){} + } + + //Get an ant launch config setup to use eclipse VM - which users will setup to be the jdk, + //allowing the use of javac. Also sets the location of the file to execute + ILaunchConfiguration launcher = AntLaunchShortcut.createDefaultLaunchConfiguration(new Path(antScript.getAbsolutePath()), null); + + //Get copy that can be edited + ILaunchConfigurationWorkingCopy workingCopy = launcher.getWorkingCopy(); + + //Prevent this configuration from appearing in history or dialogs + workingCopy.setAttribute(ILaunchManager.ATTR_PRIVATE, false); + + //Setup to show output on console + if(outputToConsole){ + workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, true); + workingCopy.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, true); + }else{ + workingCopy.setAttribute(DebugPlugin.ATTR_CAPTURE_OUTPUT, false); + workingCopy.setAttribute(IExternalToolConstants.ATTR_SHOW_CONSOLE, false); + } + + + workingCopy.setAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND, true); + + if(targets != null){ + workingCopy.setAttribute(IAntLaunchConstants.ATTR_ANT_TARGETS, targets); + } + + if(arguments != null){ + workingCopy.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, arguments); + } + + if(mode.equals(ILaunchManager.DEBUG_MODE)){ + Set modes = new HashSet(); + modes.add(ILaunchManager.DEBUG_MODE); + workingCopy.addModes(modes); + } + + //Save/assert all changes + launcher = workingCopy.doSave(); + + //Launch the modified configuration in the specified mode + try{ret = launcher.launch(mode, null, true, true);}catch(Exception e){ + //Does not need Output, handled and resolved internally + e.printStackTrace(); + return null; + } + }catch(Exception e){ + e.printStackTrace(); + return null; + } + + return ret; + } + + public static boolean isInstalling(){ + return installing; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/nature/FRCProjectNature.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/nature/FRCProjectNature.java new file mode 100644 index 0000000000..085ee93420 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/nature/FRCProjectNature.java @@ -0,0 +1,97 @@ +package edu.wpi.first.wpilib.plugins.core.nature; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectNature; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; + + +/** + * Project nature which configures any project which is given it to be an + * FRC Project, and designates it so FRC options will be enabled to act on + * it + * + */ +public class FRCProjectNature implements IProjectNature { + + public static final String FRC_PROJECT_NATURE = + "edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature"; + + + private IProject internalProject; + + /** + * IStatus representing a failed configuration attempt + * + * @author Ryan O'Meara + */ + private class FRCProjectFailedStatus implements IStatus{ + String message; + + public FRCProjectFailedStatus(String message){ + this.message = message; + } + + @Override + public IStatus[] getChildren() {return null;} + + @Override + public int getCode() {return 0;} + + @Override + public Throwable getException() {return null;} + + @Override + public String getMessage() {return message;} + + @Override + public String getPlugin() {return WPILibCore.PLUGIN_ID;} + + @Override + public int getSeverity() {return ERROR;} + + @Override + public boolean isMultiStatus() {return false;} + + @Override + public boolean isOK() {return false;} + + @Override + public boolean matches(int severityMask) { + if((severityMask & ERROR) == ERROR){return true;} + return false; + } + } + + public FRCProjectNature(){ + internalProject = null; + } + + @Override + public void configure() throws CoreException { + if(internalProject == null){ + throw new CoreException( + new FRCProjectFailedStatus("No project set")); + } + } + + @Override + public void deconfigure() throws CoreException { + if(internalProject == null){ + throw new CoreException( + new FRCProjectFailedStatus("No project set")); + } + } + + @Override + public IProject getProject() { + return internalProject; + } + + @Override + public void setProject(IProject project) { + internalProject = project; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/ComboFieldEditor.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/ComboFieldEditor.java new file mode 100644 index 0000000000..789d6c981c --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/ComboFieldEditor.java @@ -0,0 +1,69 @@ +package edu.wpi.first.wpilib.plugins.core.preferences; + +import java.util.List; + +import org.eclipse.jface.preference.FieldEditor; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; + +public class ComboFieldEditor extends FieldEditor { + private List choices; + private Composite parent; + Combo comboDropDown; + + public ComboFieldEditor(String preference, String label, Composite parent, List choices) { + super(preference, label, parent); + this.choices = choices; + for (String choice : choices) { + comboDropDown.add(choice); + } + } + + public void setChoice(String item) { + comboDropDown.select(choices.indexOf(item)); + } + + public String getChoice() { + return choices.get(comboDropDown.getSelectionIndex()); + } + + @Override protected void adjustForNumColumns(int numColumns) { + ((GridData) parent.getLayoutData()).horizontalSpan = numColumns; + } + + @Override protected void doFillIntoGrid(Composite parent, int numColumns) { + this.parent = parent; + + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = numColumns; + parent.setLayoutData(gd); + + Label label = getLabelControl(parent); + label.setText(getLabelText()); + + comboDropDown = new Combo(parent, SWT.DROP_DOWN | SWT.BORDER); + gd = new GridData(GridData.FILL_HORIZONTAL); + comboDropDown.setLayoutData(gd); + } + + @Override protected void doLoad() { + String item = getPreferenceStore().getString(getPreferenceName()); + setChoice(item); + } + + @Override protected void doLoadDefault() { + String item = getPreferenceStore().getDefaultString(getPreferenceName()); + setChoice(item); + } + + @Override protected void doStore() { + getPreferenceStore().setValue(getPreferenceName(), getChoice()); + } + + @Override public int getNumberOfControls() { + return 2; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/PreferenceConstants.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/PreferenceConstants.java new file mode 100644 index 0000000000..533a5e54b3 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/PreferenceConstants.java @@ -0,0 +1,10 @@ +package edu.wpi.first.wpilib.plugins.core.preferences; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + public static final String TEAM_NUMBER = "teamNumberPreference"; + public static final String TOOLS_VERSION = "toolsVersionPreference"; + public static final String UPDATE_TOOLS_VERSION = "udpateToolsVersionPreference"; +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/PreferenceInitializer.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/PreferenceInitializer.java new file mode 100644 index 0000000000..8697809fa9 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/PreferenceInitializer.java @@ -0,0 +1,25 @@ +package edu.wpi.first.wpilib.plugins.core.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = WPILibCore.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.TEAM_NUMBER, + WPILibCore.getDefault().getProjectProperties(null).getProperty("team-number", "0")); + store.setDefault(PreferenceConstants.TOOLS_VERSION, WPILibCore.getDefault().getDefaultVersion()); + store.setDefault(PreferenceConstants.UPDATE_TOOLS_VERSION, true); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/WPILibPreferencePage.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/WPILibPreferencePage.java new file mode 100644 index 0000000000..63703cd7a5 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/preferences/WPILibPreferencePage.java @@ -0,0 +1,98 @@ +package edu.wpi.first.wpilib.plugins.core.preferences; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Properties; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.jface.preference.IntegerFieldEditor; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing FieldEditorPreferencePage, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + *

+ * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class WPILibPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + IntegerFieldEditor teamNumberEditor; + private ComboFieldEditor toolsVersionEditor; + private BooleanFieldEditor autoUpdateEditor; + + public WPILibPreferencePage() { + super(GRID); + setPreferenceStore(WPILibCore.getDefault().getPreferenceStore()); + setDescription("A preference page for changing all workspace level settings."); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + teamNumberEditor = new IntegerFieldEditor(PreferenceConstants.TEAM_NUMBER, + "&Team Number:", getFieldEditorParent()); + addField(teamNumberEditor); + toolsVersionEditor = new ComboFieldEditor(PreferenceConstants.TOOLS_VERSION, + "&Tools Version:", getFieldEditorParent(), getInstalledVersions()); + addField(toolsVersionEditor); + autoUpdateEditor = new BooleanFieldEditor(PreferenceConstants.UPDATE_TOOLS_VERSION, + "&Auto Update Tools Version", getFieldEditorParent()); + addField(autoUpdateEditor); + } + + private List getInstalledVersions() { + File[] dirs = new File(WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"tools") + .listFiles(new FileFilter() { + @Override public boolean accept(File f) { + return f.isDirectory(); + } + }); + List versions = new ArrayList(); + for (File dir : dirs) { + versions.add(dir.getName()); + } + Collections.sort(versions); + return versions; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + System.out.println("Preferences initialized."); + Properties props = WPILibCore.getDefault().getProjectProperties(null); + getPreferenceStore().setValue(PreferenceConstants.TEAM_NUMBER, + Integer.parseInt(props.getProperty("team-number", "0"))); + } + + @Override public void performApply() { + performOk(); + } + + @Override public boolean performOk() { + Properties props = WPILibCore.getDefault().getProjectProperties(null); + props.setProperty("team-number", teamNumberEditor.getStringValue()); + WPILibCore.getDefault().saveGlobalProperties(props); + return super.performOk(); + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ExampleWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ExampleWizard.java new file mode 100644 index 0000000000..90e99ab6ee --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ExampleWizard.java @@ -0,0 +1,88 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + +import java.net.URL; +import java.util.List; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.IWizardPage; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWizard; + +public abstract class ExampleWizard extends Wizard implements INewWizard { + private ExampleWizardChoicePage page1; + private IWizardPage page2; + protected ISelection selection; + private TeamNumberPage teamNumberPage; + + /** + * Constructor for SampleNewWizard. + */ + public ExampleWizard() { + super(); + setNeedsProgressMonitor(true); + } + + /** + * The worker method. It will find the container, create the + * file if missing or just replace its contents, and open + * the editor on the newly created file. + */ + protected abstract void doFinish(IExampleProject ex, String teamNumber) throws CoreException; + + protected abstract IWizardPage getDetailsPage(); + + public abstract IExampleProject makeExampleProject(String name, String description, + List tags, List folders, List files); + + public abstract URL getResourceURL(); + + public abstract String getXMLFile(); + + protected TeamNumberPage getTeamNumberPage() { + return teamNumberPage; + } + + /** + * Adding the page to the wizard. + */ + + public void addPages() { + if (TeamNumberPage.needsTeamNumberPage()) { + teamNumberPage = new TeamNumberPage(selection); + addPage(teamNumberPage); + } + page1 = new ExampleWizardChoicePage(this, selection); + addPage(page1); + page2 = getDetailsPage(); + addPage(page2); + } + + /** + * This method is called when 'Finish' button is pressed in + * the wizard. We will create an operation and run it + * using wizard as execution context. + */ + public boolean performFinish() { + try { + doFinish(page1.getExampleProject(), TeamNumberPage.getTeamNumberFromPage(teamNumberPage)); + } catch (CoreException e) { + e.printStackTrace(); + MessageDialog.openError(getShell(), "Error", e.getMessage()); + return false; + } + return true; + } + /** + * We will accept the selection in the workbench to see if + * we can initialize from it. + * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.selection = selection; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ExampleWizardChoicePage.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ExampleWizardChoicePage.java new file mode 100644 index 0000000000..91ef974112 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ExampleWizardChoicePage.java @@ -0,0 +1,238 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.eclipse.jface.dialogs.IDialogPage; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.events.SelectionListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Tree; +import org.eclipse.swt.widgets.TreeItem; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +/** + * The "New" wizard page allows setting the container for the new file as well + * as the file name. The page will only accept file name without the extension + * OR with the extension that matches the expected one (mpe). + */ + +public class ExampleWizardChoicePage extends WizardPage { + private Tree exampleTree; + private Browser descriptionText; + private IExampleProject selectedExample; + private ExampleWizard parent; + + /** + * Constructor for SampleNewWizardPage. + * + * @param pageName + */ + public ExampleWizardChoicePage(ExampleWizard parent, ISelection selection) { + super("wizardPage"); + this.parent = parent; + setTitle("Select Example Project to Create"); + setDescription("This wizard creates a new example project based on your selection."); + } + + /** + * @see IDialogPage#createControl(Composite) + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 2; + layout.verticalSpacing = 9; + + exampleTree = new Tree(container, SWT.BORDER); + GridData gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); + gd.heightHint = 400; + exampleTree.setLayoutData(gd); + exampleTree.addSelectionListener(new SelectionListener() { + @Override + public void widgetSelected(SelectionEvent arg0) { + dialogChanged(); + } + @Override + public void widgetDefaultSelected(SelectionEvent arg0) { + dialogChanged(); + } + }); + + descriptionText = new Browser(container, SWT.BORDER); + gd = new GridData(GridData.FILL_HORIZONTAL | GridData.FILL_VERTICAL); + gd.heightHint = 400; + gd.widthHint = 300; + descriptionText.setLayoutData(gd); + + initialize(); + dialogChanged(); + setControl(container); + } + + /** + * Tests if the current workbench selection is a suitable container to use. + */ + + private void initialize() { + Document doc = loadXMLResource(parent.getXMLFile()); + + // Generate all of the tags + List tags = new ArrayList(); + NodeList nList = doc.getElementsByTagName("tagDescription"); + for (int i = 0; i < nList.getLength(); i++) { + if (nList.item(i).getNodeType() == Node.ELEMENT_NODE) { + tags.add(generateTagFromElement((Element) nList.item(i))); + } + } + + // Generate all of the example projects + List examples = new ArrayList(); + nList = doc.getElementsByTagName("example"); + for (int i = 0; i < nList.getLength(); i++) { + if (nList.item(i).getNodeType() == Node.ELEMENT_NODE) { + examples.add(generateExampleFromElement((Element) nList.item(i))); + } + } + + System.out.println(examples); + System.out.println(tags); + + // Generate the tags tree + for (Tag tag : tags) { + TreeItem tagItem = new TreeItem(exampleTree, SWT.NONE); + tagItem.setData(tag); + tagItem.setText(tag.getName()); + for (IExampleProject ex : examples) { + if (ex.getTags().contains(tag.getName())) { + TreeItem exItem = new TreeItem(tagItem, SWT.NONE); + exItem.setData(ex); + exItem.setText(ex.getName()); + } + } + tagItem.setExpanded(true); + } + } + + /** + * Ensures that both text fields are set. + */ + + private void dialogChanged() { + if (exampleTree.getSelection().length > 0) { + Object selectedData = exampleTree.getSelection()[0].getData(); + if (selectedData instanceof IExampleProject) { + IExampleProject example = (IExampleProject) selectedData; + descriptionText.setText(example.getContent()); + selectedExample = example; + } else if (selectedData instanceof Tag) { + Tag tag = (Tag) selectedData; + descriptionText.setText(tag.getContent()); + selectedExample = null; + } else selectedExample = null; + } + + if (selectedExample == null) { + updateStatus("Must select a valid example before continuing."); + return; + } + + updateStatus(null); + } + + private void updateStatus(String message) { + setErrorMessage(message); + setPageComplete(message == null); + } + + private Document loadXMLResource(String filename) { + final URL installURL = parent.getResourceURL(); + URL url = null; + try { + url = new URL(installURL, filename); + } catch (final MalformedURLException e) { + e.printStackTrace(); + return null; + } + DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder dBuilder; + Document doc; + try { + dBuilder = dbFactory.newDocumentBuilder(); + doc = dBuilder.parse(url.openStream()); + } catch (ParserConfigurationException e) { + e.printStackTrace(); + return null; + } catch (SAXException e) { + e.printStackTrace(); + return null; + } catch (IOException e) { + e.printStackTrace(); + return null; + } + doc.getDocumentElement().normalize(); + return doc; + } + + private Tag generateTagFromElement(Element element) { + String name = element.getElementsByTagName("name").item(0).getTextContent(); + String description = element.getElementsByTagName("description").item(0).getTextContent(); + return new Tag(name, description); + } + + private IExampleProject generateExampleFromElement(Element element) { + String name = element.getElementsByTagName("name").item(0).getTextContent(); + String description = element.getElementsByTagName("description").item(0).getTextContent(); + List tags = new ArrayList(); + Node tagsElement = element.getElementsByTagName("tags").item(0); + if (tagsElement.getNodeType() == Node.ELEMENT_NODE) { + NodeList tagElementList = ((Element) tagsElement).getElementsByTagName("tag"); + for (int i = 0; i < tagElementList.getLength(); i++) { + tags.add(tagElementList.item(i).getTextContent()); + } + } + List packages = new ArrayList(); + tagsElement = element.getElementsByTagName("packages").item(0); + if (tagsElement.getNodeType() == Node.ELEMENT_NODE) { + NodeList elementList = ((Element) tagsElement).getElementsByTagName("package"); + for (int i = 0; i < elementList.getLength(); i++) { + packages.add(elementList.item(i).getTextContent()); + } + } + List files = new ArrayList(); + tagsElement = element.getElementsByTagName("files").item(0); + if (tagsElement.getNodeType() == Node.ELEMENT_NODE) { + NodeList elementList = ((Element) tagsElement).getElementsByTagName("file"); + for (int i = 0; i < elementList.getLength(); i++) { + if (elementList.item(i).getNodeType() == Node.ELEMENT_NODE) { + element = (Element) elementList.item(i); + files.add(new IExampleProject.ExportFile(element.getAttribute("source"), + element.getAttribute("destination"))); + } + } + } + return parent.makeExampleProject(name, description, tags, packages, files); + } + + public IExampleProject getExampleProject() { + return selectedExample; + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/IExampleProject.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/IExampleProject.java new file mode 100644 index 0000000000..3b1860cb1b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/IExampleProject.java @@ -0,0 +1,17 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + +import java.util.List; + +public interface IExampleProject extends ProjectType { + public String getName(); + public String getContent(); + public List getTags(); + + static class ExportFile { + public String source, destination; + public ExportFile(String source, String destination) { + this.source = source; + this.destination = destination; + } + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/IProjectCreator.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/IProjectCreator.java new file mode 100644 index 0000000000..4b64ade470 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/IProjectCreator.java @@ -0,0 +1,60 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + +import java.util.List; +import java.util.Map; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; + +/** + * An interface for providing hooks into the project creation + * process. It provides necessary information and can perform + * both initialization and finalization of the project + * creation process. + * + * @author Alex Henning + */ +public interface IProjectCreator { + + /** + * @return The name of the project to create. + */ + String getName(); + + /** + * @return The main package to be created. Should be an + * empty string if irrelevant. + */ + String getPackageName(); + + /** + * @return Map of keys to be substituted with values + * during the creation process. + */ + Map getValues(); + + /** + * @return The natures that this project should have. + */ + List getNatures(); + + /** + * @return A project type object that provides files + * and directories to create. + */ + ProjectType getProjectType(); + + /** + * Run extra initialization code on the project. + * @param project The project being created + * @throws CoreException + */ + void initialize(IProject project) throws CoreException; + + /** + * Run extra finalization code on the project. + * @param project The project being created + * @throws CoreException + */ + void finalize(IProject project) throws CoreException; +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/IProjectFilter.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/IProjectFilter.java new file mode 100644 index 0000000000..74b1e63745 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/IProjectFilter.java @@ -0,0 +1,17 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + +import org.eclipse.core.resources.IProject; + +/** + * A filter that can be used to select projects. + * + * @author alex + * + */ +public interface IProjectFilter { + /** + * @param project The project to check. + * @return Whether or to accept the project. + */ + boolean accept(IProject project); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/NewProjectMainPage.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/NewProjectMainPage.java new file mode 100644 index 0000000000..972d9ebed9 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/NewProjectMainPage.java @@ -0,0 +1,197 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + +import java.util.Map; + +import javax.swing.event.ChangeEvent; +import javax.swing.event.ChangeListener; + +import org.eclipse.jface.dialogs.IDialogPage; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Group; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +/** + * The "New" wizard page allows setting the container for the new file as well + * as the file name. The page will only accept file name without the extension + * OR with the extension that matches the expected one (mpe). + */ + +public class NewProjectMainPage extends WizardPage { + private Text projectNameText; + private Text packageText; + Map types; + + Button simpleRobot, iterativeRobot, commandRobot; + private boolean showPackage; + private boolean showProjectTypes; + private TeamNumberPage teamNumberPage; + + /** + * Constructor for SampleNewWizardPage. + * @param teamNumberPage + * + * @param pageName + */ + public NewProjectMainPage(ISelection selection, TeamNumberPage teamNumberPage) { + super("wizardPage"); + this.teamNumberPage = teamNumberPage; + showPackage = true; + showProjectTypes = false; + } + + /** + * @see IDialogPage#createControl(Composite) + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 2; + layout.verticalSpacing = 9; + Label label = new Label(container, SWT.NULL); + label.setText("Project &Name:"); + + projectNameText = new Text(container, SWT.BORDER | SWT.SINGLE); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + projectNameText.setLayoutData(gd); + projectNameText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + + if (showPackage) { + label = new Label(container, SWT.NULL); + label.setText("&Package:"); + + packageText = new Text(container, SWT.BORDER | SWT.SINGLE); + gd = new GridData(GridData.FILL_HORIZONTAL); + packageText.setLayoutData(gd); + packageText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + } + + if (showProjectTypes) { + Group projectTypeGroup = new Group(container, SWT.BORDER); + projectTypeGroup.setText("Project Type"); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + projectTypeGroup.setLayoutData(gd); + GridLayout groupLayout = new GridLayout(); + groupLayout.numColumns = 1; + projectTypeGroup.setLayout(groupLayout); + + simpleRobot = new Button(projectTypeGroup, SWT.RADIO | SWT.WRAP); + //simpleRobot.setData( RWT.MARKUP_ENABLED, Boolean.TRUE ); + simpleRobot.setText("Simple Robot: A flexible robot project intended for robots that implement basic functionality. Can also be used as a starting point for teams with a custom framework."); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint = 300; + simpleRobot.setLayoutData(gd); + simpleRobot.setSelection(true); + + iterativeRobot = new Button(projectTypeGroup, SWT.RADIO | SWT.WRAP); + iterativeRobot.setText("Iterative Robot: A robot project that allows robots to be implemented in an iterative manner."); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint = 300; + iterativeRobot.setLayoutData(gd); + + commandRobot = new Button(projectTypeGroup, SWT.RADIO | SWT.WRAP); + commandRobot.setText("Command-Based Robot: A robot project that allows robots to be implemented using the command based model to allow complex functionality to be developed from simpler functionality."); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.widthHint = 300; + commandRobot.setLayoutData(gd); + } + + initialize(); + dialogChanged(); + setControl(container); + } + + /** + * Tests if the current workbench selection is a suitable container to use. + */ + private void initialize() { + String teamNumber = TeamNumberPage.getTeamNumberFromPage(teamNumberPage); + if (showPackage) { + packageText.setText("com.first.team"+teamNumber+".robot"); + if (teamNumberPage != null) { + teamNumberPage.registerChangeListener(new ChangeListener() { + @Override public void stateChanged(ChangeEvent e) { + String teamNumber = TeamNumberPage.getTeamNumberFromPage(teamNumberPage); + packageText.setText("com.first.team"+teamNumber+".robot"); + + } + }); + } + } + } + + /** + * Ensures that both text fields are set. + */ + private void dialogChanged() { + String projectName = getProjectName(); + + String packageString = ""; + if (showPackage) packageString = getPackage(); + + if (projectName.length() == 0) { + updateStatus("Project name must be specified"); + return; + } + if (showPackage && packageString.length() == 0) { + updateStatus("Package must be specified"); + return; + } + if (showPackage && !packageString.matches("^([a-zA-Z_]{1}[a-zA-Z0-9_]*(\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*)*)$")) { + updateStatus("Must be valid java package"); + return; + } + updateStatus(null); + } + + private void updateStatus(String message) { + setErrorMessage(message); + setPageComplete(message == null); + } + + public String getProjectName() { + return projectNameText.getText(); + } + + public String getPackage() { + return packageText.getText(); + } + + public ProjectType getProjectType() { + if (!showProjectTypes) return null; + else if (simpleRobot.getSelection()) return types.get(ProjectType.SIMPLE); + else if (iterativeRobot.getSelection()) return types.get(ProjectType.ITERATIVE); + else return types.get(ProjectType.COMMAND_BASED); + } + + public void setShowPackage(boolean bool) { + showPackage = bool; + } + + public void setShowProjectTypes(boolean bool) { + showProjectTypes = bool; + } + + public void setProjectTypes(Map types) { + showProjectTypes = true; + this.types = types; + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ProjectComboField.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ProjectComboField.java new file mode 100644 index 0000000000..abfd84ecb3 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ProjectComboField.java @@ -0,0 +1,51 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + +import java.util.Arrays; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.widgets.Combo; +import org.eclipse.swt.widgets.Composite; + +public class ProjectComboField { + public static String NO_PROJECT = "No Project"; + + private Combo combo; + + public ProjectComboField(Composite composite, int config, IProjectFilter filter) { + combo = new Combo(composite, config); + + combo.add(NO_PROJECT); + combo.select(0); + IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); + for (IProject project : projects) { + if (filter == null || filter.accept(project)) + combo.add(project.getName()); + } + } + + public void setProject(IProject project) { + if (project != null) + combo.select(Arrays.binarySearch(combo.getItems(), project.getName())); + else combo.select(0); + } + + public IProject getProject() { + return ResourcesPlugin.getWorkspace().getRoot().getProject(combo.getItem(combo.getSelectionIndex())); + } + + public boolean isValid() { + return combo.getSelectionIndex() != 0; + } + + public void setLayoutData(GridData gd) { + combo.setLayoutData(gd); + } + + public void addModifyListener(ModifyListener modifyListener) { + combo.addModifyListener(modifyListener); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ProjectCreationUtils.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ProjectCreationUtils.java new file mode 100644 index 0000000000..8f7ddc57f6 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ProjectCreationUtils.java @@ -0,0 +1,195 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.io.Reader; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.Map; +import java.util.Map.Entry; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.Path; + +/** + * Utilities for creating a new project and files from templates. Uses + * IProjectCreator to provide hooks for generating the directory + * structure, initial files, initializing and finalizing the creation + * of the new project. + * + * @author Alex Henning + **/ +public class ProjectCreationUtils { + + /** + * Create a project using the given IProjectCreator. + * + * @param creator The creator that provides the necessary information + * to create the project. + * @return The newly created project. + */ + public static IProject createProject(IProjectCreator creator) { + IProject project = createBaseProject(creator.getName(), null); + + try { + creator.initialize(project); + for (String nature : creator.getNatures()) { + addNature(project, nature); + } + addToProjectStructure(project, creator); + addFilesToProject(project, creator); + creator.finalize(project); + } catch (CoreException e) { + e.printStackTrace(); + project = null; + } + + return project; + } + + private static IProject createBaseProject(String projectName, IPath location) { + IProject newProject = ResourcesPlugin.getWorkspace().getRoot().getProject(projectName); + + if (!newProject.exists()) { + IPath projectLocation = location; + IProjectDescription desc = newProject.getWorkspace().newProjectDescription(newProject.getName()); + if (location != null && + ResourcesPlugin.getWorkspace().getRoot().getLocation().equals(location)) { + projectLocation = null; + } + desc.setLocation(projectLocation); + try { + newProject.create(desc, null); + if (!newProject.isOpen()) { + newProject.open(null); + } + } catch (CoreException e) { + e.printStackTrace(); + } + } + + return newProject; + } + + private static void addNature(IProject project, String nature_id) throws CoreException { + if (!project.hasNature(nature_id)) { + IProjectDescription desc = project.getDescription(); + String[] prevNatures = desc.getNatureIds(); + String[] newNatures = new String[prevNatures.length + 1]; + System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length); + newNatures[prevNatures.length] = nature_id; + desc.setNatureIds(newNatures); + + project.setDescription(desc, null); + } + } + + private static void addToProjectStructure(IProject project, IProjectCreator creator) throws CoreException { + String[] paths = creator.getProjectType().getFolders(creator.getPackageName()); + for (String path : paths) { + IFolder etcFolders = project.getFolder(path); + createFolder(etcFolders); + } + } + + private static void createFolder(IFolder folder) throws CoreException { + IContainer parent = folder.getParent(); + if (parent instanceof IFolder) { + createFolder((IFolder) parent); + } + if (!folder.exists()) { + folder.create(false, true, null); + } + folder.refreshLocal(IResource.DEPTH_INFINITE, null); + } + + private static void addFilesToProject(IProject project, IProjectCreator creator) throws CoreException { + Map files = creator.getProjectType().getFiles(creator.getPackageName()); + for (Entry e : files.entrySet()) { + try { + URL url = new URL(creator.getProjectType().getBaseURL(), e.getValue()); + createTemplateFile(project, e.getKey(), url, creator.getValues()); + } catch (MalformedURLException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + } + } + + /** + * Create a file in the project from a template. Substituting as required. + * + * @param project The project to use create the file in. + * @param filepath The path of the created file. + * @param filesource The source of the template to use. + * @param vals The map of values to use for substitution. + * @throws CoreException + */ + public static void createTemplateFile(IProject project, String filepath, URL url, Map vals) throws CoreException { + IFile template = project.getFile(new Path(filepath)); + if (!template.exists()) { + InputStream in = openTemplateContentStream(project, url, vals); + template.create(in, true, null); + } + } + + private static InputStream openTemplateContentStream(IProject project, URL url, Map vals) { + //http://eclipse-javacc.cvs.sourceforge.net/viewvc/eclipse-javacc/sf.eclipse.javacc/src-plugin/sf/eclipse/javacc/wizards/JJNewWizard.java?view=markup + //eclipse plugin distributing template files + try { + return makeTemplateInputStream(url.openStream(), vals); + } catch (final MalformedURLException e) { + e.printStackTrace(); + } catch (final IOException e) { + e.printStackTrace(); + } + return null; + } + + private static InputStream makeTemplateInputStream(InputStream stream, Map vals) { + String str; + try { + str = readInput(stream); + stream.close(); + } catch (final IOException e) { + e.printStackTrace(); + return null; + } + + // Instantiate template + for (Entry e : vals.entrySet()) + str = str.replace(e.getKey(), e.getValue()); + + return new ByteArrayInputStream(str.getBytes()); + } + + private static String readInput(InputStream stream) { + StringBuffer buffer = new StringBuffer(); + try { + InputStreamReader isr = new InputStreamReader(stream); + Reader in = new BufferedReader(isr); + int ch; + while ((ch = in.read()) > -1) { + buffer.append((char)ch); + } + System.out.print("\n"); + in.close(); + return buffer.toString(); + } catch (IOException e) { + e.printStackTrace(); + return null; + } + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ProjectType.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ProjectType.java new file mode 100644 index 0000000000..17433743be --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/ProjectType.java @@ -0,0 +1,14 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + +import java.net.URL; +import java.util.Map; + +public interface ProjectType { + String SIMPLE = "SIMPLE"; + String ITERATIVE = "ITERATIVE"; + String COMMAND_BASED = "COMMAND_BASED"; + + String[] getFolders(String packageName); + Map getFiles(String packageName); + URL getBaseURL(); +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/Tag.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/Tag.java new file mode 100644 index 0000000000..221a27a430 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/Tag.java @@ -0,0 +1,19 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + + +public class Tag { + private String name, description; + + public Tag(String name, String description) { + this.name = name; + this.description = description; + } + + public String getName() { + return name; + } + + public String getContent() { + return "

"+name+"

"+description+"

"; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/TeamNumberPage.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/TeamNumberPage.java new file mode 100644 index 0000000000..3e3728b3fc --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.core/src/main/java/edu/wpi/first/wpilib/plugins/core/wizards/TeamNumberPage.java @@ -0,0 +1,111 @@ +package edu.wpi.first.wpilib.plugins.core.wizards; + +import javax.swing.event.ChangeListener; + +import org.eclipse.jface.dialogs.IDialogPage; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; + +public class TeamNumberPage extends WizardPage { + private Text teamNumberText; + private ChangeListener listener; + + /** + * Constructor for SampleNewWizardPage. + * + * @param pageName + */ + public TeamNumberPage(ISelection selection) { + super("wizardPage"); + setTitle("Set Team Number"); + setDescription("This page lets you set your team number so that code can be loaded onto the right robot."); + } + + /** + * @see IDialogPage#createControl(Composite) + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 2; + layout.verticalSpacing = 9; + Label label = new Label(container, SWT.NULL); + label.setText("Team &Number:"); + + teamNumberText = new Text(container, SWT.BORDER | SWT.SINGLE); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + teamNumberText.setLayoutData(gd); + teamNumberText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + + label = new Label(container, SWT.NULL); + label.setText("Team number is a global setting that can be changed in Window > Preferences > WPILib Preferences > Team Number"); + gd = new GridData(GridData.FILL_HORIZONTAL); + gd.horizontalSpan = 2; + label.setLayoutData(gd); + + initialize(); + dialogChanged(); + setControl(container); + } + + /** + * Tests if the current workbench selection is a suitable container to use. + */ + private void initialize() { + String teamNumber = Integer.toString(WPILibCore.getDefault().getTeamNumber(null)); + teamNumberText.setText(teamNumber); + } + + /** + * Ensures that both text fields are set. + */ + private void dialogChanged() { + String teamNumber = getTeamNumber(); + if (listener != null) listener.stateChanged(null); + if (!teamNumber.matches("^([0-9]+)$")) { + updateStatus("Team number must be a valid integer."); + return; + } + updateStatus(null); + } + + private void updateStatus(String message) { + setErrorMessage(message); + setPageComplete(message == null); + } + + public String getTeamNumber() { + return teamNumberText.getText(); + } + + public static boolean needsTeamNumberPage() { + return WPILibCore.getDefault().getTeamNumber(null) == 0; + } + + public static String getTeamNumberFromPage(TeamNumberPage teamNumberPage) { + if (teamNumberPage != null) { + return teamNumberPage.getTeamNumber(); + } else { + return Integer.toString(WPILibCore.getDefault().getTeamNumber(null)); + } + } + + public void registerChangeListener(ChangeListener changeListener) { + listener = changeListener; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/.project new file mode 100644 index 0000000000..cb3157daa3 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/.project @@ -0,0 +1,17 @@ + + + edu.wpi.first.wpilib.plugins.cpp.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/feature.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/feature.xml new file mode 100644 index 0000000000..2b24374f01 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/feature.xml @@ -0,0 +1,64 @@ + + + + + FRC Robot C++ Program Development Environment. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. Redistributions in binary form must reproduce the +* above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. Neither the name of the FIRST nor the +* names of its contributors may be used to endorse or promote +* products derived from this software without specific prior +* written permission. +* +* THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +* EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/pom.xml new file mode 100644 index 0000000000..d4a9b0d738 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.feature/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.cpp.feature + eclipse-feature + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/.project new file mode 100644 index 0000000000..d7ffa026d4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/.project @@ -0,0 +1,17 @@ + + + edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/feature.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/feature.xml new file mode 100644 index 0000000000..6ee6c4cf69 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/feature.xml @@ -0,0 +1,59 @@ + + + + + The C++ toolchain to build Athena programs on Linux. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. Redistributions in binary form must reproduce the +* above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. Neither the name of the FIRST nor the +* names of its contributors may be used to endorse or promote +* products derived from this software without specific prior +* written permission. +* +* THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +* EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/pom.xml new file mode 100644 index 0000000000..04be54179b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature + 0.2.0 + eclipse-feature + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/.classpath b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/.classpath new file mode 100644 index 0000000000..098194ca4b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/.project new file mode 100644 index 0000000000..8317f12f59 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/.project @@ -0,0 +1,28 @@ + + + edu.wpi.first.wpilib.plugins.cpp.toolchains.linux + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/META-INF/MANIFEST.MF b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..43b19f1328 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Linux +Bundle-SymbolicName: edu.wpi.first.wpilib.plugins.cpp.toolchains.linux;singleton:=true +Bundle-Version: 0.2.0 +Bundle-Activator: edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + edu.wpi.first.wpilib.plugins.core;bundle-version="0.1.0", + edu.wpi.first.wpilib.plugins.cpp;bundle-version="0.1.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/README b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/README new file mode 100644 index 0000000000..c7114baf95 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/README @@ -0,0 +1,8 @@ +Making This Plugin Work +======================= + +This plugin needs a very big zip that contains the toolchain. This is +currently hosted by Jenkins in the "Windows Toolchain Provider" +project. This can also be created from the download from mentor +embedded. The file should be resources/toolchain.zip and contains the +5 main directories. \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/build.properties new file mode 100644 index 0000000000..cc05bf7aed --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + resources/,\ + plugin.xml +src.includes = resources/ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/plugin.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/plugin.xml new file mode 100644 index 0000000000..88ae2f4185 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/pom.xml new file mode 100644 index 0000000000..9f935036b8 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.cpp.toolchains.linux + 0.2.0 + eclipse-plugin + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + copy + prepare-package + + copy + + + + + edu.wpi.first.wpilib.plugins.cpp.toolchains + linux + 1.0.0 + zip + toolchain.zip + + + true + ${project.build.outputDirectory}/resources + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/resources/PLACEHOLDER b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/resources/PLACEHOLDER new file mode 100644 index 0000000000..e69de29bb2 diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/linux/Activator.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/linux/Activator.java new file mode 100644 index 0000000000..3222d18422 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/linux/Activator.java @@ -0,0 +1,62 @@ +package edu.wpi.first.wpilib.plugins.cpp.toolchains.linux; + +import org.eclipse.ui.IStartup; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin implements IStartup { + + // The plug-in ID + public static final String PLUGIN_ID = "edu.wpi.first.wpilib.plugins.cpp.toolchains.windows"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + private String getCurrentVersion() { + return WPILibCPPPlugin.getDefault().getDefaultToolchainVersion(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + @Override + public void earlyStartup() { + new ToolchainInstaller(getCurrentVersion()).installIfNecessary(); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/linux/ToolchainInstaller.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/linux/ToolchainInstaller.java new file mode 100644 index 0000000000..b42d84e020 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.linux/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/linux/ToolchainInstaller.java @@ -0,0 +1,36 @@ +package edu.wpi.first.wpilib.plugins.cpp.toolchains.linux; + +import java.io.InputStream; + +import org.eclipse.jface.preference.IPreferenceStore; + +import edu.wpi.first.wpilib.plugins.core.installer.AbstractInstaller; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; +import edu.wpi.first.wpilib.plugins.cpp.preferences.PreferenceConstants; + +public class ToolchainInstaller extends AbstractInstaller { + + public ToolchainInstaller(String version) { + super(version); + } + + @Override + protected String getFeatureName() { + return "toolchains"; + } + + @Override + protected void updateInstalledVersion(String version) { + IPreferenceStore prefs = WPILibCPPPlugin.getDefault().getPreferenceStore(); + if (prefs.getBoolean(PreferenceConstants.UPDATE_TOOLCHAIN_VERSION)) { + System.out.println("Forcing library version to "+version); + prefs.setValue(PreferenceConstants.TOOLCHAIN_VERSION, version); + } + } + + @Override + protected InputStream getInstallResourceStream() { + return ToolchainInstaller.class.getResourceAsStream("/resources/toolchain.zip"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/.project new file mode 100644 index 0000000000..eedadaa4a7 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/.project @@ -0,0 +1,17 @@ + + + edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/feature.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/feature.xml new file mode 100644 index 0000000000..88d74133f6 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/feature.xml @@ -0,0 +1,59 @@ + + + + + The C++ toolchain to build Athena programs on a Mac. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. Redistributions in binary form must reproduce the +* above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. Neither the name of the FIRST nor the +* names of its contributors may be used to endorse or promote +* products derived from this software without specific prior +* written permission. +* +* THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +* EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/pom.xml new file mode 100644 index 0000000000..fb70083482 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature + 0.2.0 + eclipse-feature + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/.classpath b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/.classpath new file mode 100644 index 0000000000..098194ca4b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/.project new file mode 100644 index 0000000000..bb3deccb96 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/.project @@ -0,0 +1,28 @@ + + + edu.wpi.first.wpilib.plugins.cpp.toolchains.mac + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/META-INF/MANIFEST.MF b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..4de558b5ac --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Windows +Bundle-SymbolicName: edu.wpi.first.wpilib.plugins.cpp.toolchains.mac;singleton:=true +Bundle-Version: 0.2.0 +Bundle-Activator: edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + edu.wpi.first.wpilib.plugins.core;bundle-version="0.1.0", + edu.wpi.first.wpilib.plugins.cpp;bundle-version="0.1.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/README b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/README new file mode 100644 index 0000000000..c7114baf95 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/README @@ -0,0 +1,8 @@ +Making This Plugin Work +======================= + +This plugin needs a very big zip that contains the toolchain. This is +currently hosted by Jenkins in the "Windows Toolchain Provider" +project. This can also be created from the download from mentor +embedded. The file should be resources/toolchain.zip and contains the +5 main directories. \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/build.properties new file mode 100644 index 0000000000..cc05bf7aed --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + resources/,\ + plugin.xml +src.includes = resources/ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/plugin.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/plugin.xml new file mode 100644 index 0000000000..1cf334019a --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/pom.xml new file mode 100644 index 0000000000..2035aedd73 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.cpp.toolchains.mac + 0.2.0 + eclipse-plugin + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + copy + prepare-package + + copy + + + + + edu.wpi.first.wpilib.plugins.cpp.toolchains + mac + 1.0.0 + zip + toolchain.zip + + + true + ${project.build.outputDirectory}/resources + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/resources/PLACEHOLDER b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/resources/PLACEHOLDER new file mode 100644 index 0000000000..e69de29bb2 diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/mac/Activator.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/mac/Activator.java new file mode 100644 index 0000000000..6c9b8c281b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/mac/Activator.java @@ -0,0 +1,62 @@ +package edu.wpi.first.wpilib.plugins.cpp.toolchains.mac; + +import org.eclipse.ui.IStartup; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin implements IStartup { + + // The plug-in ID + public static final String PLUGIN_ID = "edu.wpi.first.wpilib.plugins.cpp.toolchains.windows"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + private String getCurrentVersion() { + return WPILibCPPPlugin.getDefault().getDefaultToolchainVersion(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + @Override + public void earlyStartup() { + new ToolchainInstaller(getCurrentVersion()).installIfNecessary(); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/mac/ToolchainInstaller.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/mac/ToolchainInstaller.java new file mode 100644 index 0000000000..15c3fc4d68 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.mac/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/mac/ToolchainInstaller.java @@ -0,0 +1,36 @@ +package edu.wpi.first.wpilib.plugins.cpp.toolchains.mac; + +import java.io.InputStream; + +import org.eclipse.jface.preference.IPreferenceStore; + +import edu.wpi.first.wpilib.plugins.core.installer.AbstractInstaller; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; +import edu.wpi.first.wpilib.plugins.cpp.preferences.PreferenceConstants; + +public class ToolchainInstaller extends AbstractInstaller { + + public ToolchainInstaller(String version) { + super(version); + } + + @Override + protected String getFeatureName() { + return "toolchains"; + } + + @Override + protected void updateInstalledVersion(String version) { + IPreferenceStore prefs = WPILibCPPPlugin.getDefault().getPreferenceStore(); + if (prefs.getBoolean(PreferenceConstants.UPDATE_TOOLCHAIN_VERSION)) { + System.out.println("Forcing library version to "+version); + prefs.setValue(PreferenceConstants.TOOLCHAIN_VERSION, version); + } + } + + @Override + protected InputStream getInstallResourceStream() { + return ToolchainInstaller.class.getResourceAsStream("/resources/toolchain.zip"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/.project new file mode 100644 index 0000000000..d7a1926954 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/.project @@ -0,0 +1,17 @@ + + + edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/feature.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/feature.xml new file mode 100644 index 0000000000..474579b2e8 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/feature.xml @@ -0,0 +1,59 @@ + + + + + The C++ toolchain to build Athena programs on Windows. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. Redistributions in binary form must reproduce the +* above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. Neither the name of the FIRST nor the +* names of its contributors may be used to endorse or promote +* products derived from this software without specific prior +* written permission. +* +* THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +* EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/pom.xml new file mode 100644 index 0000000000..66bd52cbd2 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature/pom.xml @@ -0,0 +1,16 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature + 0.2.0 + eclipse-feature + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/.classpath b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/.classpath new file mode 100644 index 0000000000..098194ca4b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/.project new file mode 100644 index 0000000000..4b17efb32b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/.project @@ -0,0 +1,28 @@ + + + edu.wpi.first.wpilib.plugins.cpp.toolchains.windows + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/META-INF/MANIFEST.MF b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..743c3cfbec --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/META-INF/MANIFEST.MF @@ -0,0 +1,12 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Windows +Bundle-SymbolicName: edu.wpi.first.wpilib.plugins.cpp.toolchains.windows;singleton:=true +Bundle-Version: 0.2.0 +Bundle-Activator: edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.Activator +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + edu.wpi.first.wpilib.plugins.core;bundle-version="0.1.0", + edu.wpi.first.wpilib.plugins.cpp;bundle-version="0.1.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/README b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/README new file mode 100644 index 0000000000..c7114baf95 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/README @@ -0,0 +1,8 @@ +Making This Plugin Work +======================= + +This plugin needs a very big zip that contains the toolchain. This is +currently hosted by Jenkins in the "Windows Toolchain Provider" +project. This can also be created from the download from mentor +embedded. The file should be resources/toolchain.zip and contains the +5 main directories. \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/build.properties new file mode 100644 index 0000000000..cc05bf7aed --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/build.properties @@ -0,0 +1,7 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + resources/,\ + plugin.xml +src.includes = resources/ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/plugin.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/plugin.xml new file mode 100644 index 0000000000..a56a247458 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/pom.xml new file mode 100644 index 0000000000..15767e5cac --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/pom.xml @@ -0,0 +1,47 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.cpp.toolchains.windows + 0.2.0 + eclipse-plugin + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + copy + prepare-package + + copy + + + + + edu.wpi.first.wpilib.plugins.cpp.toolchains + windows + 1.0.0 + zip + toolchain.zip + + + true + ${project.build.outputDirectory}/resources + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/resources/PLACEHOLDER b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/resources/PLACEHOLDER new file mode 100644 index 0000000000..e69de29bb2 diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/windows/Activator.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/windows/Activator.java new file mode 100644 index 0000000000..5d8023d69e --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/windows/Activator.java @@ -0,0 +1,62 @@ +package edu.wpi.first.wpilib.plugins.cpp.toolchains.windows; + +import org.eclipse.ui.IStartup; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin implements IStartup { + + // The plug-in ID + public static final String PLUGIN_ID = "edu.wpi.first.wpilib.plugins.cpp.toolchains.windows"; //$NON-NLS-1$ + + // The shared instance + private static Activator plugin; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + private String getCurrentVersion() { + return WPILibCPPPlugin.getDefault().getDefaultToolchainVersion(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + @Override + public void earlyStartup() { + new ToolchainInstaller(getCurrentVersion()).installIfNecessary(); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/windows/ToolchainInstaller.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/windows/ToolchainInstaller.java new file mode 100644 index 0000000000..d57fa3ee62 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp.toolchains.windows/src/edu/wpi/first/wpilib/plugins/cpp/toolchains/windows/ToolchainInstaller.java @@ -0,0 +1,36 @@ +package edu.wpi.first.wpilib.plugins.cpp.toolchains.windows; + +import java.io.InputStream; + +import org.eclipse.jface.preference.IPreferenceStore; + +import edu.wpi.first.wpilib.plugins.core.installer.AbstractInstaller; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; +import edu.wpi.first.wpilib.plugins.cpp.preferences.PreferenceConstants; + +public class ToolchainInstaller extends AbstractInstaller { + + public ToolchainInstaller(String version) { + super(version); + } + + @Override + protected String getFeatureName() { + return "toolchains"; + } + + @Override + protected void updateInstalledVersion(String version) { + IPreferenceStore prefs = WPILibCPPPlugin.getDefault().getPreferenceStore(); + if (prefs.getBoolean(PreferenceConstants.UPDATE_TOOLCHAIN_VERSION)) { + System.out.println("Forcing library version to "+version); + prefs.setValue(PreferenceConstants.TOOLCHAIN_VERSION, version); + } + } + + @Override + protected InputStream getInstallResourceStream() { + return ToolchainInstaller.class.getResourceAsStream("/resources/toolchain.zip"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/.classpath b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/.classpath new file mode 100644 index 0000000000..c0b4c7e112 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/.project new file mode 100644 index 0000000000..325460c3af --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/.project @@ -0,0 +1,28 @@ + + + edu.wpi.first.wpilib.plugins.cpp + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/META-INF/MANIFEST.MF b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..7121a5cbec --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/META-INF/MANIFEST.MF @@ -0,0 +1,31 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: WPILib_CPP_Robot_Development +Bundle-SymbolicName: edu.wpi.first.wpilib.plugins.cpp;singleton:=true +Bundle-Version: 0.1.0.qualifier +Bundle-Activator: edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.core.resources;bundle-version="3.8.1", + edu.wpi.first.wpilib.plugins.core;bundle-version="0.1.0", + org.eclipse.cdt;bundle-version="8.1.0", + org.eclipse.cdt.build.crossgcc;bundle-version="1.1.0", + org.eclipse.cdt.core;bundle-version="5.4.0", + org.eclipse.cdt.ui;bundle-version="5.4.0", + org.eclipse.cdt.managedbuilder.core;bundle-version="8.1.0", + org.eclipse.cdt.managedbuilder.gnu.ui;bundle-version="8.1.0", + org.eclipse.cdt.managedbuilder.ui;bundle-version="8.1.0", + org.eclipse.ui.editors;bundle-version="3.8.0", + org.eclipse.ui.ide;bundle-version="3.8.1", + org.eclipse.debug.core;bundle-version="3.7.100", + org.eclipse.debug.ui;bundle-version="3.8.1", + org.eclipse.rse;bundle-version="3.1.0", + org.eclipse.rse.core;bundle-version="3.1.1", + org.eclipse.cdt.debug.core;bundle-version="7.2.0", + org.eclipse.cdt.debug.ui;bundle-version="7.2.0", + org.eclipse.cdt.launch;bundle-version="7.1.0", + org.eclipse.cdt.launch.remote;bundle-version="2.4.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Export-Package: edu.wpi.first.wpilib.plugins.cpp, + edu.wpi.first.wpilib.plugins.cpp.preferences diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/build.properties new file mode 100644 index 0000000000..85c3a2e7ac --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/build.properties @@ -0,0 +1,9 @@ +source.. = src/main/java/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + resources/ +src.includes = resources/**,\ + src/ +bin.excludes = resources/configuration.properties diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/plugin.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/plugin.xml new file mode 100644 index 0000000000..492db0c514 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/plugin.xml @@ -0,0 +1,190 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml new file mode 100644 index 0000000000..fb34e64a65 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/pom.xml @@ -0,0 +1,365 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.cpp + eclipse-plugin + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + + + WPILib Repository + http://frcbuilder.wpi.edu:8348/ + + + + + DEVELOPMENT + ${project.build.directory}/cpp-zip + + + + + + . + + resources/configuration.properties + + true + + + + + maven-resources-plugin + 2.6 + + + copy-ant-resources-to-cpp-zip + generate-sources + + copy-resources + + + ${cpp-zip} + + + src/main/resources/cpp-zip + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + + + fetch-cpp-zip-dependencies + compile + + copy + + + + + + edu.wpi.first.wpilib.networktables.cpp + libNetworkTablesAthena + 0.1.0-SNAPSHOT + a + libNetworkTables.a + + + edu.wpi.first.wpilib.hal + libHALAthena + 0.1.0-SNAPSHOT + a + libHAL.a + + + edu.wpi.first.wpilib.cpp + libWPILibAthena + 0.1.0-SNAPSHOT + a + libWPILib.a + + + com.ni.first.libraries + libFRC_NetworkCommunication + 0.1.0-SNAPSHOT + so + libFRC_NetworkCommunication.so + + + + com.ni.first.libraries + libRoboRIO_FRC_ChipObject + 0.1.0-SNAPSHOT + so + libRoboRIO_FRC_ChipObject.so + + + com.ni.first.libraries + libFRC_FPGA_ChipObject + 0.1.0-SNAPSHOT + so + libFRC_FPGA_ChipObject.so + + + com.ni.first.libraries + libNiFpga + 0.1.0-SNAPSHOT + so + libNiFpga.so + + + com.ni.first.libraries + libni_emb + 0.1.0-SNAPSHOT + so + libni_emb.so + + + com.ni.first.libraries + libnirio_emb_can + 0.1.0-SNAPSHOT + so + libnirio_emb_can.so + + + com.ni.first.libraries + libNiFpgaLv + 0.1.0-SNAPSHOT + so + libNiFpgaLv.so + + + com.ni.first.libraries + libNiRioSrv + 0.1.0-SNAPSHOT + so + libNiRioSrv.so + + + com.ni.first.libraries + libni_rtlog + 0.1.0-SNAPSHOT + so + libni_rtlog.so + + + + + edu.wpi.first.wpilib.hal + include + 0.1.0-SNAPSHOT + inczip + ${cpp-zip}/inczip + + + edu.wpi.first.wpilib.networktables.cpp + include + 0.1.0-SNAPSHOT + inczip + ${cpp-zip}/inczip + + + edu.wpi.first.wpilib.cpp + libWPILibAthena + 0.1.0-SNAPSHOT + inczip + ${cpp-zip}/inczip + + + ${cpp-zip}/lib + false + true + true + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.7 + + + + + set-version-info + + run + + process-sources + + + + + + + + + + + true + + + + + + unzip-cpp-includes + compile + + run + + + + + + + + + + + + + + + + + + + generate-cpp-zip + compile + + run + + + + + + + + + + + + + + + + + edu.wpi.first.wpilib.networktables.cpp + libNetworkTablesAthena + 0.1.0-SNAPSHOT + a + + + edu.wpi.first.wpilib.hal + libHALAthena + 0.1.0-SNAPSHOT + a + + + edu.wpi.first.wpilib.cpp + libWPILibAthena + 0.1.0-SNAPSHOT + a + + + com.ni.first.libraries + libFRC_NetworkCommunication + 0.1.0-SNAPSHOT + so + + + com.ni.first.libraries + libRoboRIO_FRC_ChipObject + 0.1.0-SNAPSHOT + so + + + com.ni.first.libraries + libFRC_FPGA_ChipObject + 0.1.0-SNAPSHOT + so + + + com.ni.first.libraries + libNiFpga + 0.1.0-SNAPSHOT + so + + + com.ni.first.libraries + libni_emb + 0.1.0-SNAPSHOT + so + + + com.ni.first.libraries + libnirio_emb_can + 0.1.0-SNAPSHOT + so + + + com.ni.first.libraries + libNiFpgaLv + 0.1.0-SNAPSHOT + so + + + com.ni.first.libraries + libNiRioSrv + 0.1.0-SNAPSHOT + so + + + com.ni.first.libraries + libni_rtlog + 0.1.0-SNAPSHOT + so + + + + + edu.wpi.first.wpilib.hal + include + 0.1.0-SNAPSHOT + inczip + + + edu.wpi.first.wpilib.networktables.cpp + include + 0.1.0-SNAPSHOT + inczip + + + edu.wpi.first.wpilib.cpp + libWPILibAthena + 0.1.0-SNAPSHOT + inczip + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/configuration.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/configuration.properties new file mode 100644 index 0000000000..cbfaca2ede --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/configuration.properties @@ -0,0 +1,2 @@ +timestamp=${timestamp} +version=${version} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/Button.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/Button.png new file mode 100644 index 0000000000..f6584ec823 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/Button.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/Command.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/Command.png new file mode 100644 index 0000000000..c3d9c2d991 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/Command.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/CommandGroup.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/CommandGroup.png new file mode 100644 index 0000000000..1a027c85fd Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/CommandGroup.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/PIDSubsystem.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/PIDSubsystem.png new file mode 100644 index 0000000000..766fca1c3b Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/PIDSubsystem.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/Subsystem.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/Subsystem.png new file mode 100644 index 0000000000..35ee694c8c Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/Subsystem.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/sample.gif b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/sample.gif new file mode 100644 index 0000000000..34fb3c9d8c Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/sample.gif differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/wpi.ico b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/wpi.ico new file mode 100644 index 0000000000..a6de9245f9 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/icons/wpi.ico differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject new file mode 100644 index 0000000000..f05fb0ea8a --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/.cproject @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties new file mode 100644 index 0000000000..e89514796f --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.properties @@ -0,0 +1,21 @@ +# Deployment information +username=admin +password= +deploy.dir=/home/admin +deploy.run.command=./runcppprogram +deploy.debug.command=./debugcppprogram + +# Libraries to use +wpilib=${user.home}/wpilib/cpp/${cpp-version} +wpilib.lib=${wpilib}/lib + +# Ant support +wpilib.ant.dir=${wpilib}/ant +jsch.jar=${wpilib.ant.dir}/jsch-0.1.50.jar +classloadertask.jar=${wpilib.ant.dir}/ant-classloadertask.jar + +# Build information +out=FRCUserProgram +src.dir=src +build.dir=build +out.exe=Debug/${out} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.xml new file mode 100644 index 0000000000..22e948e5ba --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/build.xml @@ -0,0 +1,27 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Command.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Command.cpp new file mode 100644 index 0000000000..92a24a2644 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Command.cpp @@ -0,0 +1,31 @@ +#include "$classname.h" + +$classname::$classname() { + // Use Requires() here to declare subsystem dependencies + // eg. Requires(chassis); +} + +// Called just before this Command runs the first time +void $classname::Initialize() { + +} + +// Called repeatedly when this Command is scheduled to run +void $classname::Execute() { + +} + +// Make this return true when this Command no longer needs to run execute() +bool $classname::IsFinished() { + return false; +} + +// Called once after isFinished returns true +void $classname::End() { + +} + +// Called when another command which requires one or more of the same +// subsystems is scheduled to run +void $classname::Interrupted() { +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Command.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Command.h new file mode 100644 index 0000000000..768daa47e7 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Command.h @@ -0,0 +1,21 @@ +#ifndef $classname_H +#define $classname_H + +#include "../CommandBase.h" + +/** + * + * + * @author ExampleAuthor + */ +class $classname: public CommandBase { +public: + $classname(); + virtual void Initialize(); + virtual void Execute(); + virtual bool IsFinished(); + virtual void End(); + virtual void Interrupted(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandBase.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandBase.cpp new file mode 100644 index 0000000000..c89014b938 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandBase.cpp @@ -0,0 +1,21 @@ +#include "CommandBase.h" +#include "Subsystems/ExampleSubsystem.h" +#include "Commands/Scheduler.h" + +CommandBase::CommandBase(const char *name) : Command(name) { +} + +CommandBase::CommandBase() : Command() { +} + +// Initialize a single static instance of all of your subsystems to NULL +ExampleSubsystem* CommandBase::examplesubsystem = NULL; +OI* CommandBase::oi = NULL; + +void CommandBase::init() { + // Create a single static instance of all of your subsystems. The following + // line should be repeated for each subsystem in the project. + examplesubsystem = new ExampleSubsystem(); + + oi = new OI(); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandBase.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandBase.h new file mode 100644 index 0000000000..e300f088cc --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandBase.h @@ -0,0 +1,24 @@ +#ifndef COMMAND_BASE_H +#define COMMAND_BASE_H + +#include "Commands/Command.h" +#include "Subsystems/ExampleSubsystem.h" +#include "OI.h" + + +/** + * The base for all commands. All atomic commands should subclass CommandBase. + * CommandBase stores creates and stores each control system. To access a + * subsystem elsewhere in your code in your code use CommandBase.examplesubsystem + */ +class CommandBase: public Command { +public: + CommandBase(const char *name); + CommandBase(); + static void init(); + // Create a single static instance of all of your subsystems + static ExampleSubsystem *examplesubsystem; + static OI *oi; +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandGroup.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandGroup.cpp new file mode 100644 index 0000000000..d31408bc2f --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandGroup.cpp @@ -0,0 +1,21 @@ + +#include "$classname.h" + +$classname::$classname() { + // Add Commands here: + // e.g. AddSequential(new Command1()); + // AddSequential(new Command2()); + // these will run in order. + + // To run multiple commands at the same time, + // use AddParallel() + // e.g. AddParallel(new Command1()); + // AddSequential(new Command2()); + // Command1 and Command2 will run in parallel. + + // A command group will require all of the subsystems that each member + // would require. + // e.g. if Command1 requires chassis, and Command2 requires arm, + // a CommandGroup containing them would require both the chassis and the + // arm. +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandGroup.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandGroup.h new file mode 100644 index 0000000000..fe723d6ad5 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/CommandGroup.h @@ -0,0 +1,17 @@ + +#ifndef $classname_H +#define $classname_H + +#include "Commands/CommandGroup.h" + +/** + * + * + * @author ExampleAuthor + */ +class $classname: public CommandGroup { +public: + $classname(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleCommand.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleCommand.cpp new file mode 100644 index 0000000000..15bdf215e9 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleCommand.cpp @@ -0,0 +1,31 @@ +#include "ExampleCommand.h" + +ExampleCommand::ExampleCommand() { + // Use Requires() here to declare subsystem dependencies + // eg. Requires(chassis); +} + +// Called just before this Command runs the first time +void ExampleCommand::Initialize() { + +} + +// Called repeatedly when this Command is scheduled to run +void ExampleCommand::Execute() { + +} + +// Make this return true when this Command no longer needs to run execute() +bool ExampleCommand::IsFinished() { + return false; +} + +// Called once after isFinished returns true +void ExampleCommand::End() { + +} + +// Called when another command which requires one or more of the same +// subsystems is scheduled to run +void ExampleCommand::Interrupted() { +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleCommand.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleCommand.h new file mode 100644 index 0000000000..50ad6a3065 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleCommand.h @@ -0,0 +1,21 @@ +#ifndef EXAMPLE_COMMAND_H +#define EXAMPLE_COMMAND_H + +#include "../CommandBase.h" + +/** + * + * + * @author ExampleAuthor + */ +class ExampleCommand: public CommandBase { +public: + ExampleCommand(); + virtual void Initialize(); + virtual void Execute(); + virtual bool IsFinished(); + virtual void End(); + virtual void Interrupted(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleSubsystem.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleSubsystem.cpp new file mode 100644 index 0000000000..21d8e636d8 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleSubsystem.cpp @@ -0,0 +1,16 @@ +#include "ExampleSubsystem.h" +#include "../Robotmap.h" + +ExampleSubsystem::ExampleSubsystem() : Subsystem("ExampleSubsystem") { + +} + +void ExampleSubsystem::InitDefaultCommand() { + // Set the default command for a subsystem here. + //SetDefaultCommand(new MySpecialCommand()); +} + + +// Put methods for controlling this subsystem +// here. Call these from Commands. + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleSubsystem.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleSubsystem.h new file mode 100644 index 0000000000..4f88ff0200 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/ExampleSubsystem.h @@ -0,0 +1,20 @@ +#ifndef EXAMPLE_SUBSYSTEM_H +#define EXAMPLE_SUBSYSTEM_H +#include "Commands/Subsystem.h" +#include "WPILib.h" + +/** + * + * + * @author ExampleAuthor + */ +class ExampleSubsystem: public Subsystem { +private: + // It's desirable that everything possible under private except + // for methods that implement subsystem capabilities +public: + ExampleSubsystem(); + void InitDefaultCommand(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/OI.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/OI.cpp new file mode 100644 index 0000000000..06eda9aa19 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/OI.cpp @@ -0,0 +1,5 @@ +#include "OI.h" + +OI::OI() { + // Process operator interface input here. +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/OI.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/OI.h new file mode 100644 index 0000000000..7a2ab97996 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/OI.h @@ -0,0 +1,13 @@ +#ifndef OI_H +#define OI_H + +#include "WPILib.h" + +class OI { +private: + +public: + OI(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/PIDSubsystem.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/PIDSubsystem.cpp new file mode 100644 index 0000000000..3d64f689c4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/PIDSubsystem.cpp @@ -0,0 +1,31 @@ + +#include "$classname.h" +#include "../Robotmap.h" +#include "SmartDashboard/SmartDashboard.h" +#include "LiveWindow/LiveWindow.h" + +#@autogenerated_code("pid", "") +#parse("${exporter-path}PIDSubsystem-pid.cpp") +#end +$classname::$classname() : PIDSubsystem("$classname", 1.0, 0.0, 0.0) { + // Use these to get going: + // SetSetpoint() - Sets where the PID controller should move the system + // to + // Enable() - Enables the PID controller. +} + +double $classname::ReturnPIDInput() { + // Return your input value for the PID loop + // e.g. a sensor, like a potentiometer: + // yourPot->SetAverageVoltage() / kYourMaxVoltage; +} + +void $classname::UsePIDOutput(double output) { + // Use output to drive your system, like a motor + // e.g. yourMotor->Set(output); +} + +void $classname::InitDefaultCommand() { + // Set the default command for a subsystem here. + //setDefaultCommand(new MySpecialCommand()); +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/PIDSubsystem.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/PIDSubsystem.h new file mode 100644 index 0000000000..8dc603fd51 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/PIDSubsystem.h @@ -0,0 +1,21 @@ + +#ifndef $classname_H +#define $classname_H + +#include "Commands/PIDSubsystem.h" +#include "WPILib.h" + +/** + * + * + * @author ExampleAuthor + */ +class $classname: public PIDSubsystem { + public: + $classname(); + double ReturnPIDInput(); + void UsePIDOutput(double output); + void InitDefaultCommand(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Robot.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Robot.cpp new file mode 100644 index 0000000000..07e201c8c5 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Robot.cpp @@ -0,0 +1,51 @@ +//============================================================================ +// Name : Robot.cpp +// Author : +// Version : +// Copyright : +// Description : Hello World in C++, Ansi-style +//============================================================================ + +#include "WPILib.h" +#include "Commands/Command.h" +#include "Commands/ExampleCommand.h" +#include "CommandBase.h" + +class Robot : public IterativeRobot { +private: + Command *autonomousCommand; + LiveWindow *lw; + + virtual void RobotInit() { + CommandBase::init(); + autonomousCommand = new ExampleCommand(); + lw = LiveWindow::GetInstance(); + } + + virtual void AutonomousInit() { + autonomousCommand->Start(); + } + + virtual void AutonomousPeriodic() { + Scheduler::GetInstance()->Run(); + } + + virtual void TeleopInit() { + // This makes sure that the autonomous stops running when + // teleop starts running. If you want the autonomous to + // continue until interrupted by another command, remove + // this line or comment it out. + autonomousCommand->Cancel(); + } + + virtual void TeleopPeriodic() { + Scheduler::GetInstance()->Run(); + } + + virtual void TestPeriodic() { + lw->Run(); + } +}; + +START_ROBOT_CLASS(Robot); + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/RobotMap.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/RobotMap.h new file mode 100644 index 0000000000..fa48c742d1 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/RobotMap.h @@ -0,0 +1,22 @@ +#ifndef ROBOTMAP_H +#define ROBOTMAP_H + + +/** + * The RobotMap is a mapping from the ports sensors and actuators are wired into + * to a variable name. This provides flexibility changing wiring, makes checking + * the wiring easier and significantly reduces the number of magic numbers + * floating around. + */ + +// For example to map the left and right motors, you could define the +// following variables to use with your drivetrain subsystem. +// #define LEFTMOTOR 1 +// #define RIGHTMOTOR 2 + +// If you are using multiple modules, make sure to define both the port +// number and the module. For example you with a rangefinder: +// #define RANGE_FINDER_PORT 1 +// #define RANGE_FINDER_MODULE 1 + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Subsystem.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Subsystem.cpp new file mode 100644 index 0000000000..06e0a13e5d --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Subsystem.cpp @@ -0,0 +1,15 @@ +#include "$classname.h" +#include "../Robotmap.h" + +$classname::$classname() : Subsystem("ExampleSubsystem") { + +} + +void $classname::InitDefaultCommand() { + // Set the default command for a subsystem here. + //SetDefaultCommand(new MySpecialCommand()); +} + + +// Put methods for controlling this subsystem +// here. Call these from Commands. diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Subsystem.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Subsystem.h new file mode 100644 index 0000000000..d059c25df6 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Subsystem.h @@ -0,0 +1,20 @@ +#ifndef $classname_H +#define $classname_H +#include "Commands/Subsystem.h" +#include "WPILib.h" + +/** + * + * + * @author ExampleAuthor + */ +class $classname: public Subsystem { +private: + // It's desirable that everything possible under private except + // for methods that implement subsystem capabilities +public: + $classname(); + void InitDefaultCommand(); +}; + +#endif diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Trigger.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Trigger.cpp new file mode 100644 index 0000000000..d24a1bf794 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Trigger.cpp @@ -0,0 +1,13 @@ +// TODO: convert into C++ template + +import edu.wpi.first.wpilibj.command.Trigger; + +/** + * New and improved C++ + */ +public class $classname extends Trigger { + + public boolean get() { + return false; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Trigger.h b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Trigger.h new file mode 100644 index 0000000000..d24a1bf794 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/command-based/Trigger.h @@ -0,0 +1,13 @@ +// TODO: convert into C++ template + +import edu.wpi.first.wpilibj.command.Trigger; + +/** + * New and improved C++ + */ +public class $classname extends Trigger { + + public boolean get() { + return false; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/Network Table Counter/Robot.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/Network Table Counter/Robot.cpp new file mode 100644 index 0000000000..668db9c756 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/Network Table Counter/Robot.cpp @@ -0,0 +1,30 @@ +//============================================================================ +// Name : Robot.cpp +// Author : +// Version : +// Copyright : +// Description : Hello World in C++, Ansi-style +//============================================================================ + +#include +#include +using namespace std; + +// This is a simple robot program +int main() { + NetworkTable::SetServerMode(); + NetworkTable::SetTeam(190); + NetworkTable* table = NetworkTable::GetTable("SmartDashboard"); + cout << "Started up" << endl; + + long i = 0; + while (true) { + cout << i << endl; + table->PutNumber("i", i); + i++; + + sleep(1); + } + + return 0; +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/Simple Robot Example/Robot.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/Simple Robot Example/Robot.java new file mode 100644 index 0000000000..045087fe16 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/Simple Robot Example/Robot.java @@ -0,0 +1,17 @@ +package $package; + +/** + * Simplest possible robot program + * + * @author Team $team-number + */ +public class Robot { + + /** + * @param args Input.... + */ + public static void main(String[] args) { + // Do stuff here! + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml new file mode 100644 index 0000000000..68376777cd --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/examples/examples.xml @@ -0,0 +1,47 @@ + + + + Simple Robot + Examples for simple robot programs. + + + Network Tables + Examples of how to use Network Tables to accomplish a + variety of tasks such as sending and receiving values to both + dashboards and co-processors.. + + + + Simple Robot Example + The simplest possible program that compiles. This + shows the structure of a simple program that does nothing at + all. + + Simple Robot + + + src + + + + + + + + Network Table Counter + A simple program that increments a network table + variable once every second. This shows the structure of a simple + program that only uses network tables. + + Simple Robot + Network Tables + + + src + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/iterative/Robot.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/iterative/Robot.cpp new file mode 100644 index 0000000000..50819b5fc2 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/iterative/Robot.cpp @@ -0,0 +1,48 @@ +//============================================================================ +// Name : Robot.cpp +// Author : +// Version : +// Copyright : +// Description : Hello World in C++, Ansi-style +//============================================================================ + +//============================================================================ +// Name : Robot.cpp +// Author : +// Version : +// Copyright : +// Description : Hello World in C++, Ansi-style +//============================================================================ + +#include "WPILib.h" + +class Robot : public IterativeRobot { +private: + LiveWindow *lw; + + virtual void RobotInit() { + lw = LiveWindow::GetInstance(); + } + + virtual void AutonomousInit() { + + } + + virtual void AutonomousPeriodic() { + + } + + virtual void TeleopInit() { + + } + + virtual void TeleopPeriodic() { + + } + + virtual void TestPeriodic() { + lw->Run(); + } +}; + +START_ROBOT_CLASS(Robot); diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/simple/Robot.cpp b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/simple/Robot.cpp new file mode 100644 index 0000000000..8c4a7996f8 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/resources/templates/simple/Robot.cpp @@ -0,0 +1,62 @@ +//============================================================================ +// Name : Robot.cpp +// Author : +// Version : +// Copyright : +// Description : Hello World in C++, Ansi-style +//============================================================================ + +#include "WPILib.h" + +/** + * This is a demo program showing the use of the RobotBase class. + * The SimpleRobot class is the base of a robot application that will automatically call your + * Autonomous and OperatorControl methods at the right time as controlled by the switches on + * the driver station or the field controls. + */ +class Robot : public SimpleRobot +{ + RobotDrive myRobot; // robot drive system + Joystick stick; // only joystick + +public: + Robot(void): + myRobot(1, 2), // these must be initialized in the same order + stick(1) // as they are declared above. + { + myRobot.SetExpiration(0.1); + } + + /** + * Drive left & right motors for 2 seconds then stop + */ + void Autonomous(void) + { + myRobot.SetSafetyEnabled(false); + myRobot.Drive(-0.5, 0.0); // drive forwards half speed + Wait(2.0); // for 2 seconds + myRobot.Drive(0.0, 0.0); // stop robot + } + + /** + * Runs the motors with arcade steering. + */ + void OperatorControl(void) + { + myRobot.SetSafetyEnabled(true); + while (IsOperatorControl()) + { + myRobot.ArcadeDrive(stick); // drive with arcade style (use right stick) + Wait(0.005); // wait for a motor update time + } + } + + /** + * Runs during test mode + */ + void Test() { + + } +}; + +START_ROBOT_CLASS(Robot); diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/WPILibCPPPlugin.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/WPILibCPPPlugin.java new file mode 100644 index 0000000000..b7525da52a --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/WPILibCPPPlugin.java @@ -0,0 +1,92 @@ +package edu.wpi.first.wpilib.plugins.cpp; + +import java.io.File; +import java.util.Properties; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.ui.IStartup; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.ant.AntPropertiesParser; +import edu.wpi.first.wpilib.plugins.cpp.installer.CPPInstaller; +import edu.wpi.first.wpilib.plugins.cpp.preferences.PreferenceConstants; + +/** + * The activator class controls the plug-in life cycle + */ +public class WPILibCPPPlugin extends AbstractUIPlugin implements IStartup { + + // The plug-in ID + public static final String PLUGIN_ID = "WPILib_CPP_Robot_Development"; //$NON-NLS-1$ + + // The shared instance + private static WPILibCPPPlugin plugin; + + /** + * The constructor + */ + public WPILibCPPPlugin() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static WPILibCPPPlugin getDefault() { + return plugin; + } + + public String getDefaultToolchainVersion() { + return "arm-none-linux-gnueabi-4.4.1"; + } + + public String getToolchain() { + return WPILibCore.getDefault().getWPILibBaseDir() + + File.separator + "toolchains" + File.separator + getPreferenceStore().getString(PreferenceConstants.TOOLCHAIN_VERSION); + } + + public String getCurrentVersion() { + try { + Properties props = new AntPropertiesParser(WPILibCPPPlugin.class.getResourceAsStream("/resources/configuration.properties")).getProperties(); + if (props.getProperty("version").startsWith("$")) { + return "DEVELOPMENT"; + } else { + return props.getProperty("version"); + } + } catch (CoreException e) { + return "DEVELOPMENT"; + } + } + + public String getCPPDir() { + return WPILibCore.getDefault().getWPILibBaseDir() + + File.separator + "cpp" + File.separator + getPreferenceStore().getString(PreferenceConstants.LIBRARY_VERSION); + } + + @Override + public void earlyStartup() { + new CPPInstaller(getCurrentVersion()).installIfNecessary(); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/installer/CPPInstaller.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/installer/CPPInstaller.java new file mode 100644 index 0000000000..0b699bc875 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/installer/CPPInstaller.java @@ -0,0 +1,46 @@ +package edu.wpi.first.wpilib.plugins.cpp.installer; + +import java.io.InputStream; +import java.util.Properties; + +import org.eclipse.jface.preference.IPreferenceStore; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.installer.AbstractInstaller; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; +import edu.wpi.first.wpilib.plugins.cpp.preferences.PreferenceConstants; + +/** + * Installs the given version of WPILib into the correct location. Where the + * install directory is usually ~/wpilib/cpp/version. + * + * @author alex + */ +public class CPPInstaller extends AbstractInstaller { + + public CPPInstaller(String version) { + super(version); + } + + @Override + protected String getFeatureName() { + return "cpp"; + } + + @Override + protected void updateInstalledVersion(String version) { + IPreferenceStore prefs = WPILibCPPPlugin.getDefault().getPreferenceStore(); + if (prefs.getBoolean(PreferenceConstants.UPDATE_LIBRARY_VERSION)) { + System.out.println("Forcing library version to "+version); + Properties props = WPILibCore.getDefault().getProjectProperties(null); + props.setProperty("cpp-version", version); + WPILibCore.getDefault().saveGlobalProperties(props); + prefs.setValue(PreferenceConstants.LIBRARY_VERSION, version); + } + } + + @Override + protected InputStream getInstallResourceStream() { + return CPPInstaller.class.getResourceAsStream("/resources/cpp.zip"); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/DeployLaunchShortcut.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/DeployLaunchShortcut.java new file mode 100644 index 0000000000..58e8387cbf --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/DeployLaunchShortcut.java @@ -0,0 +1,184 @@ +package edu.wpi.first.wpilib.plugins.cpp.launching; + +import java.io.File; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants; +import org.eclipse.cdt.launch.remote.IRemoteConnectionConfigurationConstants; +import org.eclipse.core.internal.resources.Resource; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.ILaunchShortcut; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.PlatformUI; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; + +/** + * Launch shortcut base functionality, common for deploying to the robot. + * Retrieves the project the operation is being called on, and runs the correct + * ant targets based on polymorphically determined data values + * + * @author Ryan O'Meara + * @author Alex Henning + */ +@SuppressWarnings("restriction") +public class DeployLaunchShortcut implements ILaunchShortcut { + //Class constants - used to delineate types for launch shortcuts + public static final String DEPLOY_TYPE = "edu.wpi.first.wpilib.plugins.core.deploy"; + private static final String ANT_SERVER_THREAD_NAME = "Ant Build Server Connection"; + + private static ILaunch lastDeploy = null; + + /** + * Returns the launch type of the shortcut that was used, one of the constants + * defined in BaseLaunchShortcut + * @return Launch shortcut type + */ + public String getLaunchType() {return DEPLOY_TYPE;} + + @Override + public void launch(ISelection selection, String mode) { + //Extract resource from selection + StructuredSelection sel = (StructuredSelection)selection; + IProject activeProject = null; + if (sel.getFirstElement() instanceof IProject) { + activeProject = (IProject) sel.getFirstElement(); + } else { + return; + } + + //Run config using project found in extracted resource, with indicated mode + runConfig(activeProject, mode); + } + + @Override + public void launch(IEditorPart editor, String mode) { + //Extract resource from editor + if(editor != null){ + IFileEditorInput input = (IFileEditorInput)editor.getEditorInput(); + IFile file = input.getFile(); + IProject activeProject = file.getProject(); + + //If editor existed, run config using extracted resource in indicated mode + runConfig(activeProject, mode); + }else{ + System.err.println("editor was null"); + } + + } + + /** + * Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile) + * @param activeProj The project that the script will be run on/from + * @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE) + */ + public void runConfig(IProject activeProj, String mode){ + String targets = "deploy"; + + if(mode.equals(ILaunchManager.RUN_MODE)){ + if(getLaunchType().equals(DEPLOY_TYPE)){ + targets = "deploy"; + } + } else if ((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) { + targets = "debug-deploy"; + try{ + PlatformUI.getWorkbench().showPerspective(IDebugUIConstants.ID_DEBUG_PERSPECTIVE, + PlatformUI.getWorkbench().getActiveWorkbenchWindow()); + + }catch(Exception e){} + } + + if((lastDeploy != null)&&(!lastDeploy.isTerminated())){ + System.out.println("Last deploy running"); + //Find the server connection thread and kill it + Vector threadGroups = new Vector(); + ThreadGroup root = Thread.currentThread().getThreadGroup().getParent(); + while (root.getParent() != null) {root = root.getParent();} + threadGroups.add(root); + ThreadGroup threadGroup = threadGroups.remove(0); + int numThreads = threadGroup.activeCount(); + Thread[] threads = new Thread[numThreads*100]; + numThreads = threadGroup.enumerate(threads, true); + + for(Thread current: threads){ + if(current != null){ + if(current.getName().equals(ANT_SERVER_THREAD_NAME)){ + try{ + //Manually end thread and then try terminating launch + Method stopMethod = current.getClass().getMethod("stop"); + stopMethod.invoke(current); + lastDeploy.terminate(); + break; + }catch(Exception e){e.printStackTrace();} + } + } + } + + System.out.println("Waiting"); + try{wait(1000);}catch(Exception e){} + + } + + if (mode.equals(ILaunchManager.RUN_MODE)) { + System.out.println("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml"); + System.out.println("Targets: " + targets + ", Mode: " + mode); + lastDeploy = AntLauncher.runAntFile(new File (activeProj.getLocation().toOSString() + File.separator + "build.xml"), targets, null, mode); + } else if((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) { + ILaunchConfigurationWorkingCopy config; + try { + config = getRemoteDebugConfig(activeProj); + //config.doSave(); // NOTE: For debugging + startDebugConfig(config, lastDeploy); + } catch (CoreException e) { + System.err.println("Debug attach failed."); + e.printStackTrace(); + } + } + + try { + activeProj.refreshLocal(Resource.DEPTH_INFINITE, null); + } catch (Exception e) {} + } + + private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException { + ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); + ILaunchConfigurationType type = manager.getLaunchConfigurationType(ICDTLaunchConfigurationConstants.ID_LAUNCH_C_REMOTE_APP); + int teamNumber = WPILibCore.getDefault().getTeamNumber(activeProj); + String remote_connection = RSEUtils.getTarget(teamNumber).getName(); + + ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName()); + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName()); + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_PROGRAM_NAME, "Debug/FRCUserProgram"); + config.setAttribute(DebugPlugin.getUniqueIdentifier() + ".ATTR_TARGET_PATH", "/home/admin/FRCUserProgram"); + config.setAttribute("org.eclipse.cdt.debug.mi.core.DEBUG_NAME", WPILibCPPPlugin.getDefault().getToolchain()+"/bin/arm-none-linux-gnueabi-gdb"); + config.setAttribute("org.eclipse.cdt.dsf.gdb.DEBUG_NAME", WPILibCPPPlugin.getDefault().getToolchain()+"/bin/arm-none-linux-gnueabi-gdb"); + config.setAttribute(IRemoteConnectionConfigurationConstants.ATTR_REMOTE_CONNECTION, remote_connection); + config.setAttribute(ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_ID, "org.eclipse.rse.remotecdt.RemoteGDBDebugger"); + Map launchers = new HashMap(); + launchers.put("[debug]", "org.eclipse.rse.remotecdt.launch"); + config.setAttribute(DebugPlugin.getUniqueIdentifier() + ".preferred_launchers", launchers); + + return config; + } + + private void startDebugConfig(final ILaunchConfigurationWorkingCopy config, ILaunch deploy) throws CoreException { + config.launch(ILaunchManager.DEBUG_MODE, null); + } +} + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/RSEUtils.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/RSEUtils.java new file mode 100644 index 0000000000..1a88a91246 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/launching/RSEUtils.java @@ -0,0 +1,53 @@ +package edu.wpi.first.wpilib.plugins.cpp.launching; + +import java.util.Arrays; + +import org.eclipse.rse.core.IRSESystemType; +import org.eclipse.rse.core.PasswordPersistenceManager; +import org.eclipse.rse.core.RSECorePlugin; +import org.eclipse.rse.core.model.IHost; +import org.eclipse.rse.core.model.ISystemProfile; +import org.eclipse.rse.core.model.ISystemRegistry; +import org.eclipse.rse.core.model.SystemSignonInformation; + +public class RSEUtils { + + public static IHost getTarget(int teamNumber) { + // The ip address based on the team number + String hostName = "10."+(teamNumber/100)+"."+(teamNumber%100)+".2"; + String connectionName = "Team "+teamNumber; + + // get the singleton RSE registry + try { + RSECorePlugin.waitForInitCompletion(); + } catch (InterruptedException e1) { + // TODO Auto-generated catch block + e1.printStackTrace(); + } + ISystemRegistry registry = RSECorePlugin.getDefault().getSystemRegistry(); + + // get the default profile, used to store connections + System.out.println("Profiles: "+Arrays.toString(registry.getActiveSystemProfiles())); + ISystemProfile profile = registry.getActiveSystemProfiles()[0]; + + // see if a host object already exists for "build.eclipse.org" + IHost host = registry.getHost(profile, connectionName); + if (host == null) { + // if there's no host then we will create it + try { + // create the host object as an SSH Only connection + IRSESystemType systemType = + RSECorePlugin.getTheCoreRegistry().getSystemTypeById("org.eclipse.rse.systemtype.ssh"); + host = registry.createHost(profile.getName(), systemType, connectionName, hostName, + "The remote target for debugging the robot for team "+teamNumber+"."); + host.setDefaultUserId("admin"); + SystemSignonInformation info = new SystemSignonInformation(hostName, "admin", + "XX", systemType); + PasswordPersistenceManager.getInstance().add(info, true, false); + } catch (Exception e) { + e.printStackTrace(); + } + } + return host; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/preferences/CPPPreferencePage.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/preferences/CPPPreferencePage.java new file mode 100644 index 0000000000..c9733a0d74 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/preferences/CPPPreferencePage.java @@ -0,0 +1,118 @@ +package edu.wpi.first.wpilib.plugins.cpp.preferences; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Properties; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.preferences.ComboFieldEditor; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing FieldEditorPreferencePage, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + *

+ * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class CPPPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + ComboFieldEditor toolchainVersionEditor; + BooleanFieldEditor autoUpdateToolchainEditor; + private ComboFieldEditor wpiLibVersionEditor; + private BooleanFieldEditor autoUpdateEditor; + + public CPPPreferencePage() { + super(GRID); + setPreferenceStore(WPILibCPPPlugin.getDefault().getPreferenceStore()); + setDescription("Change workspace level settings for C++."); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + wpiLibVersionEditor = new ComboFieldEditor(PreferenceConstants.LIBRARY_VERSION, + "&Library Version:", getFieldEditorParent(), getInstalledVersions()); + addField(wpiLibVersionEditor); + autoUpdateEditor = new BooleanFieldEditor(PreferenceConstants.UPDATE_LIBRARY_VERSION, + "&Auto Update Library Version", getFieldEditorParent()); + addField(autoUpdateEditor); + toolchainVersionEditor = new ComboFieldEditor(PreferenceConstants.TOOLCHAIN_VERSION, + "&Toolchain Version:", getFieldEditorParent(), getInstalledToolchains()); + addField(toolchainVersionEditor); + autoUpdateToolchainEditor = new BooleanFieldEditor(PreferenceConstants.UPDATE_TOOLCHAIN_VERSION, + "&Auto Update Toolchain Version", getFieldEditorParent()); + addField(autoUpdateToolchainEditor); + } + + private List getInstalledVersions() { + File[] dirs = new File(WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"cpp") + .listFiles(new FileFilter() { + @Override public boolean accept(File f) { + return f.isDirectory(); + } + }); + List versions = new ArrayList(); + for (File dir : dirs) { + versions.add(dir.getName()); + } + Collections.sort(versions); + return versions; + } + + private List getInstalledToolchains() { + File[] dirs = new File(WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"toolchains") + .listFiles(new FileFilter() { + @Override public boolean accept(File f) { + return f.isDirectory(); + } + }); + List versions = new ArrayList(); + for (File dir : dirs) { + versions.add(dir.getName()); + } + Collections.sort(versions); + return versions; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + System.out.println("Preferences initialized."); + Properties props = WPILibCore.getDefault().getProjectProperties(null); + getPreferenceStore().setValue(PreferenceConstants.LIBRARY_VERSION, + props.getProperty("cpp-version", WPILibCPPPlugin.getDefault().getCurrentVersion())); + } + + @Override public void performApply() { + performOk(); + } + + @Override public boolean performOk() { + Properties props = WPILibCore.getDefault().getProjectProperties(null); + props.setProperty("cpp-version", wpiLibVersionEditor.getChoice()); + WPILibCore.getDefault().saveGlobalProperties(props); + return super.performOk(); + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/preferences/PreferenceConstants.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/preferences/PreferenceConstants.java new file mode 100644 index 0000000000..936107c937 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/preferences/PreferenceConstants.java @@ -0,0 +1,11 @@ +package edu.wpi.first.wpilib.plugins.cpp.preferences; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + public static final String LIBRARY_VERSION = "libraryVersionPreference"; + public static final String UPDATE_LIBRARY_VERSION = "udpateLibraryVersionPreference"; + public static final String TOOLCHAIN_VERSION = "toolchainVersionPreference"; + public static final String UPDATE_TOOLCHAIN_VERSION = "udpateToolchainVersionPreference"; +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/preferences/PreferenceInitializer.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/preferences/PreferenceInitializer.java new file mode 100644 index 0000000000..a82f47bcab --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/preferences/PreferenceInitializer.java @@ -0,0 +1,28 @@ +package edu.wpi.first.wpilib.plugins.cpp.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = WPILibCPPPlugin.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.LIBRARY_VERSION, + WPILibCore.getDefault().getProjectProperties(null) + .getProperty("cpp-version", WPILibCPPPlugin.getDefault().getCurrentVersion())); + store.setDefault(PreferenceConstants.UPDATE_LIBRARY_VERSION, true); + store.setDefault(PreferenceConstants.TOOLCHAIN_VERSION, WPILibCPPPlugin.getDefault().getDefaultToolchainVersion()); + store.setDefault(PreferenceConstants.UPDATE_TOOLCHAIN_VERSION, true); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/examples/ExampleCPPProject.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/examples/ExampleCPPProject.java new file mode 100644 index 0000000000..d0b4eb0275 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/examples/ExampleCPPProject.java @@ -0,0 +1,49 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.examples; + +import java.util.List; +import java.util.Map; + +import edu.wpi.first.wpilib.plugins.core.wizards.IExampleProject; +import edu.wpi.first.wpilib.plugins.cpp.wizards.newproject.CPPProjectType; + +public class ExampleCPPProject extends CPPProjectType implements IExampleProject { + private String name, description; + private List tags; + private List directories; + private List files; + + public ExampleCPPProject(String name, String description, List tags, + List directories, List files) { + this.name = name; + this.description = description; + this.tags = tags; + this.directories = directories; + this.files = files; + } + + public String getName() { + return name; + } + + public String getContent() { + return "

"+name+"

"+description+"

"; + } + + public List getTags() { + return tags; + } + + @Override + public String[] getFolders(String packageName) { + return directories.toArray(new String[0]); + } + + @Override + public Map getFiles(String packageName) { + Map files = super.getFiles(packageName); + for (ExportFile file : this.files) { + files.put(file.destination, file.source); + } + return files; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/examples/ExampleCPPWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/examples/ExampleCPPWizard.java new file mode 100644 index 0000000000..1ecdfed307 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/examples/ExampleCPPWizard.java @@ -0,0 +1,65 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.examples; + +import java.net.URL; +import java.util.List; +import java.util.Properties; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.wizard.IWizardPage; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.wizards.ExampleWizard; +import edu.wpi.first.wpilib.plugins.core.wizards.IExampleProject; +import edu.wpi.first.wpilib.plugins.core.wizards.IExampleProject.ExportFile; +import edu.wpi.first.wpilib.plugins.core.wizards.NewProjectMainPage; +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectCreationUtils; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; +import edu.wpi.first.wpilib.plugins.cpp.wizards.newproject.WPIRobotCPPProjectCreator; + +public class ExampleCPPWizard extends ExampleWizard { + private NewProjectMainPage detailsPage; + + /** + * Constructor for SampleNewWizard. + */ + public ExampleCPPWizard() { + super(); + setNeedsProgressMonitor(true); + } + + @Override + protected void doFinish(IExampleProject ex, String teamNumber) throws CoreException { + Properties props = WPILibCore.getDefault().getProjectProperties(null); + props.setProperty("team-number", teamNumber); + WPILibCore.getDefault().saveGlobalProperties(props); + + final String projectName = detailsPage.getProjectName(); + ProjectCreationUtils.createProject(new WPIRobotCPPProjectCreator(projectName, ex)); + } + + @Override + protected IWizardPage getDetailsPage() { + if (detailsPage != null) return detailsPage; + detailsPage = new NewProjectMainPage(selection, getTeamNumberPage()); + detailsPage.setTitle("Create Example Robot Java Project"); + detailsPage.setDescription("This wizard creates a new example project based on your selection."); + detailsPage.setShowPackage(false); + return detailsPage; + } + + @Override + public IExampleProject makeExampleProject(String name, String description, + List tags, List folders, List files) { + return new ExampleCPPProject(name, description, tags, folders, files); + } + + @Override + public URL getResourceURL() { + return WPILibCPPPlugin.getDefault().getBundle().getEntry("/resources/templates/examples"); + } + + @Override + public String getXMLFile() { + return "examples.xml"; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/CommandGroupWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/CommandGroupWizard.java new file mode 100644 index 0000000000..b7b9e70c9f --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/CommandGroupWizard.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.file_template; + +public class CommandGroupWizard extends FileTemplateWizard { + + public CommandGroupWizard() { + super("CommandGroup", "command-based/CommandGroup", "Commands"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/CommandWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/CommandWizard.java new file mode 100644 index 0000000000..649020a267 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/CommandWizard.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.file_template; + +public class CommandWizard extends FileTemplateWizard { + + public CommandWizard() { + super("Command", "command-based/Command", "Commands"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/FileTemplateWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/FileTemplateWizard.java new file mode 100644 index 0000000000..bf920eb5da --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/FileTemplateWizard.java @@ -0,0 +1,135 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.file_template; + +import java.io.File; +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.cdt.core.model.ICContainer; +import org.eclipse.cdt.core.model.ISourceRoot; +import org.eclipse.cdt.core.model.ITranslationUnit; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWizard; + +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectCreationUtils; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; + +public class FileTemplateWizard extends Wizard implements INewWizard { + private String type, source, ending; + private FileTemplateWizardMainPage page; + private ISelection selection; + private IProject project; + + /** + * Constructor for SampleNewWizard. + */ + public FileTemplateWizard(String type, String source, String ending) { + super(); + setNeedsProgressMonitor(true); + this.type = type; + this.source = source; + this.ending = ending; + } + + /** + * Adding the page to the wizard. + */ + + public void addPages() { + page = new FileTemplateWizardMainPage(type, project, ending, selection); + addPage(page); + } + + /** + * This method is called when 'Finish' button is pressed in + * the wizard. We will create an operation and run it + * using wizard as execution context. + */ + public boolean performFinish() { + final IProject project = page.getProject(); + final String className = page.getClassName(); + final String folderName = page.getFolder(); + System.out.println("Class: "+className+" Folder: "+folderName); + IRunnableWithProgress op = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException { + try { + doFinish(project, className, folderName, monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }; + try { + getContainer().run(true, false, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + Throwable realException = e.getTargetException(); + MessageDialog.openError(getShell(), "Error", realException.getMessage()); + return false; + } + return true; + } + + /** + * The worker method. It will find the container, create the + * file if missing or just replace its contents, and open + * the editor on the newly created file. + */ + private void doFinish(IProject project, String className, String folderName, IProgressMonitor monitor) throws CoreException { + Map map = new HashMap(); + map.put("$classname", className); + map.put("$folder", folderName); + String filepath = folderName+File.separator+className; + try { + // Create Header + URL url = new URL(WPILibCPPPlugin.getDefault().getBundle().getEntry("/resources/templates/"), source+".h"); + ProjectCreationUtils.createTemplateFile(project, filepath+".h", url, map); + + // Create CPP file + url = new URL(WPILibCPPPlugin.getDefault().getBundle().getEntry("/resources/templates/"), source+".cpp"); + ProjectCreationUtils.createTemplateFile(project, filepath+".cpp", url, map); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * We will accept the selection in the workbench to see if + * we can initialize from it. + * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.selection = selection; + System.out.println(selection); + Object element = ((StructuredSelection) selection).getFirstElement(); + System.out.println(element.getClass()); + if (element instanceof IResource) { + project = ((IResource) element).getProject(); + } else if (element instanceof ISourceRoot) { + project = ((ISourceRoot) element).getCProject().getProject(); + } else if (element instanceof ITranslationUnit) { + project = ((ITranslationUnit) element).getCProject().getProject(); + } else if (element instanceof ISourceRoot) { + project = ((ISourceRoot) element).getCProject().getProject(); + } else if (element instanceof ICContainer) { + project = ((ICContainer) element).getCProject().getProject(); + } else System.out.println("Element not instance of IResource: "+element.getClass()); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/FileTemplateWizardMainPage.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/FileTemplateWizardMainPage.java new file mode 100644 index 0000000000..02f498aa78 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/FileTemplateWizardMainPage.java @@ -0,0 +1,179 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.file_template; + +import java.io.File; + +import org.eclipse.cdt.core.CCProjectNature; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.dialogs.IDialogPage; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature; +import edu.wpi.first.wpilib.plugins.core.wizards.IProjectFilter; +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectComboField; + +/** + * The "New" wizard page allows setting the container for the new file as well + * as the file name. The page will only accept file name without the extension + * OR with the extension that matches the expected one (mpe). + */ + +public class FileTemplateWizardMainPage extends WizardPage { + private IProject project; + private String ending; + private ProjectComboField projectsCombo; + private Text classNameText; + private Text folderText; + + /** + * Constructor for SampleNewWizardPage. + * + * @param pageName + */ + public FileTemplateWizardMainPage(String type, IProject project, String ending, ISelection selection) { + super("wizardPage"); + setTitle("Create New "+type); + setDescription("This wizard creates a new "+type.toLowerCase()+" from a template."); + this.project = project; + this.ending = ending; + } + + /** + * @see IDialogPage#createControl(Composite) + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 2; + layout.verticalSpacing = 9; + + Label label = new Label(container, SWT.NULL); + label.setText("Pro&ject:"); + + projectsCombo = new ProjectComboField(container, SWT.BORDER | SWT.SINGLE, + new IProjectFilter() { + @Override public boolean accept(IProject project) { + try { + return project.hasNature(FRCProjectNature.FRC_PROJECT_NATURE) + && project.hasNature(CCProjectNature.C_NATURE_ID); + } catch (CoreException e) { + e.printStackTrace(); + return false; + } + } + }); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + projectsCombo.setLayoutData(gd); + projectsCombo.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + + label = new Label(container, SWT.NULL); + label.setText("Class &Name:"); + + classNameText = new Text(container, SWT.BORDER | SWT.SINGLE); + gd = new GridData(GridData.FILL_HORIZONTAL); + classNameText.setLayoutData(gd); + classNameText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + + label = new Label(container, SWT.NULL); + label.setText("&Folder:"); + + folderText = new Text(container, SWT.BORDER | SWT.SINGLE); + gd = new GridData(GridData.FILL_HORIZONTAL); + folderText.setLayoutData(gd); + folderText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + + initialize(); + dialogChanged(); + setControl(container); + } + + /** + * Tests if the current workbench selection is a suitable container to use. + */ + + private void initialize() { + projectsCombo.setProject(project); + folderText.setText(getDefaultFolder()); + } + + /** + * Ensures that both text fields are set. + */ + + private void dialogChanged() { + String className = getClassName(); + String folder = getFolder(); + + // Update the default package if necessary + if (project == null || !project.equals(projectsCombo.getProject())) { + String oldDefault = getDefaultFolder(); + project = projectsCombo.getProject(); + if (folder.equals(oldDefault)) { + folderText.setText(getDefaultFolder()); + } + } + + if (!projectsCombo.isValid()) { + updateStatus("Must select a project."); + return; + } + + if (className.length() == 0) { + updateStatus("Class name must be specified"); + return; + } + if (!className.matches("^([a-zA-Z_]{1}[a-zA-Z0-9_]*)$")) { + updateStatus("Must be a valid java class name"); + return; + } + if (folder.length() == 0) { + updateStatus("Package must be specified"); + return; + } + updateStatus(null); + } + + private void updateStatus(String message) { + setErrorMessage(message); + setPageComplete(message == null); + } + + public IProject getProject() { + return projectsCombo.getProject(); + } + + public String getClassName() { + return classNameText.getText(); + } + + public String getFolder() { + return folderText.getText(); + } + + public String getDefaultFolder() { + System.out.println("Project: "+project); + return "src"+File.separator+ending; + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/PIDSubsystemWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/PIDSubsystemWizard.java new file mode 100644 index 0000000000..63e615831b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/PIDSubsystemWizard.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.file_template; + +public class PIDSubsystemWizard extends FileTemplateWizard { + + public PIDSubsystemWizard() { + super("PIDSubsystem", "command-based/PIDSubsystem", "Subsystems"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/SubsystemWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/SubsystemWizard.java new file mode 100644 index 0000000000..2c60310329 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/SubsystemWizard.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.file_template; + +public class SubsystemWizard extends FileTemplateWizard { + + public SubsystemWizard() { + super("Subsystem", "command-based/Subsystem", "Subsystems"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/TriggerWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/TriggerWizard.java new file mode 100644 index 0000000000..73d0d04407 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/file_template/TriggerWizard.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.file_template; + +public class TriggerWizard extends FileTemplateWizard { + + public TriggerWizard() { + super("Trigger", "command-based/Trigger", "Triggers"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/CPPProjectType.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/CPPProjectType.java new file mode 100644 index 0000000000..d376f19bad --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/CPPProjectType.java @@ -0,0 +1,75 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.newproject; + +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectType; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; + +public class CPPProjectType implements ProjectType { + static ProjectType SIMPLE = new CPPProjectType() { + @Override public Map getFiles(String packageName) { + Map files = super.getFiles(packageName); + files.put("src/Robot.cpp", "simple/Robot.cpp"); + return files; + } + }; + static ProjectType ITERATIVE = new CPPProjectType() { + @Override public Map getFiles(String packageName) { + Map files = super.getFiles(packageName); + files.put("src/Robot.cpp", "iterative/Robot.cpp"); + return files; + } + }; + static ProjectType COMMAND_BASED = new CPPProjectType() { + @Override public String[] getFolders(String packageName) { + String[] paths = {"src", + "src/Commands", + "src/Subsystems", + "src/Triggers"}; + return paths; + } + @Override public Map getFiles(String packageName) { + Map files = super.getFiles(packageName); + files.put("src/Robot.cpp", "command-based/Robot.cpp"); + files.put("src/OI.h", "command-based/OI.h"); + files.put("src/OI.cpp", "command-based/OI.cpp"); + files.put("src/RobotMap.h", "command-based/RobotMap.h"); + files.put("src/CommandBase.cpp", "command-based/CommandBase.cpp"); + files.put("src/CommandBase.h", "command-based/CommandBase.h"); + files.put("src/Subsystems/ExampleSubsystem.h", "command-based/ExampleSubsystem.h"); + files.put("src/Subsystems/ExampleSubsystem.cpp", "command-based/ExampleSubsystem.cpp"); + files.put("src/Commands/ExampleCommand.h", "command-based/ExampleCommand.h"); + files.put("src/Commands/ExampleCommand.cpp", "command-based/ExampleCommand.cpp"); + return files; + } + }; + @SuppressWarnings("serial") + static Map TYPES = new HashMap() {{ + put(ProjectType.SIMPLE, SIMPLE); + put(ProjectType.ITERATIVE, ITERATIVE); + put(ProjectType.COMMAND_BASED, COMMAND_BASED); + }}; + + @Override + public String[] getFolders(String packageName) { + String[] paths = {"src"}; + return paths; + } + + @Override + public Map getFiles(String packageName) { + HashMap files = new HashMap(); + files.put("build.xml", "build.xml"); + files.put("build.properties", "build.properties"); + files.put(".cproject", ".cproject"); + return files; + } + + + @Override + public URL getBaseURL() { + return WPILibCPPPlugin.getDefault().getBundle().getEntry("/resources/templates/"); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/NewCPPWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/NewCPPWizard.java new file mode 100644 index 0000000000..b4a07bfb50 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/NewCPPWizard.java @@ -0,0 +1,120 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.newproject; + +import java.lang.reflect.InvocationTargetException; +import java.util.Properties; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWizard; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.wizards.NewProjectMainPage; +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectCreationUtils; +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectType; +import edu.wpi.first.wpilib.plugins.core.wizards.TeamNumberPage; + +/** + * + * Example Docs: + * This is a sample new wizard. Its role is to create a new file + * resource in the provided container. If the container resource + * (a folder or a project) is selected in the workspace + * when the wizard is opened, it will accept it as the target + * container. The wizard creates one file with the extension + * "mpe". If a sample multi-page editor (also available + * as a template) is registered for the same extension, it will + * be able to open it. + */ + +public class NewCPPWizard extends Wizard implements INewWizard { + private NewProjectMainPage page; + private ISelection selection; + private TeamNumberPage teamNumberPage; + + /** + * Constructor for SampleNewWizard. + */ + public NewCPPWizard() { + super(); + setNeedsProgressMonitor(true); + } + + /** + * Adding the page to the wizard. + */ + + public void addPages() { + if (TeamNumberPage.needsTeamNumberPage()) { + teamNumberPage = new TeamNumberPage(selection); + addPage(teamNumberPage); + } + page = new NewProjectMainPage(selection, teamNumberPage); + page.setTitle("Create New Robot C++ Project"); + page.setDescription("This wizard creates a new Robot C++ Project configured to use WPILib for programming FRC robots."); + page.setShowPackage(false); + page.setProjectTypes(CPPProjectType.TYPES); + addPage(page); + } + + /** + * This method is called when 'Finish' button is pressed in + * the wizard. We will create an operation and run it + * using wizard as execution context. + */ + public boolean performFinish() { + final String projectName = page.getProjectName(); + final String teamNumber = TeamNumberPage.getTeamNumberFromPage(teamNumberPage); + final ProjectType projectType = page.getProjectType(); + System.out.println("Project: "+projectName+" Project Type: "+projectType); + IRunnableWithProgress op = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException { + try { + doFinish(projectName, teamNumber, projectType, monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }; + try { + getContainer().run(true, false, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + Throwable realException = e.getTargetException(); + MessageDialog.openError(getShell(), "Error", realException.getMessage()); + return false; + } + return true; + } + + /** + * The worker method. It will find the container, create the + * file if missing or just replace its contents, and open + * the editor on the newly created file. + */ + + private void doFinish(String projectName, String teamNumber, ProjectType projectType, IProgressMonitor monitor) throws CoreException { + Properties props = WPILibCore.getDefault().getProjectProperties(null); + props.setProperty("team-number", teamNumber); + WPILibCore.getDefault().saveGlobalProperties(props); + ProjectCreationUtils.createProject(new WPIRobotCPPProjectCreator(projectName, projectType)); + } + + /** + * We will accept the selection in the workbench to see if + * we can initialize from it. + * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.selection = selection; + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/WPIRobotCPPProjectCreator.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/WPIRobotCPPProjectCreator.java new file mode 100644 index 0000000000..53748cf625 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/java/edu/wpi/first/wpilib/plugins/cpp/wizards/newproject/WPIRobotCPPProjectCreator.java @@ -0,0 +1,92 @@ +package edu.wpi.first.wpilib.plugins.cpp.wizards.newproject; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.cdt.build.core.scannerconfig.ScannerConfigNature; +import org.eclipse.cdt.core.CCProjectNature; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.index.IIndexManager; +import org.eclipse.cdt.core.model.ICElement; +import org.eclipse.cdt.managedbuilder.core.ManagedCProjectNature; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; + +import edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature; +import edu.wpi.first.wpilib.plugins.core.wizards.IProjectCreator; +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectType; +import edu.wpi.first.wpilib.plugins.cpp.WPILibCPPPlugin; + +public class WPIRobotCPPProjectCreator implements IProjectCreator { + String projectName; + ProjectType projectType; + + public WPIRobotCPPProjectCreator(String projectName, ProjectType projectType) { + this.projectName = projectName; + this.projectType = projectType; + } + + @Override + public String getName() { + return projectName; + } + + @Override + public String getPackageName() { + return ""; // C++ doesn't have the equivalent of a project name + } + + @Override + public Map getValues() { + Map vals = new HashMap(); + vals.put("$project", projectName); + vals.put("$toolchain", WPILibCPPPlugin.getDefault().getToolchain()); + vals.put("$cpp-location", WPILibCPPPlugin.getDefault().getCPPDir()); + return vals; + } + + @Override + public List getNatures() { + List natures = new ArrayList<>(); + natures.add(CCProjectNature.C_NATURE_ID); + natures.add(CCProjectNature.CC_NATURE_ID); + natures.add(ManagedCProjectNature.MNG_NATURE_ID); + natures.add(ScannerConfigNature.NATURE_ID); + natures.add(FRCProjectNature.FRC_PROJECT_NATURE); + return natures; + } + + @Override + public ProjectType getProjectType() { + return projectType; + } + + @Override + public void initialize(IProject project) { + try { + CCorePlugin.getDefault().createCDTProject(project.getDescription(), project, null); + project.open(null); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + + //config.getToolChain().getOptionById("cdt.managedbuild.option.gnu.cross.prefix").setValue(prefix); + //config.getToolChain().getOptionById("cdt.managedbuild.option.gnu.cross.path").setValue(path); + } + + @Override + public void finalize(IProject project) throws CoreException { + updateVariables(project); + + // Freshen the index because otherwise it's red and angry + ICElement[] projects = {CCorePlugin.getDefault().getCoreModel().create(project)}; + CCorePlugin.getIndexManager().update(projects, IIndexManager.UPDATE_ALL | IIndexManager.UPDATE_EXTERNAL_FILES_FOR_PROJECT); + } + + private void updateVariables(IProject project) throws CoreException { + // TODO: implement C++ equivalent + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/ant-classloadertask.jar b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/ant-classloadertask.jar new file mode 100644 index 0000000000..d2f58d9f1d Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/ant-classloadertask.jar differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/ant-contrib.jar b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/ant-contrib.jar new file mode 100644 index 0000000000..ea817cd434 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/ant-contrib.jar differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml new file mode 100644 index 0000000000..6f9627176f --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/build.xml @@ -0,0 +1,101 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Target IP: ${target} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + [athena-deploy] Killing running program + + [athena-deploy] Copying code over. + + + + [athena-deploy] Starting program. + + + + + [athena-deploy] Killing running program + + [athena-debug-deploy] Copying code over. + + + + [athena-debug-deploy] Starting program. + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/debugjavaprogram b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/debugjavaprogram new file mode 100644 index 0000000000..e5c0068b6a --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/debugjavaprogram @@ -0,0 +1,6 @@ +#. ./.profile +killall java +sleep 1 +nohup java -Djna.library.path=$LD_LIBRARY_PATH -Xmx32M -agentlib:jdwp=transport=dt_socket,address=8348,server=y,suspend=y -jar FRCUserProgram.jar edu.wpi.first.wpilibj.unittests.RunTests + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/jsch-0.1.50.jar b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/jsch-0.1.50.jar new file mode 100644 index 0000000000..85c044f216 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/jsch-0.1.50.jar differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/runcppprogram b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/runcppprogram new file mode 100644 index 0000000000..5eab995b6d --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/runcppprogram @@ -0,0 +1,6 @@ +#. ./.profile +killall java +killall FRCUserProgram +sleep 1 +chmod +x ./FRCUserProgram +nohup ./FRCUserProgram diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/runjavaprogram b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/runjavaprogram new file mode 100644 index 0000000000..114b837be9 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.cpp/src/main/resources/cpp-zip/ant/runjavaprogram @@ -0,0 +1,5 @@ +#. ./.profile +killall java +killall FRCUserProgram +sleep 1 +nohup java -Djna.library.path=$LD_LIBRARY_PATH -Xmx32M -jar FRCUserProgram.jar diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/.project new file mode 100644 index 0000000000..bd4257bb4d --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/.project @@ -0,0 +1,17 @@ + + + edu.wpi.first.wpilib.plugins.java.feature + + + + + + org.eclipse.pde.FeatureBuilder + + + + + + org.eclipse.pde.FeatureNature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/build.properties new file mode 100644 index 0000000000..64f93a9f0b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/build.properties @@ -0,0 +1 @@ +bin.includes = feature.xml diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/feature.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/feature.xml new file mode 100644 index 0000000000..318db9ab0a --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/feature.xml @@ -0,0 +1,59 @@ + + + + + FRC Robot Java Program Development Environment. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. + + + + * Copyright (c) 2013 FIRST and WPI +* All rights reserved. +* +* Redistribution and use in source and binary forms, with or +* without modification, are permitted provided that the following +* conditions are met: +* Redistributions of source code must retain the above +* copyright notice, this list of conditions and the following +* disclaimer. Redistributions in binary form must reproduce the +* above copyright notice, this list of conditions and the following +* disclaimer in the documentation and/or other materials provided +* with the distribution. Neither the name of the FIRST nor the +* names of its contributors may be used to endorse or promote +* products derived from this software without specific prior +* written permission. +* +* THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' +* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED +* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT +* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO +* EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, +* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE +* GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS +* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, +* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE +* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, +* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/pom.xml new file mode 100644 index 0000000000..5abf065c41 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java.feature/pom.xml @@ -0,0 +1,15 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.java.feature + eclipse-feature + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/.classpath b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/.classpath new file mode 100644 index 0000000000..c0b4c7e112 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/.project new file mode 100644 index 0000000000..02b92fbf34 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/.project @@ -0,0 +1,34 @@ + + + edu.wpi.first.wpilib.plugins.java + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/META-INF/MANIFEST.MF b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..c0e4927e75 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/META-INF/MANIFEST.MF @@ -0,0 +1,23 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: WPILib_Java_Robot_Development +Bundle-SymbolicName: edu.wpi.first.wpilib.plugins.java;singleton:=true +Bundle-Version: 0.1.0.qualifier +Bundle-Activator: edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin +Bundle-Vendor: Worcester Polytechnic Institute +Require-Bundle: org.eclipse.ui, + org.eclipse.core.runtime, + org.eclipse.core.resources;bundle-version="3.8.1", + edu.wpi.first.wpilib.plugins.core;bundle-version="0.1.0", + org.eclipse.jdt;bundle-version="3.8.0", + org.eclipse.jdt.core;bundle-version="3.8.2", + org.eclipse.jdt.debug;bundle-version="3.7.101", + org.eclipse.jdt.debug.ui;bundle-version="3.6.100", + org.eclipse.jdt.launching;bundle-version="3.6.100", + org.eclipse.jdt.ui;bundle-version="3.8.1", + org.eclipse.debug.core;bundle-version="3.7.100", + org.eclipse.debug.ui;bundle-version="3.8.1", + org.eclipse.ui.editors;bundle-version="3.8.0", + org.eclipse.ui.ide;bundle-version="3.8.1" +Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-ActivationPolicy: lazy diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/build.properties new file mode 100644 index 0000000000..b91237bcf1 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/build.properties @@ -0,0 +1,8 @@ +source.. = src/main/java/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml,\ + resources/ +src.includes = src/,\ + resources/ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/plugin.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/plugin.xml new file mode 100644 index 0000000000..e9166311f8 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/plugin.xml @@ -0,0 +1,189 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml new file mode 100644 index 0000000000..52d378c8fe --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/pom.xml @@ -0,0 +1,273 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.java + eclipse-plugin + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + + + DEVELOPMENT + ${project.build.directory}/java-zip + + + + + sonatype + Sonatype OSS Snapshots Repository + http://oss.sonatype.org/content/groups/public + + + + nativelibs4java-repo + http://nativelibs4java.sourceforge.net/maven + + + + WPILib Repository + http://frcbuilder.wpi.edu:8348/ + + + + + + + . + + resources/configuration.properties + + true + + + + + maven-resources-plugin + 2.6 + + + copy-ant-resources-to-java-zip + generate-sources + + copy-resources + + + ${java-zip} + + + src/main/resources/java-zip + + + + + + + + org.apache.maven.plugins + maven-dependency-plugin + 2.8 + + + + + fetch-jar-zip-dependencies + compile + + copy + + + + + + edu.wpi.first.wpilib.networktables.java + NetworkTables + 0.1.0-SNAPSHOT + jar + NetworkTables.jar + ${java-zip}/lib + + + edu.wpi.first.wpilib + WPILibJ + 0.1.0-SNAPSHOT + jar + WPILib.jar + ${java-zip}/lib + + + net.java.dev.jna + jna + 4.0.0 + jar + ${java-zip}/lib + + + com.nativelibs4java + jnaerator-runtime + 0.12-SNAPSHOT + jar + jnaerator-runtime.jar + ${java-zip}/lib + + + + edu.wpi.first.wpilib.networktables.java + NetworkTables + 0.1.0-SNAPSHOT + sources + ${java-zip}/lib + NetworkTables-sources.jar + + + edu.wpi.first.wpilib + WPILibJ + 0.1.0-SNAPSHOT + sources + ${java-zip}/lib + WPILib-sources.jar + + + + + edu.wpi.first.wpilib + WPILibJ + 0.1.0-SNAPSHOT + javadoc + ${java-zip}/javadoc-jar + + + false + true + + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.7 + + + + + set-version-info + + run + + process-sources + + + + + + + + + + + true + + + + + + unzip-javadocs + compile + + run + + + + + + + + + + + + + + + + generate-jar-zip + compile + + run + + + + + + + + + + + + + + + + + edu.wpi.first.wpilib.networktables.java + NetworkTables + 0.1.0-SNAPSHOT + jar + + + edu.wpi.first.wpilib + WPILibJ + 0.1.0-SNAPSHOT + jar + + + net.java.dev.jna + jna + 4.0.0 + jar + + + com.nativelibs4java + jnaerator-runtime + 0.12-SNAPSHOT + jar + + + + + edu.wpi.first.wpilib.networktables.java + NetworkTables + 0.1.0-SNAPSHOT + sources + + + edu.wpi.first.wpilib + WPILibJ + 0.1.0-SNAPSHOT + sources + + + + + edu.wpi.first.wpilib + WPILibJ + 0.1.0-SNAPSHOT + javadoc + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/configuration.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/configuration.properties new file mode 100644 index 0000000000..cbfaca2ede --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/configuration.properties @@ -0,0 +1,2 @@ +timestamp=${timestamp} +version=${version} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Button.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Button.png new file mode 100644 index 0000000000..f6584ec823 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Button.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Command.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Command.png new file mode 100644 index 0000000000..c3d9c2d991 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Command.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/CommandGroup.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/CommandGroup.png new file mode 100644 index 0000000000..1a027c85fd Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/CommandGroup.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/PIDSubsystem.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/PIDSubsystem.png new file mode 100644 index 0000000000..766fca1c3b Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/PIDSubsystem.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Subsystem.png b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Subsystem.png new file mode 100644 index 0000000000..35ee694c8c Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/Subsystem.png differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/sample.gif b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/sample.gif new file mode 100644 index 0000000000..34fb3c9d8c Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/sample.gif differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/wpi.ico b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/wpi.ico new file mode 100644 index 0000000000..a6de9245f9 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/icons/wpi.ico differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/.classpath b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/.classpath new file mode 100644 index 0000000000..daf6ebbf77 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/build.properties new file mode 100644 index 0000000000..e29b4d35d5 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/build.properties @@ -0,0 +1,3 @@ +# Project specific information +package=$package +main=${package}.Robot \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/build.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/build.xml new file mode 100644 index 0000000000..2182d373a5 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/build.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Command.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Command.java new file mode 100644 index 0000000000..ff7510756d --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Command.java @@ -0,0 +1,36 @@ +package $package; + +import edu.wpi.first.wpilibj.command.Command; + +/** + * + */ +public class $classname extends Command { + + public $classname() { + // Use requires() here to declare subsystem dependencies + // eg. requires(chassis); + } + + // Called just before this Command runs the first time + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/CommandGroup.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/CommandGroup.java new file mode 100644 index 0000000000..29e66e86ea --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/CommandGroup.java @@ -0,0 +1,28 @@ +package $package; + +import edu.wpi.first.wpilibj.command.CommandGroup; + +/** + * + */ +public class $classname extends CommandGroup { + + public $classname() { + // Add Commands here: + // e.g. addSequential(new Command1()); + // addSequential(new Command2()); + // these will run in order. + + // To run multiple commands at the same time, + // use addParallel() + // e.g. addParallel(new Command1()); + // addSequential(new Command2()); + // Command1 and Command2 will run in parallel. + + // A command group will require all of the subsystems that each member + // would require. + // e.g. if Command1 requires chassis, and Command2 requires arm, + // a CommandGroup containing them would require both the chassis and the + // arm. + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/ExampleCommand.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/ExampleCommand.java new file mode 100644 index 0000000000..7d04aa17c1 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/ExampleCommand.java @@ -0,0 +1,39 @@ + +package $package.commands; + +import edu.wpi.first.wpilibj.command.Command; + +import $package.Robot; + +/** + * + */ +public class ExampleCommand extends Command { + + public ExampleCommand() { + // Use requires() here to declare subsystem dependencies + requires(Robot.exampleSubsystem); + } + + // Called just before this Command runs the first time + protected void initialize() { + } + + // Called repeatedly when this Command is scheduled to run + protected void execute() { + } + + // Make this return true when this Command no longer needs to run execute() + protected boolean isFinished() { + return false; + } + + // Called once after isFinished returns true + protected void end() { + } + + // Called when another command which requires one or more of the same + // subsystems is scheduled to run + protected void interrupted() { + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/ExampleSubsystem.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/ExampleSubsystem.java new file mode 100644 index 0000000000..6baed1bd73 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/ExampleSubsystem.java @@ -0,0 +1,19 @@ + +package $package.subsystems; + +import edu.wpi.first.wpilibj.command.Subsystem; + +/** + * + */ +public class ExampleSubsystem extends Subsystem { + + // Put methods for controlling this subsystem + // here. Call these from Commands. + + public void initDefaultCommand() { + // Set the default command for a subsystem here. + //setDefaultCommand(new MySpecialCommand()); + } +} + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/PIDSubsystem.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/PIDSubsystem.java new file mode 100644 index 0000000000..1f468fce70 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/PIDSubsystem.java @@ -0,0 +1,34 @@ +package $package; + +import edu.wpi.first.wpilibj.command.PIDSubsystem; + +/** + * + */ +public class $classname extends PIDSubsystem { + + // Initialize your subsystem here + public $classname() { + // Use these to get going: + // setSetpoint() - Sets where the PID controller should move the system + // to + // enable() - Enables the PID controller. + } + + public void initDefaultCommand() { + // Set the default command for a subsystem here. + //setDefaultCommand(new MySpecialCommand()); + } + + protected double returnPIDInput() { + // Return your input value for the PID loop + // e.g. a sensor, like a potentiometer: + // yourPot.getAverageVoltage() / kYourMaxVoltage; + return 0.0; + } + + protected void usePIDOutput(double output) { + // Use output to drive your system, like a motor + // e.g. yourMotor.set(output); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Robot.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Robot.java new file mode 100644 index 0000000000..c11abcc0b7 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Robot.java @@ -0,0 +1,66 @@ + +package $package; + +import edu.wpi.first.wpilibj.IterativeRobot; +import edu.wpi.first.wpilibj.command.Command; +import edu.wpi.first.wpilibj.command.Scheduler; +import edu.wpi.first.wpilibj.livewindow.LiveWindow; +import $package.commands.ExampleCommand; +import $package.subsystems.ExampleSubsystem; + +/** + * The VM is configured to automatically run this class, and to call the + * functions corresponding to each mode, as described in the IterativeRobot + * documentation. If you change the name of this class or the package after + * creating this project, you must also update the manifest file in the resource + * directory. + */ +public class Robot extends IterativeRobot { + + public static final ExampleSubsystem exampleSubsystem = new ExampleSubsystem(); + + Command autonomousCommand; + + /** + * This function is run when the robot is first started up and should be + * used for any initialization code. + */ + public void robotInit() { + // instantiate the command used for the autonomous period + autonomousCommand = new ExampleCommand(); + } + + public void autonomousInit() { + // schedule the autonomous command (example) + autonomousCommand.start(); + } + + /** + * This function is called periodically during autonomous + */ + public void autonomousPeriodic() { + Scheduler.getInstance().run(); + } + + public void teleopInit() { + // This makes sure that the autonomous stops running when + // teleop starts running. If you want the autonomous to + // continue until interrupted by another command, remove + // this line or comment it out. + autonomousCommand.cancel(); + } + + /** + * This function is called periodically during operator control + */ + public void teleopPeriodic() { + Scheduler.getInstance().run(); + } + + /** + * This function is called periodically during test mode + */ + public void testPeriodic() { + LiveWindow.run(); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Subsystem.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Subsystem.java new file mode 100644 index 0000000000..ae97a4ba8f --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Subsystem.java @@ -0,0 +1,18 @@ +package $package; + +import edu.wpi.first.wpilibj.command.Subsystem; + +/** + * + */ +public class $classname extends Subsystem { + + // Put methods for controlling this subsystem + // here. Call these from Commands. + + public void initDefaultCommand() { + // Set the default command for a subsystem here. + //setDefaultCommand(new MySpecialCommand()); + } +} + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Trigger.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Trigger.java new file mode 100644 index 0000000000..768c3870eb --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/command-based/Trigger.java @@ -0,0 +1,13 @@ +package $package; + +import edu.wpi.first.wpilibj.command.Trigger; + +/** + * + */ +public class $classname extends Trigger { + + public boolean get() { + return false; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/Network Table Counter/Robot.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/Network Table Counter/Robot.java new file mode 100644 index 0000000000..edf5564b26 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/Network Table Counter/Robot.java @@ -0,0 +1,39 @@ +package $package; + +import edu.wpi.first.wpilibj.networktables.NetworkTable; + +/** + * An example of a network table counter. + * + * @author Team $team-number + */ +public class Robot { + + private static NetworkTable table; + + /** + * @param args + */ + public static void main(String[] args) { + NetworkTable.setServerMode(); + NetworkTable.setTeam(190); + table = NetworkTable.getTable("SmartDashboard"); + System.out.println("Started up"); + + long i = 0; + while (true) { + System.out.println(i); + table.putNumber("i", i); + i++; + + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/Simple Robot Example/Robot.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/Simple Robot Example/Robot.java new file mode 100644 index 0000000000..045087fe16 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/Simple Robot Example/Robot.java @@ -0,0 +1,17 @@ +package $package; + +/** + * Simplest possible robot program + * + * @author Team $team-number + */ +public class Robot { + + /** + * @param args Input.... + */ + public static void main(String[] args) { + // Do stuff here! + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml new file mode 100644 index 0000000000..fbde882752 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/examples/examples.xml @@ -0,0 +1,47 @@ + + + + Simple Robot + Examples for simple robot programs. + + + Network Tables + Examples of how to use Network Tables to accomplish a + variety of tasks such as sending and receiving values to both + dashboards and co-processors.. + + + + Simple Robot Example + The simplest possible program that compiles. This + shows the structure of a simple program that does nothing at + all. + + Simple Robot + + + src/$package-dir + + + + + + + + Network Table Counter + A simple program that increments a network table + variable once every second. This shows the structure of a simple + program that only uses network tables. + + Simple Robot + Network Tables + + + src/$package-dir + + + + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/iterative/Robot.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/iterative/Robot.java new file mode 100644 index 0000000000..b59c24f886 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/iterative/Robot.java @@ -0,0 +1,43 @@ + +package $package; + +import edu.wpi.first.wpilibj.IterativeRobot; + +/** + * The VM is configured to automatically run this class, and to call the + * functions corresponding to each mode, as described in the IterativeRobot + * documentation. If you change the name of this class or the package after + * creating this project, you must also update the manifest file in the resource + * directory. + */ +public class Robot extends IterativeRobot { + /** + * This function is run when the robot is first started up and should be + * used for any initialization code. + */ + public void robotInit() { + + } + + /** + * This function is called periodically during autonomous + */ + public void autonomousPeriodic() { + + } + + /** + * This function is called periodically during operator control + */ + public void teleopPeriodic() { + + } + + /** + * This function is called periodically during test mode + */ + public void testPeriodic() { + + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/simple/Robot.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/simple/Robot.java new file mode 100644 index 0000000000..efb45cb0d3 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/resources/templates/simple/Robot.java @@ -0,0 +1,35 @@ + +package $package; + + +import edu.wpi.first.wpilibj.SimpleRobot; + +/** + * The VM is configured to automatically run this class, and to call the + * functions corresponding to each mode, as described in the SimpleRobot + * documentation. If you change the name of this class or the package after + * creating this project, you must also update the manifest file in the resource + * directory. + */ +public class Robot extends SimpleRobot { + /** + * This function is called once each time the robot enters autonomous mode. + */ + public void autonomous() { + + } + + /** + * This function is called once each time the robot enters operator control. + */ + public void operatorControl() { + + } + + /** + * This function is called once each time the robot enters test mode. + */ + public void test() { + + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/WPILibJavaPlugin.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/WPILibJavaPlugin.java new file mode 100644 index 0000000000..4b7143a6c6 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/WPILibJavaPlugin.java @@ -0,0 +1,126 @@ +package edu.wpi.first.wpilib.plugins.java; + +import java.io.File; +import java.io.FileInputStream; +import java.util.Properties; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.IWorkspaceRoot; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Path; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.ui.IStartup; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.ant.AntPropertiesParser; +import edu.wpi.first.wpilib.plugins.java.installer.JavaInstaller; + +/** + * The activator class controls the plug-in life cycle + */ +public class WPILibJavaPlugin extends AbstractUIPlugin implements IStartup { + + // The plug-in ID + public static final String PLUGIN_ID = "WPILib_Java_Robot_Development"; //$NON-NLS-1$ + + // The shared instance + private static WPILibJavaPlugin plugin; + + /** + * The constructor + */ + public WPILibJavaPlugin() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static WPILibJavaPlugin getDefault() { + return plugin; + } + + public String getCurrentVersion() { + try { + Properties props = new AntPropertiesParser(WPILibJavaPlugin.class.getResourceAsStream("/resources/configuration.properties")).getProperties(); + if (props.getProperty("version").startsWith("$")) { + return "DEVELOPMENT"; + } else { + return props.getProperty("version"); + } + } catch (CoreException e) { + return "DEVELOPMENT"; + } + } + + public Properties getProjectProperties(IProject project) { + Properties defaults = WPILibCore.getDefault().getProjectProperties(project); + Properties props; + try { + File file = new File(WPILibCore.getDefault().getWPILibBaseDir()+"/java/"+getCurrentVersion()+"/ant/build.properties"); + props = new AntPropertiesParser(new FileInputStream(file)).getProperties(defaults); + } catch (Exception e) { + e.printStackTrace(); + props = new Properties(defaults); + } + return props; + } + + public void updateProjects() { + // Get the root of the workspace + IWorkspace workspace = ResourcesPlugin.getWorkspace(); + IWorkspaceRoot root = workspace.getRoot(); + // Get all projects in the workspace + IProject[] projects = root.getProjects(); + // Loop over all projects + for (IProject project : projects) { + try { + updateVariables(project); + } catch (CoreException e) { + e.printStackTrace(); + } + } + } + + public void updateVariables(IProject project) throws CoreException { + Properties props = WPILibJavaPlugin.getDefault().getProjectProperties(project); + + try { + JavaCore.setClasspathVariable("wpilib", new Path(props.getProperty("wpilib.jar")), null); + JavaCore.setClasspathVariable("wpilib.sources", new Path(props.getProperty("wpilib.sources")), null); + JavaCore.setClasspathVariable("networktables", new Path(props.getProperty("networktables.jar")), null); + JavaCore.setClasspathVariable("networktables.sources", new Path(props.getProperty("networktables.sources")), null); + } catch (JavaModelException e) { + e.printStackTrace(); // Classpath variables didn't get set + } + } + + @Override + public void earlyStartup() { + new JavaInstaller(getCurrentVersion()).installIfNecessary(); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/installer/JavaInstaller.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/installer/JavaInstaller.java new file mode 100644 index 0000000000..f32a23008e --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/installer/JavaInstaller.java @@ -0,0 +1,47 @@ +package edu.wpi.first.wpilib.plugins.java.installer; + +import java.io.InputStream; +import java.util.Properties; + +import org.eclipse.jface.preference.IPreferenceStore; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.installer.AbstractInstaller; +import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin; +import edu.wpi.first.wpilib.plugins.java.preferences.PreferenceConstants; + +/** + * Installs the given version of WPILib into the correct location. Where the + * install directory is usually ~/wpilib/java/version. + * + * @author alex + */ +public class JavaInstaller extends AbstractInstaller { + + public JavaInstaller(String version) { + super(version); + } + + @Override + protected String getFeatureName() { + return "java"; + } + + @Override + protected void updateInstalledVersion(String version) { + IPreferenceStore prefs = WPILibJavaPlugin.getDefault().getPreferenceStore(); + if (prefs.getBoolean(PreferenceConstants.UPDATE_LIBRARY_VERSION)) { + System.out.println("Forcing library version to "+version); + Properties props = WPILibCore.getDefault().getProjectProperties(null); + props.setProperty("version", version); + WPILibCore.getDefault().saveGlobalProperties(props); + prefs.setValue(PreferenceConstants.LIBRARY_VERSION, version); + } + WPILibJavaPlugin.getDefault().updateProjects(); + } + + @Override + protected InputStream getInstallResourceStream() { + return JavaInstaller.class.getResourceAsStream("/resources/java.zip"); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/DeployLaunchShortcut.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/DeployLaunchShortcut.java new file mode 100644 index 0000000000..c0305b8a18 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/launching/DeployLaunchShortcut.java @@ -0,0 +1,207 @@ +package edu.wpi.first.wpilib.plugins.java.launching; + +import java.io.File; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; +import java.util.Vector; + +import org.eclipse.core.internal.resources.Resource; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.debug.core.DebugPlugin; +import org.eclipse.debug.core.ILaunch; +import org.eclipse.debug.core.ILaunchConfigurationType; +import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; +import org.eclipse.debug.core.ILaunchManager; +import org.eclipse.debug.core.IStreamListener; +import org.eclipse.debug.core.model.IStreamMonitor; +import org.eclipse.debug.ui.IDebugUIConstants; +import org.eclipse.debug.ui.ILaunchShortcut; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IJavaProject; +import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants; +import org.eclipse.jdt.launching.IVMConnector; +import org.eclipse.jdt.launching.JavaRuntime; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IEditorPart; +import org.eclipse.ui.IFileEditorInput; +import org.eclipse.ui.PlatformUI; + +import com.sun.jdi.connect.Connector.Argument; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.launching.AntLauncher; + +/** + * Launch shortcut base functionality, common for deploying to the robot. + * Retrieves the project the operation is being called on, and runs the correct + * ant targets based on polymorphically determined data values + * + * @author Ryan O'Meara + * @author Alex Henning + */ +@SuppressWarnings("restriction") +public class DeployLaunchShortcut implements ILaunchShortcut { + //Class constants - used to delineate types for launch shortcuts + public static final String DEPLOY_TYPE = "edu.wpi.first.wpilib.plugins.core.deploy"; + private static final String ANT_SERVER_THREAD_NAME = "Ant Build Server Connection"; + + // NOTE: This string must be changed if the port is changed. + private static final String DEBUG_START_TEXT = "Listening for transport dt_socket at address: 8348"; + + private static ILaunch lastDeploy = null; + + /** + * Returns the launch type of the shortcut that was used, one of the constants + * defined in BaseLaunchShortcut + * @return Launch shortcut type + */ + public String getLaunchType() {return DEPLOY_TYPE;} + + @Override + public void launch(ISelection selection, String mode) { + //Extract resource from selection + StructuredSelection sel = (StructuredSelection)selection; + IProject activeProject = null; + //NOTE: This caused issues earlier, as the sel return was treated as a workspace, instead of a project + //When it is a valid FIRST project, the selection is always a JavaProject + if(sel.getFirstElement() instanceof IJavaProject){ + activeProject = ((IJavaProject)sel.getFirstElement()).getProject(); + }else if(sel.getFirstElement() instanceof IJavaElement){ + activeProject = ((IJavaElement)sel.getFirstElement()).getJavaProject().getProject(); + }else{ + return; + } + + //Run config using project found in extracted resource, with indicated mode + runConfig(activeProject, mode); + } + + @Override + public void launch(IEditorPart editor, String mode) { + //Extract resource from editor + if(editor != null){ + IFileEditorInput input = (IFileEditorInput)editor.getEditorInput(); + IFile file = input.getFile(); + IProject activeProject = file.getProject(); + + //If editor existed, run config using extracted resource in indicated mode + runConfig(activeProject, mode); + }else{ + System.err.println("editor was null"); + } + + } + + /** + * Runs the ant script using the correct target for the indicated mode (deploy to cRIO or just compile) + * @param activeProj The project that the script will be run on/from + * @param mode The mode it will be run in (ILaunchManager.RUN_MODE or ILaunchManager.DEBUG_MODE) + */ + public void runConfig(IProject activeProj, String mode){ + String targets = "deploy"; + + if(mode.equals(ILaunchManager.RUN_MODE)){ + if(getLaunchType().equals(DEPLOY_TYPE)){ + targets = "deploy"; + } + } else if ((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) { + targets = "debug-deploy"; + try{ + PlatformUI.getWorkbench().showPerspective(IDebugUIConstants.ID_DEBUG_PERSPECTIVE, + PlatformUI.getWorkbench().getActiveWorkbenchWindow()); + + }catch(Exception e){} + } + + if((lastDeploy != null)&&(!lastDeploy.isTerminated())){ + System.out.println("Last deploy running"); + //Find the server connection thread and kill it + Vector threadGroups = new Vector(); + ThreadGroup root = Thread.currentThread().getThreadGroup().getParent(); + while (root.getParent() != null) {root = root.getParent();} + threadGroups.add(root); + ThreadGroup threadGroup = threadGroups.remove(0); + int numThreads = threadGroup.activeCount(); + Thread[] threads = new Thread[numThreads*100]; + numThreads = threadGroup.enumerate(threads, true); + + for(Thread current: threads){ + if(current != null){ + if(current.getName().equals(ANT_SERVER_THREAD_NAME)){ + try{ + //Manually end thread and then try terminating launch + Method stopMethod = current.getClass().getMethod("stop"); + stopMethod.invoke(current); + lastDeploy.terminate(); + break; + }catch(Exception e){e.printStackTrace();} + } + } + } + + System.out.println("Waiting"); + try{wait(1000);}catch(Exception e){} + + } + + System.out.println("Running ant file: " + activeProj.getLocation().toOSString() + File.separator + "build.xml"); + System.out.println("Targets: " + targets + ", Mode: " + mode); + lastDeploy = AntLauncher.runAntFile(new File (activeProj.getLocation().toOSString() + File.separator + "build.xml"), targets, null, mode); + + if((mode.equals(ILaunchManager.DEBUG_MODE))&&(getLaunchType().equals(DEPLOY_TYPE))) { + ILaunchConfigurationWorkingCopy config; + try { + config = getRemoteDebugConfig(activeProj); + startDebugConfig(config, lastDeploy); + } catch (CoreException e) { + System.err.println("Debug attach failed."); + e.printStackTrace(); + } + } + + try { + activeProj.refreshLocal(Resource.DEPTH_INFINITE, null); + } catch (Exception e) {} + } + + private ILaunchConfigurationWorkingCopy getRemoteDebugConfig(IProject activeProj) throws CoreException { + ILaunchManager manager = DebugPlugin.getDefault().getLaunchManager(); + ILaunchConfigurationType type = manager.getLaunchConfigurationType(IJavaLaunchConfigurationConstants.ID_REMOTE_JAVA_APPLICATION); + ILaunchConfigurationWorkingCopy config = type.newInstance(null, "Debug "+activeProj.getName()); + config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, activeProj.getName()); + config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_ALLOW_TERMINATE, true); + config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_VM_CONNECTOR, IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); + IVMConnector connector = JavaRuntime.getVMConnector(IJavaLaunchConfigurationConstants.ID_SOCKET_ATTACH_VM_CONNECTOR); + Map def = connector.getDefaultArguments(); + Map argMap = new HashMap(def.size()); + argMap.put("hostname", WPILibCore.getDefault().getTargetIP(activeProj)); + argMap.put("port", "8348"); + System.out.println(argMap); + config.setAttribute(IJavaLaunchConfigurationConstants.ATTR_CONNECT_MAP, argMap); + return config; + } + + private void startDebugConfig(final ILaunchConfigurationWorkingCopy config, ILaunch deploy) throws CoreException { + IStreamListener listener = new IStreamListener() { + @Override + public void streamAppended(String text, IStreamMonitor monitor) { + if (text.contains(DEBUG_START_TEXT)) { + try { + config.launch(ILaunchManager.DEBUG_MODE, null); + } catch (CoreException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + monitor.removeListener(this); + } + } + }; + deploy.getProcesses()[0].getStreamsProxy().getOutputStreamMonitor().addListener(listener); + + } +} + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/preferences/JavaPreferencePage.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/preferences/JavaPreferencePage.java new file mode 100644 index 0000000000..b01574fbf4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/preferences/JavaPreferencePage.java @@ -0,0 +1,96 @@ +package edu.wpi.first.wpilib.plugins.java.preferences; + +import java.io.File; +import java.io.FileFilter; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Properties; + +import org.eclipse.jface.preference.BooleanFieldEditor; +import org.eclipse.jface.preference.FieldEditorPreferencePage; +import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.ui.IWorkbench; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.preferences.ComboFieldEditor; +import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin; + +/** + * This class represents a preference page that + * is contributed to the Preferences dialog. By + * subclassing FieldEditorPreferencePage, we + * can use the field support built into JFace that allows + * us to create a page that is small and knows how to + * save, restore and apply itself. + *

+ * This page is used to modify preferences only. They + * are stored in the preference store that belongs to + * the main plug-in class. That way, preferences can + * be accessed directly via the preference store. + */ + +public class JavaPreferencePage + extends FieldEditorPreferencePage + implements IWorkbenchPreferencePage { + ComboFieldEditor wpiLibVersionEditor; + BooleanFieldEditor autoUpdateEditor; + + public JavaPreferencePage() { + super(GRID); + setPreferenceStore(WPILibJavaPlugin.getDefault().getPreferenceStore()); + setDescription("Change workspace level settings for Java."); + } + + /** + * Creates the field editors. Field editors are abstractions of + * the common GUI blocks needed to manipulate various types + * of preferences. Each field editor knows how to save and + * restore itself. + */ + public void createFieldEditors() { + wpiLibVersionEditor = new ComboFieldEditor(PreferenceConstants.LIBRARY_VERSION, + "&Library Version:", getFieldEditorParent(), getInstalledVersions()); + addField(wpiLibVersionEditor); + autoUpdateEditor = new BooleanFieldEditor(PreferenceConstants.UPDATE_LIBRARY_VERSION, + "&Auto Update Library Version", getFieldEditorParent()); + addField(autoUpdateEditor); + } + + private List getInstalledVersions() { + File[] dirs = new File(WPILibCore.getDefault().getWPILibBaseDir()+File.separator+"java") + .listFiles(new FileFilter() { + @Override public boolean accept(File f) { + return f.isDirectory(); + } + }); + List versions = new ArrayList(); + for (File dir : dirs) { + versions.add(dir.getName()); + } + Collections.sort(versions); + return versions; + } + + /* (non-Javadoc) + * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench) + */ + public void init(IWorkbench workbench) { + System.out.println("Preferences initialized."); + Properties props = WPILibCore.getDefault().getProjectProperties(null); + getPreferenceStore().setValue(PreferenceConstants.LIBRARY_VERSION, + props.getProperty("version", WPILibJavaPlugin.getDefault().getCurrentVersion())); + } + + @Override public void performApply() { + performOk(); + } + + @Override public boolean performOk() { + Properties props = WPILibCore.getDefault().getProjectProperties(null); + props.setProperty("version", wpiLibVersionEditor.getChoice()); + WPILibCore.getDefault().saveGlobalProperties(props); + WPILibJavaPlugin.getDefault().updateProjects(); + return super.performOk(); + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/preferences/PreferenceConstants.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/preferences/PreferenceConstants.java new file mode 100644 index 0000000000..f8ac04c143 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/preferences/PreferenceConstants.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.java.preferences; + +/** + * Constant definitions for plug-in preferences + */ +public class PreferenceConstants { + public static final String LIBRARY_VERSION = "libraryVersionPreference"; + public static final String UPDATE_LIBRARY_VERSION = "udpateLibraryVersionPreference"; +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/preferences/PreferenceInitializer.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/preferences/PreferenceInitializer.java new file mode 100644 index 0000000000..948356d992 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/preferences/PreferenceInitializer.java @@ -0,0 +1,26 @@ +package edu.wpi.first.wpilib.plugins.java.preferences; + +import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; +import org.eclipse.jface.preference.IPreferenceStore; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin; + +/** + * Class used to initialize default preference values. + */ +public class PreferenceInitializer extends AbstractPreferenceInitializer { + + /* + * (non-Javadoc) + * + * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences() + */ + public void initializeDefaultPreferences() { + IPreferenceStore store = WPILibJavaPlugin.getDefault().getPreferenceStore(); + store.setDefault(PreferenceConstants.LIBRARY_VERSION, + WPILibCore.getDefault().getProjectProperties(null) + .getProperty("version", WPILibJavaPlugin.getDefault().getCurrentVersion())); + store.setDefault(PreferenceConstants.UPDATE_LIBRARY_VERSION, true); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/examples/ExampleJavaProject.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/examples/ExampleJavaProject.java new file mode 100644 index 0000000000..0c7298864b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/examples/ExampleJavaProject.java @@ -0,0 +1,54 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.examples; + +import java.util.List; +import java.util.Map; + +import edu.wpi.first.wpilib.plugins.core.wizards.IExampleProject; +import edu.wpi.first.wpilib.plugins.java.wizards.newproject.JavaProjectType; + +public class ExampleJavaProject extends JavaProjectType implements IExampleProject { + private String name, description; + private List tags; + private List packages; + private List files; + + public ExampleJavaProject(String name, String description, List tags, + List packages, List files) { + this.name = name; + this.description = description; + this.tags = tags; + this.packages = packages; + this.files = files; + } + + public String getName() { + return name; + } + + public String getContent() { + return "

"+name+"

"+description+"

"; + } + + public List getTags() { + return tags; + } + + @Override + public String[] getFolders(String packageName) { + String packageDir = packageName.replace(".", "/"); + for (int i = 0; i < packages.size(); i++) { + packages.set(i, packages.get(i).replaceAll("\\$package-dir", packageDir)); + } + return packages.toArray(new String[0]); + } + + @Override + public Map getFiles(String packageName) { + String packageDir = packageName.replace(".", "/"); + Map files = super.getFiles(packageName); + for (ExportFile file : this.files) { + files.put(file.destination.replaceAll("\\$package-dir", packageDir), file.source); + } + return files; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/examples/ExampleJavaWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/examples/ExampleJavaWizard.java new file mode 100644 index 0000000000..9f59ae3eaf --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/examples/ExampleJavaWizard.java @@ -0,0 +1,65 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.examples; + +import java.net.URL; +import java.util.List; +import java.util.Properties; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jface.wizard.IWizardPage; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.wizards.ExampleWizard; +import edu.wpi.first.wpilib.plugins.core.wizards.IExampleProject; +import edu.wpi.first.wpilib.plugins.core.wizards.IExampleProject.ExportFile; +import edu.wpi.first.wpilib.plugins.core.wizards.NewProjectMainPage; +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectCreationUtils; +import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin; +import edu.wpi.first.wpilib.plugins.java.wizards.newproject.WPIRobotJavaProjectCreator; + +public class ExampleJavaWizard extends ExampleWizard { + private NewProjectMainPage detailsPage; + + /** + * Constructor for SampleNewWizard. + */ + public ExampleJavaWizard() { + super(); + setNeedsProgressMonitor(true); + } + + @Override + protected void doFinish(IExampleProject ex, String teamNumber) throws CoreException { + Properties props = WPILibCore.getDefault().getProjectProperties(null); + props.setProperty("team-number", teamNumber); + WPILibCore.getDefault().saveGlobalProperties(props); + + final String projectName = detailsPage.getProjectName(); + final String packageName = detailsPage.getPackage(); + ProjectCreationUtils.createProject(new WPIRobotJavaProjectCreator(projectName, packageName, ex)); + } + + @Override + protected IWizardPage getDetailsPage() { + if (detailsPage != null) return detailsPage; + detailsPage = new NewProjectMainPage(selection, getTeamNumberPage()); + detailsPage.setTitle("Create Example Robot Java Project"); + detailsPage.setDescription("This wizard creates a new example project based on your selection."); + return detailsPage; + } + + @Override + public IExampleProject makeExampleProject(String name, String description, + List tags, List folders, List files) { + return new ExampleJavaProject(name, description, tags, folders, files); + } + + @Override + public URL getResourceURL() { + return WPILibJavaPlugin.getDefault().getBundle().getEntry("/resources/templates/examples"); + } + + @Override + public String getXMLFile() { + return "examples.xml"; + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/CommandGroupWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/CommandGroupWizard.java new file mode 100644 index 0000000000..b2a22fa196 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/CommandGroupWizard.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.file_template; + +public class CommandGroupWizard extends FileTemplateWizard { + + public CommandGroupWizard() { + super("CommandGroup", "command-based/CommandGroup.java", "commands"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/CommandWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/CommandWizard.java new file mode 100644 index 0000000000..fe277fe1d5 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/CommandWizard.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.file_template; + +public class CommandWizard extends FileTemplateWizard { + + public CommandWizard() { + super("Command", "command-based/Command.java", "commands"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/FileTemplateWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/FileTemplateWizard.java new file mode 100644 index 0000000000..72ddc74ca8 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/FileTemplateWizard.java @@ -0,0 +1,127 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.file_template; + +import java.lang.reflect.InvocationTargetException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jdt.core.ICompilationUnit; +import org.eclipse.jdt.core.IPackageFragment; +import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWizard; + +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectCreationUtils; +import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin; + +public class FileTemplateWizard extends Wizard implements INewWizard { + private String type, source, ending; + private FileTemplateWizardMainPage page; + private ISelection selection; + private IProject project; + + /** + * Constructor for SampleNewWizard. + */ + public FileTemplateWizard(String type, String source, String ending) { + super(); + setNeedsProgressMonitor(true); + this.type = type; + this.source = source; + this.ending = ending; + } + + /** + * Adding the page to the wizard. + */ + + public void addPages() { + page = new FileTemplateWizardMainPage(type, project, ending, selection); + addPage(page); + } + + /** + * This method is called when 'Finish' button is pressed in + * the wizard. We will create an operation and run it + * using wizard as execution context. + */ + public boolean performFinish() { + final IProject project = page.getProject(); + final String className = page.getClassName(); + final String packageName = page.getPackage(); + System.out.println("Class: "+className+" Package: "+packageName); + IRunnableWithProgress op = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException { + try { + doFinish(project, className, packageName, monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }; + try { + getContainer().run(true, false, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + Throwable realException = e.getTargetException(); + MessageDialog.openError(getShell(), "Error", realException.getMessage()); + return false; + } + return true; + } + + /** + * The worker method. It will find the container, create the + * file if missing or just replace its contents, and open + * the editor on the newly created file. + */ + private void doFinish(IProject project, String className, String packageName, IProgressMonitor monitor) throws CoreException { + Map map = new HashMap(); + map.put("$classname", className); + map.put("$package", packageName); + String filepath = "src/"+packageName.replace(".", "/")+"/"+className+".java"; + try { + URL url = new URL(WPILibJavaPlugin.getDefault().getBundle().getEntry("/resources/templates/"), source); + ProjectCreationUtils.createTemplateFile(project, filepath, url, map); + } catch (MalformedURLException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + /** + * We will accept the selection in the workbench to see if + * we can initialize from it. + * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.selection = selection; + System.out.println(selection); + Object element = ((StructuredSelection) selection).getFirstElement(); + if (element != null) System.out.println(element.getClass()); + if (element instanceof IResource) { + project = ((IResource) element).getProject(); + } else if (element instanceof IPackageFragment) { + project = ((IPackageFragment) element).getJavaProject().getProject(); + } else if (element instanceof IPackageFragmentRoot) { + project = ((IPackageFragmentRoot) element).getJavaProject().getProject(); + } else if (element instanceof ICompilationUnit) { + project = ((ICompilationUnit) element).getJavaProject().getProject(); + } else System.out.println("Element not instance of IResource"); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/FileTemplateWizardMainPage.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/FileTemplateWizardMainPage.java new file mode 100644 index 0000000000..4bb63be5c1 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/FileTemplateWizardMainPage.java @@ -0,0 +1,203 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.file_template; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.IJavaElement; +import org.eclipse.jdt.core.IPackageFragmentRoot; +import org.eclipse.jdt.core.JavaCore; +import org.eclipse.jdt.core.JavaModelException; +import org.eclipse.jface.dialogs.IDialogPage; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Text; + +import edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature; +import edu.wpi.first.wpilib.plugins.core.wizards.IProjectFilter; +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectComboField; + +/** + * The "New" wizard page allows setting the container for the new file as well + * as the file name. The page will only accept file name without the extension + * OR with the extension that matches the expected one (mpe). + */ + +public class FileTemplateWizardMainPage extends WizardPage { + private IProject project; + private String ending; + private ProjectComboField projectsCombo; + private Text classNameText; + private Text packageText; + + /** + * Constructor for SampleNewWizardPage. + * + * @param pageName + */ + public FileTemplateWizardMainPage(String type, IProject project, String ending, ISelection selection) { + super("wizardPage"); + setTitle("Create New "+type); + setDescription("This wizard creates a new "+type.toLowerCase()+" from a template."); + this.project = project; + this.ending = ending; + } + + /** + * @see IDialogPage#createControl(Composite) + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 2; + layout.verticalSpacing = 9; + + Label label = new Label(container, SWT.NULL); + label.setText("Pro&ject:"); + + projectsCombo = new ProjectComboField(container, SWT.BORDER | SWT.SINGLE, + new IProjectFilter() { + @Override public boolean accept(IProject project) { + try { + return project.hasNature(FRCProjectNature.FRC_PROJECT_NATURE) + && project.hasNature(JavaCore.NATURE_ID); + } catch (CoreException e) { + e.printStackTrace(); + return false; + } + } + }); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + projectsCombo.setLayoutData(gd); + projectsCombo.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + + label = new Label(container, SWT.NULL); + label.setText("Class &Name:"); + + classNameText = new Text(container, SWT.BORDER | SWT.SINGLE); + gd = new GridData(GridData.FILL_HORIZONTAL); + classNameText.setLayoutData(gd); + classNameText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + + label = new Label(container, SWT.NULL); + label.setText("&Package:"); + + packageText = new Text(container, SWT.BORDER | SWT.SINGLE); + gd = new GridData(GridData.FILL_HORIZONTAL); + packageText.setLayoutData(gd); + packageText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + + initialize(); + dialogChanged(); + setControl(container); + } + + /** + * Tests if the current workbench selection is a suitable container to use. + */ + + private void initialize() { + projectsCombo.setProject(project); + packageText.setText(getDefaultPackage()); + } + + /** + * Ensures that both text fields are set. + */ + + private void dialogChanged() { + String className = getClassName(); + String packageString = getPackage(); + + // Update the default package if necessary + if (project == null || !project.equals(projectsCombo.getProject())) { + String oldDefault = getDefaultPackage(); + project = projectsCombo.getProject(); + if (packageString.equals(oldDefault)) { + packageText.setText(getDefaultPackage()); + } + } + + if (!projectsCombo.isValid()) { + updateStatus("Must select a project."); + return; + } + if (className.length() == 0) { + updateStatus("Class name must be specified"); + return; + } + if (!className.matches("^([a-zA-Z_]{1}[a-zA-Z0-9_]*)$")) { + updateStatus("Must be a valid java class name"); + return; + } + if (packageString.length() == 0) { + updateStatus("Package must be specified"); + return; + } + if (!packageString.matches("^([a-zA-Z_]{1}[a-zA-Z0-9_]*(\\.[a-zA-Z_]{1}[a-zA-Z0-9_]*)*)$")) { + updateStatus("Must be valid java package"); + return; + } + updateStatus(null); + } + + private void updateStatus(String message) { + setErrorMessage(message); + setPageComplete(message == null); + } + + public IProject getProject() { + return projectsCombo.getProject(); + } + + public String getClassName() { + return classNameText.getText(); + } + + public String getPackage() { + return packageText.getText(); + } + + public String getDefaultPackage() { + System.out.println("Project: "+project); + String defaultPackage = null; + if (project != null) { + try { + IPackageFragmentRoot root = JavaCore.create(project) + .getPackageFragmentRoot(project.getFolder("src")); + String backupPackage = ""; + for (IJavaElement child : root.getChildren()) { + if (child.getElementType()==IJavaElement.PACKAGE_FRAGMENT + && child.getElementName().endsWith("."+ending)) { + defaultPackage = child.getElementName(); + } + backupPackage = child.getElementName(); + } + if (defaultPackage == null) defaultPackage = backupPackage; + } catch (JavaModelException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + if (defaultPackage != null) return defaultPackage; + else return ""; + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/PIDSubsystemWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/PIDSubsystemWizard.java new file mode 100644 index 0000000000..d61cc1ad25 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/PIDSubsystemWizard.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.file_template; + +public class PIDSubsystemWizard extends FileTemplateWizard { + + public PIDSubsystemWizard() { + super("PIDSubsystem", "command-based/PIDSubsystem.java", "subsystems"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/SubsystemWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/SubsystemWizard.java new file mode 100644 index 0000000000..35c20b4da2 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/SubsystemWizard.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.file_template; + +public class SubsystemWizard extends FileTemplateWizard { + + public SubsystemWizard() { + super("Subsystem", "command-based/Subsystem.java", "subsystems"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/TriggerWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/TriggerWizard.java new file mode 100644 index 0000000000..c2f3ac3b14 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/file_template/TriggerWizard.java @@ -0,0 +1,9 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.file_template; + +public class TriggerWizard extends FileTemplateWizard { + + public TriggerWizard() { + super("Trigger", "command-based/Trigger.java", "triggers"); + } + +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/JavaProjectType.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/JavaProjectType.java new file mode 100644 index 0000000000..3765c69302 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/JavaProjectType.java @@ -0,0 +1,67 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.newproject; + +import java.net.URL; +import java.util.HashMap; +import java.util.Map; + +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectType; +import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin; + +public class JavaProjectType implements ProjectType { + static ProjectType SIMPLE = new JavaProjectType() { + @Override public Map getFiles(String packageName) { + Map files = super.getFiles(packageName); + files.put("src/"+packageName.replace(".", "/")+"/Robot.java", "simple/Robot.java"); + return files; + } + }; + static ProjectType ITERATIVE = new JavaProjectType() { + @Override public Map getFiles(String packageName) { + Map files = super.getFiles(packageName); + files.put("src/"+packageName.replace(".", "/")+"/Robot.java", "iterative/Robot.java"); + return files; + } + }; + static ProjectType COMMAND_BASED = new JavaProjectType() { + @Override public String[] getFolders(String packageName) { + String[] paths = {"src/"+packageName.replace(".", "/"), + "src/"+packageName.replace(".", "/")+"/commands", + "src/"+packageName.replace(".", "/")+"/subsystems", + "src/"+packageName.replace(".", "/")+"/triggers"}; + return paths; + } + @Override public Map getFiles(String packageName) { + Map files = super.getFiles(packageName); + files.put("src/"+packageName.replace(".", "/")+"/Robot.java", "command-based/Robot.java"); + files.put("src/"+packageName.replace(".", "/")+"/commands/ExampleCommand.java", "command-based/ExampleCommand.java"); + files.put("src/"+packageName.replace(".", "/")+"/subsystems/ExampleSubsystem.java", "command-based/ExampleSubsystem.java"); + return files; + } + }; + @SuppressWarnings("serial") + static Map TYPES = new HashMap() {{ + put(ProjectType.SIMPLE, SIMPLE); + put(ProjectType.ITERATIVE, ITERATIVE); + put(ProjectType.COMMAND_BASED, COMMAND_BASED); + }}; + + @Override + public String[] getFolders(String packageName) { + String[] paths = {"src/"+packageName.replace(".", "/")}; + return paths; + } + + @Override + public Map getFiles(String packageName) { + HashMap files = new HashMap(); + files.put("build.xml", "build.xml"); + files.put("build.properties", "build.properties"); + files.put(".classpath", ".classpath"); + return files; + } + + @Override + public URL getBaseURL() { + return WPILibJavaPlugin.getDefault().getBundle().getEntry("/resources/templates/"); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/NewJavaWizard.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/NewJavaWizard.java new file mode 100644 index 0000000000..58ab10265b --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/NewJavaWizard.java @@ -0,0 +1,120 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.newproject; + +import java.lang.reflect.InvocationTargetException; +import java.util.Properties; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchWizard; + +import edu.wpi.first.wpilib.plugins.core.WPILibCore; +import edu.wpi.first.wpilib.plugins.core.wizards.NewProjectMainPage; +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectCreationUtils; +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectType; +import edu.wpi.first.wpilib.plugins.core.wizards.TeamNumberPage; + +/** + * + * Example Docs: + * This is a sample new wizard. Its role is to create a new file + * resource in the provided container. If the container resource + * (a folder or a project) is selected in the workspace + * when the wizard is opened, it will accept it as the target + * container. The wizard creates one file with the extension + * "mpe". If a sample multi-page editor (also available + * as a template) is registered for the same extension, it will + * be able to open it. + */ + +public class NewJavaWizard extends Wizard implements INewWizard { + private TeamNumberPage teamNumberPage; + private NewProjectMainPage page; + private ISelection selection; + + /** + * Constructor for SampleNewWizard. + */ + public NewJavaWizard() { + super(); + setNeedsProgressMonitor(true); + } + + /** + * Adding the page to the wizard. + */ + + public void addPages() { + if (TeamNumberPage.needsTeamNumberPage()) { + teamNumberPage = new TeamNumberPage(selection); + addPage(teamNumberPage); + } + page = new NewProjectMainPage(selection, teamNumberPage); + page.setProjectTypes(JavaProjectType.TYPES); + page.setTitle("Create New Robot Java Project"); + page.setDescription("This wizard creates a new Robot Java Project configured to use WPILib for programming FRC robots."); + addPage(page); + } + + /** + * This method is called when 'Finish' button is pressed in + * the wizard. We will create an operation and run it + * using wizard as execution context. + */ + public boolean performFinish() { + final String projectName = page.getProjectName(); + final String teamNumber = TeamNumberPage.getTeamNumberFromPage(teamNumberPage); + final String packageName = page.getPackage(); + final ProjectType projectType = page.getProjectType(); + System.out.println("Project: "+projectName+" Package: "+packageName+" Project Type: "+projectType); + IRunnableWithProgress op = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException { + try { + doFinish(projectName, teamNumber, packageName, projectType, monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }; + try { + getContainer().run(true, false, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + Throwable realException = e.getTargetException(); + MessageDialog.openError(getShell(), "Error", realException.getMessage()); + return false; + } + return true; + } + + /** + * The worker method. It will find the container, create the + * file if missing or just replace its contents, and open + * the editor on the newly created file. + */ + + private void doFinish(String projectName, String teamNumber, String packageName, ProjectType projectType, IProgressMonitor monitor) throws CoreException { + Properties props = WPILibCore.getDefault().getProjectProperties(null); + props.setProperty("team-number", teamNumber); + WPILibCore.getDefault().saveGlobalProperties(props); + ProjectCreationUtils.createProject(new WPIRobotJavaProjectCreator(projectName, packageName, projectType)); + } + + /** + * We will accept the selection in the workbench to see if + * we can initialize from it. + * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.selection = selection; + } +} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/WPIRobotJavaProjectCreator.java b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/WPIRobotJavaProjectCreator.java new file mode 100644 index 0000000000..4a47f9fb98 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/java/edu/wpi/first/wpilib/plugins/java/wizards/newproject/WPIRobotJavaProjectCreator.java @@ -0,0 +1,67 @@ +package edu.wpi.first.wpilib.plugins.java.wizards.newproject; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.jdt.core.JavaCore; + +import edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature; +import edu.wpi.first.wpilib.plugins.core.wizards.IProjectCreator; +import edu.wpi.first.wpilib.plugins.core.wizards.ProjectType; +import edu.wpi.first.wpilib.plugins.java.WPILibJavaPlugin; + +public class WPIRobotJavaProjectCreator implements IProjectCreator { + String projectName, packageName; + ProjectType projectType; + + public WPIRobotJavaProjectCreator(String projectName, String packageName, ProjectType projectType) { + this.projectName = projectName; + this.packageName = packageName; + this.projectType = projectType; + } + + @Override + public String getName() { + return projectName; + } + + @Override + public String getPackageName() { + return packageName; + } + + @Override + public Map getValues() { + Map vals = new HashMap(); + vals.put("$project", projectName); + vals.put("$package", packageName); + return vals; + } + + @Override + public List getNatures() { + List natures = new ArrayList<>(); + natures.add(JavaCore.NATURE_ID); + natures.add(FRCProjectNature.FRC_PROJECT_NATURE); + return natures; + } + + @Override + public ProjectType getProjectType() { + return projectType; + } + + @Override + public void initialize(IProject project) { + JavaCore.create(project); + } + + @Override + public void finalize(IProject project) throws CoreException { + WPILibJavaPlugin.getDefault().updateVariables(project); + } +} diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/ant-classloadertask.jar b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/ant-classloadertask.jar new file mode 100644 index 0000000000..d2f58d9f1d Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/ant-classloadertask.jar differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/ant-contrib.jar b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/ant-contrib.jar new file mode 100644 index 0000000000..ea817cd434 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/ant-contrib.jar differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties new file mode 100644 index 0000000000..9d39d2a1fd --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.properties @@ -0,0 +1,30 @@ +# Deployment information +username=admin +password= +deploy.dir=/home/admin +deploy.run.command=./runjavaprogram +deploy.debug.command=./debugjavaprogram + +# Libraries to use +wpilib=${user.home}/wpilib/java/${version} +wpilib.lib=${wpilib}/lib +wpilib.jar=${wpilib.lib}/WPILib.jar +wpilib.sources=${wpilib.lib}/WPILib-sources.jar +networktables.jar=${wpilib.lib}/NetworkTables.jar +networktables.sources=${wpilib.lib}/NetworkTables-sources.jar +jna.jar=${wpilib.lib}/jna-4.0.0.jar +jnaerator.jar=${wpilib.lib}/jnaerator-runtime.jar +classpath=${wpilib.jar}:${networktables.jar}:${jna.jar}:${jnaerator.jar} + +# Ant support +wpilib.ant.dir=${wpilib}/ant +jsch.jar=${wpilib.ant.dir}/jsch-0.1.50.jar +classloadertask.jar=${wpilib.ant.dir}/ant-classloadertask.jar + +# Build information +jar=FRCUserProgram.jar +src.dir=src +build.dir=build +build.jars=${build.dir}/jars +dist.dir=dist +dist.jar=${dist.dir}/${jar} \ No newline at end of file diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml new file mode 100644 index 0000000000..3579f8352d --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/build.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + + + + + + + + Target IP: ${target} + + + + + [athena-compile] Compiling ${src.dir} with classpath=${classpath} to ${build.dir} + + + + + + + [athena-jar] Making jar ${dist.jar}. + + + + [athena-jar] Copying jars from ${classpath} to ${build.jars}. + + + + + + + + + + + + + + + + + + + + + + + [athena-deploy] Copying code over. + + [athena-deploy] Starting program. + + + + + [athena-debug-deploy] Copying code over. + + [athena-debug-deploy] Starting program. + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/jsch-0.1.50.jar b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/jsch-0.1.50.jar new file mode 100644 index 0000000000..85c044f216 Binary files /dev/null and b/eclipse-plugins/edu.wpi.first.wpilib.plugins.java/src/main/resources/java-zip/ant/jsch-0.1.50.jar differ diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/.project b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/.project new file mode 100644 index 0000000000..0bbfd83d3f --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/.project @@ -0,0 +1,17 @@ + + + edu.wpi.first.wpilib.plugins.updatesite + + + + + + org.eclipse.pde.UpdateSiteBuilder + + + + + + org.eclipse.pde.UpdateSiteNature + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/index.html b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/index.html new file mode 100644 index 0000000000..3763331b5e --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/index.html @@ -0,0 +1,60 @@ + + +WPILib Update Site + + + + + + +
+ + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/pom.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/pom.xml new file mode 100644 index 0000000000..612dd10319 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/pom.xml @@ -0,0 +1,14 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins.updatesite + eclipse-update-site + + + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + .. + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/site.xml b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/site.xml new file mode 100644 index 0000000000..84fffa1893 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/site.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + Core WPILib Robot Development Tools. + + + + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/web/site.css b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/web/site.css new file mode 100644 index 0000000000..62c6f9ffa4 --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/web/site.css @@ -0,0 +1,12 @@ + diff --git a/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/web/site.xsl b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/web/site.xsl new file mode 100644 index 0000000000..c25380716c --- /dev/null +++ b/eclipse-plugins/edu.wpi.first.wpilib.plugins.updatesite/web/site.xsl @@ -0,0 +1,214 @@ + + + + + + + + WPILib Update Site + + + +

WPILib Update Site

+

+ + + + + + + + + + + + + + + + dark-row + + + light-row + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + dark-row + + + light-row + + + + + + + + + + + + + + + dark-row + + + light-row + + + + + + + + +
+ + + +
+ + + +
+
+ ( - ) +
+
+ + - + +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
Operating Systems:
Windows Systems:
Languages:
Architecture:
+


+ Uncategorized +
+ + + +
+
+ ( - ) +
+
+ + - + +
+

+
+ + + + + + + + + + + + + + + + + + + + + +
Operating Systems:
Windows Systems:
Languages:
Architecture:
+
+ + + +
+
+ ( - ) +
+
+ + - + +
+

+
+ + + + + + + + + + + + + + + + + + + + + +
Operating Systems:
Windows Systems:
Languages:
Architecture:
+
+ + +
+
+
diff --git a/eclipse-plugins/pom.xml b/eclipse-plugins/pom.xml new file mode 100644 index 0000000000..f8cd527202 --- /dev/null +++ b/eclipse-plugins/pom.xml @@ -0,0 +1,93 @@ + + + 4.0.0 + edu.wpi.first.wpilib.plugins + edu.wpi.first.wpilib.plugins + 0.1.0.qualifier + pom + + + edu.wpi.first.wpilib.plugins.core + edu.wpi.first.wpilib.plugins.core.feature + edu.wpi.first.wpilib.plugins.cpp + edu.wpi.first.wpilib.plugins.cpp.feature + edu.wpi.first.wpilib.plugins.cpp.toolchains.linux + edu.wpi.first.wpilib.plugins.cpp.toolchains.linux.feature + edu.wpi.first.wpilib.plugins.cpp.toolchains.mac + edu.wpi.first.wpilib.plugins.cpp.toolchains.mac.feature + edu.wpi.first.wpilib.plugins.cpp.toolchains.windows + edu.wpi.first.wpilib.plugins.cpp.toolchains.windows.feature + edu.wpi.first.wpilib.plugins.java + edu.wpi.first.wpilib.plugins.java.feature + edu.wpi.first.wpilib.plugins.updatesite + + + + C:/Users/wpilibj-buildmaster/maven-repository + 0.18.1 + + + + + juno + p2 + http://download.eclipse.org/releases/juno + + + FRC Binaries + http://first.wpi.edu/FRC/c/maven/ + + + + + + + org.eclipse.tycho + tycho-maven-plugin + ${tycho-version} + true + + + + + + + jenkins + + + myrepository + file:${local-repository} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hal/.cproject b/hal/.cproject new file mode 100644 index 0000000000..3e425fb7ed --- /dev/null +++ b/hal/.cproject @@ -0,0 +1,194 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/hal/.gitignore b/hal/.gitignore new file mode 100644 index 0000000000..94cd9036f4 --- /dev/null +++ b/hal/.gitignore @@ -0,0 +1,10 @@ +*~ +*# +PPC603gnu/ +Debug/ +target/ +tmp/ +GPATH +GRTAGS +GSYMS +GTAGS \ No newline at end of file diff --git a/hal/.project b/hal/.project new file mode 100644 index 0000000000..669fd7d0d4 --- /dev/null +++ b/hal/.project @@ -0,0 +1,34 @@ + + + HAL + + + + + + org.eclipse.cdt.managedbuilder.core.genmakebuilder + clean,full,incremental, + + + + + org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder + full,incremental, + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.cdt.core.cnature + org.eclipse.cdt.core.ccnature + org.eclipse.cdt.managedbuilder.core.managedBuildNature + org.eclipse.cdt.managedbuilder.core.ScannerConfigNature + edu.wpi.first.wpilib.plugins.core.nature.FRCProjectNature + + diff --git a/hal/Athena/pom.xml b/hal/Athena/pom.xml new file mode 100644 index 0000000000..9d63e1e81a --- /dev/null +++ b/hal/Athena/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + edu.wpi.first.wpilib.hal + libHALAthena + a + + + edu.wpi.first.wpilib.templates.athena + static-library + 0.1.0-SNAPSHOT + + + + + WPILib Repository + http://frcbuilder.wpi.edu:8348/ + + + + + + edu.wpi.first.wpilib.hal + include + 0.1.0-SNAPSHOT + inczip + + + + + + + org.codehaus.mojo + native-maven-plugin + + + + src/main/native + + **/*.cpp + + + + + + + + diff --git a/hal/Athena/src/main/native/Analog.cpp b/hal/Athena/src/main/native/Analog.cpp new file mode 100644 index 0000000000..a406ea4a19 --- /dev/null +++ b/hal/Athena/src/main/native/Analog.cpp @@ -0,0 +1,728 @@ + +#include "HAL/Analog.h" + +#include "Port.h" +#include "HAL/Errors.h" +#include "HAL/Semaphore.h" +#include "ChipObject.h" +#include "HAL/cpp/Synchronized.h" +#include "HAL/cpp/Resource.h" +#include "NetworkCommunication/AICalibration.h" +#include "NetworkCommunication/LoadOut.h" + +#include // TODO: remove printf for debugging + +static const long kTimebase = 40000000; ///< 40 MHz clock +static const long kDefaultOversampleBits = 0; +static const long kDefaultAverageBits = 7; +static const float kDefaultSampleRate = 50000.0; +static const uint32_t kAnalogPins = 8; + +static const uint32_t kAccumulatorNumChannels = 2; +static const uint32_t kAccumulatorChannels[] = {1, 2}; + +struct analog_port_t { + Port port; + tAccumulator *accumulator; +}; +typedef struct analog_port_t AnalogPort; + +bool analogSampleRateSet = false; +MUTEX_ID analogRegisterWindowSemaphore = NULL; +tAI* analogSystem = NULL; +uint32_t analogNumChannelsToActivate = 0; + +// Utility methods defined below. +uint32_t getAnalogNumActiveChannels(int32_t *status); +uint32_t getAnalogNumChannelsToActivate(int32_t *status); +void setAnalogNumChannelsToActivate(uint32_t channels); + +bool analogSystemInitialized = false; + +/** + * Initialize the analog System. + */ +void initializeAnalog(int32_t *status) { + if (analogSystemInitialized) return; + analogRegisterWindowSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + analogSystem = tAI::create(status); + setAnalogNumChannelsToActivate(kAnalogPins); + setAnalogSampleRate(kDefaultSampleRate, status); + analogSystemInitialized = true; +} + +/** + * Initialize the analog port using the given port object. + */ +void* initializeAnalogPort(void* port_pointer, int32_t *status) { + initializeAnalog(status); + Port* port = (Port*) port_pointer; + + // Initialize port structure + AnalogPort* analog_port = new AnalogPort(); + analog_port->port = *port; + if (isAccumulatorChannel(analog_port, status)) { + analog_port->accumulator = tAccumulator::create(port->pin - 1, status); + } else analog_port->accumulator = NULL; + + // Set default configuration + analogSystem->writeScanList(port->pin - 1, port->pin - 1, status); + setAnalogAverageBits(analog_port, kDefaultAverageBits, status); + setAnalogOversampleBits(analog_port, kDefaultOversampleBits, status); + return analog_port; +} + + +/** + * Check that the analog module number is valid. + * + * @return Analog module is valid and present + */ +bool checkAnalogModule(uint8_t module) { + return module == 1; +} + +/** + * Check that the analog channel number is value. + * Verify that the analog channel number is one of the legal channel numbers. Channel numbers + * are 1-based. + * + * @return Analog channel is valid + */ +bool checkAnalogChannel(uint32_t pin) { + if (pin > 0 && pin <= kAnalogPins) + return true; + return false; +} + +/** + * Set the sample rate. + * + * This is a global setting for the Athena and effects all channels. + * + * @param samplesPerSecond The number of samples per channel per second. + */ +void setAnalogSampleRate(double samplesPerSecond, int32_t *status) { + // TODO: This will change when variable size scan lists are implemented. + // TODO: Need float comparison with epsilon. + //wpi_assert(!sampleRateSet || GetSampleRate() == samplesPerSecond); + analogSampleRateSet = true; + + // Compute the convert rate + uint32_t ticksPerSample = (uint32_t)((float)kTimebase / samplesPerSecond); + uint32_t ticksPerConversion = ticksPerSample / getAnalogNumChannelsToActivate(status); + // ticksPerConversion must be at least 80 + if (ticksPerConversion < 80) { + if ((*status) >= 0) *status = SAMPLE_RATE_TOO_HIGH; + ticksPerConversion = 80; + } + + // Atomically set the scan size and the convert rate so that the sample rate is constant + tAI::tConfig config; + config.ScanSize = getAnalogNumChannelsToActivate(status); + config.ConvertRate = ticksPerConversion; + analogSystem->writeConfig(config, status); + + // Indicate that the scan size has been commited to hardware. + setAnalogNumChannelsToActivate(0); +} + +/** + * Get the current sample rate. + * + * This assumes one entry in the scan list. + * This is a global setting for the Athena and effects all channels. + * + * @return Sample rate. + */ +float getAnalogSampleRate(int32_t *status) { + uint32_t ticksPerConversion = analogSystem->readLoopTiming(status); + uint32_t ticksPerSample = ticksPerConversion * getAnalogNumActiveChannels(status); + return (float)kTimebase / (float)ticksPerSample; +} + +/** + * Set the sample rate on the module. + * + * This is a global setting for the module and effects all channels. + * + * @param module The module to use + * @param samplesPerSecond The number of samples per channel per second. + */ +void setAnalogSampleRateWithModule(uint8_t module, double samplesPerSecond, int32_t *status) { + if (checkAnalogModule(module)) { + setAnalogSampleRate(samplesPerSecond, status); + } else { + // XXX: Set error status + } +} + +/** + * Get the current sample rate on the module. + * + * This assumes one entry in the scan list. + * This is a global setting for the module and effects all channels. + * + * @param module The module to use + * @return Sample rate. + */ +float getAnalogSampleRateWithModule(uint8_t module, int32_t *status) { + if (checkAnalogModule(module)) { + return getAnalogSampleRate(status); + } else { + return -1; // XXX: Set error status + } +} + + +/** + * Set the number of averaging bits. + * + * This sets the number of averaging bits. The actual number of averaged samples is 2**bits. + * Use averaging to improve the stability of your measurement at the expense of sampling rate. + * The averaging is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to configure. + * @param bits Number of bits to average. + */ +void setAnalogAverageBits(void* analog_port_pointer, uint32_t bits, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + analogSystem->writeAverageBits(port->port.pin - 1, bits, status); +} + +/** + * Get the number of averaging bits. + * + * This gets the number of averaging bits from the FPGA. The actual number of averaged samples is 2**bits. + * The averaging is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Bits to average. + */ +uint32_t getAnalogAverageBits(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + uint32_t result = analogSystem->readAverageBits(port->port.pin - 1, status); + return result; +} + +/** + * Set the number of oversample bits. + * + * This sets the number of oversample bits. The actual number of oversampled values is 2**bits. + * Use oversampling to improve the resolution of your measurements at the expense of sampling rate. + * The oversampling is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @param bits Number of bits to oversample. + */ +void setAnalogOversampleBits(void* analog_port_pointer, uint32_t bits, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + analogSystem->writeOversampleBits(port->port.pin - 1, bits, status); +} + + +/** + * Get the number of oversample bits. + * + * This gets the number of oversample bits from the FPGA. The actual number of oversampled values is + * 2**bits. The oversampling is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Bits to oversample. + */ +uint32_t getAnalogOversampleBits(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + uint32_t result = analogSystem->readOversampleBits(port->port.pin - 1, status); + return result; +} + +/** + * Get a sample straight from the channel on this module. + * + * The sample is a 12-bit value representing the -10V to 10V range of the A/D converter in the module. + * The units are in A/D converter codes. Use GetVoltage() to get the analog value in calibrated units. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A sample straight from the channel on this module. + */ +int16_t getAnalogValue(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + int16_t value; + checkAnalogChannel(port->port.pin); + + tAI::tReadSelect readSelect; + readSelect.Channel = port->port.pin - 1; + readSelect.Averaged = false; + + { + Synchronized sync(analogRegisterWindowSemaphore); + analogSystem->writeReadSelect(readSelect, status); + analogSystem->strobeLatchOutput(status); + value = (int16_t) analogSystem->readOutput(status); + } + + return value; +} + +/** + * Get a sample from the output of the oversample and average engine for the channel. + * + * The sample is 12-bit + the value configured in SetOversampleBits(). + * The value configured in SetAverageBits() will cause this value to be averaged 2**bits number of samples. + * This is not a sliding window. The sample will not change until 2**(OversamplBits + AverageBits) samples + * have been acquired from the module on this channel. + * Use GetAverageVoltage() to get the analog value in calibrated units. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A sample from the oversample and average engine for the channel. + */ +int32_t getAnalogAverageValue(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + int16_t value; + checkAnalogChannel(port->port.pin); + + tAI::tReadSelect readSelect; + readSelect.Channel = port->port.pin - 1; + readSelect.Averaged = true; + + { + Synchronized sync(analogRegisterWindowSemaphore); + analogSystem->writeReadSelect(readSelect, status); + analogSystem->strobeLatchOutput(status); + value = (int16_t) analogSystem->readOutput(status); + } + + return value; +} + +/** + * Get a scaled sample straight from the channel on this module. + * + * The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset(). + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A scaled sample straight from the channel on this module. + */ +float getAnalogVoltage(void* analog_port_pointer, int32_t *status) { + int16_t value = getAnalogValue(analog_port_pointer, status); + uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status); + int32_t offset = getAnalogOffset(analog_port_pointer, status); + float voltage = LSBWeight * 1.0e-9 * value - offset * 1.0e-9; + return voltage; +} + +/** + * Get a scaled sample from the output of the oversample and average engine for the channel. + * + * The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset(). + * Using oversampling will cause this value to be higher resolution, but it will update more slowly. + * Using averaging will cause this value to be more stable, but it will update more slowly. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A scaled sample from the output of the oversample and average engine for the channel. + */ +float getAnalogAverageVoltage(void* analog_port_pointer, int32_t *status) { + int32_t value = getAnalogAverageValue(analog_port_pointer, status); + uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status); + int32_t offset = getAnalogOffset(analog_port_pointer, status); + uint32_t oversampleBits = getAnalogOversampleBits(analog_port_pointer, status); + float voltage = ((LSBWeight * 1.0e-9 * value) / (float)(1 << oversampleBits)) - offset * 1.0e-9; + return voltage; +} + +/** + * Convert a voltage to a raw value for a specified channel. + * + * This process depends on the calibration of each channel, so the channel + * must be specified. + * + * @todo This assumes raw values. Oversampling not supported as is. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @param voltage The voltage to convert. + * @return The raw value for the channel. + */ +int32_t getAnalogVoltsToValue(void* analog_port_pointer, double voltage, int32_t *status) { + if (voltage > 10.0) { + voltage = 10.0; + *status = VOLTAGE_OUT_OF_RANGE; + } + if (voltage < -10.0) { + voltage = -10.0; + *status = VOLTAGE_OUT_OF_RANGE; + } + uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status); + int32_t offset = getAnalogOffset(analog_port_pointer, status); + int32_t value = (int32_t) ((voltage + offset * 1.0e-9) / (LSBWeight * 1.0e-9)); + return value; +} + +/** + * Get the factory scaling least significant bit weight constant. + * The least significant bit weight constant for the channel that was calibrated in + * manufacturing and stored in an eeprom in the module. + * + * Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9) + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Least significant bit weight. + */ +uint32_t getAnalogLSBWeight(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + uint32_t lsbWeight = FRC_NetworkCommunication_nAICalibration_getLSBWeight(0, port->port.pin - 1, status); // XXX: aiSystemIndex == 0? + return lsbWeight; +} + +/** + * Get the factory scaling offset constant. + * The offset constant for the channel that was calibrated in manufacturing and stored + * in an eeprom in the module. + * + * Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9) + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Offset constant. + */ +int32_t getAnalogOffset(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + int32_t offset = FRC_NetworkCommunication_nAICalibration_getOffset(0, port->port.pin - 1, status); // XXX: aiSystemIndex == 0? + return offset; +} + + +/** + * Return the number of channels on the module in use. + * + * @return Active channels. + */ +uint32_t getAnalogNumActiveChannels(int32_t *status) { + uint32_t scanSize = analogSystem->readConfig_ScanSize(status); + if (scanSize == 0) + return 8; + return scanSize; +} + +/** + * Get the number of active channels. + * + * This is an internal function to allow the atomic update of both the + * number of active channels and the sample rate. + * + * When the number of channels changes, use the new value. Otherwise, + * return the curent value. + * + * @return Value to write to the active channels field. + */ +uint32_t getAnalogNumChannelsToActivate(int32_t *status) { + if(analogNumChannelsToActivate == 0) return getAnalogNumActiveChannels(status); + return analogNumChannelsToActivate; +} + +/** + * Set the number of active channels. + * + * Store the number of active channels to set. Don't actually commit to hardware + * until SetSampleRate(). + * + * @param channels Number of active channels. + */ +void setAnalogNumChannelsToActivate(uint32_t channels) { + analogNumChannelsToActivate = channels; +} + +//// Accumulator Stuff + +/** + * Is the channel attached to an accumulator. + * + * @return The analog channel is attached to an accumulator. + */ +bool isAccumulatorChannel(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + for (uint32_t i=0; i < kAccumulatorNumChannels; i++) { + if (port->port.pin == kAccumulatorChannels[i]) return true; + } + return false; +} + +/** + * Initialize the accumulator. + */ +void initAccumulator(void* analog_port_pointer, int32_t *status) { + setAccumulatorCenter(analog_port_pointer, 0, status); + resetAccumulator(analog_port_pointer, status); +} + +/** + * Resets the accumulator to the initial value. + */ +void resetAccumulator(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + port->accumulator->strobeReset(status); +} + +/** + * Set the center value of the accumulator. + * + * The center value is subtracted from each A/D value before it is added to the accumulator. This + * is used for the center value of devices like gyros and accelerometers to make integration work + * and to take the device offset into account when integrating. + * + * This center value is based on the output of the oversampled and averaged source from channel 1. + * Because of this, any non-zero oversample bits will affect the size of the value for this field. + */ +void setAccumulatorCenter(void* analog_port_pointer, int32_t center, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + port->accumulator->writeCenter(center, status); +} + +/** + * Set the accumulator's deadband. + */ +void setAccumulatorDeadband(void* analog_port_pointer, int32_t deadband, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + port->accumulator->writeDeadband(deadband, status); +} + +/** + * Read the accumulated value. + * + * Read the value that has been accumulating on channel 1. + * The accumulator is attached after the oversample and average engine. + * + * @return The 64-bit value accumulated since the last Reset(). + */ +int64_t getAccumulatorValue(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return 0; + } + int64_t value = port->accumulator->readOutput_Value(status); + return value; +} + +/** + * Read the number of accumulated values. + * + * Read the count of the accumulated values since the accumulator was last Reset(). + * + * @return The number of times samples from the channel were accumulated. + */ +uint32_t getAccumulatorCount(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return 0; + } + return port->accumulator->readOutput_Count(status); +} + +/** + * Read the accumulated value and the number of accumulated values atomically. + * + * This function reads the value and count from the FPGA atomically. + * This can be used for averaging. + * + * @param value Pointer to the 64-bit accumulated output. + * @param count Pointer to the number of accumulation cycles. + */ +void getAccumulatorOutput(void* analog_port_pointer, int64_t *value, uint32_t *count, int32_t *status) { + printf("[HAL] getAccumulatorOutput()\n"); + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + if (value == NULL || count == NULL) { + *status = NULL_PARAMETER; + return; + } + + printf("[HAL]\t Getting output...\n"); + tAccumulator::tOutput output = port->accumulator->readOutput(status); + + printf("[HAL]\t Status: %d, Value: %lld, Count: %d.\n", *status, output.Value, output.Count); + printf("[HAL]\t value: %d, value2: %d, value3: %d.\n", output.value, output.value2, output.value3); + printf("[HAL]\t Value: %lld, Count: %d.\n", port->accumulator->readOutput_Value(status), port->accumulator->readOutput_Count(status)); + *value = output.Value; + *count = output.Count; +} + + +struct trigger_t { + tAnalogTrigger* trigger; + AnalogPort* port; + uint32_t index; +}; +typedef struct trigger_t AnalogTrigger; + +static Resource *triggers = NULL; + +void* initializeAnalogTrigger(void* port_pointer, uint32_t *index, int32_t *status) { + Port* port = (Port*) port_pointer; + Resource::CreateResourceObject(&triggers, tAnalogTrigger::kNumSystems); + + AnalogTrigger* trigger = new AnalogTrigger(); + trigger->port = (AnalogPort*) initializeAnalogPort(port, status); + trigger->index = triggers->Allocate("Analog Trigger"); + *index = trigger->index; + // TODO: if (index == ~0ul) { CloneError(triggers); return; } + + trigger->trigger = tAnalogTrigger::create(trigger->index, status); + trigger->trigger->writeSourceSelect_Channel(port->pin - 1, status); + + return trigger; +} + +void cleanAnalogTrigger(void* analog_trigger_pointer, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + triggers->Free(trigger->index); + delete trigger->trigger; + delete trigger; +} + +void setAnalogTriggerLimitsRaw(void* analog_trigger_pointer, int32_t lower, int32_t upper, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (lower > upper) { + *status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR; + } + trigger->trigger->writeLowerLimit(lower, status); + trigger->trigger->writeUpperLimit(upper, status); +} + +/** + * Set the upper and lower limits of the analog trigger. + * The limits are given as floating point voltage values. + */ +void setAnalogTriggerLimitsVoltage(void* analog_trigger_pointer, double lower, double upper, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (lower > upper) { + *status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR; + } + // TODO: This depends on the averaged setting. Only raw values will work as is. + trigger->trigger->writeLowerLimit(getAnalogVoltsToValue(trigger->port, lower, status), status); + trigger->trigger->writeUpperLimit(getAnalogVoltsToValue(trigger->port, upper, status), status); +} + +/** + * Configure the analog trigger to use the averaged vs. raw values. + * If the value is true, then the averaged value is selected for the analog trigger, otherwise + * the immediate value is used. + */ +void setAnalogTriggerAveraged(void* analog_trigger_pointer, bool useAveragedValue, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (trigger->trigger->readSourceSelect_Filter(status) != 0) { + *status = INCOMPATIBLE_STATE; + // TODO: wpi_setWPIErrorWithContext(IncompatibleMode, "Hardware does not support average and filtering at the same time."); + } + trigger->trigger->writeSourceSelect_Averaged(useAveragedValue, status); +} + +/** + * Configure the analog trigger to use a filtered value. + * The analog trigger will operate with a 3 point average rejection filter. This is designed to + * help with 360 degree pot applications for the period where the pot crosses through zero. + */ +void setAnalogTriggerFiltered(void* analog_trigger_pointer, bool useFilteredValue, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (trigger->trigger->readSourceSelect_Averaged(status) != 0) { + *status = INCOMPATIBLE_STATE; + // TODO: wpi_setWPIErrorWithContext(IncompatibleMode, "Hardware does not support average and filtering at the same time."); + } + trigger->trigger->writeSourceSelect_Filter(useFilteredValue, status); +} + +/** + * Return the InWindow output of the analog trigger. + * True if the analog input is between the upper and lower limits. + * @return The InWindow output of the analog trigger. + */ +bool getAnalogTriggerInWindow(void* analog_trigger_pointer, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + return trigger->trigger->readOutput_InHysteresis(trigger->index, status) != 0; +} + +/** + * Return the TriggerState output of the analog trigger. + * True if above upper limit. + * False if below lower limit. + * If in Hysteresis, maintain previous state. + * @return The TriggerState output of the analog trigger. + */ +bool getAnalogTriggerTriggerState(void* analog_trigger_pointer, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + return trigger->trigger->readOutput_OverLimit(trigger->index, status) != 0; +} + +/** + * Get the state of the analog trigger output. + * @return The state of the analog trigger output. + */ +bool getAnalogTriggerOutput(void* analog_trigger_pointer, AnalogTriggerType type, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + bool result = false; + switch(type) { + case kInWindow: + result = trigger->trigger->readOutput_InHysteresis(trigger->index, status); + break; // XXX: Backport + case kState: + result = trigger->trigger->readOutput_OverLimit(trigger->index, status); + break; // XXX: Backport + case kRisingPulse: + case kFallingPulse: + *status = ANALOG_TRIGGER_PULSE_OUTPUT_ERROR; + return false; + } + return result; +} + + + +//// Float JNA Hack +// Float +int getAnalogSampleRateIntHack(int32_t *status) { + return floatToInt(getAnalogSampleRate(status)); +} + +int getAnalogSampleRateWithModuleIntHack(uint8_t module, int32_t *status) { + return floatToInt(getAnalogSampleRateWithModuleIntHack(module, status)); +} + +int getAnalogVoltageIntHack(void* analog_port_pointer, int32_t *status) { + return floatToInt(getAnalogVoltage(analog_port_pointer, status)); +} + +int getAnalogAverageVoltageIntHack(void* analog_port_pointer, int32_t *status) { + return floatToInt(getAnalogAverageVoltage(analog_port_pointer, status)); +} + + +// Doubles +void setAnalogSampleRateIntHack(int samplesPerSecond, int32_t *status) { + setAnalogSampleRate(intToFloat(samplesPerSecond), status); +} + +void setAnalogSampleRateWithModuleIntHack(uint8_t module, int samplesPerSecond, int32_t *status) { + setAnalogSampleRateWithModule(module, intToFloat(samplesPerSecond), status); +} + +int32_t getAnalogVoltsToValueIntHack(void* analog_port_pointer, int voltage, int32_t *status) { + return getAnalogVoltsToValue(analog_port_pointer, intToFloat(voltage), status); +} + +void setAnalogTriggerLimitsVoltageIntHack(void* analog_trigger_pointer, int lower, int upper, int32_t *status) { + setAnalogTriggerLimitsVoltage(analog_trigger_pointer, intToFloat(lower), intToFloat(upper), status); +} diff --git a/hal/Athena/src/main/native/ChipObject.h b/hal/Athena/src/main/native/ChipObject.h new file mode 100644 index 0000000000..057dbfc48d --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject.h @@ -0,0 +1,36 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#ifndef __ChipObject_h__ +#define __ChipObject_h__ + +#include +#include "ChipObject/NiRio.h" +#include "ChipObject/RoboRIO_FRC_ChipObject_Aliases.h" +#include "ChipObject/FRC_FPGA_ChipObject_Aliases.h" + +#include "ChipObject/tAccel.h" +#include "ChipObject/tAccumulator.h" +#include "ChipObject/tAI.h" +#include "ChipObject/tAlarm.h" +#include "ChipObject/tAnalogTrigger.h" +#include "ChipObject/tAO.h" +#include "ChipObject/tBIST.h" +#include "ChipObject/tCounter.h" +#include "ChipObject/tDIO.h" +#include "ChipObject/tDMA.h" +#include "ChipObject/tEncoder.h" +#include "ChipObject/tGlobal.h" +#include "ChipObject/tInterrupt.h" +#include "ChipObject/tInterruptManager.h" +#include "ChipObject/tPower.h" +#include "ChipObject/tPWM.h" +#include "ChipObject/tRelay.h" +#include "ChipObject/tWatchdog.h" + +using namespace nFPGA; +using namespace nRoboRIO_FPGANamespace; +#endif diff --git a/hal/Athena/src/main/native/ChipObject/FRC_FPGA_ChipObject_Aliases.h b/hal/Athena/src/main/native/ChipObject/FRC_FPGA_ChipObject_Aliases.h new file mode 100644 index 0000000000..ef129fa116 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/FRC_FPGA_ChipObject_Aliases.h @@ -0,0 +1,10 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __FRC_FPGA_ChipObject_Aliases_h__ +#define __FRC_FPGA_ChipObject_Aliases_h__ + +#define nInvariantFPGANamespace nFRC_C0EF_1_1_0 +#define nRuntimeFPGANamespace nFRC_2012_1_6_4 + +#endif // __FRC_FPGA_ChipObject_Aliases_h__ diff --git a/hal/Athena/src/main/native/ChipObject/NiRio.h b/hal/Athena/src/main/native/ChipObject/NiRio.h new file mode 100644 index 0000000000..ed40bd1a22 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/NiRio.h @@ -0,0 +1,9 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __NiRio_h__ +#define __NiRio_h__ + +#include "fpgainterfacecapi/NiFpga.h" +typedef NiFpga_Status tRioStatusCode; + +#endif // __NiRio_h__ diff --git a/hal/Athena/src/main/native/ChipObject/RoboRIO_FRC_ChipObject_Aliases.h b/hal/Athena/src/main/native/ChipObject/RoboRIO_FRC_ChipObject_Aliases.h new file mode 100644 index 0000000000..c69ce97ea6 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/RoboRIO_FRC_ChipObject_Aliases.h @@ -0,0 +1,9 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __RoboRIO_FRC_ChipObject_Aliases_h__ +#define __RoboRIO_FRC_ChipObject_Aliases_h__ + +#define nRoboRIO_FPGANamespace nFRC_2015_1_0_2 + +#endif // __RoboRIO_FRC_ChipObject_Aliases_h__ diff --git a/hal/Athena/src/main/native/ChipObject/fpgainterfacecapi/NiFpga.h b/hal/Athena/src/main/native/ChipObject/fpgainterfacecapi/NiFpga.h new file mode 100644 index 0000000000..0df6bfbb73 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/fpgainterfacecapi/NiFpga.h @@ -0,0 +1,2312 @@ +/* + * FPGA Interface C API 2.0 header file. + * + * Copyright (c) 2011, + * National Instruments Corporation. + * All rights reserved. + */ + +#ifndef __NiFpga_h__ +#define __NiFpga_h__ + +/* + * Determine platform details. + */ +#if defined(_M_IX86) \ + || defined(_M_X64) \ + || defined(i386) \ + || defined(__i386__) \ + || defined(__amd64__) \ + || defined(__amd64) \ + || defined(__x86_64__) \ + || defined(__x86_64) \ + || defined(__i386) \ + || defined(_X86_) \ + || defined(__THW_INTEL__) \ + || defined(__I86__) \ + || defined(__INTEL__) \ + || defined(__X86__) \ + || defined(__386__) \ + || defined(__I86__) \ + || defined(M_I386) \ + || defined(M_I86) \ + || defined(_M_I386) \ + || defined(_M_I86) \ + || defined(__arm__) + #if defined(_WIN32) \ + || defined(_WIN64) \ + || defined(__WIN32__) \ + || defined(__TOS_WIN__) \ + || defined(__WINDOWS__) \ + || defined(_WINDOWS) \ + || defined(__WINDOWS_386__) \ + || defined(__CYGWIN__) + /* Either Windows or Phar Lap ETS. */ + #define NiFpga_Windows 1 + #elif defined(__linux) \ + || defined(__linux__) \ + || defined(__gnu_linux__) \ + || defined(linux) + #define NiFpga_Linux 1 + #else + #error Unsupported OS. + #endif +#elif defined(__powerpc) \ + || defined(__powerpc__) \ + || defined(__POWERPC__) \ + || defined(__ppc__) \ + || defined(__PPC) \ + || defined(_M_PPC) \ + || defined(_ARCH_PPC) \ + || defined(__PPC__) \ + || defined(__ppc) + #if defined(__vxworks) + #define NiFpga_VxWorks 1 + #else + #error Unsupported OS. + #endif +#else + #error Unsupported architecture. +#endif + +/* + * Determine compiler. + */ +#if defined(_MSC_VER) + #define NiFpga_Msvc 1 +#elif defined(__GNUC__) + #define NiFpga_Gcc 1 +#elif defined(_CVI_) && !defined(_TPC_) + #define NiFpga_Cvi 1 + /* Enables CVI Library Protection Errors. */ + #pragma EnableLibraryRuntimeChecking +#else + /* Unknown compiler. */ +#endif + +/* + * Determine compliance with different C/C++ language standards. + */ +#if defined(__cplusplus) + #define NiFpga_Cpp 1 + #if __cplusplus >= 199707L + #define NiFpga_Cpp98 1 + #endif +#endif +#if defined(__STDC__) + #define NiFpga_C89 1 + #if defined(__STDC_VERSION__) + #define NiFpga_C90 1 + #if __STDC_VERSION__ >= 199409L + #define NiFpga_C94 1 + #if __STDC_VERSION__ >= 199901L + #define NiFpga_C99 1 + #endif + #endif + #endif +#endif + +/* + * Determine ability to inline functions. + */ +#if NiFpga_Cpp || NiFpga_C99 + /* The inline keyword exists in C++ and C99. */ + #define NiFpga_Inline inline +#elif NiFpga_Msvc + /* Visual C++ (at least since 6.0) also supports an alternate keyword. */ + #define NiFpga_Inline __inline +#elif NiFpga_Gcc + /* GCC (at least since 2.95.2) also supports an alternate keyword. */ + #define NiFpga_Inline __inline__ +#elif !defined(NiFpga_Inline) + /* + * Disable inlining if inline support is unknown. To manually enable + * inlining, #define the following macro before #including NiFpga.h: + * + * #define NiFpga_Inline inline + */ + #define NiFpga_Inline +#endif + +/* + * Define exact-width integer types, if they have not already been defined. + */ +#if NiFpga_ExactWidthIntegerTypesDefined \ + || defined(_STDINT) \ + || defined(_STDINT_H) \ + || defined(_STDINT_H_) \ + || defined(_INTTYPES_H) \ + || defined(_INTTYPES_H_) \ + || defined(_SYS_STDINT_H) \ + || defined(_SYS_STDINT_H_) \ + || defined(_SYS_INTTYPES_H) \ + || defined(_SYS_INTTYPES_H_) \ + || defined(_STDINT_H_INCLUDED) \ + || defined(BOOST_CSTDINT_HPP) \ + || defined(_MSC_STDINT_H_) \ + || defined(_PSTDINT_H_INCLUDED) + /* Assume that exact-width integer types have already been defined. */ +#elif NiFpga_VxWorks + #include +#elif NiFpga_C99 \ + || NiFpga_Gcc /* GCC (at least since 3.0) has a stdint.h. */ \ + || defined(HAVE_STDINT_H) + /* Assume that stdint.h can be included. */ + #include +#elif NiFpga_Msvc \ + || NiFpga_Cvi + /* Manually define exact-width integer types. */ + typedef signed char int8_t; + typedef unsigned char uint8_t; + typedef short int16_t; + typedef unsigned short uint16_t; + typedef int int32_t; + typedef unsigned int uint32_t; + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; +#else + /* + * Exact-width integer types must be defined by the user, and the following + * macro must be #defined, before #including NiFpga.h: + * + * #define NiFpga_ExactWidthIntegerTypesDefined 1 + */ + #error Exact-width integer types must be defined by the user. See comment. +#endif + +/* Included for definition of size_t. */ +#include + +#if NiFpga_Cpp +extern "C" { +#endif + +/** + * A boolean value; either NiFpga_False or NiFpga_True. + */ +typedef uint8_t NiFpga_Bool; + +/** + * Represents a false condition. + */ +static const NiFpga_Bool NiFpga_False = 0; + +/** + * Represents a true condition. + */ +static const NiFpga_Bool NiFpga_True = 1; + +/** + * Represents the resulting status of a function call through its return value. + * 0 is success, negative values are errors, and positive values are warnings. + */ +typedef int32_t NiFpga_Status; + +/** + * No errors or warnings. + */ +static const NiFpga_Status NiFpga_Status_Success = 0; + +/** + * The timeout expired before the FIFO operation could complete. + */ +static const NiFpga_Status NiFpga_Status_FifoTimeout = -50400; + +/** + * A memory allocation failed. Try again after rebooting. + */ +static const NiFpga_Status NiFpga_Status_MemoryFull = -52000; + +/** + * An unexpected software error occurred. + */ +static const NiFpga_Status NiFpga_Status_SoftwareFault = -52003; + +/** + * A parameter to a function was not valid. This could be a NULL pointer, a bad + * value, etc. + */ +static const NiFpga_Status NiFpga_Status_InvalidParameter = -52005; + +/** + * A required resource was not found. The NiFpga.* library, the RIO resource, + * or some other resource may be missing, or the NiFpga.* library may not be + * the required minimum version. + */ +static const NiFpga_Status NiFpga_Status_ResourceNotFound = -52006; + +/** + * A required resource was not properly initialized. This could occur if + * NiFpga_Initialize was not called or a required NiFpga_IrqContext was not + * reserved. + */ +static const NiFpga_Status NiFpga_Status_ResourceNotInitialized = -52010; + +/** + * The FPGA is already running. + */ +static const NiFpga_Status NiFpga_Status_FpgaAlreadyRunning = -61003; + +/** + * The bitfile was not compiled for the specified resource's device type. + */ +static const NiFpga_Status NiFpga_Status_DeviceTypeMismatch = -61024; + +/** + * An error was detected in the communication between the host computer and the + * FPGA target. + */ +static const NiFpga_Status NiFpga_Status_CommunicationTimeout = -61046; + +/** + * The timeout expired before any of the IRQs were asserted. + */ +static const NiFpga_Status NiFpga_Status_IrqTimeout = -61060; + +/** + * The specified bitfile is invalid or corrupt. + */ +static const NiFpga_Status NiFpga_Status_CorruptBitfile = -61070; + +/** + * The FIFO depth is invalid. It was either 0, greater than the amount of + * available memory in the host computer, or greater than the maximum size + * allowed by the hardware. + */ +static const NiFpga_Status NiFpga_Status_BadDepth = -61072; + +/** + * The number of FIFO elements is invalid. Either the number is greater than + * the depth of the host memory DMA FIFO, or more elements were requested for + * release than had been acquired. + */ +static const NiFpga_Status NiFpga_Status_BadReadWriteCount = -61073; + +/** + * A hardware clocking error occurred. A derived clock lost lock with its base + * clock during the execution of the LabVIEW FPGA VI. If any base clocks with + * derived clocks are referencing an external source, make sure that the + * external source is connected and within the supported frequency, jitter, + * accuracy, duty cycle, and voltage specifications. Also verify that the + * characteristics of the base clock match the configuration specified in the + * FPGA Base Clock Properties. If all base clocks with derived clocks are + * generated from free-running, on-board sources, please contact National + * Instruments technical support at ni.com/support. + */ +static const NiFpga_Status NiFpga_Status_ClockLostLock = -61083; + +/** + * Operation could not be performed because the FPGA is busy. Stop all the + * activities on the FPGA before requesting this operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusy = -61141; + +/** + * Operation could not be performed because the FPGA is busy operating in FPGA + * Interface C API mode. Stop all the activities on the FPGA before requesting + * this operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterfaceCApi = -61200; + +/** + * The chassis is in Scan Interface programming mode. In order to run FPGA VIs, + * you must go to the chassis properties page, select FPGA programming mode, + * and deploy settings. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyScanInterface = -61201; + +/** + * Operation could not be performed because the FPGA is busy operating in FPGA + * Interface mode. Stop all the activities on the FPGA before requesting this + * operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterface = -61202; + +/** + * Operation could not be performed because the FPGA is busy operating in + * Interactive mode. Stop all the activities on the FPGA before requesting this + * operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyInteractive = -61203; + +/** + * Operation could not be performed because the FPGA is busy operating in + * Emulation mode. Stop all the activities on the FPGA before requesting this + * operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyEmulation = -61204; + +/** + * An unexpected internal error occurred. + */ +static const NiFpga_Status NiFpga_Status_InternalError = -61499; + +/** + * Access to the remote system was denied. Use MAX to check the Remote Device + * Access settings under Software>>NI-RIO>>NI-RIO Settings on the remote system. + */ +static const NiFpga_Status NiFpga_Status_AccessDenied = -63033; + +/** + * A connection could not be established to the specified remote device. Ensure + * that the device is on and accessible over the network, that NI-RIO software + * is installed, and that the RIO server is running and properly configured. + */ +static const NiFpga_Status NiFpga_Status_RpcConnectionError = -63040; + +/** + * The RPC session is invalid. The target may have reset or been rebooted. Check + * the network connection and retry the operation. + */ +static const NiFpga_Status NiFpga_Status_RpcSessionError = -63043; + +/** + * A Read FIFO or Write FIFO function was called while the host had acquired + * elements of the FIFO. Release all acquired elements before reading or + * writing. + */ +static const NiFpga_Status NiFpga_Status_FifoElementsCurrentlyAcquired = -63083; + +/** + * The bitfile could not be read. + */ +static const NiFpga_Status NiFpga_Status_BitfileReadError = -63101; + +/** + * The specified signature does not match the signature of the bitfile. If the + * bitfile has been recompiled, regenerate the C API and rebuild the + * application. + */ +static const NiFpga_Status NiFpga_Status_SignatureMismatch = -63106; + +/** + * Either the supplied resource name is invalid as a RIO resource name, or the + * device was not found. Use MAX to find the proper resource name for the + * intended device. + */ +static const NiFpga_Status NiFpga_Status_InvalidResourceName = -63192; + +/** + * The requested feature is not supported. + */ +static const NiFpga_Status NiFpga_Status_FeatureNotSupported = -63193; + +/** + * The NI-RIO software on the remote system is not compatible with the local + * NI-RIO software. Upgrade the NI-RIO software on the remote system. + */ +static const NiFpga_Status NiFpga_Status_VersionMismatch = -63194; + +/** + * The session is invalid or has been closed. + */ +static const NiFpga_Status NiFpga_Status_InvalidSession = -63195; + +/** + * The maximum number of open FPGA sessions has been reached. Close some open + * sessions. + */ +static const NiFpga_Status NiFpga_Status_OutOfHandles = -63198; + +/** + * Tests whether a status is an error. + * + * @param status status to check for an error + * @return whether the status was an error + */ +static NiFpga_Inline NiFpga_Bool NiFpga_IsError(const NiFpga_Status status) +{ + return status < NiFpga_Status_Success; +} + +/** + * Tests whether a status is not an error. Success and warnings are not errors. + * + * @param status status to check for an error + * @return whether the status was a success or warning + */ +static NiFpga_Inline NiFpga_Bool NiFpga_IsNotError(const NiFpga_Status status) +{ + return status >= NiFpga_Status_Success; +} + +/** + * Conditionally sets the status to a new value. The previous status is + * preserved unless the new status is more of an error, which means that + * warnings and errors overwrite successes, and errors overwrite warnings. New + * errors do not overwrite older errors, and new warnings do not overwrite + * older warnings. + * + * @param status status to conditionally set + * @param newStatus new status value that may be set + * @return the resulting status + */ +static NiFpga_Inline NiFpga_Status NiFpga_MergeStatus( + NiFpga_Status* const status, + const NiFpga_Status newStatus) +{ + if (!status) + { + return NiFpga_Status_InvalidParameter; + } + if (NiFpga_IsNotError(*status) + && (*status == NiFpga_Status_Success || NiFpga_IsError(newStatus))) + { + *status = newStatus; + } + return *status; +} + +/** + * This macro evaluates the expression only if the status is not an error. The + * expression must evaluate to an NiFpga_Status, such as a call to any NiFpga_* + * function, because the status will be set to the returned status if the + * expression is evaluated. + * + * You can use this macro to mimic status chaining in LabVIEW, where the status + * does not have to be explicitly checked after each call. Such code may look + * like the following example. + * + * NiFpga_Status status = NiFpga_Status_Success; + * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...)); + * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...)); + * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...)); + * + * @param status status to check for an error + * @param expression expression to call if the incoming status is not an error + */ +#define NiFpga_IfIsNotError(status, expression) \ + if (NiFpga_IsNotError(status)) \ + { \ + NiFpga_MergeStatus(&status, (expression)); \ + } + +/** + * You must call this function before all other function calls. This function + * loads the NiFpga library so that all the other functions will work. If this + * function succeeds, you must call NiFpga_Finalize after all other function + * calls. + * + * @warning This function is not thread safe. + * + * @return result of the call + */ +NiFpga_Status NiFpga_Initialize(void); + +/** + * You must call this function after all other function calls if + * NiFpga_Initialize succeeds. This function unloads the NiFpga library. + * + * @warning This function is not thread safe. + * + * @return result of the call + */ +NiFpga_Status NiFpga_Finalize(void); + +/** + * A handle to an FPGA session. + */ +typedef uint32_t NiFpga_Session; + +/** + * Attributes that NiFpga_Open accepts. + */ +typedef enum +{ + NiFpga_OpenAttribute_NoRun = 1 +} NiFpga_OpenAttribute; + +/** + * Opens a session to the FPGA. This call ensures that the contents of the + * bitfile are programmed to the FPGA. The FPGA runs unless the + * NiFpga_OpenAttribute_NoRun attribute is used. + * + * Because different operating systems have different default current working + * directories for applications, you must pass an absolute path for the bitfile + * parameter. If you pass only the filename instead of an absolute path, the + * operating system may not be able to locate the bitfile. For example, the + * default current working directories are C:\ni-rt\system\ for Phar Lap ETS and + * /c/ for VxWorks. Because the generated *_Bitfile constant is a #define to a + * string literal, you can use C/C++ string-literal concatenation to form an + * absolute path. For example, if the bitfile is in the root directory of a + * Phar Lap ETS system, pass the following for the bitfile parameter. + * + * "C:\\" NiFpga_MyApplication_Bitfile + * + * @param bitfile path to the bitfile + * @param signature signature of the bitfile + * @param resource RIO resource string to open ("RIO0" or "rio://mysystem/RIO") + * @param attribute bitwise OR of any NiFpga_OpenAttributes, or 0 + * @param session outputs the session handle, which must be closed when no + * longer needed + * @return result of the call + */ +NiFpga_Status NiFpga_Open(const char* bitfile, + const char* signature, + const char* resource, + uint32_t attribute, + NiFpga_Session* session); + +/** + * Attributes that NiFpga_Close accepts. + */ +typedef enum +{ + NiFpga_CloseAttribute_NoResetIfLastSession = 1 +} NiFpga_CloseAttribute; + +/** + * Closes the session to the FPGA. The FPGA resets unless either another session + * is still open or you use the NiFpga_CloseAttribute_NoResetIfLastSession + * attribute. + * + * @param session handle to a currently open session + * @param attribute bitwise OR of any NiFpga_CloseAttributes, or 0 + * @return result of the call + */ +NiFpga_Status NiFpga_Close(NiFpga_Session session, + uint32_t attribute); + +/** + * Attributes that NiFpga_Run accepts. + */ +typedef enum +{ + NiFpga_RunAttribute_WaitUntilDone = 1 +} NiFpga_RunAttribute; + +/** + * Runs the FPGA VI on the target. If you use NiFpga_RunAttribute_WaitUntilDone, + * NiFpga_Run blocks the thread until the FPGA finishes running (if ever). + * + * @param session handle to a currently open session + * @param attribute bitwise OR of any NiFpga_RunAttributes, or 0 + * @return result of the call + */ +NiFpga_Status NiFpga_Run(NiFpga_Session session, + uint32_t attribute); + +/** + * Aborts the FPGA VI. + * + * @param session handle to a currently open session + * @return result of the call + */ +NiFpga_Status NiFpga_Abort(NiFpga_Session session); + +/** + * Resets the FPGA VI. + * + * @param session handle to a currently open session + * @return result of the call + */ +NiFpga_Status NiFpga_Reset(NiFpga_Session session); + +/** + * Re-downloads the FPGA bitstream to the target. + * + * @param session handle to a currently open session + * @return result of the call + */ +NiFpga_Status NiFpga_Download(NiFpga_Session session); + +/** + * Reads a boolean value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadBool(NiFpga_Session session, + uint32_t indicator, + NiFpga_Bool* value); + +/** + * Reads a signed 8-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI8(NiFpga_Session session, + uint32_t indicator, + int8_t* value); + +/** + * Reads an unsigned 8-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU8(NiFpga_Session session, + uint32_t indicator, + uint8_t* value); + +/** + * Reads a signed 16-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI16(NiFpga_Session session, + uint32_t indicator, + int16_t* value); + +/** + * Reads an unsigned 16-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU16(NiFpga_Session session, + uint32_t indicator, + uint16_t* value); + +/** + * Reads a signed 32-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI32(NiFpga_Session session, + uint32_t indicator, + int32_t* value); + +/** + * Reads an unsigned 32-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU32(NiFpga_Session session, + uint32_t indicator, + uint32_t* value); + +/** + * Reads a signed 64-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI64(NiFpga_Session session, + uint32_t indicator, + int64_t* value); + +/** + * Reads an unsigned 64-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU64(NiFpga_Session session, + uint32_t indicator, + uint64_t* value); + +/** + * Writes a boolean value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteBool(NiFpga_Session session, + uint32_t control, + NiFpga_Bool value); + +/** + * Writes a signed 8-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI8(NiFpga_Session session, + uint32_t control, + int8_t value); + +/** + * Writes an unsigned 8-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU8(NiFpga_Session session, + uint32_t control, + uint8_t value); + +/** + * Writes a signed 16-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI16(NiFpga_Session session, + uint32_t control, + int16_t value); + +/** + * Writes an unsigned 16-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU16(NiFpga_Session session, + uint32_t control, + uint16_t value); + +/** + * Writes a signed 32-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI32(NiFpga_Session session, + uint32_t control, + int32_t value); + +/** + * Writes an unsigned 32-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU32(NiFpga_Session session, + uint32_t control, + uint32_t value); + +/** + * Writes a signed 64-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI64(NiFpga_Session session, + uint32_t control, + int64_t value); + +/** + * Writes an unsigned 64-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU64(NiFpga_Session session, + uint32_t control, + uint64_t value); + +/** + * Reads an entire array of boolean values from a given array indicator or + * control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayBool(NiFpga_Session session, + uint32_t indicator, + NiFpga_Bool* array, + size_t size); + +/** + * Reads an entire array of signed 8-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI8(NiFpga_Session session, + uint32_t indicator, + int8_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 8-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU8(NiFpga_Session session, + uint32_t indicator, + uint8_t* array, + size_t size); + +/** + * Reads an entire array of signed 16-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI16(NiFpga_Session session, + uint32_t indicator, + int16_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 16-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU16(NiFpga_Session session, + uint32_t indicator, + uint16_t* array, + size_t size); + +/** + * Reads an entire array of signed 32-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI32(NiFpga_Session session, + uint32_t indicator, + int32_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 32-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU32(NiFpga_Session session, + uint32_t indicator, + uint32_t* array, + size_t size); + +/** + * Reads an entire array of signed 64-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI64(NiFpga_Session session, + uint32_t indicator, + int64_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 64-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU64(NiFpga_Session session, + uint32_t indicator, + uint64_t* array, + size_t size); + +/** + * Writes an entire array of boolean values to a given array control or + * indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayBool(NiFpga_Session session, + uint32_t control, + const NiFpga_Bool* array, + size_t size); + +/** + * Writes an entire array of signed 8-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI8(NiFpga_Session session, + uint32_t control, + const int8_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 8-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU8(NiFpga_Session session, + uint32_t control, + const uint8_t* array, + size_t size); + +/** + * Writes an entire array of signed 16-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI16(NiFpga_Session session, + uint32_t control, + const int16_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 16-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU16(NiFpga_Session session, + uint32_t control, + const uint16_t* array, + size_t size); + +/** + * Writes an entire array of signed 32-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI32(NiFpga_Session session, + uint32_t control, + const int32_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 32-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU32(NiFpga_Session session, + uint32_t control, + const uint32_t* array, + size_t size); + +/** + * Writes an entire array of signed 64-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI64(NiFpga_Session session, + uint32_t control, + const int64_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 64-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU64(NiFpga_Session session, + uint32_t control, + const uint64_t* array, + size_t size); + +/** + * Enumeration of all 32 possible IRQs. Multiple IRQs can be bitwise ORed + * together like this: + * + * NiFpga_Irq_3 | NiFpga_Irq_23 + */ +typedef enum +{ + NiFpga_Irq_0 = 1 << 0, + NiFpga_Irq_1 = 1 << 1, + NiFpga_Irq_2 = 1 << 2, + NiFpga_Irq_3 = 1 << 3, + NiFpga_Irq_4 = 1 << 4, + NiFpga_Irq_5 = 1 << 5, + NiFpga_Irq_6 = 1 << 6, + NiFpga_Irq_7 = 1 << 7, + NiFpga_Irq_8 = 1 << 8, + NiFpga_Irq_9 = 1 << 9, + NiFpga_Irq_10 = 1 << 10, + NiFpga_Irq_11 = 1 << 11, + NiFpga_Irq_12 = 1 << 12, + NiFpga_Irq_13 = 1 << 13, + NiFpga_Irq_14 = 1 << 14, + NiFpga_Irq_15 = 1 << 15, + NiFpga_Irq_16 = 1 << 16, + NiFpga_Irq_17 = 1 << 17, + NiFpga_Irq_18 = 1 << 18, + NiFpga_Irq_19 = 1 << 19, + NiFpga_Irq_20 = 1 << 20, + NiFpga_Irq_21 = 1 << 21, + NiFpga_Irq_22 = 1 << 22, + NiFpga_Irq_23 = 1 << 23, + NiFpga_Irq_24 = 1 << 24, + NiFpga_Irq_25 = 1 << 25, + NiFpga_Irq_26 = 1 << 26, + NiFpga_Irq_27 = 1 << 27, + NiFpga_Irq_28 = 1 << 28, + NiFpga_Irq_29 = 1 << 29, + NiFpga_Irq_30 = 1 << 30, + NiFpga_Irq_31 = 1U << 31 +} NiFpga_Irq; + +/** + * Represents an infinite timeout. + */ +static const uint32_t NiFpga_InfiniteTimeout = 0xFFFFFFFF; + +/** + * See NiFpga_ReserveIrqContext for more information. + */ +typedef void* NiFpga_IrqContext; + +/** + * IRQ contexts are single-threaded; only one thread can wait with a particular + * context at any given time. Clients must reserve as many contexts as the + * application requires. + * + * If a context is successfully reserved (the returned status is not an error), + * it must be unreserved later. Otherwise a memory leak will occur. + * + * @param session handle to a currently open session + * @param context outputs the IRQ context + * @return result of the call + */ +NiFpga_Status NiFpga_ReserveIrqContext(NiFpga_Session session, + NiFpga_IrqContext* context); + +/** + * Unreserves an IRQ context obtained from NiFpga_ReserveIrqContext. + * + * @param session handle to a currently open session + * @param context IRQ context to unreserve + * @return result of the call + */ +NiFpga_Status NiFpga_UnreserveIrqContext(NiFpga_Session session, + NiFpga_IrqContext context); + +/** + * This is a blocking function that stops the calling thread until the FPGA + * asserts any IRQ in the irqs parameter, or until the function call times out. + * Before calling this function, you must use NiFpga_ReserveIrqContext to + * reserve an IRQ context. No other threads can use the same context when this + * function is called. + * + * You can use the irqsAsserted parameter to determine which IRQs were asserted + * for each function call. + * + * @param session handle to a currently open session + * @param context IRQ context with which to wait + * @param irqs bitwise OR of NiFpga_Irqs + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param irqsAsserted if non-NULL, outputs bitwise OR of IRQs that were + * asserted + * @param timedOut if non-NULL, outputs whether the timeout expired + * @return result of the call + */ +NiFpga_Status NiFpga_WaitOnIrqs(NiFpga_Session session, + NiFpga_IrqContext context, + uint32_t irqs, + uint32_t timeout, + uint32_t* irqsAsserted, + NiFpga_Bool* timedOut); + +/** + * Acknowledges an IRQ or set of IRQs. + * + * @param session handle to a currently open session + * @param irqs bitwise OR of NiFpga_Irqs + * @return result of the call + */ +NiFpga_Status NiFpga_AcknowledgeIrqs(NiFpga_Session session, + uint32_t irqs); + +/** + * Specifies the depth of the host memory part of the DMA FIFO. This method is + * optional. In order to see the actual depth configured, use + * NiFpga_ConfigureFifo2. + * + * @param session handle to a currently open session + * @param fifo FIFO to configure + * @param depth requested number of elements in the host memory part of the + * DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ConfigureFifo(NiFpga_Session session, + uint32_t fifo, + size_t depth); + +/** + * Specifies the depth of the host memory part of the DMA FIFO. This method is + * optional. + * + * @param session handle to a currently open session + * @param fifo FIFO to configure + * @param requestedDepth requested number of elements in the host memory part + * of the DMA FIFO + * @param actualDepth if non-NULL, outputs the actual number of elements in the + * host memory part of the DMA FIFO, which may be more than + * the requested number + * @return result of the call + */ +NiFpga_Status NiFpga_ConfigureFifo2(NiFpga_Session session, + uint32_t fifo, + size_t requestedDepth, + size_t* actualDepth); +/** + * Starts a FIFO. This method is optional. + * + * @param session handle to a currently open session + * @param fifo FIFO to start + * @return result of the call + */ +NiFpga_Status NiFpga_StartFifo(NiFpga_Session session, + uint32_t fifo); + +/** + * Stops a FIFO. This method is optional. + * + * @param session handle to a currently open session + * @param fifo FIFO to stop + * @return result of the call + */ +NiFpga_Status NiFpga_StopFifo(NiFpga_Session session, + uint32_t fifo); + +/** + * Reads from a target-to-host FIFO of booleans. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoBool(NiFpga_Session session, + uint32_t fifo, + NiFpga_Bool* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI8(NiFpga_Session session, + uint32_t fifo, + int8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU8(NiFpga_Session session, + uint32_t fifo, + uint8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI16(NiFpga_Session session, + uint32_t fifo, + int16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU16(NiFpga_Session session, + uint32_t fifo, + uint16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI32(NiFpga_Session session, + uint32_t fifo, + int32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU32(NiFpga_Session session, + uint32_t fifo, + uint32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI64(NiFpga_Session session, + uint32_t fifo, + int64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU64(NiFpga_Session session, + uint32_t fifo, + uint64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Writes to a host-to-target FIFO of booleans. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoBool(NiFpga_Session session, + uint32_t fifo, + const NiFpga_Bool* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI8(NiFpga_Session session, + uint32_t fifo, + const int8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU8(NiFpga_Session session, + uint32_t fifo, + const uint8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI16(NiFpga_Session session, + uint32_t fifo, + const int16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU16(NiFpga_Session session, + uint32_t fifo, + const uint16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI32(NiFpga_Session session, + uint32_t fifo, + const int32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU32(NiFpga_Session session, + uint32_t fifo, + const uint32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI64(NiFpga_Session session, + uint32_t fifo, + const int64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU64(NiFpga_Session session, + uint32_t fifo, + const uint64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of booleans. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsBool( + NiFpga_Session session, + uint32_t fifo, + NiFpga_Bool** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 8-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI8( + NiFpga_Session session, + uint32_t fifo, + int8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 8-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU8( + NiFpga_Session session, + uint32_t fifo, + uint8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 16-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI16( + NiFpga_Session session, + uint32_t fifo, + int16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 16-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU16( + NiFpga_Session session, + uint32_t fifo, + uint16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 32-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI32( + NiFpga_Session session, + uint32_t fifo, + int32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 32-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU32( + NiFpga_Session session, + uint32_t fifo, + uint32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 64-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI64( + NiFpga_Session session, + uint32_t fifo, + int64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 64-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU64( + NiFpga_Session session, + uint32_t fifo, + uint64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of booleans. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsBool( + NiFpga_Session session, + uint32_t fifo, + NiFpga_Bool** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 8-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI8( + NiFpga_Session session, + uint32_t fifo, + int8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 8-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU8( + NiFpga_Session session, + uint32_t fifo, + uint8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 16-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI16( + NiFpga_Session session, + uint32_t fifo, + int16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 16-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU16( + NiFpga_Session session, + uint32_t fifo, + uint16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 32-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI32( + NiFpga_Session session, + uint32_t fifo, + int32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 32-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU32( + NiFpga_Session session, + uint32_t fifo, + uint32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 64-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI64( + NiFpga_Session session, + uint32_t fifo, + int64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 64-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU64( + NiFpga_Session session, + uint32_t fifo, + uint64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Releases previously acquired FIFO elements. + * + * The FPGA target cannot read elements acquired by the host. Therefore, the + * host must release elements after acquiring them. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo FIFO from which to release elements + * @param elements number of elements to release + * @return result of the call + */ +NiFpga_Status NiFpga_ReleaseFifoElements(NiFpga_Session session, + uint32_t fifo, + size_t elements); + +/** + * Gets an endpoint reference to a peer-to-peer FIFO. + * + * @param session handle to a currently open session + * @param fifo peer-to-peer FIFO + * @param endpoint outputs the endpoint reference + * @return result of the call + */ +NiFpga_Status NiFpga_GetPeerToPeerFifoEndpoint(NiFpga_Session session, + uint32_t fifo, + uint32_t* endpoint); + +#if NiFpga_Cpp +} +#endif + +#endif diff --git a/hal/Athena/src/main/native/ChipObject/nInterfaceGlobals.h b/hal/Athena/src/main/native/ChipObject/nInterfaceGlobals.h new file mode 100644 index 0000000000..4789ec618d --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/nInterfaceGlobals.h @@ -0,0 +1,15 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_nInterfaceGlobals_h__ +#define __nFRC_2015_1_0_2_nInterfaceGlobals_h__ + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + extern unsigned int g_currentTargetClass; +} +} + +#endif // __nFRC_2015_1_0_2_nInterfaceGlobals_h__ diff --git a/hal/Athena/src/main/native/ChipObject/printFpgaVersion.h b/hal/Athena/src/main/native/ChipObject/printFpgaVersion.h new file mode 100644 index 0000000000..9ef9bf4370 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/printFpgaVersion.h @@ -0,0 +1,42 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __printFPGAVersion_h__ +#define __printFPGAVersion_h__ + +namespace nFPGA +{ + +template +inline void printFPGAVersion(ttGlobal &global) +{ + tRioStatusCode cleanStatus=0; + uint32_t hardwareGuid[4]; + tSystemInterface &system = *global.getSystemInterface(); + system.getHardwareFpgaSignature(hardwareGuid, &cleanStatus); + const uint32_t *softwareGuid = system.getExpectedFPGASignature(); + printf("FPGA Hardware GUID: 0x"); + for(int i=0; i<4; i++) + { + printf("%08X", hardwareGuid[i]); + } + printf("\n"); + printf("FPGA Software GUID: 0x"); + for(int i=0; i<4; i++) + { + printf("%08X", softwareGuid[i]); + } + printf("\n"); + uint16_t fpgaHardwareVersion = global.readVersion(&cleanStatus); + uint16_t fpgaSoftwareVersion = system.getExpectedFPGAVersion(); + printf("FPGA Hardware Version: %X\n", fpgaHardwareVersion); + printf("FPGA Software Version: %X\n", fpgaSoftwareVersion); + uint32_t fpgaHardwareRevision = global.readRevision(&cleanStatus); + uint32_t fpgaSoftwareRevision = system.getExpectedFPGARevision(); + printf("FPGA Hardware Revision: %X.%X.%X\n", (fpgaHardwareRevision >> 20) & 0xFFF, (fpgaHardwareRevision >> 12) & 0xFF, fpgaHardwareRevision & 0xFFF); + printf("FPGA Software Revision: %X.%X.%X\n", (fpgaSoftwareRevision >> 20) & 0xFFF, (fpgaSoftwareRevision >> 12) & 0xFF, fpgaSoftwareRevision & 0xFFF); +} + +} + +#endif // __printFPGAVersion_h__ + diff --git a/hal/Athena/src/main/native/ChipObject/tAI.h b/hal/Athena/src/main/native/ChipObject/tAI.h new file mode 100644 index 0000000000..7169a591a4 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tAI.h @@ -0,0 +1,143 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_AI_h__ +#define __nFRC_2015_1_0_2_AI_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tAI +{ +public: + tAI(){} + virtual ~tAI(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAI* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ScanSize : 3; + unsigned ConvertRate : 26; +#else + unsigned ConvertRate : 26; + unsigned ScanSize : 3; +#endif + }; + struct{ + unsigned value : 29; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Channel : 3; + unsigned Averaged : 1; +#else + unsigned Averaged : 1; + unsigned Channel : 3; +#endif + }; + struct{ + unsigned value : 4; + }; + } tReadSelect; + + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual signed int readOutput(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_ScanSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ConvertRate(unsigned int value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ScanSize(tRioStatusCode *status) = 0; + virtual unsigned int readConfig_ConvertRate(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLoopTiming_IfaceConstants; + + virtual unsigned int readLoopTiming(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumOversampleBitsElements = 8, + } tOversampleBits_IfaceConstants; + + virtual void writeOversampleBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readOversampleBits(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumAverageBitsElements = 8, + } tAverageBits_IfaceConstants; + + virtual void writeAverageBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readAverageBits(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumScanListElements = 8, + } tScanList_IfaceConstants; + + virtual void writeScanList(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readScanList(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tLatchOutput_IfaceConstants; + + virtual void strobeLatchOutput(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReadSelect_IfaceConstants; + + virtual void writeReadSelect(tReadSelect value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Averaged(bool value, tRioStatusCode *status) = 0; + virtual tReadSelect readReadSelect(tRioStatusCode *status) = 0; + virtual unsigned char readReadSelect_Channel(tRioStatusCode *status) = 0; + virtual bool readReadSelect_Averaged(tRioStatusCode *status) = 0; + + + + +private: + tAI(const tAI&); + void operator=(const tAI&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_AI_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tAO.h b/hal/Athena/src/main/native/ChipObject/tAO.h new file mode 100644 index 0000000000..5f4ec853a1 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tAO.h @@ -0,0 +1,59 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_AO_h__ +#define __nFRC_2015_1_0_2_AO_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tAO +{ +public: + tAO(){} + virtual ~tAO(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAO* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + + + typedef enum + { + kNumMXPRegisters = 2, + } tMXP_IfaceConstants; + + virtual void writeMXP(unsigned char reg_index, unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readMXP(unsigned char reg_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumValueRegisters = 2, + } tValue_IfaceConstants; + + virtual void writeValue(unsigned char reg_index, unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readValue(unsigned char reg_index, tRioStatusCode *status) = 0; + + +private: + tAO(const tAO&); + void operator=(const tAO&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_AO_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tAccel.h b/hal/Athena/src/main/native/ChipObject/tAccel.h new file mode 100644 index 0000000000..df3c9d2960 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tAccel.h @@ -0,0 +1,62 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_Accel_h__ +#define __nFRC_2015_1_0_2_Accel_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tAccel +{ +public: + tAccel(){} + virtual ~tAccel(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAccel* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tX_IfaceConstants; + + virtual signed short readX(tRioStatusCode *status) = 0; + + + typedef enum + { + } tY_IfaceConstants; + + virtual signed short readY(tRioStatusCode *status) = 0; + + + typedef enum + { + } tZ_IfaceConstants; + + virtual signed short readZ(tRioStatusCode *status) = 0; + + + + +private: + tAccel(const tAccel&); + void operator=(const tAccel&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_Accel_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tAccumulator.h b/hal/Athena/src/main/native/ChipObject/tAccumulator.h new file mode 100644 index 0000000000..804eceafbb --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tAccumulator.h @@ -0,0 +1,87 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_Accumulator_h__ +#define __nFRC_2015_1_0_2_Accumulator_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tAccumulator +{ +public: + tAccumulator(){} + virtual ~tAccumulator(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAccumulator* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + typedef + union{ + struct{ + signed long long Value; + unsigned Count : 32; + }; + struct{ + unsigned value : 32; + unsigned value2 : 32; + unsigned value3 : 32; + }; + } tOutput; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual signed long long readOutput_Value(tRioStatusCode *status) = 0; + virtual unsigned int readOutput_Count(tRioStatusCode *status) = 0; + + + typedef enum + { + } tCenter_IfaceConstants; + + virtual void writeCenter(signed int value, tRioStatusCode *status) = 0; + virtual signed int readCenter(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDeadband_IfaceConstants; + + virtual void writeDeadband(signed int value, tRioStatusCode *status) = 0; + virtual signed int readDeadband(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + + + +private: + tAccumulator(const tAccumulator&); + void operator=(const tAccumulator&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_Accumulator_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tAlarm.h b/hal/Athena/src/main/native/ChipObject/tAlarm.h new file mode 100644 index 0000000000..ad1d5ab8cc --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tAlarm.h @@ -0,0 +1,57 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_Alarm_h__ +#define __nFRC_2015_1_0_2_Alarm_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tAlarm +{ +public: + tAlarm(){} + virtual ~tAlarm(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAlarm* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tEnable_IfaceConstants; + + virtual void writeEnable(bool value, tRioStatusCode *status) = 0; + virtual bool readEnable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTriggerTime_IfaceConstants; + + virtual void writeTriggerTime(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readTriggerTime(tRioStatusCode *status) = 0; + + + + +private: + tAlarm(const tAlarm&); + void operator=(const tAlarm&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_Alarm_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tAnalogTrigger.h b/hal/Athena/src/main/native/ChipObject/tAnalogTrigger.h new file mode 100644 index 0000000000..84fa939296 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tAnalogTrigger.h @@ -0,0 +1,129 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_AnalogTrigger_h__ +#define __nFRC_2015_1_0_2_AnalogTrigger_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tAnalogTrigger +{ +public: + tAnalogTrigger(){} + virtual ~tAnalogTrigger(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAnalogTrigger* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned InHysteresis : 1; + unsigned OverLimit : 1; + unsigned Rising : 1; + unsigned Falling : 1; +#else + unsigned Falling : 1; + unsigned Rising : 1; + unsigned OverLimit : 1; + unsigned InHysteresis : 1; +#endif + }; + struct{ + unsigned value : 4; + }; + } tOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Channel : 3; + unsigned Averaged : 1; + unsigned Filter : 1; + unsigned FloatingRollover : 1; + signed RolloverLimit : 8; +#else + signed RolloverLimit : 8; + unsigned FloatingRollover : 1; + unsigned Filter : 1; + unsigned Averaged : 1; + unsigned Channel : 3; +#endif + }; + struct{ + unsigned value : 14; + }; + } tSourceSelect; + + + typedef enum + { + } tSourceSelect_IfaceConstants; + + virtual void writeSourceSelect(tSourceSelect value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Averaged(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Filter(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_FloatingRollover(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_RolloverLimit(signed short value, tRioStatusCode *status) = 0; + virtual tSourceSelect readSourceSelect(tRioStatusCode *status) = 0; + virtual unsigned char readSourceSelect_Channel(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_Averaged(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_Filter(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_FloatingRollover(tRioStatusCode *status) = 0; + virtual signed short readSourceSelect_RolloverLimit(tRioStatusCode *status) = 0; + + + typedef enum + { + } tUpperLimit_IfaceConstants; + + virtual void writeUpperLimit(signed int value, tRioStatusCode *status) = 0; + virtual signed int readUpperLimit(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLowerLimit_IfaceConstants; + + virtual void writeLowerLimit(signed int value, tRioStatusCode *status) = 0; + virtual signed int readLowerLimit(tRioStatusCode *status) = 0; + + + + typedef enum + { + kNumOutputElements = 8, + } tOutput_IfaceConstants; + + virtual tOutput readOutput(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_InHysteresis(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_OverLimit(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_Rising(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_Falling(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + +private: + tAnalogTrigger(const tAnalogTrigger&); + void operator=(const tAnalogTrigger&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_AnalogTrigger_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tBIST.h b/hal/Athena/src/main/native/ChipObject/tBIST.h new file mode 100644 index 0000000000..bd076009b7 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tBIST.h @@ -0,0 +1,90 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_BIST_h__ +#define __nFRC_2015_1_0_2_BIST_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tBIST +{ +public: + tBIST(){} + virtual ~tBIST(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tBIST* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tDO0SquareTicks_IfaceConstants; + + virtual void writeDO0SquareTicks(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readDO0SquareTicks(tRioStatusCode *status) = 0; + + + typedef enum + { + } tEnable_IfaceConstants; + + virtual void writeEnable(bool value, tRioStatusCode *status) = 0; + virtual bool readEnable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDO1SquareEnable_IfaceConstants; + + virtual void writeDO1SquareEnable(bool value, tRioStatusCode *status) = 0; + virtual bool readDO1SquareEnable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDO0SquareEnable_IfaceConstants; + + virtual void writeDO0SquareEnable(bool value, tRioStatusCode *status) = 0; + virtual bool readDO0SquareEnable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDO1SquareTicks_IfaceConstants; + + virtual void writeDO1SquareTicks(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readDO1SquareTicks(tRioStatusCode *status) = 0; + + + + + typedef enum + { + kNumDORegisters = 2, + } tDO_IfaceConstants; + + virtual void writeDO(unsigned char reg_index, bool value, tRioStatusCode *status) = 0; + virtual bool readDO(unsigned char reg_index, tRioStatusCode *status) = 0; + + +private: + tBIST(const tBIST&); + void operator=(const tBIST&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_BIST_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tCounter.h b/hal/Athena/src/main/native/ChipObject/tCounter.h new file mode 100644 index 0000000000..9d79eb22b0 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tCounter.h @@ -0,0 +1,219 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_Counter_h__ +#define __nFRC_2015_1_0_2_Counter_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tCounter +{ +public: + tCounter(){} + virtual ~tCounter(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tCounter* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Direction : 1; + signed Value : 31; +#else + signed Value : 31; + unsigned Direction : 1; +#endif + }; + struct{ + unsigned value : 32; + }; + } tOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned UpSource_Channel : 4; + unsigned UpSource_Module : 1; + unsigned UpSource_AnalogTrigger : 1; + unsigned DownSource_Channel : 4; + unsigned DownSource_Module : 1; + unsigned DownSource_AnalogTrigger : 1; + unsigned IndexSource_Channel : 4; + unsigned IndexSource_Module : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexActiveHigh : 1; + unsigned UpRisingEdge : 1; + unsigned UpFallingEdge : 1; + unsigned DownRisingEdge : 1; + unsigned DownFallingEdge : 1; + unsigned Mode : 2; + unsigned PulseLengthThreshold : 6; + unsigned Enable : 1; +#else + unsigned Enable : 1; + unsigned PulseLengthThreshold : 6; + unsigned Mode : 2; + unsigned DownFallingEdge : 1; + unsigned DownRisingEdge : 1; + unsigned UpFallingEdge : 1; + unsigned UpRisingEdge : 1; + unsigned IndexActiveHigh : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexSource_Module : 1; + unsigned IndexSource_Channel : 4; + unsigned DownSource_AnalogTrigger : 1; + unsigned DownSource_Module : 1; + unsigned DownSource_Channel : 4; + unsigned UpSource_AnalogTrigger : 1; + unsigned UpSource_Module : 1; + unsigned UpSource_Channel : 4; +#endif + }; + struct{ + unsigned value : 32; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Period : 23; + signed Count : 8; + unsigned Stalled : 1; +#else + unsigned Stalled : 1; + signed Count : 8; + unsigned Period : 23; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned StallPeriod : 24; + unsigned AverageSize : 7; + unsigned UpdateWhenEmpty : 1; +#else + unsigned UpdateWhenEmpty : 1; + unsigned AverageSize : 7; + unsigned StallPeriod : 24; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerConfig; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual bool readOutput_Direction(tRioStatusCode *status) = 0; + virtual signed int readOutput_Value(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexActiveHigh(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpRisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpFallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownRisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownFallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Mode(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_PulseLengthThreshold(unsigned short value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_UpSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_UpSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_UpSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_DownSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_DownSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_DownSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexActiveHigh(tRioStatusCode *status) = 0; + virtual bool readConfig_UpRisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_UpFallingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_DownRisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_DownFallingEdge(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Mode(tRioStatusCode *status) = 0; + virtual unsigned short readConfig_PulseLengthThreshold(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerOutput_IfaceConstants; + + virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0; + virtual unsigned int readTimerOutput_Period(tRioStatusCode *status) = 0; + virtual signed char readTimerOutput_Count(tRioStatusCode *status) = 0; + virtual bool readTimerOutput_Stalled(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerConfig_IfaceConstants; + + virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_StallPeriod(unsigned int value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_AverageSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_UpdateWhenEmpty(bool value, tRioStatusCode *status) = 0; + virtual tTimerConfig readTimerConfig(tRioStatusCode *status) = 0; + virtual unsigned int readTimerConfig_StallPeriod(tRioStatusCode *status) = 0; + virtual unsigned char readTimerConfig_AverageSize(tRioStatusCode *status) = 0; + virtual bool readTimerConfig_UpdateWhenEmpty(tRioStatusCode *status) = 0; + + + + + +private: + tCounter(const tCounter&); + void operator=(const tCounter&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_Counter_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tDIO.h b/hal/Athena/src/main/native/ChipObject/tDIO.h new file mode 100644 index 0000000000..f8ee9e1887 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tDIO.h @@ -0,0 +1,261 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_DIO_h__ +#define __nFRC_2015_1_0_2_DIO_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tDIO +{ +public: + tDIO(){} + virtual ~tDIO(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tDIO* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Headers : 10; + unsigned Reserved : 6; + unsigned MXP : 16; +#else + unsigned MXP : 16; + unsigned Reserved : 6; + unsigned Headers : 10; +#endif + }; + struct{ + unsigned value : 32; + }; + } tDO; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Headers : 10; + unsigned Reserved : 6; + unsigned MXP : 16; +#else + unsigned MXP : 16; + unsigned Reserved : 6; + unsigned Headers : 10; +#endif + }; + struct{ + unsigned value : 32; + }; + } tOutputEnable; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Headers : 10; + unsigned Reserved : 6; + unsigned MXP : 16; +#else + unsigned MXP : 16; + unsigned Reserved : 6; + unsigned Headers : 10; +#endif + }; + struct{ + unsigned value : 32; + }; + } tPulse; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Headers : 10; + unsigned Reserved : 6; + unsigned MXP : 16; +#else + unsigned MXP : 16; + unsigned Reserved : 6; + unsigned Headers : 10; +#endif + }; + struct{ + unsigned value : 32; + }; + } tDI; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned PeriodPower : 6; + unsigned OutputSelect_0 : 5; + unsigned OutputSelect_1 : 5; + unsigned OutputSelect_2 : 5; + unsigned OutputSelect_3 : 5; +#else + unsigned OutputSelect_3 : 5; + unsigned OutputSelect_2 : 5; + unsigned OutputSelect_1 : 5; + unsigned OutputSelect_0 : 5; + unsigned PeriodPower : 6; +#endif + }; + struct{ + unsigned value : 26; + }; + } tPWMConfig; + + + + typedef enum + { + } tDO_IfaceConstants; + + virtual void writeDO(tDO value, tRioStatusCode *status) = 0; + virtual void writeDO_Headers(unsigned short value, tRioStatusCode *status) = 0; + virtual void writeDO_Reserved(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_MXP(unsigned short value, tRioStatusCode *status) = 0; + virtual tDO readDO(tRioStatusCode *status) = 0; + virtual unsigned short readDO_Headers(tRioStatusCode *status) = 0; + virtual unsigned char readDO_Reserved(tRioStatusCode *status) = 0; + virtual unsigned short readDO_MXP(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumPWMDutyCycleElements = 4, + } tPWMDutyCycle_IfaceConstants; + + virtual void writePWMDutyCycle(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPWMDutyCycle(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumFilterSelectHdrElements = 16, + } tFilterSelectHdr_IfaceConstants; + + virtual void writeFilterSelectHdr(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readFilterSelectHdr(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumFilterPeriodMXPElements = 3, + } tFilterPeriodMXP_IfaceConstants; + + virtual void writeFilterPeriodMXP(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readFilterPeriodMXP(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tOutputEnable_IfaceConstants; + + virtual void writeOutputEnable(tOutputEnable value, tRioStatusCode *status) = 0; + virtual void writeOutputEnable_Headers(unsigned short value, tRioStatusCode *status) = 0; + virtual void writeOutputEnable_Reserved(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeOutputEnable_MXP(unsigned short value, tRioStatusCode *status) = 0; + virtual tOutputEnable readOutputEnable(tRioStatusCode *status) = 0; + virtual unsigned short readOutputEnable_Headers(tRioStatusCode *status) = 0; + virtual unsigned char readOutputEnable_Reserved(tRioStatusCode *status) = 0; + virtual unsigned short readOutputEnable_MXP(tRioStatusCode *status) = 0; + + + typedef enum + { + } tPulse_IfaceConstants; + + virtual void writePulse(tPulse value, tRioStatusCode *status) = 0; + virtual void writePulse_Headers(unsigned short value, tRioStatusCode *status) = 0; + virtual void writePulse_Reserved(unsigned char value, tRioStatusCode *status) = 0; + virtual void writePulse_MXP(unsigned short value, tRioStatusCode *status) = 0; + virtual tPulse readPulse(tRioStatusCode *status) = 0; + virtual unsigned short readPulse_Headers(tRioStatusCode *status) = 0; + virtual unsigned char readPulse_Reserved(tRioStatusCode *status) = 0; + virtual unsigned short readPulse_MXP(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDI_IfaceConstants; + + virtual tDI readDI(tRioStatusCode *status) = 0; + virtual unsigned short readDI_Headers(tRioStatusCode *status) = 0; + virtual unsigned char readDI_Reserved(tRioStatusCode *status) = 0; + virtual unsigned short readDI_MXP(tRioStatusCode *status) = 0; + + + typedef enum + { + } tEnableMXPSpecialFunction_IfaceConstants; + + virtual void writeEnableMXPSpecialFunction(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readEnableMXPSpecialFunction(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumFilterSelectMXPElements = 16, + } tFilterSelectMXP_IfaceConstants; + + virtual void writeFilterSelectMXP(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readFilterSelectMXP(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tPulseLength_IfaceConstants; + + virtual void writePulseLength(unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPulseLength(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumFilterPeriodHdrElements = 3, + } tFilterPeriodHdr_IfaceConstants; + + virtual void writeFilterPeriodHdr(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readFilterPeriodHdr(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tPWMConfig_IfaceConstants; + + virtual void writePWMConfig(tPWMConfig value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_PeriodPower(unsigned char value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_OutputSelect_0(unsigned char value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_OutputSelect_1(unsigned char value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_OutputSelect_2(unsigned char value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_OutputSelect_3(unsigned char value, tRioStatusCode *status) = 0; + virtual tPWMConfig readPWMConfig(tRioStatusCode *status) = 0; + virtual unsigned char readPWMConfig_PeriodPower(tRioStatusCode *status) = 0; + virtual unsigned char readPWMConfig_OutputSelect_0(tRioStatusCode *status) = 0; + virtual unsigned char readPWMConfig_OutputSelect_1(tRioStatusCode *status) = 0; + virtual unsigned char readPWMConfig_OutputSelect_2(tRioStatusCode *status) = 0; + virtual unsigned char readPWMConfig_OutputSelect_3(tRioStatusCode *status) = 0; + + + + +private: + tDIO(const tDIO&); + void operator=(const tDIO&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_DIO_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tDMA.h b/hal/Athena/src/main/native/ChipObject/tDMA.h new file mode 100644 index 0000000000..06e699910e --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tDMA.h @@ -0,0 +1,188 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_DMA_h__ +#define __nFRC_2015_1_0_2_DMA_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tDMA +{ +public: + tDMA(){} + virtual ~tDMA(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tDMA* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Pause : 1; + unsigned Enable_AI0_Low : 1; + unsigned Enable_AI0_High : 1; + unsigned Enable_AIAveraged0_Low : 1; + unsigned Enable_AIAveraged0_High : 1; + unsigned Enable_AI1_Low : 1; + unsigned Enable_AI1_High : 1; + unsigned Enable_AIAveraged1_Low : 1; + unsigned Enable_AIAveraged1_High : 1; + unsigned Enable_Accumulator0 : 1; + unsigned Enable_Accumulator1 : 1; + unsigned Enable_DI : 1; + unsigned Enable_AnalogTriggers : 1; + unsigned Enable_Counters_Low : 1; + unsigned Enable_Counters_High : 1; + unsigned Enable_CounterTimers_Low : 1; + unsigned Enable_CounterTimers_High : 1; + unsigned Enable_Encoders : 1; + unsigned Enable_EncoderTimers : 1; + unsigned ExternalClock : 1; +#else + unsigned ExternalClock : 1; + unsigned Enable_EncoderTimers : 1; + unsigned Enable_Encoders : 1; + unsigned Enable_CounterTimers_High : 1; + unsigned Enable_CounterTimers_Low : 1; + unsigned Enable_Counters_High : 1; + unsigned Enable_Counters_Low : 1; + unsigned Enable_AnalogTriggers : 1; + unsigned Enable_DI : 1; + unsigned Enable_Accumulator1 : 1; + unsigned Enable_Accumulator0 : 1; + unsigned Enable_AIAveraged1_High : 1; + unsigned Enable_AIAveraged1_Low : 1; + unsigned Enable_AI1_High : 1; + unsigned Enable_AI1_Low : 1; + unsigned Enable_AIAveraged0_High : 1; + unsigned Enable_AIAveraged0_Low : 1; + unsigned Enable_AI0_High : 1; + unsigned Enable_AI0_Low : 1; + unsigned Pause : 1; +#endif + }; + struct{ + unsigned value : 20; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ExternalClockSource_Channel : 4; + unsigned ExternalClockSource_Module : 1; + unsigned ExternalClockSource_AnalogTrigger : 1; + unsigned RisingEdge : 1; + unsigned FallingEdge : 1; +#else + unsigned FallingEdge : 1; + unsigned RisingEdge : 1; + unsigned ExternalClockSource_AnalogTrigger : 1; + unsigned ExternalClockSource_Module : 1; + unsigned ExternalClockSource_Channel : 4; +#endif + }; + struct{ + unsigned value : 8; + }; + } tExternalTriggers; + + + + typedef enum + { + } tRate_IfaceConstants; + + virtual void writeRate(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readRate(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_Pause(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI0_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI0_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged0_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged0_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI1_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI1_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged1_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged1_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Accumulator0(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Accumulator1(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_DI(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AnalogTriggers(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Counters_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Counters_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_CounterTimers_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_CounterTimers_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Encoders(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_EncoderTimers(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_ExternalClock(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual bool readConfig_Pause(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI0_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI0_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged0_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged0_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI1_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI1_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged1_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged1_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Accumulator0(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Accumulator1(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_DI(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AnalogTriggers(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Counters_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Counters_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_CounterTimers_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_CounterTimers_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Encoders(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_EncoderTimers(tRioStatusCode *status) = 0; + virtual bool readConfig_ExternalClock(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumExternalTriggersElements = 4, + } tExternalTriggers_IfaceConstants; + + virtual void writeExternalTriggers(unsigned char bitfield_index, tExternalTriggers value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_Channel(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_Module(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_AnalogTrigger(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_RisingEdge(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_FallingEdge(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual tExternalTriggers readExternalTriggers(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual unsigned char readExternalTriggers_ExternalClockSource_Channel(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual unsigned char readExternalTriggers_ExternalClockSource_Module(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_ExternalClockSource_AnalogTrigger(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_RisingEdge(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_FallingEdge(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + +private: + tDMA(const tDMA&); + void operator=(const tDMA&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_DMA_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tDMAManager.h b/hal/Athena/src/main/native/ChipObject/tDMAManager.h new file mode 100644 index 0000000000..ce292b1592 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tDMAManager.h @@ -0,0 +1,46 @@ +// Class for handling DMA transters. +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tDMAManager_h__ +#define __tDMAManager_h__ + +#include "tSystem.h" + +namespace nFPGA +{ +// TODO: Implement DMA Manager +/* +class tDMAManager : public tSystem +{ +public: + tDMAManager(tNIRIO_u32 dmaChannel, tNIRIO_u32 hostBufferSize, tRioStatusCode *status); + ~tDMAManager(); + void start(tRioStatusCode *status); + void stop(tRioStatusCode *status); + bool isStarted() {return _started;} + void read( + tNIRIO_u32* buf, + tNIRIO_u32 num, + tNIRIO_u32 timeout, + tNIRIO_u32* read, + tNIRIO_u32* remaining, + tRioStatusCode *status); + void write( + tNIRIO_u32* buf, + tNIRIO_u32 num, + tNIRIO_u32 timeout, + tNIRIO_u32* remaining, + tRioStatusCode *status); +private: + bool _started; + tNIRIO_u32 _dmaChannel; + tNIRIO_u32 _hostBufferSize; + tDMAChannelDescriptor const *_dmaChannelDescriptor; + +}; +*/ +} + + +#endif // __tDMAManager_h__ + diff --git a/hal/Athena/src/main/native/ChipObject/tEncoder.h b/hal/Athena/src/main/native/ChipObject/tEncoder.h new file mode 100644 index 0000000000..8d32017462 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tEncoder.h @@ -0,0 +1,199 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_Encoder_h__ +#define __nFRC_2015_1_0_2_Encoder_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tEncoder +{ +public: + tEncoder(){} + virtual ~tEncoder(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tEncoder* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 4, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Direction : 1; + signed Value : 31; +#else + signed Value : 31; + unsigned Direction : 1; +#endif + }; + struct{ + unsigned value : 32; + }; + } tOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ASource_Channel : 4; + unsigned ASource_Module : 1; + unsigned ASource_AnalogTrigger : 1; + unsigned BSource_Channel : 4; + unsigned BSource_Module : 1; + unsigned BSource_AnalogTrigger : 1; + unsigned IndexSource_Channel : 4; + unsigned IndexSource_Module : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexActiveHigh : 1; + unsigned Reverse : 1; + unsigned Enable : 1; +#else + unsigned Enable : 1; + unsigned Reverse : 1; + unsigned IndexActiveHigh : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexSource_Module : 1; + unsigned IndexSource_Channel : 4; + unsigned BSource_AnalogTrigger : 1; + unsigned BSource_Module : 1; + unsigned BSource_Channel : 4; + unsigned ASource_AnalogTrigger : 1; + unsigned ASource_Module : 1; + unsigned ASource_Channel : 4; +#endif + }; + struct{ + unsigned value : 21; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Period : 23; + signed Count : 8; + unsigned Stalled : 1; +#else + unsigned Stalled : 1; + signed Count : 8; + unsigned Period : 23; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned StallPeriod : 24; + unsigned AverageSize : 7; + unsigned UpdateWhenEmpty : 1; +#else + unsigned UpdateWhenEmpty : 1; + unsigned AverageSize : 7; + unsigned StallPeriod : 24; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerConfig; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual bool readOutput_Direction(tRioStatusCode *status) = 0; + virtual signed int readOutput_Value(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexActiveHigh(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Reverse(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ASource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ASource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_ASource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_BSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexActiveHigh(tRioStatusCode *status) = 0; + virtual bool readConfig_Reverse(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerOutput_IfaceConstants; + + virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0; + virtual unsigned int readTimerOutput_Period(tRioStatusCode *status) = 0; + virtual signed char readTimerOutput_Count(tRioStatusCode *status) = 0; + virtual bool readTimerOutput_Stalled(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerConfig_IfaceConstants; + + virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_StallPeriod(unsigned int value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_AverageSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_UpdateWhenEmpty(bool value, tRioStatusCode *status) = 0; + virtual tTimerConfig readTimerConfig(tRioStatusCode *status) = 0; + virtual unsigned int readTimerConfig_StallPeriod(tRioStatusCode *status) = 0; + virtual unsigned char readTimerConfig_AverageSize(tRioStatusCode *status) = 0; + virtual bool readTimerConfig_UpdateWhenEmpty(tRioStatusCode *status) = 0; + + + + + +private: + tEncoder(const tEncoder&); + void operator=(const tEncoder&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_Encoder_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tGlobal.h b/hal/Athena/src/main/native/ChipObject/tGlobal.h new file mode 100644 index 0000000000..3d516c06c9 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tGlobal.h @@ -0,0 +1,104 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_Global_h__ +#define __nFRC_2015_1_0_2_Global_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tGlobal +{ +public: + tGlobal(){} + virtual ~tGlobal(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tGlobal* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Radio : 8; + unsigned Comm : 8; + unsigned Mode : 8; + unsigned RSL : 1; +#else + unsigned RSL : 1; + unsigned Mode : 8; + unsigned Comm : 8; + unsigned Radio : 8; +#endif + }; + struct{ + unsigned value : 25; + }; + } tLEDs; + + + + typedef enum + { + } tLEDs_IfaceConstants; + + virtual void writeLEDs(tLEDs value, tRioStatusCode *status) = 0; + virtual void writeLEDs_Radio(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeLEDs_Comm(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeLEDs_Mode(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeLEDs_RSL(bool value, tRioStatusCode *status) = 0; + virtual tLEDs readLEDs(tRioStatusCode *status) = 0; + virtual unsigned char readLEDs_Radio(tRioStatusCode *status) = 0; + virtual unsigned char readLEDs_Comm(tRioStatusCode *status) = 0; + virtual unsigned char readLEDs_Mode(tRioStatusCode *status) = 0; + virtual bool readLEDs_RSL(tRioStatusCode *status) = 0; + + + typedef enum + { + } tVersion_IfaceConstants; + + virtual unsigned short readVersion(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLocalTime_IfaceConstants; + + virtual unsigned int readLocalTime(tRioStatusCode *status) = 0; + + + typedef enum + { + } tUserButton_IfaceConstants; + + virtual bool readUserButton(tRioStatusCode *status) = 0; + + + typedef enum + { + } tRevision_IfaceConstants; + + virtual unsigned int readRevision(tRioStatusCode *status) = 0; + + + + +private: + tGlobal(const tGlobal&); + void operator=(const tGlobal&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_Global_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tInterrupt.h b/hal/Athena/src/main/native/ChipObject/tInterrupt.h new file mode 100644 index 0000000000..7993004e54 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tInterrupt.h @@ -0,0 +1,93 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_Interrupt_h__ +#define __nFRC_2015_1_0_2_Interrupt_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tInterrupt +{ +public: + tInterrupt(){} + virtual ~tInterrupt(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tInterrupt* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Source_Channel : 4; + unsigned Source_Module : 1; + unsigned Source_AnalogTrigger : 1; + unsigned RisingEdge : 1; + unsigned FallingEdge : 1; + unsigned WaitForAck : 1; +#else + unsigned WaitForAck : 1; + unsigned FallingEdge : 1; + unsigned RisingEdge : 1; + unsigned Source_AnalogTrigger : 1; + unsigned Source_Module : 1; + unsigned Source_Channel : 4; +#endif + }; + struct{ + unsigned value : 9; + }; + } tConfig; + + + typedef enum + { + } tTimeStamp_IfaceConstants; + + virtual unsigned int readTimeStamp(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_RisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_FallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_WaitForAck(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Source_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Source_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_Source_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_RisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_FallingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_WaitForAck(tRioStatusCode *status) = 0; + + + + + +private: + tInterrupt(const tInterrupt&); + void operator=(const tInterrupt&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_Interrupt_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tInterruptManager.h b/hal/Athena/src/main/native/ChipObject/tInterruptManager.h new file mode 100644 index 0000000000..b8fb361845 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tInterruptManager.h @@ -0,0 +1,61 @@ +// Class for handling interrupts. +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tInterruptManager_h__ +#define __tInterruptManager_h__ + +#include "tSystem.h" + +namespace ni +{ + namespace dsc + { + namespace osdep + { + class CriticalSection; + } + } +} + +namespace nFPGA +{ + +typedef void (*tInterruptHandler)(uint32_t interruptAssertedMask, void *param); + +class tInterruptManager : public tSystem +{ +public: + tInterruptManager(uint32_t interruptMask, bool watcher, tRioStatusCode *status); + ~tInterruptManager(); + void registerHandler(tInterruptHandler handler, void *param, tRioStatusCode *status); + uint32_t watch(int32_t timeoutInMs, tRioStatusCode *status); + void enable(tRioStatusCode *status); + void disable(tRioStatusCode *status); + bool isEnabled(tRioStatusCode *status); +private: + class tInterruptThread; + friend class tInterruptThread; + void handler(); + static int handlerWrapper(tInterruptManager *pInterrupt); + + void acknowledge(tRioStatusCode *status); + void reserve(tRioStatusCode *status); + void unreserve(tRioStatusCode *status); + tInterruptHandler _handler; + uint32_t _interruptMask; + tInterruptThread *_thread; + NiFpga_IrqContext _rioContext; + bool _watcher; + bool _enabled; + void *_userParam; + + // maintain the interrupts that are already dealt with. + static uint32_t _globalInterruptMask; + static ni::dsc::osdep::CriticalSection *_globalInterruptMaskSemaphore; +}; + +} + + +#endif // __tInterruptManager_h__ + diff --git a/hal/Athena/src/main/native/ChipObject/tPWM.h b/hal/Athena/src/main/native/ChipObject/tPWM.h new file mode 100644 index 0000000000..5f8f7e220e --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tPWM.h @@ -0,0 +1,111 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_PWM_h__ +#define __nFRC_2015_1_0_2_PWM_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tPWM +{ +public: + tPWM(){} + virtual ~tPWM(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tPWM* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Period : 16; + unsigned MinHigh : 16; +#else + unsigned MinHigh : 16; + unsigned Period : 16; +#endif + }; + struct{ + unsigned value : 32; + }; + } tConfig; + + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_Period(unsigned short value, tRioStatusCode *status) = 0; + virtual void writeConfig_MinHigh(unsigned short value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned short readConfig_Period(tRioStatusCode *status) = 0; + virtual unsigned short readConfig_MinHigh(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLoopTiming_IfaceConstants; + + virtual unsigned short readLoopTiming(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumPeriodScaleMXPElements = 10, + } tPeriodScaleMXP_IfaceConstants; + + virtual void writePeriodScaleMXP(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPeriodScaleMXP(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumPeriodScaleHdrElements = 10, + } tPeriodScaleHdr_IfaceConstants; + + virtual void writePeriodScaleHdr(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPeriodScaleHdr(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + + typedef enum + { + kNumHdrRegisters = 10, + } tHdr_IfaceConstants; + + virtual void writeHdr(unsigned char reg_index, unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readHdr(unsigned char reg_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumMXPRegisters = 10, + } tMXP_IfaceConstants; + + virtual void writeMXP(unsigned char reg_index, unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readMXP(unsigned char reg_index, tRioStatusCode *status) = 0; + + +private: + tPWM(const tPWM&); + void operator=(const tPWM&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_PWM_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tPower.h b/hal/Athena/src/main/native/ChipObject/tPower.h new file mode 100644 index 0000000000..b0ede13787 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tPower.h @@ -0,0 +1,107 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_Power_h__ +#define __nFRC_2015_1_0_2_Power_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tPower +{ +public: + tPower(){} + virtual ~tPower(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tPower* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned User3V3 : 8; + unsigned User5V : 8; + signed User6V : 16; +#else + signed User6V : 16; + unsigned User5V : 8; + unsigned User3V3 : 8; +#endif + }; + struct{ + unsigned value : 32; + }; + } tStatus; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned User3V3 : 1; + unsigned User5V : 1; + unsigned User6V : 1; +#else + unsigned User6V : 1; + unsigned User5V : 1; + unsigned User3V3 : 1; +#endif + }; + struct{ + unsigned value : 3; + }; + } tDisable; + + + + typedef enum + { + } tStatus_IfaceConstants; + + virtual tStatus readStatus(tRioStatusCode *status) = 0; + virtual unsigned char readStatus_User3V3(tRioStatusCode *status) = 0; + virtual unsigned char readStatus_User5V(tRioStatusCode *status) = 0; + virtual signed short readStatus_User6V(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDisable_IfaceConstants; + + virtual void writeDisable(tDisable value, tRioStatusCode *status) = 0; + virtual void writeDisable_User3V3(bool value, tRioStatusCode *status) = 0; + virtual void writeDisable_User5V(bool value, tRioStatusCode *status) = 0; + virtual void writeDisable_User6V(bool value, tRioStatusCode *status) = 0; + virtual tDisable readDisable(tRioStatusCode *status) = 0; + virtual bool readDisable_User3V3(tRioStatusCode *status) = 0; + virtual bool readDisable_User5V(tRioStatusCode *status) = 0; + virtual bool readDisable_User6V(tRioStatusCode *status) = 0; + + + typedef enum + { + } tIndicateOutOfRange_IfaceConstants; + + virtual void writeIndicateOutOfRange(bool value, tRioStatusCode *status) = 0; + virtual bool readIndicateOutOfRange(tRioStatusCode *status) = 0; + + + + +private: + tPower(const tPower&); + void operator=(const tPower&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_Power_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tRelay.h b/hal/Athena/src/main/native/ChipObject/tRelay.h new file mode 100644 index 0000000000..93db1848dd --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tRelay.h @@ -0,0 +1,68 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_Relay_h__ +#define __nFRC_2015_1_0_2_Relay_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tRelay +{ +public: + tRelay(){} + virtual ~tRelay(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tRelay* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Forward : 4; + unsigned Reverse : 4; +#else + unsigned Reverse : 4; + unsigned Forward : 4; +#endif + }; + struct{ + unsigned value : 8; + }; + } tValue; + + + + typedef enum + { + } tValue_IfaceConstants; + + virtual void writeValue(tValue value, tRioStatusCode *status) = 0; + virtual void writeValue_Forward(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeValue_Reverse(unsigned char value, tRioStatusCode *status) = 0; + virtual tValue readValue(tRioStatusCode *status) = 0; + virtual unsigned char readValue_Forward(tRioStatusCode *status) = 0; + virtual unsigned char readValue_Reverse(tRioStatusCode *status) = 0; + + + + +private: + tRelay(const tRelay&); + void operator=(const tRelay&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_Relay_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tSysWatchdog.h b/hal/Athena/src/main/native/ChipObject/tSysWatchdog.h new file mode 100644 index 0000000000..05bc242533 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tSysWatchdog.h @@ -0,0 +1,71 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_SysWatchdog_h__ +#define __nFRC_2015_1_0_2_SysWatchdog_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tSysWatchdog +{ +public: + tSysWatchdog(){} + virtual ~tSysWatchdog(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tSysWatchdog* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tCommand_IfaceConstants; + + virtual void writeCommand(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readCommand(tRioStatusCode *status) = 0; + + + typedef enum + { + } tChallenge_IfaceConstants; + + virtual unsigned char readChallenge(tRioStatusCode *status) = 0; + + + typedef enum + { + } tActive_IfaceConstants; + + virtual void writeActive(bool value, tRioStatusCode *status) = 0; + virtual bool readActive(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimer_IfaceConstants; + + virtual unsigned int readTimer(tRioStatusCode *status) = 0; + + + + +private: + tSysWatchdog(const tSysWatchdog&); + void operator=(const tSysWatchdog&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_SysWatchdog_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tSystem.h b/hal/Athena/src/main/native/ChipObject/tSystem.h new file mode 100644 index 0000000000..eb55be1772 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tSystem.h @@ -0,0 +1,47 @@ +// Base class for generated chip objects +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tSystem_h__ +#define __tSystem_h__ + +#include "fpgainterfacecapi/NiFpga.h" +typedef NiFpga_Status tRioStatusCode; + +#define FRC_FPGA_PRELOAD_BITFILE + +typedef uint32_t NiFpga_Session; + +namespace nFPGA +{ + +class tSystem +{ +public: + tSystem(tRioStatusCode *status); + ~tSystem(); + void getFpgaGuid(uint32_t *guid_ptr, tRioStatusCode *status); + +protected: + static NiFpga_Session _DeviceHandle; + +#ifdef FRC_FPGA_PRELOAD_BITFILE + void NiFpga_SharedOpen_common(const char* bitfile); + NiFpga_Status NiFpga_SharedOpen(const char* bitfile, + const char* signature, + const char* resource, + uint32_t attribute, + NiFpga_Session* session); + NiFpga_Status NiFpgaLv_SharedOpen(const char* const bitfile, + const char* const apiSignature, + const char* const resource, + const uint32_t attribute, + NiFpga_Session* const session); +private: + static char *_FileName; + static char *_Bitfile; +#endif +}; + +} + +#endif // __tSystem_h__ diff --git a/hal/Athena/src/main/native/ChipObject/tSystemInterface.h b/hal/Athena/src/main/native/ChipObject/tSystemInterface.h new file mode 100644 index 0000000000..46786e8e7d --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tSystemInterface.h @@ -0,0 +1,26 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tSystemInterface_h__ +#define __tSystemInterface_h__ + +namespace nFPGA +{ + +class tSystemInterface +{ +public: + tSystemInterface(){} + virtual ~tSystemInterface(){} + + virtual const uint16_t getExpectedFPGAVersion()=0; + virtual const uint32_t getExpectedFPGARevision()=0; + virtual const uint32_t * const getExpectedFPGASignature()=0; + virtual void getHardwareFpgaSignature(uint32_t *guid_ptr, tRioStatusCode *status)=0; + virtual uint32_t getLVHandle(tRioStatusCode *status)=0; + virtual uint32_t getHandle()=0; +}; + +} + +#endif // __tSystemInterface_h__ + diff --git a/hal/Athena/src/main/native/ChipObject/tWatchdog.h b/hal/Athena/src/main/native/ChipObject/tWatchdog.h new file mode 100644 index 0000000000..ddbc24cb66 --- /dev/null +++ b/hal/Athena/src/main/native/ChipObject/tWatchdog.h @@ -0,0 +1,108 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2015_1_0_2_Watchdog_h__ +#define __nFRC_2015_1_0_2_Watchdog_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2015_1_0_2 +{ + +class tWatchdog +{ +public: + tWatchdog(){} + virtual ~tWatchdog(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tWatchdog* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned SystemActive : 1; + unsigned Alive : 1; + unsigned SysDisableCount : 15; + unsigned DisableCount : 15; +#else + unsigned DisableCount : 15; + unsigned SysDisableCount : 15; + unsigned Alive : 1; + unsigned SystemActive : 1; +#endif + }; + struct{ + unsigned value : 32; + }; + } tStatus; + + + + typedef enum + { + } tStatus_IfaceConstants; + + virtual tStatus readStatus(tRioStatusCode *status) = 0; + virtual bool readStatus_SystemActive(tRioStatusCode *status) = 0; + virtual bool readStatus_Alive(tRioStatusCode *status) = 0; + virtual unsigned short readStatus_SysDisableCount(tRioStatusCode *status) = 0; + virtual unsigned short readStatus_DisableCount(tRioStatusCode *status) = 0; + + + typedef enum + { + } tKill_IfaceConstants; + + virtual void strobeKill(tRioStatusCode *status) = 0; + + + typedef enum + { + } tFeed_IfaceConstants; + + virtual void strobeFeed(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimer_IfaceConstants; + + virtual unsigned int readTimer(tRioStatusCode *status) = 0; + + + typedef enum + { + } tExpiration_IfaceConstants; + + virtual void writeExpiration(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readExpiration(tRioStatusCode *status) = 0; + + + typedef enum + { + } tImmortal_IfaceConstants; + + virtual void writeImmortal(bool value, tRioStatusCode *status) = 0; + virtual bool readImmortal(tRioStatusCode *status) = 0; + + + + +private: + tWatchdog(const tWatchdog&); + void operator=(const tWatchdog&); +}; + +} +} + +#endif // __nFRC_2015_1_0_2_Watchdog_h__ diff --git a/hal/Athena/src/main/native/Digital.cpp b/hal/Athena/src/main/native/Digital.cpp new file mode 100644 index 0000000000..7e44729300 --- /dev/null +++ b/hal/Athena/src/main/native/Digital.cpp @@ -0,0 +1,1563 @@ + +#include "HAL/Digital.h" + +#include "Port.h" +#include "HAL/HAL.h" +#include "ChipObject.h" +#include "HAL/cpp/Synchronized.h" +#include "HAL/cpp/Resource.h" +#include "NetworkCommunication/LoadOut.h" +#include +#include + +static const uint32_t kExpectedLoopTiming = 40; +static const uint32_t kDigitalPins = 14; +static const uint32_t kPwmPins = 10; +static const uint32_t kRelayPins = 8; +/** + * kDefaultPwmPeriod is in ms + * + * - 20ms periods (50 Hz) are the "safest" setting in that this works for all devices + * - 20ms periods seem to be desirable for Vex Motors + * - 20ms periods are the specified period for HS-322HD servos, but work reliably down + * to 10.0 ms; starting at about 8.5ms, the servo sometimes hums and get hot; + * by 5.0ms the hum is nearly continuous + * - 10ms periods work well for Victor 884 + * - 5ms periods allows higher update rates for Luminary Micro Jaguar speed controllers. + * Due to the shipping firmware on the Jaguar, we can't run the update period less + * than 5.05 ms. + * + * kDefaultPwmPeriod is the 1x period (5.05 ms). In hardware, the period scaling is implemented as an + * output squelch to get longer periods for old devices. + */ +static const float kDefaultPwmPeriod = 5.05; +/** + * kDefaultPwmCenter is the PWM range center in ms + */ +static const float kDefaultPwmCenter = 1.5; +/** + * kDefaultPWMStepsDown is the number of PWM steps below the centerpoint + */ +static const int32_t kDefaultPwmStepsDown = 1000; +static const int32_t kPwmDisabled = 0; + +struct digital_port_t { + Port port; + uint32_t PWMGeneratorID; +}; +typedef struct digital_port_t DigitalPort; + +// XXX: Set these back to static once we figure out the memory clobbering issue +MUTEX_ID digitalDIOSemaphore = NULL; +MUTEX_ID digitalRelaySemaphore = NULL; +MUTEX_ID digitalPwmSemaphore = NULL; +MUTEX_ID digitalI2CSemaphore = NULL; +tDIO* digitalSystem = NULL; +tRelay* relaySystem = NULL; +tPWM* pwmSystem = NULL; +Resource *DIOChannels = NULL; +Resource *DO_PWMGenerators = NULL; + +bool digitalSystemsInitialized = false; + +/** + * Initialize the digital modules. + */ +void initializeDigital(int32_t *status) { + if (digitalSystemsInitialized) return; + + // Create a semaphore to protect changes to the digital output values + digitalDIOSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + // Create a semaphore to protect changes to the relay values + digitalRelaySemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + // Create a semaphore to protect changes to the DO PWM config + digitalPwmSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + digitalI2CSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + Resource::CreateResourceObject(&DIOChannels, tDIO::kNumSystems * kDigitalPins); + Resource::CreateResourceObject(&DO_PWMGenerators, tDIO::kNumPWMDutyCycleElements); + digitalSystem = tDIO::create(status); + + // Relay Setup + relaySystem = tRelay::create(status); + + // Turn off all relay outputs. + relaySystem->writeValue_Forward(0, status); + relaySystem->writeValue_Reverse(0, status); + + // PWM Setup + pwmSystem = tPWM::create(status); + + // Make sure that the 9403 IONode has had a chance to initialize before continuing. + while(pwmSystem->readLoopTiming(status) == 0) delayTicks(1); + + if (pwmSystem->readLoopTiming(status) != kExpectedLoopTiming) { + // TODO: char err[128]; + // TODO: sprintf(err, "DIO LoopTiming: %d, expecting: %lu\n", digitalModules[port->module-1]->readLoopTiming(status), kExpectedLoopTiming); + *status = LOOP_TIMING_ERROR; // NOTE: Doesn't display the error + } + + //Calculate the length, in ms, of one DIO loop + double loopTime = pwmSystem->readLoopTiming(status)/(kSystemClockTicksPerMicrosecond*1e3); + + pwmSystem->writeConfig_Period((uint16_t) (kDefaultPwmPeriod/loopTime + .5), status); + uint16_t minHigh = (uint16_t) ((kDefaultPwmCenter-kDefaultPwmStepsDown*loopTime)/loopTime + .5); + pwmSystem->writeConfig_MinHigh(minHigh, status); +// printf("MinHigh: %d\n", minHigh); + // Ensure that PWM output values are set to OFF + for (uint32_t pwm_index = 1; pwm_index <= kPwmPins; pwm_index++) { + // Initialize port structure + DigitalPort* digital_port = new DigitalPort(); + digital_port->port.pin = pwm_index; + + setPWM(digital_port, kPwmDisabled, status); + setPWMPeriodScale(digital_port, 3, status); // Set all to 4x by default. + } + + digitalSystemsInitialized = true; +} + +/** + * Create a new instance of an digital module. + * Create an instance of the digital module object. Initialize all the parameters + * to reasonable values on start. + * Setting a global value on an digital module can be done only once unless subsequent + * values are set the previously set value. + * Digital modules are a singleton, so the constructor is never called outside of this class. + * + * @param moduleNumber The digital module to create (1 or 2). + */ +void* initializeDigitalPort(void* port_pointer, int32_t *status) { + initializeDigital(status); + Port* port = (Port*) port_pointer; + + // Initialize port structure + DigitalPort* digital_port = new DigitalPort(); + digital_port->port = *port; + + return digital_port; +} + +bool checkDigitalModule(uint8_t module) { + if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Digital, module - 1)) + return true; + return false; +} + +bool checkPWMChannel(void* digital_port_pointer) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + if (port->port.pin > 0 && port->port.pin <= kPwmPins) + return true; + return false; +} + +bool checkRelayChannel(void* digital_port_pointer) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + if (port->port.pin > 0 && port->port.pin <= kRelayPins) + return true; + return false; +} + +uint8_t remapDigitalChannel(uint32_t pin, int32_t *status) { + return pin; // TODO: No mapping needed anymore +} + +uint8_t unmapDigitalChannel(uint32_t pin, int32_t *status) { + return pin; // TODO: No mapping needed anymore +} + +/** + * Set a PWM channel to the desired value. The values range from 0 to 255 and the period is controlled + * by the PWM Period and MinHigh registers. + * + * @param channel The PWM channel to set. + * @param value The PWM value to set. + */ +void setPWM(void* digital_port_pointer, unsigned short value, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkPWMChannel(port); +// printf("Value:%d\n", value); + pwmSystem->writeHdr(port->port.pin - 1, value, status); // XXX: Support MXP +} + +/** + * Get a value from a PWM channel. The values range from 0 to 255. + * + * @param channel The PWM channel to read from. + * @return The raw PWM value. + */ +unsigned short getPWM(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkPWMChannel(port); + return pwmSystem->readHdr(port->port.pin - 1, status); // XXX: Support MXP +} + +/** + * Set how how often the PWM signal is squelched, thus scaling the period. + * + * @param channel The PWM channel to configure. + * @param squelchMask The 2-bit mask of outputs to squelch. + */ +void setPWMPeriodScale(void* digital_port_pointer, uint32_t squelchMask, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkPWMChannel(port); + pwmSystem->writePeriodScaleHdr(port->port.pin - 1, squelchMask, status); // XXX: Support MXP +} + +/** + * Allocate a DO PWM Generator. + * Allocate PWM generators so that they are not accidently reused. + * + * @return PWM Generator refnum + */ +void* allocatePWM(int32_t *status) { + return allocatePWMWithModule(0, status); +} + +/** + * Allocate a DO PWM Generator. + * Allocate PWM generators so that they are not accidently reused. + * + * @return PWM Generator refnum + */ +void* allocatePWMWithModule(uint8_t module, int32_t *status) { + char buf[64]; + snprintf(buf, 64, "DO_PWM (Module: %d)", module); + uint32_t* val = NULL; + *val = DO_PWMGenerators->Allocate(buf); + return val; +} + +/** + * Free the resource associated with a DO PWM generator. + * + * @param pwmGenerator The pwmGen to free that was allocated with AllocateDO_PWM() + */ +void freePWM(void* pwmGenerator, int32_t *status) { + freePWMWithModule(0, pwmGenerator, status); +} + +/** + * Free the resource associated with a DO PWM generator. + * + * @param pwmGenerator The pwmGen to free that was allocated with AllocateDO_PWM() + */ +void freePWMWithModule(uint8_t module, void* pwmGenerator, int32_t *status) { + uint32_t id = *((uint32_t*) pwmGenerator); + if (id == ~0ul) return; + DO_PWMGenerators->Free(id); +} + +/** + * Change the frequency of the DO PWM generator. + * + * The valid range is from 0.6 Hz to 19 kHz. The frequency resolution is logarithmic. + * + * @param rate The frequency to output all digital output PWM signals on this module. + */ +void setPWMRate(double rate, int32_t *status) { + setPWMRateWithModule(0, rate, status); +} + +/** + * Change the frequency of the DO PWM generator. + * + * The valid range is from 0.6 Hz to 19 kHz. The frequency resolution is logarithmic. + * + * @param rate The frequency to output all digital output PWM signals on this module. + */ +void setPWMRateWithModule(uint8_t module, double rate, int32_t *status) { + // Currently rounding in the log rate domain... heavy weight toward picking a higher freq. + // TODO: Round in the linear rate domain. + uint8_t pwmPeriodPower = (uint8_t)(log(1.0 / (pwmSystem->readLoopTiming(status) * 0.25E-6 * rate))/log(2.0) + 0.5); + digitalSystem->writePWMConfig_PeriodPower(pwmPeriodPower, status); +} + +/** + * Configure the duty-cycle of the PWM generator + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param dutyCycle The percent duty cycle to output [0..1]. + */ +void setPWMDutyCycle(void* pwmGenerator, double dutyCycle, int32_t *status) { + setPWMDutyCycleWithModule(0, pwmGenerator, dutyCycle, status); +} + +/** + * Configure the duty-cycle of the PWM generator + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param dutyCycle The percent duty cycle to output [0..1]. + */ +void setPWMDutyCycleWithModule(uint8_t module, void* pwmGenerator, double dutyCycle, int32_t *status) { + uint32_t id = *((uint32_t*) pwmGenerator); + if (id == ~0ul) return; + if (dutyCycle > 1.0) dutyCycle = 1.0; + if (dutyCycle < 0.0) dutyCycle = 0.0; + float rawDutyCycle = 256.0 * dutyCycle; + if (rawDutyCycle > 255.5) rawDutyCycle = 255.5; + { + Synchronized sync(digitalPwmSemaphore); + uint8_t pwmPeriodPower = digitalSystem->readPWMConfig_PeriodPower(status); + if (pwmPeriodPower < 4) { + // The resolution of the duty cycle drops close to the highest frequencies. + rawDutyCycle = rawDutyCycle / pow(2.0, 4 - pwmPeriodPower); + } + digitalSystem->writePWMDutyCycle(id, (uint8_t)rawDutyCycle, status); + } +} + +/** + * Configure which DO channel the PWM siganl is output on + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param channel The Digital Output channel to output on + */ +void setPWMOutputChannel(void* pwmGenerator, uint32_t pin, int32_t *status) { + setPWMOutputChannelWithModule(0, pwmGenerator, pin, status); +} + +/** + * Configure which DO channel the PWM siganl is output on + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param channel The Digital Output channel to output on + */ +void setPWMOutputChannelWithModule(uint8_t module, void* pwmGenerator, uint32_t pin, int32_t *status) { + uint32_t id = *((uint32_t*) pwmGenerator); + if (id == ~0ul) return; + switch(id) { + case 0: + digitalSystem->writePWMConfig_OutputSelect_0(remapDigitalChannel(pin - 1, status), status); + break; + case 1: + digitalSystem->writePWMConfig_OutputSelect_1(remapDigitalChannel(pin - 1, status), status); + break; + case 2: + digitalSystem->writePWMConfig_OutputSelect_2(remapDigitalChannel(pin - 1, status), status); + break; + case 3: + digitalSystem->writePWMConfig_OutputSelect_3(remapDigitalChannel(pin - 1, status), status); + break; + } +} + +/** + * Set the state of a relay. + * Set the state of a relay output to be forward. Relays have two outputs and each is + * independently set to 0v or 12v. + */ +void setRelayForward(void* digital_port_pointer, bool on, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkRelayChannel(port); + { + Synchronized sync(digitalRelaySemaphore); + uint8_t forwardRelays = relaySystem->readValue_Forward(status); + if (on) + forwardRelays |= 1 << (port->port.pin - 1); + else + forwardRelays &= ~(1 << (port->port.pin - 1)); + relaySystem->writeValue_Forward(forwardRelays, status); + } +} + +/** + * Set the state of a relay. + * Set the state of a relay output to be reverse. Relays have two outputs and each is + * independently set to 0v or 12v. + */ +void setRelayReverse(void* digital_port_pointer, bool on, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkRelayChannel(port); + { + Synchronized sync(digitalRelaySemaphore); + uint8_t reverseRelays = relaySystem->readValue_Reverse(status); + if (on) + reverseRelays |= 1 << (port->port.pin - 1); + else + reverseRelays &= ~(1 << (port->port.pin - 1)); + relaySystem->writeValue_Reverse(reverseRelays, status); + } +} + +/** + * Get the current state of the forward relay channel + */ +bool getRelayForward(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint8_t forwardRelays = relaySystem->readValue_Forward(status); + return (forwardRelays & (1 << (port->port.pin - 1))) != 0; +} + +/** + * Get the current state of the reverse relay channel + */ +bool getRelayReverse(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint8_t reverseRelays = relaySystem->readValue_Reverse(status); + return (reverseRelays & (1 << (port->port.pin - 1))) != 0; +} + +/** + * Allocate Digital I/O channels. + * Allocate channels so that they are not accidently reused. Also the direction is set at the + * time of the allocation. + * + * @param channel The Digital I/O channel + * @param input If true open as input; if false open as output + * @return Was successfully allocated + */ +bool allocateDIO(void* digital_port_pointer, bool input, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + char buf[64]; + snprintf(buf, 64, "DIO %d (Module %d)", port->port.pin, port->port.module); + if (DIOChannels->Allocate(kDigitalPins * (port->port.module - 1) + port->port.pin - 1, buf) == ~0ul) return false; + { + Synchronized sync(digitalDIOSemaphore); + uint32_t bitToSet = 1 << (remapDigitalChannel(port->port.pin - 1, status)); + tDIO::tOutputEnable outputEnable = digitalSystem->readOutputEnable(status); + if (input) { + outputEnable.value = outputEnable.value & (~bitToSet); // clear the bit for read + } else { + outputEnable.value = outputEnable.value | bitToSet; // set the bit for write + } + digitalSystem->writeOutputEnable(outputEnable, status); + } + return true; +} + +/** + * Free the resource associated with a digital I/O channel. + * + * @param channel The Digital I/O channel to free + */ +void freeDIO(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + DIOChannels->Free(kDigitalPins * (port->port.module - 1) + port->port.pin - 1); +} + +/** + * Write a digital I/O bit to the FPGA. + * Set a single value on a digital I/O channel. + * + * @param channel The Digital I/O channel + * @param value The state to set the digital channel (if it is configured as an output) + */ +void setDIO(void* digital_port_pointer, short value, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + if (value != 0 && value != 1) { + if (value != 0) + value = 1; + } + { + Synchronized sync(digitalDIOSemaphore); + tDIO::tDO currentDIO = digitalSystem->readDO(status); + if(value == 0) { + currentDIO.Headers = currentDIO.Headers & ~(1 << remapDigitalChannel(port->port.pin - 1, status)); + } else if (value == 1) { + currentDIO.Headers = currentDIO.Headers | (1 << remapDigitalChannel(port->port.pin - 1, status)); + } + digitalSystem->writeDO(currentDIO, status); + } +} + +/** + * Read a digital I/O bit from the FPGA. + * Get a single value from a digital I/O channel. + * + * @param channel The digital I/O channel + * @return The state of the specified channel + */ +bool getDIO(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + tDIO::tDI currentDIO = digitalSystem->readDI(status); + //Shift 00000001 over channel-1 places. + //AND it against the currentDIO + //if it == 0, then return false + //else return true + + return ((currentDIO.Headers >> remapDigitalChannel(port->port.pin - 1, status)) & 1) != 0; +} + +/** + * Read the direction of a the Digital I/O lines + * A 1 bit means output and a 0 bit means input. + * + * @param channel The digital I/O channel + * @return The direction of the specified channel + */ +bool getDIODirection(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + tDIO::tOutputEnable currentOutputEnable = digitalSystem->readOutputEnable(status); + + //Shift 00000001 over port->port.pin-1 places. + //AND it against the currentOutputEnable + //if it == 0, then return false + //else return true + return ((currentOutputEnable.value >> remapDigitalChannel(port->port.pin - 1, status)) & 1) != 0; +} + +/** + * Generate a single pulse. + * Write a pulse to the specified digital output channel. There can only be a single pulse going at any time. + * + * @param channel The Digital Output channel that the pulse should be output on + * @param pulseLength The active length of the pulse (in seconds) + */ +void pulse(void* digital_port_pointer, double pulseLength, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + tDIO::tPulse pulse; + pulse.value = 1 << remapDigitalChannel(port->port.pin - 1, status); + digitalSystem->writePulseLength((uint8_t)(1.0e9 * pulseLength / (pwmSystem->readLoopTiming(status) * 25)), status); + digitalSystem->writePulse(pulse, status); +} + +/** + * Check a DIO line to see if it is currently generating a pulse. + * + * @return A pulse is in progress + */ +bool isPulsing(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint16_t mask = 1 << remapDigitalChannel(port->port.pin - 1, status); + tDIO::tPulse pulseRegister = digitalSystem->readPulse(status); + return (pulseRegister.value & mask) != 0; +} + +/** + * Check if any DIO line is currently generating a pulse. + * + * @return A pulse on some line is in progress + */ +bool isAnyPulsing(int32_t *status) { + return isAnyPulsingWithModule(1, status) || isAnyPulsingWithModule(2, status); +} + +/** + * Check if any DIO line is currently generating a pulse. + * + * @return A pulse on some line is in progress + */ +bool isAnyPulsingWithModule(uint8_t module, int32_t *status) { + tDIO::tPulse pulseRegister = digitalSystem->readPulse(status); + return pulseRegister.value != 0; +} + + + +struct counter_t { + tCounter* counter; + uint32_t index; +}; +typedef struct counter_t Counter; + +static Resource *counters = NULL; + +void* initializeCounter(Mode mode, uint32_t *index, int32_t *status) { + Resource::CreateResourceObject(&counters, tCounter::kNumSystems); + *index = counters->Allocate("Counter"); + if (*index == ~0ul) { + *status = NO_AVAILABLE_RESOURCES; + return NULL; + } + Counter* counter = new Counter(); + counter->counter = tCounter::create(*index, status); + counter->counter->writeConfig_Mode(mode, status); + counter->counter->writeTimerConfig_AverageSize(1, status); + counter->index = *index; + return counter; +} + +void freeCounter(void* counter_pointer, int32_t *status) { + if (counter_pointer != NULL) { + Counter* counter = (Counter*) counter_pointer; + delete counter->counter; + counters->Free(counter->index); + } else { + *status = NULL_PARAMETER; + } +} + +void setCounterAverageSize(void* counter_pointer, int32_t size, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeTimerConfig_AverageSize(size, status); +} + +/** + * Set the source object that causes the counter to count up. + * Set the up counting DigitalSource. + */ +void setCounterUpSourceWithModule(void* counter_pointer, uint8_t module, uint32_t pin, + bool analogTrigger, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + + counter->counter->writeConfig_UpSource_Module(module, status); + counter->counter->writeConfig_UpSource_Channel(pin, status); + counter->counter->writeConfig_UpSource_AnalogTrigger(analogTrigger, status); + + if(counter->counter->readConfig_Mode(status) == kTwoPulse || + counter->counter->readConfig_Mode(status) == kExternalDirection) { + setCounterUpSourceEdge(counter_pointer, true, false, status); + } + counter->counter->strobeReset(status); +} + +/** + * Set the edge sensitivity on an up counting source. + * Set the up source to either detect rising edges or falling edges. + */ +void setCounterUpSourceEdge(void* counter_pointer, bool risingEdge, bool fallingEdge, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_UpRisingEdge(risingEdge, status); + counter->counter->writeConfig_UpFallingEdge(fallingEdge, status); +} + +/** + * Disable the up counting source to the counter. + */ +void clearCounterUpSource(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + bool state = counter->counter->readConfig_Enable(status); + counter->counter->writeConfig_Enable(false, status); + counter->counter->writeConfig_UpFallingEdge(false, status); + counter->counter->writeConfig_UpRisingEdge(false, status); + // Index 0 of digital is always 0. + counter->counter->writeConfig_UpSource_Channel(0, status); + counter->counter->writeConfig_UpSource_AnalogTrigger(false, status); + counter->counter->writeConfig_Enable(state, status); +} + +/** + * Set the source object that causes the counter to count down. + * Set the down counting DigitalSource. + */ +void setCounterDownSourceWithModule(void* counter_pointer, uint8_t module, uint32_t pin, + bool analogTrigger, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + unsigned char mode = counter->counter->readConfig_Mode(status); + if (mode != kTwoPulse && mode != kExternalDirection) { + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "Counter only supports DownSource in TwoPulse and ExternalDirection modes."); + *status = PARAMETER_OUT_OF_RANGE; + return; + } + counter->counter->writeConfig_DownSource_Module(module, status); + counter->counter->writeConfig_DownSource_Channel(pin, status); + counter->counter->writeConfig_DownSource_AnalogTrigger(analogTrigger, status); + + setCounterDownSourceEdge(counter_pointer, true, false, status); + counter->counter->strobeReset(status); +} + +/** + * Set the edge sensitivity on a down counting source. + * Set the down source to either detect rising edges or falling edges. + */ +void setCounterDownSourceEdge(void* counter_pointer, bool risingEdge, bool fallingEdge, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_DownRisingEdge(risingEdge, status); + counter->counter->writeConfig_DownFallingEdge(fallingEdge, status); +} + +/** + * Disable the down counting source to the counter. + */ +void clearCounterDownSource(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + bool state = counter->counter->readConfig_Enable(status); + counter->counter->writeConfig_Enable(false, status); + counter->counter->writeConfig_DownFallingEdge(false, status); + counter->counter->writeConfig_DownRisingEdge(false, status); + // Index 0 of digital is always 0. + counter->counter->writeConfig_DownSource_Channel(0, status); + counter->counter->writeConfig_DownSource_AnalogTrigger(false, status); + counter->counter->writeConfig_Enable(state, status); +} + +/** + * Set standard up / down counting mode on this counter. + * Up and down counts are sourced independently from two inputs. + */ +void setCounterUpDownMode(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kTwoPulse, status); +} + +/** + * Set external direction mode on this counter. + * Counts are sourced on the Up counter input. + * The Down counter input represents the direction to count. + */ +void setCounterExternalDirectionMode(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kExternalDirection, status); +} + +/** + * Set Semi-period mode on this counter. + * Counts up on both rising and falling edges. + */ +void setCounterSemiPeriodMode(void* counter_pointer, bool highSemiPeriod, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kSemiperiod, status); + counter->counter->writeConfig_UpRisingEdge(highSemiPeriod, status); + setCounterUpdateWhenEmpty(counter_pointer, false, status); +} + +/** + * Configure the counter to count in up or down based on the length of the input pulse. + * This mode is most useful for direction sensitive gear tooth sensors. + * @param threshold The pulse length beyond which the counter counts the opposite direction. Units are seconds. + */ +void setCounterPulseLengthMode(void* counter_pointer, double threshold, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kPulseLength, status); + counter->counter->writeConfig_PulseLengthThreshold((uint32_t)(threshold * 1.0e6) * kSystemClockTicksPerMicrosecond, status); +} + +/** + * Get the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @return SamplesToAverage The number of samples being averaged (from 1 to 127) + */ +int32_t getCounterSamplesToAverage(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + return counter->counter->readTimerConfig_AverageSize(status); +} + +/** + * Set the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @param samplesToAverage The number of samples to average from 1 to 127. + */ +void setCounterSamplesToAverage(void* counter_pointer, int samplesToAverage, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + if (samplesToAverage < 1 || samplesToAverage > 127) { + *status = PARAMETER_OUT_OF_RANGE; + } + counter->counter->writeTimerConfig_AverageSize(samplesToAverage, status); +} + +/** + * Start the Counter counting. + * This enables the counter and it starts accumulating counts from the associated + * input channel. The counter value is not reset on starting, and still has the previous value. + */ +void startCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Enable(1, status); +} + +/** + * Stop the Counter. + * Stops the counting but doesn't effect the current value. + */ +void stopCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Enable(0, status); +} + +/** + * Reset the Counter to zero. + * Set the counter value to zero. This doesn't effect the running state of the counter, just sets + * the current value to zero. + */ +void resetCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->strobeReset(status); +} + +/** + * Read the current counter value. + * Read the value at this instant. It may still be running, so it reflects the current value. Next + * time it is read, it might have a different value. + */ +int32_t getCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + int32_t value = counter->counter->readOutput_Value(status); + return value; +} + +/* + * Get the Period of the most recent count. + * Returns the time interval of the most recent count. This can be used for velocity calculations + * to determine shaft speed. + * @returns The period of the last two pulses in units of seconds. + */ +double getCounterPeriod(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + tCounter::tTimerOutput output = counter->counter->readTimerOutput(status); + double period; + if (output.Stalled) { + // Return infinity + double zero = 0.0; + period = 1.0 / zero; + } else { + // output.Period is a fixed point number that counts by 2 (24 bits, 25 integer bits) + period = (double)(output.Period << 1) / (double)output.Count; + } + return period * 1.0e-6; +} + +/** + * Set the maximum period where the device is still considered "moving". + * Sets the maximum period where the device is considered moving. This value is used to determine + * the "stopped" state of the counter using the GetStopped method. + * @param maxPeriod The maximum period where the counted device is considered moving in + * seconds. + */ +void setCounterMaxPeriod(void* counter_pointer, double maxPeriod, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 1.0e6), status); +} + +/** + * Select whether you want to continue updating the event timer output when there are no samples captured. + * The output of the event timer has a buffer of periods that are averaged and posted to + * a register on the FPGA. When the timer detects that the event source has stopped + * (based on the MaxPeriod) the buffer of samples to be averaged is emptied. If you + * enable the update when empty, you will be notified of the stopped source and the event + * time will report 0 samples. If you disable update when empty, the most recent average + * will remain on the output until a new sample is acquired. You will never see 0 samples + * output (except when there have been no events since an FPGA reset) and you will likely not + * see the stopped bit become true (since it is updated at the end of an average and there are + * no samples to average). + */ +void setCounterUpdateWhenEmpty(void* counter_pointer, bool enabled, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeTimerConfig_UpdateWhenEmpty(enabled, status); +} + +/** + * Determine if the clock is stopped. + * Determine if the clocked input is stopped based on the MaxPeriod value set using the + * SetMaxPeriod method. If the clock exceeds the MaxPeriod, then the device (and counter) are + * assumed to be stopped and it returns true. + * @return Returns true if the most recent counter period exceeds the MaxPeriod value set by + * SetMaxPeriod. + */ +bool getCounterStopped(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + return counter->counter->readTimerOutput_Stalled(status); +} + +/** + * The last direction the counter value changed. + * @return The last direction the counter value changed. + */ +bool getCounterDirection(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + bool value = counter->counter->readOutput_Direction(status); + return value; +} + +/** + * Set the Counter to return reversed sensing on the direction. + * This allows counters to change the direction they are counting in the case of 1X and 2X + * quadrature encoding only. Any other counter mode isn't supported. + * @param reverseDirection true if the value counted should be negated. + */ +void setCounterReverseDirection(void* counter_pointer, bool reverseDirection, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + if (counter->counter->readConfig_Mode(status) == kExternalDirection) { + if (reverseDirection) + setCounterDownSourceEdge(counter_pointer, true, true, status); + else + setCounterDownSourceEdge(counter_pointer, false, true, status); + } +} + +struct encoder_t { + tEncoder* encoder; + uint32_t index; +}; +typedef struct encoder_t Encoder; + +static const double DECODING_SCALING_FACTOR = 0.25; +static Resource *quadEncoders = NULL; + +void* initializeEncoder(uint8_t port_a_module, uint32_t port_a_pin, bool port_a_analog_trigger, + uint8_t port_b_module, uint32_t port_b_pin, bool port_b_analog_trigger, + bool reverseDirection, int32_t *index, int32_t *status) { + + // Initialize encoder structure + Encoder* encoder = new Encoder(); + + Resource::CreateResourceObject(&quadEncoders, tEncoder::kNumSystems); + encoder->index = quadEncoders->Allocate("4X Encoder"); + *index = encoder->index; + // TODO: if (index == ~0ul) { CloneError(quadEncoders); return; } + encoder->encoder = tEncoder::create(encoder->index, status); + encoder->encoder->writeConfig_ASource_Module(port_a_module, status); + encoder->encoder->writeConfig_ASource_Channel(port_a_pin, status); + encoder->encoder->writeConfig_ASource_AnalogTrigger(port_a_analog_trigger, status); + encoder->encoder->writeConfig_BSource_Module(port_b_module, status); + encoder->encoder->writeConfig_BSource_Channel(port_b_pin, status); + encoder->encoder->writeConfig_BSource_AnalogTrigger(port_b_analog_trigger, status); + encoder->encoder->strobeReset(status); + encoder->encoder->writeConfig_Reverse(reverseDirection, status); + encoder->encoder->writeTimerConfig_AverageSize(4, status); + + return encoder; +} + +void freeEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + quadEncoders->Free(encoder->index); + delete encoder->encoder; +} + +/** + * Start the Encoder. + * Starts counting pulses on the Encoder device. + */ +void startEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeConfig_Enable(1, status); +} + +/** + * Stops counting pulses on the Encoder device. The value is not changed. + */ +void stopEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeConfig_Enable(0, status); +} + +/** + * Reset the Encoder distance to zero. + * Resets the current count to zero on the encoder. + */ +void resetEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->strobeReset(status); +} + +/** + * Gets the raw value from the encoder. + * The raw value is the actual count unscaled by the 1x, 2x, or 4x scale + * factor. + * @return Current raw count from the encoder + */ +int32_t getEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readOutput_Value(status); +} + +/** + * Returns the period of the most recent pulse. + * Returns the period of the most recent Encoder pulse in seconds. + * This method compenstates for the decoding type. + * + * @deprecated Use GetRate() in favor of this method. This returns unscaled periods and GetRate() scales using value from SetDistancePerPulse(). + * + * @return Period in seconds of the most recent pulse. + */ +double getEncoderPeriod(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + tEncoder::tTimerOutput output = encoder->encoder->readTimerOutput(status); + double value; + if (output.Stalled) { + // Return infinity + double zero = 0.0; + value = 1.0 / zero; + } else { + // output.Period is a fixed point number that counts by 2 (24 bits, 25 integer bits) + value = (double)(output.Period << 1) / (double)output.Count; + } + double measuredPeriod = value * 1.0e-6; + return measuredPeriod / DECODING_SCALING_FACTOR; +} + +/** + * Sets the maximum period for stopped detection. + * Sets the value that represents the maximum period of the Encoder before it will assume + * that the attached device is stopped. This timeout allows users to determine if the wheels or + * other shaft has stopped rotating. + * This method compensates for the decoding type. + * + * @deprecated Use SetMinRate() in favor of this method. This takes unscaled periods and SetMinRate() scales using value from SetDistancePerPulse(). + * + * @param maxPeriod The maximum time between rising and falling edges before the FPGA will + * report the device stopped. This is expressed in seconds. + */ +void setEncoderMaxPeriod(void* encoder_pointer, double maxPeriod, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 1.0e6 * DECODING_SCALING_FACTOR), status); +} + +/** + * Determine if the encoder is stopped. + * Using the MaxPeriod value, a boolean is returned that is true if the encoder is considered + * stopped and false if it is still moving. A stopped encoder is one where the most recent pulse + * width exceeds the MaxPeriod. + * @return True if the encoder is considered stopped. + */ +bool getEncoderStopped(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readTimerOutput_Stalled(status) != 0; +} + +/** + * The last direction the encoder value changed. + * @return The last direction the encoder value changed. + */ +bool getEncoderDirection(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readOutput_Direction(status); +} + +/** + * Set the direction sensing for this encoder. + * This sets the direction sensing on the encoder so that it could count in the correct + * software direction regardless of the mounting. + * @param reverseDirection true if the encoder direction should be reversed + */ +void setEncoderReverseDirection(void* encoder_pointer, bool reverseDirection, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeConfig_Reverse(reverseDirection, status); +} + +/** + * Set the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @param samplesToAverage The number of samples to average from 1 to 127. + */ +void setEncoderSamplesToAverage(void* encoder_pointer, uint32_t samplesToAverage, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + if (samplesToAverage < 1 || samplesToAverage > 127) { + *status = PARAMETER_OUT_OF_RANGE; + } + encoder->encoder->writeTimerConfig_AverageSize(samplesToAverage, status); +} + +/** + * Get the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @return SamplesToAverage The number of samples being averaged (from 1 to 127) + */ +uint32_t getEncoderSamplesToAverage(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readTimerConfig_AverageSize(status); +} + +/** + * Get the loop timing of the Digital Module + * + * @return The loop time + */ +uint16_t getLoopTiming(int32_t *status) { + return getLoopTimingWithModule(1, status); +} + +/** + * Get the loop timing of the Digital Module + * + * @return The loop time + */ +uint16_t getLoopTimingWithModule(uint8_t module, int32_t *status) { + return pwmSystem->readLoopTiming(status); +} + +// XXX: What happened to SPI? +// struct spi_t { +// tSPI* spi; +// tSPI::tConfig config; +// tSPI::tChannels channels; +// MUTEX_ID semaphore; +// }; +// typedef struct spi_t SPI; + +// void* initializeSPI(uint8_t sclk_routing_module, uint32_t sclk_routing_pin, +// uint8_t mosi_routing_module, uint32_t mosi_routing_pin, +// uint8_t miso_routing_module, uint32_t miso_routing_pin, int32_t *status) { +// SPI* spi = new SPI(); + +// spi->semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + +// spi->spi = tSPI::create(status); + +// spi->config.BusBitWidth = 8; +// spi->config.ClockHalfPeriodDelay = 0; +// spi->config.MSBfirst = 0; +// spi->config.DataOnFalling = 0; +// spi->config.LatchFirst = 0; +// spi->config.LatchLast = 0; +// spi->config.FramePolarity = 0; +// spi->config.WriteOnly = miso_routing_pin ? 0 : 1; +// spi->config.ClockPolarity = 0; + +// spi->channels.SCLK_Channel = sclk_routing_pin; +// spi->channels.SCLK_Module = sclk_routing_module; +// spi->channels.SS_Channel = 0; +// spi->channels.SS_Module = 0; + +// if (mosi_routing_pin) { +// spi->channels.MOSI_Channel = mosi_routing_pin; +// spi->channels.MOSI_Module = mosi_routing_module; +// } else { +// spi->channels.MOSI_Channel = 0; +// spi->channels.MOSI_Module = 0; +// } + +// if (miso_routing_pin) { +// spi->channels.MISO_Channel = miso_routing_pin; +// spi->channels.MISO_Module = miso_routing_module; +// } else { +// spi->channels.MISO_Channel = 0; +// spi->channels.MISO_Module = 0; +// } +// return spi; +// } + +// void cleanSPI(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// delete spi->spi; +// delete spi; +// } + +// /** +// * Configure the number of bits from each word that the slave transmits +// * or receives. +// * +// * @param bits The number of bits in one frame (1 to 32 bits). +// */ +// void setSPIBitsPerWord(void* spi_pointer, uint32_t bits, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->config.BusBitWidth = bits; +// } + +// /** +// * Get the number of bits from each word that the slave transmits +// * or receives. +// * +// * @return The number of bits in one frame (1 to 32 bits). +// */ +// uint32_t getSPIBitsPerWord(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// return spi->config.BusBitWidth; +// } + +// /** +// * Configure the rate of the generated clock signal. +// * The default and maximum value is 76,628.4 Hz. +// * +// * @param hz The clock rate in Hertz. +// */ +// void setSPIClockRate(void* spi_pointer, double hz, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// int delay = 0; +// int loopTiming = getLoopTimingWithModule(spi->spi->readChannels_SCLK_Module(status), status); +// double v = (1.0 / hz) / (2 * loopTiming / (kSystemClockTicksPerMicrosecond * 1e6)); +// if (v < 1) { +// // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "SPI Clock too high"); +// } +// delay = (int) (v + .5); +// if (delay > 255) { +// // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "SPI Clock too low"); +// } + +// spi->config.ClockHalfPeriodDelay = delay; +// } + +// /** +// * Configure the order that bits are sent and received on the wire +// * to be most significant bit first. +// */ +// void setSPIMSBFirst(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->config.MSBfirst = 1; +// } + +// /** +// * Configure the order that bits are sent and received on the wire +// * to be least significant bit first. +// */ +// void setSPILSBFirst(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->config.MSBfirst = 0; +// } + +// /** +// * Configure that the data is stable on the falling edge and the data +// * changes on the rising edge. +// */ +// void setSPISampleDataOnFalling(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->config.DataOnFalling = 1; +// } + +// /** +// * Configure that the data is stable on the rising edge and the data +// * changes on the falling edge. +// */ +// void setSPISampleDataOnRising(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->config.DataOnFalling = 0; +// } + +// void setSPISlaveSelect(void* spi_pointer, uint8_t ss_routing_module, uint32_t ss_routing_pin, +// int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->channels.SS_Channel = ss_routing_pin; +// spi->channels.SS_Module = ss_routing_module; +// } + +// void setSPILatchMode(void* spi_pointer, tFrameMode mode, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// switch (mode) { +// case kChipSelect: +// spi->config.LatchFirst = 0; +// spi->config.LatchLast = 0; +// break; +// case kPreLatchPulse: +// spi->config.LatchFirst = 1; +// spi->config.LatchLast = 0; +// break; +// case kPostLatchPulse: +// spi->config.LatchFirst = 0; +// spi->config.LatchLast = 1; +// break; +// case kPreAndPostLatchPulse: +// spi->config.LatchFirst = 1; +// spi->config.LatchLast = 1; +// break; +// } +// } + +// tFrameMode getSPILatchMode(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// return (tFrameMode) (spi->config.LatchFirst | (spi->config.LatchLast << 1)); +// } + +// void setSPIFramePolarity(void* spi_pointer, bool activeLow, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->config.FramePolarity = activeLow ? 1 : 0; +// } + +// bool getSPIFramePolarity(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// return spi->config.FramePolarity != 0; +// } + +// /** +// * Configure the clock output line to be active low. +// * This is sometimes called clock polarity high. +// */ +// void setSPIClockActiveLow(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->config.ClockPolarity = 1; +// } + +// /** +// * Configure the clock output line to be active high. +// * This is sometimes called clock polarity low. +// */ +// void setSPIClockActiveHigh(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->config.ClockPolarity = 0; +// } + + +// /** +// * Apply configuration settings and reset the SPI logic. +// */ +// void applySPIConfig(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// Synchronized sync(spi->semaphore); + +// spi->spi->writeConfig(spi->config, status); +// spi->spi->writeChannels(spi->channels, status); +// spi->spi->strobeReset(status); +// } + +// /** +// * Get the number of words that can currently be stored before being +// * transmitted to the device. +// * +// * @return The number of words available to be written. +// */ +// uint16_t getSPIOutputFIFOAvailable(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// uint16_t result = spi->spi->readAvailableToLoad(status); +// return result; +// } + +// /** +// * Get the number of words received and currently available to be read from +// * the receive FIFO. +// * +// * @return The number of words available to read. +// */ +// uint16_t getSPINumReceived(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// uint16_t result = spi->spi->readReceivedElements(status); +// return result; +// } + +// /** +// * Have all pending transfers completed? +// * +// * @return True if no transfers are pending. +// */ +// bool isSPIDone(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// bool result = spi->spi->readStatus_Idle(status); +// return result; +// } + + +// /** +// * Determine if the receive FIFO was full when attempting to add new data at +// * end of a transfer. +// * +// * @return True if the receive FIFO overflowed. +// */ +// bool hadSPIReceiveOverflow(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// bool result = spi->spi->readStatus_ReceivedDataOverflow(status); +// return result; +// } + +// /** +// * Write a word to the slave device. Blocks until there is space in the +// * output FIFO. +// * +// * If not running in output only mode, also saves the data received +// * on the MISO input during the transfer into the receive FIFO. +// */ +// void writeSPI(void* spi_pointer, uint32_t data, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// if (spi->channels.MOSI_Channel == 0 && spi->channels.MOSI_Module == 0) { +// *status = SPI_WRITE_NO_MOSI; +// return; +// } + +// Synchronized sync(spi->semaphore); + +// while (getSPIOutputFIFOAvailable(spi_pointer, status) == 0) +// delayTicks(HAL_NO_WAIT); + +// spi->spi->writeDataToLoad(data, status); +// spi->spi->strobeLoad(status); +// } + +// /** +// * Read a word from the receive FIFO. +// * +// * Waits for the current transfer to complete if the receive FIFO is empty. +// * +// * If the receive FIFO is empty, there is no active transfer, and initiate +// * is false, errors. +// * +// * @param initiate If true, this function pushes "0" into the +// * transmit buffer and initiates a transfer. +// * If false, this function assumes that data is +// * already in the receive FIFO from a previous write. +// */ +// uint32_t readSPI(void* spi_pointer, bool initiate, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// if (spi->channels.MISO_Channel == 0 && spi->channels.MISO_Module == 0) { +// *status = SPI_READ_NO_MISO; +// return 0; +// } + +// uint32_t data; +// { +// Synchronized sync(spi->semaphore); + +// if (initiate) { +// spi->spi->writeDataToLoad(0, status); +// spi->spi->strobeLoad(status); +// } + +// // Do we have anything ready to read? +// if (getSPINumReceived(spi_pointer, status) == 0) { +// if (!initiate && isSPIDone(spi_pointer, status) +// && getSPIOutputFIFOAvailable(spi_pointer, status) == kTransmitFIFODepth) { +// // Nothing to read: error out +// *status = SPI_READ_NO_DATA; +// return 0; +// } + +// // Wait for the transaction to complete +// while (getSPINumReceived(spi_pointer, status) == 0) +// delayTicks(HAL_NO_WAIT); +// } + +// spi->spi->strobeReadReceivedData(status); +// data = spi->spi->readReceivedData(status); +// } + +// return data; +// } + +// /** +// * Stop any transfer in progress and empty the transmit FIFO. +// */ +// void resetSPI(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->spi->strobeReset(status); +// } + +// /** +// * Empty the receive FIFO. +// */ +// void clearSPIReceivedData(void* spi_pointer, int32_t *status) { +// SPI* spi = (SPI*) spi_pointer; +// spi->spi->strobeClearReceivedData(status); +// } + + + +void* initializeSPI(uint8_t sclk_routing_module, uint32_t sclk_routing_pin, + uint8_t mosi_routing_module, uint32_t mosi_routing_pin, + uint8_t miso_routing_module, uint32_t miso_routing_pin, int32_t *status) { + return NULL; +} +void cleanSPI(void* spi_pointer, int32_t *status) {} +void setSPIBitsPerWord(void* spi_pointer, uint32_t bits, int32_t *status) {} +uint32_t getSPIBitsPerWord(void* spi_pointer, int32_t *status) { + return 0; +} +void setSPIClockRate(void* spi_pointer, double hz, int32_t *status) {} +void setSPIMSBFirst(void* spi_pointer, int32_t *status) {} +void setSPILSBFirst(void* spi_pointer, int32_t *status) {} +void setSPISampleDataOnFalling(void* spi_pointer, int32_t *status) {} +void setSPISampleDataOnRising(void* spi_pointer, int32_t *status) {} +void setSPISlaveSelect(void* spi_pointer, uint8_t ss_routing_module, uint32_t ss_routing_pin, + int32_t *status) {} +void setSPILatchMode(void* spi_pointer, tFrameMode mode, int32_t *status) {} +tFrameMode getSPILatchMode(void* spi_pointer, int32_t *status) { + return (tFrameMode) 0; +} +void setSPIFramePolarity(void* spi_pointer, bool activeLow, int32_t *status) {} +bool getSPIFramePolarity(void* spi_pointer, int32_t *status) { + return false; +} +void setSPIClockActiveLow(void* spi_pointer, int32_t *status) {} +void setSPIClockActiveHigh(void* spi_pointer, int32_t *status) {} +void applySPIConfig(void* spi_pointer, int32_t *status) {} +uint16_t getSPIOutputFIFOAvailable(void* spi_pointer, int32_t *status) { + return 0; +} +uint16_t getSPINumReceived(void* spi_pointer, int32_t *status) { + return 0; +} +bool isSPIDone(void* spi_pointer, int32_t *status) { + return false; +} +bool hadSPIReceiveOverflow(void* spi_pointer, int32_t *status) { + return false; +} +void writeSPI(void* spi_pointer, uint32_t data, int32_t *status) {} +uint32_t readSPI(void* spi_pointer, bool initiate, int32_t *status) {} +void resetSPI(void* spi_pointer, int32_t *status) {} +void clearSPIReceivedData(void* spi_pointer, int32_t *status) {} + +/** + * Generic transaction. + * + * This is a lower-level interface to the I2C hardware giving you more control over each transaction. + * + * @param dataToSend Buffer of data to send as part of the transaction. + * @param sendSize Number of bytes to send as part of the transaction. [0..6] + * @param dataReceived Buffer to read data into. + * @param receiveSize Number of byted to read from the device. [0..7] + * @return Transfer Aborted... false for success, true for aborted. + */ +bool doI2CTransaction(uint8_t address, bool compatibilityMode, uint8_t *dataToSend, + uint8_t sendSize, uint8_t *dataReceived, uint8_t receiveSize, + int32_t *status) { + return doI2CTransactionWithModule(1, address, compatibilityMode, dataToSend, sendSize, + dataReceived, receiveSize, status); +} + +/** + * Generic transaction. + * + * This is a lower-level interface to the I2C hardware giving you more control over each transaction. + * + * @param dataToSend Buffer of data to send as part of the transaction. + * @param sendSize Number of bytes to send as part of the transaction. [0..6] + * @param dataReceived Buffer to read data into. + * @param receiveSize Number of byted to read from the device. [0..7] + * @return Transfer Aborted... false for success, true for aborted. + */ +bool doI2CTransactionWithModule(uint8_t module, uint8_t address, bool compatibilityMode, + uint8_t *dataToSend, uint8_t sendSize, uint8_t *dataReceived, + uint8_t receiveSize, int32_t *status) { + // initializeDigital(status); + // if (sendSize > 6) { + // *status = PARAMETER_OUT_OF_RANGE; + // // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "sendSize"); + // return true; + // } + // if (receiveSize > 7) { + // *status = PARAMETER_OUT_OF_RANGE; + // // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "receiveSize"); + // return true; + // } + + // uint32_t data=0; + // uint32_t dataHigh=0; + // uint32_t i; + // for(i=0; iwriteI2CConfig_Address(address, status); + // digitalModules[module]->writeI2CConfig_BytesToWrite(sendSize, status); + // digitalModules[module]->writeI2CConfig_BytesToRead(receiveSize, status); + // if (sendSize > 0) digitalModules[module]->writeI2CDataToSend(data, status); + // if (sendSize > sizeof(data)) digitalModules[module]->writeI2CConfig_DataToSendHigh(dataHigh, status); + // digitalModules[module]->writeI2CConfig_BitwiseHandshake(compatibilityMode, status); + // uint8_t transaction = digitalModules[module]->readI2CStatus_Transaction(status); + // digitalModules[module]->strobeI2CStart(status); + // while(transaction == digitalModules[module]->readI2CStatus_Transaction(status)) delayTicks(1); + // while(!digitalModules[module]->readI2CStatus_Done(status)) delayTicks(1); + // aborted = digitalModules[module]->readI2CStatus_Aborted(status); + // if (receiveSize > 0) data = digitalModules[module]->readI2CDataReceived(status); + // if (receiveSize > sizeof(data)) dataHigh = digitalModules[module]->readI2CStatus_DataReceivedHigh(status); + // } + + // for(i=0; i> (8*i)) & 0xFF; + // } + // for(; i> (8*(i-sizeof(data)))) & 0xFF; + // } + // return aborted; + return false; // XXX: What happened to I2C? +} + + +//// Float JNA Hack +// double +void setPWMRateIntHack(int32_t rate, int32_t *status) { + setPWMRate(intToFloat(rate), status); +} + +void setPWMRateWithModuleIntHack(uint8_t module, int32_t rate, int32_t *status) { + setPWMRateWithModule(module, intToFloat(rate), status); +} + +void setPWMDutyCycleIntHack(void* pwmGenerator, int32_t dutyCycle, int32_t *status) { + setPWMDutyCycle(pwmGenerator, intToFloat(dutyCycle), status); +} + +void setPWMDutyCycleWithModuleIntHack(uint8_t module, void* pwmGenerator, int32_t dutyCycle, int32_t *status) { + setPWMDutyCycleWithModule(module, pwmGenerator, dutyCycle, status); +} diff --git a/hal/Athena/src/main/native/HAL.cpp b/hal/Athena/src/main/native/HAL.cpp new file mode 100644 index 0000000000..09c38da936 --- /dev/null +++ b/hal/Athena/src/main/native/HAL.cpp @@ -0,0 +1,125 @@ + +#include "HAL/HAL.h" + +#include "Port.h" +#include "HAL/Errors.h" +#include "ChipObject.h" + +// XXX: What to do with solenoids? const uint32_t solenoid_kNumDO7_0Elements = tSolenoid::kNumDO7_0Elements; +const uint32_t dio_kNumSystems = tDIO::kNumSystems; +const uint32_t interrupt_kNumSystems = tInterrupt::kNumSystems; +const uint32_t kSystemClockTicksPerMicrosecond = 40; + +void* getPort(uint8_t pin) { + Port* port = new Port(); + port->pin = pin; + port->module = 1; + return port; +} + +/** + * @deprecated Uses module numbers + */ +void* getPortWithModule(uint8_t module, uint8_t pin) { + Port* port = new Port(); + port->pin = pin; + port->module = module; + return port; +} + +const char* getHALErrorMessage(int32_t code) { + if (code == 0) return ""; + else if (code == SAMPLE_RATE_TOO_HIGH) return SAMPLE_RATE_TOO_HIGH_MESSAGE; + else if (code == VOLTAGE_OUT_OF_RANGE) return VOLTAGE_OUT_OF_RANGE_MESSAGE; + else if (code == LOOP_TIMING_ERROR) return LOOP_TIMING_ERROR_MESSAGE; + else if (code == SPI_WRITE_NO_MOSI) return SPI_WRITE_NO_MOSI_MESSAGE; + else if (code == SPI_READ_NO_MISO) return SPI_READ_NO_MISO_MESSAGE; + else if (code == SPI_READ_NO_DATA) return SPI_READ_NO_DATA_MESSAGE; + else if (code == INCOMPATIBLE_STATE) return INCOMPATIBLE_STATE_MESSAGE; + else if (code == NO_AVAILABLE_RESOURCES) return NO_AVAILABLE_RESOURCES_MESSAGE; + else if (code == NULL_PARAMETER) return NULL_PARAMETER_MESSAGE; + else if (code == ANALOG_TRIGGER_LIMIT_ORDER_ERROR) return ANALOG_TRIGGER_LIMIT_ORDER_ERROR_MESSAGE; + else if (code == ANALOG_TRIGGER_PULSE_OUTPUT_ERROR) return ANALOG_TRIGGER_PULSE_OUTPUT_ERROR_MESSAGE; + else if (code == PARAMETER_OUT_OF_RANGE) return PARAMETER_OUT_OF_RANGE_MESSAGE; + else return ""; +} + +/** + * Return the FPGA Version number. + * For now, expect this to be competition year. + * @return FPGA Version number. + */ +uint16_t getFPGAVersion(int32_t *status) { + tGlobal *global = tGlobal::create(status); + uint16_t version = global->readVersion(status); + delete global; + return version; +} + +/** + * Return the FPGA Revision number. + * The format of the revision is 3 numbers. + * The 12 most significant bits are the Major Revision. + * the next 8 bits are the Minor Revision. + * The 12 least significant bits are the Build Number. + * @return FPGA Revision number. + */ +uint32_t getFPGARevision(int32_t *status) { + tGlobal *global = tGlobal::create(status); + uint32_t revision = global->readRevision(status); + delete global; + return revision; +} + +/** + * Read the microsecond-resolution timer on the FPGA. + * + * @return The current time in microseconds according to the FPGA (since FPGA reset). + */ +uint32_t getFPGATime(int32_t *status) { + tGlobal *global = tGlobal::create(status); + uint32_t time = global->readLocalTime(status); + delete global; + return time; +} + + +/** + * Set the state of the FPGA status LED on the cRIO. + */ +void setFPGALED(uint32_t state, int32_t *status) { + // XXX: Not supported? + // tGlobal *global = tGlobal::create(status); + // global->writeFPGA_LED(state, status); + // delete global; +} + +/** + * Get the current state of the FPGA status LED on the cRIO. + * @return The curent state of the FPGA LED. + */ +int32_t getFPGALED(int32_t *status) { + // XXX: Not supported? + // tGlobal *global = tGlobal::create(status); + // bool ledValue = global->readFPGA_LED(status); + // delete global; + // return ledValue; + return 0; // XXX: Dummy value +} + +// TODO: HACKS +void NumericArrayResize() {} +void RTSetCleanupProc() {} +void EDVR_CreateReference() {} +void Occur() {} + +void imaqGetErrorText() {} +void imaqGetLastError() {} +void niTimestamp64() {} + +#include "NetworkCommunication/LoadOut.h" +namespace nLoadOut { + bool getModulePresence(tModuleType moduleType, uint8_t moduleNumber) { + return true; + } +} diff --git a/hal/Athena/src/main/native/Interrupts.cpp b/hal/Athena/src/main/native/Interrupts.cpp new file mode 100644 index 0000000000..c47f5769f4 --- /dev/null +++ b/hal/Athena/src/main/native/Interrupts.cpp @@ -0,0 +1,86 @@ + +#include "HAL/Interrupts.h" + +#include "ChipObject.h" + +struct interrupt_t { + tInterrupt *anInterrupt; + tInterruptManager *manager; +}; +typedef struct interrupt_t Interrupt; + +void* initializeInterrupts(uint32_t interruptIndex, bool watcher, int32_t *status) { + Interrupt* anInterrupt = new Interrupt(); + // Expects the calling leaf class to allocate an interrupt index. + anInterrupt->anInterrupt = tInterrupt::create(interruptIndex, status); + anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status); + anInterrupt->manager = new tInterruptManager(1 << interruptIndex, watcher, status); + return anInterrupt; +} + +void cleanInterrupts(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + delete anInterrupt->anInterrupt; + delete anInterrupt->manager; + anInterrupt->anInterrupt = NULL; + anInterrupt->manager = NULL; +} + +/** + * In synchronous mode, wait for the defined interrupt to occur. + * @param timeout Timeout in seconds + */ +void waitForInterrupt(void* interrupt_pointer, double timeout, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->watch((int32_t)(timeout * 1e3), status); +} + +/** + * Enable interrupts to occur on this input. + * oInterrupts are disabled when the RequestInterrupt call is made. This gives time to do the + * setup of the other options before starting to field interrupts. + */ +void enableInterrupts(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->enable(status); +} + +/** + * Disable Interrupts without without deallocating structures. + */ +void disableInterrupts(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->disable(status); +} + +/** + * Return the timestamp for the interrupt that occurred most recently. + * This is in the same time domain as GetClock(). + * @return Timestamp in seconds since boot. + */ +double readInterruptTimestamp(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + uint32_t timestamp = anInterrupt->anInterrupt->readTimeStamp(status); + return timestamp * 1e-6; +} + +void requestInterrupts(void* interrupt_pointer, uint8_t routing_module, uint32_t routing_pin, + bool routing_analog_trigger, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status); + anInterrupt->anInterrupt->writeConfig_Source_AnalogTrigger(routing_analog_trigger, status); + anInterrupt->anInterrupt->writeConfig_Source_Channel(routing_pin, status); + anInterrupt->anInterrupt->writeConfig_Source_Module(routing_module, status); +} + +void attachInterruptHandler(void* interrupt_pointer, InterruptHandlerFunction handler, + void* param, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->registerHandler(handler, param, status); +} + +void setInterruptUpSourceEdge(void* interrupt_pointer, bool risingEdge, bool fallingEdge, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->anInterrupt->writeConfig_RisingEdge(risingEdge, status); + anInterrupt->anInterrupt->writeConfig_FallingEdge(fallingEdge, status); +} diff --git a/hal/Athena/src/main/native/NetworkCommunication/AICalibration.h b/hal/Athena/src/main/native/NetworkCommunication/AICalibration.h new file mode 100644 index 0000000000..39755bda89 --- /dev/null +++ b/hal/Athena/src/main/native/NetworkCommunication/AICalibration.h @@ -0,0 +1,19 @@ + +#ifndef __AICalibration_h__ +#define __AICalibration_h__ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + uint32_t FRC_NetworkCommunication_nAICalibration_getLSBWeight(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status); + int32_t FRC_NetworkCommunication_nAICalibration_getOffset(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status); + +#ifdef __cplusplus +} +#endif + +#endif // __AICalibration_h__ diff --git a/hal/Athena/src/main/native/NetworkCommunication/LoadOut.h b/hal/Athena/src/main/native/NetworkCommunication/LoadOut.h new file mode 100644 index 0000000000..0304b30665 --- /dev/null +++ b/hal/Athena/src/main/native/NetworkCommunication/LoadOut.h @@ -0,0 +1,52 @@ + +#ifndef __LoadOut_h__ +#define __LoadOut_h__ + +#ifdef SIMULATION +#include +#define EXPORT_FUNC __declspec(dllexport) __cdecl +#elif defined (__vxworks) +#include +#define EXPORT_FUNC +#else +#include +#define EXPORT_FUNC +#endif + +#define kMaxModuleNumber 2 +namespace nLoadOut +{ + typedef enum { + kModuleType_Unknown = 0x00, + kModuleType_Analog = 0x01, + kModuleType_Digital = 0x02, + kModuleType_Solenoid = 0x03, + } tModuleType; + bool EXPORT_FUNC getModulePresence(tModuleType moduleType, uint8_t moduleNumber); + typedef enum { + kTargetClass_Unknown = 0x00, + kTargetClass_FRC1 = 0x10, + kTargetClass_FRC2 = 0x20, + kTargetClass_FRC3 = 0x30, + kTargetClass_RoboRIO = 0x40, + kTargetClass_FRC2_Analog = kTargetClass_FRC2 | kModuleType_Analog, + kTargetClass_FRC2_Digital = kTargetClass_FRC2 | kModuleType_Digital, + kTargetClass_FRC2_Solenoid = kTargetClass_FRC2 | kModuleType_Solenoid, + kTargetClass_FamilyMask = 0xF0, + kTargetClass_ModuleMask = 0x0F, + } tTargetClass; + tTargetClass EXPORT_FUNC getTargetClass(); +} + +#ifdef __cplusplus +extern "C" { +#endif + + uint32_t EXPORT_FUNC FRC_NetworkCommunication_nLoadOut_getModulePresence(uint32_t moduleType, uint8_t moduleNumber); + uint32_t EXPORT_FUNC FRC_NetworkCommunication_nLoadOut_getTargetClass(); + +#ifdef __cplusplus +} +#endif + +#endif // __LoadOut_h__ diff --git a/hal/Athena/src/main/native/Notifier.cpp b/hal/Athena/src/main/native/Notifier.cpp new file mode 100644 index 0000000000..8d9766b6c3 --- /dev/null +++ b/hal/Athena/src/main/native/Notifier.cpp @@ -0,0 +1,40 @@ + +#include "HAL/Notifier.h" + +#include "ChipObject.h" + +static const uint32_t kTimerInterruptNumber = 28; + +struct notifier_t { + tAlarm *alarm; + tInterruptManager *manager; +}; +typedef struct notifier_t Notifier; + +void* initializeNotifier(void (*ProcessQueue)(uint32_t, void*), int32_t *status) { + Notifier* notifier = new Notifier(); + notifier->manager = new tInterruptManager(1 << kTimerInterruptNumber, false, status); + notifier->manager->registerHandler(ProcessQueue, NULL, status); + notifier->manager->enable(status); + notifier->alarm = tAlarm::create(status); + return notifier; +} + +void cleanNotifier(void* notifier_pointer, int32_t *status) { + Notifier* notifier = (Notifier*) notifier_pointer; + notifier->alarm->writeEnable(false, status); + delete notifier->alarm; + notifier->alarm = NULL; + notifier->manager->disable(status); + delete notifier->manager; + notifier->manager = NULL; +} + + +void updateNotifierAlarm(void* notifier_pointer, uint32_t triggerTime, int32_t *status) { + Notifier* notifier = (Notifier*) notifier_pointer; + // write the first item in the queue into the trigger time + notifier->alarm->writeTriggerTime(triggerTime, status); + // Enable the alarm. The hardware disables itself after each alarm. + notifier->alarm->writeEnable(true, status); +} diff --git a/hal/Athena/src/main/native/Port.h b/hal/Athena/src/main/native/Port.h new file mode 100644 index 0000000000..433f318e92 --- /dev/null +++ b/hal/Athena/src/main/native/Port.h @@ -0,0 +1,11 @@ + +#ifndef HAL_PORT_H +#define HAL_PORT_H + +struct port_t { + uint8_t pin; + uint8_t module; +}; +typedef struct port_t Port; + +#endif diff --git a/hal/Athena/src/main/native/Semaphore.cpp b/hal/Athena/src/main/native/Semaphore.cpp new file mode 100644 index 0000000000..2cf2258216 --- /dev/null +++ b/hal/Athena/src/main/native/Semaphore.cpp @@ -0,0 +1,120 @@ + +#include "HAL/Semaphore.h" + +#include "ChipObject.h" + +// See: http://www.vxdev.com/docs/vx55man/vxworks/ref/semMLib.html +const uint32_t SEMAPHORE_Q_FIFO= 0x01; // TODO: Support +const uint32_t SEMAPHORE_Q_PRIORITY = 0x01; // TODO: Support +const uint32_t SEMAPHORE_DELETE_SAFE = 0x04; // TODO: Support +const uint32_t SEMAPHORE_INVERSION_SAFE = 0x08; // TODO: Support + +const int32_t SEMAPHORE_NO_WAIT = 0; +const int32_t SEMAPHORE_WAIT_FOREVER = -1; + +const uint32_t SEMAPHORE_EMPTY = 0; +const uint32_t SEMAPHORE_FULL = 1; + +MUTEX_ID initializeMutex(uint32_t flags) { + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + MUTEX_ID sem = new pthread_mutex_t(); + pthread_mutex_init(sem, &attr); + pthread_mutexattr_destroy(&attr); + return sem; +} + +void deleteMutex(MUTEX_ID sem) { + pthread_mutex_destroy(sem); + delete sem; +} + +/** + * Lock the semaphore, blocking until it's available. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t takeMutex(MUTEX_ID sem, int32_t timeout) { + if (timeout == SEMAPHORE_NO_WAIT) { + return pthread_mutex_trylock(sem); + } else if (timeout == SEMAPHORE_WAIT_FOREVER) { + return pthread_mutex_lock(sem); + } else { + // struct timespec test; + // return pthread_mutex_timedlock(sem, ); + return -1; // TODO: implement timed wait + } +} + +/** + * Unlock the semaphore. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t giveMutex(MUTEX_ID sem) { + // return semGive(sem); + // return sem_post(sem); + return pthread_mutex_unlock(sem); +} + +SEMAPHORE_ID initializeSemaphore(uint32_t flags, uint32_t initial_value) { + SEMAPHORE_ID sem = new sem_t; + sem_init(sem, 0, initial_value); + return sem; +} + +void deleteSemaphore(SEMAPHORE_ID sem) { + sem_destroy(sem); + delete sem; +} + +/** + * Lock the semaphore, blocking until it's available. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t takeSemaphore(SEMAPHORE_ID sem, int32_t timeout) { + if (timeout == SEMAPHORE_NO_WAIT) { + return sem_trywait(sem); + } else if (timeout == SEMAPHORE_WAIT_FOREVER) { + return sem_wait(sem); + } else { + // return sem_timedwait(sem, ); + return -1; // TODO: implement timed wait + } +} + +/** + * Unlock the semaphore. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t giveSemaphore(SEMAPHORE_ID sem) { + return sem_post(sem); +} + + +MULTIWAIT_ID initializeMultiWait() { + pthread_condattr_t attr; + pthread_condattr_init(&attr); + MULTIWAIT_ID cond = new pthread_cond_t(); + pthread_cond_init(cond, &attr); + pthread_condattr_destroy(&attr); + return cond; +} + +void deleteMultiWait(MULTIWAIT_ID sem) { + pthread_cond_destroy(sem); + delete sem; +} + +int8_t takeMultiWait(MULTIWAIT_ID sem, int32_t timeout) { + MUTEX_ID m = initializeMutex(NULL); + takeMutex(m, SEMAPHORE_WAIT_FOREVER); + int8_t val = pthread_cond_wait(sem, m); + deleteMutex(m); + return val; +} + +int8_t giveMultiWait(MULTIWAIT_ID sem) { + return pthread_cond_broadcast(sem); +} + + diff --git a/hal/Athena/src/main/native/Solenoid.cpp b/hal/Athena/src/main/native/Solenoid.cpp new file mode 100644 index 0000000000..758dcf37a4 --- /dev/null +++ b/hal/Athena/src/main/native/Solenoid.cpp @@ -0,0 +1,86 @@ + +#include "HAL/Solenoid.h" + +#include "Port.h" +#include "HAL/Errors.h" +#include "ChipObject.h" +#include "HAL/cpp/Synchronized.h" +#include "NetworkCommunication/LoadOut.h" + +// XXX No solenoid abstraction :( + +// struct solenoid_port_t { +// Port port; +// tSolenoid *module; +// uint32_t PWMGeneratorID; +// }; +// typedef struct solenoid_port_t SolenoidPort; + +// static ReentrantSemaphore solenoidSemaphore; +// static tSolenoid* solenoidModules[2] = {NULL, NULL}; + +// bool solenoidModulesInitialized = false; + +// /** +// * Initialize the digital modules. +// */ +// void initializeSolenoid(int32_t *status) { +// if (solenoidModulesInitialized) return; + +// for (unsigned int i = 0; i < (sizeof(solenoidModules)/sizeof(solenoidModules[0])); i++) { +// Synchronized sync(solenoidSemaphore); +// solenoidModules[i] = tSolenoid::create(status); +// } +// solenoidModulesInitialized = true; +// } + +// void* initializeSolenoidPort(void* port_pointer, int32_t *status) { +// initializeSolenoid(status); +// Port* port = (Port*) port_pointer; + +// // Initialize port structure +// SolenoidPort* solenoid_port = new SolenoidPort(); +// solenoid_port->port = *port; +// solenoid_port->module = solenoidModules[solenoid_port->port.module-1]; + +// return solenoid_port; +// } + +// bool checkSolenoidModule(uint8_t module) { +// if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Solenoid, module - 1)) +// return true; +// return false; +// } + +// bool getSolenoid(void* solenoid_port_pointer, int32_t *status) { +// SolenoidPort* port = (SolenoidPort*) solenoid_port_pointer; +// if (checkSolenoidModule(port->port.module)) { +// uint8_t mask = 1 << (port->port.pin - 1); +// return (mask & port->module->readDO7_0(port->port.module - 1, status)); +// } +// return false; +// } + +// void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status) { +// SolenoidPort* port = (SolenoidPort*) solenoid_port_pointer; +// if (checkSolenoidModule(port->port.module)) { +// Synchronized sync(solenoidSemaphore); +// uint8_t currentValue = port->module->readDO7_0(port->port.module - 1, status); +// uint8_t mask = 1 << (port->port.pin - 1); +// if (value) currentValue = currentValue | mask; // Flip the bit on +// else currentValue = currentValue & ~mask; // Flip the bit off +// port->module->writeDO7_0(port->port.module - 1, currentValue, status); +// } +// } + +// XXX No solenoid abstraction :( + +/** + * Initialize the digital modules. + */ +void initializeSolenoid(int32_t *status) {} +void* initializeSolenoidPort(void* port_pointer, int32_t *status) { return NULL; } +bool checkSolenoidModule(uint8_t module) { return false; } +bool getSolenoid(void* solenoid_port_pointer, int32_t *status) { return false; } +void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status) {} + diff --git a/hal/Athena/src/main/native/Task.cpp b/hal/Athena/src/main/native/Task.cpp new file mode 100644 index 0000000000..22fc93743e --- /dev/null +++ b/hal/Athena/src/main/native/Task.cpp @@ -0,0 +1,100 @@ + +#include "HAL/Task.h" + +#include "HAL/HAL.h" +#include "ChipObject.h" + +#include +#include + +const uint32_t VXWORKS_FP_TASK = 0x01000000; +const int32_t HAL_objLib_OBJ_ID_ERROR = -1; // TODO: update to relevant TaskIDError +const int32_t HAL_objLib_OBJ_DELETED = -1; // TODO: update to relevant TaskDeletedError +const int32_t HAL_taskLib_ILLEGAL_OPTIONS = -1; // TODO: update to relevant TaskOptionsError +const int32_t HAL_memLib_NOT_ENOUGH_MEMORY = -1; // TODO: update to relevant TaskMemoryError +const int32_t HAL_taskLib_ILLEGAL_PRIORITY = -1; // TODO: update to relevant TaskPriorityError + +typedef struct task_args_t { + FUNCPTR fun; + char* name; + pthread_t** task; + uint32_t arg0, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8, arg9; +} TaskArgs; + +void* startRoutine(void* data) { + TaskArgs* args = (TaskArgs*) data; + printf("[HAL] Starting task %s...\n", args->name); + int val = args->fun(args->arg0, args->arg1, args->arg2, args->arg3, args->arg4, + args->arg5, args->arg6, args->arg7, args->arg8, args->arg9); + printf("[HAL] Exited task %s with code %i\n", args->name, val); + *args->task = NULL; + int* ret = new int(); *ret = val; + return ret; +} + +TASK spawnTask(char * name, int priority, int options, int stackSize, + FUNCPTR entryPt, uint32_t arg0, uint32_t arg1, uint32_t arg2, + uint32_t arg3, uint32_t arg4, uint32_t arg5, uint32_t arg6, + uint32_t arg7, uint32_t arg8, uint32_t arg9) { + printf("[HAL] Spawning task %s...\n", name); + pthread_t* task = new pthread_t; + pthread_attr_t* attr = new pthread_attr_t; + pthread_attr_init(attr); + TaskArgs* args = new TaskArgs(); + args->fun = entryPt; + args->name = name; + args->task = new pthread_t*; + *args->task = task; + args->arg0 = arg0; args->arg1 = arg1; args->arg2 = arg2; args->arg3 = arg3; args->arg4 = arg4; + args->arg5 = arg5; args->arg6 = arg6; args->arg7 = arg7; args->arg8 = arg8; args->arg9 = arg9; + if (pthread_create(task, attr, startRoutine, args) == 0) { + printf("[HAL] Success\n"); + pthread_detach(*task); + } else { + printf("[HAL] Failure\n"); + task = NULL; + } + pthread_attr_destroy(attr); + return task; +} + +STATUS restartTask(TASK task) { + return ERROR; // TODO: implement; +} + +STATUS deleteTask(TASK task) { + return ERROR; // TODO: implement +} + +STATUS isTaskReady(TASK task) { + return ERROR; // TODO: implement +} + +STATUS isTaskSuspended(TASK task) { + return ERROR; // TODO: implement +} + +STATUS suspendTask(TASK task) { + return ERROR; // TODO: implement +} + +STATUS resumeTask(TASK task) { + return ERROR; // TODO: implement +} + +STATUS verifyTaskID(TASK task) { + if (task != NULL && pthread_kill(*task, 0) == 0) { + return OK; + } else { + return ERROR; + } +} + +STATUS setTaskPriority(TASK task, int priority) { + return ERROR; // TODO: implement +} + +STATUS getTaskPriority(TASK task, int* priority) { + return ERROR; // TODO: implement +} diff --git a/hal/Athena/src/main/native/Utilities.cpp b/hal/Athena/src/main/native/Utilities.cpp new file mode 100644 index 0000000000..e79259ebc9 --- /dev/null +++ b/hal/Athena/src/main/native/Utilities.cpp @@ -0,0 +1,29 @@ + +#include "HAL/Utilities.h" + +#include "HAL/HAL.h" +#include "ChipObject.h" + +const int32_t HAL_NO_WAIT = 0; +const int32_t HAL_WAIT_FOREVER = -1; + +void delayTicks(int32_t ticks) { + struct timespec test, remaining; + test.tv_sec = 0; + test.tv_nsec = ticks * 3; + nanosleep(&test, &remaining); +} + +void delayMillis(double ms) { + struct timespec test, remaining; + test.tv_sec = ms/1000; + test.tv_nsec = 1000*(((uint64_t) ms)%1000000); + nanosleep(&test, &remaining); +} + +void delaySeconds(double s) { + struct timespec test, remaining; + test.tv_sec = 0; + test.tv_nsec = s * 1000000000.0; + nanosleep(&test, &remaining); +} diff --git a/hal/Athena/src/main/native/Watchdog.cpp b/hal/Athena/src/main/native/Watchdog.cpp new file mode 100644 index 0000000000..59e2041ab3 --- /dev/null +++ b/hal/Athena/src/main/native/Watchdog.cpp @@ -0,0 +1,140 @@ + +#include "HAL/Watchdog.h" + +#include "HAL/HAL.h" +#include "ChipObject.h" + +typedef tWatchdog Watchdog; +const double kDefaultWatchdogExpiration = 0.5; + +void* initializeWatchdog(int32_t *status) { + Watchdog* watchdog = tWatchdog::create(status); + setWatchdogExpiration(watchdog, kDefaultWatchdogExpiration, status); + setWatchdogEnabled(watchdog, true, status); + return watchdog; +} + +void cleanWatchdog(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + setWatchdogEnabled(watchdog, false, status); + delete watchdog; +} + +/** + * Throw the dog a bone. + * + * When everything is going well, you feed your dog when you get home. + * Let's hope you don't drive your car off a bridge on the way home... + * Your dog won't get fed and he will starve to death. + * + * By the way, it's not cool to ask the neighbor (some random task) to + * feed your dog for you. He's your responsibility! + * + * @returns Returns the previous state of the watchdog before feeding it. + */ +bool feedWatchdog(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool previous = getWatchdogEnabled(watchdog_pointer, status); + watchdog->strobeFeed(status); + return previous; +} + +/** + * Put the watchdog out of its misery. + * + * Don't wait for your dying robot to starve when there is a problem. + * Kill it quickly, cleanly, and humanely. + */ +void killWatchdog(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + watchdog->strobeKill(status); +} + +/** + * Read how long it has been since the watchdog was last fed. + * + * @return The number of seconds since last meal. + */ +double getWatchdogLastFed(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + uint32_t timer = watchdog->readTimer(status); + return timer / (kSystemClockTicksPerMicrosecond * 1e6); +} + +/** + * Read what the current expiration is. + * + * @return The number of seconds before starvation following a meal (watchdog starves if it doesn't eat this often). + */ +double getWatchdogExpiration(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + uint32_t expiration = watchdog->readExpiration(status); + return expiration / (kSystemClockTicksPerMicrosecond * 1e6); +} + +/** + * Configure how many seconds your watchdog can be neglected before it starves to death. + * + * @param expiration The number of seconds before starvation following a meal (watchdog starves if it doesn't eat this often). + */ +void setWatchdogExpiration(void* watchdog_pointer, double expiration, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + watchdog->writeExpiration((uint32_t)(expiration * (kSystemClockTicksPerMicrosecond * 1e6)), status); +} + +/** + * Find out if the watchdog is currently enabled or disabled (mortal or immortal). + * + * @return Enabled or disabled. + */ +bool getWatchdogEnabled(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool enabled = !watchdog->readImmortal(status); + return enabled; +} + +/** + * Enable or disable the watchdog timer. + * + * When enabled, you must keep feeding the watchdog timer to + * keep the watchdog active, and hence the dangerous parts + * (motor outputs, etc.) can keep functioning. + * When disabled, the watchdog is immortal and will remain active + * even without being fed. It will also ignore any kill commands + * while disabled. + * + * @param enabled Enable or disable the watchdog. + */ +void setWatchdogEnabled(void* watchdog_pointer, bool enabled, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + watchdog->writeImmortal(!enabled, status); +} + +/** + * Check in on the watchdog and make sure he's still kicking. + * + * This indicates that your watchdog is allowing the system to operate. + * It is still possible that the network communications is not allowing the + * system to run, but you can check this to make sure it's not your fault. + * Check IsSystemActive() for overall system status. + * + * If the watchdog is disabled, then your watchdog is immortal. + * + * @return Is the watchdog still alive? + */ +bool isWatchdogAlive(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool alive = watchdog->readStatus_Alive(status); + return alive; +} + +/** + * Check on the overall status of the system. + * + * @return Is the system active (i.e. PWM motor outputs, etc. enabled)? + */ +bool isWatchdogSystemActive(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool alive = watchdog->readStatus_SystemActive(status); + return alive; +} diff --git a/hal/Athena/src/main/native/cpp/Resource.cpp b/hal/Athena/src/main/native/cpp/Resource.cpp new file mode 100644 index 0000000000..a2baa41e16 --- /dev/null +++ b/hal/Athena/src/main/native/cpp/Resource.cpp @@ -0,0 +1,120 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#include "HAL/cpp/Resource.h" +#include "HAL/Errors.h" +#include + +ReentrantSemaphore Resource::m_createLock; + +/** + * Allocate storage for a new instance of Resource. + * Allocate a bool array of values that will get initialized to indicate that no resources + * have been allocated yet. The indicies of the resources are [0 .. elements - 1]. + */ +Resource::Resource(uint32_t elements) +{ + Synchronized sync(m_createLock); + m_size = elements; + m_isAllocated = new bool[m_size]; + for (uint32_t i=0; i < m_size; i++) + { + m_isAllocated[i] = false; + } +} + +/** + * Factory method to create a Resource allocation-tracker *if* needed. + * + * @param r -- address of the caller's Resource pointer. If *r == NULL, this + * will construct a Resource and make *r point to it. If *r != NULL, i.e. + * the caller already has a Resource instance, this won't do anything. + * @param elements -- the number of elements for this Resource allocator to + * track, that is, it will allocate resource numbers in the range + * [0 .. elements - 1]. + */ +/*static*/ void Resource::CreateResourceObject(Resource **r, uint32_t elements) +{ + Synchronized sync(m_createLock); + if (*r == NULL) + { + *r = new Resource(elements); + } +} + +/** + * Delete the allocated array or resources. + * This happens when the module is unloaded (provided it was statically allocated). + */ +Resource::~Resource() +{ + delete[] m_isAllocated; +} + +/** + * Allocate a resource. + * When a resource is requested, mark it allocated. In this case, a free resource value + * within the range is located and returned after it is marked allocated. + */ +uint32_t Resource::Allocate(const char *resourceDesc) +{ + Synchronized sync(m_allocateLock); + for (uint32_t i=0; i < m_size; i++) + { + if (!m_isAllocated[i]) + { + m_isAllocated[i] = true; + return i; + } + } + // TODO: wpi_setWPIErrorWithContext(NoAvailableResources, resourceDesc); + return ~0ul; +} + +/** + * Allocate a specific resource value. + * The user requests a specific resource value, i.e. channel number and it is verified + * unallocated, then returned. + */ +uint32_t Resource::Allocate(uint32_t index, const char *resourceDesc) +{ + Synchronized sync(m_allocateLock); + if (index >= m_size) + { + // TODO: wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, resourceDesc); + return ~0ul; + } + if ( m_isAllocated[index] ) + { + // TODO: wpi_setWPIErrorWithContext(ResourceAlreadyAllocated, resourceDesc); + return ~0ul; + } + m_isAllocated[index] = true; + return index; +} + + +/** + * Free an allocated resource. + * After a resource is no longer needed, for example a destructor is called for a channel assignment + * class, Free will release the resource value so it can be reused somewhere else in the program. + */ +void Resource::Free(uint32_t index) +{ + Synchronized sync(m_allocateLock); + if (index == ~0ul) return; + if (index >= m_size) + { + // TODO: wpi_setWPIError(NotAllocated); + return; + } + if (!m_isAllocated[index]) + { + // TODO: wpi_setWPIError(NotAllocated); + return; + } + m_isAllocated[index] = false; +} diff --git a/hal/Athena/src/main/native/cpp/StackTrace.cpp b/hal/Athena/src/main/native/cpp/StackTrace.cpp new file mode 100644 index 0000000000..7629925728 --- /dev/null +++ b/hal/Athena/src/main/native/cpp/StackTrace.cpp @@ -0,0 +1,15 @@ + +#include "HAL/cpp/StackTrace.h" + +#include "HAL/HAL.h" +#include "../ChipObject.h" +#include + + +void printCurrentStackTrace() { + // TODO: Implement +} + +bool getErrnoToName(int32_t errNo, char* name) { + return false; // TODO: Implement +} diff --git a/hal/Athena/src/main/native/cpp/Synchronized.cpp b/hal/Athena/src/main/native/cpp/Synchronized.cpp new file mode 100644 index 0000000000..c20d333a43 --- /dev/null +++ b/hal/Athena/src/main/native/cpp/Synchronized.cpp @@ -0,0 +1,49 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#include "HAL/cpp/Synchronized.h" +#include "HAL/Semaphore.h" + +/** + * Synchronized class deals with critical regions. + * Declare a Synchronized object at the beginning of a block. That will take the semaphore. + * When the code exits from the block it will call the destructor which will give the semaphore. + * This ensures that no matter how the block is exited, the semaphore will always be released. + * Use the CRITICAL_REGION(SEM_ID) and END_REGION macros to make the code look cleaner (see header file) + * @param semaphore The semaphore controlling this critical region. + */ +Synchronized::Synchronized(MUTEX_ID semaphore) +{ + m_mutex = semaphore; + m_semaphore = NULL; + takeMutex(m_mutex, SEMAPHORE_WAIT_FOREVER); +} + +Synchronized::Synchronized(SEMAPHORE_ID semaphore) +{ + m_mutex = NULL; + m_semaphore = semaphore; + takeSemaphore(m_semaphore, SEMAPHORE_WAIT_FOREVER); +} + +Synchronized::Synchronized(ReentrantSemaphore& semaphore) +{ + m_mutex = semaphore.m_semaphore; + m_semaphore = NULL; + takeMutex(m_mutex, SEMAPHORE_WAIT_FOREVER); +} + +/** + * This destructor unlocks the semaphore. + */ +Synchronized::~Synchronized() +{ + if (m_mutex != NULL) { + giveMutex(m_mutex); + } else { + giveSemaphore(m_semaphore); + } +} diff --git a/hal/AthenaJava/pom.xml b/hal/AthenaJava/pom.xml new file mode 100644 index 0000000000..17b0b4fc81 --- /dev/null +++ b/hal/AthenaJava/pom.xml @@ -0,0 +1,98 @@ + + + 4.0.0 + edu.wpi.first.wpilib.hal + libHALAthenaJava + so + + + edu.wpi.first.wpilib.templates.athena + shared-library + 0.1.0-SNAPSHOT + + + + + com.nativelibs4java + jnaerator-runtime + 0.12-SNAPSHOT + compile + + + edu.wpi.first.wpilib.hal + include + 0.1.0-SNAPSHOT + inczip + + + com.ni.first.libraries + libFRC_NetworkCommunication + 0.1.0-SNAPSHOT + so + + + + + + sonatype + Sonatype OSS Snapshots Repository + http://oss.sonatype.org/content/groups/public + + + + nativelibs4java-repo + http://nativelibs4java.sourceforge.net/maven + + + + WPILib Repository + http://frcbuilder.wpi.edu:8348/ + + + + + sonatype + Sonatype OSS Snapshots Repository + http://oss.sonatype.org/content/groups/public + + + + nativelibs4java-repo + http://nativelibs4java.sourceforge.net/maven + + + + + + + org.codehaus.mojo + native-maven-plugin + + + + ../Athena/src/main/native + + **/*.cpp + + + + + + + com.nativelibs4java + maven-jnaerator-plugin + 0.12-SNAPSHOT + true + + + process-classes + + generate + + + + + + + diff --git a/hal/AthenaJava/src/main/jnaerator/config.jnaerator b/hal/AthenaJava/src/main/jnaerator/config.jnaerator new file mode 100644 index 0000000000..fcc6546955 --- /dev/null +++ b/hal/AthenaJava/src/main/jnaerator/config.jnaerator @@ -0,0 +1,15 @@ +-dontCastConstants +-runtime JNAerator +-direct +// -reification +-M__java=true + +-package edu.wpi.first.wpilibj.hal +// -entryClass HAL + +-library HAL +-Itarget/native/include/ + +target/native/include/HAL/HAL.h +// include/HAL/Errors.h + diff --git a/hal/AthenaXX/pom.xml b/hal/AthenaXX/pom.xml new file mode 100644 index 0000000000..ea45821c8c --- /dev/null +++ b/hal/AthenaXX/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + edu.wpi.first.wpilib.hal + libHALAthenaXX + a + + + edu.wpi.first.wpilib.templates.athena + static-library + 0.1.0-SNAPSHOT + + + + + WPILib Repository + http://frcbuilder.wpi.edu:8348/ + + + + + + edu.wpi.first.wpilib.hal + include + 0.1.0-SNAPSHOT + inczip + + + + + + + org.codehaus.mojo + native-maven-plugin + + + + src/main/native + + **/*.cpp + + + + + + + + diff --git a/hal/AthenaXX/src/main/native/Analog.cpp b/hal/AthenaXX/src/main/native/Analog.cpp new file mode 100644 index 0000000000..8c752b5efc --- /dev/null +++ b/hal/AthenaXX/src/main/native/Analog.cpp @@ -0,0 +1,696 @@ + +#include "HAL/Analog.h" + +#include "Port.h" +#include "HAL/Errors.h" +#include "HAL/Semaphore.h" +#include "ChipObject.h" +#include "HAL/cpp/Synchronized.h" +#include "HAL/cpp/Resource.h" +#include "NetworkCommunication/AICalibration.h" +#include "NetworkCommunication/LoadOut.h" + +#include // TODO: remove printf for debugging + +static const long kTimebase = 40000000; ///< 40 MHz clock +static const long kDefaultOversampleBits = 0; +static const long kDefaultAverageBits = 7; +static const float kDefaultSampleRate = 50000.0; +static const uint32_t kAnalogPins = 8; + +static const uint8_t kAccumulatorModuleNumber = 1; +static const uint32_t kAccumulatorNumChannels = 2; +static const uint32_t kAccumulatorChannels[] = {1, 2}; + +struct analog_port_t { + Port port; + tAI *module; + tAccumulator *accumulator; +}; +typedef struct analog_port_t AnalogPort; + +bool analogSampleRateSet[2] = {false, false}; +MUTEX_ID analogRegisterWindowSemaphore = NULL; +tAI* analogModules[2] = {NULL, NULL}; +uint32_t analogNumChannelsToActivate[2] = {0, 0}; + +// Utility methods defined below. +uint32_t getAnalogNumActiveChannels(uint8_t module, int32_t *status); +uint32_t getAnalogNumChannelsToActivate(uint8_t module, int32_t *status); +void setAnalogNumChannelsToActivate(uint8_t module, uint32_t channels); + +bool analogModulesInitialized = false; + +/** + * Initialize the analog modules. + */ +void initializeAnalog(int32_t *status) { + if (analogModulesInitialized) return; + // Needs to be global since the protected resource spans both module singletons. + analogRegisterWindowSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + for (unsigned int i = 0; i < (sizeof(analogModules)/sizeof(analogModules[0])); i++) { + analogModules[i] = tAI::create(i, status); + setAnalogNumChannelsToActivate(i + 1, kAnalogPins); + setAnalogSampleRateWithModule(i + 1, kDefaultSampleRate, status); + } + analogModulesInitialized = true; +} + +/** + * Initialize the analog port using the given port object. + */ +void* initializeAnalogPort(void* port_pointer, int32_t *status) { + initializeAnalog(status); + Port* port = (Port*) port_pointer; + + // Initialize port structure + AnalogPort* analog_port = new AnalogPort(); + analog_port->port = *port; + analog_port->module = analogModules[analog_port->port.module-1]; + if (isAccumulatorChannel(analog_port, status)) { + analog_port->accumulator = tAccumulator::create(port->pin - 1, status); + } else analog_port->accumulator = NULL; + + // Set default configuration + analog_port->module->writeScanList(port->pin - 1, port->pin - 1, status); + setAnalogAverageBits(analog_port, kDefaultAverageBits, status); + setAnalogOversampleBits(analog_port, kDefaultOversampleBits, status); + return analog_port; +} + + +/** + * Check that the analog module number is valid. + * + * @return Analog module is valid and present + */ +bool checkAnalogModule(uint8_t module) { + if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Analog, module - 1)) + return true; + return false; +} + +/** + * Check that the analog channel number is value. + * Verify that the analog channel number is one of the legal channel numbers. Channel numbers + * are 1-based. + * + * @return Analog channel is valid + */ +bool checkAnalogChannel(uint32_t pin) { + if (pin > 0 && pin <= kAnalogPins) + return true; + return false; +} + +/** + * Set the sample rate on module 0. + * + * This is a global setting for the module and effects all channels. + * + * @param samplesPerSecond The number of samples per channel per second. + */ +void setAnalogSampleRate(double samplesPerSecond, int32_t *status) { + setAnalogSampleRateWithModule(1, samplesPerSecond, status); +} + +/** + * Get the current sample rate on module 0. + * + * This assumes one entry in the scan list. + * This is a global setting for the module and effects all channels. + * + * @return Sample rate. + */ +float getAnalogSampleRate(int32_t *status) { + return getAnalogSampleRateWithModule(1, status); +} + +/** + * Set the sample rate on the module. + * + * This is a global setting for the module and effects all channels. + * + * @param module The module to use + * @param samplesPerSecond The number of samples per channel per second. + */ +void setAnalogSampleRateWithModule(uint8_t module, double samplesPerSecond, int32_t *status) { + // TODO: This will change when variable size scan lists are implemented. + // TODO: Need float comparison with epsilon. + //wpi_assert(!sampleRateSet || GetSampleRate() == samplesPerSecond); + analogSampleRateSet[module-1] = true; + + // Compute the convert rate + uint32_t ticksPerSample = (uint32_t)((float)kTimebase / samplesPerSecond); + uint32_t ticksPerConversion = ticksPerSample / getAnalogNumChannelsToActivate(module, status); + // ticksPerConversion must be at least 80 + if (ticksPerConversion < 80) { + if ((*status) >= 0) *status = SAMPLE_RATE_TOO_HIGH; + ticksPerConversion = 80; + } + + // Atomically set the scan size and the convert rate so that the sample rate is constant + tAI::tConfig config; + config.ScanSize = getAnalogNumChannelsToActivate(module, status); + config.ConvertRate = ticksPerConversion; + analogModules[module-1]->writeConfig(config, status); + + // Indicate that the scan size has been commited to hardware. + setAnalogNumChannelsToActivate(module, 0); +} + +/** + * Get the current sample rate on the module. + * + * This assumes one entry in the scan list. + * This is a global setting for the module and effects all channels. + * + * @param module The module to use + * @return Sample rate. + */ +float getAnalogSampleRateWithModule(uint8_t module, int32_t *status) { + uint32_t ticksPerConversion = analogModules[module-1]->readLoopTiming(status); + uint32_t ticksPerSample = ticksPerConversion * getAnalogNumActiveChannels(module, status); + return (float)kTimebase / (float)ticksPerSample; +} + + +/** + * Set the number of averaging bits. + * + * This sets the number of averaging bits. The actual number of averaged samples is 2**bits. + * Use averaging to improve the stability of your measurement at the expense of sampling rate. + * The averaging is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to configure. + * @param bits Number of bits to average. + */ +void setAnalogAverageBits(void* analog_port_pointer, uint32_t bits, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + port->module->writeAverageBits(port->port.pin - 1, bits, status); +} + +/** + * Get the number of averaging bits. + * + * This gets the number of averaging bits from the FPGA. The actual number of averaged samples is 2**bits. + * The averaging is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Bits to average. + */ +uint32_t getAnalogAverageBits(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + uint32_t result = port->module->readAverageBits(port->port.pin - 1, status); + return result; +} + +/** + * Set the number of oversample bits. + * + * This sets the number of oversample bits. The actual number of oversampled values is 2**bits. + * Use oversampling to improve the resolution of your measurements at the expense of sampling rate. + * The oversampling is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @param bits Number of bits to oversample. + */ +void setAnalogOversampleBits(void* analog_port_pointer, uint32_t bits, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + port->module->writeOversampleBits(port->port.pin - 1, bits, status); +} + + +/** + * Get the number of oversample bits. + * + * This gets the number of oversample bits from the FPGA. The actual number of oversampled values is + * 2**bits. The oversampling is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Bits to oversample. + */ +uint32_t getAnalogOversampleBits(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + uint32_t result = port->module->readOversampleBits(port->port.pin - 1, status); + return result; +} + +/** + * Get a sample straight from the channel on this module. + * + * The sample is a 12-bit value representing the -10V to 10V range of the A/D converter in the module. + * The units are in A/D converter codes. Use GetVoltage() to get the analog value in calibrated units. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A sample straight from the channel on this module. + */ +int16_t getAnalogValue(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + int16_t value; + checkAnalogChannel(port->port.pin); + + tAI::tReadSelect readSelect; + readSelect.Channel = port->port.pin - 1; + readSelect.Module = port->port.module - 1; + readSelect.Averaged = false; + + { + Synchronized sync(analogRegisterWindowSemaphore); + port->module->writeReadSelect(readSelect, status); + port->module->strobeLatchOutput(status); + value = (int16_t) port->module->readOutput(status); + } + + return value; +} + +/** + * Get a sample from the output of the oversample and average engine for the channel. + * + * The sample is 12-bit + the value configured in SetOversampleBits(). + * The value configured in SetAverageBits() will cause this value to be averaged 2**bits number of samples. + * This is not a sliding window. The sample will not change until 2**(OversamplBits + AverageBits) samples + * have been acquired from the module on this channel. + * Use GetAverageVoltage() to get the analog value in calibrated units. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A sample from the oversample and average engine for the channel. + */ +int32_t getAnalogAverageValue(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + int16_t value; + checkAnalogChannel(port->port.pin); + + tAI::tReadSelect readSelect; + readSelect.Channel = port->port.pin - 1; + readSelect.Module = port->port.module - 1; + readSelect.Averaged = true; + + { + Synchronized sync(analogRegisterWindowSemaphore); + port->module->writeReadSelect(readSelect, status); + port->module->strobeLatchOutput(status); + value = (int16_t) port->module->readOutput(status); + } + + return value; +} + +/** + * Get a scaled sample straight from the channel on this module. + * + * The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset(). + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A scaled sample straight from the channel on this module. + */ +float getAnalogVoltage(void* analog_port_pointer, int32_t *status) { + int16_t value = getAnalogValue(analog_port_pointer, status); + uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status); + int32_t offset = getAnalogOffset(analog_port_pointer, status); + float voltage = LSBWeight * 1.0e-9 * value - offset * 1.0e-9; + return voltage; +} + +/** + * Get a scaled sample from the output of the oversample and average engine for the channel. + * + * The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset(). + * Using oversampling will cause this value to be higher resolution, but it will update more slowly. + * Using averaging will cause this value to be more stable, but it will update more slowly. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A scaled sample from the output of the oversample and average engine for the channel. + */ +float getAnalogAverageVoltage(void* analog_port_pointer, int32_t *status) { + int32_t value = getAnalogAverageValue(analog_port_pointer, status); + uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status); + int32_t offset = getAnalogOffset(analog_port_pointer, status); + uint32_t oversampleBits = getAnalogOversampleBits(analog_port_pointer, status); + float voltage = ((LSBWeight * 1.0e-9 * value) / (float)(1 << oversampleBits)) - offset * 1.0e-9; + return voltage; +} + +/** + * Convert a voltage to a raw value for a specified channel. + * + * This process depends on the calibration of each channel, so the channel + * must be specified. + * + * @todo This assumes raw values. Oversampling not supported as is. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @param voltage The voltage to convert. + * @return The raw value for the channel. + */ +int32_t getAnalogVoltsToValue(void* analog_port_pointer, double voltage, int32_t *status) { + if (voltage > 10.0) { + voltage = 10.0; + *status = VOLTAGE_OUT_OF_RANGE; + } + if (voltage < -10.0) { + voltage = -10.0; + *status = VOLTAGE_OUT_OF_RANGE; + } + uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status); + int32_t offset = getAnalogOffset(analog_port_pointer, status); + int32_t value = (int32_t) ((voltage + offset * 1.0e-9) / (LSBWeight * 1.0e-9)); + return value; +} + +/** + * Get the factory scaling least significant bit weight constant. + * The least significant bit weight constant for the channel that was calibrated in + * manufacturing and stored in an eeprom in the module. + * + * Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9) + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Least significant bit weight. + */ +uint32_t getAnalogLSBWeight(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + uint32_t lsbWeight = FRC_NetworkCommunication_nAICalibration_getLSBWeight(port->module->getSystemIndex(), + port->port.pin - 1, status); + return lsbWeight; +} + +/** + * Get the factory scaling offset constant. + * The offset constant for the channel that was calibrated in manufacturing and stored + * in an eeprom in the module. + * + * Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9) + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Offset constant. + */ +int32_t getAnalogOffset(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + int32_t offset = FRC_NetworkCommunication_nAICalibration_getOffset(port->module->getSystemIndex(), + port->port.pin - 1, status); + return offset; +} + + +/** + * Return the number of channels on the module in use. + * + * @return Active channels. + */ +uint32_t getAnalogNumActiveChannels(uint8_t module, int32_t *status) { + uint32_t scanSize = analogModules[module-1]->readConfig_ScanSize(status); + if (scanSize == 0) + return 8; + return scanSize; +} + +/** + * Get the number of active channels. + * + * This is an internal function to allow the atomic update of both the + * number of active channels and the sample rate. + * + * When the number of channels changes, use the new value. Otherwise, + * return the curent value. + * + * @return Value to write to the active channels field. + */ +uint32_t getAnalogNumChannelsToActivate(uint8_t module, int32_t *status) { + if(analogNumChannelsToActivate[module-1] == 0) return getAnalogNumActiveChannels(module, status); + return analogNumChannelsToActivate[module-1]; +} + +/** + * Set the number of active channels. + * + * Store the number of active channels to set. Don't actually commit to hardware + * until SetSampleRate(). + * + * @param channels Number of active channels. + */ +void setAnalogNumChannelsToActivate(uint8_t module, uint32_t channels) { + analogNumChannelsToActivate[module-1] = channels; +} + +//// Accumulator Stuff + +/** + * Is the channel attached to an accumulator. + * + * @return The analog channel is attached to an accumulator. + */ +bool isAccumulatorChannel(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if(port->port.module != kAccumulatorModuleNumber) return false; + for (uint32_t i=0; i < kAccumulatorNumChannels; i++) { + if (port->port.pin == kAccumulatorChannels[i]) return true; + } + return false; +} + +/** + * Initialize the accumulator. + */ +void initAccumulator(void* analog_port_pointer, int32_t *status) { + setAccumulatorCenter(analog_port_pointer, 0, status); + resetAccumulator(analog_port_pointer, status); +} + +/** + * Resets the accumulator to the initial value. + */ +void resetAccumulator(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + port->accumulator->strobeReset(status); +} + +/** + * Set the center value of the accumulator. + * + * The center value is subtracted from each A/D value before it is added to the accumulator. This + * is used for the center value of devices like gyros and accelerometers to make integration work + * and to take the device offset into account when integrating. + * + * This center value is based on the output of the oversampled and averaged source from channel 1. + * Because of this, any non-zero oversample bits will affect the size of the value for this field. + */ +void setAccumulatorCenter(void* analog_port_pointer, int32_t center, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + port->accumulator->writeCenter(center, status); +} + +/** + * Set the accumulator's deadband. + */ +void setAccumulatorDeadband(void* analog_port_pointer, int32_t deadband, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + port->accumulator->writeDeadband(deadband, status); +} + +/** + * Read the accumulated value. + * + * Read the value that has been accumulating on channel 1. + * The accumulator is attached after the oversample and average engine. + * + * @return The 64-bit value accumulated since the last Reset(). + */ +int64_t getAccumulatorValue(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return 0; + } + int64_t value = port->accumulator->readOutput_Value(status); + return value; +} + +/** + * Read the number of accumulated values. + * + * Read the count of the accumulated values since the accumulator was last Reset(). + * + * @return The number of times samples from the channel were accumulated. + */ +uint32_t getAccumulatorCount(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return 0; + } + return port->accumulator->readOutput_Count(status); +} + +/** + * Read the accumulated value and the number of accumulated values atomically. + * + * This function reads the value and count from the FPGA atomically. + * This can be used for averaging. + * + * @param value Pointer to the 64-bit accumulated output. + * @param count Pointer to the number of accumulation cycles. + */ +void getAccumulatorOutput(void* analog_port_pointer, int64_t *value, uint32_t *count, int32_t *status) { +// printf("[HAL] getAccumulatorOutput()\n"); + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + if (value == NULL || count == NULL) { + *status = NULL_PARAMETER; + return; + } + +// printf("[HAL]\t Getting output...\n"); + tAccumulator::tOutput output = port->accumulator->readOutput(status); + +// printf("[HAL]\t Status: %d, Value: %lld, Count: %d.\n", *status, output.Value, output.Count); +// printf("[HAL]\t value: %d, value2: %d, value3: %d.\n", output.value, output.value2, output.value3); +// printf("[HAL]\t Value: %lld, Count: %d.\n", port->accumulator->readOutput_Value(status), port->accumulator->readOutput_Count(status)); + *value = output.Value; + *count = output.Count; +} + + +struct trigger_t { + tAnalogTrigger* trigger; + AnalogPort* port; + uint32_t index; +}; +typedef struct trigger_t AnalogTrigger; + +static Resource *triggers = NULL; + +void* initializeAnalogTrigger(void* port_pointer, uint32_t *index, int32_t *status) { + Port* port = (Port*) port_pointer; + Resource::CreateResourceObject(&triggers, tAnalogTrigger::kNumSystems); + + AnalogTrigger* trigger = new AnalogTrigger(); + trigger->port = (AnalogPort*) initializeAnalogPort(port, status); + trigger->index = triggers->Allocate("Analog Trigger"); + *index = trigger->index; + // TODO: if (index == ~0ul) { CloneError(triggers); return; } + + trigger->trigger = tAnalogTrigger::create(trigger->index, status); + trigger->trigger->writeSourceSelect_Channel(port->pin - 1, status); + trigger->trigger->writeSourceSelect_Module(port->module - 1, status); + + return trigger; +} + +void cleanAnalogTrigger(void* analog_trigger_pointer, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + triggers->Free(trigger->index); + delete trigger->trigger; + delete trigger; +} + +void setAnalogTriggerLimitsRaw(void* analog_trigger_pointer, int32_t lower, int32_t upper, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (lower > upper) { + *status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR; + } + trigger->trigger->writeLowerLimit(lower, status); + trigger->trigger->writeUpperLimit(upper, status); +} + +/** + * Set the upper and lower limits of the analog trigger. + * The limits are given as floating point voltage values. + */ +void setAnalogTriggerLimitsVoltage(void* analog_trigger_pointer, double lower, double upper, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (lower > upper) { + *status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR; + } + // TODO: This depends on the averaged setting. Only raw values will work as is. + trigger->trigger->writeLowerLimit(getAnalogVoltsToValue(trigger->port, lower, status), status); + trigger->trigger->writeUpperLimit(getAnalogVoltsToValue(trigger->port, upper, status), status); +} + +/** + * Configure the analog trigger to use the averaged vs. raw values. + * If the value is true, then the averaged value is selected for the analog trigger, otherwise + * the immediate value is used. + */ +void setAnalogTriggerAveraged(void* analog_trigger_pointer, bool useAveragedValue, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (trigger->trigger->readSourceSelect_Filter(status) != 0) { + *status = INCOMPATIBLE_STATE; + // TODO: wpi_setWPIErrorWithContext(IncompatibleMode, "Hardware does not support average and filtering at the same time."); + } + trigger->trigger->writeSourceSelect_Averaged(useAveragedValue, status); +} + +/** + * Configure the analog trigger to use a filtered value. + * The analog trigger will operate with a 3 point average rejection filter. This is designed to + * help with 360 degree pot applications for the period where the pot crosses through zero. + */ +void setAnalogTriggerFiltered(void* analog_trigger_pointer, bool useFilteredValue, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (trigger->trigger->readSourceSelect_Averaged(status) != 0) { + *status = INCOMPATIBLE_STATE; + // TODO: wpi_setWPIErrorWithContext(IncompatibleMode, "Hardware does not support average and filtering at the same time."); + } + trigger->trigger->writeSourceSelect_Filter(useFilteredValue, status); +} + +/** + * Return the InWindow output of the analog trigger. + * True if the analog input is between the upper and lower limits. + * @return The InWindow output of the analog trigger. + */ +bool getAnalogTriggerInWindow(void* analog_trigger_pointer, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + return trigger->trigger->readOutput_InHysteresis(trigger->index, status) != 0; +} + +/** + * Return the TriggerState output of the analog trigger. + * True if above upper limit. + * False if below lower limit. + * If in Hysteresis, maintain previous state. + * @return The TriggerState output of the analog trigger. + */ +bool getAnalogTriggerTriggerState(void* analog_trigger_pointer, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + return trigger->trigger->readOutput_OverLimit(trigger->index, status) != 0; +} + +/** + * Get the state of the analog trigger output. + * @return The state of the analog trigger output. + */ +bool getAnalogTriggerOutput(void* analog_trigger_pointer, AnalogTriggerType type, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + bool result = false; + switch(type) { + case kInWindow: + result = trigger->trigger->readOutput_InHysteresis(trigger->index, status); + break; // XXX: Backport + case kState: + result = trigger->trigger->readOutput_OverLimit(trigger->index, status); + break; // XXX: Backport + case kRisingPulse: + case kFallingPulse: + *status = ANALOG_TRIGGER_PULSE_OUTPUT_ERROR; + return false; + } + return result; +} diff --git a/hal/AthenaXX/src/main/native/ChipObject.h b/hal/AthenaXX/src/main/native/ChipObject.h new file mode 100644 index 0000000000..a1ab3da685 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject.h @@ -0,0 +1,32 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#ifndef __ChipObject_h__ +#define __ChipObject_h__ + +#include +#include "ChipObject/NiRio.h" + +#include "ChipObject/tAccumulator.h" +#include "ChipObject/tAI.h" +#include "ChipObject/tAlarm.h" +#include "ChipObject/tAnalogTrigger.h" +#include "ChipObject/tCounter.h" +#include "ChipObject/tDIO.h" +#include "ChipObject/tDMA.h" +//#include "ChipObject/tDMAManager.h" +#include "ChipObject/tEncoder.h" +#include "ChipObject/tGlobal.h" +#include "ChipObject/tInterrupt.h" +#include "ChipObject/tInterruptManager.h" +#include "ChipObject/tSolenoid.h" +#include "ChipObject/tSPI.h" +#include "ChipObject/tWatchdog.h" + +using namespace nFPGA; +using namespace nFRC_2012_1_6_4; + +#endif diff --git a/hal/AthenaXX/src/main/native/ChipObject/NiFpga.h b/hal/AthenaXX/src/main/native/ChipObject/NiFpga.h new file mode 100644 index 0000000000..0df6bfbb73 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/NiFpga.h @@ -0,0 +1,2312 @@ +/* + * FPGA Interface C API 2.0 header file. + * + * Copyright (c) 2011, + * National Instruments Corporation. + * All rights reserved. + */ + +#ifndef __NiFpga_h__ +#define __NiFpga_h__ + +/* + * Determine platform details. + */ +#if defined(_M_IX86) \ + || defined(_M_X64) \ + || defined(i386) \ + || defined(__i386__) \ + || defined(__amd64__) \ + || defined(__amd64) \ + || defined(__x86_64__) \ + || defined(__x86_64) \ + || defined(__i386) \ + || defined(_X86_) \ + || defined(__THW_INTEL__) \ + || defined(__I86__) \ + || defined(__INTEL__) \ + || defined(__X86__) \ + || defined(__386__) \ + || defined(__I86__) \ + || defined(M_I386) \ + || defined(M_I86) \ + || defined(_M_I386) \ + || defined(_M_I86) \ + || defined(__arm__) + #if defined(_WIN32) \ + || defined(_WIN64) \ + || defined(__WIN32__) \ + || defined(__TOS_WIN__) \ + || defined(__WINDOWS__) \ + || defined(_WINDOWS) \ + || defined(__WINDOWS_386__) \ + || defined(__CYGWIN__) + /* Either Windows or Phar Lap ETS. */ + #define NiFpga_Windows 1 + #elif defined(__linux) \ + || defined(__linux__) \ + || defined(__gnu_linux__) \ + || defined(linux) + #define NiFpga_Linux 1 + #else + #error Unsupported OS. + #endif +#elif defined(__powerpc) \ + || defined(__powerpc__) \ + || defined(__POWERPC__) \ + || defined(__ppc__) \ + || defined(__PPC) \ + || defined(_M_PPC) \ + || defined(_ARCH_PPC) \ + || defined(__PPC__) \ + || defined(__ppc) + #if defined(__vxworks) + #define NiFpga_VxWorks 1 + #else + #error Unsupported OS. + #endif +#else + #error Unsupported architecture. +#endif + +/* + * Determine compiler. + */ +#if defined(_MSC_VER) + #define NiFpga_Msvc 1 +#elif defined(__GNUC__) + #define NiFpga_Gcc 1 +#elif defined(_CVI_) && !defined(_TPC_) + #define NiFpga_Cvi 1 + /* Enables CVI Library Protection Errors. */ + #pragma EnableLibraryRuntimeChecking +#else + /* Unknown compiler. */ +#endif + +/* + * Determine compliance with different C/C++ language standards. + */ +#if defined(__cplusplus) + #define NiFpga_Cpp 1 + #if __cplusplus >= 199707L + #define NiFpga_Cpp98 1 + #endif +#endif +#if defined(__STDC__) + #define NiFpga_C89 1 + #if defined(__STDC_VERSION__) + #define NiFpga_C90 1 + #if __STDC_VERSION__ >= 199409L + #define NiFpga_C94 1 + #if __STDC_VERSION__ >= 199901L + #define NiFpga_C99 1 + #endif + #endif + #endif +#endif + +/* + * Determine ability to inline functions. + */ +#if NiFpga_Cpp || NiFpga_C99 + /* The inline keyword exists in C++ and C99. */ + #define NiFpga_Inline inline +#elif NiFpga_Msvc + /* Visual C++ (at least since 6.0) also supports an alternate keyword. */ + #define NiFpga_Inline __inline +#elif NiFpga_Gcc + /* GCC (at least since 2.95.2) also supports an alternate keyword. */ + #define NiFpga_Inline __inline__ +#elif !defined(NiFpga_Inline) + /* + * Disable inlining if inline support is unknown. To manually enable + * inlining, #define the following macro before #including NiFpga.h: + * + * #define NiFpga_Inline inline + */ + #define NiFpga_Inline +#endif + +/* + * Define exact-width integer types, if they have not already been defined. + */ +#if NiFpga_ExactWidthIntegerTypesDefined \ + || defined(_STDINT) \ + || defined(_STDINT_H) \ + || defined(_STDINT_H_) \ + || defined(_INTTYPES_H) \ + || defined(_INTTYPES_H_) \ + || defined(_SYS_STDINT_H) \ + || defined(_SYS_STDINT_H_) \ + || defined(_SYS_INTTYPES_H) \ + || defined(_SYS_INTTYPES_H_) \ + || defined(_STDINT_H_INCLUDED) \ + || defined(BOOST_CSTDINT_HPP) \ + || defined(_MSC_STDINT_H_) \ + || defined(_PSTDINT_H_INCLUDED) + /* Assume that exact-width integer types have already been defined. */ +#elif NiFpga_VxWorks + #include +#elif NiFpga_C99 \ + || NiFpga_Gcc /* GCC (at least since 3.0) has a stdint.h. */ \ + || defined(HAVE_STDINT_H) + /* Assume that stdint.h can be included. */ + #include +#elif NiFpga_Msvc \ + || NiFpga_Cvi + /* Manually define exact-width integer types. */ + typedef signed char int8_t; + typedef unsigned char uint8_t; + typedef short int16_t; + typedef unsigned short uint16_t; + typedef int int32_t; + typedef unsigned int uint32_t; + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; +#else + /* + * Exact-width integer types must be defined by the user, and the following + * macro must be #defined, before #including NiFpga.h: + * + * #define NiFpga_ExactWidthIntegerTypesDefined 1 + */ + #error Exact-width integer types must be defined by the user. See comment. +#endif + +/* Included for definition of size_t. */ +#include + +#if NiFpga_Cpp +extern "C" { +#endif + +/** + * A boolean value; either NiFpga_False or NiFpga_True. + */ +typedef uint8_t NiFpga_Bool; + +/** + * Represents a false condition. + */ +static const NiFpga_Bool NiFpga_False = 0; + +/** + * Represents a true condition. + */ +static const NiFpga_Bool NiFpga_True = 1; + +/** + * Represents the resulting status of a function call through its return value. + * 0 is success, negative values are errors, and positive values are warnings. + */ +typedef int32_t NiFpga_Status; + +/** + * No errors or warnings. + */ +static const NiFpga_Status NiFpga_Status_Success = 0; + +/** + * The timeout expired before the FIFO operation could complete. + */ +static const NiFpga_Status NiFpga_Status_FifoTimeout = -50400; + +/** + * A memory allocation failed. Try again after rebooting. + */ +static const NiFpga_Status NiFpga_Status_MemoryFull = -52000; + +/** + * An unexpected software error occurred. + */ +static const NiFpga_Status NiFpga_Status_SoftwareFault = -52003; + +/** + * A parameter to a function was not valid. This could be a NULL pointer, a bad + * value, etc. + */ +static const NiFpga_Status NiFpga_Status_InvalidParameter = -52005; + +/** + * A required resource was not found. The NiFpga.* library, the RIO resource, + * or some other resource may be missing, or the NiFpga.* library may not be + * the required minimum version. + */ +static const NiFpga_Status NiFpga_Status_ResourceNotFound = -52006; + +/** + * A required resource was not properly initialized. This could occur if + * NiFpga_Initialize was not called or a required NiFpga_IrqContext was not + * reserved. + */ +static const NiFpga_Status NiFpga_Status_ResourceNotInitialized = -52010; + +/** + * The FPGA is already running. + */ +static const NiFpga_Status NiFpga_Status_FpgaAlreadyRunning = -61003; + +/** + * The bitfile was not compiled for the specified resource's device type. + */ +static const NiFpga_Status NiFpga_Status_DeviceTypeMismatch = -61024; + +/** + * An error was detected in the communication between the host computer and the + * FPGA target. + */ +static const NiFpga_Status NiFpga_Status_CommunicationTimeout = -61046; + +/** + * The timeout expired before any of the IRQs were asserted. + */ +static const NiFpga_Status NiFpga_Status_IrqTimeout = -61060; + +/** + * The specified bitfile is invalid or corrupt. + */ +static const NiFpga_Status NiFpga_Status_CorruptBitfile = -61070; + +/** + * The FIFO depth is invalid. It was either 0, greater than the amount of + * available memory in the host computer, or greater than the maximum size + * allowed by the hardware. + */ +static const NiFpga_Status NiFpga_Status_BadDepth = -61072; + +/** + * The number of FIFO elements is invalid. Either the number is greater than + * the depth of the host memory DMA FIFO, or more elements were requested for + * release than had been acquired. + */ +static const NiFpga_Status NiFpga_Status_BadReadWriteCount = -61073; + +/** + * A hardware clocking error occurred. A derived clock lost lock with its base + * clock during the execution of the LabVIEW FPGA VI. If any base clocks with + * derived clocks are referencing an external source, make sure that the + * external source is connected and within the supported frequency, jitter, + * accuracy, duty cycle, and voltage specifications. Also verify that the + * characteristics of the base clock match the configuration specified in the + * FPGA Base Clock Properties. If all base clocks with derived clocks are + * generated from free-running, on-board sources, please contact National + * Instruments technical support at ni.com/support. + */ +static const NiFpga_Status NiFpga_Status_ClockLostLock = -61083; + +/** + * Operation could not be performed because the FPGA is busy. Stop all the + * activities on the FPGA before requesting this operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusy = -61141; + +/** + * Operation could not be performed because the FPGA is busy operating in FPGA + * Interface C API mode. Stop all the activities on the FPGA before requesting + * this operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterfaceCApi = -61200; + +/** + * The chassis is in Scan Interface programming mode. In order to run FPGA VIs, + * you must go to the chassis properties page, select FPGA programming mode, + * and deploy settings. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyScanInterface = -61201; + +/** + * Operation could not be performed because the FPGA is busy operating in FPGA + * Interface mode. Stop all the activities on the FPGA before requesting this + * operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterface = -61202; + +/** + * Operation could not be performed because the FPGA is busy operating in + * Interactive mode. Stop all the activities on the FPGA before requesting this + * operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyInteractive = -61203; + +/** + * Operation could not be performed because the FPGA is busy operating in + * Emulation mode. Stop all the activities on the FPGA before requesting this + * operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyEmulation = -61204; + +/** + * An unexpected internal error occurred. + */ +static const NiFpga_Status NiFpga_Status_InternalError = -61499; + +/** + * Access to the remote system was denied. Use MAX to check the Remote Device + * Access settings under Software>>NI-RIO>>NI-RIO Settings on the remote system. + */ +static const NiFpga_Status NiFpga_Status_AccessDenied = -63033; + +/** + * A connection could not be established to the specified remote device. Ensure + * that the device is on and accessible over the network, that NI-RIO software + * is installed, and that the RIO server is running and properly configured. + */ +static const NiFpga_Status NiFpga_Status_RpcConnectionError = -63040; + +/** + * The RPC session is invalid. The target may have reset or been rebooted. Check + * the network connection and retry the operation. + */ +static const NiFpga_Status NiFpga_Status_RpcSessionError = -63043; + +/** + * A Read FIFO or Write FIFO function was called while the host had acquired + * elements of the FIFO. Release all acquired elements before reading or + * writing. + */ +static const NiFpga_Status NiFpga_Status_FifoElementsCurrentlyAcquired = -63083; + +/** + * The bitfile could not be read. + */ +static const NiFpga_Status NiFpga_Status_BitfileReadError = -63101; + +/** + * The specified signature does not match the signature of the bitfile. If the + * bitfile has been recompiled, regenerate the C API and rebuild the + * application. + */ +static const NiFpga_Status NiFpga_Status_SignatureMismatch = -63106; + +/** + * Either the supplied resource name is invalid as a RIO resource name, or the + * device was not found. Use MAX to find the proper resource name for the + * intended device. + */ +static const NiFpga_Status NiFpga_Status_InvalidResourceName = -63192; + +/** + * The requested feature is not supported. + */ +static const NiFpga_Status NiFpga_Status_FeatureNotSupported = -63193; + +/** + * The NI-RIO software on the remote system is not compatible with the local + * NI-RIO software. Upgrade the NI-RIO software on the remote system. + */ +static const NiFpga_Status NiFpga_Status_VersionMismatch = -63194; + +/** + * The session is invalid or has been closed. + */ +static const NiFpga_Status NiFpga_Status_InvalidSession = -63195; + +/** + * The maximum number of open FPGA sessions has been reached. Close some open + * sessions. + */ +static const NiFpga_Status NiFpga_Status_OutOfHandles = -63198; + +/** + * Tests whether a status is an error. + * + * @param status status to check for an error + * @return whether the status was an error + */ +static NiFpga_Inline NiFpga_Bool NiFpga_IsError(const NiFpga_Status status) +{ + return status < NiFpga_Status_Success; +} + +/** + * Tests whether a status is not an error. Success and warnings are not errors. + * + * @param status status to check for an error + * @return whether the status was a success or warning + */ +static NiFpga_Inline NiFpga_Bool NiFpga_IsNotError(const NiFpga_Status status) +{ + return status >= NiFpga_Status_Success; +} + +/** + * Conditionally sets the status to a new value. The previous status is + * preserved unless the new status is more of an error, which means that + * warnings and errors overwrite successes, and errors overwrite warnings. New + * errors do not overwrite older errors, and new warnings do not overwrite + * older warnings. + * + * @param status status to conditionally set + * @param newStatus new status value that may be set + * @return the resulting status + */ +static NiFpga_Inline NiFpga_Status NiFpga_MergeStatus( + NiFpga_Status* const status, + const NiFpga_Status newStatus) +{ + if (!status) + { + return NiFpga_Status_InvalidParameter; + } + if (NiFpga_IsNotError(*status) + && (*status == NiFpga_Status_Success || NiFpga_IsError(newStatus))) + { + *status = newStatus; + } + return *status; +} + +/** + * This macro evaluates the expression only if the status is not an error. The + * expression must evaluate to an NiFpga_Status, such as a call to any NiFpga_* + * function, because the status will be set to the returned status if the + * expression is evaluated. + * + * You can use this macro to mimic status chaining in LabVIEW, where the status + * does not have to be explicitly checked after each call. Such code may look + * like the following example. + * + * NiFpga_Status status = NiFpga_Status_Success; + * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...)); + * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...)); + * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...)); + * + * @param status status to check for an error + * @param expression expression to call if the incoming status is not an error + */ +#define NiFpga_IfIsNotError(status, expression) \ + if (NiFpga_IsNotError(status)) \ + { \ + NiFpga_MergeStatus(&status, (expression)); \ + } + +/** + * You must call this function before all other function calls. This function + * loads the NiFpga library so that all the other functions will work. If this + * function succeeds, you must call NiFpga_Finalize after all other function + * calls. + * + * @warning This function is not thread safe. + * + * @return result of the call + */ +NiFpga_Status NiFpga_Initialize(void); + +/** + * You must call this function after all other function calls if + * NiFpga_Initialize succeeds. This function unloads the NiFpga library. + * + * @warning This function is not thread safe. + * + * @return result of the call + */ +NiFpga_Status NiFpga_Finalize(void); + +/** + * A handle to an FPGA session. + */ +typedef uint32_t NiFpga_Session; + +/** + * Attributes that NiFpga_Open accepts. + */ +typedef enum +{ + NiFpga_OpenAttribute_NoRun = 1 +} NiFpga_OpenAttribute; + +/** + * Opens a session to the FPGA. This call ensures that the contents of the + * bitfile are programmed to the FPGA. The FPGA runs unless the + * NiFpga_OpenAttribute_NoRun attribute is used. + * + * Because different operating systems have different default current working + * directories for applications, you must pass an absolute path for the bitfile + * parameter. If you pass only the filename instead of an absolute path, the + * operating system may not be able to locate the bitfile. For example, the + * default current working directories are C:\ni-rt\system\ for Phar Lap ETS and + * /c/ for VxWorks. Because the generated *_Bitfile constant is a #define to a + * string literal, you can use C/C++ string-literal concatenation to form an + * absolute path. For example, if the bitfile is in the root directory of a + * Phar Lap ETS system, pass the following for the bitfile parameter. + * + * "C:\\" NiFpga_MyApplication_Bitfile + * + * @param bitfile path to the bitfile + * @param signature signature of the bitfile + * @param resource RIO resource string to open ("RIO0" or "rio://mysystem/RIO") + * @param attribute bitwise OR of any NiFpga_OpenAttributes, or 0 + * @param session outputs the session handle, which must be closed when no + * longer needed + * @return result of the call + */ +NiFpga_Status NiFpga_Open(const char* bitfile, + const char* signature, + const char* resource, + uint32_t attribute, + NiFpga_Session* session); + +/** + * Attributes that NiFpga_Close accepts. + */ +typedef enum +{ + NiFpga_CloseAttribute_NoResetIfLastSession = 1 +} NiFpga_CloseAttribute; + +/** + * Closes the session to the FPGA. The FPGA resets unless either another session + * is still open or you use the NiFpga_CloseAttribute_NoResetIfLastSession + * attribute. + * + * @param session handle to a currently open session + * @param attribute bitwise OR of any NiFpga_CloseAttributes, or 0 + * @return result of the call + */ +NiFpga_Status NiFpga_Close(NiFpga_Session session, + uint32_t attribute); + +/** + * Attributes that NiFpga_Run accepts. + */ +typedef enum +{ + NiFpga_RunAttribute_WaitUntilDone = 1 +} NiFpga_RunAttribute; + +/** + * Runs the FPGA VI on the target. If you use NiFpga_RunAttribute_WaitUntilDone, + * NiFpga_Run blocks the thread until the FPGA finishes running (if ever). + * + * @param session handle to a currently open session + * @param attribute bitwise OR of any NiFpga_RunAttributes, or 0 + * @return result of the call + */ +NiFpga_Status NiFpga_Run(NiFpga_Session session, + uint32_t attribute); + +/** + * Aborts the FPGA VI. + * + * @param session handle to a currently open session + * @return result of the call + */ +NiFpga_Status NiFpga_Abort(NiFpga_Session session); + +/** + * Resets the FPGA VI. + * + * @param session handle to a currently open session + * @return result of the call + */ +NiFpga_Status NiFpga_Reset(NiFpga_Session session); + +/** + * Re-downloads the FPGA bitstream to the target. + * + * @param session handle to a currently open session + * @return result of the call + */ +NiFpga_Status NiFpga_Download(NiFpga_Session session); + +/** + * Reads a boolean value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadBool(NiFpga_Session session, + uint32_t indicator, + NiFpga_Bool* value); + +/** + * Reads a signed 8-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI8(NiFpga_Session session, + uint32_t indicator, + int8_t* value); + +/** + * Reads an unsigned 8-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU8(NiFpga_Session session, + uint32_t indicator, + uint8_t* value); + +/** + * Reads a signed 16-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI16(NiFpga_Session session, + uint32_t indicator, + int16_t* value); + +/** + * Reads an unsigned 16-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU16(NiFpga_Session session, + uint32_t indicator, + uint16_t* value); + +/** + * Reads a signed 32-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI32(NiFpga_Session session, + uint32_t indicator, + int32_t* value); + +/** + * Reads an unsigned 32-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU32(NiFpga_Session session, + uint32_t indicator, + uint32_t* value); + +/** + * Reads a signed 64-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI64(NiFpga_Session session, + uint32_t indicator, + int64_t* value); + +/** + * Reads an unsigned 64-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU64(NiFpga_Session session, + uint32_t indicator, + uint64_t* value); + +/** + * Writes a boolean value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteBool(NiFpga_Session session, + uint32_t control, + NiFpga_Bool value); + +/** + * Writes a signed 8-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI8(NiFpga_Session session, + uint32_t control, + int8_t value); + +/** + * Writes an unsigned 8-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU8(NiFpga_Session session, + uint32_t control, + uint8_t value); + +/** + * Writes a signed 16-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI16(NiFpga_Session session, + uint32_t control, + int16_t value); + +/** + * Writes an unsigned 16-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU16(NiFpga_Session session, + uint32_t control, + uint16_t value); + +/** + * Writes a signed 32-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI32(NiFpga_Session session, + uint32_t control, + int32_t value); + +/** + * Writes an unsigned 32-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU32(NiFpga_Session session, + uint32_t control, + uint32_t value); + +/** + * Writes a signed 64-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI64(NiFpga_Session session, + uint32_t control, + int64_t value); + +/** + * Writes an unsigned 64-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU64(NiFpga_Session session, + uint32_t control, + uint64_t value); + +/** + * Reads an entire array of boolean values from a given array indicator or + * control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayBool(NiFpga_Session session, + uint32_t indicator, + NiFpga_Bool* array, + size_t size); + +/** + * Reads an entire array of signed 8-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI8(NiFpga_Session session, + uint32_t indicator, + int8_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 8-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU8(NiFpga_Session session, + uint32_t indicator, + uint8_t* array, + size_t size); + +/** + * Reads an entire array of signed 16-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI16(NiFpga_Session session, + uint32_t indicator, + int16_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 16-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU16(NiFpga_Session session, + uint32_t indicator, + uint16_t* array, + size_t size); + +/** + * Reads an entire array of signed 32-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI32(NiFpga_Session session, + uint32_t indicator, + int32_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 32-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU32(NiFpga_Session session, + uint32_t indicator, + uint32_t* array, + size_t size); + +/** + * Reads an entire array of signed 64-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI64(NiFpga_Session session, + uint32_t indicator, + int64_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 64-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU64(NiFpga_Session session, + uint32_t indicator, + uint64_t* array, + size_t size); + +/** + * Writes an entire array of boolean values to a given array control or + * indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayBool(NiFpga_Session session, + uint32_t control, + const NiFpga_Bool* array, + size_t size); + +/** + * Writes an entire array of signed 8-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI8(NiFpga_Session session, + uint32_t control, + const int8_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 8-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU8(NiFpga_Session session, + uint32_t control, + const uint8_t* array, + size_t size); + +/** + * Writes an entire array of signed 16-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI16(NiFpga_Session session, + uint32_t control, + const int16_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 16-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU16(NiFpga_Session session, + uint32_t control, + const uint16_t* array, + size_t size); + +/** + * Writes an entire array of signed 32-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI32(NiFpga_Session session, + uint32_t control, + const int32_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 32-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU32(NiFpga_Session session, + uint32_t control, + const uint32_t* array, + size_t size); + +/** + * Writes an entire array of signed 64-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI64(NiFpga_Session session, + uint32_t control, + const int64_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 64-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU64(NiFpga_Session session, + uint32_t control, + const uint64_t* array, + size_t size); + +/** + * Enumeration of all 32 possible IRQs. Multiple IRQs can be bitwise ORed + * together like this: + * + * NiFpga_Irq_3 | NiFpga_Irq_23 + */ +typedef enum +{ + NiFpga_Irq_0 = 1 << 0, + NiFpga_Irq_1 = 1 << 1, + NiFpga_Irq_2 = 1 << 2, + NiFpga_Irq_3 = 1 << 3, + NiFpga_Irq_4 = 1 << 4, + NiFpga_Irq_5 = 1 << 5, + NiFpga_Irq_6 = 1 << 6, + NiFpga_Irq_7 = 1 << 7, + NiFpga_Irq_8 = 1 << 8, + NiFpga_Irq_9 = 1 << 9, + NiFpga_Irq_10 = 1 << 10, + NiFpga_Irq_11 = 1 << 11, + NiFpga_Irq_12 = 1 << 12, + NiFpga_Irq_13 = 1 << 13, + NiFpga_Irq_14 = 1 << 14, + NiFpga_Irq_15 = 1 << 15, + NiFpga_Irq_16 = 1 << 16, + NiFpga_Irq_17 = 1 << 17, + NiFpga_Irq_18 = 1 << 18, + NiFpga_Irq_19 = 1 << 19, + NiFpga_Irq_20 = 1 << 20, + NiFpga_Irq_21 = 1 << 21, + NiFpga_Irq_22 = 1 << 22, + NiFpga_Irq_23 = 1 << 23, + NiFpga_Irq_24 = 1 << 24, + NiFpga_Irq_25 = 1 << 25, + NiFpga_Irq_26 = 1 << 26, + NiFpga_Irq_27 = 1 << 27, + NiFpga_Irq_28 = 1 << 28, + NiFpga_Irq_29 = 1 << 29, + NiFpga_Irq_30 = 1 << 30, + NiFpga_Irq_31 = 1U << 31 +} NiFpga_Irq; + +/** + * Represents an infinite timeout. + */ +static const uint32_t NiFpga_InfiniteTimeout = 0xFFFFFFFF; + +/** + * See NiFpga_ReserveIrqContext for more information. + */ +typedef void* NiFpga_IrqContext; + +/** + * IRQ contexts are single-threaded; only one thread can wait with a particular + * context at any given time. Clients must reserve as many contexts as the + * application requires. + * + * If a context is successfully reserved (the returned status is not an error), + * it must be unreserved later. Otherwise a memory leak will occur. + * + * @param session handle to a currently open session + * @param context outputs the IRQ context + * @return result of the call + */ +NiFpga_Status NiFpga_ReserveIrqContext(NiFpga_Session session, + NiFpga_IrqContext* context); + +/** + * Unreserves an IRQ context obtained from NiFpga_ReserveIrqContext. + * + * @param session handle to a currently open session + * @param context IRQ context to unreserve + * @return result of the call + */ +NiFpga_Status NiFpga_UnreserveIrqContext(NiFpga_Session session, + NiFpga_IrqContext context); + +/** + * This is a blocking function that stops the calling thread until the FPGA + * asserts any IRQ in the irqs parameter, or until the function call times out. + * Before calling this function, you must use NiFpga_ReserveIrqContext to + * reserve an IRQ context. No other threads can use the same context when this + * function is called. + * + * You can use the irqsAsserted parameter to determine which IRQs were asserted + * for each function call. + * + * @param session handle to a currently open session + * @param context IRQ context with which to wait + * @param irqs bitwise OR of NiFpga_Irqs + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param irqsAsserted if non-NULL, outputs bitwise OR of IRQs that were + * asserted + * @param timedOut if non-NULL, outputs whether the timeout expired + * @return result of the call + */ +NiFpga_Status NiFpga_WaitOnIrqs(NiFpga_Session session, + NiFpga_IrqContext context, + uint32_t irqs, + uint32_t timeout, + uint32_t* irqsAsserted, + NiFpga_Bool* timedOut); + +/** + * Acknowledges an IRQ or set of IRQs. + * + * @param session handle to a currently open session + * @param irqs bitwise OR of NiFpga_Irqs + * @return result of the call + */ +NiFpga_Status NiFpga_AcknowledgeIrqs(NiFpga_Session session, + uint32_t irqs); + +/** + * Specifies the depth of the host memory part of the DMA FIFO. This method is + * optional. In order to see the actual depth configured, use + * NiFpga_ConfigureFifo2. + * + * @param session handle to a currently open session + * @param fifo FIFO to configure + * @param depth requested number of elements in the host memory part of the + * DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ConfigureFifo(NiFpga_Session session, + uint32_t fifo, + size_t depth); + +/** + * Specifies the depth of the host memory part of the DMA FIFO. This method is + * optional. + * + * @param session handle to a currently open session + * @param fifo FIFO to configure + * @param requestedDepth requested number of elements in the host memory part + * of the DMA FIFO + * @param actualDepth if non-NULL, outputs the actual number of elements in the + * host memory part of the DMA FIFO, which may be more than + * the requested number + * @return result of the call + */ +NiFpga_Status NiFpga_ConfigureFifo2(NiFpga_Session session, + uint32_t fifo, + size_t requestedDepth, + size_t* actualDepth); +/** + * Starts a FIFO. This method is optional. + * + * @param session handle to a currently open session + * @param fifo FIFO to start + * @return result of the call + */ +NiFpga_Status NiFpga_StartFifo(NiFpga_Session session, + uint32_t fifo); + +/** + * Stops a FIFO. This method is optional. + * + * @param session handle to a currently open session + * @param fifo FIFO to stop + * @return result of the call + */ +NiFpga_Status NiFpga_StopFifo(NiFpga_Session session, + uint32_t fifo); + +/** + * Reads from a target-to-host FIFO of booleans. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoBool(NiFpga_Session session, + uint32_t fifo, + NiFpga_Bool* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI8(NiFpga_Session session, + uint32_t fifo, + int8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU8(NiFpga_Session session, + uint32_t fifo, + uint8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI16(NiFpga_Session session, + uint32_t fifo, + int16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU16(NiFpga_Session session, + uint32_t fifo, + uint16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI32(NiFpga_Session session, + uint32_t fifo, + int32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU32(NiFpga_Session session, + uint32_t fifo, + uint32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI64(NiFpga_Session session, + uint32_t fifo, + int64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU64(NiFpga_Session session, + uint32_t fifo, + uint64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Writes to a host-to-target FIFO of booleans. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoBool(NiFpga_Session session, + uint32_t fifo, + const NiFpga_Bool* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI8(NiFpga_Session session, + uint32_t fifo, + const int8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU8(NiFpga_Session session, + uint32_t fifo, + const uint8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI16(NiFpga_Session session, + uint32_t fifo, + const int16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU16(NiFpga_Session session, + uint32_t fifo, + const uint16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI32(NiFpga_Session session, + uint32_t fifo, + const int32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU32(NiFpga_Session session, + uint32_t fifo, + const uint32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI64(NiFpga_Session session, + uint32_t fifo, + const int64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU64(NiFpga_Session session, + uint32_t fifo, + const uint64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of booleans. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsBool( + NiFpga_Session session, + uint32_t fifo, + NiFpga_Bool** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 8-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI8( + NiFpga_Session session, + uint32_t fifo, + int8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 8-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU8( + NiFpga_Session session, + uint32_t fifo, + uint8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 16-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI16( + NiFpga_Session session, + uint32_t fifo, + int16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 16-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU16( + NiFpga_Session session, + uint32_t fifo, + uint16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 32-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI32( + NiFpga_Session session, + uint32_t fifo, + int32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 32-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU32( + NiFpga_Session session, + uint32_t fifo, + uint32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 64-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI64( + NiFpga_Session session, + uint32_t fifo, + int64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 64-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU64( + NiFpga_Session session, + uint32_t fifo, + uint64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of booleans. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsBool( + NiFpga_Session session, + uint32_t fifo, + NiFpga_Bool** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 8-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI8( + NiFpga_Session session, + uint32_t fifo, + int8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 8-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU8( + NiFpga_Session session, + uint32_t fifo, + uint8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 16-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI16( + NiFpga_Session session, + uint32_t fifo, + int16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 16-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU16( + NiFpga_Session session, + uint32_t fifo, + uint16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 32-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI32( + NiFpga_Session session, + uint32_t fifo, + int32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 32-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU32( + NiFpga_Session session, + uint32_t fifo, + uint32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 64-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI64( + NiFpga_Session session, + uint32_t fifo, + int64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 64-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU64( + NiFpga_Session session, + uint32_t fifo, + uint64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Releases previously acquired FIFO elements. + * + * The FPGA target cannot read elements acquired by the host. Therefore, the + * host must release elements after acquiring them. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo FIFO from which to release elements + * @param elements number of elements to release + * @return result of the call + */ +NiFpga_Status NiFpga_ReleaseFifoElements(NiFpga_Session session, + uint32_t fifo, + size_t elements); + +/** + * Gets an endpoint reference to a peer-to-peer FIFO. + * + * @param session handle to a currently open session + * @param fifo peer-to-peer FIFO + * @param endpoint outputs the endpoint reference + * @return result of the call + */ +NiFpga_Status NiFpga_GetPeerToPeerFifoEndpoint(NiFpga_Session session, + uint32_t fifo, + uint32_t* endpoint); + +#if NiFpga_Cpp +} +#endif + +#endif diff --git a/hal/AthenaXX/src/main/native/ChipObject/NiRio.h b/hal/AthenaXX/src/main/native/ChipObject/NiRio.h new file mode 100644 index 0000000000..c0dc29ec35 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/NiRio.h @@ -0,0 +1,9 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __NiRio_h__ +#define __NiRio_h__ + +#include "NiFpga.h" +typedef NiFpga_Status tRioStatusCode; + +#endif // __NiRio_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/nInterfaceGlobals.h b/hal/AthenaXX/src/main/native/ChipObject/nInterfaceGlobals.h new file mode 100644 index 0000000000..b6c366cf9c --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/nInterfaceGlobals.h @@ -0,0 +1,15 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_nInterfaceGlobals_h__ +#define __nFRC_2012_1_6_4_nInterfaceGlobals_h__ + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + extern unsigned int g_currentTargetClass; +} +} + +#endif // __nFRC_2012_1_6_4_nInterfaceGlobals_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tAI.h b/hal/AthenaXX/src/main/native/ChipObject/tAI.h new file mode 100644 index 0000000000..6316af666a --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tAI.h @@ -0,0 +1,149 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_AI_h__ +#define __nFRC_2012_1_6_4_AI_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAI +{ +public: + tAI(){} + virtual ~tAI(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAI* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Channel : 3; + unsigned Module : 1; + unsigned Averaged : 1; +#else + unsigned Averaged : 1; + unsigned Module : 1; + unsigned Channel : 3; +#endif + }; + struct{ + unsigned value : 5; + }; + } tReadSelect; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ScanSize : 3; + unsigned ConvertRate : 26; +#else + unsigned ConvertRate : 26; + unsigned ScanSize : 3; +#endif + }; + struct{ + unsigned value : 29; + }; + } tConfig; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_ScanSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ConvertRate(unsigned int value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ScanSize(tRioStatusCode *status) = 0; + virtual unsigned int readConfig_ConvertRate(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLoopTiming_IfaceConstants; + + virtual unsigned int readLoopTiming(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumOversampleBitsElements = 8, + } tOversampleBits_IfaceConstants; + + virtual void writeOversampleBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readOversampleBits(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumAverageBitsElements = 8, + } tAverageBits_IfaceConstants; + + virtual void writeAverageBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readAverageBits(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumScanListElements = 8, + } tScanList_IfaceConstants; + + virtual void writeScanList(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readScanList(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual signed int readOutput(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLatchOutput_IfaceConstants; + + virtual void strobeLatchOutput(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReadSelect_IfaceConstants; + + virtual void writeReadSelect(tReadSelect value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Averaged(bool value, tRioStatusCode *status) = 0; + virtual tReadSelect readReadSelect(tRioStatusCode *status) = 0; + virtual unsigned char readReadSelect_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readReadSelect_Module(tRioStatusCode *status) = 0; + virtual bool readReadSelect_Averaged(tRioStatusCode *status) = 0; + + + + +private: + tAI(const tAI&); + void operator=(const tAI&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_AI_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tAccumulator.h b/hal/AthenaXX/src/main/native/ChipObject/tAccumulator.h new file mode 100644 index 0000000000..d182882dd7 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tAccumulator.h @@ -0,0 +1,87 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Accumulator_h__ +#define __nFRC_2012_1_6_4_Accumulator_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAccumulator +{ +public: + tAccumulator(){} + virtual ~tAccumulator(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAccumulator* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + typedef + union{ + struct{ + signed long long Value; + unsigned Count : 32; + }; + struct{ + unsigned value : 32; + unsigned value2 : 32; + unsigned value3 : 32; + }; + } tOutput; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual signed long long readOutput_Value(tRioStatusCode *status) = 0; + virtual unsigned int readOutput_Count(tRioStatusCode *status) = 0; + + + typedef enum + { + } tCenter_IfaceConstants; + + virtual void writeCenter(signed int value, tRioStatusCode *status) = 0; + virtual signed int readCenter(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDeadband_IfaceConstants; + + virtual void writeDeadband(signed int value, tRioStatusCode *status) = 0; + virtual signed int readDeadband(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + + + +private: + tAccumulator(const tAccumulator&); + void operator=(const tAccumulator&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Accumulator_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tAlarm.h b/hal/AthenaXX/src/main/native/ChipObject/tAlarm.h new file mode 100644 index 0000000000..a1c2f516ea --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tAlarm.h @@ -0,0 +1,57 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Alarm_h__ +#define __nFRC_2012_1_6_4_Alarm_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAlarm +{ +public: + tAlarm(){} + virtual ~tAlarm(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAlarm* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tEnable_IfaceConstants; + + virtual void writeEnable(bool value, tRioStatusCode *status) = 0; + virtual bool readEnable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTriggerTime_IfaceConstants; + + virtual void writeTriggerTime(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readTriggerTime(tRioStatusCode *status) = 0; + + + + +private: + tAlarm(const tAlarm&); + void operator=(const tAlarm&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Alarm_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tAnalogTrigger.h b/hal/AthenaXX/src/main/native/ChipObject/tAnalogTrigger.h new file mode 100644 index 0000000000..4fabd9cd9e --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tAnalogTrigger.h @@ -0,0 +1,133 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_AnalogTrigger_h__ +#define __nFRC_2012_1_6_4_AnalogTrigger_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAnalogTrigger +{ +public: + tAnalogTrigger(){} + virtual ~tAnalogTrigger(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAnalogTrigger* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned InHysteresis : 1; + unsigned OverLimit : 1; + unsigned Rising : 1; + unsigned Falling : 1; +#else + unsigned Falling : 1; + unsigned Rising : 1; + unsigned OverLimit : 1; + unsigned InHysteresis : 1; +#endif + }; + struct{ + unsigned value : 4; + }; + } tOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Channel : 3; + unsigned Module : 1; + unsigned Averaged : 1; + unsigned Filter : 1; + unsigned FloatingRollover : 1; + signed RolloverLimit : 8; +#else + signed RolloverLimit : 8; + unsigned FloatingRollover : 1; + unsigned Filter : 1; + unsigned Averaged : 1; + unsigned Module : 1; + unsigned Channel : 3; +#endif + }; + struct{ + unsigned value : 15; + }; + } tSourceSelect; + + + typedef enum + { + } tSourceSelect_IfaceConstants; + + virtual void writeSourceSelect(tSourceSelect value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Averaged(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Filter(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_FloatingRollover(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_RolloverLimit(signed short value, tRioStatusCode *status) = 0; + virtual tSourceSelect readSourceSelect(tRioStatusCode *status) = 0; + virtual unsigned char readSourceSelect_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readSourceSelect_Module(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_Averaged(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_Filter(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_FloatingRollover(tRioStatusCode *status) = 0; + virtual signed short readSourceSelect_RolloverLimit(tRioStatusCode *status) = 0; + + + typedef enum + { + } tUpperLimit_IfaceConstants; + + virtual void writeUpperLimit(signed int value, tRioStatusCode *status) = 0; + virtual signed int readUpperLimit(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLowerLimit_IfaceConstants; + + virtual void writeLowerLimit(signed int value, tRioStatusCode *status) = 0; + virtual signed int readLowerLimit(tRioStatusCode *status) = 0; + + + + typedef enum + { + kNumOutputElements = 8, + } tOutput_IfaceConstants; + + virtual tOutput readOutput(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_InHysteresis(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_OverLimit(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_Rising(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_Falling(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + +private: + tAnalogTrigger(const tAnalogTrigger&); + void operator=(const tAnalogTrigger&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_AnalogTrigger_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tCounter.h b/hal/AthenaXX/src/main/native/ChipObject/tCounter.h new file mode 100644 index 0000000000..200ffb348f --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tCounter.h @@ -0,0 +1,219 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Counter_h__ +#define __nFRC_2012_1_6_4_Counter_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tCounter +{ +public: + tCounter(){} + virtual ~tCounter(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tCounter* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Direction : 1; + signed Value : 31; +#else + signed Value : 31; + unsigned Direction : 1; +#endif + }; + struct{ + unsigned value : 32; + }; + } tOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned UpSource_Channel : 4; + unsigned UpSource_Module : 1; + unsigned UpSource_AnalogTrigger : 1; + unsigned DownSource_Channel : 4; + unsigned DownSource_Module : 1; + unsigned DownSource_AnalogTrigger : 1; + unsigned IndexSource_Channel : 4; + unsigned IndexSource_Module : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexActiveHigh : 1; + unsigned UpRisingEdge : 1; + unsigned UpFallingEdge : 1; + unsigned DownRisingEdge : 1; + unsigned DownFallingEdge : 1; + unsigned Mode : 2; + unsigned PulseLengthThreshold : 6; + unsigned Enable : 1; +#else + unsigned Enable : 1; + unsigned PulseLengthThreshold : 6; + unsigned Mode : 2; + unsigned DownFallingEdge : 1; + unsigned DownRisingEdge : 1; + unsigned UpFallingEdge : 1; + unsigned UpRisingEdge : 1; + unsigned IndexActiveHigh : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexSource_Module : 1; + unsigned IndexSource_Channel : 4; + unsigned DownSource_AnalogTrigger : 1; + unsigned DownSource_Module : 1; + unsigned DownSource_Channel : 4; + unsigned UpSource_AnalogTrigger : 1; + unsigned UpSource_Module : 1; + unsigned UpSource_Channel : 4; +#endif + }; + struct{ + unsigned value : 32; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Period : 23; + signed Count : 8; + unsigned Stalled : 1; +#else + unsigned Stalled : 1; + signed Count : 8; + unsigned Period : 23; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned StallPeriod : 24; + unsigned AverageSize : 7; + unsigned UpdateWhenEmpty : 1; +#else + unsigned UpdateWhenEmpty : 1; + unsigned AverageSize : 7; + unsigned StallPeriod : 24; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerConfig; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual bool readOutput_Direction(tRioStatusCode *status) = 0; + virtual signed int readOutput_Value(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexActiveHigh(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpRisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpFallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownRisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownFallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Mode(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_PulseLengthThreshold(unsigned short value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_UpSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_UpSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_UpSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_DownSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_DownSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_DownSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexActiveHigh(tRioStatusCode *status) = 0; + virtual bool readConfig_UpRisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_UpFallingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_DownRisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_DownFallingEdge(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Mode(tRioStatusCode *status) = 0; + virtual unsigned short readConfig_PulseLengthThreshold(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerOutput_IfaceConstants; + + virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0; + virtual unsigned int readTimerOutput_Period(tRioStatusCode *status) = 0; + virtual signed char readTimerOutput_Count(tRioStatusCode *status) = 0; + virtual bool readTimerOutput_Stalled(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerConfig_IfaceConstants; + + virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_StallPeriod(unsigned int value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_AverageSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_UpdateWhenEmpty(bool value, tRioStatusCode *status) = 0; + virtual tTimerConfig readTimerConfig(tRioStatusCode *status) = 0; + virtual unsigned int readTimerConfig_StallPeriod(tRioStatusCode *status) = 0; + virtual unsigned char readTimerConfig_AverageSize(tRioStatusCode *status) = 0; + virtual bool readTimerConfig_UpdateWhenEmpty(tRioStatusCode *status) = 0; + + + + + +private: + tCounter(const tCounter&); + void operator=(const tCounter&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Counter_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tDIO.h b/hal/AthenaXX/src/main/native/ChipObject/tDIO.h new file mode 100644 index 0000000000..d9852c93ad --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tDIO.h @@ -0,0 +1,330 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_DIO_h__ +#define __nFRC_2012_1_6_4_DIO_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tDIO +{ +public: + tDIO(){} + virtual ~tDIO(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tDIO* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Period : 16; + unsigned MinHigh : 16; +#else + unsigned MinHigh : 16; + unsigned Period : 16; +#endif + }; + struct{ + unsigned value : 32; + }; + } tPWMConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned RelayFwd : 8; + unsigned RelayRev : 8; + unsigned I2CHeader : 4; +#else + unsigned I2CHeader : 4; + unsigned RelayRev : 8; + unsigned RelayFwd : 8; +#endif + }; + struct{ + unsigned value : 20; + }; + } tSlowValue; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Transaction : 1; + unsigned Done : 1; + unsigned Aborted : 1; + unsigned DataReceivedHigh : 24; +#else + unsigned DataReceivedHigh : 24; + unsigned Aborted : 1; + unsigned Done : 1; + unsigned Transaction : 1; +#endif + }; + struct{ + unsigned value : 27; + }; + } tI2CStatus; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Address : 8; + unsigned BytesToRead : 3; + unsigned BytesToWrite : 3; + unsigned DataToSendHigh : 16; + unsigned BitwiseHandshake : 1; +#else + unsigned BitwiseHandshake : 1; + unsigned DataToSendHigh : 16; + unsigned BytesToWrite : 3; + unsigned BytesToRead : 3; + unsigned Address : 8; +#endif + }; + struct{ + unsigned value : 31; + }; + } tI2CConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned PeriodPower : 4; + unsigned OutputSelect_0 : 4; + unsigned OutputSelect_1 : 4; + unsigned OutputSelect_2 : 4; + unsigned OutputSelect_3 : 4; +#else + unsigned OutputSelect_3 : 4; + unsigned OutputSelect_2 : 4; + unsigned OutputSelect_1 : 4; + unsigned OutputSelect_0 : 4; + unsigned PeriodPower : 4; +#endif + }; + struct{ + unsigned value : 20; + }; + } tDO_PWMConfig; + + + typedef enum + { + kNumFilterSelectElements = 16, + } tFilterSelect_IfaceConstants; + + virtual void writeFilterSelect(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readFilterSelect(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CDataToSend_IfaceConstants; + + virtual void writeI2CDataToSend(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readI2CDataToSend(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDO_IfaceConstants; + + virtual void writeDO(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readDO(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumFilterPeriodElements = 3, + } tFilterPeriod_IfaceConstants; + + virtual void writeFilterPeriod(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readFilterPeriod(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tOutputEnable_IfaceConstants; + + virtual void writeOutputEnable(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readOutputEnable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tPulse_IfaceConstants; + + virtual void writePulse(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readPulse(tRioStatusCode *status) = 0; + + + typedef enum + { + } tSlowValue_IfaceConstants; + + virtual void writeSlowValue(tSlowValue value, tRioStatusCode *status) = 0; + virtual void writeSlowValue_RelayFwd(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSlowValue_RelayRev(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSlowValue_I2CHeader(unsigned char value, tRioStatusCode *status) = 0; + virtual tSlowValue readSlowValue(tRioStatusCode *status) = 0; + virtual unsigned char readSlowValue_RelayFwd(tRioStatusCode *status) = 0; + virtual unsigned char readSlowValue_RelayRev(tRioStatusCode *status) = 0; + virtual unsigned char readSlowValue_I2CHeader(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CStatus_IfaceConstants; + + virtual tI2CStatus readI2CStatus(tRioStatusCode *status) = 0; + virtual unsigned char readI2CStatus_Transaction(tRioStatusCode *status) = 0; + virtual bool readI2CStatus_Done(tRioStatusCode *status) = 0; + virtual bool readI2CStatus_Aborted(tRioStatusCode *status) = 0; + virtual unsigned int readI2CStatus_DataReceivedHigh(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CDataReceived_IfaceConstants; + + virtual unsigned int readI2CDataReceived(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDI_IfaceConstants; + + virtual unsigned short readDI(tRioStatusCode *status) = 0; + + + typedef enum + { + } tPulseLength_IfaceConstants; + + virtual void writePulseLength(unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPulseLength(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumPWMPeriodScaleElements = 10, + } tPWMPeriodScale_IfaceConstants; + + virtual void writePWMPeriodScale(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPWMPeriodScale(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumDO_PWMDutyCycleElements = 4, + } tDO_PWMDutyCycle_IfaceConstants; + + virtual void writeDO_PWMDutyCycle(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMDutyCycle(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tBFL_IfaceConstants; + + virtual void writeBFL(bool value, tRioStatusCode *status) = 0; + virtual bool readBFL(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CConfig_IfaceConstants; + + virtual void writeI2CConfig(tI2CConfig value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_Address(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_BytesToRead(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_BytesToWrite(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_DataToSendHigh(unsigned short value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_BitwiseHandshake(bool value, tRioStatusCode *status) = 0; + virtual tI2CConfig readI2CConfig(tRioStatusCode *status) = 0; + virtual unsigned char readI2CConfig_Address(tRioStatusCode *status) = 0; + virtual unsigned char readI2CConfig_BytesToRead(tRioStatusCode *status) = 0; + virtual unsigned char readI2CConfig_BytesToWrite(tRioStatusCode *status) = 0; + virtual unsigned short readI2CConfig_DataToSendHigh(tRioStatusCode *status) = 0; + virtual bool readI2CConfig_BitwiseHandshake(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDO_PWMConfig_IfaceConstants; + + virtual void writeDO_PWMConfig(tDO_PWMConfig value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_PeriodPower(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_0(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_1(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_2(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_3(unsigned char value, tRioStatusCode *status) = 0; + virtual tDO_PWMConfig readDO_PWMConfig(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_PeriodPower(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_0(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_1(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_2(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_3(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CStart_IfaceConstants; + + virtual void strobeI2CStart(tRioStatusCode *status) = 0; + + + + typedef enum + { + } tLoopTiming_IfaceConstants; + + virtual unsigned short readLoopTiming(tRioStatusCode *status) = 0; + + + typedef enum + { + } tPWMConfig_IfaceConstants; + + virtual void writePWMConfig(tPWMConfig value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_Period(unsigned short value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_MinHigh(unsigned short value, tRioStatusCode *status) = 0; + virtual tPWMConfig readPWMConfig(tRioStatusCode *status) = 0; + virtual unsigned short readPWMConfig_Period(tRioStatusCode *status) = 0; + virtual unsigned short readPWMConfig_MinHigh(tRioStatusCode *status) = 0; + + + + typedef enum + { + kNumPWMValueRegisters = 10, + } tPWMValue_IfaceConstants; + + virtual void writePWMValue(unsigned char reg_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPWMValue(unsigned char reg_index, tRioStatusCode *status) = 0; + + + +private: + tDIO(const tDIO&); + void operator=(const tDIO&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_DIO_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tDMA.h b/hal/AthenaXX/src/main/native/ChipObject/tDMA.h new file mode 100644 index 0000000000..c46cad2e0b --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tDMA.h @@ -0,0 +1,188 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_DMA_h__ +#define __nFRC_2012_1_6_4_DMA_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tDMA +{ +public: + tDMA(){} + virtual ~tDMA(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tDMA* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Pause : 1; + unsigned Enable_AI0_Low : 1; + unsigned Enable_AI0_High : 1; + unsigned Enable_AIAveraged0_Low : 1; + unsigned Enable_AIAveraged0_High : 1; + unsigned Enable_AI1_Low : 1; + unsigned Enable_AI1_High : 1; + unsigned Enable_AIAveraged1_Low : 1; + unsigned Enable_AIAveraged1_High : 1; + unsigned Enable_Accumulator0 : 1; + unsigned Enable_Accumulator1 : 1; + unsigned Enable_DI : 1; + unsigned Enable_AnalogTriggers : 1; + unsigned Enable_Counters_Low : 1; + unsigned Enable_Counters_High : 1; + unsigned Enable_CounterTimers_Low : 1; + unsigned Enable_CounterTimers_High : 1; + unsigned Enable_Encoders : 1; + unsigned Enable_EncoderTimers : 1; + unsigned ExternalClock : 1; +#else + unsigned ExternalClock : 1; + unsigned Enable_EncoderTimers : 1; + unsigned Enable_Encoders : 1; + unsigned Enable_CounterTimers_High : 1; + unsigned Enable_CounterTimers_Low : 1; + unsigned Enable_Counters_High : 1; + unsigned Enable_Counters_Low : 1; + unsigned Enable_AnalogTriggers : 1; + unsigned Enable_DI : 1; + unsigned Enable_Accumulator1 : 1; + unsigned Enable_Accumulator0 : 1; + unsigned Enable_AIAveraged1_High : 1; + unsigned Enable_AIAveraged1_Low : 1; + unsigned Enable_AI1_High : 1; + unsigned Enable_AI1_Low : 1; + unsigned Enable_AIAveraged0_High : 1; + unsigned Enable_AIAveraged0_Low : 1; + unsigned Enable_AI0_High : 1; + unsigned Enable_AI0_Low : 1; + unsigned Pause : 1; +#endif + }; + struct{ + unsigned value : 20; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ExternalClockSource_Channel : 4; + unsigned ExternalClockSource_Module : 1; + unsigned ExternalClockSource_AnalogTrigger : 1; + unsigned RisingEdge : 1; + unsigned FallingEdge : 1; +#else + unsigned FallingEdge : 1; + unsigned RisingEdge : 1; + unsigned ExternalClockSource_AnalogTrigger : 1; + unsigned ExternalClockSource_Module : 1; + unsigned ExternalClockSource_Channel : 4; +#endif + }; + struct{ + unsigned value : 8; + }; + } tExternalTriggers; + + + + typedef enum + { + } tRate_IfaceConstants; + + virtual void writeRate(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readRate(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_Pause(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI0_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI0_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged0_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged0_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI1_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI1_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged1_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged1_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Accumulator0(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Accumulator1(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_DI(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AnalogTriggers(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Counters_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Counters_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_CounterTimers_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_CounterTimers_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Encoders(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_EncoderTimers(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_ExternalClock(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual bool readConfig_Pause(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI0_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI0_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged0_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged0_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI1_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI1_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged1_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged1_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Accumulator0(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Accumulator1(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_DI(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AnalogTriggers(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Counters_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Counters_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_CounterTimers_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_CounterTimers_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Encoders(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_EncoderTimers(tRioStatusCode *status) = 0; + virtual bool readConfig_ExternalClock(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumExternalTriggersElements = 4, + } tExternalTriggers_IfaceConstants; + + virtual void writeExternalTriggers(unsigned char bitfield_index, tExternalTriggers value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_Channel(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_Module(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_AnalogTrigger(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_RisingEdge(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_FallingEdge(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual tExternalTriggers readExternalTriggers(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual unsigned char readExternalTriggers_ExternalClockSource_Channel(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual unsigned char readExternalTriggers_ExternalClockSource_Module(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_ExternalClockSource_AnalogTrigger(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_RisingEdge(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_FallingEdge(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + +private: + tDMA(const tDMA&); + void operator=(const tDMA&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_DMA_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tDMAManager.h b/hal/AthenaXX/src/main/native/ChipObject/tDMAManager.h new file mode 100644 index 0000000000..ce292b1592 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tDMAManager.h @@ -0,0 +1,46 @@ +// Class for handling DMA transters. +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tDMAManager_h__ +#define __tDMAManager_h__ + +#include "tSystem.h" + +namespace nFPGA +{ +// TODO: Implement DMA Manager +/* +class tDMAManager : public tSystem +{ +public: + tDMAManager(tNIRIO_u32 dmaChannel, tNIRIO_u32 hostBufferSize, tRioStatusCode *status); + ~tDMAManager(); + void start(tRioStatusCode *status); + void stop(tRioStatusCode *status); + bool isStarted() {return _started;} + void read( + tNIRIO_u32* buf, + tNIRIO_u32 num, + tNIRIO_u32 timeout, + tNIRIO_u32* read, + tNIRIO_u32* remaining, + tRioStatusCode *status); + void write( + tNIRIO_u32* buf, + tNIRIO_u32 num, + tNIRIO_u32 timeout, + tNIRIO_u32* remaining, + tRioStatusCode *status); +private: + bool _started; + tNIRIO_u32 _dmaChannel; + tNIRIO_u32 _hostBufferSize; + tDMAChannelDescriptor const *_dmaChannelDescriptor; + +}; +*/ +} + + +#endif // __tDMAManager_h__ + diff --git a/hal/AthenaXX/src/main/native/ChipObject/tEncoder.h b/hal/AthenaXX/src/main/native/ChipObject/tEncoder.h new file mode 100644 index 0000000000..0b68067f64 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tEncoder.h @@ -0,0 +1,199 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Encoder_h__ +#define __nFRC_2012_1_6_4_Encoder_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tEncoder +{ +public: + tEncoder(){} + virtual ~tEncoder(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tEncoder* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 4, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Direction : 1; + signed Value : 31; +#else + signed Value : 31; + unsigned Direction : 1; +#endif + }; + struct{ + unsigned value : 32; + }; + } tOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ASource_Channel : 4; + unsigned ASource_Module : 1; + unsigned ASource_AnalogTrigger : 1; + unsigned BSource_Channel : 4; + unsigned BSource_Module : 1; + unsigned BSource_AnalogTrigger : 1; + unsigned IndexSource_Channel : 4; + unsigned IndexSource_Module : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexActiveHigh : 1; + unsigned Reverse : 1; + unsigned Enable : 1; +#else + unsigned Enable : 1; + unsigned Reverse : 1; + unsigned IndexActiveHigh : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexSource_Module : 1; + unsigned IndexSource_Channel : 4; + unsigned BSource_AnalogTrigger : 1; + unsigned BSource_Module : 1; + unsigned BSource_Channel : 4; + unsigned ASource_AnalogTrigger : 1; + unsigned ASource_Module : 1; + unsigned ASource_Channel : 4; +#endif + }; + struct{ + unsigned value : 21; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Period : 23; + signed Count : 8; + unsigned Stalled : 1; +#else + unsigned Stalled : 1; + signed Count : 8; + unsigned Period : 23; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerOutput; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned StallPeriod : 24; + unsigned AverageSize : 7; + unsigned UpdateWhenEmpty : 1; +#else + unsigned UpdateWhenEmpty : 1; + unsigned AverageSize : 7; + unsigned StallPeriod : 24; +#endif + }; + struct{ + unsigned value : 32; + }; + } tTimerConfig; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual bool readOutput_Direction(tRioStatusCode *status) = 0; + virtual signed int readOutput_Value(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexActiveHigh(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Reverse(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ASource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ASource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_ASource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_BSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexActiveHigh(tRioStatusCode *status) = 0; + virtual bool readConfig_Reverse(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerOutput_IfaceConstants; + + virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0; + virtual unsigned int readTimerOutput_Period(tRioStatusCode *status) = 0; + virtual signed char readTimerOutput_Count(tRioStatusCode *status) = 0; + virtual bool readTimerOutput_Stalled(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerConfig_IfaceConstants; + + virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_StallPeriod(unsigned int value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_AverageSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_UpdateWhenEmpty(bool value, tRioStatusCode *status) = 0; + virtual tTimerConfig readTimerConfig(tRioStatusCode *status) = 0; + virtual unsigned int readTimerConfig_StallPeriod(tRioStatusCode *status) = 0; + virtual unsigned char readTimerConfig_AverageSize(tRioStatusCode *status) = 0; + virtual bool readTimerConfig_UpdateWhenEmpty(tRioStatusCode *status) = 0; + + + + + +private: + tEncoder(const tEncoder&); + void operator=(const tEncoder&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Encoder_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tGlobal.h b/hal/AthenaXX/src/main/native/ChipObject/tGlobal.h new file mode 100644 index 0000000000..2dbbbe78f3 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tGlobal.h @@ -0,0 +1,70 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Global_h__ +#define __nFRC_2012_1_6_4_Global_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tGlobal +{ +public: + tGlobal(){} + virtual ~tGlobal(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tGlobal* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tVersion_IfaceConstants; + + virtual unsigned short readVersion(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLocalTime_IfaceConstants; + + virtual unsigned int readLocalTime(tRioStatusCode *status) = 0; + + + typedef enum + { + } tFPGA_LED_IfaceConstants; + + virtual void writeFPGA_LED(bool value, tRioStatusCode *status) = 0; + virtual bool readFPGA_LED(tRioStatusCode *status) = 0; + + + typedef enum + { + } tRevision_IfaceConstants; + + virtual unsigned int readRevision(tRioStatusCode *status) = 0; + + + + +private: + tGlobal(const tGlobal&); + void operator=(const tGlobal&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Global_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tInterrupt.h b/hal/AthenaXX/src/main/native/ChipObject/tInterrupt.h new file mode 100644 index 0000000000..519f6b319b --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tInterrupt.h @@ -0,0 +1,93 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Interrupt_h__ +#define __nFRC_2012_1_6_4_Interrupt_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tInterrupt +{ +public: + tInterrupt(){} + virtual ~tInterrupt(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tInterrupt* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned Source_Channel : 4; + unsigned Source_Module : 1; + unsigned Source_AnalogTrigger : 1; + unsigned RisingEdge : 1; + unsigned FallingEdge : 1; + unsigned WaitForAck : 1; +#else + unsigned WaitForAck : 1; + unsigned FallingEdge : 1; + unsigned RisingEdge : 1; + unsigned Source_AnalogTrigger : 1; + unsigned Source_Module : 1; + unsigned Source_Channel : 4; +#endif + }; + struct{ + unsigned value : 9; + }; + } tConfig; + + + typedef enum + { + } tTimeStamp_IfaceConstants; + + virtual unsigned int readTimeStamp(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_RisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_FallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_WaitForAck(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Source_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Source_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_Source_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_RisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_FallingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_WaitForAck(tRioStatusCode *status) = 0; + + + + + +private: + tInterrupt(const tInterrupt&); + void operator=(const tInterrupt&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Interrupt_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tInterruptManager.h b/hal/AthenaXX/src/main/native/ChipObject/tInterruptManager.h new file mode 100644 index 0000000000..b8fb361845 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tInterruptManager.h @@ -0,0 +1,61 @@ +// Class for handling interrupts. +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tInterruptManager_h__ +#define __tInterruptManager_h__ + +#include "tSystem.h" + +namespace ni +{ + namespace dsc + { + namespace osdep + { + class CriticalSection; + } + } +} + +namespace nFPGA +{ + +typedef void (*tInterruptHandler)(uint32_t interruptAssertedMask, void *param); + +class tInterruptManager : public tSystem +{ +public: + tInterruptManager(uint32_t interruptMask, bool watcher, tRioStatusCode *status); + ~tInterruptManager(); + void registerHandler(tInterruptHandler handler, void *param, tRioStatusCode *status); + uint32_t watch(int32_t timeoutInMs, tRioStatusCode *status); + void enable(tRioStatusCode *status); + void disable(tRioStatusCode *status); + bool isEnabled(tRioStatusCode *status); +private: + class tInterruptThread; + friend class tInterruptThread; + void handler(); + static int handlerWrapper(tInterruptManager *pInterrupt); + + void acknowledge(tRioStatusCode *status); + void reserve(tRioStatusCode *status); + void unreserve(tRioStatusCode *status); + tInterruptHandler _handler; + uint32_t _interruptMask; + tInterruptThread *_thread; + NiFpga_IrqContext _rioContext; + bool _watcher; + bool _enabled; + void *_userParam; + + // maintain the interrupts that are already dealt with. + static uint32_t _globalInterruptMask; + static ni::dsc::osdep::CriticalSection *_globalInterruptMaskSemaphore; +}; + +} + + +#endif // __tInterruptManager_h__ + diff --git a/hal/AthenaXX/src/main/native/ChipObject/tSPI.h b/hal/AthenaXX/src/main/native/ChipObject/tSPI.h new file mode 100644 index 0000000000..c74ec9b558 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tSPI.h @@ -0,0 +1,228 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_SPI_h__ +#define __nFRC_2012_1_6_4_SPI_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tSPI +{ +public: + tSPI(){} + virtual ~tSPI(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tSPI* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned ReceivedDataOverflow : 1; + unsigned Idle : 1; +#else + unsigned Idle : 1; + unsigned ReceivedDataOverflow : 1; +#endif + }; + struct{ + unsigned value : 2; + }; + } tStatus; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned BusBitWidth : 8; + unsigned ClockHalfPeriodDelay : 8; + unsigned MSBfirst : 1; + unsigned DataOnFalling : 1; + unsigned LatchFirst : 1; + unsigned LatchLast : 1; + unsigned FramePolarity : 1; + unsigned WriteOnly : 1; + unsigned ClockPolarity : 1; +#else + unsigned ClockPolarity : 1; + unsigned WriteOnly : 1; + unsigned FramePolarity : 1; + unsigned LatchLast : 1; + unsigned LatchFirst : 1; + unsigned DataOnFalling : 1; + unsigned MSBfirst : 1; + unsigned ClockHalfPeriodDelay : 8; + unsigned BusBitWidth : 8; +#endif + }; + struct{ + unsigned value : 23; + }; + } tConfig; + typedef + union{ + struct{ +#ifdef __vxworks + unsigned SCLK_Channel : 4; + unsigned SCLK_Module : 1; + unsigned MOSI_Channel : 4; + unsigned MOSI_Module : 1; + unsigned MISO_Channel : 4; + unsigned MISO_Module : 1; + unsigned SS_Channel : 4; + unsigned SS_Module : 1; +#else + unsigned SS_Module : 1; + unsigned SS_Channel : 4; + unsigned MISO_Module : 1; + unsigned MISO_Channel : 4; + unsigned MOSI_Module : 1; + unsigned MOSI_Channel : 4; + unsigned SCLK_Module : 1; + unsigned SCLK_Channel : 4; +#endif + }; + struct{ + unsigned value : 20; + }; + } tChannels; + + + + typedef enum + { + } tStatus_IfaceConstants; + + virtual tStatus readStatus(tRioStatusCode *status) = 0; + virtual bool readStatus_ReceivedDataOverflow(tRioStatusCode *status) = 0; + virtual bool readStatus_Idle(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReceivedData_IfaceConstants; + + virtual unsigned int readReceivedData(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDataToLoad_IfaceConstants; + + virtual void writeDataToLoad(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readDataToLoad(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_BusBitWidth(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ClockHalfPeriodDelay(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_MSBfirst(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DataOnFalling(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_LatchFirst(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_LatchLast(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_FramePolarity(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_WriteOnly(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_ClockPolarity(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BusBitWidth(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ClockHalfPeriodDelay(tRioStatusCode *status) = 0; + virtual bool readConfig_MSBfirst(tRioStatusCode *status) = 0; + virtual bool readConfig_DataOnFalling(tRioStatusCode *status) = 0; + virtual bool readConfig_LatchFirst(tRioStatusCode *status) = 0; + virtual bool readConfig_LatchLast(tRioStatusCode *status) = 0; + virtual bool readConfig_FramePolarity(tRioStatusCode *status) = 0; + virtual bool readConfig_WriteOnly(tRioStatusCode *status) = 0; + virtual bool readConfig_ClockPolarity(tRioStatusCode *status) = 0; + + + typedef enum + { + } tClearReceivedData_IfaceConstants; + + virtual void strobeClearReceivedData(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReceivedElements_IfaceConstants; + + virtual unsigned short readReceivedElements(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLoad_IfaceConstants; + + virtual void strobeLoad(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tChannels_IfaceConstants; + + virtual void writeChannels(tChannels value, tRioStatusCode *status) = 0; + virtual void writeChannels_SCLK_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_SCLK_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MOSI_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MOSI_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MISO_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MISO_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_SS_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_SS_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual tChannels readChannels(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SCLK_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SCLK_Module(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MOSI_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MOSI_Module(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MISO_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MISO_Module(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SS_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SS_Module(tRioStatusCode *status) = 0; + + + typedef enum + { + } tAvailableToLoad_IfaceConstants; + + virtual unsigned short readAvailableToLoad(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReadReceivedData_IfaceConstants; + + virtual void strobeReadReceivedData(tRioStatusCode *status) = 0; + + + + +private: + tSPI(const tSPI&); + void operator=(const tSPI&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_SPI_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tSolenoid.h b/hal/AthenaXX/src/main/native/ChipObject/tSolenoid.h new file mode 100644 index 0000000000..67c9a40103 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tSolenoid.h @@ -0,0 +1,50 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Solenoid_h__ +#define __nFRC_2012_1_6_4_Solenoid_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tSolenoid +{ +public: + tSolenoid(){} + virtual ~tSolenoid(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tSolenoid* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + kNumDO7_0Elements = 2, + } tDO7_0_IfaceConstants; + + virtual void writeDO7_0(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readDO7_0(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + +private: + tSolenoid(const tSolenoid&); + void operator=(const tSolenoid&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Solenoid_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tSysWatchdog.h b/hal/AthenaXX/src/main/native/ChipObject/tSysWatchdog.h new file mode 100644 index 0000000000..daca9b6d0f --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tSysWatchdog.h @@ -0,0 +1,71 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_SysWatchdog_h__ +#define __nFRC_2012_1_6_4_SysWatchdog_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tSysWatchdog +{ +public: + tSysWatchdog(){} + virtual ~tSysWatchdog(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tSysWatchdog* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tCommand_IfaceConstants; + + virtual void writeCommand(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readCommand(tRioStatusCode *status) = 0; + + + typedef enum + { + } tChallenge_IfaceConstants; + + virtual unsigned char readChallenge(tRioStatusCode *status) = 0; + + + typedef enum + { + } tActive_IfaceConstants; + + virtual void writeActive(bool value, tRioStatusCode *status) = 0; + virtual bool readActive(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimer_IfaceConstants; + + virtual unsigned int readTimer(tRioStatusCode *status) = 0; + + + + +private: + tSysWatchdog(const tSysWatchdog&); + void operator=(const tSysWatchdog&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_SysWatchdog_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tSystem.h b/hal/AthenaXX/src/main/native/ChipObject/tSystem.h new file mode 100644 index 0000000000..baf83a8f88 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tSystem.h @@ -0,0 +1,47 @@ +// Base class for generated chip objects +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tSystem_h__ +#define __tSystem_h__ + +#include "NiFpga.h" +typedef NiFpga_Status tRioStatusCode; + +#define FRC_FPGA_PRELOAD_BITFILE + +typedef uint32_t NiFpga_Session; + +namespace nFPGA +{ + +class tSystem +{ +public: + tSystem(tRioStatusCode *status); + ~tSystem(); + void getFpgaGuid(uint32_t *guid_ptr, tRioStatusCode *status); + +protected: + static NiFpga_Session _DeviceHandle; + +#ifdef FRC_FPGA_PRELOAD_BITFILE + void NiFpga_SharedOpen_common(const char* bitfile); + NiFpga_Status NiFpga_SharedOpen(const char* bitfile, + const char* signature, + const char* resource, + uint32_t attribute, + NiFpga_Session* session); + NiFpga_Status NiFpgaLv_SharedOpen(const char* const bitfile, + const char* const apiSignature, + const char* const resource, + const uint32_t attribute, + NiFpga_Session* const session); +private: + static char *_FileName; + static char *_Bitfile; +#endif +}; + +} + +#endif // __tSystem_h__ diff --git a/hal/AthenaXX/src/main/native/ChipObject/tSystemInterface.h b/hal/AthenaXX/src/main/native/ChipObject/tSystemInterface.h new file mode 100644 index 0000000000..46786e8e7d --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tSystemInterface.h @@ -0,0 +1,26 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tSystemInterface_h__ +#define __tSystemInterface_h__ + +namespace nFPGA +{ + +class tSystemInterface +{ +public: + tSystemInterface(){} + virtual ~tSystemInterface(){} + + virtual const uint16_t getExpectedFPGAVersion()=0; + virtual const uint32_t getExpectedFPGARevision()=0; + virtual const uint32_t * const getExpectedFPGASignature()=0; + virtual void getHardwareFpgaSignature(uint32_t *guid_ptr, tRioStatusCode *status)=0; + virtual uint32_t getLVHandle(tRioStatusCode *status)=0; + virtual uint32_t getHandle()=0; +}; + +} + +#endif // __tSystemInterface_h__ + diff --git a/hal/AthenaXX/src/main/native/ChipObject/tWatchdog.h b/hal/AthenaXX/src/main/native/ChipObject/tWatchdog.h new file mode 100644 index 0000000000..d4a4cba383 --- /dev/null +++ b/hal/AthenaXX/src/main/native/ChipObject/tWatchdog.h @@ -0,0 +1,108 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Watchdog_h__ +#define __nFRC_2012_1_6_4_Watchdog_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tWatchdog +{ +public: + tWatchdog(){} + virtual ~tWatchdog(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tWatchdog* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ +#ifdef __vxworks + unsigned SystemActive : 1; + unsigned Alive : 1; + unsigned SysDisableCount : 15; + unsigned DisableCount : 15; +#else + unsigned DisableCount : 15; + unsigned SysDisableCount : 15; + unsigned Alive : 1; + unsigned SystemActive : 1; +#endif + }; + struct{ + unsigned value : 32; + }; + } tStatus; + + + + typedef enum + { + } tStatus_IfaceConstants; + + virtual tStatus readStatus(tRioStatusCode *status) = 0; + virtual bool readStatus_SystemActive(tRioStatusCode *status) = 0; + virtual bool readStatus_Alive(tRioStatusCode *status) = 0; + virtual unsigned short readStatus_SysDisableCount(tRioStatusCode *status) = 0; + virtual unsigned short readStatus_DisableCount(tRioStatusCode *status) = 0; + + + typedef enum + { + } tKill_IfaceConstants; + + virtual void strobeKill(tRioStatusCode *status) = 0; + + + typedef enum + { + } tFeed_IfaceConstants; + + virtual void strobeFeed(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimer_IfaceConstants; + + virtual unsigned int readTimer(tRioStatusCode *status) = 0; + + + typedef enum + { + } tExpiration_IfaceConstants; + + virtual void writeExpiration(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readExpiration(tRioStatusCode *status) = 0; + + + typedef enum + { + } tImmortal_IfaceConstants; + + virtual void writeImmortal(bool value, tRioStatusCode *status) = 0; + virtual bool readImmortal(tRioStatusCode *status) = 0; + + + + +private: + tWatchdog(const tWatchdog&); + void operator=(const tWatchdog&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Watchdog_h__ diff --git a/hal/AthenaXX/src/main/native/Digital.cpp b/hal/AthenaXX/src/main/native/Digital.cpp new file mode 100644 index 0000000000..ae7095430a --- /dev/null +++ b/hal/AthenaXX/src/main/native/Digital.cpp @@ -0,0 +1,1492 @@ + +#include "HAL/Digital.h" + +#include "Port.h" +#include "HAL/HAL.h" +#include "ChipObject.h" +#include "HAL/cpp/Synchronized.h" +#include "HAL/cpp/Resource.h" +#include "NetworkCommunication/LoadOut.h" +#include +#include + +static const uint32_t kExpectedLoopTiming = 260; +static const uint32_t kDigitalPins = 14; +static const uint32_t kPwmPins = 10; +static const uint32_t kRelayPins = 8; +/** + * kDefaultPwmPeriod is in ms + * + * - 20ms periods (50 Hz) are the "safest" setting in that this works for all devices + * - 20ms periods seem to be desirable for Vex Motors + * - 20ms periods are the specified period for HS-322HD servos, but work reliably down + * to 10.0 ms; starting at about 8.5ms, the servo sometimes hums and get hot; + * by 5.0ms the hum is nearly continuous + * - 10ms periods work well for Victor 884 + * - 5ms periods allows higher update rates for Luminary Micro Jaguar speed controllers. + * Due to the shipping firmware on the Jaguar, we can't run the update period less + * than 5.05 ms. + * + * kDefaultPwmPeriod is the 1x period (5.05 ms). In hardware, the period scaling is implemented as an + * output squelch to get longer periods for old devices. + */ +static const float kDefaultPwmPeriod = 5.05; +/** + * kDefaultPwmCenter is the PWM range center in ms + */ +static const float kDefaultPwmCenter = 1.5; +/** + * kDefaultPWMStepsDown is the number of PWM steps below the centerpoint + */ +static const int32_t kDefaultPwmStepsDown = 128; +static const int32_t kPwmDisabled = 0; + +struct digital_port_t { + Port port; + tDIO *module; + uint32_t PWMGeneratorID; +}; +typedef struct digital_port_t DigitalPort; + +// XXX: Set these back to static once we figure out the memory clobbering issue +MUTEX_ID digitalDIOSemaphore = NULL; +MUTEX_ID digitalRelaySemaphore = NULL; +MUTEX_ID digitalPwmSemaphore = NULL; +MUTEX_ID digitalI2CSemaphore = NULL; +tDIO* digitalModules[2] = {NULL, NULL}; +Resource *DIOChannels = NULL; +Resource *DO_PWMGenerators[tDIO::kNumSystems] = {NULL}; + +bool digitalModulesInitialized = false; + +/** + * Initialize the digital modules. + */ +void initializeDigital(int32_t *status) { + if (digitalModulesInitialized) return; + + // Create a semaphore to protect changes to the digital output values + digitalDIOSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + // Create a semaphore to protect changes to the relay values + digitalRelaySemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + // Create a semaphore to protect changes to the DO PWM config + digitalPwmSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + digitalI2CSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + for (unsigned int i = 0; i < (sizeof(digitalModules)/sizeof(digitalModules[0])); i++) { + Resource::CreateResourceObject(&DIOChannels, tDIO::kNumSystems * kDigitalPins); + Resource::CreateResourceObject(&DO_PWMGenerators[i], tDIO::kNumDO_PWMDutyCycleElements); + digitalModules[i] = tDIO::create(i, status); + + // Make sure that the 9403 IONode has had a chance to initialize before continuing. + while(digitalModules[i]->readLoopTiming(status) == 0) delayTicks(1); + + if (digitalModules[i]->readLoopTiming(status) != kExpectedLoopTiming) { + // TODO: char err[128]; + // TODO: sprintf(err, "DIO LoopTiming: %d, expecting: %lu\n", digitalModules[port->module-1]->readLoopTiming(status), kExpectedLoopTiming); + *status = LOOP_TIMING_ERROR; // NOTE: Doesn't display the error + } + + //Calculate the length, in ms, of one DIO loop + double loopTime = digitalModules[i]->readLoopTiming(status)/(kSystemClockTicksPerMicrosecond*1e3); + + digitalModules[i]->writePWMConfig_Period((uint16_t) (kDefaultPwmPeriod/loopTime + .5), status); + digitalModules[i]->writePWMConfig_MinHigh((uint16_t) ((kDefaultPwmCenter-kDefaultPwmStepsDown*loopTime)/loopTime + .5), status); + + // Ensure that PWM output values are set to OFF + for (uint32_t pwm_index = 1; pwm_index <= kPwmPins; pwm_index++) { + // Initialize port structure + DigitalPort* digital_port = new DigitalPort(); + digital_port->port.pin = pwm_index; + digital_port->port.module = i + 1; + digital_port->module = digitalModules[i]; + + setPWM(digital_port, kPwmDisabled, status); + setPWMPeriodScale(digital_port, 3, status); // Set all to 4x by default. + } + + // Turn off all relay outputs. + digitalModules[i]->writeSlowValue_RelayFwd(0, status); + digitalModules[i]->writeSlowValue_RelayRev(0, status); + } + digitalModulesInitialized = true; +} + +/** + * Create a new instance of an digital module. + * Create an instance of the digital module object. Initialize all the parameters + * to reasonable values on start. + * Setting a global value on an digital module can be done only once unless subsequent + * values are set the previously set value. + * Digital modules are a singleton, so the constructor is never called outside of this class. + * + * @param moduleNumber The digital module to create (1 or 2). + */ +void* initializeDigitalPort(void* port_pointer, int32_t *status) { + initializeDigital(status); + Port* port = (Port*) port_pointer; + + // Initialize port structure + DigitalPort* digital_port = new DigitalPort(); + digital_port->port = *port; + digital_port->module = digitalModules[digital_port->port.module-1]; + + return digital_port; +} + +bool checkDigitalModule(uint8_t module) { + if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Digital, module - 1)) + return true; + return false; +} + +bool checkPWMChannel(void* digital_port_pointer) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + if (port->port.pin > 0 && port->port.pin <= kPwmPins) + return true; + return false; +} + +bool checkRelayChannel(void* digital_port_pointer) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + if (port->port.pin > 0 && port->port.pin <= kRelayPins) + return true; + return false; +} + +uint8_t remapDigitalChannel(uint32_t pin, int32_t *status) { + return 15 - pin; // TODO: Need channel validation +} + +uint8_t unmapDigitalChannel(uint32_t pin, int32_t *status) { + return 15 - pin; // TODO: Need channel validation +} + +/** + * Set a PWM channel to the desired value. The values range from 0 to 255 and the period is controlled + * by the PWM Period and MinHigh registers. + * + * @param channel The PWM channel to set. + * @param value The PWM value to set. + */ +void setPWM(void* digital_port_pointer, unsigned short value, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkPWMChannel(port); + port->module->writePWMValue(port->port.pin - 1, value, status); +} + +/** + * Get a value from a PWM channel. The values range from 0 to 255. + * + * @param channel The PWM channel to read from. + * @return The raw PWM value. + */ +unsigned short getPWM(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkPWMChannel(port); + return port->module->readPWMValue(port->port.pin - 1, status); +} + +/** + * Set how how often the PWM signal is squelched, thus scaling the period. + * + * @param channel The PWM channel to configure. + * @param squelchMask The 2-bit mask of outputs to squelch. + */ +void setPWMPeriodScale(void* digital_port_pointer, uint32_t squelchMask, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkPWMChannel(port); + port->module->writePWMPeriodScale(port->port.pin - 1, squelchMask, status); +} + +/** + * Allocate a DO PWM Generator. + * Allocate PWM generators so that they are not accidently reused. + * + * @return PWM Generator refnum + */ +void* allocatePWM(int32_t *status) { + return allocatePWMWithModule(0, status); +} + +/** + * Allocate a DO PWM Generator. + * Allocate PWM generators so that they are not accidently reused. + * + * @return PWM Generator refnum + */ +void* allocatePWMWithModule(uint8_t module, int32_t *status) { + char buf[64]; + snprintf(buf, 64, "DO_PWM (Module: %d)", module); + uint32_t* val = NULL; + *val = DO_PWMGenerators[(module - 1)]->Allocate(buf); + return val; +} + +/** + * Free the resource associated with a DO PWM generator. + * + * @param pwmGenerator The pwmGen to free that was allocated with AllocateDO_PWM() + */ +void freePWM(void* pwmGenerator, int32_t *status) { + freePWMWithModule(0, pwmGenerator, status); +} + +/** + * Free the resource associated with a DO PWM generator. + * + * @param pwmGenerator The pwmGen to free that was allocated with AllocateDO_PWM() + */ +void freePWMWithModule(uint8_t module, void* pwmGenerator, int32_t *status) { + uint32_t id = *((uint32_t*) pwmGenerator); + if (id == ~0ul) return; + DO_PWMGenerators[(module - 1)]->Free(id); +} + +/** + * Change the frequency of the DO PWM generator. + * + * The valid range is from 0.6 Hz to 19 kHz. The frequency resolution is logarithmic. + * + * @param rate The frequency to output all digital output PWM signals on this module. + */ +void setPWMRate(double rate, int32_t *status) { + setPWMRateWithModule(0, rate, status); +} + +/** + * Change the frequency of the DO PWM generator. + * + * The valid range is from 0.6 Hz to 19 kHz. The frequency resolution is logarithmic. + * + * @param rate The frequency to output all digital output PWM signals on this module. + */ +void setPWMRateWithModule(uint8_t module, double rate, int32_t *status) { + // Currently rounding in the log rate domain... heavy weight toward picking a higher freq. + // TODO: Round in the linear rate domain. + uint8_t pwmPeriodPower = (uint8_t)(log(1.0 / (digitalModules[module-1]->readLoopTiming(status) * 0.25E-6 * rate))/log(2.0) + 0.5); + digitalModules[module-1]->writeDO_PWMConfig_PeriodPower(pwmPeriodPower, status); +} + +/** + * Configure the duty-cycle of the PWM generator + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param dutyCycle The percent duty cycle to output [0..1]. + */ +void setPWMDutyCycle(void* pwmGenerator, double dutyCycle, int32_t *status) { + setPWMDutyCycleWithModule(0, pwmGenerator, dutyCycle, status); +} + +/** + * Configure the duty-cycle of the PWM generator + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param dutyCycle The percent duty cycle to output [0..1]. + */ +void setPWMDutyCycleWithModule(uint8_t module, void* pwmGenerator, double dutyCycle, int32_t *status) { + uint32_t id = *((uint32_t*) pwmGenerator); + if (id == ~0ul) return; + if (dutyCycle > 1.0) dutyCycle = 1.0; + if (dutyCycle < 0.0) dutyCycle = 0.0; + float rawDutyCycle = 256.0 * dutyCycle; + if (rawDutyCycle > 255.5) rawDutyCycle = 255.5; + { + Synchronized sync(digitalPwmSemaphore); + uint8_t pwmPeriodPower = digitalModules[module-1]->readDO_PWMConfig_PeriodPower(status); + if (pwmPeriodPower < 4) + { + // The resolution of the duty cycle drops close to the highest frequencies. + rawDutyCycle = rawDutyCycle / pow(2.0, 4 - pwmPeriodPower); + } + digitalModules[module-1]->writeDO_PWMDutyCycle(id, (uint8_t)rawDutyCycle, status); + } +} + +/** + * Configure which DO channel the PWM siganl is output on + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param channel The Digital Output channel to output on + */ +void setPWMOutputChannel(void* pwmGenerator, uint32_t pin, int32_t *status) { + setPWMOutputChannelWithModule(0, pwmGenerator, pin, status); +} + +/** + * Configure which DO channel the PWM siganl is output on + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param channel The Digital Output channel to output on + */ +void setPWMOutputChannelWithModule(uint8_t module, void* pwmGenerator, uint32_t pin, int32_t *status) { + uint32_t id = *((uint32_t*) pwmGenerator); + if (id == ~0ul) return; + switch(id) { + case 0: + digitalModules[module-1]->writeDO_PWMConfig_OutputSelect_0(remapDigitalChannel(pin - 1, status), status); + break; + case 1: + digitalModules[module-1]->writeDO_PWMConfig_OutputSelect_1(remapDigitalChannel(pin - 1, status), status); + break; + case 2: + digitalModules[module-1]->writeDO_PWMConfig_OutputSelect_2(remapDigitalChannel(pin - 1, status), status); + break; + case 3: + digitalModules[module-1]->writeDO_PWMConfig_OutputSelect_3(remapDigitalChannel(pin - 1, status), status); + break; + } +} + +/** + * Set the state of a relay. + * Set the state of a relay output to be forward. Relays have two outputs and each is + * independently set to 0v or 12v. + */ +void setRelayForward(void* digital_port_pointer, bool on, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkRelayChannel(port); + { + Synchronized sync(digitalRelaySemaphore); + uint8_t forwardRelays = port->module->readSlowValue_RelayFwd(status); + if (on) + forwardRelays |= 1 << (port->port.pin - 1); + else + forwardRelays &= ~(1 << (port->port.pin - 1)); + port->module->writeSlowValue_RelayFwd(forwardRelays, status); + } +} + +/** + * Set the state of a relay. + * Set the state of a relay output to be reverse. Relays have two outputs and each is + * independently set to 0v or 12v. + */ +void setRelayReverse(void* digital_port_pointer, bool on, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkRelayChannel(port); + { + Synchronized sync(digitalRelaySemaphore); + uint8_t reverseRelays = port->module->readSlowValue_RelayRev(status); + if (on) + reverseRelays |= 1 << (port->port.pin - 1); + else + reverseRelays &= ~(1 << (port->port.pin - 1)); + port->module->writeSlowValue_RelayRev(reverseRelays, status); + } +} + +/** + * Get the current state of the forward relay channel + */ +bool getRelayForward(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint8_t forwardRelays = port->module->readSlowValue_RelayFwd(status); + return (forwardRelays & (1 << (port->port.pin - 1))) != 0; +} + +/** + * Get the current state of the reverse relay channel + */ +bool getRelayReverse(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint8_t reverseRelays = port->module->readSlowValue_RelayRev(status); + return (reverseRelays & (1 << (port->port.pin - 1))) != 0; +} + +/** + * Allocate Digital I/O channels. + * Allocate channels so that they are not accidently reused. Also the direction is set at the + * time of the allocation. + * + * @param channel The Digital I/O channel + * @param input If true open as input; if false open as output + * @return Was successfully allocated + */ +bool allocateDIO(void* digital_port_pointer, bool input, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + char buf[64]; + snprintf(buf, 64, "DIO %d (Module %d)", port->port.pin, port->port.module); + if (DIOChannels->Allocate(kDigitalPins * (port->port.module - 1) + port->port.pin - 1, buf) == ~0ul) return false; + { + Synchronized sync(digitalDIOSemaphore); + uint32_t bitToSet = 1 << (remapDigitalChannel(port->port.pin - 1, status)); + uint32_t outputEnable = port->module->readOutputEnable(status); + uint32_t outputEnableValue; + if (input) { + outputEnableValue = outputEnable & (~bitToSet); // clear the bit for read + } else { + outputEnableValue = outputEnable | bitToSet; // set the bit for write + } + port->module->writeOutputEnable(outputEnableValue, status); + } + return true; +} + +/** + * Free the resource associated with a digital I/O channel. + * + * @param channel The Digital I/O channel to free + */ +void freeDIO(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + DIOChannels->Free(kDigitalPins * (port->port.module - 1) + port->port.pin - 1); +} + +/** + * Write a digital I/O bit to the FPGA. + * Set a single value on a digital I/O channel. + * + * @param channel The Digital I/O channel + * @param value The state to set the digital channel (if it is configured as an output) + */ +void setDIO(void* digital_port_pointer, short value, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + if (value != 0 && value != 1) { + if (value != 0) + value = 1; + } + { + Synchronized sync(digitalDIOSemaphore); + uint16_t currentDIO = port->module->readDO(status); + if(value == 0) { + currentDIO = currentDIO & ~(1 << remapDigitalChannel(port->port.pin - 1, status)); + } else if (value == 1) { + currentDIO = currentDIO | (1 << remapDigitalChannel(port->port.pin - 1, status)); + } + port->module->writeDO(currentDIO, status); + } +} + +/** + * Read a digital I/O bit from the FPGA. + * Get a single value from a digital I/O channel. + * + * @param channel The digital I/O channel + * @return The state of the specified channel + */ +bool getDIO(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint32_t currentDIO = port->module->readDI(status); + + //Shift 00000001 over channel-1 places. + //AND it against the currentDIO + //if it == 0, then return false + //else return true + return ((currentDIO >> remapDigitalChannel(port->port.pin - 1, status)) & 1) != 0; +} + +/** + * Read the direction of a the Digital I/O lines + * A 1 bit means output and a 0 bit means input. + * + * @param channel The digital I/O channel + * @return The direction of the specified channel + */ +bool getDIODirection(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint32_t currentOutputEnable = port->module->readOutputEnable(status); + + //Shift 00000001 over port->port.pin-1 places. + //AND it against the currentOutputEnable + //if it == 0, then return false + //else return true + return ((currentOutputEnable >> remapDigitalChannel(port->port.pin - 1, status)) & 1) != 0; +} + +/** + * Generate a single pulse. + * Write a pulse to the specified digital output channel. There can only be a single pulse going at any time. + * + * @param channel The Digital Output channel that the pulse should be output on + * @param pulseLength The active length of the pulse (in seconds) + */ +void pulse(void* digital_port_pointer, double pulseLength, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint16_t mask = 1 << remapDigitalChannel(port->port.pin - 1, status); + port->module->writePulseLength((uint8_t)(1.0e9 * pulseLength / (port->module->readLoopTiming(status) * 25)), status); + port->module->writePulse(mask, status); +} + +/** + * Check a DIO line to see if it is currently generating a pulse. + * + * @return A pulse is in progress + */ +bool isPulsing(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint16_t mask = 1 << remapDigitalChannel(port->port.pin - 1, status); + uint16_t pulseRegister = port->module->readPulse(status); + return (pulseRegister & mask) != 0; +} + +/** + * Check if any DIO line is currently generating a pulse. + * + * @return A pulse on some line is in progress + */ +bool isAnyPulsing(int32_t *status) { + return isAnyPulsingWithModule(1, status) || isAnyPulsingWithModule(2, status); +} + +/** + * Check if any DIO line is currently generating a pulse. + * + * @return A pulse on some line is in progress + */ +bool isAnyPulsingWithModule(uint8_t module, int32_t *status) { + uint16_t pulseRegister = digitalModules[module-1]->readPulse(status); + return pulseRegister != 0; +} + + + +struct counter_t { + tCounter* counter; + uint32_t index; +}; +typedef struct counter_t Counter; + +static Resource *counters = NULL; + +void* initializeCounter(Mode mode, uint32_t *index, int32_t *status) { + Resource::CreateResourceObject(&counters, tCounter::kNumSystems); + *index = counters->Allocate("Counter"); + if (*index == ~0ul) { + *status = NO_AVAILABLE_RESOURCES; + return NULL; + } + Counter* counter = new Counter(); + counter->counter = tCounter::create(*index, status); + counter->counter->writeConfig_Mode(mode, status); + counter->counter->writeTimerConfig_AverageSize(1, status); + counter->index = *index; + return counter; +} + +void freeCounter(void* counter_pointer, int32_t *status) { + if (counter_pointer != NULL) { + Counter* counter = (Counter*) counter_pointer; + delete counter->counter; + counters->Free(counter->index); + } else { + *status = NULL_PARAMETER; + } +} + +void setCounterAverageSize(void* counter_pointer, int32_t size, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeTimerConfig_AverageSize(size, status); +} + +/** + * Set the source object that causes the counter to count up. + * Set the up counting DigitalSource. + */ +void setCounterUpSourceWithModule(void* counter_pointer, uint8_t module, uint32_t pin, + bool analogTrigger, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + + counter->counter->writeConfig_UpSource_Module(module, status); + counter->counter->writeConfig_UpSource_Channel(pin, status); + counter->counter->writeConfig_UpSource_AnalogTrigger(analogTrigger, status); + + if(counter->counter->readConfig_Mode(status) == kTwoPulse || + counter->counter->readConfig_Mode(status) == kExternalDirection) { + setCounterUpSourceEdge(counter_pointer, true, false, status); + } + counter->counter->strobeReset(status); +} + +/** + * Set the edge sensitivity on an up counting source. + * Set the up source to either detect rising edges or falling edges. + */ +void setCounterUpSourceEdge(void* counter_pointer, bool risingEdge, bool fallingEdge, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_UpRisingEdge(risingEdge, status); + counter->counter->writeConfig_UpFallingEdge(fallingEdge, status); +} + +/** + * Disable the up counting source to the counter. + */ +void clearCounterUpSource(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + bool state = counter->counter->readConfig_Enable(status); + counter->counter->writeConfig_Enable(false, status); + counter->counter->writeConfig_UpFallingEdge(false, status); + counter->counter->writeConfig_UpRisingEdge(false, status); + // Index 0 of digital is always 0. + counter->counter->writeConfig_UpSource_Channel(0, status); + counter->counter->writeConfig_UpSource_AnalogTrigger(false, status); + counter->counter->writeConfig_Enable(state, status); +} + +/** + * Set the source object that causes the counter to count down. + * Set the down counting DigitalSource. + */ +void setCounterDownSourceWithModule(void* counter_pointer, uint8_t module, uint32_t pin, + bool analogTrigger, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + unsigned char mode = counter->counter->readConfig_Mode(status); + if (mode != kTwoPulse && mode != kExternalDirection) { + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "Counter only supports DownSource in TwoPulse and ExternalDirection modes."); + *status = PARAMETER_OUT_OF_RANGE; + return; + } + counter->counter->writeConfig_DownSource_Module(module, status); + counter->counter->writeConfig_DownSource_Channel(pin, status); + counter->counter->writeConfig_DownSource_AnalogTrigger(analogTrigger, status); + + setCounterDownSourceEdge(counter_pointer, true, false, status); + counter->counter->strobeReset(status); +} + +/** + * Set the edge sensitivity on a down counting source. + * Set the down source to either detect rising edges or falling edges. + */ +void setCounterDownSourceEdge(void* counter_pointer, bool risingEdge, bool fallingEdge, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_DownRisingEdge(risingEdge, status); + counter->counter->writeConfig_DownFallingEdge(fallingEdge, status); +} + +/** + * Disable the down counting source to the counter. + */ +void clearCounterDownSource(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + bool state = counter->counter->readConfig_Enable(status); + counter->counter->writeConfig_Enable(false, status); + counter->counter->writeConfig_DownFallingEdge(false, status); + counter->counter->writeConfig_DownRisingEdge(false, status); + // Index 0 of digital is always 0. + counter->counter->writeConfig_DownSource_Channel(0, status); + counter->counter->writeConfig_DownSource_AnalogTrigger(false, status); + counter->counter->writeConfig_Enable(state, status); +} + +/** + * Set standard up / down counting mode on this counter. + * Up and down counts are sourced independently from two inputs. + */ +void setCounterUpDownMode(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kTwoPulse, status); +} + +/** + * Set external direction mode on this counter. + * Counts are sourced on the Up counter input. + * The Down counter input represents the direction to count. + */ +void setCounterExternalDirectionMode(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kExternalDirection, status); +} + +/** + * Set Semi-period mode on this counter. + * Counts up on both rising and falling edges. + */ +void setCounterSemiPeriodMode(void* counter_pointer, bool highSemiPeriod, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kSemiperiod, status); + counter->counter->writeConfig_UpRisingEdge(highSemiPeriod, status); + setCounterUpdateWhenEmpty(counter_pointer, false, status); +} + +/** + * Configure the counter to count in up or down based on the length of the input pulse. + * This mode is most useful for direction sensitive gear tooth sensors. + * @param threshold The pulse length beyond which the counter counts the opposite direction. Units are seconds. + */ +void setCounterPulseLengthMode(void* counter_pointer, double threshold, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kPulseLength, status); + counter->counter->writeConfig_PulseLengthThreshold((uint32_t)(threshold * 1.0e6) * kSystemClockTicksPerMicrosecond, status); +} + +/** + * Get the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @return SamplesToAverage The number of samples being averaged (from 1 to 127) + */ +int32_t getCounterSamplesToAverage(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + return counter->counter->readTimerConfig_AverageSize(status); +} + +/** + * Set the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @param samplesToAverage The number of samples to average from 1 to 127. + */ +void setCounterSamplesToAverage(void* counter_pointer, int samplesToAverage, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + if (samplesToAverage < 1 || samplesToAverage > 127) { + *status = PARAMETER_OUT_OF_RANGE; + } + counter->counter->writeTimerConfig_AverageSize(samplesToAverage, status); +} + +/** + * Start the Counter counting. + * This enables the counter and it starts accumulating counts from the associated + * input channel. The counter value is not reset on starting, and still has the previous value. + */ +void startCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Enable(1, status); +} + +/** + * Stop the Counter. + * Stops the counting but doesn't effect the current value. + */ +void stopCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Enable(0, status); +} + +/** + * Reset the Counter to zero. + * Set the counter value to zero. This doesn't effect the running state of the counter, just sets + * the current value to zero. + */ +void resetCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->strobeReset(status); +} + +/** + * Read the current counter value. + * Read the value at this instant. It may still be running, so it reflects the current value. Next + * time it is read, it might have a different value. + */ +int32_t getCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + int32_t value = counter->counter->readOutput_Value(status); + return value; +} + +/* + * Get the Period of the most recent count. + * Returns the time interval of the most recent count. This can be used for velocity calculations + * to determine shaft speed. + * @returns The period of the last two pulses in units of seconds. + */ +double getCounterPeriod(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + tCounter::tTimerOutput output = counter->counter->readTimerOutput(status); + double period; + if (output.Stalled) { + // Return infinity + double zero = 0.0; + period = 1.0 / zero; + } else { + // output.Period is a fixed point number that counts by 2 (24 bits, 25 integer bits) + period = (double)(output.Period << 1) / (double)output.Count; + } + return period * 1.0e-6; +} + +/** + * Set the maximum period where the device is still considered "moving". + * Sets the maximum period where the device is considered moving. This value is used to determine + * the "stopped" state of the counter using the GetStopped method. + * @param maxPeriod The maximum period where the counted device is considered moving in + * seconds. + */ +void setCounterMaxPeriod(void* counter_pointer, double maxPeriod, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 1.0e6), status); +} + +/** + * Select whether you want to continue updating the event timer output when there are no samples captured. + * The output of the event timer has a buffer of periods that are averaged and posted to + * a register on the FPGA. When the timer detects that the event source has stopped + * (based on the MaxPeriod) the buffer of samples to be averaged is emptied. If you + * enable the update when empty, you will be notified of the stopped source and the event + * time will report 0 samples. If you disable update when empty, the most recent average + * will remain on the output until a new sample is acquired. You will never see 0 samples + * output (except when there have been no events since an FPGA reset) and you will likely not + * see the stopped bit become true (since it is updated at the end of an average and there are + * no samples to average). + */ +void setCounterUpdateWhenEmpty(void* counter_pointer, bool enabled, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeTimerConfig_UpdateWhenEmpty(enabled, status); +} + +/** + * Determine if the clock is stopped. + * Determine if the clocked input is stopped based on the MaxPeriod value set using the + * SetMaxPeriod method. If the clock exceeds the MaxPeriod, then the device (and counter) are + * assumed to be stopped and it returns true. + * @return Returns true if the most recent counter period exceeds the MaxPeriod value set by + * SetMaxPeriod. + */ +bool getCounterStopped(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + return counter->counter->readTimerOutput_Stalled(status); +} + +/** + * The last direction the counter value changed. + * @return The last direction the counter value changed. + */ +bool getCounterDirection(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + bool value = counter->counter->readOutput_Direction(status); + return value; +} + +/** + * Set the Counter to return reversed sensing on the direction. + * This allows counters to change the direction they are counting in the case of 1X and 2X + * quadrature encoding only. Any other counter mode isn't supported. + * @param reverseDirection true if the value counted should be negated. + */ +void setCounterReverseDirection(void* counter_pointer, bool reverseDirection, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + if (counter->counter->readConfig_Mode(status) == kExternalDirection) { + if (reverseDirection) + setCounterDownSourceEdge(counter_pointer, true, true, status); + else + setCounterDownSourceEdge(counter_pointer, false, true, status); + } +} + +struct encoder_t { + tEncoder* encoder; + uint32_t index; +}; +typedef struct encoder_t Encoder; + +static const double DECODING_SCALING_FACTOR = 0.25; +static Resource *quadEncoders = NULL; + +void* initializeEncoder(uint8_t port_a_module, uint32_t port_a_pin, bool port_a_analog_trigger, + uint8_t port_b_module, uint32_t port_b_pin, bool port_b_analog_trigger, + bool reverseDirection, int32_t *index, int32_t *status) { + + // Initialize encoder structure + Encoder* encoder = new Encoder(); + + Resource::CreateResourceObject(&quadEncoders, tEncoder::kNumSystems); + encoder->index = quadEncoders->Allocate("4X Encoder"); + *index = encoder->index; + // TODO: if (index == ~0ul) { CloneError(quadEncoders); return; } + encoder->encoder = tEncoder::create(encoder->index, status); + encoder->encoder->writeConfig_ASource_Module(port_a_module, status); + encoder->encoder->writeConfig_ASource_Channel(port_a_pin, status); + encoder->encoder->writeConfig_ASource_AnalogTrigger(port_a_analog_trigger, status); + encoder->encoder->writeConfig_BSource_Module(port_b_module, status); + encoder->encoder->writeConfig_BSource_Channel(port_b_pin, status); + encoder->encoder->writeConfig_BSource_AnalogTrigger(port_b_analog_trigger, status); + encoder->encoder->strobeReset(status); + encoder->encoder->writeConfig_Reverse(reverseDirection, status); + encoder->encoder->writeTimerConfig_AverageSize(4, status); + + return encoder; +} + +void freeEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + quadEncoders->Free(encoder->index); + delete encoder->encoder; +} + +/** + * Start the Encoder. + * Starts counting pulses on the Encoder device. + */ +void startEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeConfig_Enable(1, status); +} + +/** + * Stops counting pulses on the Encoder device. The value is not changed. + */ +void stopEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeConfig_Enable(0, status); +} + +/** + * Reset the Encoder distance to zero. + * Resets the current count to zero on the encoder. + */ +void resetEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->strobeReset(status); +} + +/** + * Gets the raw value from the encoder. + * The raw value is the actual count unscaled by the 1x, 2x, or 4x scale + * factor. + * @return Current raw count from the encoder + */ +int32_t getEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readOutput_Value(status); +} + +/** + * Returns the period of the most recent pulse. + * Returns the period of the most recent Encoder pulse in seconds. + * This method compenstates for the decoding type. + * + * @deprecated Use GetRate() in favor of this method. This returns unscaled periods and GetRate() scales using value from SetDistancePerPulse(). + * + * @return Period in seconds of the most recent pulse. + */ +double getEncoderPeriod(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + tEncoder::tTimerOutput output = encoder->encoder->readTimerOutput(status); + double value; + if (output.Stalled) { + // Return infinity + double zero = 0.0; + value = 1.0 / zero; + } else { + // output.Period is a fixed point number that counts by 2 (24 bits, 25 integer bits) + value = (double)(output.Period << 1) / (double)output.Count; + } + double measuredPeriod = value * 1.0e-6; + return measuredPeriod / DECODING_SCALING_FACTOR; +} + +/** + * Sets the maximum period for stopped detection. + * Sets the value that represents the maximum period of the Encoder before it will assume + * that the attached device is stopped. This timeout allows users to determine if the wheels or + * other shaft has stopped rotating. + * This method compensates for the decoding type. + * + * @deprecated Use SetMinRate() in favor of this method. This takes unscaled periods and SetMinRate() scales using value from SetDistancePerPulse(). + * + * @param maxPeriod The maximum time between rising and falling edges before the FPGA will + * report the device stopped. This is expressed in seconds. + */ +void setEncoderMaxPeriod(void* encoder_pointer, double maxPeriod, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 1.0e6 * DECODING_SCALING_FACTOR), status); +} + +/** + * Determine if the encoder is stopped. + * Using the MaxPeriod value, a boolean is returned that is true if the encoder is considered + * stopped and false if it is still moving. A stopped encoder is one where the most recent pulse + * width exceeds the MaxPeriod. + * @return True if the encoder is considered stopped. + */ +bool getEncoderStopped(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readTimerOutput_Stalled(status) != 0; +} + +/** + * The last direction the encoder value changed. + * @return The last direction the encoder value changed. + */ +bool getEncoderDirection(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readOutput_Direction(status); +} + +/** + * Set the direction sensing for this encoder. + * This sets the direction sensing on the encoder so that it could count in the correct + * software direction regardless of the mounting. + * @param reverseDirection true if the encoder direction should be reversed + */ +void setEncoderReverseDirection(void* encoder_pointer, bool reverseDirection, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeConfig_Reverse(reverseDirection, status); +} + +/** + * Set the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @param samplesToAverage The number of samples to average from 1 to 127. + */ +void setEncoderSamplesToAverage(void* encoder_pointer, uint32_t samplesToAverage, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + if (samplesToAverage < 1 || samplesToAverage > 127) { + *status = PARAMETER_OUT_OF_RANGE; + } + encoder->encoder->writeTimerConfig_AverageSize(samplesToAverage, status); +} + +/** + * Get the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @return SamplesToAverage The number of samples being averaged (from 1 to 127) + */ +uint32_t getEncoderSamplesToAverage(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readTimerConfig_AverageSize(status); +} + +/** + * Get the loop timing of the Digital Module + * + * @return The loop time + */ +uint16_t getLoopTiming(int32_t *status) { + return getLoopTimingWithModule(1, status); +} + +/** + * Get the loop timing of the Digital Module + * + * @return The loop time + */ +uint16_t getLoopTimingWithModule(uint8_t module, int32_t *status) { + return digitalModules[module-1]->readLoopTiming(status); +} + + +struct spi_t { + tSPI* spi; + tSPI::tConfig config; + tSPI::tChannels channels; + MUTEX_ID semaphore; +}; +typedef struct spi_t SPI; + +void* initializeSPI(uint8_t sclk_routing_module, uint32_t sclk_routing_pin, + uint8_t mosi_routing_module, uint32_t mosi_routing_pin, + uint8_t miso_routing_module, uint32_t miso_routing_pin, int32_t *status) { + SPI* spi = new SPI(); + + spi->semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + spi->spi = tSPI::create(status); + + spi->config.BusBitWidth = 8; + spi->config.ClockHalfPeriodDelay = 0; + spi->config.MSBfirst = 0; + spi->config.DataOnFalling = 0; + spi->config.LatchFirst = 0; + spi->config.LatchLast = 0; + spi->config.FramePolarity = 0; + spi->config.WriteOnly = miso_routing_pin ? 0 : 1; + spi->config.ClockPolarity = 0; + + spi->channels.SCLK_Channel = sclk_routing_pin; + spi->channels.SCLK_Module = sclk_routing_module; + spi->channels.SS_Channel = 0; + spi->channels.SS_Module = 0; + + if (mosi_routing_pin) { + spi->channels.MOSI_Channel = mosi_routing_pin; + spi->channels.MOSI_Module = mosi_routing_module; + } else { + spi->channels.MOSI_Channel = 0; + spi->channels.MOSI_Module = 0; + } + + if (miso_routing_pin) { + spi->channels.MISO_Channel = miso_routing_pin; + spi->channels.MISO_Module = miso_routing_module; + } else { + spi->channels.MISO_Channel = 0; + spi->channels.MISO_Module = 0; + } + return spi; +} + +void cleanSPI(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + delete spi->spi; + delete spi; +} + +/** + * Configure the number of bits from each word that the slave transmits + * or receives. + * + * @param bits The number of bits in one frame (1 to 32 bits). + */ +void setSPIBitsPerWord(void* spi_pointer, uint32_t bits, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.BusBitWidth = bits; +} + +/** + * Get the number of bits from each word that the slave transmits + * or receives. + * + * @return The number of bits in one frame (1 to 32 bits). + */ +uint32_t getSPIBitsPerWord(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + return spi->config.BusBitWidth; +} + +/** + * Configure the rate of the generated clock signal. + * The default and maximum value is 76,628.4 Hz. + * + * @param hz The clock rate in Hertz. + */ +void setSPIClockRate(void* spi_pointer, double hz, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + int delay = 0; + int loopTiming = getLoopTimingWithModule(spi->spi->readChannels_SCLK_Module(status), status); + double v = (1.0 / hz) / (2 * loopTiming / (kSystemClockTicksPerMicrosecond * 1e6)); + if (v < 1) { + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "SPI Clock too high"); + } + delay = (int) (v + .5); + if (delay > 255) { + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "SPI Clock too low"); + } + + spi->config.ClockHalfPeriodDelay = delay; +} + +/** + * Configure the order that bits are sent and received on the wire + * to be most significant bit first. + */ +void setSPIMSBFirst(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.MSBfirst = 1; +} + +/** + * Configure the order that bits are sent and received on the wire + * to be least significant bit first. + */ +void setSPILSBFirst(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.MSBfirst = 0; +} + +/** + * Configure that the data is stable on the falling edge and the data + * changes on the rising edge. + */ +void setSPISampleDataOnFalling(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.DataOnFalling = 1; +} + +/** + * Configure that the data is stable on the rising edge and the data + * changes on the falling edge. + */ +void setSPISampleDataOnRising(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.DataOnFalling = 0; +} + +void setSPISlaveSelect(void* spi_pointer, uint8_t ss_routing_module, uint32_t ss_routing_pin, + int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->channels.SS_Channel = ss_routing_pin; + spi->channels.SS_Module = ss_routing_module; +} + +void setSPILatchMode(void* spi_pointer, tFrameMode mode, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + switch (mode) { + case kChipSelect: + spi->config.LatchFirst = 0; + spi->config.LatchLast = 0; + break; + case kPreLatchPulse: + spi->config.LatchFirst = 1; + spi->config.LatchLast = 0; + break; + case kPostLatchPulse: + spi->config.LatchFirst = 0; + spi->config.LatchLast = 1; + break; + case kPreAndPostLatchPulse: + spi->config.LatchFirst = 1; + spi->config.LatchLast = 1; + break; + } +} + +tFrameMode getSPILatchMode(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + return (tFrameMode) (spi->config.LatchFirst | (spi->config.LatchLast << 1)); +} + +void setSPIFramePolarity(void* spi_pointer, bool activeLow, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.FramePolarity = activeLow ? 1 : 0; +} + +bool getSPIFramePolarity(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + return spi->config.FramePolarity != 0; +} + +/** + * Configure the clock output line to be active low. + * This is sometimes called clock polarity high. + */ +void setSPIClockActiveLow(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.ClockPolarity = 1; +} + +/** + * Configure the clock output line to be active high. + * This is sometimes called clock polarity low. + */ +void setSPIClockActiveHigh(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.ClockPolarity = 0; +} + + +/** + * Apply configuration settings and reset the SPI logic. + */ +void applySPIConfig(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + Synchronized sync(spi->semaphore); + + spi->spi->writeConfig(spi->config, status); + spi->spi->writeChannels(spi->channels, status); + spi->spi->strobeReset(status); +} + +/** + * Get the number of words that can currently be stored before being + * transmitted to the device. + * + * @return The number of words available to be written. + */ +uint16_t getSPIOutputFIFOAvailable(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + uint16_t result = spi->spi->readAvailableToLoad(status); + return result; +} + +/** + * Get the number of words received and currently available to be read from + * the receive FIFO. + * + * @return The number of words available to read. + */ +uint16_t getSPINumReceived(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + uint16_t result = spi->spi->readReceivedElements(status); + return result; +} + +/** + * Have all pending transfers completed? + * + * @return True if no transfers are pending. + */ +bool isSPIDone(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + bool result = spi->spi->readStatus_Idle(status); + return result; +} + + +/** + * Determine if the receive FIFO was full when attempting to add new data at + * end of a transfer. + * + * @return True if the receive FIFO overflowed. + */ +bool hadSPIReceiveOverflow(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + bool result = spi->spi->readStatus_ReceivedDataOverflow(status); + return result; +} + +/** + * Write a word to the slave device. Blocks until there is space in the + * output FIFO. + * + * If not running in output only mode, also saves the data received + * on the MISO input during the transfer into the receive FIFO. + */ +void writeSPI(void* spi_pointer, uint32_t data, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + if (spi->channels.MOSI_Channel == 0 && spi->channels.MOSI_Module == 0) { + *status = SPI_WRITE_NO_MOSI; + return; + } + + Synchronized sync(spi->semaphore); + + while (getSPIOutputFIFOAvailable(spi_pointer, status) == 0) + delayTicks(HAL_NO_WAIT); + + spi->spi->writeDataToLoad(data, status); + spi->spi->strobeLoad(status); +} + +/** + * Read a word from the receive FIFO. + * + * Waits for the current transfer to complete if the receive FIFO is empty. + * + * If the receive FIFO is empty, there is no active transfer, and initiate + * is false, errors. + * + * @param initiate If true, this function pushes "0" into the + * transmit buffer and initiates a transfer. + * If false, this function assumes that data is + * already in the receive FIFO from a previous write. + */ +uint32_t readSPI(void* spi_pointer, bool initiate, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + if (spi->channels.MISO_Channel == 0 && spi->channels.MISO_Module == 0) { + *status = SPI_READ_NO_MISO; + return 0; + } + + uint32_t data; + { + Synchronized sync(spi->semaphore); + + if (initiate) { + spi->spi->writeDataToLoad(0, status); + spi->spi->strobeLoad(status); + } + + // Do we have anything ready to read? + if (getSPINumReceived(spi_pointer, status) == 0) { + if (!initiate && isSPIDone(spi_pointer, status) + && getSPIOutputFIFOAvailable(spi_pointer, status) == kTransmitFIFODepth) { + // Nothing to read: error out + *status = SPI_READ_NO_DATA; + return 0; + } + + // Wait for the transaction to complete + while (getSPINumReceived(spi_pointer, status) == 0) + delayTicks(HAL_NO_WAIT); + } + + spi->spi->strobeReadReceivedData(status); + data = spi->spi->readReceivedData(status); + } + + return data; +} + +/** + * Stop any transfer in progress and empty the transmit FIFO. + */ +void resetSPI(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->spi->strobeReset(status); +} + +/** + * Empty the receive FIFO. + */ +void clearSPIReceivedData(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->spi->strobeClearReceivedData(status); +} + +/** + * Generic transaction. + * + * This is a lower-level interface to the I2C hardware giving you more control over each transaction. + * + * @param dataToSend Buffer of data to send as part of the transaction. + * @param sendSize Number of bytes to send as part of the transaction. [0..6] + * @param dataReceived Buffer to read data into. + * @param receiveSize Number of byted to read from the device. [0..7] + * @return Transfer Aborted... false for success, true for aborted. + */ +bool doI2CTransaction(uint8_t address, bool compatibilityMode, uint8_t *dataToSend, + uint8_t sendSize, uint8_t *dataReceived, uint8_t receiveSize, + int32_t *status) { + return doI2CTransactionWithModule(1, address, compatibilityMode, dataToSend, sendSize, + dataReceived, receiveSize, status); +} + +/** + * Generic transaction. + * + * This is a lower-level interface to the I2C hardware giving you more control over each transaction. + * + * @param dataToSend Buffer of data to send as part of the transaction. + * @param sendSize Number of bytes to send as part of the transaction. [0..6] + * @param dataReceived Buffer to read data into. + * @param receiveSize Number of byted to read from the device. [0..7] + * @return Transfer Aborted... false for success, true for aborted. + */ +bool doI2CTransactionWithModule(uint8_t module, uint8_t address, bool compatibilityMode, + uint8_t *dataToSend, uint8_t sendSize, uint8_t *dataReceived, + uint8_t receiveSize, int32_t *status) { + initializeDigital(status); + if (sendSize > 6) { + *status = PARAMETER_OUT_OF_RANGE; + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "sendSize"); + return true; + } + if (receiveSize > 7) { + *status = PARAMETER_OUT_OF_RANGE; + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "receiveSize"); + return true; + } + + uint32_t data=0; + uint32_t dataHigh=0; + uint32_t i; + for(i=0; iwriteI2CConfig_Address(address, status); + digitalModules[module]->writeI2CConfig_BytesToWrite(sendSize, status); + digitalModules[module]->writeI2CConfig_BytesToRead(receiveSize, status); + if (sendSize > 0) digitalModules[module]->writeI2CDataToSend(data, status); + if (sendSize > sizeof(data)) digitalModules[module]->writeI2CConfig_DataToSendHigh(dataHigh, status); + digitalModules[module]->writeI2CConfig_BitwiseHandshake(compatibilityMode, status); + uint8_t transaction = digitalModules[module]->readI2CStatus_Transaction(status); + digitalModules[module]->strobeI2CStart(status); + while(transaction == digitalModules[module]->readI2CStatus_Transaction(status)) delayTicks(1); + while(!digitalModules[module]->readI2CStatus_Done(status)) delayTicks(1); + aborted = digitalModules[module]->readI2CStatus_Aborted(status); + if (receiveSize > 0) data = digitalModules[module]->readI2CDataReceived(status); + if (receiveSize > sizeof(data)) dataHigh = digitalModules[module]->readI2CStatus_DataReceivedHigh(status); + } + + for(i=0; i> (8*i)) & 0xFF; + } + for(; i> (8*(i-sizeof(data)))) & 0xFF; + } + return aborted; +} diff --git a/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/AICalibration.h b/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/AICalibration.h new file mode 100644 index 0000000000..39755bda89 --- /dev/null +++ b/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/AICalibration.h @@ -0,0 +1,19 @@ + +#ifndef __AICalibration_h__ +#define __AICalibration_h__ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + uint32_t FRC_NetworkCommunication_nAICalibration_getLSBWeight(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status); + int32_t FRC_NetworkCommunication_nAICalibration_getOffset(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status); + +#ifdef __cplusplus +} +#endif + +#endif // __AICalibration_h__ diff --git a/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/FRCComm.h b/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/FRCComm.h new file mode 100644 index 0000000000..e971fac1a5 --- /dev/null +++ b/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/FRCComm.h @@ -0,0 +1,193 @@ +/************************************************************* + * NOTICE + * + * These are the only externally exposed functions to the + * NetworkCommunication library + * + * This is an implementation of FRC Spec for Comm Protocol + * Revision 4.5, June 30, 2008 + * + * Copyright (c) National Instruments 2008. All Rights Reserved. + * + *************************************************************/ + +#ifndef __FRC_COMM_H__ +#define __FRC_COMM_H__ + +#ifdef SIMULATION +#include +#define EXPORT_FUNC __declspec(dllexport) __cdecl +#else +#if defined(__vxworks) +#include +#define EXPORT_FUNC +#else +#include +#include +#define EXPORT_FUNC +#endif +#endif + +// Commandeer some bytes at the end for advanced I/O feedback. +#define IO_CONFIG_DATA_SIZE 32 +#define SYS_STATUS_DATA_SIZE 44 +#define USER_STATUS_DATA_SIZE (984 - IO_CONFIG_DATA_SIZE - SYS_STATUS_DATA_SIZE) +#define USER_DS_LCD_DATA_SIZE 128 + +struct FRCCommonControlData{ + uint16_t packetIndex; + union { + uint8_t control; +#ifndef __vxworks + struct { + uint8_t checkVersions :1; + uint8_t test :1; + uint8_t resync : 1; + uint8_t fmsAttached:1; + uint8_t autonomous : 1; + uint8_t enabled : 1; + uint8_t notEStop : 1; + uint8_t reset : 1; + }; +#else + struct { + uint8_t reset : 1; + uint8_t notEStop : 1; + uint8_t enabled : 1; + uint8_t autonomous : 1; + uint8_t fmsAttached:1; + uint8_t resync : 1; + uint8_t test :1; + uint8_t checkVersions :1; + }; +#endif + }; + uint8_t dsDigitalIn; + uint16_t teamID; + + char dsID_Alliance; + char dsID_Position; + + union { + int8_t stick0Axes[6]; + struct { + int8_t stick0Axis1; + int8_t stick0Axis2; + int8_t stick0Axis3; + int8_t stick0Axis4; + int8_t stick0Axis5; + int8_t stick0Axis6; + }; + }; + uint16_t stick0Buttons; // Left-most 4 bits are unused + + union { + int8_t stick1Axes[6]; + struct { + int8_t stick1Axis1; + int8_t stick1Axis2; + int8_t stick1Axis3; + int8_t stick1Axis4; + int8_t stick1Axis5; + int8_t stick1Axis6; + }; + }; + uint16_t stick1Buttons; // Left-most 4 bits are unused + + union { + int8_t stick2Axes[6]; + struct { + int8_t stick2Axis1; + int8_t stick2Axis2; + int8_t stick2Axis3; + int8_t stick2Axis4; + int8_t stick2Axis5; + int8_t stick2Axis6; + }; + }; + uint16_t stick2Buttons; // Left-most 4 bits are unused + + union { + int8_t stick3Axes[6]; + struct { + int8_t stick3Axis1; + int8_t stick3Axis2; + int8_t stick3Axis3; + int8_t stick3Axis4; + int8_t stick3Axis5; + int8_t stick3Axis6; + }; + }; + uint16_t stick3Buttons; // Left-most 4 bits are unused + + //Analog inputs are 10 bit right-justified + uint16_t analog1; + uint16_t analog2; + uint16_t analog3; + uint16_t analog4; + + uint64_t cRIOChecksum; + uint32_t FPGAChecksum0; + uint32_t FPGAChecksum1; + uint32_t FPGAChecksum2; + uint32_t FPGAChecksum3; + + char versionData[8]; +}; + +#define kFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Input 17 +#define kFRC_NetworkCommunication_DynamicType_DSEnhancedIO_Output 18 +#define kFRC_NetworkCommunication_DynamicType_Kinect_Header 19 +#define kFRC_NetworkCommunication_DynamicType_Kinect_Extra1 20 +#define kFRC_NetworkCommunication_DynamicType_Kinect_Vertices1 21 +#define kFRC_NetworkCommunication_DynamicType_Kinect_Extra2 22 +#define kFRC_NetworkCommunication_DynamicType_Kinect_Vertices2 23 +#define kFRC_NetworkCommunication_DynamicType_Kinect_Joystick 24 +#define kFRC_NetworkCommunication_DynamicType_Kinect_Custom 25 + +extern "C" { +#ifndef SIMULATION + void EXPORT_FUNC getFPGAHardwareVersion(uint16_t *fpgaVersion, uint32_t *fpgaRevision); +#endif + int EXPORT_FUNC getCommonControlData(FRCCommonControlData *data, int wait_ms); + int EXPORT_FUNC getRecentCommonControlData(FRCCommonControlData *commonData, int wait_ms); + int EXPORT_FUNC getRecentStatusData(uint8_t *batteryInt, uint8_t *batteryDec, uint8_t *dsDigitalOut, int wait_ms); + int EXPORT_FUNC getDynamicControlData(uint8_t type, char *dynamicData, int32_t maxLength, int wait_ms); + int EXPORT_FUNC setStatusData(float battery, uint8_t dsDigitalOut, uint8_t updateNumber, + const char *userDataHigh, int userDataHighLength, + const char *userDataLow, int userDataLowLength, int wait_ms); + int EXPORT_FUNC setStatusDataFloatAsInt(int battery, uint8_t dsDigitalOut, uint8_t updateNumber, + const char *userDataHigh, int userDataHighLength, + const char *userDataLow, int userDataLowLength, int wait_ms); + int EXPORT_FUNC setErrorData(const char *errors, int errorsLength, int wait_ms); + int EXPORT_FUNC setUserDsLcdData(const char *userDsLcdData, int userDsLcdDataLength, int wait_ms); + int EXPORT_FUNC overrideIOConfig(const char *ioConfig, int wait_ms); + +#ifdef SIMULATION + void EXPORT_FUNC setNewDataSem(HANDLE); +#else +# if defined (__vxworks) + void EXPORT_FUNC setNewDataSem(SEM_ID); + void EXPORT_FUNC setResyncSem(SEM_ID); +# else + void EXPORT_FUNC setNewDataSem(pthread_mutex_t *); + void EXPORT_FUNC setResyncSem(pthread_mutex_t *); +# endif + void EXPORT_FUNC signalResyncActionDone(void); +#endif + + // this uint32_t is really a LVRefNum + void EXPORT_FUNC setNewDataOccurRef(uint32_t refnum); +#ifndef SIMULATION + void EXPORT_FUNC setResyncOccurRef(uint32_t refnum); +#endif + + void EXPORT_FUNC FRC_NetworkCommunication_getVersionString(char *version); + void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramStarting(void); + void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramDisabled(void); + void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramAutonomous(void); + void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramTeleop(void); + void EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramTest(void); +}; + +#endif diff --git a/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/LoadOut.h b/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/LoadOut.h new file mode 100644 index 0000000000..0304b30665 --- /dev/null +++ b/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/LoadOut.h @@ -0,0 +1,52 @@ + +#ifndef __LoadOut_h__ +#define __LoadOut_h__ + +#ifdef SIMULATION +#include +#define EXPORT_FUNC __declspec(dllexport) __cdecl +#elif defined (__vxworks) +#include +#define EXPORT_FUNC +#else +#include +#define EXPORT_FUNC +#endif + +#define kMaxModuleNumber 2 +namespace nLoadOut +{ + typedef enum { + kModuleType_Unknown = 0x00, + kModuleType_Analog = 0x01, + kModuleType_Digital = 0x02, + kModuleType_Solenoid = 0x03, + } tModuleType; + bool EXPORT_FUNC getModulePresence(tModuleType moduleType, uint8_t moduleNumber); + typedef enum { + kTargetClass_Unknown = 0x00, + kTargetClass_FRC1 = 0x10, + kTargetClass_FRC2 = 0x20, + kTargetClass_FRC3 = 0x30, + kTargetClass_RoboRIO = 0x40, + kTargetClass_FRC2_Analog = kTargetClass_FRC2 | kModuleType_Analog, + kTargetClass_FRC2_Digital = kTargetClass_FRC2 | kModuleType_Digital, + kTargetClass_FRC2_Solenoid = kTargetClass_FRC2 | kModuleType_Solenoid, + kTargetClass_FamilyMask = 0xF0, + kTargetClass_ModuleMask = 0x0F, + } tTargetClass; + tTargetClass EXPORT_FUNC getTargetClass(); +} + +#ifdef __cplusplus +extern "C" { +#endif + + uint32_t EXPORT_FUNC FRC_NetworkCommunication_nLoadOut_getModulePresence(uint32_t moduleType, uint8_t moduleNumber); + uint32_t EXPORT_FUNC FRC_NetworkCommunication_nLoadOut_getTargetClass(); + +#ifdef __cplusplus +} +#endif + +#endif // __LoadOut_h__ diff --git a/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/UsageReporting.h b/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/UsageReporting.h new file mode 100644 index 0000000000..2c7499ea61 --- /dev/null +++ b/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/UsageReporting.h @@ -0,0 +1,139 @@ + +#ifndef __UsageReporting_h__ +#define __UsageReporting_h__ + +#ifdef SIMULATION +#include +#define EXPORT_FUNC __declspec(dllexport) __cdecl +#elif defined (__vxworks) +#include +#define EXPORT_FUNC +#else +#include +#include +#define EXPORT_FUNC +#endif + +#define kUsageReporting_version 1 + +namespace nUsageReporting +{ + typedef enum + { + kResourceType_Controller, + kResourceType_Module, + kResourceType_Language, + kResourceType_CANPlugin, + kResourceType_Accelerometer, + kResourceType_ADXL345, + kResourceType_AnalogChannel, + kResourceType_AnalogTrigger, + kResourceType_AnalogTriggerOutput, + kResourceType_CANJaguar, + kResourceType_Compressor, + kResourceType_Counter, + kResourceType_Dashboard, + kResourceType_DigitalInput, + kResourceType_DigitalOutput, + kResourceType_DriverStationCIO, + kResourceType_DriverStationEIO, + kResourceType_DriverStationLCD, + kResourceType_Encoder, + kResourceType_GearTooth, + kResourceType_Gyro, + kResourceType_I2C, + kResourceType_Framework, + kResourceType_Jaguar, + kResourceType_Joystick, + kResourceType_Kinect, + kResourceType_KinectStick, + kResourceType_PIDController, + kResourceType_Preferences, + kResourceType_PWM, + kResourceType_Relay, + kResourceType_RobotDrive, + kResourceType_SerialPort, + kResourceType_Servo, + kResourceType_Solenoid, + kResourceType_SPI, + kResourceType_Task, + kResourceType_Ultrasonic, + kResourceType_Victor, + kResourceType_Button, + kResourceType_Command, + kResourceType_AxisCamera, + kResourceType_PCVideoServer, + kResourceType_SmartDashboard, + kResourceType_Talon, + kResourceType_HiTechnicColorSensor, + kResourceType_HiTechnicAccel, + kResourceType_HiTechnicCompass, + kResourceType_SRF08, + } tResourceType; + + typedef enum + { + kLanguage_LabVIEW = 1, + kLanguage_CPlusPlus = 2, + kLanguage_Java = 3, + kLanguage_Python = 4, + + kCANPlugin_BlackJagBridge = 1, + kCANPlugin_2CAN = 2, + + kFramework_Iterative = 1, + kFramework_Simple = 2, + + kRobotDrive_ArcadeStandard = 1, + kRobotDrive_ArcadeButtonSpin = 2, + kRobotDrive_ArcadeRatioCurve = 3, + kRobotDrive_Tank = 4, + kRobotDrive_MecanumPolar = 5, + kRobotDrive_MecanumCartesian = 6, + + kDriverStationCIO_Analog = 1, + kDriverStationCIO_DigitalIn = 2, + kDriverStationCIO_DigitalOut = 3, + + kDriverStationEIO_Acceleration = 1, + kDriverStationEIO_AnalogIn = 2, + kDriverStationEIO_AnalogOut = 3, + kDriverStationEIO_Button = 4, + kDriverStationEIO_LED = 5, + kDriverStationEIO_DigitalIn = 6, + kDriverStationEIO_DigitalOut = 7, + kDriverStationEIO_FixedDigitalOut = 8, + kDriverStationEIO_PWM = 9, + kDriverStationEIO_Encoder = 10, + kDriverStationEIO_TouchSlider = 11, + + kADXL345_SPI = 1, + kADXL345_I2C = 2, + + kCommand_Scheduler = 1, + + kSmartDashboard_Instance = 1, + } tInstances; + + /** + * Report the usage of a resource of interest. + * + * @param resource one of the values in the tResourceType above (max value 51). + * @param instanceNumber an index that identifies the resource instance. + * @param context an optional additional context number for some cases (such as module number). Set to 0 to omit. + * @param feature a string to be included describing features in use on a specific resource. Setting the same resource more than once allows you to change the feature string. + */ + uint32_t EXPORT_FUNC report(tResourceType resource, uint8_t instanceNumber, uint8_t context = 0, const char *feature = NULL); +} + +#ifdef __cplusplus +extern "C" { +#endif + + uint32_t EXPORT_FUNC FRC_NetworkCommunication_nUsageReporting_report(uint8_t resource, uint8_t instanceNumber, uint8_t context, const char *feature); + +#ifdef __cplusplus +} +#endif + +#endif // __UsageReporting_h__ diff --git a/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/environs.h b/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/environs.h new file mode 100644 index 0000000000..f3dad7f52d --- /dev/null +++ b/hal/AthenaXX/src/main/native/FRC_NetworkCommunication/environs.h @@ -0,0 +1,94 @@ +/*! + \file environs.h + \brief Defines export symbols and namespace aliases +*/ +/* + Copyright (c) 2013, + National Instruments Corporation. + All rights reserved. + + File: $Id: //lvaddon/FIRST/FRC/trunk/2015/tools/FRCNetworkCommunication/export/1.5/1.5.0a3/includes/FRC_NetworkCommunication/environs.h#1 $ + Author: nipg.pl + Originated: Wed Aug 28 16:07:10 2013 +*/ + +#ifndef ___FRC_NetworkCommunication_environs_h___ +#define ___FRC_NetworkCommunication_environs_h___ + +#include + +/* + * kFRC_NETWORKCOMMUNICATIONExportSymbols directs the build to export symbols modified by + * the kFRC_NETWORKCOMMUNICATIONExport keyword. kFRC_NETWORKCOMMUNICATIONNoExportSymbols directs the build to not + * import or export symbols modified by the kFRC_NETWORKCOMMUNICATIONExport keyword. If + * neither of these are defined, the symbols modified by kFRC_NETWORKCOMMUNICATIONExport are + * imported. These should be defined only when building the component, + * so clients do not need to trouble themselves with it. + */ +#if defined(kFRC_NETWORKCOMMUNICATIONExportSymbols) + #define kFRC_NETWORKCOMMUNICATIONExport kNIExport + #define kFRC_NETWORKCOMMUNICATIONExportPre kNIExportPre + #define kFRC_NETWORKCOMMUNICATIONExportPost kNIExportPost + #define kFRC_NETWORKCOMMUNICATIONExportInline kNIExportInline + #define kFRC_NETWORKCOMMUNICATIONExportData kNIExportData +#elif defined(kFRC_NETWORKCOMMUNICATIONNoExportSymbols) + #define kFRC_NETWORKCOMMUNICATIONExport + #define kFRC_NETWORKCOMMUNICATIONExportPre + #define kFRC_NETWORKCOMMUNICATIONExportPost + #define kFRC_NETWORKCOMMUNICATIONExportInline + #define kFRC_NETWORKCOMMUNICATIONExportData +#else + #define kFRC_NETWORKCOMMUNICATIONExport kNIImport + #define kFRC_NETWORKCOMMUNICATIONExportPre kNIImportPre + #define kFRC_NETWORKCOMMUNICATIONExportPost kNIImportPost + #define kFRC_NETWORKCOMMUNICATIONExportInline kNIImportInline + #define kFRC_NETWORKCOMMUNICATIONExportData kNIImportData +#endif + +// namespace declarations for aliasing ... + +#ifdef __cplusplus + +namespace nACE_STATIC_5_6 { } +namespace nCINTOOLS_1_2 { } +namespace nFRC_FPGA_CHIPOBJECT_1_2 { } +namespace nIAK_SHARED_13_0 { } +namespace nNIFPGA_13_0 { } +namespace nNI_EMB_6_0 { } +namespace nROBORIO_FRC_CHIPOBJECT_1_2 { } + +/*! + \namespace nFRC_NETWORKCOMMUNICATION_1_5 + \brief FRC Network Communication Release 1.5 +*/ +namespace nFRC_NETWORKCOMMUNICATION_1_5 +{ + // current versioned namespace aliases used by this package + + // FRC_FPGA_ChipObject 1.2: + namespace nFRC_FPGA_CHIPOBJECT = nFRC_FPGA_CHIPOBJECT_1_2; + + // RoboRIO_FRC_ChipObject 1.2: + namespace nROBORIO_FRC_CHIPOBJECT = nROBORIO_FRC_CHIPOBJECT_1_2; + + // ace_static 5.6: + namespace nACE_STATIC = nACE_STATIC_5_6; + + // cintools 1.2: + namespace nCINTOOLS = nCINTOOLS_1_2; + + // iak_shared 13.0: + namespace nIAK_SHARED = nIAK_SHARED_13_0; + + // ni_emb 6.0: + namespace nNI_EMB = nNI_EMB_6_0; + + // nifpga 13.0: + namespace nNIFPGA = nNIFPGA_13_0; + +} + +#endif // __cplusplus + +#endif // ___FRC_NetworkCommunication_environs_h___ + diff --git a/hal/AthenaXX/src/main/native/HAL.cpp b/hal/AthenaXX/src/main/native/HAL.cpp new file mode 100644 index 0000000000..13f6704f26 --- /dev/null +++ b/hal/AthenaXX/src/main/native/HAL.cpp @@ -0,0 +1,122 @@ + +#include "HAL/HAL.h" + +#include "Port.h" +#include "HAL/Errors.h" +#include "ChipObject.h" + +const uint32_t solenoid_kNumDO7_0Elements = tSolenoid::kNumDO7_0Elements; +const uint32_t dio_kNumSystems = tDIO::kNumSystems; +const uint32_t interrupt_kNumSystems = tInterrupt::kNumSystems; +const uint32_t kSystemClockTicksPerMicrosecond = 40; + +void* getPort(uint8_t pin) { + Port* port = new Port(); + port->pin = pin; + port->module = 1; + return port; +} + +/** + * @deprecated Uses module numbers + */ +void* getPortWithModule(uint8_t module, uint8_t pin) { + Port* port = new Port(); + port->pin = pin; + port->module = module; + return port; +} + +const char* getHALErrorMessage(int32_t code) { + if (code == 0) return ""; + else if (code == SAMPLE_RATE_TOO_HIGH) return SAMPLE_RATE_TOO_HIGH_MESSAGE; + else if (code == VOLTAGE_OUT_OF_RANGE) return VOLTAGE_OUT_OF_RANGE_MESSAGE; + else if (code == LOOP_TIMING_ERROR) return LOOP_TIMING_ERROR_MESSAGE; + else if (code == SPI_WRITE_NO_MOSI) return SPI_WRITE_NO_MOSI_MESSAGE; + else if (code == SPI_READ_NO_MISO) return SPI_READ_NO_MISO_MESSAGE; + else if (code == SPI_READ_NO_DATA) return SPI_READ_NO_DATA_MESSAGE; + else if (code == INCOMPATIBLE_STATE) return INCOMPATIBLE_STATE_MESSAGE; + else if (code == NO_AVAILABLE_RESOURCES) return NO_AVAILABLE_RESOURCES_MESSAGE; + else if (code == NULL_PARAMETER) return NULL_PARAMETER_MESSAGE; + else if (code == ANALOG_TRIGGER_LIMIT_ORDER_ERROR) return ANALOG_TRIGGER_LIMIT_ORDER_ERROR_MESSAGE; + else if (code == ANALOG_TRIGGER_PULSE_OUTPUT_ERROR) return ANALOG_TRIGGER_PULSE_OUTPUT_ERROR_MESSAGE; + else if (code == PARAMETER_OUT_OF_RANGE) return PARAMETER_OUT_OF_RANGE_MESSAGE; + else return ""; +} + +/** + * Return the FPGA Version number. + * For now, expect this to be competition year. + * @return FPGA Version number. + */ +uint16_t getFPGAVersion(int32_t *status) { + tGlobal *global = tGlobal::create(status); + uint16_t version = global->readVersion(status); + delete global; + return version; +} + +/** + * Return the FPGA Revision number. + * The format of the revision is 3 numbers. + * The 12 most significant bits are the Major Revision. + * the next 8 bits are the Minor Revision. + * The 12 least significant bits are the Build Number. + * @return FPGA Revision number. + */ +uint32_t getFPGARevision(int32_t *status) { + tGlobal *global = tGlobal::create(status); + uint32_t revision = global->readRevision(status); + delete global; + return revision; +} + +/** + * Read the microsecond-resolution timer on the FPGA. + * + * @return The current time in microseconds according to the FPGA (since FPGA reset). + */ +uint32_t getFPGATime(int32_t *status) { + tGlobal *global = tGlobal::create(status); + uint32_t time = global->readLocalTime(status); + delete global; + return time; +} + + +/** + * Set the state of the FPGA status LED on the cRIO. + */ +void setFPGALED(uint32_t state, int32_t *status) { + tGlobal *global = tGlobal::create(status); + global->writeFPGA_LED(state, status); + delete global; +} + +/** + * Get the current state of the FPGA status LED on the cRIO. + * @return The curent state of the FPGA LED. + */ +int32_t getFPGALED(int32_t *status) { + tGlobal *global = tGlobal::create(status); + bool ledValue = global->readFPGA_LED(status); + delete global; + return ledValue; +} + +// TODO: HACKS +void NumericArrayResize() {} +void RTSetCleanupProc() {} +void EDVR_CreateReference() {} +void Occur() {} + +void imaqGetErrorText() {} +void imaqGetLastError() {} +void niTimestamp64() {} + +#include "NetworkCommunication/LoadOut.h" +namespace nLoadOut { + bool getModulePresence(tModuleType moduleType, uint8_t moduleNumber) { + return true; + } +} diff --git a/hal/AthenaXX/src/main/native/Interrupts.cpp b/hal/AthenaXX/src/main/native/Interrupts.cpp new file mode 100644 index 0000000000..c47f5769f4 --- /dev/null +++ b/hal/AthenaXX/src/main/native/Interrupts.cpp @@ -0,0 +1,86 @@ + +#include "HAL/Interrupts.h" + +#include "ChipObject.h" + +struct interrupt_t { + tInterrupt *anInterrupt; + tInterruptManager *manager; +}; +typedef struct interrupt_t Interrupt; + +void* initializeInterrupts(uint32_t interruptIndex, bool watcher, int32_t *status) { + Interrupt* anInterrupt = new Interrupt(); + // Expects the calling leaf class to allocate an interrupt index. + anInterrupt->anInterrupt = tInterrupt::create(interruptIndex, status); + anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status); + anInterrupt->manager = new tInterruptManager(1 << interruptIndex, watcher, status); + return anInterrupt; +} + +void cleanInterrupts(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + delete anInterrupt->anInterrupt; + delete anInterrupt->manager; + anInterrupt->anInterrupt = NULL; + anInterrupt->manager = NULL; +} + +/** + * In synchronous mode, wait for the defined interrupt to occur. + * @param timeout Timeout in seconds + */ +void waitForInterrupt(void* interrupt_pointer, double timeout, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->watch((int32_t)(timeout * 1e3), status); +} + +/** + * Enable interrupts to occur on this input. + * oInterrupts are disabled when the RequestInterrupt call is made. This gives time to do the + * setup of the other options before starting to field interrupts. + */ +void enableInterrupts(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->enable(status); +} + +/** + * Disable Interrupts without without deallocating structures. + */ +void disableInterrupts(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->disable(status); +} + +/** + * Return the timestamp for the interrupt that occurred most recently. + * This is in the same time domain as GetClock(). + * @return Timestamp in seconds since boot. + */ +double readInterruptTimestamp(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + uint32_t timestamp = anInterrupt->anInterrupt->readTimeStamp(status); + return timestamp * 1e-6; +} + +void requestInterrupts(void* interrupt_pointer, uint8_t routing_module, uint32_t routing_pin, + bool routing_analog_trigger, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status); + anInterrupt->anInterrupt->writeConfig_Source_AnalogTrigger(routing_analog_trigger, status); + anInterrupt->anInterrupt->writeConfig_Source_Channel(routing_pin, status); + anInterrupt->anInterrupt->writeConfig_Source_Module(routing_module, status); +} + +void attachInterruptHandler(void* interrupt_pointer, InterruptHandlerFunction handler, + void* param, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->registerHandler(handler, param, status); +} + +void setInterruptUpSourceEdge(void* interrupt_pointer, bool risingEdge, bool fallingEdge, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->anInterrupt->writeConfig_RisingEdge(risingEdge, status); + anInterrupt->anInterrupt->writeConfig_FallingEdge(fallingEdge, status); +} diff --git a/hal/AthenaXX/src/main/native/NetworkCommunication/AICalibration.h b/hal/AthenaXX/src/main/native/NetworkCommunication/AICalibration.h new file mode 100644 index 0000000000..39755bda89 --- /dev/null +++ b/hal/AthenaXX/src/main/native/NetworkCommunication/AICalibration.h @@ -0,0 +1,19 @@ + +#ifndef __AICalibration_h__ +#define __AICalibration_h__ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + uint32_t FRC_NetworkCommunication_nAICalibration_getLSBWeight(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status); + int32_t FRC_NetworkCommunication_nAICalibration_getOffset(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status); + +#ifdef __cplusplus +} +#endif + +#endif // __AICalibration_h__ diff --git a/hal/AthenaXX/src/main/native/NetworkCommunication/LoadOut.h b/hal/AthenaXX/src/main/native/NetworkCommunication/LoadOut.h new file mode 100644 index 0000000000..f28249e3f1 --- /dev/null +++ b/hal/AthenaXX/src/main/native/NetworkCommunication/LoadOut.h @@ -0,0 +1,39 @@ + +#ifndef __LoadOut_h__ +#define __LoadOut_h__ + +#define kMaxModuleNumber 2 +namespace nLoadOut +{ + typedef enum { + kModuleType_Unknown = 0x00, + kModuleType_Analog = 0x01, + kModuleType_Digital = 0x02, + kModuleType_Solenoid = 0x03, + } tModuleType; + bool getModulePresence(tModuleType moduleType, uint8_t moduleNumber); + typedef enum { + kTargetClass_Unknown = 0x00, + kTargetClass_FRC1 = 0x10, + kTargetClass_FRC2 = 0x20, + kTargetClass_FRC2_Analog = kTargetClass_FRC2 | kModuleType_Analog, + kTargetClass_FRC2_Digital = kTargetClass_FRC2 | kModuleType_Digital, + kTargetClass_FRC2_Solenoid = kTargetClass_FRC2 | kModuleType_Solenoid, + kTargetClass_FamilyMask = 0xF0, + kTargetClass_ModuleMask = 0x0F, + } tTargetClass; + tTargetClass getTargetClass(); +} + +#ifdef __cplusplus +extern "C" { +#endif + + uint32_t FRC_NetworkCommunication_nLoadOut_getModulePresence(uint32_t moduleType, uint8_t moduleNumber); + uint32_t FRC_NetworkCommunication_nLoadOut_getTargetClass(); + +#ifdef __cplusplus +} +#endif + +#endif // __LoadOut_h__ diff --git a/hal/AthenaXX/src/main/native/Notifier.cpp b/hal/AthenaXX/src/main/native/Notifier.cpp new file mode 100644 index 0000000000..8d9766b6c3 --- /dev/null +++ b/hal/AthenaXX/src/main/native/Notifier.cpp @@ -0,0 +1,40 @@ + +#include "HAL/Notifier.h" + +#include "ChipObject.h" + +static const uint32_t kTimerInterruptNumber = 28; + +struct notifier_t { + tAlarm *alarm; + tInterruptManager *manager; +}; +typedef struct notifier_t Notifier; + +void* initializeNotifier(void (*ProcessQueue)(uint32_t, void*), int32_t *status) { + Notifier* notifier = new Notifier(); + notifier->manager = new tInterruptManager(1 << kTimerInterruptNumber, false, status); + notifier->manager->registerHandler(ProcessQueue, NULL, status); + notifier->manager->enable(status); + notifier->alarm = tAlarm::create(status); + return notifier; +} + +void cleanNotifier(void* notifier_pointer, int32_t *status) { + Notifier* notifier = (Notifier*) notifier_pointer; + notifier->alarm->writeEnable(false, status); + delete notifier->alarm; + notifier->alarm = NULL; + notifier->manager->disable(status); + delete notifier->manager; + notifier->manager = NULL; +} + + +void updateNotifierAlarm(void* notifier_pointer, uint32_t triggerTime, int32_t *status) { + Notifier* notifier = (Notifier*) notifier_pointer; + // write the first item in the queue into the trigger time + notifier->alarm->writeTriggerTime(triggerTime, status); + // Enable the alarm. The hardware disables itself after each alarm. + notifier->alarm->writeEnable(true, status); +} diff --git a/hal/AthenaXX/src/main/native/Port.h b/hal/AthenaXX/src/main/native/Port.h new file mode 100644 index 0000000000..433f318e92 --- /dev/null +++ b/hal/AthenaXX/src/main/native/Port.h @@ -0,0 +1,11 @@ + +#ifndef HAL_PORT_H +#define HAL_PORT_H + +struct port_t { + uint8_t pin; + uint8_t module; +}; +typedef struct port_t Port; + +#endif diff --git a/hal/AthenaXX/src/main/native/Semaphore.cpp b/hal/AthenaXX/src/main/native/Semaphore.cpp new file mode 100644 index 0000000000..2cf2258216 --- /dev/null +++ b/hal/AthenaXX/src/main/native/Semaphore.cpp @@ -0,0 +1,120 @@ + +#include "HAL/Semaphore.h" + +#include "ChipObject.h" + +// See: http://www.vxdev.com/docs/vx55man/vxworks/ref/semMLib.html +const uint32_t SEMAPHORE_Q_FIFO= 0x01; // TODO: Support +const uint32_t SEMAPHORE_Q_PRIORITY = 0x01; // TODO: Support +const uint32_t SEMAPHORE_DELETE_SAFE = 0x04; // TODO: Support +const uint32_t SEMAPHORE_INVERSION_SAFE = 0x08; // TODO: Support + +const int32_t SEMAPHORE_NO_WAIT = 0; +const int32_t SEMAPHORE_WAIT_FOREVER = -1; + +const uint32_t SEMAPHORE_EMPTY = 0; +const uint32_t SEMAPHORE_FULL = 1; + +MUTEX_ID initializeMutex(uint32_t flags) { + pthread_mutexattr_t attr; + pthread_mutexattr_init(&attr); + pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); + MUTEX_ID sem = new pthread_mutex_t(); + pthread_mutex_init(sem, &attr); + pthread_mutexattr_destroy(&attr); + return sem; +} + +void deleteMutex(MUTEX_ID sem) { + pthread_mutex_destroy(sem); + delete sem; +} + +/** + * Lock the semaphore, blocking until it's available. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t takeMutex(MUTEX_ID sem, int32_t timeout) { + if (timeout == SEMAPHORE_NO_WAIT) { + return pthread_mutex_trylock(sem); + } else if (timeout == SEMAPHORE_WAIT_FOREVER) { + return pthread_mutex_lock(sem); + } else { + // struct timespec test; + // return pthread_mutex_timedlock(sem, ); + return -1; // TODO: implement timed wait + } +} + +/** + * Unlock the semaphore. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t giveMutex(MUTEX_ID sem) { + // return semGive(sem); + // return sem_post(sem); + return pthread_mutex_unlock(sem); +} + +SEMAPHORE_ID initializeSemaphore(uint32_t flags, uint32_t initial_value) { + SEMAPHORE_ID sem = new sem_t; + sem_init(sem, 0, initial_value); + return sem; +} + +void deleteSemaphore(SEMAPHORE_ID sem) { + sem_destroy(sem); + delete sem; +} + +/** + * Lock the semaphore, blocking until it's available. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t takeSemaphore(SEMAPHORE_ID sem, int32_t timeout) { + if (timeout == SEMAPHORE_NO_WAIT) { + return sem_trywait(sem); + } else if (timeout == SEMAPHORE_WAIT_FOREVER) { + return sem_wait(sem); + } else { + // return sem_timedwait(sem, ); + return -1; // TODO: implement timed wait + } +} + +/** + * Unlock the semaphore. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t giveSemaphore(SEMAPHORE_ID sem) { + return sem_post(sem); +} + + +MULTIWAIT_ID initializeMultiWait() { + pthread_condattr_t attr; + pthread_condattr_init(&attr); + MULTIWAIT_ID cond = new pthread_cond_t(); + pthread_cond_init(cond, &attr); + pthread_condattr_destroy(&attr); + return cond; +} + +void deleteMultiWait(MULTIWAIT_ID sem) { + pthread_cond_destroy(sem); + delete sem; +} + +int8_t takeMultiWait(MULTIWAIT_ID sem, int32_t timeout) { + MUTEX_ID m = initializeMutex(NULL); + takeMutex(m, SEMAPHORE_WAIT_FOREVER); + int8_t val = pthread_cond_wait(sem, m); + deleteMutex(m); + return val; +} + +int8_t giveMultiWait(MULTIWAIT_ID sem) { + return pthread_cond_broadcast(sem); +} + + diff --git a/hal/AthenaXX/src/main/native/Solenoid.cpp b/hal/AthenaXX/src/main/native/Solenoid.cpp new file mode 100644 index 0000000000..6dc822ed73 --- /dev/null +++ b/hal/AthenaXX/src/main/native/Solenoid.cpp @@ -0,0 +1,73 @@ + +#include "HAL/Solenoid.h" + +#include "Port.h" +#include "HAL/Errors.h" +#include "ChipObject.h" +#include "HAL/cpp/Synchronized.h" +#include "NetworkCommunication/LoadOut.h" + +struct solenoid_port_t { + Port port; + tSolenoid *module; + uint32_t PWMGeneratorID; +}; +typedef struct solenoid_port_t SolenoidPort; + +static ReentrantSemaphore solenoidSemaphore; +static tSolenoid* solenoidModules[2] = {NULL, NULL}; + +bool solenoidModulesInitialized = false; + +/** + * Initialize the digital modules. + */ +void initializeSolenoid(int32_t *status) { + if (solenoidModulesInitialized) return; + + for (unsigned int i = 0; i < (sizeof(solenoidModules)/sizeof(solenoidModules[0])); i++) { + Synchronized sync(solenoidSemaphore); + solenoidModules[i] = tSolenoid::create(status); + } + solenoidModulesInitialized = true; +} + +void* initializeSolenoidPort(void* port_pointer, int32_t *status) { + initializeSolenoid(status); + Port* port = (Port*) port_pointer; + + // Initialize port structure + SolenoidPort* solenoid_port = new SolenoidPort(); + solenoid_port->port = *port; + solenoid_port->module = solenoidModules[solenoid_port->port.module-1]; + + return solenoid_port; +} + +bool checkSolenoidModule(uint8_t module) { + if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Solenoid, module - 1)) + return true; + return false; +} + +bool getSolenoid(void* solenoid_port_pointer, int32_t *status) { + SolenoidPort* port = (SolenoidPort*) solenoid_port_pointer; + if (checkSolenoidModule(port->port.module)) { + uint8_t mask = 1 << (port->port.pin - 1); + return (mask & port->module->readDO7_0(port->port.module - 1, status)); + } + return false; +} + +void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status) { + SolenoidPort* port = (SolenoidPort*) solenoid_port_pointer; + if (checkSolenoidModule(port->port.module)) { + Synchronized sync(solenoidSemaphore); + uint8_t currentValue = port->module->readDO7_0(port->port.module - 1, status); + uint8_t mask = 1 << (port->port.pin - 1); + if (value) currentValue = currentValue | mask; // Flip the bit on + else currentValue = currentValue & ~mask; // Flip the bit off + port->module->writeDO7_0(port->port.module - 1, currentValue, status); + } +} + diff --git a/hal/AthenaXX/src/main/native/Task.cpp b/hal/AthenaXX/src/main/native/Task.cpp new file mode 100644 index 0000000000..22fc93743e --- /dev/null +++ b/hal/AthenaXX/src/main/native/Task.cpp @@ -0,0 +1,100 @@ + +#include "HAL/Task.h" + +#include "HAL/HAL.h" +#include "ChipObject.h" + +#include +#include + +const uint32_t VXWORKS_FP_TASK = 0x01000000; +const int32_t HAL_objLib_OBJ_ID_ERROR = -1; // TODO: update to relevant TaskIDError +const int32_t HAL_objLib_OBJ_DELETED = -1; // TODO: update to relevant TaskDeletedError +const int32_t HAL_taskLib_ILLEGAL_OPTIONS = -1; // TODO: update to relevant TaskOptionsError +const int32_t HAL_memLib_NOT_ENOUGH_MEMORY = -1; // TODO: update to relevant TaskMemoryError +const int32_t HAL_taskLib_ILLEGAL_PRIORITY = -1; // TODO: update to relevant TaskPriorityError + +typedef struct task_args_t { + FUNCPTR fun; + char* name; + pthread_t** task; + uint32_t arg0, arg1, arg2, arg3, arg4, + arg5, arg6, arg7, arg8, arg9; +} TaskArgs; + +void* startRoutine(void* data) { + TaskArgs* args = (TaskArgs*) data; + printf("[HAL] Starting task %s...\n", args->name); + int val = args->fun(args->arg0, args->arg1, args->arg2, args->arg3, args->arg4, + args->arg5, args->arg6, args->arg7, args->arg8, args->arg9); + printf("[HAL] Exited task %s with code %i\n", args->name, val); + *args->task = NULL; + int* ret = new int(); *ret = val; + return ret; +} + +TASK spawnTask(char * name, int priority, int options, int stackSize, + FUNCPTR entryPt, uint32_t arg0, uint32_t arg1, uint32_t arg2, + uint32_t arg3, uint32_t arg4, uint32_t arg5, uint32_t arg6, + uint32_t arg7, uint32_t arg8, uint32_t arg9) { + printf("[HAL] Spawning task %s...\n", name); + pthread_t* task = new pthread_t; + pthread_attr_t* attr = new pthread_attr_t; + pthread_attr_init(attr); + TaskArgs* args = new TaskArgs(); + args->fun = entryPt; + args->name = name; + args->task = new pthread_t*; + *args->task = task; + args->arg0 = arg0; args->arg1 = arg1; args->arg2 = arg2; args->arg3 = arg3; args->arg4 = arg4; + args->arg5 = arg5; args->arg6 = arg6; args->arg7 = arg7; args->arg8 = arg8; args->arg9 = arg9; + if (pthread_create(task, attr, startRoutine, args) == 0) { + printf("[HAL] Success\n"); + pthread_detach(*task); + } else { + printf("[HAL] Failure\n"); + task = NULL; + } + pthread_attr_destroy(attr); + return task; +} + +STATUS restartTask(TASK task) { + return ERROR; // TODO: implement; +} + +STATUS deleteTask(TASK task) { + return ERROR; // TODO: implement +} + +STATUS isTaskReady(TASK task) { + return ERROR; // TODO: implement +} + +STATUS isTaskSuspended(TASK task) { + return ERROR; // TODO: implement +} + +STATUS suspendTask(TASK task) { + return ERROR; // TODO: implement +} + +STATUS resumeTask(TASK task) { + return ERROR; // TODO: implement +} + +STATUS verifyTaskID(TASK task) { + if (task != NULL && pthread_kill(*task, 0) == 0) { + return OK; + } else { + return ERROR; + } +} + +STATUS setTaskPriority(TASK task, int priority) { + return ERROR; // TODO: implement +} + +STATUS getTaskPriority(TASK task, int* priority) { + return ERROR; // TODO: implement +} diff --git a/hal/AthenaXX/src/main/native/Utilities.cpp b/hal/AthenaXX/src/main/native/Utilities.cpp new file mode 100644 index 0000000000..b6aa8fc873 --- /dev/null +++ b/hal/AthenaXX/src/main/native/Utilities.cpp @@ -0,0 +1,29 @@ + +#include "HAL/Utilities.h" + +#include "HAL/HAL.h" +#include "ChipObject.h" + +const int32_t HAL_NO_WAIT = 0; +const int32_t HAL_WAIT_FOREVER = -1; + +void delayTicks(int32_t ticks) { + struct timespec test, remaining; + test.tv_sec = 0; + test.tv_nsec = ticks * 3; + nanosleep(&test, &remaining); +} + +void delayMillis(double ms) { + struct timespec test, remaining; + test.tv_sec = ms/1000; + test.tv_nsec = 1000*(((uint64_t) ms)%1000000); + nanosleep(&test, &remaining); +} + +void delaySeconds(double s) { + struct timespec test, remaining; + test.tv_sec = s; + test.tv_nsec = 0; + nanosleep(&test, &remaining); +} diff --git a/hal/AthenaXX/src/main/native/Watchdog.cpp b/hal/AthenaXX/src/main/native/Watchdog.cpp new file mode 100644 index 0000000000..59e2041ab3 --- /dev/null +++ b/hal/AthenaXX/src/main/native/Watchdog.cpp @@ -0,0 +1,140 @@ + +#include "HAL/Watchdog.h" + +#include "HAL/HAL.h" +#include "ChipObject.h" + +typedef tWatchdog Watchdog; +const double kDefaultWatchdogExpiration = 0.5; + +void* initializeWatchdog(int32_t *status) { + Watchdog* watchdog = tWatchdog::create(status); + setWatchdogExpiration(watchdog, kDefaultWatchdogExpiration, status); + setWatchdogEnabled(watchdog, true, status); + return watchdog; +} + +void cleanWatchdog(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + setWatchdogEnabled(watchdog, false, status); + delete watchdog; +} + +/** + * Throw the dog a bone. + * + * When everything is going well, you feed your dog when you get home. + * Let's hope you don't drive your car off a bridge on the way home... + * Your dog won't get fed and he will starve to death. + * + * By the way, it's not cool to ask the neighbor (some random task) to + * feed your dog for you. He's your responsibility! + * + * @returns Returns the previous state of the watchdog before feeding it. + */ +bool feedWatchdog(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool previous = getWatchdogEnabled(watchdog_pointer, status); + watchdog->strobeFeed(status); + return previous; +} + +/** + * Put the watchdog out of its misery. + * + * Don't wait for your dying robot to starve when there is a problem. + * Kill it quickly, cleanly, and humanely. + */ +void killWatchdog(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + watchdog->strobeKill(status); +} + +/** + * Read how long it has been since the watchdog was last fed. + * + * @return The number of seconds since last meal. + */ +double getWatchdogLastFed(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + uint32_t timer = watchdog->readTimer(status); + return timer / (kSystemClockTicksPerMicrosecond * 1e6); +} + +/** + * Read what the current expiration is. + * + * @return The number of seconds before starvation following a meal (watchdog starves if it doesn't eat this often). + */ +double getWatchdogExpiration(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + uint32_t expiration = watchdog->readExpiration(status); + return expiration / (kSystemClockTicksPerMicrosecond * 1e6); +} + +/** + * Configure how many seconds your watchdog can be neglected before it starves to death. + * + * @param expiration The number of seconds before starvation following a meal (watchdog starves if it doesn't eat this often). + */ +void setWatchdogExpiration(void* watchdog_pointer, double expiration, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + watchdog->writeExpiration((uint32_t)(expiration * (kSystemClockTicksPerMicrosecond * 1e6)), status); +} + +/** + * Find out if the watchdog is currently enabled or disabled (mortal or immortal). + * + * @return Enabled or disabled. + */ +bool getWatchdogEnabled(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool enabled = !watchdog->readImmortal(status); + return enabled; +} + +/** + * Enable or disable the watchdog timer. + * + * When enabled, you must keep feeding the watchdog timer to + * keep the watchdog active, and hence the dangerous parts + * (motor outputs, etc.) can keep functioning. + * When disabled, the watchdog is immortal and will remain active + * even without being fed. It will also ignore any kill commands + * while disabled. + * + * @param enabled Enable or disable the watchdog. + */ +void setWatchdogEnabled(void* watchdog_pointer, bool enabled, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + watchdog->writeImmortal(!enabled, status); +} + +/** + * Check in on the watchdog and make sure he's still kicking. + * + * This indicates that your watchdog is allowing the system to operate. + * It is still possible that the network communications is not allowing the + * system to run, but you can check this to make sure it's not your fault. + * Check IsSystemActive() for overall system status. + * + * If the watchdog is disabled, then your watchdog is immortal. + * + * @return Is the watchdog still alive? + */ +bool isWatchdogAlive(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool alive = watchdog->readStatus_Alive(status); + return alive; +} + +/** + * Check on the overall status of the system. + * + * @return Is the system active (i.e. PWM motor outputs, etc. enabled)? + */ +bool isWatchdogSystemActive(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool alive = watchdog->readStatus_SystemActive(status); + return alive; +} diff --git a/hal/AthenaXX/src/main/native/cpp/Resource.cpp b/hal/AthenaXX/src/main/native/cpp/Resource.cpp new file mode 100644 index 0000000000..a2baa41e16 --- /dev/null +++ b/hal/AthenaXX/src/main/native/cpp/Resource.cpp @@ -0,0 +1,120 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#include "HAL/cpp/Resource.h" +#include "HAL/Errors.h" +#include + +ReentrantSemaphore Resource::m_createLock; + +/** + * Allocate storage for a new instance of Resource. + * Allocate a bool array of values that will get initialized to indicate that no resources + * have been allocated yet. The indicies of the resources are [0 .. elements - 1]. + */ +Resource::Resource(uint32_t elements) +{ + Synchronized sync(m_createLock); + m_size = elements; + m_isAllocated = new bool[m_size]; + for (uint32_t i=0; i < m_size; i++) + { + m_isAllocated[i] = false; + } +} + +/** + * Factory method to create a Resource allocation-tracker *if* needed. + * + * @param r -- address of the caller's Resource pointer. If *r == NULL, this + * will construct a Resource and make *r point to it. If *r != NULL, i.e. + * the caller already has a Resource instance, this won't do anything. + * @param elements -- the number of elements for this Resource allocator to + * track, that is, it will allocate resource numbers in the range + * [0 .. elements - 1]. + */ +/*static*/ void Resource::CreateResourceObject(Resource **r, uint32_t elements) +{ + Synchronized sync(m_createLock); + if (*r == NULL) + { + *r = new Resource(elements); + } +} + +/** + * Delete the allocated array or resources. + * This happens when the module is unloaded (provided it was statically allocated). + */ +Resource::~Resource() +{ + delete[] m_isAllocated; +} + +/** + * Allocate a resource. + * When a resource is requested, mark it allocated. In this case, a free resource value + * within the range is located and returned after it is marked allocated. + */ +uint32_t Resource::Allocate(const char *resourceDesc) +{ + Synchronized sync(m_allocateLock); + for (uint32_t i=0; i < m_size; i++) + { + if (!m_isAllocated[i]) + { + m_isAllocated[i] = true; + return i; + } + } + // TODO: wpi_setWPIErrorWithContext(NoAvailableResources, resourceDesc); + return ~0ul; +} + +/** + * Allocate a specific resource value. + * The user requests a specific resource value, i.e. channel number and it is verified + * unallocated, then returned. + */ +uint32_t Resource::Allocate(uint32_t index, const char *resourceDesc) +{ + Synchronized sync(m_allocateLock); + if (index >= m_size) + { + // TODO: wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, resourceDesc); + return ~0ul; + } + if ( m_isAllocated[index] ) + { + // TODO: wpi_setWPIErrorWithContext(ResourceAlreadyAllocated, resourceDesc); + return ~0ul; + } + m_isAllocated[index] = true; + return index; +} + + +/** + * Free an allocated resource. + * After a resource is no longer needed, for example a destructor is called for a channel assignment + * class, Free will release the resource value so it can be reused somewhere else in the program. + */ +void Resource::Free(uint32_t index) +{ + Synchronized sync(m_allocateLock); + if (index == ~0ul) return; + if (index >= m_size) + { + // TODO: wpi_setWPIError(NotAllocated); + return; + } + if (!m_isAllocated[index]) + { + // TODO: wpi_setWPIError(NotAllocated); + return; + } + m_isAllocated[index] = false; +} diff --git a/hal/AthenaXX/src/main/native/cpp/StackTrace.cpp b/hal/AthenaXX/src/main/native/cpp/StackTrace.cpp new file mode 100644 index 0000000000..7629925728 --- /dev/null +++ b/hal/AthenaXX/src/main/native/cpp/StackTrace.cpp @@ -0,0 +1,15 @@ + +#include "HAL/cpp/StackTrace.h" + +#include "HAL/HAL.h" +#include "../ChipObject.h" +#include + + +void printCurrentStackTrace() { + // TODO: Implement +} + +bool getErrnoToName(int32_t errNo, char* name) { + return false; // TODO: Implement +} diff --git a/hal/AthenaXX/src/main/native/cpp/Synchronized.cpp b/hal/AthenaXX/src/main/native/cpp/Synchronized.cpp new file mode 100644 index 0000000000..c20d333a43 --- /dev/null +++ b/hal/AthenaXX/src/main/native/cpp/Synchronized.cpp @@ -0,0 +1,49 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#include "HAL/cpp/Synchronized.h" +#include "HAL/Semaphore.h" + +/** + * Synchronized class deals with critical regions. + * Declare a Synchronized object at the beginning of a block. That will take the semaphore. + * When the code exits from the block it will call the destructor which will give the semaphore. + * This ensures that no matter how the block is exited, the semaphore will always be released. + * Use the CRITICAL_REGION(SEM_ID) and END_REGION macros to make the code look cleaner (see header file) + * @param semaphore The semaphore controlling this critical region. + */ +Synchronized::Synchronized(MUTEX_ID semaphore) +{ + m_mutex = semaphore; + m_semaphore = NULL; + takeMutex(m_mutex, SEMAPHORE_WAIT_FOREVER); +} + +Synchronized::Synchronized(SEMAPHORE_ID semaphore) +{ + m_mutex = NULL; + m_semaphore = semaphore; + takeSemaphore(m_semaphore, SEMAPHORE_WAIT_FOREVER); +} + +Synchronized::Synchronized(ReentrantSemaphore& semaphore) +{ + m_mutex = semaphore.m_semaphore; + m_semaphore = NULL; + takeMutex(m_mutex, SEMAPHORE_WAIT_FOREVER); +} + +/** + * This destructor unlocks the semaphore. + */ +Synchronized::~Synchronized() +{ + if (m_mutex != NULL) { + giveMutex(m_mutex); + } else { + giveSemaphore(m_semaphore); + } +} diff --git a/hal/AthenaXXJava/pom.xml b/hal/AthenaXXJava/pom.xml new file mode 100644 index 0000000000..a16b2af006 --- /dev/null +++ b/hal/AthenaXXJava/pom.xml @@ -0,0 +1,98 @@ + + + 4.0.0 + edu.wpi.first.wpilib.hal + libHALAthenaXXJava + so + + + edu.wpi.first.wpilib.templates.athena + shared-library + 0.1.0-SNAPSHOT + + + + + com.nativelibs4java + jnaerator-runtime + 0.12-SNAPSHOT + compile + + + edu.wpi.first.wpilib.hal + include + 0.1.0-SNAPSHOT + inczip + + + com.ni.first.libraries + libFRC_NetworkCommunication + 0.1.0-SNAPSHOT + so + + + + + + sonatype + Sonatype OSS Snapshots Repository + http://oss.sonatype.org/content/groups/public + + + + nativelibs4java-repo + http://nativelibs4java.sourceforge.net/maven + + + + WPILib Repository + http://frcbuilder.wpi.edu:8348/ + + + + + sonatype + Sonatype OSS Snapshots Repository + http://oss.sonatype.org/content/groups/public + + + + nativelibs4java-repo + http://nativelibs4java.sourceforge.net/maven + + + + + + + org.codehaus.mojo + native-maven-plugin + + + + ../AthenaXX/src/main/native + + **/*.cpp + + + + + + + com.nativelibs4java + maven-jnaerator-plugin + 0.12-SNAPSHOT + true + + + process-classes + + generate + + + + + + + diff --git a/hal/AthenaXXJava/src/main/jnaerator/config.jnaerator b/hal/AthenaXXJava/src/main/jnaerator/config.jnaerator new file mode 100644 index 0000000000..fcc6546955 --- /dev/null +++ b/hal/AthenaXXJava/src/main/jnaerator/config.jnaerator @@ -0,0 +1,15 @@ +-dontCastConstants +-runtime JNAerator +-direct +// -reification +-M__java=true + +-package edu.wpi.first.wpilibj.hal +// -entryClass HAL + +-library HAL +-Itarget/native/include/ + +target/native/include/HAL/HAL.h +// include/HAL/Errors.h + diff --git a/hal/Azalea/pom.xml b/hal/Azalea/pom.xml new file mode 100644 index 0000000000..53c7648709 --- /dev/null +++ b/hal/Azalea/pom.xml @@ -0,0 +1,49 @@ + + + 4.0.0 + edu.wpi.first.wpilib.hal + libHALAzalea + a + + + edu.wpi.first.wpilib.templates.azalea + static-library + 0.1.0-SNAPSHOT + + + + + WPILib Repository + http://frcbuilder.wpi.edu:8348/ + + + + + + edu.wpi.first.wpilib.hal + include + 0.1.0-SNAPSHOT + inczip + + + + + + + org.codehaus.mojo + native-maven-plugin + + + + src/main/native + + **/*.cpp + + + + + + + + diff --git a/hal/Azalea/src/main/native/Analog.cpp b/hal/Azalea/src/main/native/Analog.cpp new file mode 100644 index 0000000000..54a6a96587 --- /dev/null +++ b/hal/Azalea/src/main/native/Analog.cpp @@ -0,0 +1,686 @@ + +#include "HAL/Analog.h" + +#include "Port.h" +#include "HAL/Errors.h" +#include "HAL/Semaphore.h" +#include "ChipObject.h" +#include "HAL/cpp/Synchronized.h" +#include "HAL/cpp/Resource.h" +#include "NetworkCommunication/AICalibration.h" +#include "NetworkCommunication/LoadOut.h" + +static const long kTimebase = 40000000; ///< 40 MHz clock +static const long kDefaultOversampleBits = 0; +static const long kDefaultAverageBits = 7; +static const float kDefaultSampleRate = 50000.0; +static const uint32_t kAnalogPins = 8; + +static const uint8_t kAccumulatorModuleNumber = 1; +static const uint32_t kAccumulatorNumChannels = 2; +static const uint32_t kAccumulatorChannels[] = {1, 2}; + +struct analog_port_t { + Port port; + tAI *module; + tAccumulator *accumulator; +}; +typedef struct analog_port_t AnalogPort; + +static bool analogSampleRateSet[2] = {false, false}; +static MUTEX_ID analogRegisterWindowSemaphore = NULL; +static tAI* analogModules[2] = {NULL, NULL}; +static uint32_t analogNumChannelsToActivate[2] = {0, 0}; + +// Utility methods defined below. +uint32_t getAnalogNumActiveChannels(uint8_t module, int32_t *status); +uint32_t getAnalogNumChannelsToActivate(uint8_t module, int32_t *status); +void setAnalogNumChannelsToActivate(uint8_t module, uint32_t channels); + +bool analogModulesInitialized = false; + +/** + * Initialize the analog modules. + */ +void initializeAnalog(int32_t *status) { + if (analogModulesInitialized) return; + // Needs to be global since the protected resource spans both module singletons. + analogRegisterWindowSemaphore = initializeMutex(SEM_Q_PRIORITY | SEM_DELETE_SAFE | SEM_INVERSION_SAFE); + for (unsigned int i = 0; i < (sizeof(analogModules)/sizeof(analogModules[0])); i++) { + analogModules[i] = tAI::create(i, status); + setAnalogNumChannelsToActivate(i + 1, kAnalogPins); + setAnalogSampleRateWithModule(i + 1, kDefaultSampleRate, status); + } + analogModulesInitialized = true; +} + +/** + * Initialize the analog port using the given port object. + */ +void* initializeAnalogPort(void* port_pointer, int32_t *status) { + initializeAnalog(status); + Port* port = (Port*) port_pointer; + + // Initialize port structure + AnalogPort* analog_port = new AnalogPort(); + analog_port->port = *port; + analog_port->module = analogModules[analog_port->port.module-1]; + if (isAccumulatorChannel(analog_port, status)) { + analog_port->accumulator = tAccumulator::create(port->pin - 1, status); + } else analog_port->accumulator = NULL; + + // Set default configuration + analog_port->module->writeScanList(port->pin - 1, port->pin - 1, status); + setAnalogAverageBits(analog_port, kDefaultAverageBits, status); + setAnalogOversampleBits(analog_port, kDefaultOversampleBits, status); + return analog_port; +} + + +/** + * Check that the analog module number is valid. + * + * @return Analog module is valid and present + */ +bool checkAnalogModule(uint8_t module) { + if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Analog, module - 1)) + return true; + return false; +} + +/** + * Check that the analog channel number is value. + * Verify that the analog channel number is one of the legal channel numbers. Channel numbers + * are 1-based. + * + * @return Analog channel is valid + */ +bool checkAnalogChannel(uint32_t pin) { + if (pin > 0 && pin <= kAnalogPins) + return true; + return false; +} + +/** + * Set the sample rate on module 0. + * + * This is a global setting for the module and effects all channels. + * + * @param samplesPerSecond The number of samples per channel per second. + */ +void setAnalogSampleRate(double samplesPerSecond, int32_t *status) { + setAnalogSampleRateWithModule(0, samplesPerSecond, status); +} + +/** + * Get the current sample rate on module 0. + * + * This assumes one entry in the scan list. + * This is a global setting for the module and effects all channels. + * + * @return Sample rate. + */ +float getAnalogSampleRate(int32_t *status) { + return getAnalogSampleRateWithModule(0, status); +} + +/** + * Set the sample rate on the module. + * + * This is a global setting for the module and effects all channels. + * + * @param module The module to use + * @param samplesPerSecond The number of samples per channel per second. + */ +void setAnalogSampleRateWithModule(uint8_t module, double samplesPerSecond, int32_t *status) { + // TODO: This will change when variable size scan lists are implemented. + // TODO: Need float comparison with epsilon. + //wpi_assert(!sampleRateSet || GetSampleRate() == samplesPerSecond); + analogSampleRateSet[module-1] = true; + + // Compute the convert rate + uint32_t ticksPerSample = (uint32_t)((float)kTimebase / samplesPerSecond); + uint32_t ticksPerConversion = ticksPerSample / getAnalogNumChannelsToActivate(module, status); + // ticksPerConversion must be at least 80 + if (ticksPerConversion < 80) { + if ((*status) >= 0) *status = SAMPLE_RATE_TOO_HIGH; + ticksPerConversion = 80; + } + + // Atomically set the scan size and the convert rate so that the sample rate is constant + tAI::tConfig config; + config.ScanSize = getAnalogNumChannelsToActivate(module, status); + config.ConvertRate = ticksPerConversion; + analogModules[module-1]->writeConfig(config, status); + + // Indicate that the scan size has been commited to hardware. + setAnalogNumChannelsToActivate(module, 0); +} + +/** + * Get the current sample rate on the module. + * + * This assumes one entry in the scan list. + * This is a global setting for the module and effects all channels. + * + * @param module The module to use + * @return Sample rate. + */ +float getAnalogSampleRateWithModule(uint8_t module, int32_t *status) { + uint32_t ticksPerConversion = analogModules[module-1]->readLoopTiming(status); + uint32_t ticksPerSample = ticksPerConversion * getAnalogNumActiveChannels(module, status); + return (float)kTimebase / (float)ticksPerSample; +} + + +/** + * Set the number of averaging bits. + * + * This sets the number of averaging bits. The actual number of averaged samples is 2**bits. + * Use averaging to improve the stability of your measurement at the expense of sampling rate. + * The averaging is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to configure. + * @param bits Number of bits to average. + */ +void setAnalogAverageBits(void* analog_port_pointer, uint32_t bits, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + port->module->writeAverageBits(port->port.pin - 1, bits, status); +} + +/** + * Get the number of averaging bits. + * + * This gets the number of averaging bits from the FPGA. The actual number of averaged samples is 2**bits. + * The averaging is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Bits to average. + */ +uint32_t getAnalogAverageBits(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + uint32_t result = port->module->readAverageBits(port->port.pin - 1, status); + return result; +} + +/** + * Set the number of oversample bits. + * + * This sets the number of oversample bits. The actual number of oversampled values is 2**bits. + * Use oversampling to improve the resolution of your measurements at the expense of sampling rate. + * The oversampling is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @param bits Number of bits to oversample. + */ +void setAnalogOversampleBits(void* analog_port_pointer, uint32_t bits, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + port->module->writeOversampleBits(port->port.pin - 1, bits, status); +} + + +/** + * Get the number of oversample bits. + * + * This gets the number of oversample bits from the FPGA. The actual number of oversampled values is + * 2**bits. The oversampling is done automatically in the FPGA. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Bits to oversample. + */ +uint32_t getAnalogOversampleBits(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + uint32_t result = port->module->readOversampleBits(port->port.pin - 1, status); + return result; +} + +/** + * Get a sample straight from the channel on this module. + * + * The sample is a 12-bit value representing the -10V to 10V range of the A/D converter in the module. + * The units are in A/D converter codes. Use GetVoltage() to get the analog value in calibrated units. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A sample straight from the channel on this module. + */ +int16_t getAnalogValue(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + int16_t value; + checkAnalogChannel(port->port.pin); + + tAI::tReadSelect readSelect; + readSelect.Channel = port->port.pin - 1; + readSelect.Module = port->port.module - 1; + readSelect.Averaged = false; + + { + Synchronized sync(analogRegisterWindowSemaphore); + port->module->writeReadSelect(readSelect, status); + port->module->strobeLatchOutput(status); + value = (int16_t) port->module->readOutput(status); + } + + return value; +} + +/** + * Get a sample from the output of the oversample and average engine for the channel. + * + * The sample is 12-bit + the value configured in SetOversampleBits(). + * The value configured in SetAverageBits() will cause this value to be averaged 2**bits number of samples. + * This is not a sliding window. The sample will not change until 2**(OversamplBits + AverageBits) samples + * have been acquired from the module on this channel. + * Use GetAverageVoltage() to get the analog value in calibrated units. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A sample from the oversample and average engine for the channel. + */ +int32_t getAnalogAverageValue(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + int16_t value; + checkAnalogChannel(port->port.pin); + + tAI::tReadSelect readSelect; + readSelect.Channel = port->port.pin - 1; + readSelect.Module = port->port.module - 1; + readSelect.Averaged = true; + + { + Synchronized sync(analogRegisterWindowSemaphore); + port->module->writeReadSelect(readSelect, status); + port->module->strobeLatchOutput(status); + value = (int16_t) port->module->readOutput(status); + } + + return value; +} + +/** + * Get a scaled sample straight from the channel on this module. + * + * The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset(). + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A scaled sample straight from the channel on this module. + */ +float getAnalogVoltage(void* analog_port_pointer, int32_t *status) { + int16_t value = getAnalogValue(analog_port_pointer, status); + uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status); + int32_t offset = getAnalogOffset(analog_port_pointer, status); + float voltage = LSBWeight * 1.0e-9 * value - offset * 1.0e-9; + return voltage; +} + +/** + * Get a scaled sample from the output of the oversample and average engine for the channel. + * + * The value is scaled to units of Volts using the calibrated scaling data from GetLSBWeight() and GetOffset(). + * Using oversampling will cause this value to be higher resolution, but it will update more slowly. + * Using averaging will cause this value to be more stable, but it will update more slowly. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return A scaled sample from the output of the oversample and average engine for the channel. + */ +float getAnalogAverageVoltage(void* analog_port_pointer, int32_t *status) { + int32_t value = getAnalogAverageValue(analog_port_pointer, status); + uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status); + int32_t offset = getAnalogOffset(analog_port_pointer, status); + uint32_t oversampleBits = getAnalogOversampleBits(analog_port_pointer, status); + float voltage = ((LSBWeight * 1.0e-9 * value) / (float)(1 << oversampleBits)) - offset * 1.0e-9; + return voltage; +} + +/** + * Convert a voltage to a raw value for a specified channel. + * + * This process depends on the calibration of each channel, so the channel + * must be specified. + * + * @todo This assumes raw values. Oversampling not supported as is. + * + * @param analog_port_pointer Pointer to the analog port to use. + * @param voltage The voltage to convert. + * @return The raw value for the channel. + */ +int32_t getAnalogVoltsToValue(void* analog_port_pointer, double voltage, int32_t *status) { + if (voltage > 10.0) { + voltage = 10.0; + *status = VOLTAGE_OUT_OF_RANGE; + } + if (voltage < -10.0) { + voltage = -10.0; + *status = VOLTAGE_OUT_OF_RANGE; + } + uint32_t LSBWeight = getAnalogLSBWeight(analog_port_pointer, status); + int32_t offset = getAnalogOffset(analog_port_pointer, status); + int32_t value = (int32_t) ((voltage + offset * 1.0e-9) / (LSBWeight * 1.0e-9)); + return value; +} + +/** + * Get the factory scaling least significant bit weight constant. + * The least significant bit weight constant for the channel that was calibrated in + * manufacturing and stored in an eeprom in the module. + * + * Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9) + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Least significant bit weight. + */ +uint32_t getAnalogLSBWeight(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + uint32_t lsbWeight = FRC_NetworkCommunication_nAICalibration_getLSBWeight(port->module->getSystemIndex(), + port->port.pin - 1, status); + return lsbWeight; +} + +/** + * Get the factory scaling offset constant. + * The offset constant for the channel that was calibrated in manufacturing and stored + * in an eeprom in the module. + * + * Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9) + * + * @param analog_port_pointer Pointer to the analog port to use. + * @return Offset constant. + */ +int32_t getAnalogOffset(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + int32_t offset = FRC_NetworkCommunication_nAICalibration_getOffset(port->module->getSystemIndex(), + port->port.pin - 1, status); + return offset; +} + + +/** + * Return the number of channels on the module in use. + * + * @return Active channels. + */ +uint32_t getAnalogNumActiveChannels(uint8_t module, int32_t *status) { + uint32_t scanSize = analogModules[module-1]->readConfig_ScanSize(status); + if (scanSize == 0) + return 8; + return scanSize; +} + +/** + * Get the number of active channels. + * + * This is an internal function to allow the atomic update of both the + * number of active channels and the sample rate. + * + * When the number of channels changes, use the new value. Otherwise, + * return the curent value. + * + * @return Value to write to the active channels field. + */ +uint32_t getAnalogNumChannelsToActivate(uint8_t module, int32_t *status) { + if(analogNumChannelsToActivate[module-1] == 0) return getAnalogNumActiveChannels(module, status); + return analogNumChannelsToActivate[module-1]; +} + +/** + * Set the number of active channels. + * + * Store the number of active channels to set. Don't actually commit to hardware + * until SetSampleRate(). + * + * @param channels Number of active channels. + */ +void setAnalogNumChannelsToActivate(uint8_t module, uint32_t channels) { + analogNumChannelsToActivate[module-1] = channels; +} + +//// Accumulator Stuff + +/** + * Is the channel attached to an accumulator. + * + * @return The analog channel is attached to an accumulator. + */ +bool isAccumulatorChannel(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if(port->port.module != kAccumulatorModuleNumber) return false; + for (uint32_t i=0; i < kAccumulatorNumChannels; i++) { + if (port->port.pin == kAccumulatorChannels[i]) return true; + } + return false; +} + +/** + * Initialize the accumulator. + */ +void initAccumulator(void* analog_port_pointer, int32_t *status) { + setAccumulatorCenter(analog_port_pointer, 0, status); + resetAccumulator(analog_port_pointer, status); +} + +/** + * Resets the accumulator to the initial value. + */ +void resetAccumulator(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + port->accumulator->strobeReset(status); +} + +/** + * Set the center value of the accumulator. + * + * The center value is subtracted from each A/D value before it is added to the accumulator. This + * is used for the center value of devices like gyros and accelerometers to make integration work + * and to take the device offset into account when integrating. + * + * This center value is based on the output of the oversampled and averaged source from channel 1. + * Because of this, any non-zero oversample bits will affect the size of the value for this field. + */ +void setAccumulatorCenter(void* analog_port_pointer, int32_t center, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + port->accumulator->writeCenter(center, status); +} + +/** + * Set the accumulator's deadband. + */ +void setAccumulatorDeadband(void* analog_port_pointer, int32_t deadband, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + port->accumulator->writeDeadband(deadband, status); +} + +/** + * Read the accumulated value. + * + * Read the value that has been accumulating on channel 1. + * The accumulator is attached after the oversample and average engine. + * + * @return The 64-bit value accumulated since the last Reset(). + */ +int64_t getAccumulatorValue(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return 0; + } + int64_t value = port->accumulator->readOutput_Value(status); + return value; +} + +/** + * Read the number of accumulated values. + * + * Read the count of the accumulated values since the accumulator was last Reset(). + * + * @return The number of times samples from the channel were accumulated. + */ +uint32_t getAccumulatorCount(void* analog_port_pointer, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return 0; + } + return port->accumulator->readOutput_Count(status); +} + +/** + * Read the accumulated value and the number of accumulated values atomically. + * + * This function reads the value and count from the FPGA atomically. + * This can be used for averaging. + * + * @param value Pointer to the 64-bit accumulated output. + * @param count Pointer to the number of accumulation cycles. + */ +void getAccumulatorOutput(void* analog_port_pointer, int64_t *value, uint32_t *count, int32_t *status) { + AnalogPort* port = (AnalogPort*) analog_port_pointer; + if (port->accumulator == NULL) { + *status = NULL_PARAMETER; + return; + } + if (value == NULL || count == NULL) { + *status = NULL_PARAMETER; + return; + } + + tAccumulator::tOutput output = port->accumulator->readOutput(status); + *value = output.Value; + *count = output.Count; +} + + +struct trigger_t { + tAnalogTrigger* trigger; + AnalogPort* port; + uint32_t index; +}; +typedef struct trigger_t AnalogTrigger; + +static Resource *triggers = NULL; + +void* initializeAnalogTrigger(void* port_pointer, uint32_t *index, int32_t *status) { + Port* port = (Port*) port_pointer; + Resource::CreateResourceObject(&triggers, tAnalogTrigger::kNumSystems); + + AnalogTrigger* trigger = new AnalogTrigger(); + trigger->port = (AnalogPort*) initializeAnalogPort(port, status); + trigger->index = triggers->Allocate("Analog Trigger"); + *index = trigger->index; + // TODO: if (index == ~0ul) { CloneError(triggers); return; } + + trigger->trigger = tAnalogTrigger::create(trigger->index, status); + trigger->trigger->writeSourceSelect_Channel(port->pin - 1, status); + trigger->trigger->writeSourceSelect_Module(port->module - 1, status); + + return trigger; +} + +void cleanAnalogTrigger(void* analog_trigger_pointer, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + triggers->Free(trigger->index); + delete trigger->trigger; + delete trigger; +} + +void setAnalogTriggerLimitsRaw(void* analog_trigger_pointer, int32_t lower, int32_t upper, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (lower > upper) { + *status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR; + } + trigger->trigger->writeLowerLimit(lower, status); + trigger->trigger->writeUpperLimit(upper, status); +} + +/** + * Set the upper and lower limits of the analog trigger. + * The limits are given as floating point voltage values. + */ +void setAnalogTriggerLimitsVoltage(void* analog_trigger_pointer, double lower, double upper, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (lower > upper) { + *status = ANALOG_TRIGGER_LIMIT_ORDER_ERROR; + } + // TODO: This depends on the averaged setting. Only raw values will work as is. + trigger->trigger->writeLowerLimit(getAnalogVoltsToValue(trigger->port, lower, status), status); + trigger->trigger->writeUpperLimit(getAnalogVoltsToValue(trigger->port, upper, status), status); +} + +/** + * Configure the analog trigger to use the averaged vs. raw values. + * If the value is true, then the averaged value is selected for the analog trigger, otherwise + * the immediate value is used. + */ +void setAnalogTriggerAveraged(void* analog_trigger_pointer, bool useAveragedValue, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (trigger->trigger->readSourceSelect_Filter(status) != 0) { + *status = INCOMPATIBLE_STATE; + // TODO: wpi_setWPIErrorWithContext(IncompatibleMode, "Hardware does not support average and filtering at the same time."); + } + trigger->trigger->writeSourceSelect_Averaged(useAveragedValue, status); +} + +/** + * Configure the analog trigger to use a filtered value. + * The analog trigger will operate with a 3 point average rejection filter. This is designed to + * help with 360 degree pot applications for the period where the pot crosses through zero. + */ +void setAnalogTriggerFiltered(void* analog_trigger_pointer, bool useFilteredValue, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + if (trigger->trigger->readSourceSelect_Averaged(status) != 0) { + *status = INCOMPATIBLE_STATE; + // TODO: wpi_setWPIErrorWithContext(IncompatibleMode, "Hardware does not support average and filtering at the same time."); + } + trigger->trigger->writeSourceSelect_Filter(useFilteredValue, status); +} + +/** + * Return the InWindow output of the analog trigger. + * True if the analog input is between the upper and lower limits. + * @return The InWindow output of the analog trigger. + */ +bool getAnalogTriggerInWindow(void* analog_trigger_pointer, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + return trigger->trigger->readOutput_InHysteresis(trigger->index, status) != 0; +} + +/** + * Return the TriggerState output of the analog trigger. + * True if above upper limit. + * False if below lower limit. + * If in Hysteresis, maintain previous state. + * @return The TriggerState output of the analog trigger. + */ +bool getAnalogTriggerTriggerState(void* analog_trigger_pointer, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + return trigger->trigger->readOutput_OverLimit(trigger->index, status) != 0; +} + +/** + * Get the state of the analog trigger output. + * @return The state of the analog trigger output. + */ +bool getAnalogTriggerOutput(void* analog_trigger_pointer, AnalogTriggerType type, int32_t *status) { + AnalogTrigger* trigger = (AnalogTrigger*) analog_trigger_pointer; + bool result = false; + switch(type) { + case kInWindow: + result = trigger->trigger->readOutput_InHysteresis(trigger->index, status); + case kState: + result = trigger->trigger->readOutput_OverLimit(trigger->index, status); + case kRisingPulse: + case kFallingPulse: + *status = ANALOG_TRIGGER_PULSE_OUTPUT_ERROR; + return false; + } + return result; +} diff --git a/hal/Azalea/src/main/native/ChipObject.h b/hal/Azalea/src/main/native/ChipObject.h new file mode 100644 index 0000000000..607af92283 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject.h @@ -0,0 +1,32 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#ifndef __ChipObject_h__ +#define __ChipObject_h__ + +#include +#include "ChipObject/NiRio.h" + +#include "ChipObject/tAccumulator.h" +#include "ChipObject/tAI.h" +#include "ChipObject/tAlarm.h" +#include "ChipObject/tAnalogTrigger.h" +#include "ChipObject/tCounter.h" +#include "ChipObject/tDIO.h" +#include "ChipObject/tDMA.h" +//#include "ChipObject/tDMAManager.h" +#include "ChipObject/tEncoder.h" +#include "ChipObject/tGlobal.h" +#include "ChipObject/tInterrupt.h" +#include "ChipObject/tInterruptManager.h" +#include "ChipObject/tSolenoid.h" +#include "ChipObject/tSPI.h" +#include "ChipObject/tWatchdog.h" + +using namespace nFPGA; +using namespace nFRC_2012_1_6_4; + +#endif diff --git a/hal/Azalea/src/main/native/ChipObject/Makefile b/hal/Azalea/src/main/native/ChipObject/Makefile new file mode 100644 index 0000000000..bc1916495a --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/Makefile @@ -0,0 +1,2184 @@ +# Wind River Workbench generated Makefile. +# Do not edit!!! +# +# The file ".wrmakefile" is the template used by the Wind River Workbench to +# generate the makefiles of this project. Add user-specific build targets and +# make rules only(!) in this project's ".wrmakefile" file. These will then be +# automatically dumped into the makefiles. + +WIND_HOME := $(subst \,/,$(WIND_HOME)) +WIND_BASE := $(subst \,/,$(WIND_BASE)) +WIND_USR := $(subst \,/,$(WIND_USR)) + +all : pre_build main_all post_build + +_clean :: + @echo "make: removing targets and objects of `pwd`" + +TRACE=0 +TRACEON=$(TRACE:0=@) +TRACE_FLAG=$(TRACEON:1=) + +MAKEFILE := Makefile + +BUILD_SPEC = PPC603gnu +DEBUG_MODE = 1 +SRC_DIR := . +BUILD_ROOT_DIR := +PRJ_ROOT_DIR := C:/windriver/workspace/WPILib +WS_ROOT_DIR := C:/windriver/workspace + +ALL_BUILD_SPECS := PPC32diab PPC32gnu PPC32sfdiab PPC32sfgnu \ + PPC403diab PPC403gnu PPC405diab PPC405gnu \ + PPC405sfdiab PPC405sfgnu PPC440diab PPC440gnu \ + PPC440sfdiab PPC440sfgnu PPC603diab PPC603gnu \ + PPC604diab PPC604gnu PPC85XXdiab PPC85XXgnu \ + PPC85XXsfdiab PPC85XXsfgnu PPC860sfdiab PPC860sfgnu \ + SIMLINUXdiab SIMLINUXgnu SIMNTdiab SIMNTgnu \ + SIMSPARCSOLARISdiab SIMSPARCSOLARISgnu +ENABLED_BUILD_SPECS := PPC603gnu + +ifeq ($(BUILD_SPEC),PPC32diab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC32diab_DEBUG +else +OBJ_DIR := PPC32diab +endif +endif +ifeq ($(BUILD_SPEC),PPC32gnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC32gnu_DEBUG +else +OBJ_DIR := PPC32gnu +endif +endif +ifeq ($(BUILD_SPEC),PPC32sfdiab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC32sfdiab_DEBUG +else +OBJ_DIR := PPC32sfdiab +endif +endif +ifeq ($(BUILD_SPEC),PPC32sfgnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC32sfgnu_DEBUG +else +OBJ_DIR := PPC32sfgnu +endif +endif +ifeq ($(BUILD_SPEC),PPC403diab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC403diab_DEBUG +else +OBJ_DIR := PPC403diab +endif +endif +ifeq ($(BUILD_SPEC),PPC403gnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC403gnu_DEBUG +else +OBJ_DIR := PPC403gnu +endif +endif +ifeq ($(BUILD_SPEC),PPC405diab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC405diab_DEBUG +else +OBJ_DIR := PPC405diab +endif +endif +ifeq ($(BUILD_SPEC),PPC405gnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC405gnu_DEBUG +else +OBJ_DIR := PPC405gnu +endif +endif +ifeq ($(BUILD_SPEC),PPC405sfdiab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC405sfdiab_DEBUG +else +OBJ_DIR := PPC405sfdiab +endif +endif +ifeq ($(BUILD_SPEC),PPC405sfgnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC405sfgnu_DEBUG +else +OBJ_DIR := PPC405sfgnu +endif +endif +ifeq ($(BUILD_SPEC),PPC440diab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC440diab_DEBUG +else +OBJ_DIR := PPC440diab +endif +endif +ifeq ($(BUILD_SPEC),PPC440gnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC440gnu_DEBUG +else +OBJ_DIR := PPC440gnu +endif +endif +ifeq ($(BUILD_SPEC),PPC440sfdiab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC440sfdiab_DEBUG +else +OBJ_DIR := PPC440sfdiab +endif +endif +ifeq ($(BUILD_SPEC),PPC440sfgnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC440sfgnu_DEBUG +else +OBJ_DIR := PPC440sfgnu +endif +endif +ifeq ($(BUILD_SPEC),PPC603diab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC603diab_DEBUG +else +OBJ_DIR := PPC603diab +endif +endif +ifeq ($(BUILD_SPEC),PPC603gnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC603gnu_DEBUG +else +OBJ_DIR := PPC603gnu +endif +endif +ifeq ($(BUILD_SPEC),PPC604diab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC604diab_DEBUG +else +OBJ_DIR := PPC604diab +endif +endif +ifeq ($(BUILD_SPEC),PPC604gnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC604gnu_DEBUG +else +OBJ_DIR := PPC604gnu +endif +endif +ifeq ($(BUILD_SPEC),PPC85XXdiab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC85XXdiab_DEBUG +else +OBJ_DIR := PPC85XXdiab +endif +endif +ifeq ($(BUILD_SPEC),PPC85XXgnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC85XXgnu_DEBUG +else +OBJ_DIR := PPC85XXgnu +endif +endif +ifeq ($(BUILD_SPEC),PPC85XXsfdiab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC85XXsfdiab_DEBUG +else +OBJ_DIR := PPC85XXsfdiab +endif +endif +ifeq ($(BUILD_SPEC),PPC85XXsfgnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC85XXsfgnu_DEBUG +else +OBJ_DIR := PPC85XXsfgnu +endif +endif +ifeq ($(BUILD_SPEC),PPC860sfdiab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC860sfdiab_DEBUG +else +OBJ_DIR := PPC860sfdiab +endif +endif +ifeq ($(BUILD_SPEC),PPC860sfgnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := PPC860sfgnu_DEBUG +else +OBJ_DIR := PPC860sfgnu +endif +endif +ifeq ($(BUILD_SPEC),SIMLINUXdiab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := SIMLINUXdiab_DEBUG +else +OBJ_DIR := SIMLINUXdiab +endif +endif +ifeq ($(BUILD_SPEC),SIMLINUXgnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := SIMLINUXgnu_DEBUG +else +OBJ_DIR := SIMLINUXgnu +endif +endif +ifeq ($(BUILD_SPEC),SIMNTdiab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := SIMNTdiab_DEBUG +else +OBJ_DIR := SIMNTdiab +endif +endif +ifeq ($(BUILD_SPEC),SIMNTgnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := SIMNTgnu_DEBUG +else +OBJ_DIR := SIMNTgnu +endif +endif +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISdiab) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := SIMSPARCSOLARISdiab_DEBUG +else +OBJ_DIR := SIMSPARCSOLARISdiab +endif +endif +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISgnu) +ifeq ($(DEBUG_MODE),1) +OBJ_DIR := SIMSPARCSOLARISgnu_DEBUG +else +OBJ_DIR := SIMSPARCSOLARISgnu +endif +endif + +ifeq ($(BUILD_SPEC),PPC32diab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC32gnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC32sfdiab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC32sfgnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC403diab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC403gnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC405diab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC405gnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC405sfdiab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC405sfgnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC440diab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC440gnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC440sfdiab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC440sfgnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC603diab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC603gnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC604diab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC604gnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC85XXdiab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC85XXgnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC85XXsfdiab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC85XXsfgnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC860sfdiab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),PPC860sfgnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),SIMLINUXdiab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),SIMLINUXgnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),SIMNTdiab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),SIMNTgnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISdiab) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISgnu) +SUBDIRS := +OBJECTS := + +PROJECT_TARGETS := $(OBJECTS) + +SUB_OBJECTS := +SUB_TARGETS := +endif + +PROJECT_TYPE = DKM +DEFINES = +EXPAND_DBG = 0 + +ifeq ($(BUILD_SPEC),PPC32diab) +VX_CPU_FAMILY = ppc +CPU = PPC32 +TOOL_FAMILY = diab +TOOL = diab +TOOL_PATH = +CC_ARCH_SPEC = -tPPCFH:vxworks63 -Xstmw-slow -DPPC32_fp60x +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC32gnu) +VX_CPU_FAMILY = ppc +CPU = PPC32 +TOOL_FAMILY = gnu +TOOL = gnu +TOOL_PATH = +CC_ARCH_SPEC = -mhard-float -mstrict-align -mno-implicit-fp -DPPC32_fp60x +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC32sfdiab) +VX_CPU_FAMILY = ppc +CPU = PPC32 +TOOL_FAMILY = diab +TOOL = sfdiab +TOOL_PATH = +CC_ARCH_SPEC = -tPPCFS:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC32sfgnu) +VX_CPU_FAMILY = ppc +CPU = PPC32 +TOOL_FAMILY = gnu +TOOL = sfgnu +TOOL_PATH = +CC_ARCH_SPEC = -msoft-float -mstrict-align +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC403diab) +VX_CPU_FAMILY = ppc +CPU = PPC403 +TOOL_FAMILY = diab +TOOL = diab +TOOL_PATH = +CC_ARCH_SPEC = -tPPC403FS:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC403gnu) +VX_CPU_FAMILY = ppc +CPU = PPC403 +TOOL_FAMILY = gnu +TOOL = gnu +TOOL_PATH = +CC_ARCH_SPEC = -mcpu=403 -mstrict-align -msoft-float +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC405diab) +VX_CPU_FAMILY = ppc +CPU = PPC405 +TOOL_FAMILY = diab +TOOL = diab +TOOL_PATH = +CC_ARCH_SPEC = -tPPC405FS:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC405gnu) +VX_CPU_FAMILY = ppc +CPU = PPC405 +TOOL_FAMILY = gnu +TOOL = gnu +TOOL_PATH = +CC_ARCH_SPEC = -mcpu=405 -mstrict-align -msoft-float +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC405sfdiab) +VX_CPU_FAMILY = ppc +CPU = PPC405 +TOOL_FAMILY = diab +TOOL = sfdiab +TOOL_PATH = +CC_ARCH_SPEC = -tPPC405FS:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC405sfgnu) +VX_CPU_FAMILY = ppc +CPU = PPC405 +TOOL_FAMILY = gnu +TOOL = sfgnu +TOOL_PATH = +CC_ARCH_SPEC = -mcpu=405 -mstrict-align -msoft-float +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC440diab) +VX_CPU_FAMILY = ppc +CPU = PPC440 +TOOL_FAMILY = diab +TOOL = diab +TOOL_PATH = +CC_ARCH_SPEC = -tPPC440FH:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC440gnu) +VX_CPU_FAMILY = ppc +CPU = PPC440 +TOOL_FAMILY = gnu +TOOL = gnu +TOOL_PATH = +CC_ARCH_SPEC = -mcpu=440 -mstrict-align -msoft-float +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC440sfdiab) +VX_CPU_FAMILY = ppc +CPU = PPC440 +TOOL_FAMILY = diab +TOOL = sfdiab +TOOL_PATH = +CC_ARCH_SPEC = -tPPC440FS:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC440sfgnu) +VX_CPU_FAMILY = ppc +CPU = PPC440 +TOOL_FAMILY = gnu +TOOL = sfgnu +TOOL_PATH = +CC_ARCH_SPEC = -mcpu=440 -mstrict-align -msoft-float +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC603diab) +VX_CPU_FAMILY = ppc +CPU = PPC603 +TOOL_FAMILY = diab +TOOL = diab +TOOL_PATH = +CC_ARCH_SPEC = -tPPC603FH:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC603gnu) +VX_CPU_FAMILY = ppc +CPU = PPC603 +TOOL_FAMILY = gnu +TOOL = gnu +TOOL_PATH = +CC_ARCH_SPEC = -mcpu=603 -mstrict-align -mno-implicit-fp -mlongcall +LIBPATH = +LIBS = + +IDE_INCLUDES = -I.. -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC604diab) +VX_CPU_FAMILY = ppc +CPU = PPC604 +TOOL_FAMILY = diab +TOOL = diab +TOOL_PATH = +CC_ARCH_SPEC = -tPPC604FH:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC604gnu) +VX_CPU_FAMILY = ppc +CPU = PPC604 +TOOL_FAMILY = gnu +TOOL = gnu +TOOL_PATH = +CC_ARCH_SPEC = -mcpu=604 -mstrict-align -mno-implicit-fp +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC85XXdiab) +VX_CPU_FAMILY = ppc +CPU = PPC85XX +TOOL_FAMILY = diab +TOOL = diab +TOOL_PATH = +CC_ARCH_SPEC = -tPPCE500FS:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC85XXgnu) +VX_CPU_FAMILY = ppc +CPU = PPC85XX +TOOL_FAMILY = gnu +TOOL = gnu +TOOL_PATH = +CC_ARCH_SPEC = -mcpu=8540 -mstrict-align -msoft-float -mabi=no-spe +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC85XXsfdiab) +VX_CPU_FAMILY = ppc +CPU = PPC85XX +TOOL_FAMILY = diab +TOOL = sfdiab +TOOL_PATH = +CC_ARCH_SPEC = -tPPCE500FS:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC85XXsfgnu) +VX_CPU_FAMILY = ppc +CPU = PPC85XX +TOOL_FAMILY = gnu +TOOL = sfgnu +TOOL_PATH = +CC_ARCH_SPEC = -mcpu=8540 -mstrict-align -msoft-float -mabi=no-spe +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC860sfdiab) +VX_CPU_FAMILY = ppc +CPU = PPC860 +TOOL_FAMILY = diab +TOOL = sfdiab +TOOL_PATH = +CC_ARCH_SPEC = -tPPC860FS:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),PPC860sfgnu) +VX_CPU_FAMILY = ppc +CPU = PPC860 +TOOL_FAMILY = gnu +TOOL = sfgnu +TOOL_PATH = +CC_ARCH_SPEC = -mcpu=860 -mstrict-align -msoft-float +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),SIMLINUXdiab) +VX_CPU_FAMILY = simlinux +CPU = SIMLINUX +TOOL_FAMILY = diab +TOOL = diab +TOOL_PATH = +CC_ARCH_SPEC = -tX86LH:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),SIMLINUXgnu) +VX_CPU_FAMILY = simlinux +CPU = SIMLINUX +TOOL_FAMILY = gnu +TOOL = gnu +TOOL_PATH = +CC_ARCH_SPEC = -mtune=i486 -march=i486 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),SIMNTdiab) +VX_CPU_FAMILY = simpc +CPU = SIMNT +TOOL_FAMILY = diab +TOOL = diab +TOOL_PATH = +CC_ARCH_SPEC = -tX86LH:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),SIMNTgnu) +VX_CPU_FAMILY = simpc +CPU = SIMNT +TOOL_FAMILY = gnu +TOOL = gnu +TOOL_PATH = +CC_ARCH_SPEC = -mtune=i486 -march=i486 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISdiab) +VX_CPU_FAMILY = simso +CPU = SIMSPARCSOLARIS +TOOL_FAMILY = diab +TOOL = diab +TOOL_PATH = +CC_ARCH_SPEC = -tSPARCFH:vxworks63 +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISgnu) +VX_CPU_FAMILY = simso +CPU = SIMSPARCSOLARIS +TOOL_FAMILY = gnu +TOOL = gnu +TOOL_PATH = +CC_ARCH_SPEC = +LIBPATH = +LIBS = + +IDE_INCLUDES = -I$(WIND_BASE)/target/h -I$(WIND_BASE)/target/h/wrn/coreip + +IDE_LIBRARIES = +endif + + +ifeq ($(BUILD_SPEC),PPC32diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xstsw-slow -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC403diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC403gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC603diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC603gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC604diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC604gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXsfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXsfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC860sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC860sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMLINUXdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMLINUXgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -nostdlib -fno-builtin -fno-defer-pop +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMNTdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMNTgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -nostdlib -fno-builtin -fno-defer-pop +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C-Compiler = -g +else +DEBUGFLAGS_C-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.c + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccsparc $(DEBUGFLAGS_C-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xstsw-slow -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xstsw-slow -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xstsw-slow -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xstsw-slow -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC403diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC403gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC603diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC603gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG) $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG) $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG) $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG) $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL -D'SVN_REV="$(shell svnversion -n ..)"' $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC604diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC604gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXsfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXsfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC860sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC860sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMLINUXdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMLINUXgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -nostdlib -fno-builtin -fno-defer-pop +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMNTdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMNTgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -nostdlib -fno-builtin -fno-defer-pop +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xforce-declarations -Xmake-dependency=0xd $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_C++-Compiler = -g +else +DEBUGFLAGS_C++-Compiler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cpp + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccsparc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.C + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccsparc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cxx + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccsparc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.cc + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccsparc $(DEBUGFLAGS_C++-Compiler) $(CC_ARCH_SPEC) -ansi -Wall -MD -MP $(ADDED_C++FLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xstsw-slow -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC32sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC403diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC403gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC405sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC440sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC603diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC603gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC604diab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC604gnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXsfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC85XXsfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC860sfdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),PPC860sfgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccppc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMLINUXdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Wa,-Xmnem-mit -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMLINUXgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -nostdlib -fno-builtin -fno-defer-pop +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMNTdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Wa,-Xmnem-mit -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMNTgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -nostdlib -fno-builtin -fno-defer-pop +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccpentium $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISdiab) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -XO -Xsize-opt +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)dcc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -W:c:,-Xclib-optim-off -Xansi -Xlocal-data-area-static-only -Xpreprocess-assembly -Xcpp-no-space -Xmake-dependency=0xd $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif +ifeq ($(BUILD_SPEC),SIMSPARCSOLARISgnu) +ifeq ($(DEBUG_MODE),1) +DEBUGFLAGS_Assembler = -g +else +DEBUGFLAGS_Assembler = -O2 -fstrength-reduce -fno-builtin +endif +$(OBJ_DIR)/%.o : $(SRC_DIR)/%.s + $(TRACE_FLAG)echo "building $@"; $(TOOL_PATH)ccsparc $(DEBUGFLAGS_Assembler) $(CC_ARCH_SPEC) -ansi -xassembler-with-cpp -MD -MP $(ADDED_CFLAGS) $(IDE_INCLUDES) $(ADDED_INCLUDES) -DCPU=$(CPU) -DTOOL_FAMILY=$(TOOL_FAMILY) -DTOOL=$(TOOL) -D_WRS_KERNEL $(DEFINES) -o "$@" -c "$<" + +endif + + + + + +-include $(PRJ_ROOT_DIR)/*.makefile + +-include *.makefile + +main_all : external_build $(PROJECT_TARGETS) + @echo "make: built targets of `pwd`" + +# entry point for extending the build +external_build :: + @echo "" + +# main entry point for pre processing prior to the build +pre_build :: $(PRE_BUILD_STEP) generate_sources + @echo "" + +# entry point for generating sources prior to the build +generate_sources :: + @echo "" + +# main entry point for post processing after the build +post_build :: $(POST_BUILD_STEP) deploy_output + @echo "" + +# entry point for deploying output after the build +deploy_output :: + @echo "" + +clean :: external_clean $(CLEAN_STEP) _clean + +# entry point for extending the build clean +external_clean :: + @echo "" diff --git a/hal/Azalea/src/main/native/ChipObject/NiFpga.h b/hal/Azalea/src/main/native/ChipObject/NiFpga.h new file mode 100644 index 0000000000..c5f2bce86e --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/NiFpga.h @@ -0,0 +1,2311 @@ +/* + * FPGA Interface C API 2.0 header file. + * + * Copyright (c) 2011, + * National Instruments Corporation. + * All rights reserved. + */ + +#ifndef __NiFpga_h__ +#define __NiFpga_h__ + +/* + * Determine platform details. + */ +#if defined(_M_IX86) \ + || defined(_M_X64) \ + || defined(i386) \ + || defined(__i386__) \ + || defined(__amd64__) \ + || defined(__amd64) \ + || defined(__x86_64__) \ + || defined(__x86_64) \ + || defined(__i386) \ + || defined(_X86_) \ + || defined(__THW_INTEL__) \ + || defined(__I86__) \ + || defined(__INTEL__) \ + || defined(__X86__) \ + || defined(__386__) \ + || defined(__I86__) \ + || defined(M_I386) \ + || defined(M_I86) \ + || defined(_M_I386) \ + || defined(_M_I86) + #if defined(_WIN32) \ + || defined(_WIN64) \ + || defined(__WIN32__) \ + || defined(__TOS_WIN__) \ + || defined(__WINDOWS__) \ + || defined(_WINDOWS) \ + || defined(__WINDOWS_386__) \ + || defined(__CYGWIN__) + /* Either Windows or Phar Lap ETS. */ + #define NiFpga_Windows 1 + #elif defined(__linux) \ + || defined(__linux__) \ + || defined(__gnu_linux__) \ + || defined(linux) + #define NiFpga_Linux 1 + #else + #error Unsupported OS. + #endif +#elif defined(__powerpc) \ + || defined(__powerpc__) \ + || defined(__POWERPC__) \ + || defined(__ppc__) \ + || defined(__PPC) \ + || defined(_M_PPC) \ + || defined(_ARCH_PPC) \ + || defined(__PPC__) \ + || defined(__ppc) + #if defined(__vxworks) + #define NiFpga_VxWorks 1 + #else + #error Unsupported OS. + #endif +#else + #error Unsupported architecture. +#endif + +/* + * Determine compiler. + */ +#if defined(_MSC_VER) + #define NiFpga_Msvc 1 +#elif defined(__GNUC__) + #define NiFpga_Gcc 1 +#elif defined(_CVI_) && !defined(_TPC_) + #define NiFpga_Cvi 1 + /* Enables CVI Library Protection Errors. */ + #pragma EnableLibraryRuntimeChecking +#else + /* Unknown compiler. */ +#endif + +/* + * Determine compliance with different C/C++ language standards. + */ +#if defined(__cplusplus) + #define NiFpga_Cpp 1 + #if __cplusplus >= 199707L + #define NiFpga_Cpp98 1 + #endif +#endif +#if defined(__STDC__) + #define NiFpga_C89 1 + #if defined(__STDC_VERSION__) + #define NiFpga_C90 1 + #if __STDC_VERSION__ >= 199409L + #define NiFpga_C94 1 + #if __STDC_VERSION__ >= 199901L + #define NiFpga_C99 1 + #endif + #endif + #endif +#endif + +/* + * Determine ability to inline functions. + */ +#if NiFpga_Cpp || NiFpga_C99 + /* The inline keyword exists in C++ and C99. */ + #define NiFpga_Inline inline +#elif NiFpga_Msvc + /* Visual C++ (at least since 6.0) also supports an alternate keyword. */ + #define NiFpga_Inline __inline +#elif NiFpga_Gcc + /* GCC (at least since 2.95.2) also supports an alternate keyword. */ + #define NiFpga_Inline __inline__ +#elif !defined(NiFpga_Inline) + /* + * Disable inlining if inline support is unknown. To manually enable + * inlining, #define the following macro before #including NiFpga.h: + * + * #define NiFpga_Inline inline + */ + #define NiFpga_Inline +#endif + +/* + * Define exact-width integer types, if they have not already been defined. + */ +#if NiFpga_ExactWidthIntegerTypesDefined \ + || defined(_STDINT) \ + || defined(_STDINT_H) \ + || defined(_STDINT_H_) \ + || defined(_INTTYPES_H) \ + || defined(_INTTYPES_H_) \ + || defined(_SYS_STDINT_H) \ + || defined(_SYS_STDINT_H_) \ + || defined(_SYS_INTTYPES_H) \ + || defined(_SYS_INTTYPES_H_) \ + || defined(_STDINT_H_INCLUDED) \ + || defined(BOOST_CSTDINT_HPP) \ + || defined(_MSC_STDINT_H_) \ + || defined(_PSTDINT_H_INCLUDED) + /* Assume that exact-width integer types have already been defined. */ +#elif NiFpga_VxWorks + #include +#elif NiFpga_C99 \ + || NiFpga_Gcc /* GCC (at least since 3.0) has a stdint.h. */ \ + || defined(HAVE_STDINT_H) + /* Assume that stdint.h can be included. */ + #include +#elif NiFpga_Msvc \ + || NiFpga_Cvi + /* Manually define exact-width integer types. */ + typedef signed char int8_t; + typedef unsigned char uint8_t; + typedef short int16_t; + typedef unsigned short uint16_t; + typedef int int32_t; + typedef unsigned int uint32_t; + typedef __int64 int64_t; + typedef unsigned __int64 uint64_t; +#else + /* + * Exact-width integer types must be defined by the user, and the following + * macro must be #defined, before #including NiFpga.h: + * + * #define NiFpga_ExactWidthIntegerTypesDefined 1 + */ + #error Exact-width integer types must be defined by the user. See comment. +#endif + +/* Included for definition of size_t. */ +#include + +#if NiFpga_Cpp +extern "C" { +#endif + +/** + * A boolean value; either NiFpga_False or NiFpga_True. + */ +typedef uint8_t NiFpga_Bool; + +/** + * Represents a false condition. + */ +static const NiFpga_Bool NiFpga_False = 0; + +/** + * Represents a true condition. + */ +static const NiFpga_Bool NiFpga_True = 1; + +/** + * Represents the resulting status of a function call through its return value. + * 0 is success, negative values are errors, and positive values are warnings. + */ +typedef int32_t NiFpga_Status; + +/** + * No errors or warnings. + */ +static const NiFpga_Status NiFpga_Status_Success = 0; + +/** + * The timeout expired before the FIFO operation could complete. + */ +static const NiFpga_Status NiFpga_Status_FifoTimeout = -50400; + +/** + * A memory allocation failed. Try again after rebooting. + */ +static const NiFpga_Status NiFpga_Status_MemoryFull = -52000; + +/** + * An unexpected software error occurred. + */ +static const NiFpga_Status NiFpga_Status_SoftwareFault = -52003; + +/** + * A parameter to a function was not valid. This could be a NULL pointer, a bad + * value, etc. + */ +static const NiFpga_Status NiFpga_Status_InvalidParameter = -52005; + +/** + * A required resource was not found. The NiFpga.* library, the RIO resource, + * or some other resource may be missing, or the NiFpga.* library may not be + * the required minimum version. + */ +static const NiFpga_Status NiFpga_Status_ResourceNotFound = -52006; + +/** + * A required resource was not properly initialized. This could occur if + * NiFpga_Initialize was not called or a required NiFpga_IrqContext was not + * reserved. + */ +static const NiFpga_Status NiFpga_Status_ResourceNotInitialized = -52010; + +/** + * The FPGA is already running. + */ +static const NiFpga_Status NiFpga_Status_FpgaAlreadyRunning = -61003; + +/** + * The bitfile was not compiled for the specified resource's device type. + */ +static const NiFpga_Status NiFpga_Status_DeviceTypeMismatch = -61024; + +/** + * An error was detected in the communication between the host computer and the + * FPGA target. + */ +static const NiFpga_Status NiFpga_Status_CommunicationTimeout = -61046; + +/** + * The timeout expired before any of the IRQs were asserted. + */ +static const NiFpga_Status NiFpga_Status_IrqTimeout = -61060; + +/** + * The specified bitfile is invalid or corrupt. + */ +static const NiFpga_Status NiFpga_Status_CorruptBitfile = -61070; + +/** + * The FIFO depth is invalid. It was either 0, greater than the amount of + * available memory in the host computer, or greater than the maximum size + * allowed by the hardware. + */ +static const NiFpga_Status NiFpga_Status_BadDepth = -61072; + +/** + * The number of FIFO elements is invalid. Either the number is greater than + * the depth of the host memory DMA FIFO, or more elements were requested for + * release than had been acquired. + */ +static const NiFpga_Status NiFpga_Status_BadReadWriteCount = -61073; + +/** + * A hardware clocking error occurred. A derived clock lost lock with its base + * clock during the execution of the LabVIEW FPGA VI. If any base clocks with + * derived clocks are referencing an external source, make sure that the + * external source is connected and within the supported frequency, jitter, + * accuracy, duty cycle, and voltage specifications. Also verify that the + * characteristics of the base clock match the configuration specified in the + * FPGA Base Clock Properties. If all base clocks with derived clocks are + * generated from free-running, on-board sources, please contact National + * Instruments technical support at ni.com/support. + */ +static const NiFpga_Status NiFpga_Status_ClockLostLock = -61083; + +/** + * Operation could not be performed because the FPGA is busy. Stop all the + * activities on the FPGA before requesting this operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusy = -61141; + +/** + * Operation could not be performed because the FPGA is busy operating in FPGA + * Interface C API mode. Stop all the activities on the FPGA before requesting + * this operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterfaceCApi = -61200; + +/** + * The chassis is in Scan Interface programming mode. In order to run FPGA VIs, + * you must go to the chassis properties page, select FPGA programming mode, + * and deploy settings. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyScanInterface = -61201; + +/** + * Operation could not be performed because the FPGA is busy operating in FPGA + * Interface mode. Stop all the activities on the FPGA before requesting this + * operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyFpgaInterface = -61202; + +/** + * Operation could not be performed because the FPGA is busy operating in + * Interactive mode. Stop all the activities on the FPGA before requesting this + * operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyInteractive = -61203; + +/** + * Operation could not be performed because the FPGA is busy operating in + * Emulation mode. Stop all the activities on the FPGA before requesting this + * operation. + */ +static const NiFpga_Status NiFpga_Status_FpgaBusyEmulation = -61204; + +/** + * An unexpected internal error occurred. + */ +static const NiFpga_Status NiFpga_Status_InternalError = -61499; + +/** + * Access to the remote system was denied. Use MAX to check the Remote Device + * Access settings under Software>>NI-RIO>>NI-RIO Settings on the remote system. + */ +static const NiFpga_Status NiFpga_Status_AccessDenied = -63033; + +/** + * A connection could not be established to the specified remote device. Ensure + * that the device is on and accessible over the network, that NI-RIO software + * is installed, and that the RIO server is running and properly configured. + */ +static const NiFpga_Status NiFpga_Status_RpcConnectionError = -63040; + +/** + * The RPC session is invalid. The target may have reset or been rebooted. Check + * the network connection and retry the operation. + */ +static const NiFpga_Status NiFpga_Status_RpcSessionError = -63043; + +/** + * A Read FIFO or Write FIFO function was called while the host had acquired + * elements of the FIFO. Release all acquired elements before reading or + * writing. + */ +static const NiFpga_Status NiFpga_Status_FifoElementsCurrentlyAcquired = -63083; + +/** + * The bitfile could not be read. + */ +static const NiFpga_Status NiFpga_Status_BitfileReadError = -63101; + +/** + * The specified signature does not match the signature of the bitfile. If the + * bitfile has been recompiled, regenerate the C API and rebuild the + * application. + */ +static const NiFpga_Status NiFpga_Status_SignatureMismatch = -63106; + +/** + * Either the supplied resource name is invalid as a RIO resource name, or the + * device was not found. Use MAX to find the proper resource name for the + * intended device. + */ +static const NiFpga_Status NiFpga_Status_InvalidResourceName = -63192; + +/** + * The requested feature is not supported. + */ +static const NiFpga_Status NiFpga_Status_FeatureNotSupported = -63193; + +/** + * The NI-RIO software on the remote system is not compatible with the local + * NI-RIO software. Upgrade the NI-RIO software on the remote system. + */ +static const NiFpga_Status NiFpga_Status_VersionMismatch = -63194; + +/** + * The session is invalid or has been closed. + */ +static const NiFpga_Status NiFpga_Status_InvalidSession = -63195; + +/** + * The maximum number of open FPGA sessions has been reached. Close some open + * sessions. + */ +static const NiFpga_Status NiFpga_Status_OutOfHandles = -63198; + +/** + * Tests whether a status is an error. + * + * @param status status to check for an error + * @return whether the status was an error + */ +static NiFpga_Inline NiFpga_Bool NiFpga_IsError(const NiFpga_Status status) +{ + return status < NiFpga_Status_Success; +} + +/** + * Tests whether a status is not an error. Success and warnings are not errors. + * + * @param status status to check for an error + * @return whether the status was a success or warning + */ +static NiFpga_Inline NiFpga_Bool NiFpga_IsNotError(const NiFpga_Status status) +{ + return status >= NiFpga_Status_Success; +} + +/** + * Conditionally sets the status to a new value. The previous status is + * preserved unless the new status is more of an error, which means that + * warnings and errors overwrite successes, and errors overwrite warnings. New + * errors do not overwrite older errors, and new warnings do not overwrite + * older warnings. + * + * @param status status to conditionally set + * @param newStatus new status value that may be set + * @return the resulting status + */ +static NiFpga_Inline NiFpga_Status NiFpga_MergeStatus( + NiFpga_Status* const status, + const NiFpga_Status newStatus) +{ + if (!status) + { + return NiFpga_Status_InvalidParameter; + } + if (NiFpga_IsNotError(*status) + && (*status == NiFpga_Status_Success || NiFpga_IsError(newStatus))) + { + *status = newStatus; + } + return *status; +} + +/** + * This macro evaluates the expression only if the status is not an error. The + * expression must evaluate to an NiFpga_Status, such as a call to any NiFpga_* + * function, because the status will be set to the returned status if the + * expression is evaluated. + * + * You can use this macro to mimic status chaining in LabVIEW, where the status + * does not have to be explicitly checked after each call. Such code may look + * like the following example. + * + * NiFpga_Status status = NiFpga_Status_Success; + * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...)); + * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...)); + * NiFpga_IfIsNotError(status, NiFpga_WriteU32(...)); + * + * @param status status to check for an error + * @param expression expression to call if the incoming status is not an error + */ +#define NiFpga_IfIsNotError(status, expression) \ + if (NiFpga_IsNotError(status)) \ + { \ + NiFpga_MergeStatus(&status, (expression)); \ + } + +/** + * You must call this function before all other function calls. This function + * loads the NiFpga library so that all the other functions will work. If this + * function succeeds, you must call NiFpga_Finalize after all other function + * calls. + * + * @warning This function is not thread safe. + * + * @return result of the call + */ +NiFpga_Status NiFpga_Initialize(void); + +/** + * You must call this function after all other function calls if + * NiFpga_Initialize succeeds. This function unloads the NiFpga library. + * + * @warning This function is not thread safe. + * + * @return result of the call + */ +NiFpga_Status NiFpga_Finalize(void); + +/** + * A handle to an FPGA session. + */ +typedef uint32_t NiFpga_Session; + +/** + * Attributes that NiFpga_Open accepts. + */ +typedef enum +{ + NiFpga_OpenAttribute_NoRun = 1 +} NiFpga_OpenAttribute; + +/** + * Opens a session to the FPGA. This call ensures that the contents of the + * bitfile are programmed to the FPGA. The FPGA runs unless the + * NiFpga_OpenAttribute_NoRun attribute is used. + * + * Because different operating systems have different default current working + * directories for applications, you must pass an absolute path for the bitfile + * parameter. If you pass only the filename instead of an absolute path, the + * operating system may not be able to locate the bitfile. For example, the + * default current working directories are C:\ni-rt\system\ for Phar Lap ETS and + * /c/ for VxWorks. Because the generated *_Bitfile constant is a #define to a + * string literal, you can use C/C++ string-literal concatenation to form an + * absolute path. For example, if the bitfile is in the root directory of a + * Phar Lap ETS system, pass the following for the bitfile parameter. + * + * "C:\\" NiFpga_MyApplication_Bitfile + * + * @param bitfile path to the bitfile + * @param signature signature of the bitfile + * @param resource RIO resource string to open ("RIO0" or "rio://mysystem/RIO") + * @param attribute bitwise OR of any NiFpga_OpenAttributes, or 0 + * @param session outputs the session handle, which must be closed when no + * longer needed + * @return result of the call + */ +NiFpga_Status NiFpga_Open(const char* bitfile, + const char* signature, + const char* resource, + uint32_t attribute, + NiFpga_Session* session); + +/** + * Attributes that NiFpga_Close accepts. + */ +typedef enum +{ + NiFpga_CloseAttribute_NoResetIfLastSession = 1 +} NiFpga_CloseAttribute; + +/** + * Closes the session to the FPGA. The FPGA resets unless either another session + * is still open or you use the NiFpga_CloseAttribute_NoResetIfLastSession + * attribute. + * + * @param session handle to a currently open session + * @param attribute bitwise OR of any NiFpga_CloseAttributes, or 0 + * @return result of the call + */ +NiFpga_Status NiFpga_Close(NiFpga_Session session, + uint32_t attribute); + +/** + * Attributes that NiFpga_Run accepts. + */ +typedef enum +{ + NiFpga_RunAttribute_WaitUntilDone = 1 +} NiFpga_RunAttribute; + +/** + * Runs the FPGA VI on the target. If you use NiFpga_RunAttribute_WaitUntilDone, + * NiFpga_Run blocks the thread until the FPGA finishes running (if ever). + * + * @param session handle to a currently open session + * @param attribute bitwise OR of any NiFpga_RunAttributes, or 0 + * @return result of the call + */ +NiFpga_Status NiFpga_Run(NiFpga_Session session, + uint32_t attribute); + +/** + * Aborts the FPGA VI. + * + * @param session handle to a currently open session + * @return result of the call + */ +NiFpga_Status NiFpga_Abort(NiFpga_Session session); + +/** + * Resets the FPGA VI. + * + * @param session handle to a currently open session + * @return result of the call + */ +NiFpga_Status NiFpga_Reset(NiFpga_Session session); + +/** + * Re-downloads the FPGA bitstream to the target. + * + * @param session handle to a currently open session + * @return result of the call + */ +NiFpga_Status NiFpga_Download(NiFpga_Session session); + +/** + * Reads a boolean value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadBool(NiFpga_Session session, + uint32_t indicator, + NiFpga_Bool* value); + +/** + * Reads a signed 8-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI8(NiFpga_Session session, + uint32_t indicator, + int8_t* value); + +/** + * Reads an unsigned 8-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU8(NiFpga_Session session, + uint32_t indicator, + uint8_t* value); + +/** + * Reads a signed 16-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI16(NiFpga_Session session, + uint32_t indicator, + int16_t* value); + +/** + * Reads an unsigned 16-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU16(NiFpga_Session session, + uint32_t indicator, + uint16_t* value); + +/** + * Reads a signed 32-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI32(NiFpga_Session session, + uint32_t indicator, + int32_t* value); + +/** + * Reads an unsigned 32-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU32(NiFpga_Session session, + uint32_t indicator, + uint32_t* value); + +/** + * Reads a signed 64-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadI64(NiFpga_Session session, + uint32_t indicator, + int64_t* value); + +/** + * Reads an unsigned 64-bit integer value from a given indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param value outputs the value that was read + * @return result of the call + */ +NiFpga_Status NiFpga_ReadU64(NiFpga_Session session, + uint32_t indicator, + uint64_t* value); + +/** + * Writes a boolean value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteBool(NiFpga_Session session, + uint32_t control, + NiFpga_Bool value); + +/** + * Writes a signed 8-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI8(NiFpga_Session session, + uint32_t control, + int8_t value); + +/** + * Writes an unsigned 8-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU8(NiFpga_Session session, + uint32_t control, + uint8_t value); + +/** + * Writes a signed 16-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI16(NiFpga_Session session, + uint32_t control, + int16_t value); + +/** + * Writes an unsigned 16-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU16(NiFpga_Session session, + uint32_t control, + uint16_t value); + +/** + * Writes a signed 32-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI32(NiFpga_Session session, + uint32_t control, + int32_t value); + +/** + * Writes an unsigned 32-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU32(NiFpga_Session session, + uint32_t control, + uint32_t value); + +/** + * Writes a signed 64-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteI64(NiFpga_Session session, + uint32_t control, + int64_t value); + +/** + * Writes an unsigned 64-bit integer value to a given control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param value value to write + * @return result of the call + */ +NiFpga_Status NiFpga_WriteU64(NiFpga_Session session, + uint32_t control, + uint64_t value); + +/** + * Reads an entire array of boolean values from a given array indicator or + * control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayBool(NiFpga_Session session, + uint32_t indicator, + NiFpga_Bool* array, + size_t size); + +/** + * Reads an entire array of signed 8-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI8(NiFpga_Session session, + uint32_t indicator, + int8_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 8-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU8(NiFpga_Session session, + uint32_t indicator, + uint8_t* array, + size_t size); + +/** + * Reads an entire array of signed 16-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI16(NiFpga_Session session, + uint32_t indicator, + int16_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 16-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU16(NiFpga_Session session, + uint32_t indicator, + uint16_t* array, + size_t size); + +/** + * Reads an entire array of signed 32-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI32(NiFpga_Session session, + uint32_t indicator, + int32_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 32-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU32(NiFpga_Session session, + uint32_t indicator, + uint32_t* array, + size_t size); + +/** + * Reads an entire array of signed 64-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayI64(NiFpga_Session session, + uint32_t indicator, + int64_t* array, + size_t size); + +/** + * Reads an entire array of unsigned 64-bit integer values from a given array + * indicator or control. + * + * @warning The size passed must be the exact number of elements in the + * indicator or control. + * + * @param session handle to a currently open session + * @param indicator indicator or control from which to read + * @param array outputs the entire array that was read + * @param size exact number of elements in the indicator or control + * @return result of the call + */ +NiFpga_Status NiFpga_ReadArrayU64(NiFpga_Session session, + uint32_t indicator, + uint64_t* array, + size_t size); + +/** + * Writes an entire array of boolean values to a given array control or + * indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayBool(NiFpga_Session session, + uint32_t control, + const NiFpga_Bool* array, + size_t size); + +/** + * Writes an entire array of signed 8-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI8(NiFpga_Session session, + uint32_t control, + const int8_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 8-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU8(NiFpga_Session session, + uint32_t control, + const uint8_t* array, + size_t size); + +/** + * Writes an entire array of signed 16-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI16(NiFpga_Session session, + uint32_t control, + const int16_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 16-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU16(NiFpga_Session session, + uint32_t control, + const uint16_t* array, + size_t size); + +/** + * Writes an entire array of signed 32-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI32(NiFpga_Session session, + uint32_t control, + const int32_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 32-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU32(NiFpga_Session session, + uint32_t control, + const uint32_t* array, + size_t size); + +/** + * Writes an entire array of signed 64-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayI64(NiFpga_Session session, + uint32_t control, + const int64_t* array, + size_t size); + +/** + * Writes an entire array of unsigned 64-bit integer values to a given array + * control or indicator. + * + * @warning The size passed must be the exact number of elements in the + * control or indicator. + * + * @param session handle to a currently open session + * @param control control or indicator to which to write + * @param array entire array to write + * @param size exact number of elements in the control or indicator + * @return result of the call + */ +NiFpga_Status NiFpga_WriteArrayU64(NiFpga_Session session, + uint32_t control, + const uint64_t* array, + size_t size); + +/** + * Enumeration of all 32 possible IRQs. Multiple IRQs can be bitwise ORed + * together like this: + * + * NiFpga_Irq_3 | NiFpga_Irq_23 + */ +typedef enum +{ + NiFpga_Irq_0 = 1 << 0, + NiFpga_Irq_1 = 1 << 1, + NiFpga_Irq_2 = 1 << 2, + NiFpga_Irq_3 = 1 << 3, + NiFpga_Irq_4 = 1 << 4, + NiFpga_Irq_5 = 1 << 5, + NiFpga_Irq_6 = 1 << 6, + NiFpga_Irq_7 = 1 << 7, + NiFpga_Irq_8 = 1 << 8, + NiFpga_Irq_9 = 1 << 9, + NiFpga_Irq_10 = 1 << 10, + NiFpga_Irq_11 = 1 << 11, + NiFpga_Irq_12 = 1 << 12, + NiFpga_Irq_13 = 1 << 13, + NiFpga_Irq_14 = 1 << 14, + NiFpga_Irq_15 = 1 << 15, + NiFpga_Irq_16 = 1 << 16, + NiFpga_Irq_17 = 1 << 17, + NiFpga_Irq_18 = 1 << 18, + NiFpga_Irq_19 = 1 << 19, + NiFpga_Irq_20 = 1 << 20, + NiFpga_Irq_21 = 1 << 21, + NiFpga_Irq_22 = 1 << 22, + NiFpga_Irq_23 = 1 << 23, + NiFpga_Irq_24 = 1 << 24, + NiFpga_Irq_25 = 1 << 25, + NiFpga_Irq_26 = 1 << 26, + NiFpga_Irq_27 = 1 << 27, + NiFpga_Irq_28 = 1 << 28, + NiFpga_Irq_29 = 1 << 29, + NiFpga_Irq_30 = 1 << 30, + NiFpga_Irq_31 = 1U << 31 +} NiFpga_Irq; + +/** + * Represents an infinite timeout. + */ +static const uint32_t NiFpga_InfiniteTimeout = 0xFFFFFFFF; + +/** + * See NiFpga_ReserveIrqContext for more information. + */ +typedef void* NiFpga_IrqContext; + +/** + * IRQ contexts are single-threaded; only one thread can wait with a particular + * context at any given time. Clients must reserve as many contexts as the + * application requires. + * + * If a context is successfully reserved (the returned status is not an error), + * it must be unreserved later. Otherwise a memory leak will occur. + * + * @param session handle to a currently open session + * @param context outputs the IRQ context + * @return result of the call + */ +NiFpga_Status NiFpga_ReserveIrqContext(NiFpga_Session session, + NiFpga_IrqContext* context); + +/** + * Unreserves an IRQ context obtained from NiFpga_ReserveIrqContext. + * + * @param session handle to a currently open session + * @param context IRQ context to unreserve + * @return result of the call + */ +NiFpga_Status NiFpga_UnreserveIrqContext(NiFpga_Session session, + NiFpga_IrqContext context); + +/** + * This is a blocking function that stops the calling thread until the FPGA + * asserts any IRQ in the irqs parameter, or until the function call times out. + * Before calling this function, you must use NiFpga_ReserveIrqContext to + * reserve an IRQ context. No other threads can use the same context when this + * function is called. + * + * You can use the irqsAsserted parameter to determine which IRQs were asserted + * for each function call. + * + * @param session handle to a currently open session + * @param context IRQ context with which to wait + * @param irqs bitwise OR of NiFpga_Irqs + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param irqsAsserted if non-NULL, outputs bitwise OR of IRQs that were + * asserted + * @param timedOut if non-NULL, outputs whether the timeout expired + * @return result of the call + */ +NiFpga_Status NiFpga_WaitOnIrqs(NiFpga_Session session, + NiFpga_IrqContext context, + uint32_t irqs, + uint32_t timeout, + uint32_t* irqsAsserted, + NiFpga_Bool* timedOut); + +/** + * Acknowledges an IRQ or set of IRQs. + * + * @param session handle to a currently open session + * @param irqs bitwise OR of NiFpga_Irqs + * @return result of the call + */ +NiFpga_Status NiFpga_AcknowledgeIrqs(NiFpga_Session session, + uint32_t irqs); + +/** + * Specifies the depth of the host memory part of the DMA FIFO. This method is + * optional. In order to see the actual depth configured, use + * NiFpga_ConfigureFifo2. + * + * @param session handle to a currently open session + * @param fifo FIFO to configure + * @param depth requested number of elements in the host memory part of the + * DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ConfigureFifo(NiFpga_Session session, + uint32_t fifo, + size_t depth); + +/** + * Specifies the depth of the host memory part of the DMA FIFO. This method is + * optional. + * + * @param session handle to a currently open session + * @param fifo FIFO to configure + * @param requestedDepth requested number of elements in the host memory part + * of the DMA FIFO + * @param actualDepth if non-NULL, outputs the actual number of elements in the + * host memory part of the DMA FIFO, which may be more than + * the requested number + * @return result of the call + */ +NiFpga_Status NiFpga_ConfigureFifo2(NiFpga_Session session, + uint32_t fifo, + size_t requestedDepth, + size_t* actualDepth); +/** + * Starts a FIFO. This method is optional. + * + * @param session handle to a currently open session + * @param fifo FIFO to start + * @return result of the call + */ +NiFpga_Status NiFpga_StartFifo(NiFpga_Session session, + uint32_t fifo); + +/** + * Stops a FIFO. This method is optional. + * + * @param session handle to a currently open session + * @param fifo FIFO to stop + * @return result of the call + */ +NiFpga_Status NiFpga_StopFifo(NiFpga_Session session, + uint32_t fifo); + +/** + * Reads from a target-to-host FIFO of booleans. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoBool(NiFpga_Session session, + uint32_t fifo, + NiFpga_Bool* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI8(NiFpga_Session session, + uint32_t fifo, + int8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU8(NiFpga_Session session, + uint32_t fifo, + uint8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI16(NiFpga_Session session, + uint32_t fifo, + int16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU16(NiFpga_Session session, + uint32_t fifo, + uint16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI32(NiFpga_Session session, + uint32_t fifo, + int32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU32(NiFpga_Session session, + uint32_t fifo, + uint32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of signed 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoI64(NiFpga_Session session, + uint32_t fifo, + int64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Reads from a target-to-host FIFO of unsigned 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param data outputs the data that was read + * @param numberOfElements number of elements to read + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_ReadFifoU64(NiFpga_Session session, + uint32_t fifo, + uint64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* elementsRemaining); + +/** + * Writes to a host-to-target FIFO of booleans. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoBool(NiFpga_Session session, + uint32_t fifo, + const NiFpga_Bool* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI8(NiFpga_Session session, + uint32_t fifo, + const int8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 8-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU8(NiFpga_Session session, + uint32_t fifo, + const uint8_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI16(NiFpga_Session session, + uint32_t fifo, + const int16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 16-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU16(NiFpga_Session session, + uint32_t fifo, + const uint16_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI32(NiFpga_Session session, + uint32_t fifo, + const int32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 32-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU32(NiFpga_Session session, + uint32_t fifo, + const uint32_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of signed 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoI64(NiFpga_Session session, + uint32_t fifo, + const int64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Writes to a host-to-target FIFO of unsigned 64-bit integers. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param data data to write + * @param numberOfElements number of elements to write + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param emptyElementsRemaining if non-NULL, outputs the number of empty + * elements remaining in the host memory part of + * the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_WriteFifoU64(NiFpga_Session session, + uint32_t fifo, + const uint64_t* data, + size_t numberOfElements, + uint32_t timeout, + size_t* emptyElementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of booleans. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsBool( + NiFpga_Session session, + uint32_t fifo, + NiFpga_Bool** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 8-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI8( + NiFpga_Session session, + uint32_t fifo, + int8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 8-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU8( + NiFpga_Session session, + uint32_t fifo, + uint8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 16-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI16( + NiFpga_Session session, + uint32_t fifo, + int16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 16-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU16( + NiFpga_Session session, + uint32_t fifo, + uint16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 32-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI32( + NiFpga_Session session, + uint32_t fifo, + int32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 32-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU32( + NiFpga_Session session, + uint32_t fifo, + uint32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of signed 64-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsI64( + NiFpga_Session session, + uint32_t fifo, + int64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for reading from a target-to-host FIFO of unsigned 64-bit + * integers. + * + * Acquiring, reading, and releasing FIFO elements prevents the need to copy + * the contents of elements from the host memory buffer to a separate + * user-allocated buffer before reading. The FPGA target cannot write to + * elements acquired by the host. Therefore, the host must release elements + * after reading them. The number of elements acquired may differ from the + * number of elements requested if, for example, the number of elements + * requested reaches the end of the host memory buffer. Always release all + * acquired elements before closing the session. Do not attempt to access FIFO + * elements after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo target-to-host FIFO from which to read + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoReadElementsU64( + NiFpga_Session session, + uint32_t fifo, + uint64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of booleans. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsBool( + NiFpga_Session session, + uint32_t fifo, + NiFpga_Bool** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 8-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI8( + NiFpga_Session session, + uint32_t fifo, + int8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 8-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU8( + NiFpga_Session session, + uint32_t fifo, + uint8_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 16-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI16( + NiFpga_Session session, + uint32_t fifo, + int16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 16-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU16( + NiFpga_Session session, + uint32_t fifo, + uint16_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 32-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI32( + NiFpga_Session session, + uint32_t fifo, + int32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 32-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU32( + NiFpga_Session session, + uint32_t fifo, + uint32_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of signed 64-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsI64( + NiFpga_Session session, + uint32_t fifo, + int64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Acquires elements for writing to a host-to-target FIFO of unsigned 64-bit + * integers. + * + * Acquiring, writing, and releasing FIFO elements prevents the need to write + * first into a separate user-allocated buffer and then copy the contents of + * elements to the host memory buffer. The FPGA target cannot read elements + * acquired by the host. Therefore, the host must release elements after + * writing to them. The number of elements acquired may differ from the number + * of elements requested if, for example, the number of elements requested + * reaches the end of the host memory buffer. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo host-to-target FIFO to which to write + * @param elements outputs a pointer to the elements acquired + * @param elementsRequested reqested number of elements + * @param timeout timeout in milliseconds, or NiFpga_InfiniteTimeout + * @param elementsAcquired actual number of elements acquired, which may be + * less than the requested number + * @param elementsRemaining if non-NULL, outputs the number of elements + * remaining in the host memory part of the DMA FIFO + * @return result of the call + */ +NiFpga_Status NiFpga_AcquireFifoWriteElementsU64( + NiFpga_Session session, + uint32_t fifo, + uint64_t** elements, + size_t elementsRequested, + uint32_t timeout, + size_t* elementsAcquired, + size_t* elementsRemaining); + +/** + * Releases previously acquired FIFO elements. + * + * The FPGA target cannot read elements acquired by the host. Therefore, the + * host must release elements after acquiring them. Always release all acquired + * elements before closing the session. Do not attempt to access FIFO elements + * after the elements are released or the session is closed. + * + * @param session handle to a currently open session + * @param fifo FIFO from which to release elements + * @param elements number of elements to release + * @return result of the call + */ +NiFpga_Status NiFpga_ReleaseFifoElements(NiFpga_Session session, + uint32_t fifo, + size_t elements); + +/** + * Gets an endpoint reference to a peer-to-peer FIFO. + * + * @param session handle to a currently open session + * @param fifo peer-to-peer FIFO + * @param endpoint outputs the endpoint reference + * @return result of the call + */ +NiFpga_Status NiFpga_GetPeerToPeerFifoEndpoint(NiFpga_Session session, + uint32_t fifo, + uint32_t* endpoint); + +#if NiFpga_Cpp +} +#endif + +#endif diff --git a/hal/Azalea/src/main/native/ChipObject/NiRio.h b/hal/Azalea/src/main/native/ChipObject/NiRio.h new file mode 100644 index 0000000000..c0dc29ec35 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/NiRio.h @@ -0,0 +1,9 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __NiRio_h__ +#define __NiRio_h__ + +#include "NiFpga.h" +typedef NiFpga_Status tRioStatusCode; + +#endif // __NiRio_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/nInterfaceGlobals.h b/hal/Azalea/src/main/native/ChipObject/nInterfaceGlobals.h new file mode 100644 index 0000000000..b6c366cf9c --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/nInterfaceGlobals.h @@ -0,0 +1,15 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_nInterfaceGlobals_h__ +#define __nFRC_2012_1_6_4_nInterfaceGlobals_h__ + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + extern unsigned int g_currentTargetClass; +} +} + +#endif // __nFRC_2012_1_6_4_nInterfaceGlobals_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tAI.h b/hal/Azalea/src/main/native/ChipObject/tAI.h new file mode 100644 index 0000000000..38b3f8edb8 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tAI.h @@ -0,0 +1,138 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_AI_h__ +#define __nFRC_2012_1_6_4_AI_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAI +{ +public: + tAI(){} + virtual ~tAI(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAI* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + typedef + union{ + struct{ + unsigned Channel : 3; + unsigned Module : 1; + unsigned Averaged : 1; + }; + struct{ + unsigned value : 5; + }; + } tReadSelect; + typedef + union{ + struct{ + unsigned ScanSize : 3; + unsigned ConvertRate : 26; + }; + struct{ + unsigned value : 29; + }; + } tConfig; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_ScanSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ConvertRate(unsigned int value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ScanSize(tRioStatusCode *status) = 0; + virtual unsigned int readConfig_ConvertRate(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumScanListElements = 8, + } tScanList_IfaceConstants; + + virtual void writeScanList(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readScanList(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tLoopTiming_IfaceConstants; + + virtual unsigned int readLoopTiming(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumAverageBitsElements = 8, + } tAverageBits_IfaceConstants; + + virtual void writeAverageBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readAverageBits(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumOversampleBitsElements = 8, + } tOversampleBits_IfaceConstants; + + virtual void writeOversampleBits(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readOversampleBits(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual signed int readOutput(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReadSelect_IfaceConstants; + + virtual void writeReadSelect(tReadSelect value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeReadSelect_Averaged(bool value, tRioStatusCode *status) = 0; + virtual tReadSelect readReadSelect(tRioStatusCode *status) = 0; + virtual unsigned char readReadSelect_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readReadSelect_Module(tRioStatusCode *status) = 0; + virtual bool readReadSelect_Averaged(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLatchOutput_IfaceConstants; + + virtual void strobeLatchOutput(tRioStatusCode *status) = 0; + + + + +private: + tAI(const tAI&); + void operator=(const tAI&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_AI_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tAccumulator.h b/hal/Azalea/src/main/native/ChipObject/tAccumulator.h new file mode 100644 index 0000000000..370848cb2b --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tAccumulator.h @@ -0,0 +1,87 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Accumulator_h__ +#define __nFRC_2012_1_6_4_Accumulator_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAccumulator +{ +public: + tAccumulator(){} + virtual ~tAccumulator(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAccumulator* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + typedef + union{ + struct{ + signed long long Value; + unsigned Count : 32; + }; + struct{ + unsigned value : 32; + unsigned value2 : 32; + unsigned value3 : 32; + }; + } tOutput; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual signed long long readOutput_Value(tRioStatusCode *status) = 0; + virtual unsigned int readOutput_Count(tRioStatusCode *status) = 0; + + + typedef enum + { + } tCenter_IfaceConstants; + + virtual void writeCenter(signed int value, tRioStatusCode *status) = 0; + virtual signed int readCenter(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDeadband_IfaceConstants; + + virtual void writeDeadband(signed int value, tRioStatusCode *status) = 0; + virtual signed int readDeadband(tRioStatusCode *status) = 0; + + + + + +private: + tAccumulator(const tAccumulator&); + void operator=(const tAccumulator&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Accumulator_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tAlarm.h b/hal/Azalea/src/main/native/ChipObject/tAlarm.h new file mode 100644 index 0000000000..2e542a2ff1 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tAlarm.h @@ -0,0 +1,57 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Alarm_h__ +#define __nFRC_2012_1_6_4_Alarm_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAlarm +{ +public: + tAlarm(){} + virtual ~tAlarm(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAlarm* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tTriggerTime_IfaceConstants; + + virtual void writeTriggerTime(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readTriggerTime(tRioStatusCode *status) = 0; + + + typedef enum + { + } tEnable_IfaceConstants; + + virtual void writeEnable(bool value, tRioStatusCode *status) = 0; + virtual bool readEnable(tRioStatusCode *status) = 0; + + + + +private: + tAlarm(const tAlarm&); + void operator=(const tAlarm&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Alarm_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tAnalogTrigger.h b/hal/Azalea/src/main/native/ChipObject/tAnalogTrigger.h new file mode 100644 index 0000000000..a05f19dcd2 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tAnalogTrigger.h @@ -0,0 +1,117 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_AnalogTrigger_h__ +#define __nFRC_2012_1_6_4_AnalogTrigger_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tAnalogTrigger +{ +public: + tAnalogTrigger(){} + virtual ~tAnalogTrigger(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tAnalogTrigger* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ + unsigned InHysteresis : 1; + unsigned OverLimit : 1; + unsigned Rising : 1; + unsigned Falling : 1; + }; + struct{ + unsigned value : 4; + }; + } tOutput; + typedef + union{ + struct{ + unsigned Channel : 3; + unsigned Module : 1; + unsigned Averaged : 1; + unsigned Filter : 1; + unsigned FloatingRollover : 1; + signed RolloverLimit : 8; + }; + struct{ + unsigned value : 15; + }; + } tSourceSelect; + + + typedef enum + { + } tSourceSelect_IfaceConstants; + + virtual void writeSourceSelect(tSourceSelect value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Averaged(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_Filter(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_FloatingRollover(bool value, tRioStatusCode *status) = 0; + virtual void writeSourceSelect_RolloverLimit(signed short value, tRioStatusCode *status) = 0; + virtual tSourceSelect readSourceSelect(tRioStatusCode *status) = 0; + virtual unsigned char readSourceSelect_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readSourceSelect_Module(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_Averaged(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_Filter(tRioStatusCode *status) = 0; + virtual bool readSourceSelect_FloatingRollover(tRioStatusCode *status) = 0; + virtual signed short readSourceSelect_RolloverLimit(tRioStatusCode *status) = 0; + + + typedef enum + { + } tUpperLimit_IfaceConstants; + + virtual void writeUpperLimit(signed int value, tRioStatusCode *status) = 0; + virtual signed int readUpperLimit(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLowerLimit_IfaceConstants; + + virtual void writeLowerLimit(signed int value, tRioStatusCode *status) = 0; + virtual signed int readLowerLimit(tRioStatusCode *status) = 0; + + + + typedef enum + { + kNumOutputElements = 8, + } tOutput_IfaceConstants; + + virtual tOutput readOutput(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_InHysteresis(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_OverLimit(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_Rising(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readOutput_Falling(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + +private: + tAnalogTrigger(const tAnalogTrigger&); + void operator=(const tAnalogTrigger&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_AnalogTrigger_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tCounter.h b/hal/Azalea/src/main/native/ChipObject/tCounter.h new file mode 100644 index 0000000000..83d409b867 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tCounter.h @@ -0,0 +1,182 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Counter_h__ +#define __nFRC_2012_1_6_4_Counter_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tCounter +{ +public: + tCounter(){} + virtual ~tCounter(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tCounter* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ + unsigned Direction : 1; + signed Value : 31; + }; + struct{ + unsigned value : 32; + }; + } tOutput; + typedef + union{ + struct{ + unsigned UpSource_Channel : 4; + unsigned UpSource_Module : 1; + unsigned UpSource_AnalogTrigger : 1; + unsigned DownSource_Channel : 4; + unsigned DownSource_Module : 1; + unsigned DownSource_AnalogTrigger : 1; + unsigned IndexSource_Channel : 4; + unsigned IndexSource_Module : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexActiveHigh : 1; + unsigned UpRisingEdge : 1; + unsigned UpFallingEdge : 1; + unsigned DownRisingEdge : 1; + unsigned DownFallingEdge : 1; + unsigned Mode : 2; + unsigned PulseLengthThreshold : 6; + unsigned Enable : 1; + }; + struct{ + unsigned value : 32; + }; + } tConfig; + typedef + union{ + struct{ + unsigned Period : 23; + signed Count : 8; + unsigned Stalled : 1; + }; + struct{ + unsigned value : 32; + }; + } tTimerOutput; + typedef + union{ + struct{ + unsigned StallPeriod : 24; + unsigned AverageSize : 7; + unsigned UpdateWhenEmpty : 1; + }; + struct{ + unsigned value : 32; + }; + } tTimerConfig; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual bool readOutput_Direction(tRioStatusCode *status) = 0; + virtual signed int readOutput_Value(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexActiveHigh(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpRisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_UpFallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownRisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DownFallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Mode(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_PulseLengthThreshold(unsigned short value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_UpSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_UpSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_UpSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_DownSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_DownSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_DownSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexActiveHigh(tRioStatusCode *status) = 0; + virtual bool readConfig_UpRisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_UpFallingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_DownRisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_DownFallingEdge(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Mode(tRioStatusCode *status) = 0; + virtual unsigned short readConfig_PulseLengthThreshold(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerOutput_IfaceConstants; + + virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0; + virtual unsigned int readTimerOutput_Period(tRioStatusCode *status) = 0; + virtual signed char readTimerOutput_Count(tRioStatusCode *status) = 0; + virtual bool readTimerOutput_Stalled(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerConfig_IfaceConstants; + + virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_StallPeriod(unsigned int value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_AverageSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_UpdateWhenEmpty(bool value, tRioStatusCode *status) = 0; + virtual tTimerConfig readTimerConfig(tRioStatusCode *status) = 0; + virtual unsigned int readTimerConfig_StallPeriod(tRioStatusCode *status) = 0; + virtual unsigned char readTimerConfig_AverageSize(tRioStatusCode *status) = 0; + virtual bool readTimerConfig_UpdateWhenEmpty(tRioStatusCode *status) = 0; + + + + + +private: + tCounter(const tCounter&); + void operator=(const tCounter&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Counter_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tDIO.h b/hal/Azalea/src/main/native/ChipObject/tDIO.h new file mode 100644 index 0000000000..909e72c96e --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tDIO.h @@ -0,0 +1,296 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_DIO_h__ +#define __nFRC_2012_1_6_4_DIO_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tDIO +{ +public: + tDIO(){} + virtual ~tDIO(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tDIO* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 2, + } tIfaceConstants; + + typedef + union{ + struct{ + unsigned Period : 16; + unsigned MinHigh : 16; + }; + struct{ + unsigned value : 32; + }; + } tPWMConfig; + typedef + union{ + struct{ + unsigned RelayFwd : 8; + unsigned RelayRev : 8; + unsigned I2CHeader : 4; + }; + struct{ + unsigned value : 20; + }; + } tSlowValue; + typedef + union{ + struct{ + unsigned Transaction : 1; + unsigned Done : 1; + unsigned Aborted : 1; + unsigned DataReceivedHigh : 24; + }; + struct{ + unsigned value : 27; + }; + } tI2CStatus; + typedef + union{ + struct{ + unsigned PeriodPower : 4; + unsigned OutputSelect_0 : 4; + unsigned OutputSelect_1 : 4; + unsigned OutputSelect_2 : 4; + unsigned OutputSelect_3 : 4; + }; + struct{ + unsigned value : 20; + }; + } tDO_PWMConfig; + typedef + union{ + struct{ + unsigned Address : 8; + unsigned BytesToRead : 3; + unsigned BytesToWrite : 3; + unsigned DataToSendHigh : 16; + unsigned BitwiseHandshake : 1; + }; + struct{ + unsigned value : 31; + }; + } tI2CConfig; + + + typedef enum + { + } tI2CDataToSend_IfaceConstants; + + virtual void writeI2CDataToSend(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readI2CDataToSend(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDO_IfaceConstants; + + virtual void writeDO(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readDO(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumFilterSelectElements = 16, + } tFilterSelect_IfaceConstants; + + virtual void writeFilterSelect(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readFilterSelect(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumFilterPeriodElements = 3, + } tFilterPeriod_IfaceConstants; + + virtual void writeFilterPeriod(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readFilterPeriod(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tOutputEnable_IfaceConstants; + + virtual void writeOutputEnable(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readOutputEnable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tSlowValue_IfaceConstants; + + virtual void writeSlowValue(tSlowValue value, tRioStatusCode *status) = 0; + virtual void writeSlowValue_RelayFwd(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSlowValue_RelayRev(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeSlowValue_I2CHeader(unsigned char value, tRioStatusCode *status) = 0; + virtual tSlowValue readSlowValue(tRioStatusCode *status) = 0; + virtual unsigned char readSlowValue_RelayFwd(tRioStatusCode *status) = 0; + virtual unsigned char readSlowValue_RelayRev(tRioStatusCode *status) = 0; + virtual unsigned char readSlowValue_I2CHeader(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CStatus_IfaceConstants; + + virtual tI2CStatus readI2CStatus(tRioStatusCode *status) = 0; + virtual unsigned char readI2CStatus_Transaction(tRioStatusCode *status) = 0; + virtual bool readI2CStatus_Done(tRioStatusCode *status) = 0; + virtual bool readI2CStatus_Aborted(tRioStatusCode *status) = 0; + virtual unsigned int readI2CStatus_DataReceivedHigh(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CDataReceived_IfaceConstants; + + virtual unsigned int readI2CDataReceived(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDI_IfaceConstants; + + virtual unsigned short readDI(tRioStatusCode *status) = 0; + + + typedef enum + { + } tPulse_IfaceConstants; + + virtual void writePulse(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readPulse(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumPWMPeriodScaleElements = 10, + } tPWMPeriodScale_IfaceConstants; + + virtual void writePWMPeriodScale(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPWMPeriodScale(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + kNumDO_PWMDutyCycleElements = 4, + } tDO_PWMDutyCycle_IfaceConstants; + + virtual void writeDO_PWMDutyCycle(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMDutyCycle(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + typedef enum + { + } tBFL_IfaceConstants; + + virtual void writeBFL(bool value, tRioStatusCode *status) = 0; + virtual bool readBFL(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CStart_IfaceConstants; + + virtual void strobeI2CStart(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDO_PWMConfig_IfaceConstants; + + virtual void writeDO_PWMConfig(tDO_PWMConfig value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_PeriodPower(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_0(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_1(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_2(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeDO_PWMConfig_OutputSelect_3(unsigned char value, tRioStatusCode *status) = 0; + virtual tDO_PWMConfig readDO_PWMConfig(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_PeriodPower(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_0(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_1(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_2(tRioStatusCode *status) = 0; + virtual unsigned char readDO_PWMConfig_OutputSelect_3(tRioStatusCode *status) = 0; + + + typedef enum + { + } tPulseLength_IfaceConstants; + + virtual void writePulseLength(unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPulseLength(tRioStatusCode *status) = 0; + + + typedef enum + { + } tI2CConfig_IfaceConstants; + + virtual void writeI2CConfig(tI2CConfig value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_Address(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_BytesToRead(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_BytesToWrite(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_DataToSendHigh(unsigned short value, tRioStatusCode *status) = 0; + virtual void writeI2CConfig_BitwiseHandshake(bool value, tRioStatusCode *status) = 0; + virtual tI2CConfig readI2CConfig(tRioStatusCode *status) = 0; + virtual unsigned char readI2CConfig_Address(tRioStatusCode *status) = 0; + virtual unsigned char readI2CConfig_BytesToRead(tRioStatusCode *status) = 0; + virtual unsigned char readI2CConfig_BytesToWrite(tRioStatusCode *status) = 0; + virtual unsigned short readI2CConfig_DataToSendHigh(tRioStatusCode *status) = 0; + virtual bool readI2CConfig_BitwiseHandshake(tRioStatusCode *status) = 0; + + + + typedef enum + { + } tLoopTiming_IfaceConstants; + + virtual unsigned short readLoopTiming(tRioStatusCode *status) = 0; + + + typedef enum + { + } tPWMConfig_IfaceConstants; + + virtual void writePWMConfig(tPWMConfig value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_Period(unsigned short value, tRioStatusCode *status) = 0; + virtual void writePWMConfig_MinHigh(unsigned short value, tRioStatusCode *status) = 0; + virtual tPWMConfig readPWMConfig(tRioStatusCode *status) = 0; + virtual unsigned short readPWMConfig_Period(tRioStatusCode *status) = 0; + virtual unsigned short readPWMConfig_MinHigh(tRioStatusCode *status) = 0; + + + + typedef enum + { + kNumPWMValueRegisters = 10, + } tPWMValue_IfaceConstants; + + virtual void writePWMValue(unsigned char reg_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readPWMValue(unsigned char reg_index, tRioStatusCode *status) = 0; + + + +private: + tDIO(const tDIO&); + void operator=(const tDIO&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_DIO_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tDMA.h b/hal/Azalea/src/main/native/ChipObject/tDMA.h new file mode 100644 index 0000000000..68fbb92740 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tDMA.h @@ -0,0 +1,157 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_DMA_h__ +#define __nFRC_2012_1_6_4_DMA_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tDMA +{ +public: + tDMA(){} + virtual ~tDMA(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tDMA* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ + unsigned Pause : 1; + unsigned Enable_AI0_Low : 1; + unsigned Enable_AI0_High : 1; + unsigned Enable_AIAveraged0_Low : 1; + unsigned Enable_AIAveraged0_High : 1; + unsigned Enable_AI1_Low : 1; + unsigned Enable_AI1_High : 1; + unsigned Enable_AIAveraged1_Low : 1; + unsigned Enable_AIAveraged1_High : 1; + unsigned Enable_Accumulator0 : 1; + unsigned Enable_Accumulator1 : 1; + unsigned Enable_DI : 1; + unsigned Enable_AnalogTriggers : 1; + unsigned Enable_Counters_Low : 1; + unsigned Enable_Counters_High : 1; + unsigned Enable_CounterTimers_Low : 1; + unsigned Enable_CounterTimers_High : 1; + unsigned Enable_Encoders : 1; + unsigned Enable_EncoderTimers : 1; + unsigned ExternalClock : 1; + }; + struct{ + unsigned value : 20; + }; + } tConfig; + typedef + union{ + struct{ + unsigned ExternalClockSource_Channel : 4; + unsigned ExternalClockSource_Module : 1; + unsigned ExternalClockSource_AnalogTrigger : 1; + unsigned RisingEdge : 1; + unsigned FallingEdge : 1; + }; + struct{ + unsigned value : 8; + }; + } tExternalTriggers; + + + + typedef enum + { + } tRate_IfaceConstants; + + virtual void writeRate(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readRate(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_Pause(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI0_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI0_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged0_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged0_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI1_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AI1_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged1_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AIAveraged1_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Accumulator0(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Accumulator1(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_DI(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_AnalogTriggers(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Counters_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Counters_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_CounterTimers_Low(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_CounterTimers_High(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_Encoders(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable_EncoderTimers(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_ExternalClock(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual bool readConfig_Pause(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI0_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI0_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged0_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged0_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI1_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AI1_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged1_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AIAveraged1_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Accumulator0(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Accumulator1(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_DI(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_AnalogTriggers(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Counters_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Counters_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_CounterTimers_Low(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_CounterTimers_High(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_Encoders(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable_EncoderTimers(tRioStatusCode *status) = 0; + virtual bool readConfig_ExternalClock(tRioStatusCode *status) = 0; + + + typedef enum + { + kNumExternalTriggersElements = 4, + } tExternalTriggers_IfaceConstants; + + virtual void writeExternalTriggers(unsigned char bitfield_index, tExternalTriggers value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_Channel(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_Module(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_ExternalClockSource_AnalogTrigger(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_RisingEdge(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual void writeExternalTriggers_FallingEdge(unsigned char bitfield_index, bool value, tRioStatusCode *status) = 0; + virtual tExternalTriggers readExternalTriggers(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual unsigned char readExternalTriggers_ExternalClockSource_Channel(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual unsigned char readExternalTriggers_ExternalClockSource_Module(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_ExternalClockSource_AnalogTrigger(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_RisingEdge(unsigned char bitfield_index, tRioStatusCode *status) = 0; + virtual bool readExternalTriggers_FallingEdge(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + +private: + tDMA(const tDMA&); + void operator=(const tDMA&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_DMA_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tDMAManager.h b/hal/Azalea/src/main/native/ChipObject/tDMAManager.h new file mode 100644 index 0000000000..edc774a25a --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tDMAManager.h @@ -0,0 +1,47 @@ +// Class for handling DMA transters. +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tDMAManager_h__ +#define __tDMAManager_h__ + +#include "NiRio.h" +#include "tSystem.h" + +namespace nFPGA +{ +// TODO: Implement DMA Manager +/* +class tDMAManager : public tSystem +{ +public: + tDMAManager(tNIRIO_u32 dmaChannel, tNIRIO_u32 hostBufferSize, tRioStatusCode *status); + ~tDMAManager(); + void start(tRioStatusCode *status); + void stop(tRioStatusCode *status); + bool isStarted() {return _started;} + void read( + tNIRIO_u32* buf, + tNIRIO_u32 num, + tNIRIO_u32 timeout, + tNIRIO_u32* read, + tNIRIO_u32* remaining, + tRioStatusCode *status); + void write( + tNIRIO_u32* buf, + tNIRIO_u32 num, + tNIRIO_u32 timeout, + tNIRIO_u32* remaining, + tRioStatusCode *status); +private: + bool _started; + tNIRIO_u32 _dmaChannel; + tNIRIO_u32 _hostBufferSize; + tDMAChannelDescriptor const *_dmaChannelDescriptor; + +}; +*/ +} + + +#endif // __tDMAManager_h__ + diff --git a/hal/Azalea/src/main/native/ChipObject/tEncoder.h b/hal/Azalea/src/main/native/ChipObject/tEncoder.h new file mode 100644 index 0000000000..53a770a56a --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tEncoder.h @@ -0,0 +1,167 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Encoder_h__ +#define __nFRC_2012_1_6_4_Encoder_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tEncoder +{ +public: + tEncoder(){} + virtual ~tEncoder(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tEncoder* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 4, + } tIfaceConstants; + + typedef + union{ + struct{ + unsigned Direction : 1; + signed Value : 31; + }; + struct{ + unsigned value : 32; + }; + } tOutput; + typedef + union{ + struct{ + unsigned ASource_Channel : 4; + unsigned ASource_Module : 1; + unsigned ASource_AnalogTrigger : 1; + unsigned BSource_Channel : 4; + unsigned BSource_Module : 1; + unsigned BSource_AnalogTrigger : 1; + unsigned IndexSource_Channel : 4; + unsigned IndexSource_Module : 1; + unsigned IndexSource_AnalogTrigger : 1; + unsigned IndexActiveHigh : 1; + unsigned Reverse : 1; + unsigned Enable : 1; + }; + struct{ + unsigned value : 21; + }; + } tConfig; + typedef + union{ + struct{ + unsigned Period : 23; + signed Count : 8; + unsigned Stalled : 1; + }; + struct{ + unsigned value : 32; + }; + } tTimerOutput; + typedef + union{ + struct{ + unsigned StallPeriod : 24; + unsigned AverageSize : 7; + unsigned UpdateWhenEmpty : 1; + }; + struct{ + unsigned value : 32; + }; + } tTimerConfig; + + + typedef enum + { + } tOutput_IfaceConstants; + + virtual tOutput readOutput(tRioStatusCode *status) = 0; + virtual bool readOutput_Direction(tRioStatusCode *status) = 0; + virtual signed int readOutput_Value(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ASource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_BSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexSource_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_IndexActiveHigh(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Reverse(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_Enable(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ASource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ASource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_ASource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_BSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_IndexSource_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexSource_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_IndexActiveHigh(tRioStatusCode *status) = 0; + virtual bool readConfig_Reverse(tRioStatusCode *status) = 0; + virtual bool readConfig_Enable(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerOutput_IfaceConstants; + + virtual tTimerOutput readTimerOutput(tRioStatusCode *status) = 0; + virtual unsigned int readTimerOutput_Period(tRioStatusCode *status) = 0; + virtual signed char readTimerOutput_Count(tRioStatusCode *status) = 0; + virtual bool readTimerOutput_Stalled(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimerConfig_IfaceConstants; + + virtual void writeTimerConfig(tTimerConfig value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_StallPeriod(unsigned int value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_AverageSize(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeTimerConfig_UpdateWhenEmpty(bool value, tRioStatusCode *status) = 0; + virtual tTimerConfig readTimerConfig(tRioStatusCode *status) = 0; + virtual unsigned int readTimerConfig_StallPeriod(tRioStatusCode *status) = 0; + virtual unsigned char readTimerConfig_AverageSize(tRioStatusCode *status) = 0; + virtual bool readTimerConfig_UpdateWhenEmpty(tRioStatusCode *status) = 0; + + + + + +private: + tEncoder(const tEncoder&); + void operator=(const tEncoder&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Encoder_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tGlobal.h b/hal/Azalea/src/main/native/ChipObject/tGlobal.h new file mode 100644 index 0000000000..19faf8db5b --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tGlobal.h @@ -0,0 +1,70 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Global_h__ +#define __nFRC_2012_1_6_4_Global_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tGlobal +{ +public: + tGlobal(){} + virtual ~tGlobal(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tGlobal* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tVersion_IfaceConstants; + + virtual unsigned short readVersion(tRioStatusCode *status) = 0; + + + typedef enum + { + } tFPGA_LED_IfaceConstants; + + virtual void writeFPGA_LED(bool value, tRioStatusCode *status) = 0; + virtual bool readFPGA_LED(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLocalTime_IfaceConstants; + + virtual unsigned int readLocalTime(tRioStatusCode *status) = 0; + + + typedef enum + { + } tRevision_IfaceConstants; + + virtual unsigned int readRevision(tRioStatusCode *status) = 0; + + + + +private: + tGlobal(const tGlobal&); + void operator=(const tGlobal&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Global_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tInterrupt.h b/hal/Azalea/src/main/native/ChipObject/tInterrupt.h new file mode 100644 index 0000000000..319591d186 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tInterrupt.h @@ -0,0 +1,84 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Interrupt_h__ +#define __nFRC_2012_1_6_4_Interrupt_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tInterrupt +{ +public: + tInterrupt(){} + virtual ~tInterrupt(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tInterrupt* create(unsigned char sys_index, tRioStatusCode *status); + virtual unsigned char getSystemIndex() = 0; + + + typedef enum + { + kNumSystems = 8, + } tIfaceConstants; + + typedef + union{ + struct{ + unsigned Source_Channel : 4; + unsigned Source_Module : 1; + unsigned Source_AnalogTrigger : 1; + unsigned RisingEdge : 1; + unsigned FallingEdge : 1; + unsigned WaitForAck : 1; + }; + struct{ + unsigned value : 9; + }; + } tConfig; + + + typedef enum + { + } tTimeStamp_IfaceConstants; + + virtual unsigned int readTimeStamp(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_Source_AnalogTrigger(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_RisingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_FallingEdge(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_WaitForAck(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Source_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_Source_Module(tRioStatusCode *status) = 0; + virtual bool readConfig_Source_AnalogTrigger(tRioStatusCode *status) = 0; + virtual bool readConfig_RisingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_FallingEdge(tRioStatusCode *status) = 0; + virtual bool readConfig_WaitForAck(tRioStatusCode *status) = 0; + + + + + +private: + tInterrupt(const tInterrupt&); + void operator=(const tInterrupt&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Interrupt_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tInterruptManager.h b/hal/Azalea/src/main/native/ChipObject/tInterruptManager.h new file mode 100644 index 0000000000..d7e96a257f --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tInterruptManager.h @@ -0,0 +1,50 @@ +// Class for handling interrupts. +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tInterruptManager_h__ +#define __tInterruptManager_h__ + +#include "NiRio.h" +#include "tSystem.h" +#include + +namespace nFPGA +{ + +typedef void (*tInterruptHandler)(uint32_t interruptAssertedMask, void *param); + +class tInterruptManager : public tSystem +{ +public: + tInterruptManager(uint32_t interruptMask, bool watcher, tRioStatusCode *status); + ~tInterruptManager(); + void registerHandler(tInterruptHandler handler, void *param, tRioStatusCode *status); + uint32_t watch(int32_t timeoutInMs, tRioStatusCode *status); + void enable(tRioStatusCode *status); + void disable(tRioStatusCode *status); + bool isEnabled(tRioStatusCode *status); +private: + void handler(); + static int handlerWrapper(tInterruptManager *pInterrupt); + + void acknowledge(tRioStatusCode *status); + void reserve(tRioStatusCode *status); + void unreserve(tRioStatusCode *status); + tInterruptHandler _handler; + uint32_t _interruptMask; + int32_t _taskId; + NiFpga_IrqContext _rioContext; + bool _watcher; + bool _enabled; + void *_userParam; + + // maintain the interrupts that are already dealt with. + static uint32_t _globalInterruptMask; + static SEM_ID _globalInterruptMaskSemaphore; +}; + +} + + +#endif // __tInterruptManager_h__ + diff --git a/hal/Azalea/src/main/native/ChipObject/tSPI.h b/hal/Azalea/src/main/native/ChipObject/tSPI.h new file mode 100644 index 0000000000..f113604121 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tSPI.h @@ -0,0 +1,200 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_SPI_h__ +#define __nFRC_2012_1_6_4_SPI_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tSPI +{ +public: + tSPI(){} + virtual ~tSPI(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tSPI* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ + unsigned ReceivedDataOverflow : 1; + unsigned Idle : 1; + }; + struct{ + unsigned value : 2; + }; + } tStatus; + typedef + union{ + struct{ + unsigned BusBitWidth : 8; + unsigned ClockHalfPeriodDelay : 8; + unsigned MSBfirst : 1; + unsigned DataOnFalling : 1; + unsigned LatchFirst : 1; + unsigned LatchLast : 1; + unsigned FramePolarity : 1; + unsigned WriteOnly : 1; + unsigned ClockPolarity : 1; + }; + struct{ + unsigned value : 23; + }; + } tConfig; + typedef + union{ + struct{ + unsigned SCLK_Channel : 4; + unsigned SCLK_Module : 1; + unsigned MOSI_Channel : 4; + unsigned MOSI_Module : 1; + unsigned MISO_Channel : 4; + unsigned MISO_Module : 1; + unsigned SS_Channel : 4; + unsigned SS_Module : 1; + }; + struct{ + unsigned value : 20; + }; + } tChannels; + + + + typedef enum + { + } tStatus_IfaceConstants; + + virtual tStatus readStatus(tRioStatusCode *status) = 0; + virtual bool readStatus_ReceivedDataOverflow(tRioStatusCode *status) = 0; + virtual bool readStatus_Idle(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReadReceivedData_IfaceConstants; + + virtual void strobeReadReceivedData(tRioStatusCode *status) = 0; + + + typedef enum + { + } tConfig_IfaceConstants; + + virtual void writeConfig(tConfig value, tRioStatusCode *status) = 0; + virtual void writeConfig_BusBitWidth(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_ClockHalfPeriodDelay(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeConfig_MSBfirst(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_DataOnFalling(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_LatchFirst(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_LatchLast(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_FramePolarity(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_WriteOnly(bool value, tRioStatusCode *status) = 0; + virtual void writeConfig_ClockPolarity(bool value, tRioStatusCode *status) = 0; + virtual tConfig readConfig(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_BusBitWidth(tRioStatusCode *status) = 0; + virtual unsigned char readConfig_ClockHalfPeriodDelay(tRioStatusCode *status) = 0; + virtual bool readConfig_MSBfirst(tRioStatusCode *status) = 0; + virtual bool readConfig_DataOnFalling(tRioStatusCode *status) = 0; + virtual bool readConfig_LatchFirst(tRioStatusCode *status) = 0; + virtual bool readConfig_LatchLast(tRioStatusCode *status) = 0; + virtual bool readConfig_FramePolarity(tRioStatusCode *status) = 0; + virtual bool readConfig_WriteOnly(tRioStatusCode *status) = 0; + virtual bool readConfig_ClockPolarity(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReceivedData_IfaceConstants; + + virtual unsigned int readReceivedData(tRioStatusCode *status) = 0; + + + typedef enum + { + } tDataToLoad_IfaceConstants; + + virtual void writeDataToLoad(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readDataToLoad(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReset_IfaceConstants; + + virtual void strobeReset(tRioStatusCode *status) = 0; + + + typedef enum + { + } tChannels_IfaceConstants; + + virtual void writeChannels(tChannels value, tRioStatusCode *status) = 0; + virtual void writeChannels_SCLK_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_SCLK_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MOSI_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MOSI_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MISO_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_MISO_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_SS_Channel(unsigned char value, tRioStatusCode *status) = 0; + virtual void writeChannels_SS_Module(unsigned char value, tRioStatusCode *status) = 0; + virtual tChannels readChannels(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SCLK_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SCLK_Module(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MOSI_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MOSI_Module(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MISO_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_MISO_Module(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SS_Channel(tRioStatusCode *status) = 0; + virtual unsigned char readChannels_SS_Module(tRioStatusCode *status) = 0; + + + typedef enum + { + } tClearReceivedData_IfaceConstants; + + virtual void strobeClearReceivedData(tRioStatusCode *status) = 0; + + + typedef enum + { + } tReceivedElements_IfaceConstants; + + virtual unsigned short readReceivedElements(tRioStatusCode *status) = 0; + + + typedef enum + { + } tLoad_IfaceConstants; + + virtual void strobeLoad(tRioStatusCode *status) = 0; + + + typedef enum + { + } tAvailableToLoad_IfaceConstants; + + virtual unsigned short readAvailableToLoad(tRioStatusCode *status) = 0; + + + + +private: + tSPI(const tSPI&); + void operator=(const tSPI&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_SPI_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tSolenoid.h b/hal/Azalea/src/main/native/ChipObject/tSolenoid.h new file mode 100644 index 0000000000..67c9a40103 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tSolenoid.h @@ -0,0 +1,50 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Solenoid_h__ +#define __nFRC_2012_1_6_4_Solenoid_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tSolenoid +{ +public: + tSolenoid(){} + virtual ~tSolenoid(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tSolenoid* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + kNumDO7_0Elements = 2, + } tDO7_0_IfaceConstants; + + virtual void writeDO7_0(unsigned char bitfield_index, unsigned char value, tRioStatusCode *status) = 0; + virtual unsigned char readDO7_0(unsigned char bitfield_index, tRioStatusCode *status) = 0; + + + + +private: + tSolenoid(const tSolenoid&); + void operator=(const tSolenoid&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Solenoid_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tSysWatchdog.h b/hal/Azalea/src/main/native/ChipObject/tSysWatchdog.h new file mode 100644 index 0000000000..daca9b6d0f --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tSysWatchdog.h @@ -0,0 +1,71 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_SysWatchdog_h__ +#define __nFRC_2012_1_6_4_SysWatchdog_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tSysWatchdog +{ +public: + tSysWatchdog(){} + virtual ~tSysWatchdog(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tSysWatchdog* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + + + + typedef enum + { + } tCommand_IfaceConstants; + + virtual void writeCommand(unsigned short value, tRioStatusCode *status) = 0; + virtual unsigned short readCommand(tRioStatusCode *status) = 0; + + + typedef enum + { + } tChallenge_IfaceConstants; + + virtual unsigned char readChallenge(tRioStatusCode *status) = 0; + + + typedef enum + { + } tActive_IfaceConstants; + + virtual void writeActive(bool value, tRioStatusCode *status) = 0; + virtual bool readActive(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimer_IfaceConstants; + + virtual unsigned int readTimer(tRioStatusCode *status) = 0; + + + + +private: + tSysWatchdog(const tSysWatchdog&); + void operator=(const tSysWatchdog&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_SysWatchdog_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tSystem.h b/hal/Azalea/src/main/native/ChipObject/tSystem.h new file mode 100644 index 0000000000..b5dccf03a4 --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tSystem.h @@ -0,0 +1,47 @@ +// Base class for generated chip objects +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tSystem_h__ +#define __tSystem_h__ + +#include "NiRio.h" +#include + +#define FRC_FPGA_PRELOAD_BITFILE + +typedef uint32_t NiFpga_Session; + +namespace nFPGA +{ + +class tSystem +{ +public: + tSystem(tRioStatusCode *status); + ~tSystem(); + void getFpgaGuid(uint32_t *guid_ptr, tRioStatusCode *status); + +protected: + static NiFpga_Session _DeviceHandle; + +#ifdef FRC_FPGA_PRELOAD_BITFILE + void NiFpga_SharedOpen_common(const char* bitfile); + NiFpga_Status NiFpga_SharedOpen(const char* bitfile, + const char* signature, + const char* resource, + uint32_t attribute, + NiFpga_Session* session); + NiFpga_Status NiFpgaLv_SharedOpen(const char* const bitfile, + const char* const apiSignature, + const char* const resource, + const uint32_t attribute, + NiFpga_Session* const session); +private: + static char *_FileName; + static char *_Bitfile; +#endif +}; + +} + +#endif // __tSystem_h__ diff --git a/hal/Azalea/src/main/native/ChipObject/tSystemInterface.h b/hal/Azalea/src/main/native/ChipObject/tSystemInterface.h new file mode 100644 index 0000000000..46786e8e7d --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tSystemInterface.h @@ -0,0 +1,26 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. + +#ifndef __tSystemInterface_h__ +#define __tSystemInterface_h__ + +namespace nFPGA +{ + +class tSystemInterface +{ +public: + tSystemInterface(){} + virtual ~tSystemInterface(){} + + virtual const uint16_t getExpectedFPGAVersion()=0; + virtual const uint32_t getExpectedFPGARevision()=0; + virtual const uint32_t * const getExpectedFPGASignature()=0; + virtual void getHardwareFpgaSignature(uint32_t *guid_ptr, tRioStatusCode *status)=0; + virtual uint32_t getLVHandle(tRioStatusCode *status)=0; + virtual uint32_t getHandle()=0; +}; + +} + +#endif // __tSystemInterface_h__ + diff --git a/hal/Azalea/src/main/native/ChipObject/tWatchdog.h b/hal/Azalea/src/main/native/ChipObject/tWatchdog.h new file mode 100644 index 0000000000..f5ef16a8dd --- /dev/null +++ b/hal/Azalea/src/main/native/ChipObject/tWatchdog.h @@ -0,0 +1,101 @@ +// Copyright (c) National Instruments 2008. All Rights Reserved. +// Do Not Edit... this file is generated! + +#ifndef __nFRC_2012_1_6_4_Watchdog_h__ +#define __nFRC_2012_1_6_4_Watchdog_h__ + +#include "tSystemInterface.h" + +namespace nFPGA +{ +namespace nFRC_2012_1_6_4 +{ + +class tWatchdog +{ +public: + tWatchdog(){} + virtual ~tWatchdog(){} + + virtual tSystemInterface* getSystemInterface() = 0; + static tWatchdog* create(tRioStatusCode *status); + + typedef enum + { + kNumSystems = 1, + } tIfaceConstants; + + typedef + union{ + struct{ + unsigned SystemActive : 1; + unsigned Alive : 1; + unsigned SysDisableCount : 15; + unsigned DisableCount : 15; + }; + struct{ + unsigned value : 32; + }; + } tStatus; + + + + typedef enum + { + } tStatus_IfaceConstants; + + virtual tStatus readStatus(tRioStatusCode *status) = 0; + virtual bool readStatus_SystemActive(tRioStatusCode *status) = 0; + virtual bool readStatus_Alive(tRioStatusCode *status) = 0; + virtual unsigned short readStatus_SysDisableCount(tRioStatusCode *status) = 0; + virtual unsigned short readStatus_DisableCount(tRioStatusCode *status) = 0; + + + typedef enum + { + } tImmortal_IfaceConstants; + + virtual void writeImmortal(bool value, tRioStatusCode *status) = 0; + virtual bool readImmortal(tRioStatusCode *status) = 0; + + + typedef enum + { + } tKill_IfaceConstants; + + virtual void strobeKill(tRioStatusCode *status) = 0; + + + typedef enum + { + } tFeed_IfaceConstants; + + virtual void strobeFeed(tRioStatusCode *status) = 0; + + + typedef enum + { + } tExpiration_IfaceConstants; + + virtual void writeExpiration(unsigned int value, tRioStatusCode *status) = 0; + virtual unsigned int readExpiration(tRioStatusCode *status) = 0; + + + typedef enum + { + } tTimer_IfaceConstants; + + virtual unsigned int readTimer(tRioStatusCode *status) = 0; + + + + +private: + tWatchdog(const tWatchdog&); + void operator=(const tWatchdog&); +}; + +} +} + +#endif // __nFRC_2012_1_6_4_Watchdog_h__ diff --git a/hal/Azalea/src/main/native/Digital.cpp b/hal/Azalea/src/main/native/Digital.cpp new file mode 100644 index 0000000000..9dec4e48f9 --- /dev/null +++ b/hal/Azalea/src/main/native/Digital.cpp @@ -0,0 +1,1492 @@ + +#include "HAL/Digital.h" + +#include "Port.h" +#include "HAL/HAL.h" +#include "ChipObject.h" +#include "HAL/cpp/Synchronized.h" +#include "HAL/cpp/Resource.h" +#include "NetworkCommunication/LoadOut.h" +#include +#include + +static const uint32_t kExpectedLoopTiming = 260; +static const uint32_t kDigitalPins = 14; +static const uint32_t kDigitalModules = 2; +static const uint32_t kPwmPins = 10; +static const uint32_t kRelayPins = 8; +/** + * kDefaultPwmPeriod is in ms + * + * - 20ms periods (50 Hz) are the "safest" setting in that this works for all devices + * - 20ms periods seem to be desirable for Vex Motors + * - 20ms periods are the specified period for HS-322HD servos, but work reliably down + * to 10.0 ms; starting at about 8.5ms, the servo sometimes hums and get hot; + * by 5.0ms the hum is nearly continuous + * - 10ms periods work well for Victor 884 + * - 5ms periods allows higher update rates for Luminary Micro Jaguar speed controllers. + * Due to the shipping firmware on the Jaguar, we can't run the update period less + * than 5.05 ms. + * + * kDefaultPwmPeriod is the 1x period (5.05 ms). In hardware, the period scaling is implemented as an + * output squelch to get longer periods for old devices. + */ +static const float kDefaultPwmPeriod = 5.05; +/** + * kDefaultPwmCenter is the PWM range center in ms + */ +static const float kDefaultPwmCenter = 1.5; +/** + * kDefaultPWMStepsDown is the number of PWM steps below the centerpoint + */ +static const int32_t kDefaultPwmStepsDown = 128; +static const int32_t kPwmDisabled = 0; + +struct digital_port_t { + Port port; + tDIO *module; + uint32_t PWMGeneratorID; +}; +typedef struct digital_port_t DigitalPort; + +static MUTEX_ID digitalDIOSemaphore = NULL; +static MUTEX_ID digitalRelaySemaphore = NULL; +static MUTEX_ID digitalPwmSemaphore = NULL; +static MUTEX_ID digitalI2CSemaphore = NULL; +static tDIO* digitalModules[2] = {NULL, NULL}; +static Resource *DIOChannels = NULL; +static Resource *DO_PWMGenerators[tDIO::kNumSystems] = {NULL}; + +bool digitalModulesInitialized = false; + +/** + * Initialize the digital modules. + */ +void initializeDigital(int32_t *status) { + if (digitalModulesInitialized) return; + + // Create a semaphore to protect changes to the digital output values + digitalDIOSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + // Create a semaphore to protect changes to the relay values + digitalRelaySemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + // Create a semaphore to protect changes to the DO PWM config + digitalPwmSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + digitalI2CSemaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + for (unsigned int i = 0; i < (sizeof(digitalModules)/sizeof(digitalModules[0])); i++) { + Resource::CreateResourceObject(&DIOChannels, tDIO::kNumSystems * kDigitalPins); + Resource::CreateResourceObject(&DO_PWMGenerators[i], tDIO::kNumDO_PWMDutyCycleElements); + digitalModules[i] = tDIO::create(i, status); + + // Make sure that the 9403 IONode has had a chance to initialize before continuing. + while(digitalModules[i]->readLoopTiming(status) == 0) delayTicks(1); + + if (digitalModules[i]->readLoopTiming(status) != kExpectedLoopTiming) { + // TODO: char err[128]; + // TODO: sprintf(err, "DIO LoopTiming: %d, expecting: %lu\n", digitalModules[port->module-1]->readLoopTiming(status), kExpectedLoopTiming); + *status = LOOP_TIMING_ERROR; // NOTE: Doesn't display the error + } + + //Calculate the length, in ms, of one DIO loop + double loopTime = digitalModules[i]->readLoopTiming(status)/(kSystemClockTicksPerMicrosecond*1e3); + + digitalModules[i]->writePWMConfig_Period((uint16_t) (kDefaultPwmPeriod/loopTime + .5), status); + digitalModules[i]->writePWMConfig_MinHigh((uint16_t) ((kDefaultPwmCenter-kDefaultPwmStepsDown*loopTime)/loopTime + .5), status); + + // Ensure that PWM output values are set to OFF + for (uint32_t pwm_index = 1; pwm_index <= kPwmPins; pwm_index++) { + // Initialize port structure + DigitalPort* digital_port = new DigitalPort(); + digital_port->port.pin = pwm_index; + digital_port->port.module = i + 1; + digital_port->module = digitalModules[i]; + + setPWM(digital_port, kPwmDisabled, status); + setPWMPeriodScale(digital_port, 3, status); // Set all to 4x by default. + } + + // Turn off all relay outputs. + digitalModules[i]->writeSlowValue_RelayFwd(0, status); + digitalModules[i]->writeSlowValue_RelayRev(0, status); + } + digitalModulesInitialized = true; +} + +/** + * Create a new instance of an digital module. + * Create an instance of the digital module object. Initialize all the parameters + * to reasonable values on start. + * Setting a global value on an digital module can be done only once unless subsequent + * values are set the previously set value. + * Digital modules are a singleton, so the constructor is never called outside of this class. + * + * @param moduleNumber The digital module to create (1 or 2). + */ +void* initializeDigitalPort(void* port_pointer, int32_t *status) { + initializeDigital(status); + Port* port = (Port*) port_pointer; + + // Initialize port structure + DigitalPort* digital_port = new DigitalPort(); + digital_port->port = *port; + digital_port->module = digitalModules[digital_port->port.module-1]; + + return digital_port; +} + +bool checkDigitalModule(uint8_t module) { + if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Digital, module - 1)) + return true; + return false; +} + +bool checkPWMChannel(void* digital_port_pointer) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + if (port->port.pin > 0 && port->port.pin <= kPwmPins) + return true; + return false; +} + +bool checkRelayChannel(void* digital_port_pointer) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + if (port->port.pin > 0 && port->port.pin <= kRelayPins) + return true; + return false; +} + +uint8_t remapDigitalChannel(uint32_t pin, int32_t *status) { + return 15 - pin; // TODO: Need channel validation +} + +uint8_t unmapDigitalChannel(uint32_t pin, int32_t *status) { + return 15 - pin; // TODO: Need channel validation +} + +/** + * Set a PWM channel to the desired value. The values range from 0 to 255 and the period is controlled + * by the PWM Period and MinHigh registers. + * + * @param channel The PWM channel to set. + * @param value The PWM value to set. + */ +void setPWM(void* digital_port_pointer, unsigned short value, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkPWMChannel(port); + port->module->writePWMValue(port->port.pin - 1, value, status); +} + +/** + * Get a value from a PWM channel. The values range from 0 to 255. + * + * @param channel The PWM channel to read from. + * @return The raw PWM value. + */ +unsigned short getPWM(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkPWMChannel(port); + return port->module->readPWMValue(port->port.pin - 1, status); +} + +/** + * Set how how often the PWM signal is squelched, thus scaling the period. + * + * @param channel The PWM channel to configure. + * @param squelchMask The 2-bit mask of outputs to squelch. + */ +void setPWMPeriodScale(void* digital_port_pointer, uint32_t squelchMask, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkPWMChannel(port); + port->module->writePWMPeriodScale(port->port.pin - 1, squelchMask, status); +} + +/** + * Allocate a DO PWM Generator. + * Allocate PWM generators so that they are not accidently reused. + * + * @return PWM Generator refnum + */ +void* allocatePWM(int32_t *status) { + return allocatePWMWithModule(0, status); +} + +/** + * Allocate a DO PWM Generator. + * Allocate PWM generators so that they are not accidently reused. + * + * @return PWM Generator refnum + */ +void* allocatePWMWithModule(uint8_t module, int32_t *status) { + char buf[64]; + snprintf(buf, 64, "DO_PWM (Module: %d)", module); + uint32_t* val = NULL; + *val = DO_PWMGenerators[(module - 1)]->Allocate(buf); + return val; +} + +/** + * Free the resource associated with a DO PWM generator. + * + * @param pwmGenerator The pwmGen to free that was allocated with AllocateDO_PWM() + */ +void freePWM(void* pwmGenerator, int32_t *status) { + freePWMWithModule(0, pwmGenerator, status); +} + +/** + * Free the resource associated with a DO PWM generator. + * + * @param pwmGenerator The pwmGen to free that was allocated with AllocateDO_PWM() + */ +void freePWMWithModule(uint8_t module, void* pwmGenerator, int32_t *status) { + uint32_t id = *((uint32_t*) pwmGenerator); + if (id == ~0ul) return; + DO_PWMGenerators[(module - 1)]->Free(id); +} + +/** + * Change the frequency of the DO PWM generator. + * + * The valid range is from 0.6 Hz to 19 kHz. The frequency resolution is logarithmic. + * + * @param rate The frequency to output all digital output PWM signals on this module. + */ +void setPWMRate(double rate, int32_t *status) { + setPWMRateWithModule(0, rate, status); +} + +/** + * Change the frequency of the DO PWM generator. + * + * The valid range is from 0.6 Hz to 19 kHz. The frequency resolution is logarithmic. + * + * @param rate The frequency to output all digital output PWM signals on this module. + */ +void setPWMRateWithModule(uint8_t module, double rate, int32_t *status) { + // Currently rounding in the log rate domain... heavy weight toward picking a higher freq. + // TODO: Round in the linear rate domain. + uint8_t pwmPeriodPower = (uint8_t)(log(1.0 / (digitalModules[module-1]->readLoopTiming(status) * 0.25E-6 * rate))/log(2.0) + 0.5); + digitalModules[module-1]->writeDO_PWMConfig_PeriodPower(pwmPeriodPower, status); +} + +/** + * Configure the duty-cycle of the PWM generator + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param dutyCycle The percent duty cycle to output [0..1]. + */ +void setPWMDutyCycle(void* pwmGenerator, double dutyCycle, int32_t *status) { + setPWMDutyCycleWithModule(0, pwmGenerator, dutyCycle, status); +} + +/** + * Configure the duty-cycle of the PWM generator + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param dutyCycle The percent duty cycle to output [0..1]. + */ +void setPWMDutyCycleWithModule(uint8_t module, void* pwmGenerator, double dutyCycle, int32_t *status) { + uint32_t id = *((uint32_t*) pwmGenerator); + if (id == ~0ul) return; + if (dutyCycle > 1.0) dutyCycle = 1.0; + if (dutyCycle < 0.0) dutyCycle = 0.0; + float rawDutyCycle = 256.0 * dutyCycle; + if (rawDutyCycle > 255.5) rawDutyCycle = 255.5; + { + Synchronized sync(digitalPwmSemaphore); + uint8_t pwmPeriodPower = digitalModules[module-1]->readDO_PWMConfig_PeriodPower(status); + if (pwmPeriodPower < 4) + { + // The resolution of the duty cycle drops close to the highest frequencies. + rawDutyCycle = rawDutyCycle / pow(2.0, 4 - pwmPeriodPower); + } + digitalModules[module-1]->writeDO_PWMDutyCycle(id, (uint8_t)rawDutyCycle, status); + } +} + +/** + * Configure which DO channel the PWM siganl is output on + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param channel The Digital Output channel to output on + */ +void setPWMOutputChannel(void* pwmGenerator, uint32_t pin, int32_t *status) { + setPWMOutputChannelWithModule(0, pwmGenerator, pin, status); +} + +/** + * Configure which DO channel the PWM siganl is output on + * + * @param pwmGenerator The generator index reserved by AllocateDO_PWM() + * @param channel The Digital Output channel to output on + */ +void setPWMOutputChannelWithModule(uint8_t module, void* pwmGenerator, uint32_t pin, int32_t *status) { + uint32_t id = *((uint32_t*) pwmGenerator); + if (id == ~0ul) return; + switch(id) { + case 0: + digitalModules[module-1]->writeDO_PWMConfig_OutputSelect_0(remapDigitalChannel(pin - 1, status), status); + break; + case 1: + digitalModules[module-1]->writeDO_PWMConfig_OutputSelect_1(remapDigitalChannel(pin - 1, status), status); + break; + case 2: + digitalModules[module-1]->writeDO_PWMConfig_OutputSelect_2(remapDigitalChannel(pin - 1, status), status); + break; + case 3: + digitalModules[module-1]->writeDO_PWMConfig_OutputSelect_3(remapDigitalChannel(pin - 1, status), status); + break; + } +} + +/** + * Set the state of a relay. + * Set the state of a relay output to be forward. Relays have two outputs and each is + * independently set to 0v or 12v. + */ +void setRelayForward(void* digital_port_pointer, bool on, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkRelayChannel(port); + { + Synchronized sync(digitalRelaySemaphore); + uint8_t forwardRelays = port->module->readSlowValue_RelayFwd(status); + if (on) + forwardRelays |= 1 << (port->port.pin - 1); + else + forwardRelays &= ~(1 << (port->port.pin - 1)); + port->module->writeSlowValue_RelayFwd(forwardRelays, status); + } +} + +/** + * Set the state of a relay. + * Set the state of a relay output to be reverse. Relays have two outputs and each is + * independently set to 0v or 12v. + */ +void setRelayReverse(void* digital_port_pointer, bool on, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + checkRelayChannel(port); + { + Synchronized sync(digitalRelaySemaphore); + uint8_t reverseRelays = port->module->readSlowValue_RelayRev(status); + if (on) + reverseRelays |= 1 << (port->port.pin - 1); + else + reverseRelays &= ~(1 << (port->port.pin - 1)); + port->module->writeSlowValue_RelayRev(reverseRelays, status); + } +} + +/** + * Get the current state of the forward relay channel + */ +bool getRelayForward(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint8_t forwardRelays = port->module->readSlowValue_RelayFwd(status); + return (forwardRelays & (1 << (port->port.pin - 1))) != 0; +} + +/** + * Get the current state of the reverse relay channel + */ +bool getRelayReverse(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint8_t reverseRelays = port->module->readSlowValue_RelayRev(status); + return (reverseRelays & (1 << (port->port.pin - 1))) != 0; +} + +/** + * Allocate Digital I/O channels. + * Allocate channels so that they are not accidently reused. Also the direction is set at the + * time of the allocation. + * + * @param channel The Digital I/O channel + * @param input If true open as input; if false open as output + * @return Was successfully allocated + */ +bool allocateDIO(void* digital_port_pointer, bool input, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + char buf[64]; + snprintf(buf, 64, "DIO %d (Module %d)", port->port.pin, port->port.module); + if (DIOChannels->Allocate(kDigitalPins * (port->port.module - 1) + port->port.pin - 1, buf) == ~0ul) return false; + { + Synchronized sync(digitalDIOSemaphore); + uint32_t bitToSet = 1 << (remapDigitalChannel(port->port.pin - 1, status)); + uint32_t outputEnable = port->module->readOutputEnable(status); + uint32_t outputEnableValue; + if (input) { + outputEnableValue = outputEnable & (~bitToSet); // clear the bit for read + } else { + outputEnableValue = outputEnable | bitToSet; // set the bit for write + } + port->module->writeOutputEnable(outputEnableValue, status); + } + return true; +} + +/** + * Free the resource associated with a digital I/O channel. + * + * @param channel The Digital I/O channel to free + */ +void freeDIO(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + DIOChannels->Free(kDigitalPins * (port->port.module - 1) + port->port.pin - 1); +} + +/** + * Write a digital I/O bit to the FPGA. + * Set a single value on a digital I/O channel. + * + * @param channel The Digital I/O channel + * @param value The state to set the digital channel (if it is configured as an output) + */ +void setDIO(void* digital_port_pointer, short value, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + if (value != 0 && value != 1) { + if (value != 0) + value = 1; + } + { + Synchronized sync(digitalDIOSemaphore); + uint16_t currentDIO = port->module->readDO(status); + if(value == 0) { + currentDIO = currentDIO & ~(1 << remapDigitalChannel(port->port.pin - 1, status)); + } else if (value == 1) { + currentDIO = currentDIO | (1 << remapDigitalChannel(port->port.pin - 1, status)); + } + port->module->writeDO(currentDIO, status); + } +} + +/** + * Read a digital I/O bit from the FPGA. + * Get a single value from a digital I/O channel. + * + * @param channel The digital I/O channel + * @return The state of the specified channel + */ +bool getDIO(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint32_t currentDIO = port->module->readDI(status); + + //Shift 00000001 over channel-1 places. + //AND it against the currentDIO + //if it == 0, then return false + //else return true + return ((currentDIO >> remapDigitalChannel(port->port.pin - 1, status)) & 1) != 0; +} + +/** + * Read the direction of a the Digital I/O lines + * A 1 bit means output and a 0 bit means input. + * + * @param channel The digital I/O channel + * @return The direction of the specified channel + */ +bool getDIODirection(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint32_t currentOutputEnable = port->module->readOutputEnable(status); + + //Shift 00000001 over port->port.pin-1 places. + //AND it against the currentOutputEnable + //if it == 0, then return false + //else return true + return ((currentOutputEnable >> remapDigitalChannel(port->port.pin - 1, status)) & 1) != 0; +} + +/** + * Generate a single pulse. + * Write a pulse to the specified digital output channel. There can only be a single pulse going at any time. + * + * @param channel The Digital Output channel that the pulse should be output on + * @param pulseLength The active length of the pulse (in seconds) + */ +void pulse(void* digital_port_pointer, double pulseLength, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint16_t mask = 1 << remapDigitalChannel(port->port.pin - 1, status); + port->module->writePulseLength((uint8_t)(1.0e9 * pulseLength / (port->module->readLoopTiming(status) * 25)), status); + port->module->writePulse(mask, status); +} + +/** + * Check a DIO line to see if it is currently generating a pulse. + * + * @return A pulse is in progress + */ +bool isPulsing(void* digital_port_pointer, int32_t *status) { + DigitalPort* port = (DigitalPort*) digital_port_pointer; + uint16_t mask = 1 << remapDigitalChannel(port->port.pin - 1, status); + uint16_t pulseRegister = port->module->readPulse(status); + return (pulseRegister & mask) != 0; +} + +/** + * Check if any DIO line is currently generating a pulse. + * + * @return A pulse on some line is in progress + */ +bool isAnyPulsing(int32_t *status) { + return isAnyPulsingWithModule(1, status) || isAnyPulsingWithModule(2, status); +} + +/** + * Check if any DIO line is currently generating a pulse. + * + * @return A pulse on some line is in progress + */ +bool isAnyPulsingWithModule(uint8_t module, int32_t *status) { + uint16_t pulseRegister = digitalModules[module-1]->readPulse(status); + return pulseRegister != 0; +} + + + +struct counter_t { + tCounter* counter; + uint32_t index; +}; +typedef struct counter_t Counter; + +static Resource *counters = NULL; + +void* initializeCounter(Mode mode, uint32_t *index, int32_t *status) { + Resource::CreateResourceObject(&counters, tCounter::kNumSystems); + *index = counters->Allocate("Counter"); + if (*index == ~0ul) { + *status = NO_AVAILABLE_RESOURCES; + return NULL; + } + Counter* counter = new Counter(); + counter->counter = tCounter::create(*index, status); + counter->counter->writeConfig_Mode(mode, status); + counter->counter->writeTimerConfig_AverageSize(1, status); + counter->index = *index; + return counter; +} + +void freeCounter(void* counter_pointer, int32_t *status) { + if (counter_pointer != NULL) { + Counter* counter = (Counter*) counter_pointer; + delete counter->counter; + counters->Free(counter->index); + } else { + *status = NULL_PARAMETER; + } +} + +void setCounterAverageSize(void* counter_pointer, int32_t size, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeTimerConfig_AverageSize(size, status); +} + +/** + * Set the source object that causes the counter to count up. + * Set the up counting DigitalSource. + */ +void setCounterUpSourceWithModule(void* counter_pointer, uint8_t module, uint32_t pin, + bool analogTrigger, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + + counter->counter->writeConfig_UpSource_Module(module, status); + counter->counter->writeConfig_UpSource_Channel(pin, status); + counter->counter->writeConfig_UpSource_AnalogTrigger(analogTrigger, status); + + if(counter->counter->readConfig_Mode(status) == kTwoPulse || + counter->counter->readConfig_Mode(status) == kExternalDirection) { + setCounterUpSourceEdge(counter_pointer, true, false, status); + } + counter->counter->strobeReset(status); +} + +/** + * Set the edge sensitivity on an up counting source. + * Set the up source to either detect rising edges or falling edges. + */ +void setCounterUpSourceEdge(void* counter_pointer, bool risingEdge, bool fallingEdge, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_UpRisingEdge(risingEdge, status); + counter->counter->writeConfig_UpFallingEdge(fallingEdge, status); +} + +/** + * Disable the up counting source to the counter. + */ +void clearCounterUpSource(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + bool state = counter->counter->readConfig_Enable(status); + counter->counter->writeConfig_Enable(false, status); + counter->counter->writeConfig_UpFallingEdge(false, status); + counter->counter->writeConfig_UpRisingEdge(false, status); + // Index 0 of digital is always 0. + counter->counter->writeConfig_UpSource_Channel(0, status); + counter->counter->writeConfig_UpSource_AnalogTrigger(false, status); + counter->counter->writeConfig_Enable(state, status); +} + +/** + * Set the source object that causes the counter to count down. + * Set the down counting DigitalSource. + */ +void setCounterDownSourceWithModule(void* counter_pointer, uint8_t module, uint32_t pin, + bool analogTrigger, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + unsigned char mode = counter->counter->readConfig_Mode(status); + if (mode != kTwoPulse && mode != kExternalDirection) { + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "Counter only supports DownSource in TwoPulse and ExternalDirection modes."); + *status = PARAMETER_OUT_OF_RANGE; + return; + } + counter->counter->writeConfig_DownSource_Module(module, status); + counter->counter->writeConfig_DownSource_Channel(pin, status); + counter->counter->writeConfig_DownSource_AnalogTrigger(analogTrigger, status); + + setCounterDownSourceEdge(counter_pointer, true, false, status); + counter->counter->strobeReset(status); +} + +/** + * Set the edge sensitivity on a down counting source. + * Set the down source to either detect rising edges or falling edges. + */ +void setCounterDownSourceEdge(void* counter_pointer, bool risingEdge, bool fallingEdge, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_DownRisingEdge(risingEdge, status); + counter->counter->writeConfig_DownFallingEdge(fallingEdge, status); +} + +/** + * Disable the down counting source to the counter. + */ +void clearCounterDownSource(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + bool state = counter->counter->readConfig_Enable(status); + counter->counter->writeConfig_Enable(false, status); + counter->counter->writeConfig_DownFallingEdge(false, status); + counter->counter->writeConfig_DownRisingEdge(false, status); + // Index 0 of digital is always 0. + counter->counter->writeConfig_DownSource_Channel(0, status); + counter->counter->writeConfig_DownSource_AnalogTrigger(false, status); + counter->counter->writeConfig_Enable(state, status); +} + +/** + * Set standard up / down counting mode on this counter. + * Up and down counts are sourced independently from two inputs. + */ +void setCounterUpDownMode(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kTwoPulse, status); +} + +/** + * Set external direction mode on this counter. + * Counts are sourced on the Up counter input. + * The Down counter input represents the direction to count. + */ +void setCounterExternalDirectionMode(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kExternalDirection, status); +} + +/** + * Set Semi-period mode on this counter. + * Counts up on both rising and falling edges. + */ +void setCounterSemiPeriodMode(void* counter_pointer, bool highSemiPeriod, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kSemiperiod, status); + counter->counter->writeConfig_UpRisingEdge(highSemiPeriod, status); + setCounterUpdateWhenEmpty(counter_pointer, false, status); +} + +/** + * Configure the counter to count in up or down based on the length of the input pulse. + * This mode is most useful for direction sensitive gear tooth sensors. + * @param threshold The pulse length beyond which the counter counts the opposite direction. Units are seconds. + */ +void setCounterPulseLengthMode(void* counter_pointer, double threshold, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Mode(kPulseLength, status); + counter->counter->writeConfig_PulseLengthThreshold((uint32_t)(threshold * 1.0e6) * kSystemClockTicksPerMicrosecond, status); +} + +/** + * Get the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @return SamplesToAverage The number of samples being averaged (from 1 to 127) + */ +int32_t getCounterSamplesToAverage(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + return counter->counter->readTimerConfig_AverageSize(status); +} + +/** + * Set the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @param samplesToAverage The number of samples to average from 1 to 127. + */ +void setCounterSamplesToAverage(void* counter_pointer, int samplesToAverage, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + if (samplesToAverage < 1 || samplesToAverage > 127) { + *status = PARAMETER_OUT_OF_RANGE; + } + counter->counter->writeTimerConfig_AverageSize(samplesToAverage, status); +} + +/** + * Start the Counter counting. + * This enables the counter and it starts accumulating counts from the associated + * input channel. The counter value is not reset on starting, and still has the previous value. + */ +void startCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Enable(1, status); +} + +/** + * Stop the Counter. + * Stops the counting but doesn't effect the current value. + */ +void stopCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeConfig_Enable(0, status); +} + +/** + * Reset the Counter to zero. + * Set the counter value to zero. This doesn't effect the running state of the counter, just sets + * the current value to zero. + */ +void resetCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->strobeReset(status); +} + +/** + * Read the current counter value. + * Read the value at this instant. It may still be running, so it reflects the current value. Next + * time it is read, it might have a different value. + */ +int32_t getCounter(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + int32_t value = counter->counter->readOutput_Value(status); + return value; +} + +/* + * Get the Period of the most recent count. + * Returns the time interval of the most recent count. This can be used for velocity calculations + * to determine shaft speed. + * @returns The period of the last two pulses in units of seconds. + */ +double getCounterPeriod(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + tCounter::tTimerOutput output = counter->counter->readTimerOutput(status); + double period; + if (output.Stalled) { + // Return infinity + double zero = 0.0; + period = 1.0 / zero; + } else { + // output.Period is a fixed point number that counts by 2 (24 bits, 25 integer bits) + period = (double)(output.Period << 1) / (double)output.Count; + } + return period * 1.0e-6; +} + +/** + * Set the maximum period where the device is still considered "moving". + * Sets the maximum period where the device is considered moving. This value is used to determine + * the "stopped" state of the counter using the GetStopped method. + * @param maxPeriod The maximum period where the counted device is considered moving in + * seconds. + */ +void setCounterMaxPeriod(void* counter_pointer, double maxPeriod, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 1.0e6), status); +} + +/** + * Select whether you want to continue updating the event timer output when there are no samples captured. + * The output of the event timer has a buffer of periods that are averaged and posted to + * a register on the FPGA. When the timer detects that the event source has stopped + * (based on the MaxPeriod) the buffer of samples to be averaged is emptied. If you + * enable the update when empty, you will be notified of the stopped source and the event + * time will report 0 samples. If you disable update when empty, the most recent average + * will remain on the output until a new sample is acquired. You will never see 0 samples + * output (except when there have been no events since an FPGA reset) and you will likely not + * see the stopped bit become true (since it is updated at the end of an average and there are + * no samples to average). + */ +void setCounterUpdateWhenEmpty(void* counter_pointer, bool enabled, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + counter->counter->writeTimerConfig_UpdateWhenEmpty(enabled, status); +} + +/** + * Determine if the clock is stopped. + * Determine if the clocked input is stopped based on the MaxPeriod value set using the + * SetMaxPeriod method. If the clock exceeds the MaxPeriod, then the device (and counter) are + * assumed to be stopped and it returns true. + * @return Returns true if the most recent counter period exceeds the MaxPeriod value set by + * SetMaxPeriod. + */ +bool getCounterStopped(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + return counter->counter->readTimerOutput_Stalled(status); +} + +/** + * The last direction the counter value changed. + * @return The last direction the counter value changed. + */ +bool getCounterDirection(void* counter_pointer, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + bool value = counter->counter->readOutput_Direction(status); + return value; +} + +/** + * Set the Counter to return reversed sensing on the direction. + * This allows counters to change the direction they are counting in the case of 1X and 2X + * quadrature encoding only. Any other counter mode isn't supported. + * @param reverseDirection true if the value counted should be negated. + */ +void setCounterReverseDirection(void* counter_pointer, bool reverseDirection, int32_t *status) { + Counter* counter = (Counter*) counter_pointer; + if (counter->counter->readConfig_Mode(status) == kExternalDirection) { + if (reverseDirection) + setCounterDownSourceEdge(counter_pointer, true, true, status); + else + setCounterDownSourceEdge(counter_pointer, false, true, status); + } +} + +struct encoder_t { + tEncoder* encoder; + uint32_t index; +}; +typedef struct encoder_t Encoder; + +static const double DECODING_SCALING_FACTOR = 0.25; +static Resource *quadEncoders = NULL; + +void* initializeEncoder(uint8_t port_a_module, uint32_t port_a_pin, bool port_a_analog_trigger, + uint8_t port_b_module, uint32_t port_b_pin, bool port_b_analog_trigger, + bool reverseDirection, int32_t *index, int32_t *status) { + + // Initialize encoder structure + Encoder* encoder = new Encoder(); + + Resource::CreateResourceObject(&quadEncoders, tEncoder::kNumSystems); + encoder->index = quadEncoders->Allocate("4X Encoder"); + *index = encoder->index; + // TODO: if (index == ~0ul) { CloneError(quadEncoders); return; } + encoder->encoder = tEncoder::create(encoder->index, status); + encoder->encoder->writeConfig_ASource_Module(port_a_module, status); + encoder->encoder->writeConfig_ASource_Channel(port_a_pin, status); + encoder->encoder->writeConfig_ASource_AnalogTrigger(port_a_analog_trigger, status); + encoder->encoder->writeConfig_BSource_Module(port_b_module, status); + encoder->encoder->writeConfig_BSource_Channel(port_b_pin, status); + encoder->encoder->writeConfig_BSource_AnalogTrigger(port_b_analog_trigger, status); + encoder->encoder->strobeReset(status); + encoder->encoder->writeConfig_Reverse(reverseDirection, status); + encoder->encoder->writeTimerConfig_AverageSize(4, status); + + return encoder; +} + +void freeEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + quadEncoders->Free(encoder->index); + delete encoder->encoder; +} + +/** + * Start the Encoder. + * Starts counting pulses on the Encoder device. + */ +void startEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeConfig_Enable(1, status); +} + +/** + * Stops counting pulses on the Encoder device. The value is not changed. + */ +void stopEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeConfig_Enable(0, status); +} + +/** + * Reset the Encoder distance to zero. + * Resets the current count to zero on the encoder. + */ +void resetEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->strobeReset(status); +} + +/** + * Gets the raw value from the encoder. + * The raw value is the actual count unscaled by the 1x, 2x, or 4x scale + * factor. + * @return Current raw count from the encoder + */ +int32_t getEncoder(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readOutput_Value(status); +} + +/** + * Returns the period of the most recent pulse. + * Returns the period of the most recent Encoder pulse in seconds. + * This method compenstates for the decoding type. + * + * @deprecated Use GetRate() in favor of this method. This returns unscaled periods and GetRate() scales using value from SetDistancePerPulse(). + * + * @return Period in seconds of the most recent pulse. + */ +double getEncoderPeriod(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + tEncoder::tTimerOutput output = encoder->encoder->readTimerOutput(status); + double value; + if (output.Stalled) { + // Return infinity + double zero = 0.0; + value = 1.0 / zero; + } else { + // output.Period is a fixed point number that counts by 2 (24 bits, 25 integer bits) + value = (double)(output.Period << 1) / (double)output.Count; + } + double measuredPeriod = value * 1.0e-6; + return measuredPeriod / DECODING_SCALING_FACTOR; +} + +/** + * Sets the maximum period for stopped detection. + * Sets the value that represents the maximum period of the Encoder before it will assume + * that the attached device is stopped. This timeout allows users to determine if the wheels or + * other shaft has stopped rotating. + * This method compensates for the decoding type. + * + * @deprecated Use SetMinRate() in favor of this method. This takes unscaled periods and SetMinRate() scales using value from SetDistancePerPulse(). + * + * @param maxPeriod The maximum time between rising and falling edges before the FPGA will + * report the device stopped. This is expressed in seconds. + */ +void setEncoderMaxPeriod(void* encoder_pointer, double maxPeriod, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeTimerConfig_StallPeriod((uint32_t)(maxPeriod * 1.0e6 * DECODING_SCALING_FACTOR), status); +} + +/** + * Determine if the encoder is stopped. + * Using the MaxPeriod value, a boolean is returned that is true if the encoder is considered + * stopped and false if it is still moving. A stopped encoder is one where the most recent pulse + * width exceeds the MaxPeriod. + * @return True if the encoder is considered stopped. + */ +bool getEncoderStopped(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readTimerOutput_Stalled(status) != 0; +} + +/** + * The last direction the encoder value changed. + * @return The last direction the encoder value changed. + */ +bool getEncoderDirection(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readOutput_Direction(status); +} + +/** + * Set the direction sensing for this encoder. + * This sets the direction sensing on the encoder so that it could count in the correct + * software direction regardless of the mounting. + * @param reverseDirection true if the encoder direction should be reversed + */ +void setEncoderReverseDirection(void* encoder_pointer, bool reverseDirection, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + encoder->encoder->writeConfig_Reverse(reverseDirection, status); +} + +/** + * Set the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @param samplesToAverage The number of samples to average from 1 to 127. + */ +void setEncoderSamplesToAverage(void* encoder_pointer, uint32_t samplesToAverage, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + if (samplesToAverage < 1 || samplesToAverage > 127) { + *status = PARAMETER_OUT_OF_RANGE; + } + encoder->encoder->writeTimerConfig_AverageSize(samplesToAverage, status); +} + +/** + * Get the Samples to Average which specifies the number of samples of the timer to + * average when calculating the period. Perform averaging to account for + * mechanical imperfections or as oversampling to increase resolution. + * @return SamplesToAverage The number of samples being averaged (from 1 to 127) + */ +uint32_t getEncoderSamplesToAverage(void* encoder_pointer, int32_t *status) { + Encoder* encoder = (Encoder*) encoder_pointer; + return encoder->encoder->readTimerConfig_AverageSize(status); +} + +/** + * Get the loop timing of the Digital Module + * + * @return The loop time + */ +uint16_t getLoopTiming(int32_t *status) { + return getLoopTimingWithModule(0, status); +} + +/** + * Get the loop timing of the Digital Module + * + * @return The loop time + */ +uint16_t getLoopTimingWithModule(uint8_t module, int32_t *status) { + return digitalModules[module-1]->readLoopTiming(status); +} + + +struct spi_t { + tSPI* spi; + tSPI::tConfig config; + tSPI::tChannels channels; + MUTEX_ID semaphore; +}; +typedef struct spi_t SPI; + +void* initializeSPI(uint8_t sclk_routing_module, uint32_t sclk_routing_pin, + uint8_t mosi_routing_module, uint32_t mosi_routing_pin, + uint8_t miso_routing_module, uint32_t miso_routing_pin, int32_t *status) { + SPI* spi = new SPI(); + + spi->semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE | SEMAPHORE_INVERSION_SAFE); + + spi->spi = tSPI::create(status); + + spi->config.BusBitWidth = 8; + spi->config.ClockHalfPeriodDelay = 0; + spi->config.MSBfirst = 0; + spi->config.DataOnFalling = 0; + spi->config.LatchFirst = 0; + spi->config.LatchLast = 0; + spi->config.FramePolarity = 0; + spi->config.WriteOnly = miso_routing_pin ? 0 : 1; + spi->config.ClockPolarity = 0; + + spi->channels.SCLK_Channel = sclk_routing_pin; + spi->channels.SCLK_Module = sclk_routing_module; + spi->channels.SS_Channel = 0; + spi->channels.SS_Module = 0; + + if (mosi_routing_pin) { + spi->channels.MOSI_Channel = mosi_routing_pin; + spi->channels.MOSI_Module = mosi_routing_module; + } else { + spi->channels.MOSI_Channel = 0; + spi->channels.MOSI_Module = 0; + } + + if (miso_routing_pin) { + spi->channels.MISO_Channel = miso_routing_pin; + spi->channels.MISO_Module = miso_routing_module; + } else { + spi->channels.MISO_Channel = 0; + spi->channels.MISO_Module = 0; + } + return spi; +} + +void cleanSPI(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + delete spi->spi; + delete spi; +} + +/** + * Configure the number of bits from each word that the slave transmits + * or receives. + * + * @param bits The number of bits in one frame (1 to 32 bits). + */ +void setSPIBitsPerWord(void* spi_pointer, uint32_t bits, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.BusBitWidth = bits; +} + +/** + * Get the number of bits from each word that the slave transmits + * or receives. + * + * @return The number of bits in one frame (1 to 32 bits). + */ +uint32_t getSPIBitsPerWord(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + return spi->config.BusBitWidth; +} + +/** + * Configure the rate of the generated clock signal. + * The default and maximum value is 76,628.4 Hz. + * + * @param hz The clock rate in Hertz. + */ +void setSPIClockRate(void* spi_pointer, double hz, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + int delay = 0; + int loopTiming = getLoopTimingWithModule(spi->spi->readChannels_SCLK_Module(status), status); + double v = (1.0 / hz) / (2 * loopTiming / (kSystemClockTicksPerMicrosecond * 1e6)); + if (v < 1) { + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "SPI Clock too high"); + } + delay = (int) (v + .5); + if (delay > 255) { + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "SPI Clock too low"); + } + + spi->config.ClockHalfPeriodDelay = delay; +} + +/** + * Configure the order that bits are sent and received on the wire + * to be most significant bit first. + */ +void setSPIMSBFirst(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.MSBfirst = 1; +} + +/** + * Configure the order that bits are sent and received on the wire + * to be least significant bit first. + */ +void setSPILSBFirst(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.MSBfirst = 0; +} + +/** + * Configure that the data is stable on the falling edge and the data + * changes on the rising edge. + */ +void setSPISampleDataOnFalling(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.DataOnFalling = 1; +} + +/** + * Configure that the data is stable on the rising edge and the data + * changes on the falling edge. + */ +void setSPISampleDataOnRising(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.DataOnFalling = 0; +} + +void setSPISlaveSelect(void* spi_pointer, uint8_t ss_routing_module, uint32_t ss_routing_pin, + int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->channels.SS_Channel = ss_routing_pin; + spi->channels.SS_Module = ss_routing_module; +} + +void setSPILatchMode(void* spi_pointer, tFrameMode mode, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + switch (mode) { + case kChipSelect: + spi->config.LatchFirst = 0; + spi->config.LatchLast = 0; + break; + case kPreLatchPulse: + spi->config.LatchFirst = 1; + spi->config.LatchLast = 0; + break; + case kPostLatchPulse: + spi->config.LatchFirst = 0; + spi->config.LatchLast = 1; + break; + case kPreAndPostLatchPulse: + spi->config.LatchFirst = 1; + spi->config.LatchLast = 1; + break; + } +} + +tFrameMode getSPILatchMode(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + return (tFrameMode) (spi->config.LatchFirst | (spi->config.LatchLast << 1)); +} + +void setSPIFramePolarity(void* spi_pointer, bool activeLow, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.FramePolarity = activeLow ? 1 : 0; +} + +bool getSPIFramePolarity(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + return spi->config.FramePolarity != 0; +} + +/** + * Configure the clock output line to be active low. + * This is sometimes called clock polarity high. + */ +void setSPIClockActiveLow(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.ClockPolarity = 1; +} + +/** + * Configure the clock output line to be active high. + * This is sometimes called clock polarity low. + */ +void setSPIClockActiveHigh(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->config.ClockPolarity = 0; +} + + +/** + * Apply configuration settings and reset the SPI logic. + */ +void applySPIConfig(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + Synchronized sync(spi->semaphore); + + spi->spi->writeConfig(spi->config, status); + spi->spi->writeChannels(spi->channels, status); + spi->spi->strobeReset(status); +} + +/** + * Get the number of words that can currently be stored before being + * transmitted to the device. + * + * @return The number of words available to be written. + */ +uint16_t getSPIOutputFIFOAvailable(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + uint16_t result = spi->spi->readAvailableToLoad(status); + return result; +} + +/** + * Get the number of words received and currently available to be read from + * the receive FIFO. + * + * @return The number of words available to read. + */ +uint16_t getSPINumReceived(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + uint16_t result = spi->spi->readReceivedElements(status); + return result; +} + +/** + * Have all pending transfers completed? + * + * @return True if no transfers are pending. + */ +bool isSPIDone(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + bool result = spi->spi->readStatus_Idle(status); + return result; +} + + +/** + * Determine if the receive FIFO was full when attempting to add new data at + * end of a transfer. + * + * @return True if the receive FIFO overflowed. + */ +bool hadSPIReceiveOverflow(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + bool result = spi->spi->readStatus_ReceivedDataOverflow(status); + return result; +} + +/** + * Write a word to the slave device. Blocks until there is space in the + * output FIFO. + * + * If not running in output only mode, also saves the data received + * on the MISO input during the transfer into the receive FIFO. + */ +void writeSPI(void* spi_pointer, uint32_t data, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + if (spi->channels.MOSI_Channel == 0 && spi->channels.MOSI_Module == 0) { + *status = SPI_WRITE_NO_MOSI; + return; + } + + Synchronized sync(spi->semaphore); + + while (getSPIOutputFIFOAvailable(spi_pointer, status) == 0) + delayTicks(HAL_NO_WAIT); + + spi->spi->writeDataToLoad(data, status); + spi->spi->strobeLoad(status); +} + +/** + * Read a word from the receive FIFO. + * + * Waits for the current transfer to complete if the receive FIFO is empty. + * + * If the receive FIFO is empty, there is no active transfer, and initiate + * is false, errors. + * + * @param initiate If true, this function pushes "0" into the + * transmit buffer and initiates a transfer. + * If false, this function assumes that data is + * already in the receive FIFO from a previous write. + */ +uint32_t readSPI(void* spi_pointer, bool initiate, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + if (spi->channels.MISO_Channel == 0 && spi->channels.MISO_Module == 0) { + *status = SPI_READ_NO_MISO; + return 0; + } + + uint32_t data; + { + Synchronized sync(spi->semaphore); + + if (initiate) { + spi->spi->writeDataToLoad(0, status); + spi->spi->strobeLoad(status); + } + + // Do we have anything ready to read? + if (getSPINumReceived(spi_pointer, status) == 0) { + if (!initiate && isSPIDone(spi_pointer, status) + && getSPIOutputFIFOAvailable(spi_pointer, status) == kTransmitFIFODepth) { + // Nothing to read: error out + *status = SPI_READ_NO_DATA; + return 0; + } + + // Wait for the transaction to complete + while (getSPINumReceived(spi_pointer, status) == 0) + delayTicks(HAL_NO_WAIT); + } + + spi->spi->strobeReadReceivedData(status); + data = spi->spi->readReceivedData(status); + } + + return data; +} + +/** + * Stop any transfer in progress and empty the transmit FIFO. + */ +void resetSPI(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->spi->strobeReset(status); +} + +/** + * Empty the receive FIFO. + */ +void clearSPIReceivedData(void* spi_pointer, int32_t *status) { + SPI* spi = (SPI*) spi_pointer; + spi->spi->strobeClearReceivedData(status); +} + +/** + * Generic transaction. + * + * This is a lower-level interface to the I2C hardware giving you more control over each transaction. + * + * @param dataToSend Buffer of data to send as part of the transaction. + * @param sendSize Number of bytes to send as part of the transaction. [0..6] + * @param dataReceived Buffer to read data into. + * @param receiveSize Number of byted to read from the device. [0..7] + * @return Transfer Aborted... false for success, true for aborted. + */ +bool doI2CTransaction(uint8_t address, bool compatibilityMode, uint8_t *dataToSend, + uint8_t sendSize, uint8_t *dataReceived, uint8_t receiveSize, + int32_t *status) { + return doI2CTransactionWithModule(1, address, compatibilityMode, dataToSend, sendSize, + dataReceived, receiveSize, status); +} + +/** + * Generic transaction. + * + * This is a lower-level interface to the I2C hardware giving you more control over each transaction. + * + * @param dataToSend Buffer of data to send as part of the transaction. + * @param sendSize Number of bytes to send as part of the transaction. [0..6] + * @param dataReceived Buffer to read data into. + * @param receiveSize Number of byted to read from the device. [0..7] + * @return Transfer Aborted... false for success, true for aborted. + */ +bool doI2CTransactionWithModule(uint8_t module, uint8_t address, bool compatibilityMode, + uint8_t *dataToSend, uint8_t sendSize, uint8_t *dataReceived, + uint8_t receiveSize, int32_t *status) { + initializeDigital(status); + if (sendSize > 6) { + *status = PARAMETER_OUT_OF_RANGE; + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "sendSize"); + return true; + } + if (receiveSize > 7) { + *status = PARAMETER_OUT_OF_RANGE; + // TODO: wpi_setWPIErrorWithContext(ParameterOutOfRange, "receiveSize"); + return true; + } + + uint32_t data=0; + uint32_t dataHigh=0; + uint32_t i; + for(i=0; iwriteI2CConfig_Address(address, status); + digitalModules[module]->writeI2CConfig_BytesToWrite(sendSize, status); + digitalModules[module]->writeI2CConfig_BytesToRead(receiveSize, status); + if (sendSize > 0) digitalModules[module]->writeI2CDataToSend(data, status); + if (sendSize > sizeof(data)) digitalModules[module]->writeI2CConfig_DataToSendHigh(dataHigh, status); + digitalModules[module]->writeI2CConfig_BitwiseHandshake(compatibilityMode, status); + uint8_t transaction = digitalModules[module]->readI2CStatus_Transaction(status); + digitalModules[module]->strobeI2CStart(status); + while(transaction == digitalModules[module]->readI2CStatus_Transaction(status)) delayTicks(1); + while(!digitalModules[module]->readI2CStatus_Done(status)) delayTicks(1); + aborted = digitalModules[module]->readI2CStatus_Aborted(status); + if (receiveSize > 0) data = digitalModules[module]->readI2CDataReceived(status); + if (receiveSize > sizeof(data)) dataHigh = digitalModules[module]->readI2CStatus_DataReceivedHigh(status); + } + + for(i=0; i> (8*i)) & 0xFF; + } + for(; i> (8*(i-sizeof(data)))) & 0xFF; + } + return aborted; +} diff --git a/hal/Azalea/src/main/native/HAL.cpp b/hal/Azalea/src/main/native/HAL.cpp new file mode 100644 index 0000000000..2d4b3489c8 --- /dev/null +++ b/hal/Azalea/src/main/native/HAL.cpp @@ -0,0 +1,106 @@ + +#include "HAL/HAL.h" + +#include "Port.h" +#include "HAL/Errors.h" +#include "ChipObject.h" + +const uint32_t solenoid_kNumDO7_0Elements = tSolenoid::kNumDO7_0Elements; +const uint32_t dio_kNumSystems = tDIO::kNumSystems; +const uint32_t interrupt_kNumSystems = tInterrupt::kNumSystems; +const uint32_t kSystemClockTicksPerMicrosecond = 40; + + +void* getPort(uint8_t pin) { + Port* port = new Port(); + port->pin = pin; + port->module = 0; + return port; +} + +/** + * @deprecated Uses module numbers + */ +void* getPortWithModule(uint8_t module, uint8_t pin) { + Port* port = new Port(); + port->pin = pin; + port->module = module; + return port; +} + +const char* getHALErrorMessage(int32_t code) { + if (code == 0) return ""; + else if (code == SAMPLE_RATE_TOO_HIGH) return SAMPLE_RATE_TOO_HIGH_MESSAGE; + else if (code == VOLTAGE_OUT_OF_RANGE) return VOLTAGE_OUT_OF_RANGE_MESSAGE; + else if (code == LOOP_TIMING_ERROR) return LOOP_TIMING_ERROR_MESSAGE; + else if (code == SPI_WRITE_NO_MOSI) return SPI_WRITE_NO_MOSI_MESSAGE; + else if (code == SPI_READ_NO_MISO) return SPI_READ_NO_MISO_MESSAGE; + else if (code == SPI_READ_NO_DATA) return SPI_READ_NO_DATA_MESSAGE; + else if (code == INCOMPATIBLE_STATE) return INCOMPATIBLE_STATE_MESSAGE; + else if (code == NO_AVAILABLE_RESOURCES) return NO_AVAILABLE_RESOURCES_MESSAGE; + else if (code == NULL_PARAMETER) return NULL_PARAMETER_MESSAGE; + else if (code == ANALOG_TRIGGER_LIMIT_ORDER_ERROR) return ANALOG_TRIGGER_LIMIT_ORDER_ERROR_MESSAGE; + else if (code == ANALOG_TRIGGER_PULSE_OUTPUT_ERROR) return ANALOG_TRIGGER_PULSE_OUTPUT_ERROR_MESSAGE; + else if (code == PARAMETER_OUT_OF_RANGE) return PARAMETER_OUT_OF_RANGE_MESSAGE; + else return ""; +} + +/** + * Return the FPGA Version number. + * For now, expect this to be competition year. + * @return FPGA Version number. + */ +uint16_t getFPGAVersion(int32_t *status) { + tGlobal *global = tGlobal::create(status); + uint16_t version = global->readVersion(status); + delete global; + return version; +} + +/** + * Return the FPGA Revision number. + * The format of the revision is 3 numbers. + * The 12 most significant bits are the Major Revision. + * the next 8 bits are the Minor Revision. + * The 12 least significant bits are the Build Number. + * @return FPGA Revision number. + */ +uint32_t getFPGARevision(int32_t *status) { + tGlobal *global = tGlobal::create(status); + uint32_t revision = global->readRevision(status); + delete global; + return revision; +} + +/** + * Read the microsecond-resolution timer on the FPGA. + * + * @return The current time in microseconds according to the FPGA (since FPGA reset). + */ +uint32_t getFPGATime(int32_t *status) { + tGlobal *global = tGlobal::create(status); + uint32_t time = global->readLocalTime(status); + delete global; + return time; +} + + +/** + * Set the state of the FPGA status LED on the cRIO. + */ +void setFPGALED(uint32_t state, int32_t *status) { + tGlobal *global = tGlobal::create(status); + global->writeFPGA_LED(state, status); + delete global; +} + +/** + * Get the current state of the FPGA status LED on the cRIO. + * @return The curent state of the FPGA LED. + */ +int32_t getFPGALED(int32_t *status) { + tGlobal *global = tGlobal::create(status); + bool ledValue = global->readFPGA_LED(status); + delete global; + return ledValue; +} diff --git a/hal/Azalea/src/main/native/Interrupts.cpp b/hal/Azalea/src/main/native/Interrupts.cpp new file mode 100644 index 0000000000..c47f5769f4 --- /dev/null +++ b/hal/Azalea/src/main/native/Interrupts.cpp @@ -0,0 +1,86 @@ + +#include "HAL/Interrupts.h" + +#include "ChipObject.h" + +struct interrupt_t { + tInterrupt *anInterrupt; + tInterruptManager *manager; +}; +typedef struct interrupt_t Interrupt; + +void* initializeInterrupts(uint32_t interruptIndex, bool watcher, int32_t *status) { + Interrupt* anInterrupt = new Interrupt(); + // Expects the calling leaf class to allocate an interrupt index. + anInterrupt->anInterrupt = tInterrupt::create(interruptIndex, status); + anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status); + anInterrupt->manager = new tInterruptManager(1 << interruptIndex, watcher, status); + return anInterrupt; +} + +void cleanInterrupts(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + delete anInterrupt->anInterrupt; + delete anInterrupt->manager; + anInterrupt->anInterrupt = NULL; + anInterrupt->manager = NULL; +} + +/** + * In synchronous mode, wait for the defined interrupt to occur. + * @param timeout Timeout in seconds + */ +void waitForInterrupt(void* interrupt_pointer, double timeout, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->watch((int32_t)(timeout * 1e3), status); +} + +/** + * Enable interrupts to occur on this input. + * oInterrupts are disabled when the RequestInterrupt call is made. This gives time to do the + * setup of the other options before starting to field interrupts. + */ +void enableInterrupts(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->enable(status); +} + +/** + * Disable Interrupts without without deallocating structures. + */ +void disableInterrupts(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->disable(status); +} + +/** + * Return the timestamp for the interrupt that occurred most recently. + * This is in the same time domain as GetClock(). + * @return Timestamp in seconds since boot. + */ +double readInterruptTimestamp(void* interrupt_pointer, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + uint32_t timestamp = anInterrupt->anInterrupt->readTimeStamp(status); + return timestamp * 1e-6; +} + +void requestInterrupts(void* interrupt_pointer, uint8_t routing_module, uint32_t routing_pin, + bool routing_analog_trigger, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->anInterrupt->writeConfig_WaitForAck(false, status); + anInterrupt->anInterrupt->writeConfig_Source_AnalogTrigger(routing_analog_trigger, status); + anInterrupt->anInterrupt->writeConfig_Source_Channel(routing_pin, status); + anInterrupt->anInterrupt->writeConfig_Source_Module(routing_module, status); +} + +void attachInterruptHandler(void* interrupt_pointer, InterruptHandlerFunction handler, + void* param, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->manager->registerHandler(handler, param, status); +} + +void setInterruptUpSourceEdge(void* interrupt_pointer, bool risingEdge, bool fallingEdge, int32_t *status) { + Interrupt* anInterrupt = (Interrupt*) interrupt_pointer; + anInterrupt->anInterrupt->writeConfig_RisingEdge(risingEdge, status); + anInterrupt->anInterrupt->writeConfig_FallingEdge(fallingEdge, status); +} diff --git a/hal/Azalea/src/main/native/NetworkCommunication/AICalibration.h b/hal/Azalea/src/main/native/NetworkCommunication/AICalibration.h new file mode 100644 index 0000000000..1e86343204 --- /dev/null +++ b/hal/Azalea/src/main/native/NetworkCommunication/AICalibration.h @@ -0,0 +1,19 @@ + +#ifndef __AICalibration_h__ +#define __AICalibration_h__ + +#include + +#ifdef __cplusplus +extern "C" +{ +#endif + + uint32_t FRC_NetworkCommunication_nAICalibration_getLSBWeight(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status); + int32_t FRC_NetworkCommunication_nAICalibration_getOffset(const uint32_t aiSystemIndex, const uint32_t channel, int32_t *status); + +#ifdef __cplusplus +} +#endif + +#endif // __AICalibration_h__ diff --git a/hal/Azalea/src/main/native/NetworkCommunication/LoadOut.h b/hal/Azalea/src/main/native/NetworkCommunication/LoadOut.h new file mode 100644 index 0000000000..f28249e3f1 --- /dev/null +++ b/hal/Azalea/src/main/native/NetworkCommunication/LoadOut.h @@ -0,0 +1,39 @@ + +#ifndef __LoadOut_h__ +#define __LoadOut_h__ + +#define kMaxModuleNumber 2 +namespace nLoadOut +{ + typedef enum { + kModuleType_Unknown = 0x00, + kModuleType_Analog = 0x01, + kModuleType_Digital = 0x02, + kModuleType_Solenoid = 0x03, + } tModuleType; + bool getModulePresence(tModuleType moduleType, uint8_t moduleNumber); + typedef enum { + kTargetClass_Unknown = 0x00, + kTargetClass_FRC1 = 0x10, + kTargetClass_FRC2 = 0x20, + kTargetClass_FRC2_Analog = kTargetClass_FRC2 | kModuleType_Analog, + kTargetClass_FRC2_Digital = kTargetClass_FRC2 | kModuleType_Digital, + kTargetClass_FRC2_Solenoid = kTargetClass_FRC2 | kModuleType_Solenoid, + kTargetClass_FamilyMask = 0xF0, + kTargetClass_ModuleMask = 0x0F, + } tTargetClass; + tTargetClass getTargetClass(); +} + +#ifdef __cplusplus +extern "C" { +#endif + + uint32_t FRC_NetworkCommunication_nLoadOut_getModulePresence(uint32_t moduleType, uint8_t moduleNumber); + uint32_t FRC_NetworkCommunication_nLoadOut_getTargetClass(); + +#ifdef __cplusplus +} +#endif + +#endif // __LoadOut_h__ diff --git a/hal/Azalea/src/main/native/Notifier.cpp b/hal/Azalea/src/main/native/Notifier.cpp new file mode 100644 index 0000000000..8d9766b6c3 --- /dev/null +++ b/hal/Azalea/src/main/native/Notifier.cpp @@ -0,0 +1,40 @@ + +#include "HAL/Notifier.h" + +#include "ChipObject.h" + +static const uint32_t kTimerInterruptNumber = 28; + +struct notifier_t { + tAlarm *alarm; + tInterruptManager *manager; +}; +typedef struct notifier_t Notifier; + +void* initializeNotifier(void (*ProcessQueue)(uint32_t, void*), int32_t *status) { + Notifier* notifier = new Notifier(); + notifier->manager = new tInterruptManager(1 << kTimerInterruptNumber, false, status); + notifier->manager->registerHandler(ProcessQueue, NULL, status); + notifier->manager->enable(status); + notifier->alarm = tAlarm::create(status); + return notifier; +} + +void cleanNotifier(void* notifier_pointer, int32_t *status) { + Notifier* notifier = (Notifier*) notifier_pointer; + notifier->alarm->writeEnable(false, status); + delete notifier->alarm; + notifier->alarm = NULL; + notifier->manager->disable(status); + delete notifier->manager; + notifier->manager = NULL; +} + + +void updateNotifierAlarm(void* notifier_pointer, uint32_t triggerTime, int32_t *status) { + Notifier* notifier = (Notifier*) notifier_pointer; + // write the first item in the queue into the trigger time + notifier->alarm->writeTriggerTime(triggerTime, status); + // Enable the alarm. The hardware disables itself after each alarm. + notifier->alarm->writeEnable(true, status); +} diff --git a/hal/Azalea/src/main/native/Port.h b/hal/Azalea/src/main/native/Port.h new file mode 100644 index 0000000000..4d68312bb7 --- /dev/null +++ b/hal/Azalea/src/main/native/Port.h @@ -0,0 +1,11 @@ + +#ifndef HAL_PORT_H +#define HAL_PORT_H + +struct port_t { + uint32_t pin; + uint8_t module; +}; +typedef struct port_t Port; + +#endif diff --git a/hal/Azalea/src/main/native/Semaphore.cpp b/hal/Azalea/src/main/native/Semaphore.cpp new file mode 100644 index 0000000000..bdbe6b88b5 --- /dev/null +++ b/hal/Azalea/src/main/native/Semaphore.cpp @@ -0,0 +1,79 @@ + +#include "HAL/Semaphore.h" + +#include "ChipObject.h" + +const uint32_t SEMAPHORE_Q_FIFO = SEM_Q_FIFO; +const uint32_t SEMAPHORE_Q_PRIORITY = SEM_Q_PRIORITY; +const uint32_t SEMAPHORE_DELETE_SAFE = SEM_DELETE_SAFE; +const uint32_t SEMAPHORE_INVERSION_SAFE = SEM_INVERSION_SAFE; + +const int32_t SEMAPHORE_NO_WAIT = NO_WAIT; +const int32_t SEMAPHORE_WAIT_FOREVER = WAIT_FOREVER; + +const uint32_t SEMAPHORE_EMPTY = SEM_EMPTY; +const uint32_t SEMAPHORE_FULL = SEM_FULL; + +MUTEX_ID initializeMutex(uint32_t flags) { + return semMCreate(flags); +} + +void deleteMutex(MUTEX_ID sem) { + semDelete(sem); +} + +/** + * Lock the semaphore, blocking until it's available. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t takeMutex(MUTEX_ID sem, int32_t timeout) { + return semTake(sem, timeout); +} +/** + * Unlock the semaphore. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t giveMutex(MUTEX_ID sem) { + return semGive(sem); +} + + +SEMAPHORE_ID initializeSemaphore(uint32_t flags, uint32_t initial_state) { + return semBCreate(flags, (SEM_B_STATE) initial_state); +} + +void deleteSemaphore(SEMAPHORE_ID sem) { + semDelete(sem); +} + +/** + * Lock the semaphore, blocking until it's available. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t takeSemaphore(SEMAPHORE_ID sem, int32_t timeout) { + return semTake(sem, timeout); +} +/** + * Unlock the semaphore. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ +int8_t giveSemaphore(SEMAPHORE_ID sem) { + return semGive(sem); +} + + +MULTIWAIT_ID initializeMultiWait() { + return initializeSemaphore(SEMAPHORE_Q_PRIORITY, SEMAPHORE_FULL); +} + +void deleteMultiWait(MULTIWAIT_ID sem) { + deleteSemaphore(sem); +} + +int8_t takeMultiWait(MULTIWAIT_ID sem, int32_t timeout) { + return takeSemaphore(sem, timeout); +} + +int8_t giveMultiWait(MULTIWAIT_ID sem) { + return semFlush(sem); +} diff --git a/hal/Azalea/src/main/native/Solenoid.cpp b/hal/Azalea/src/main/native/Solenoid.cpp new file mode 100644 index 0000000000..6dc822ed73 --- /dev/null +++ b/hal/Azalea/src/main/native/Solenoid.cpp @@ -0,0 +1,73 @@ + +#include "HAL/Solenoid.h" + +#include "Port.h" +#include "HAL/Errors.h" +#include "ChipObject.h" +#include "HAL/cpp/Synchronized.h" +#include "NetworkCommunication/LoadOut.h" + +struct solenoid_port_t { + Port port; + tSolenoid *module; + uint32_t PWMGeneratorID; +}; +typedef struct solenoid_port_t SolenoidPort; + +static ReentrantSemaphore solenoidSemaphore; +static tSolenoid* solenoidModules[2] = {NULL, NULL}; + +bool solenoidModulesInitialized = false; + +/** + * Initialize the digital modules. + */ +void initializeSolenoid(int32_t *status) { + if (solenoidModulesInitialized) return; + + for (unsigned int i = 0; i < (sizeof(solenoidModules)/sizeof(solenoidModules[0])); i++) { + Synchronized sync(solenoidSemaphore); + solenoidModules[i] = tSolenoid::create(status); + } + solenoidModulesInitialized = true; +} + +void* initializeSolenoidPort(void* port_pointer, int32_t *status) { + initializeSolenoid(status); + Port* port = (Port*) port_pointer; + + // Initialize port structure + SolenoidPort* solenoid_port = new SolenoidPort(); + solenoid_port->port = *port; + solenoid_port->module = solenoidModules[solenoid_port->port.module-1]; + + return solenoid_port; +} + +bool checkSolenoidModule(uint8_t module) { + if (nLoadOut::getModulePresence(nLoadOut::kModuleType_Solenoid, module - 1)) + return true; + return false; +} + +bool getSolenoid(void* solenoid_port_pointer, int32_t *status) { + SolenoidPort* port = (SolenoidPort*) solenoid_port_pointer; + if (checkSolenoidModule(port->port.module)) { + uint8_t mask = 1 << (port->port.pin - 1); + return (mask & port->module->readDO7_0(port->port.module - 1, status)); + } + return false; +} + +void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status) { + SolenoidPort* port = (SolenoidPort*) solenoid_port_pointer; + if (checkSolenoidModule(port->port.module)) { + Synchronized sync(solenoidSemaphore); + uint8_t currentValue = port->module->readDO7_0(port->port.module - 1, status); + uint8_t mask = 1 << (port->port.pin - 1); + if (value) currentValue = currentValue | mask; // Flip the bit on + else currentValue = currentValue & ~mask; // Flip the bit off + port->module->writeDO7_0(port->port.module - 1, currentValue, status); + } +} + diff --git a/hal/Azalea/src/main/native/Task.cpp b/hal/Azalea/src/main/native/Task.cpp new file mode 100644 index 0000000000..65f7246515 --- /dev/null +++ b/hal/Azalea/src/main/native/Task.cpp @@ -0,0 +1,64 @@ + +#include "HAL/Task.h" + +#include "HAL/HAL.h" +#include "ChipObject.h" +#include +#include + +const uint32_t VXWORKS_FP_TASK = VX_FP_TASK; +const int32_t HAL_objLib_OBJ_ID_ERROR = S_objLib_OBJ_ID_ERROR; +const int32_t HAL_objLib_OBJ_DELETED = S_objLib_OBJ_DELETED; +const int32_t HAL_taskLib_ILLEGAL_OPTIONS = S_taskLib_ILLEGAL_OPTIONS; +const int32_t HAL_memLib_NOT_ENOUGH_MEMORY = S_memLib_NOT_ENOUGH_MEMORY; +const int32_t HAL_taskLib_ILLEGAL_PRIORITY = S_taskLib_ILLEGAL_PRIORITY; + +TASK spawnTask(char * name, int priority, int options, int stackSize, + FUNCPTR entryPt, uint32_t arg0, uint32_t arg1, uint32_t arg2, + uint32_t arg3, uint32_t arg4, uint32_t arg5, uint32_t arg6, + uint32_t arg7, uint32_t arg8, uint32_t arg9) { + return taskSpawn(name, + priority, + options, // options + stackSize, // stack size + entryPt, // function to start + arg0, arg1, arg2, arg3, arg4, // parameter 1 - pointer to this class + arg5, arg6, arg7, arg8, arg9);// additional unused parameters + +} + +STATUS restartTask(TASK task) { + return taskRestart(task); +} + +STATUS deleteTask(TASK task) { + return taskDelete(task); +} + +STATUS isTaskReady(TASK task) { + return taskIsReady(task); +} + +STATUS isTaskSuspended(TASK task) { + return taskIsSuspended(task); +} + +STATUS suspendTask(TASK task) { + return taskSuspend(task); +} + +STATUS resumeTask(TASK task) { + return taskResume(task); +} + +STATUS verifyTaskID(TASK task) { + return taskIdVerify(task); +} + +STATUS setTaskPriority(TASK task, int priority) { + return taskPrioritySet(task, priority); +} + +STATUS getTaskPriority(TASK task, int* priority) { + return taskPriorityGet(task, priority); +} diff --git a/hal/Azalea/src/main/native/Utilities.cpp b/hal/Azalea/src/main/native/Utilities.cpp new file mode 100644 index 0000000000..5597aad72b --- /dev/null +++ b/hal/Azalea/src/main/native/Utilities.cpp @@ -0,0 +1,23 @@ + +#include "HAL/Utilities.h" + +#include "HAL/HAL.h" +#include "ChipObject.h" + +#include // for taskDelay +#include // for sysClkRateGet + +const int32_t HAL_NO_WAIT = NO_WAIT; +const int32_t HAL_WAIT_FOREVER = WAIT_FOREVER; + +void delayTicks(int32_t ticks) { + taskDelay(ticks); +} + +void delayMillis(double ms) { + taskDelay((int32_t)((double)sysClkRateGet() * ms / 1000)); +} + +void delaySeconds(double s) { + taskDelay((int32_t)((double)sysClkRateGet() * s)); +} diff --git a/hal/Azalea/src/main/native/Watchdog.cpp b/hal/Azalea/src/main/native/Watchdog.cpp new file mode 100644 index 0000000000..59e2041ab3 --- /dev/null +++ b/hal/Azalea/src/main/native/Watchdog.cpp @@ -0,0 +1,140 @@ + +#include "HAL/Watchdog.h" + +#include "HAL/HAL.h" +#include "ChipObject.h" + +typedef tWatchdog Watchdog; +const double kDefaultWatchdogExpiration = 0.5; + +void* initializeWatchdog(int32_t *status) { + Watchdog* watchdog = tWatchdog::create(status); + setWatchdogExpiration(watchdog, kDefaultWatchdogExpiration, status); + setWatchdogEnabled(watchdog, true, status); + return watchdog; +} + +void cleanWatchdog(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + setWatchdogEnabled(watchdog, false, status); + delete watchdog; +} + +/** + * Throw the dog a bone. + * + * When everything is going well, you feed your dog when you get home. + * Let's hope you don't drive your car off a bridge on the way home... + * Your dog won't get fed and he will starve to death. + * + * By the way, it's not cool to ask the neighbor (some random task) to + * feed your dog for you. He's your responsibility! + * + * @returns Returns the previous state of the watchdog before feeding it. + */ +bool feedWatchdog(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool previous = getWatchdogEnabled(watchdog_pointer, status); + watchdog->strobeFeed(status); + return previous; +} + +/** + * Put the watchdog out of its misery. + * + * Don't wait for your dying robot to starve when there is a problem. + * Kill it quickly, cleanly, and humanely. + */ +void killWatchdog(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + watchdog->strobeKill(status); +} + +/** + * Read how long it has been since the watchdog was last fed. + * + * @return The number of seconds since last meal. + */ +double getWatchdogLastFed(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + uint32_t timer = watchdog->readTimer(status); + return timer / (kSystemClockTicksPerMicrosecond * 1e6); +} + +/** + * Read what the current expiration is. + * + * @return The number of seconds before starvation following a meal (watchdog starves if it doesn't eat this often). + */ +double getWatchdogExpiration(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + uint32_t expiration = watchdog->readExpiration(status); + return expiration / (kSystemClockTicksPerMicrosecond * 1e6); +} + +/** + * Configure how many seconds your watchdog can be neglected before it starves to death. + * + * @param expiration The number of seconds before starvation following a meal (watchdog starves if it doesn't eat this often). + */ +void setWatchdogExpiration(void* watchdog_pointer, double expiration, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + watchdog->writeExpiration((uint32_t)(expiration * (kSystemClockTicksPerMicrosecond * 1e6)), status); +} + +/** + * Find out if the watchdog is currently enabled or disabled (mortal or immortal). + * + * @return Enabled or disabled. + */ +bool getWatchdogEnabled(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool enabled = !watchdog->readImmortal(status); + return enabled; +} + +/** + * Enable or disable the watchdog timer. + * + * When enabled, you must keep feeding the watchdog timer to + * keep the watchdog active, and hence the dangerous parts + * (motor outputs, etc.) can keep functioning. + * When disabled, the watchdog is immortal and will remain active + * even without being fed. It will also ignore any kill commands + * while disabled. + * + * @param enabled Enable or disable the watchdog. + */ +void setWatchdogEnabled(void* watchdog_pointer, bool enabled, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + watchdog->writeImmortal(!enabled, status); +} + +/** + * Check in on the watchdog and make sure he's still kicking. + * + * This indicates that your watchdog is allowing the system to operate. + * It is still possible that the network communications is not allowing the + * system to run, but you can check this to make sure it's not your fault. + * Check IsSystemActive() for overall system status. + * + * If the watchdog is disabled, then your watchdog is immortal. + * + * @return Is the watchdog still alive? + */ +bool isWatchdogAlive(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool alive = watchdog->readStatus_Alive(status); + return alive; +} + +/** + * Check on the overall status of the system. + * + * @return Is the system active (i.e. PWM motor outputs, etc. enabled)? + */ +bool isWatchdogSystemActive(void* watchdog_pointer, int32_t *status) { + Watchdog* watchdog = (Watchdog*) watchdog_pointer; + bool alive = watchdog->readStatus_SystemActive(status); + return alive; +} diff --git a/hal/Azalea/src/main/native/cpp/Resource.cpp b/hal/Azalea/src/main/native/cpp/Resource.cpp new file mode 100644 index 0000000000..4ef0f324b1 --- /dev/null +++ b/hal/Azalea/src/main/native/cpp/Resource.cpp @@ -0,0 +1,119 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#include "HAL/cpp/Resource.h" +#include "HAL/Errors.h" + +ReentrantSemaphore Resource::m_createLock; + +/** + * Allocate storage for a new instance of Resource. + * Allocate a bool array of values that will get initialized to indicate that no resources + * have been allocated yet. The indicies of the resources are [0 .. elements - 1]. + */ +Resource::Resource(uint32_t elements) +{ + Synchronized sync(m_createLock); + m_size = elements; + m_isAllocated = new bool[m_size]; + for (uint32_t i=0; i < m_size; i++) + { + m_isAllocated[i] = false; + } +} + +/** + * Factory method to create a Resource allocation-tracker *if* needed. + * + * @param r -- address of the caller's Resource pointer. If *r == NULL, this + * will construct a Resource and make *r point to it. If *r != NULL, i.e. + * the caller already has a Resource instance, this won't do anything. + * @param elements -- the number of elements for this Resource allocator to + * track, that is, it will allocate resource numbers in the range + * [0 .. elements - 1]. + */ +/*static*/ void Resource::CreateResourceObject(Resource **r, uint32_t elements) +{ + Synchronized sync(m_createLock); + if (*r == NULL) + { + *r = new Resource(elements); + } +} + +/** + * Delete the allocated array or resources. + * This happens when the module is unloaded (provided it was statically allocated). + */ +Resource::~Resource() +{ + delete[] m_isAllocated; +} + +/** + * Allocate a resource. + * When a resource is requested, mark it allocated. In this case, a free resource value + * within the range is located and returned after it is marked allocated. + */ +uint32_t Resource::Allocate(const char *resourceDesc) +{ + Synchronized sync(m_allocateLock); + for (uint32_t i=0; i < m_size; i++) + { + if (!m_isAllocated[i]) + { + m_isAllocated[i] = true; + return i; + } + } + // TODO: wpi_setWPIErrorWithContext(NoAvailableResources, resourceDesc); + return ~0ul; +} + +/** + * Allocate a specific resource value. + * The user requests a specific resource value, i.e. channel number and it is verified + * unallocated, then returned. + */ +uint32_t Resource::Allocate(uint32_t index, const char *resourceDesc) +{ + Synchronized sync(m_allocateLock); + if (index >= m_size) + { + // TODO: wpi_setWPIErrorWithContext(ChannelIndexOutOfRange, resourceDesc); + return ~0ul; + } + if ( m_isAllocated[index] ) + { + // TODO: wpi_setWPIErrorWithContext(ResourceAlreadyAllocated, resourceDesc); + return ~0ul; + } + m_isAllocated[index] = true; + return index; +} + + +/** + * Free an allocated resource. + * After a resource is no longer needed, for example a destructor is called for a channel assignment + * class, Free will release the resource value so it can be reused somewhere else in the program. + */ +void Resource::Free(uint32_t index) +{ + Synchronized sync(m_allocateLock); + if (index == ~0ul) return; + if (index >= m_size) + { + // TODO: wpi_setWPIError(NotAllocated); + return; + } + if (!m_isAllocated[index]) + { + // TODO: wpi_setWPIError(NotAllocated); + return; + } + m_isAllocated[index] = false; +} diff --git a/hal/Azalea/src/main/native/cpp/StackTrace.cpp b/hal/Azalea/src/main/native/cpp/StackTrace.cpp new file mode 100644 index 0000000000..6613bb7b4f --- /dev/null +++ b/hal/Azalea/src/main/native/cpp/StackTrace.cpp @@ -0,0 +1,165 @@ + +#include "HAL/cpp/StackTrace.h" + +#include "HAL/HAL.h" +#include "../ChipObject.h" +#include +#include +#include +#include +#include + +#define DBG_DEMANGLE_PRINT_LEN 256 /* Num chars of demangled names to print */ + +extern "C" +{ + extern char * cplusDemangle (char *source, char *dest, int32_t n); +} + +char *wpi_getLabel(uint16_t addr, int32_t *found) +{ + int pVal; + SYM_TYPE pType; + char name[MAX_SYS_SYM_LEN + 1]; + static char label[DBG_DEMANGLE_PRINT_LEN + 1 + 11]; + bzero(label, DBG_DEMANGLE_PRINT_LEN + 1 + 11); + + if (symFindByValue(sysSymTbl, addr, name, &pVal, &pType) == OK) + { + cplusDemangle(name, label, sizeof(label) - 11); + if ((uint16_t)pVal != addr) + { + sprintf(&label[strlen(label)], "+0x%04x", addr-pVal); + if (found) *found = 2; + } + else + { + if (found) *found = 1; + } + } + else + { + sprintf(label, "0x%04x", addr); + if (found) *found = 0; + } + + return label; +} +/* +static void wpiTracePrint(INSTR *caller, int32_t func, int32_t nargs, int32_t *args, int32_t taskId, BOOL isKernelAdrs) +{ + char buf [MAX_SYS_SYM_LEN * 2]; + int32_t ix; + int32_t len = 0; + len += sprintf (&buf [len], "%s <%#010x>: ", wpi_getLabel((uint32_t)caller), (int32_t)caller); + len += sprintf (&buf [len], "%s <%#010x> (", wpi_getLabel((uint32_t)func), func); + for (ix = 0; ix < nargs; ix++) + { + if (ix != 0) + len += sprintf (&buf [len], ", "); + len += sprintf (&buf [len], "%#x", args [ix]); + } + len += sprintf (&buf [len], ")\n"); + + printf(buf); +} +*/ +static void wpiCleanTracePrint(INSTR *caller, int32_t func, int32_t nargs, int32_t *args, int32_t taskId, BOOL isKernelAdrs) +{ + char buf [MAX_SYS_SYM_LEN]; + int32_t ix; + int32_t len = 0; + int32_t nameFound = 0; + int32_t params = 0; + int32_t totalnargs = nargs; + char *funcName = wpi_getLabel((uint32_t)func, &nameFound); + // Ignore names that are not exact symbol address matches. + if (nameFound != 1) return; + + // Ignore internal function name matches. + if (strncmp(funcName, "wpi_assert", 10) == 0) return; + if (strncmp(funcName, "wpi_fatal", 9) == 0) return; + if (strncmp(funcName, "wpi_selfTrace", 13) == 0) return; + if (strncmp(funcName, "Error::Set", 10) == 0) return; + if (strncmp(funcName, "ErrorBase::SetError", 19) == 0) return; + if (strncmp(funcName, "Error::Report", 13) == 0) return; + + // Find the number of arguments in the name string. + char *start = strchr(funcName, '('); + char *end = strrchr(funcName, ')'); + if (start + 1 != end && start != NULL) + { + do + { + params++; + if(strncmp(start+1, "bool", 4) == 0 || strncmp(start+2, "bool", 4) == 0) + { + totalnargs++; + } + start = strchr(start + 1, ','); + } + while(start < end && start != NULL); + } + char *funcNameEnd = strchr(funcName, '('); + *funcNameEnd = 0; + len += sprintf (&buf [len], funcName); + + // If this is a member function, print out the this pointer value. + if (totalnargs - params == 1) + { + len += sprintf (&buf [len], "", args [0]); + } + + // Print out the argument values. + len += sprintf (&buf [len], "("); + for (ix = totalnargs - params; ix < nargs; ix++) + { + if (ix != totalnargs - params) + len += sprintf (&buf [len], ", "); + len += sprintf (&buf [len], "%#lx", args [ix]); + } + len += sprintf (&buf [len], ")\n"); + + printf(buf); +} + +extern "C" +{ + extern void trcStack(REG_SET* pRegs, FUNCPTR printRtn, int32_t tid); +} + +static int32_t wpiStackTask(int32_t taskId) +{ + delayTicks(1); + //tt(taskId); + + REG_SET regs; + taskRegsGet(taskId, ®s); + trcStack(®s, (FUNCPTR) wpiCleanTracePrint, taskId); + printf("\n"); + + // The task should be resumed because it had to be suspended to get the stack trace. + taskResume(taskId); + return 0; +} + +void printCurrentStackTrace() +{ + int priority=100; + taskPriorityGet(0, &priority); + // Lower priority than the calling task. + // Task traceTask("StackTrace", (FUNCPTR)wpiStackTask, priority + 1); + // traceTask.Start(taskIdSelf()); + spawnTask("StackTrace", priority + 1, VXWORKS_FP_TASK, 20000, (FUNCPTR)wpiStackTask, taskIdSelf(), + 0, 0, 0, 0, 0, 0, 0, 0, 0); + + // Task to be traced must be suspended for the stack trace to work. + taskSuspend(0); +} + +bool getErrnoToName(int32_t errNo, char* name) { + int pval; + SYM_TYPE ptype; + symFindByValue(statSymTbl, errNo, name, &pval, &ptype); + return (pval == errNo); +} diff --git a/hal/Azalea/src/main/native/cpp/Synchronized.cpp b/hal/Azalea/src/main/native/cpp/Synchronized.cpp new file mode 100644 index 0000000000..b531c0e2b3 --- /dev/null +++ b/hal/Azalea/src/main/native/cpp/Synchronized.cpp @@ -0,0 +1,35 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#include "HAL/cpp/Synchronized.h" + +/** + * Synchronized class deals with critical regions. + * Declare a Synchronized object at the beginning of a block. That will take the semaphore. + * When the code exits from the block it will call the destructor which will give the semaphore. + * This ensures that no matter how the block is exited, the semaphore will always be released. + * Use the CRITICAL_REGION(SEM_ID) and END_REGION macros to make the code look cleaner (see header file) + * @param semaphore The semaphore controlling this critical region. + */ +Synchronized::Synchronized(MUTEX_ID semaphore) +{ + m_semaphore = semaphore; + takeMutex(m_semaphore, SEMAPHORE_WAIT_FOREVER); +} + +Synchronized::Synchronized(ReentrantSemaphore& semaphore) +{ + m_semaphore = semaphore.m_semaphore; + takeMutex(m_semaphore, SEMAPHORE_WAIT_FOREVER); +} + +/** + * This destructor unlocks the semaphore. + */ +Synchronized::~Synchronized() +{ + giveMutex(m_semaphore); +} diff --git a/hal/README.org b/hal/README.org new file mode 100644 index 0000000000..9eb132a406 --- /dev/null +++ b/hal/README.org @@ -0,0 +1,94 @@ + +* Purpose +The HAL is a hardware abstraction layer that provides a uniform +interface that can be used to access a number of primarily I/O +features in the underlying platform. The features include: +- Analog input, accumulation and triggers +- PWM, Relay and Solenoid output +- Digital input and output +- I2C and SPI communication +- Encoders and counters +- Interrupts and Notifiers + +The initial goal is to allow a higher level like WPILib to support +both the CRIO and the upcoming Athena platform only by changing which +version of the HAL it's running on. + +* Editing +You can always use any text editor and then build with Maven. There +are also eclipse project files so that it can be edited in the same +eclipse environment that teams develop with. For the AthenaXX, this +can be found in the =root= directory of this project. It imports as an +FRC Robot C++ Eclipse project. The Windriver project can be imported +from the =src= directory. + +* Building with Maven +There are multiple build targets that the HAL supports. Instructions +for setting up the environment and building each of these is described +below. Current targets are listed below: +- All: All of the following targets. +- include: The header files for the HAL. +- Azalea: CRIO C++ build. +- AthenaXX: Athena Dos Equis C++ build. +- AthenaXXJava: Athena Dos Equis Java build with auto-generated JNA + wrappers. + +Output from each build target is placed in the directory +=target/=. So, the Azalea output is placed in +=target/Azalea=. + +** All +Note: Windows only due to the Windriver requirement. +1. Ensure that =C:\WindRiver\gnu\3.4.4-vxworks-6.3\x86-win32\bin= is + on the system path so that =ccppc= and =arppc= can be accessed. +2. Set the environment variable =WIND_BASE= to =C:\WindRiver\vxworks-6.3=. +3. Ensure that + =$HOME/wpilib/toolchains/arm-none-linux-gnueabi-4.4.1/bin/= is on + the system path so that =arm-none-linux-gnueabi-g++= and + =arm-none-linux-gnueabi-ar= can be accessed. +4. Checkout and install the NI-Libraries from Github: + [[https://github.com/first/NI-Libraries]]. +5. Run the following maven command: + =mvn clean install= +6. Success + +** include +1. =cd= into the include directory: =cd include= +2. Run the following maven command: + =mvn clean install= +3. Success + +** Azalea +Note: Windows only. +1. Ensure that =C:\WindRiver\gnu\3.4.4-vxworks-6.3\x86-win32\bin= is + on the system path so that =ccppc= and =arppc= can be accessed. +2. Set the environment variable =WIND_BASE= to =C:\WindRiver\vxworks-6.3=. +3. =cd= into the AthenaXX directory: =cd AthenaXX= +4. =cd= into the Azalea directory: =cd Azalea= +5. Run the following maven command: + =mvn clean install= +6. Success + +** AthenaXX +1. Ensure that + =$HOME/wpilib/toolchains/arm-none-linux-gnueabi-4.4.1/bin/= is on + the system path so that =arm-none-linux-gnueabi-g++= and + =arm-none-linux-gnueabi-ar= can be accessed. +2. Install the include target. +3. =cd= into the AthenaXX directory: =cd AthenaXX= +4. Run the following maven command: + =mvn clean install= +5. Success + +** AthenaXXJava +1. Ensure that + =$HOME/wpilib/toolchains/arm-none-linux-gnueabi-4.4.1/bin/= is on + the system path so that =arm-none-linux-gnueabi-g++= and + =arm-none-linux-gnueabi-ar= can be accessed. +2. Checkout and install the NI-Libraries from Github: + [[https://github.com/first/NI-Libraries]]. +3. Install the include target. +4. =cd= into the AthenaXXJava directory: =cd AthenaXXJava= +5. Run the following maven command: + =mvn clean install= +6. Success diff --git a/hal/include/pom.xml b/hal/include/pom.xml new file mode 100644 index 0000000000..720e7de84b --- /dev/null +++ b/hal/include/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + edu.wpi.first.wpilib.hal + include + a + + + edu.wpi.first.wpilib.templates + include + 0.1.0-SNAPSHOT + + + + + WPILib Repository + http://frcbuilder.wpi.edu:8348/ + + + + + + + org.codehaus.mojo + native-maven-plugin + + + + diff --git a/hal/include/src/main/include/HAL/Analog.h b/hal/include/src/main/include/HAL/Analog.h new file mode 100644 index 0000000000..260cbeceb2 --- /dev/null +++ b/hal/include/src/main/include/HAL/Analog.h @@ -0,0 +1,66 @@ + +#ifdef __vxworks +#include +#else +#include +#endif + +#ifndef HAL_ANALOG_H +#define HAL_ANALOG_H + +extern "C" { + void* initializeAnalogPort(void* port_pointer, int32_t *status); + bool checkAnalogModule(uint8_t module); + bool checkAnalogChannel(uint32_t pin); + + void setAnalogSampleRate(double samplesPerSecond, int32_t *status); + float getAnalogSampleRate(int32_t *status); + void setAnalogSampleRateWithModule(uint8_t module, double samplesPerSecond, int32_t *status); + float getAnalogSampleRateWithModule(uint8_t module, int32_t *status); + void setAnalogAverageBits(void* analog_port_pointer, uint32_t bits, int32_t *status); + uint32_t getAnalogAverageBits(void* analog_port_pointer, int32_t *status); + void setAnalogOversampleBits(void* analog_port_pointer, uint32_t bits, int32_t *status); + uint32_t getAnalogOversampleBits(void* analog_port_pointer, int32_t *status); + int16_t getAnalogValue(void* analog_port_pointer, int32_t *status); + int32_t getAnalogAverageValue(void* analog_port_pointer, int32_t *status); + int32_t getAnalogVoltsToValue(void* analog_port_pointer, double voltage, int32_t *status); + float getAnalogVoltage(void* analog_port_pointer, int32_t *status); + float getAnalogAverageVoltage(void* analog_port_pointer, int32_t *status); + uint32_t getAnalogLSBWeight(void* analog_port_pointer, int32_t *status); + int32_t getAnalogOffset(void* analog_port_pointer, int32_t *status); + + bool isAccumulatorChannel(void* analog_port_pointer, int32_t *status); + void initAccumulator(void* analog_port_pointer, int32_t *status); + void resetAccumulator(void* analog_port_pointer, int32_t *status); + void setAccumulatorCenter(void* analog_port_pointer, int32_t center, int32_t *status); + void setAccumulatorDeadband(void* analog_port_pointer, int32_t deadband, int32_t *status); + int64_t getAccumulatorValue(void* analog_port_pointer, int32_t *status); + uint32_t getAccumulatorCount(void* analog_port_pointer, int32_t *status); + void getAccumulatorOutput(void* analog_port_pointer, int64_t *value, uint32_t *count, int32_t *status); + + typedef enum {kInWindow=0, kState=1, kRisingPulse=2, kFallingPulse=3} AnalogTriggerType; + void* initializeAnalogTrigger(void* port_pointer, uint32_t *index, int32_t *status); + void cleanAnalogTrigger(void* analog_trigger_pointer, int32_t *status); + void setAnalogTriggerLimitsRaw(void* analog_trigger_pointer, int32_t lower, int32_t upper, int32_t *status); + void setAnalogTriggerLimitsVoltage(void* analog_trigger_pointer, double lower, double upper, int32_t *status); + void setAnalogTriggerAveraged(void* analog_trigger_pointer, bool useAveragedValue, int32_t *status); + void setAnalogTriggerFiltered(void* analog_trigger_pointer, bool useFilteredValue, int32_t *status); + bool getAnalogTriggerInWindow(void* analog_trigger_pointer, int32_t *status); + bool getAnalogTriggerTriggerState(void* analog_trigger_pointer, int32_t *status); + bool getAnalogTriggerOutput(void* analog_trigger_pointer, AnalogTriggerType type, int32_t *status); + + + //// Float JNA Hack + // Float + int getAnalogSampleRateIntHack(int32_t *status); + int getAnalogSampleRateWithModuleIntHack(uint8_t module, int32_t *status); + int getAnalogVoltageIntHack(void* analog_port_pointer, int32_t *status); + int getAnalogAverageVoltageIntHack(void* analog_port_pointer, int32_t *status); + + // Doubles + void setAnalogSampleRateIntHack(int samplesPerSecond, int32_t *status); + void setAnalogSampleRateWithModuleIntHack(uint8_t module, int samplesPerSecond, int32_t *status); + int32_t getAnalogVoltsToValueIntHack(void* analog_port_pointer, int voltage, int32_t *status); + void setAnalogTriggerLimitsVoltageIntHack(void* analog_trigger_pointer, int lower, int upper, int32_t *status); +} +#endif diff --git a/hal/include/src/main/include/HAL/Digital.h b/hal/include/src/main/include/HAL/Digital.h new file mode 100644 index 0000000000..91a33fd802 --- /dev/null +++ b/hal/include/src/main/include/HAL/Digital.h @@ -0,0 +1,141 @@ + +#ifdef __vxworks +#include +#else +#include +#endif + +#ifndef HAL_DIGITAL_H +#define HAL_DIGITAL_H +extern "C" { + void* initializeDigitalPort(void* port_pointer, int32_t *status); + bool checkDigitalModule(uint8_t module); + bool checkPWMChannel(void* digital_port_pointer); + bool checkRelayChannel(void* digital_port_pointer); + uint8_t remapDigitalChannel(uint32_t pin, int32_t *status); + uint8_t unmapDigitalChannel(uint32_t pin, int32_t *status); + + void setPWM(void* digital_port_pointer, unsigned short value, int32_t *status); + unsigned short getPWM(void* digital_port_pointer, int32_t *status); + void setPWMPeriodScale(void* digital_port_pointer, uint32_t squelchMask, int32_t *status); + void* allocatePWM(int32_t *status); + void* allocatePWMWithModule(uint8_t module, int32_t *status); + void freePWM(void* pwmGenerator, int32_t *status); + void freePWMWithModule(uint8_t module, void* pwmGenerator, int32_t *status); + void setPWMRate(double rate, int32_t *status); + void setPWMRateWithModule(uint8_t module, double rate, int32_t *status); + void setPWMDutyCycle(void* pwmGenerator, double dutyCycle, int32_t *status); + void setPWMDutyCycleWithModule(uint8_t module, void* pwmGenerator, double dutyCycle, int32_t *status); + void setPWMOutputChannel(void* pwmGenerator, uint32_t pin, int32_t *status); + void setPWMOutputChannelWithModule(uint8_t module, void* pwmGenerator, uint32_t pin, int32_t *status); + + void setRelayForward(void* digital_port_pointer, bool on, int32_t *status); + void setRelayReverse(void* digital_port_pointer, bool on, int32_t *status); + bool getRelayForward(void* digital_port_pointer, int32_t *status); + bool getRelayReverse(void* digital_port_pointer, int32_t *status); + + bool allocateDIO(void* digital_port_pointer, bool input, int32_t *status); + void freeDIO(void* digital_port_pointer, int32_t *status); + void setDIO(void* digital_port_pointer, short value, int32_t *status); + bool getDIO(void* digital_port_pointer, int32_t *status); + bool getDIODirection(void* digital_port_pointer, int32_t *status); + void pulse(void* digital_port_pointer, double pulseLength, int32_t *status); + bool isPulsing(void* digital_port_pointer, int32_t *status); + bool isAnyPulsing(int32_t *status); + bool isAnyPulsingWithModule(uint8_t module, int32_t *status); + + typedef enum {kTwoPulse=0, kSemiperiod=1, kPulseLength=2, kExternalDirection=3} Mode; + + void* initializeCounter(Mode mode, uint32_t *index, int32_t *status); + void freeCounter(void* counter_pointer, int32_t *status); + void setCounterAverageSize(void* counter_pointer, int32_t size, int32_t *status); + void setCounterUpSourceWithModule(void* counter_pointer, uint8_t module, uint32_t pin, + bool analogTrigger, int32_t *status); // TODO: Without Module + void setCounterUpSourceEdge(void* counter_pointer, bool risingEdge, bool fallingEdge, int32_t *status); + void clearCounterUpSource(void* counter_pointer, int32_t *status); + void setCounterDownSourceWithModule(void* counter_pointer, uint8_t module, uint32_t pin, + bool analogTrigger, int32_t *status); // TODO: Without Module + void setCounterDownSourceEdge(void* counter_pointer, bool risingEdge, bool fallingEdge, int32_t *status); + void clearCounterDownSource(void* counter_pointer, int32_t *status); + void setCounterUpDownMode(void* counter_pointer, int32_t *status); + void setCounterExternalDirectionMode(void* counter_pointer, int32_t *status); + void setCounterSemiPeriodMode(void* counter_pointer, bool highSemiPeriod, int32_t *status); + void setCounterPulseLengthMode(void* counter_pointer, double threshold, int32_t *status); + int32_t getCounterSamplesToAverage(void* counter_pointer, int32_t *status); + void setCounterSamplesToAverage(void* counter_pointer, int samplesToAverage, int32_t *status); + void startCounter(void* counter_pointer, int32_t *status); + void stopCounter(void* counter_pointer, int32_t *status); + void resetCounter(void* counter_pointer, int32_t *status); + int32_t getCounter(void* counter_pointer, int32_t *status); + double getCounterPeriod(void* counter_pointer, int32_t *status); + void setCounterMaxPeriod(void* counter_pointer, double maxPeriod, int32_t *status); + void setCounterUpdateWhenEmpty(void* counter_pointer, bool enabled, int32_t *status); + bool getCounterStopped(void* counter_pointer, int32_t *status); + bool getCounterDirection(void* counter_pointer, int32_t *status); + void setCounterReverseDirection(void* counter_pointer, bool reverseDirection, int32_t *status); + + void* initializeEncoder(uint8_t port_a_module, uint32_t port_a_pin, bool port_a_analog_trigger, + uint8_t port_b_module, uint32_t port_b_pin, bool port_b_analog_trigger, + bool reverseDirection, int32_t *index, int32_t *status); // TODO: fix routing + void freeEncoder(void* encoder_pointer, int32_t *status); + void startEncoder(void* encoder_pointer, int32_t *status); + void stopEncoder(void* encoder_pointer, int32_t *status); + void resetEncoder(void* encoder_pointer, int32_t *status); + int32_t getEncoder(void* encoder_pointer, int32_t *status); // Raw value + double getEncoderPeriod(void* encoder_pointer, int32_t *status); + void setEncoderMaxPeriod(void* encoder_pointer, double maxPeriod, int32_t *status); + bool getEncoderStopped(void* encoder_pointer, int32_t *status); + bool getEncoderDirection(void* encoder_pointer, int32_t *status); + void setEncoderReverseDirection(void* encoder_pointer, bool reverseDirection, int32_t *status); + void setEncoderSamplesToAverage(void* encoder_pointer, uint32_t samplesToAverage, int32_t *status); + uint32_t getEncoderSamplesToAverage(void* encoder_pointer, int32_t *status); + + uint16_t getLoopTiming(int32_t *status); + uint16_t getLoopTimingWithModule(uint8_t module, int32_t *status); + + enum tSPIConstants {kReceiveFIFODepth=512, kTransmitFIFODepth=512}; + enum tFrameMode {kChipSelect, kPreLatchPulse, kPostLatchPulse, kPreAndPostLatchPulse}; + void* initializeSPI(uint8_t sclk_routing_module, uint32_t sclk_routing_pin, + uint8_t mosi_routing_module, uint32_t mosi_routing_pin, + uint8_t miso_routing_module, uint32_t miso_routing_pin, int32_t *status); + void cleanSPI(void* spi_pointer, int32_t *status); + void setSPIBitsPerWord(void* spi_pointer, uint32_t bits, int32_t *status); + uint32_t getSPIBitsPerWord(void* spi_pointer, int32_t *status); + void setSPIClockRate(void* spi_pointer, double hz, int32_t *status); + void setSPIMSBFirst(void* spi_pointer, int32_t *status); + void setSPILSBFirst(void* spi_pointer, int32_t *status); + void setSPISampleDataOnFalling(void* spi_pointer, int32_t *status); + void setSPISampleDataOnRising(void* spi_pointer, int32_t *status); + void setSPISlaveSelect(void* spi_pointer, uint8_t ss_routing_module, uint32_t ss_routing_pin, + int32_t *status); + void setSPILatchMode(void* spi_pointer, tFrameMode mode, int32_t *status); + tFrameMode getSPILatchMode(void* spi_pointer, int32_t *status); + void setSPIFramePolarity(void* spi_pointer, bool activeLow, int32_t *status); + bool getSPIFramePolarity(void* spi_pointer, int32_t *status); + void setSPIClockActiveLow(void* spi_pointer, int32_t *status); + void setSPIClockActiveHigh(void* spi_pointer, int32_t *status); + void applySPIConfig(void* spi_pointer, int32_t *status); + uint16_t getSPIOutputFIFOAvailable(void* spi_pointer, int32_t *status); + uint16_t getSPINumReceived(void* spi_pointer, int32_t *status); + bool isSPIDone(void* spi_pointer, int32_t *status); + bool hadSPIReceiveOverflow(void* spi_pointer, int32_t *status); + void writeSPI(void* spi_pointer, uint32_t data, int32_t *status); + uint32_t readSPI(void* spi_pointer, bool initiate, int32_t *status); + void resetSPI(void* spi_pointer, int32_t *status); + void clearSPIReceivedData(void* spi_pointer, int32_t *status); + + bool doI2CTransaction(uint8_t address, bool compatibilityMode, uint8_t *dataToSend, + uint8_t sendSize, uint8_t *dataReceived, uint8_t receiveSize, + int32_t *status); + bool doI2CTransactionWithModule(uint8_t module, uint8_t address, bool compatibilityMode, + uint8_t *dataToSend, uint8_t sendSize, uint8_t *dataReceived, + uint8_t receiveSize, int32_t *status); + + //// Float JNA Hack + // double + void setPWMRateIntHack(int rate, int32_t *status); + void setPWMRateWithModuleIntHack(uint8_t module, int32_t rate, int32_t *status); + void setPWMDutyCycleIntHack(void* pwmGenerator, int32_t dutyCycle, int32_t *status); + void setPWMDutyCycleWithModuleIntHack(uint8_t module, void* pwmGenerator, int32_t dutyCycle, int32_t *status); +} +#endif diff --git a/hal/include/src/main/include/HAL/Errors.h b/hal/include/src/main/include/HAL/Errors.h new file mode 100644 index 0000000000..6d516e5e35 --- /dev/null +++ b/hal/include/src/main/include/HAL/Errors.h @@ -0,0 +1,30 @@ + +#ifndef HAL_ERRORS_H +#define HAL_ERRORS_H + +#define SAMPLE_RATE_TOO_HIGH 1 +#define SAMPLE_RATE_TOO_HIGH_MESSAGE "Analog module sample rate is too high" +#define VOLTAGE_OUT_OF_RANGE 2 +#define VOLTAGE_OUT_OF_RANGE_MESSAGE "Voltage to convert to raw value is out of range [-10; 10]" +#define LOOP_TIMING_ERROR 4 +#define LOOP_TIMING_ERROR_MESSAGE "Digital module loop timing is not the expected value" +#define SPI_WRITE_NO_MOSI 12 +#define SPI_WRITE_NO_MOSI_MESSAGE "Cannot write to SPI port with no MOSI output" +#define SPI_READ_NO_MISO 13 +#define SPI_READ_NO_MISO_MESSAGE "Cannot read from SPI port with no MISO input" +#define SPI_READ_NO_DATA 14 +#define SPI_READ_NO_DATA_MESSAGE "No data available to read from SPI" +#define INCOMPATIBLE_STATE 15 +#define INCOMPATIBLE_STATE_MESSAGE "Incompatible State: The operation cannot be completed" +#define NO_AVAILABLE_RESOURCES -4 +#define NO_AVAILABLE_RESOURCES_MESSAGE "No available resources to allocate" +#define NULL_PARAMETER -5 +#define NULL_PARAMETER_MESSAGE "A pointer parameter to a method is NULL" +#define ANALOG_TRIGGER_LIMIT_ORDER_ERROR -10 +#define ANALOG_TRIGGER_LIMIT_ORDER_ERROR_MESSAGE "AnalogTrigger limits error. Lower limit > Upper Limit" +#define ANALOG_TRIGGER_PULSE_OUTPUT_ERROR -11 +#define ANALOG_TRIGGER_PULSE_OUTPUT_ERROR_MESSAGE "Attempted to read AnalogTrigger pulse output." +#define PARAMETER_OUT_OF_RANGE -28 +#define PARAMETER_OUT_OF_RANGE_MESSAGE "A parameter is out of range." + +#endif diff --git a/hal/include/src/main/include/HAL/HAL.h b/hal/include/src/main/include/HAL/HAL.h new file mode 100644 index 0000000000..39c4b345e2 --- /dev/null +++ b/hal/include/src/main/include/HAL/HAL.h @@ -0,0 +1,64 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2013. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#ifdef __vxworks +#include +#else +#include +#endif + +#include "Analog.h" +#include "Digital.h" +#include "Solenoid.h" +#include "Watchdog.h" +#include "Notifier.h" +#include "Interrupts.h" +#include "Errors.h" + +#include "Utilities.h" +#include "Semaphore.h" +#include "Task.h" + +#ifndef HAL_H +#define HAL_H + + +inline float intToFloat(int value) { + return *(float*) &value; +} + +inline int floatToInt(float value) { + return *(int*) &value; +} + +extern "C" { + extern const uint32_t dio_kNumSystems; + extern const uint32_t solenoid_kNumDO7_0Elements; + extern const uint32_t interrupt_kNumSystems; + extern const uint32_t kSystemClockTicksPerMicrosecond; + + void* getPort(uint8_t pin); + void* getPortWithModule(uint8_t module, uint8_t pin); + const char* getHALErrorMessage(int32_t code); + + uint16_t getFPGAVersion(int32_t *status); + uint32_t getFPGARevision(int32_t *status); + uint32_t getFPGATime(int32_t *status); + + void setFPGALED(uint32_t state, int32_t *status); + int32_t getFPGALED(int32_t *status); +} + +// TODO: HACKS for now... +extern "C" { + void FRC_NetworkCommunication_Reserve(); + + void NumericArrayResize(); + void RTSetCleanupProc(); + void EDVR_CreateReference(); + void Occur(); +} +#endif diff --git a/hal/include/src/main/include/HAL/Interrupts.h b/hal/include/src/main/include/HAL/Interrupts.h new file mode 100644 index 0000000000..ad85afed4f --- /dev/null +++ b/hal/include/src/main/include/HAL/Interrupts.h @@ -0,0 +1,27 @@ + +#ifdef __vxworks +#include +#else +#include +#endif + +#ifndef HAL_INTERRUPTS_H +#define HAL_INTERRUPTS_H + +extern "C" { + typedef void (*InterruptHandlerFunction)(uint32_t interruptAssertedMask, void *param); + + void* initializeInterrupts(uint32_t interruptIndex, bool watcher, int32_t *status); + void cleanInterrupts(void* interrupt_pointer, int32_t *status); + + void waitForInterrupt(void* interrupt_pointer, double timeout, int32_t *status); + void enableInterrupts(void* interrupt_pointer, int32_t *status); + void disableInterrupts(void* interrupt_pointer, int32_t *status); + double readInterruptTimestamp(void* interrupt_pointer, int32_t *status); + void requestInterrupts(void* interrupt_pointer, uint8_t routing_module, uint32_t routing_pin, + bool routing_analog_trigger, int32_t *status); + void attachInterruptHandler(void* interrupt_pointer, InterruptHandlerFunction handler, + void* param, int32_t *status); + void setInterruptUpSourceEdge(void* interrupt_pointer, bool risingEdge, bool fallingEdge, int32_t *status); +} +#endif diff --git a/hal/include/src/main/include/HAL/Notifier.h b/hal/include/src/main/include/HAL/Notifier.h new file mode 100644 index 0000000000..6bb7321944 --- /dev/null +++ b/hal/include/src/main/include/HAL/Notifier.h @@ -0,0 +1,17 @@ + +#ifdef __vxworks +#include +#else +#include +#endif + +#ifndef HAL_NOTIFIER_H +#define HAL_NOTIFIER_H + +extern "C" { + void* initializeNotifier(void (*ProcessQueue)(uint32_t, void*), int32_t *status); + void cleanNotifier(void* notifier_pointer, int32_t *status); + + void updateNotifierAlarm(void* notifier_pointer, uint32_t triggerTime, int32_t *status); +} +#endif diff --git a/hal/include/src/main/include/HAL/Semaphore.h b/hal/include/src/main/include/HAL/Semaphore.h new file mode 100644 index 0000000000..1282827ec8 --- /dev/null +++ b/hal/include/src/main/include/HAL/Semaphore.h @@ -0,0 +1,51 @@ + +#ifdef __vxworks +#include +#else +#include +#include +#include +#endif + +#ifndef HAL_SEMAPHORE_H +#define HAL_SEMAPHORE_H + +extern "C" { +#ifdef __vxworks + typedef SEM_ID MUTEX_ID; + typedef SEM_ID SEMAPHORE_ID; + typedef SEM_ID MULTIWAIT_ID; +#else + typedef pthread_mutex_t* MUTEX_ID; + typedef sem_t* SEMAPHORE_ID; + typedef pthread_cond_t* MULTIWAIT_ID; +#endif + + extern const uint32_t SEMAPHORE_Q_FIFO; + extern const uint32_t SEMAPHORE_Q_PRIORITY; + extern const uint32_t SEMAPHORE_DELETE_SAFE; + extern const uint32_t SEMAPHORE_INVERSION_SAFE; + + extern const int32_t SEMAPHORE_NO_WAIT; + extern const int32_t SEMAPHORE_WAIT_FOREVER; + + extern const uint32_t SEMAPHORE_EMPTY; + extern const uint32_t SEMAPHORE_FULL; + + MUTEX_ID initializeMutex(uint32_t flags); + void deleteMutex(MUTEX_ID sem); + int8_t takeMutex(MUTEX_ID sem, int32_t timeout); + int8_t giveMutex(MUTEX_ID sem); + + SEMAPHORE_ID initializeSemaphore(uint32_t flags, uint32_t initial_value); + void deleteSemaphore(SEMAPHORE_ID sem); + int8_t takeSemaphore(SEMAPHORE_ID sem, int32_t timeout); + int8_t giveSemaphore(SEMAPHORE_ID sem); + + MULTIWAIT_ID initializeMultiWait(); + void deleteMultiWait(MULTIWAIT_ID sem); + int8_t takeMultiWait(MULTIWAIT_ID sem, int32_t timeout); + int8_t giveMultiWait(MULTIWAIT_ID sem); +} + +#endif diff --git a/hal/include/src/main/include/HAL/Solenoid.h b/hal/include/src/main/include/HAL/Solenoid.h new file mode 100644 index 0000000000..fb555d0252 --- /dev/null +++ b/hal/include/src/main/include/HAL/Solenoid.h @@ -0,0 +1,17 @@ + +#ifdef __vxworks +#include +#else +#include +#endif + +#ifndef HAL_SOLENOID_H +#define HAL_SOLENOID_H +extern "C" { + void* initializeSolenoidPort(void* port_pointer, int32_t *status); + bool checkSolenoidModule(uint8_t module); + + bool getSolenoid(void* solenoid_port_pointer, int32_t *status); + void setSolenoid(void* solenoid_port_pointer, bool value, int32_t *status); +} +#endif diff --git a/hal/include/src/main/include/HAL/Task.h b/hal/include/src/main/include/HAL/Task.h new file mode 100644 index 0000000000..4456531d99 --- /dev/null +++ b/hal/include/src/main/include/HAL/Task.h @@ -0,0 +1,68 @@ + +#ifdef __vxworks +#include +#else +#include +#include +#endif + +#ifndef _FUNCPTR_DEFINED +#define _FUNCPTR_DEFINED +#ifdef __cplusplus +typedef int (*FUNCPTR) (...); /* ptr to function returning int */ +#else +typedef int (*FUNCPTR) (); /* ptr to function returning int */ +#endif /* __cplusplus */ +#endif /* _FUNCPTR_DEFINED */ + +#ifndef _STATUS_DEFINED +#define _STATUS_DEFINED +typedef int STATUS; +#endif /* _STATUS_DEFINED */ + +#ifndef OK +#define OK 0 +#endif /* OK */ +#ifndef ERROR +#define ERROR (-1) +#endif /* ERROR */ + +#ifndef HAL_TASK_H +#define HAL_TASK_H + +#ifdef __vxworks +#define NULL_TASK -1 +#else +#define NULL_TASK NULL +#endif + +extern "C" { + extern const uint32_t VXWORKS_FP_TASK; + extern const int32_t HAL_objLib_OBJ_ID_ERROR; + extern const int32_t HAL_objLib_OBJ_DELETED; + extern const int32_t HAL_taskLib_ILLEGAL_OPTIONS; + extern const int32_t HAL_memLib_NOT_ENOUGH_MEMORY; + extern const int32_t HAL_taskLib_ILLEGAL_PRIORITY; + +#ifdef __vxworks + typedef int32_t TASK; +#else + typedef pthread_t* TASK; +#endif + + TASK spawnTask(char * name, int priority, int options, int stackSize, + FUNCPTR entryPt, uint32_t arg0, uint32_t arg1, uint32_t arg2, + uint32_t arg3, uint32_t arg4, uint32_t arg5, uint32_t arg6, + uint32_t arg7, uint32_t arg8, uint32_t arg9); + STATUS restartTask(TASK task); + STATUS deleteTask(TASK task); + STATUS isTaskReady(TASK task); + STATUS isTaskSuspended(TASK task); + STATUS suspendTask(TASK task); + STATUS resumeTask(TASK task); + STATUS verifyTaskID(TASK task); + STATUS setTaskPriority(TASK task, int priority); + STATUS getTaskPriority(TASK task, int* priority); +} + +#endif diff --git a/hal/include/src/main/include/HAL/Utilities.h b/hal/include/src/main/include/HAL/Utilities.h new file mode 100644 index 0000000000..6e0384e194 --- /dev/null +++ b/hal/include/src/main/include/HAL/Utilities.h @@ -0,0 +1,18 @@ + +#ifdef __vxworks +#include +#else +#include +#endif + +#ifndef HAL_UTILITIES_H +#define HAL_UTILITIES_H + +extern "C" { + extern const int32_t HAL_NO_WAIT; + extern const int32_t HAL_WAIT_FOREVER; + + void delayTicks(int32_t ticks); + void delayMillis(double ms); + void delaySeconds(double s);} +#endif diff --git a/hal/include/src/main/include/HAL/Watchdog.h b/hal/include/src/main/include/HAL/Watchdog.h new file mode 100644 index 0000000000..6b39f858d6 --- /dev/null +++ b/hal/include/src/main/include/HAL/Watchdog.h @@ -0,0 +1,27 @@ + +#ifdef __vxworks +#include +#else +#include +#endif + +#ifndef HAL_WATCHDOG_H +#define HAL_WATCHDOG_H + +extern "C" { + extern const double kDefaultWatchdogExpiration; + + void* initializeWatchdog(int32_t *status); + void cleanWatchdog(void* watchdog_pointer, int32_t *status); + + bool feedWatchdog(void* watchdog_pointer, int32_t *status); + void killWatchdog(void* watchdog_pointer, int32_t *status); + double getWatchdogLastFed(void* watchdog_pointer, int32_t *status); + double getWatchdogExpiration(void* watchdog_pointer, int32_t *status); + void setWatchdogExpiration(void* watchdog_pointer, double expiration, int32_t *status); + bool getWatchdogEnabled(void* watchdog_pointer, int32_t *status); + void setWatchdogEnabled(void* watchdog_pointer, bool enabled, int32_t *status); + bool isWatchdogAlive(void* watchdog_pointer, int32_t *status); + bool isWatchdogSystemActive(void* watchdog_pointer, int32_t *status); +} +#endif diff --git a/hal/include/src/main/include/HAL/cpp/Resource.h b/hal/include/src/main/include/HAL/cpp/Resource.h new file mode 100644 index 0000000000..43d93e3959 --- /dev/null +++ b/hal/include/src/main/include/HAL/cpp/Resource.h @@ -0,0 +1,48 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#ifndef RESOURCE_H_ +#define RESOURCE_H_ + +#include "../Errors.h" +#include "Synchronized.h" +#ifdef __vxworks +#include +#else +#include +#endif + +/** + * The Resource class is a convenient way to track allocated resources. + * It tracks them as indicies in the range [0 .. elements - 1]. + * E.g. the library uses this to track hardware channel allocation. + * + * The Resource class does not allocate the hardware channels or other + * resources; it just tracks which indices were marked in use by + * Allocate and not yet freed by Free. + */ +class Resource +{ +public: + virtual ~Resource(); + static void CreateResourceObject(Resource **r, uint32_t elements); + uint32_t Allocate(const char *resourceDesc); + uint32_t Allocate(uint32_t index, const char *resourceDesc); + void Free(uint32_t index); + +private: + explicit Resource(uint32_t size); + + bool *m_isAllocated; + ReentrantSemaphore m_allocateLock; + uint32_t m_size; + + static ReentrantSemaphore m_createLock; + + DISALLOW_COPY_AND_ASSIGN(Resource); +}; + +#endif diff --git a/hal/include/src/main/include/HAL/cpp/StackTrace.h b/hal/include/src/main/include/HAL/cpp/StackTrace.h new file mode 100644 index 0000000000..6112d9c2e5 --- /dev/null +++ b/hal/include/src/main/include/HAL/cpp/StackTrace.h @@ -0,0 +1,15 @@ + +#ifdef __vxworks +#include +#else +#include +#endif + +#ifndef HAL_STACKTRACE_H +#define HAL_STACKTRACE_H + +extern "C" { + void printCurrentStackTrace(); + bool getErrnoToName(int32_t errNo, char* name); +} +#endif diff --git a/hal/include/src/main/include/HAL/cpp/Synchronized.h b/hal/include/src/main/include/HAL/cpp/Synchronized.h new file mode 100644 index 0000000000..768861ffff --- /dev/null +++ b/hal/include/src/main/include/HAL/cpp/Synchronized.h @@ -0,0 +1,102 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in $(WIND_BASE)/WPILib. */ +/*----------------------------------------------------------------------------*/ + +#ifndef SYNCHRONIZED_H +#define SYNCHRONIZED_H + +#include "HAL/HAL.h" + +// A macro to disallow the copy constructor and operator= functions +// This should be used in the private: declarations for a class +#define DISALLOW_COPY_AND_ASSIGN(TypeName) \ + TypeName(const TypeName&); \ + void operator=(const TypeName&) + +#define CRITICAL_REGION(s) { Synchronized _sync(s); +#define END_REGION } + +class Synchronized; + +/** + * Wrap a vxWorks semaphore (SEM_ID) for easier use in C++. For a static + * instance, the constructor runs at program load time before main() can spawn + * any tasks. Use that to fix race conditions in setup code. + * + * This uses a semM semaphore which is "reentrant" in the sense that the owning + * task can "take" the semaphore more than once. It will need to "give" the + * semaphore the same number of times to unlock it. + * + * This class is safe to use in static variables because it does not depend on + * any other C++ static constructors or destructors. + */ +class ReentrantSemaphore +{ +public: + explicit ReentrantSemaphore() { + m_semaphore = initializeMutex(SEMAPHORE_Q_PRIORITY | SEMAPHORE_DELETE_SAFE); + } + ~ReentrantSemaphore() { + deleteMutex(m_semaphore); + } + + /** + * Lock the semaphore, blocking until it's available. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ + int take() { + return takeMutex(m_semaphore, SEMAPHORE_WAIT_FOREVER); + } + + /** + * Unlock the semaphore. + * @return 0 for success, -1 for error. If -1, the error will be in errno. + */ + int give() { + return giveMutex(m_semaphore); + } + +private: + MUTEX_ID m_semaphore; + + friend class Synchronized; + DISALLOW_COPY_AND_ASSIGN(ReentrantSemaphore); +}; + +/** + * Provide easy support for critical regions. + * + * A critical region is an area of code that is always executed under mutual exclusion. Only + * one task can be executing this code at any time. The idea is that code that manipulates data + * that is shared between two or more tasks has to be prevented from executing at the same time + * otherwise a race condition is possible when both tasks try to update the data. Typically + * semaphores are used to ensure only single task access to the data. + * + * Synchronized objects are a simple wrapper around semaphores to help ensure + * that semaphores are always unlocked (semGive) after locking (semTake). + * + * You allocate a Synchronized as a local variable, *not* on the heap. That + * makes it a "stack object" whose destructor runs automatically when it goes + * out of scope. E.g. + * + * { Synchronized _sync(aReentrantSemaphore); ... critical region ... } + */ +class Synchronized +{ +public: + explicit Synchronized(MUTEX_ID); +#ifndef __vxworks + explicit Synchronized(SEMAPHORE_ID); +#endif + explicit Synchronized(ReentrantSemaphore&); + virtual ~Synchronized(); +private: + MUTEX_ID m_mutex; + SEMAPHORE_ID m_semaphore; + + DISALLOW_COPY_AND_ASSIGN(Synchronized); +}; + +#endif diff --git a/hal/pom.xml b/hal/pom.xml new file mode 100644 index 0000000000..33b56a79be --- /dev/null +++ b/hal/pom.xml @@ -0,0 +1,50 @@ + + + 4.0.0 + edu.wpi.first.wpilib.hal + edu.wpi.first.wpilib.hal + pom + 0.1.0-SNAPSHOT + + + include + + + + C:/Users/wpilibj-buildmaster/maven-repository + + + + + jenkins + + + myrepository + file:${local-repository} + + + + + athena + + true + + + Athena + AthenaJava + AthenaXX + AthenaXXJava + + + + azalea + + true + + + Azalea + + + + diff --git a/maven-utilities/.gitignore b/maven-utilities/.gitignore new file mode 100644 index 0000000000..535c157308 --- /dev/null +++ b/maven-utilities/.gitignore @@ -0,0 +1,2 @@ +*~ +target/ \ No newline at end of file diff --git a/maven-utilities/README.org b/maven-utilities/README.org new file mode 100644 index 0000000000..3481b79529 --- /dev/null +++ b/maven-utilities/README.org @@ -0,0 +1,15 @@ + +* Purpose +This project contains a number of utilities for using maven with +wpilib. Currently it only contains a number of useful parents to +inherit from. + +* List of possible parents +- edu.wpi.first.wpilib.templates.athena:static-library :: Create a + static library (*.a) to run on the Athena platform. +- edu.wpi.first.wpilib.templates.athena:shared-library :: Create a + shared library (*.so) to run on the Athena platform. +- edu.wpi.first.wpilib.templates.azalea:static-library :: Create a + static library (*.a) to run on the Azalea platform. +- edu.wpi.first.wpilib.templates:include :: Create a set of headers + that can be included with the native-maven-plugin. diff --git a/maven-utilities/athena/cpp-executable/pom.xml b/maven-utilities/athena/cpp-executable/pom.xml new file mode 100644 index 0000000000..b527679efa --- /dev/null +++ b/maven-utilities/athena/cpp-executable/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + edu.wpi.first.wpilib.templates.athena + cpp-executable + 0.1.0-SNAPSHOT + pom + + + UTF-8 + UTF-8 + C:/Users/wpilibj-buildmaster/maven-repository + + + + + + + org.codehaus.mojo + native-maven-plugin + 1.0-alpha-7 + true + + + arm-none-linux-gnueabi-g++ + + -O0 -g3 -Wall + + + arm-none-linux-gnueabi-g++ + + -ldl -lpthread + + + + + src/main/native + + **/*.cpp + + + + + + + + + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/maven-utilities/athena/library-jar/pom.xml b/maven-utilities/athena/library-jar/pom.xml new file mode 100644 index 0000000000..82dd3ac640 --- /dev/null +++ b/maven-utilities/athena/library-jar/pom.xml @@ -0,0 +1,62 @@ + + + 4.0.0 + edu.wpi.first.wpilib.templates.athena + library-jar + pom + 0.1.0-SNAPSHOT + + + UTF-8 + UTF-8 + C:/Users/wpilibj-buildmaster/maven-repository + + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + package + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadoc + package + + jar + + + + + + + + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/maven-utilities/athena/pom.xml b/maven-utilities/athena/pom.xml new file mode 100644 index 0000000000..689748d388 --- /dev/null +++ b/maven-utilities/athena/pom.xml @@ -0,0 +1,31 @@ + + + 4.0.0 + edu.wpi.first.wpilib.templates + athena + pom + 0.1.0-SNAPSHOT + + + static-library + shared-library + cpp-executable + library-jar + + + + C:/Users/wpilibj-buildmaster/maven-repository + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/maven-utilities/athena/shared-library/pom.xml b/maven-utilities/athena/shared-library/pom.xml new file mode 100644 index 0000000000..9ce400dfe9 --- /dev/null +++ b/maven-utilities/athena/shared-library/pom.xml @@ -0,0 +1,74 @@ + + + 4.0.0 + edu.wpi.first.wpilib.templates.athena + shared-library + 0.1.0-SNAPSHOT + pom + + + UTF-8 + UTF-8 + C:/Users/wpilibj-buildmaster/maven-repository + + + + + + + org.codehaus.mojo + native-maven-plugin + 1.0-alpha-7 + true + + + arm-none-linux-gnueabi-g++ + + -march=armv7 -mcpu=cortex-a9 -mfloat-abi=softfp -fPIC + + + -O0 -g3 -Wall + + + arm-none-linux-gnueabi-g++ + + -shared + + + -ldl -lpthread + + + + + src/main/native + + **/*.cpp + + + + src/main/include + + + true + + + + + + + + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/maven-utilities/athena/static-library/pom.xml b/maven-utilities/athena/static-library/pom.xml new file mode 100644 index 0000000000..d95d1fd2d0 --- /dev/null +++ b/maven-utilities/athena/static-library/pom.xml @@ -0,0 +1,103 @@ + + + 4.0.0 + edu.wpi.first.wpilib.templates.athena + static-library + 0.1.0-SNAPSHOT + pom + + + UTF-8 + UTF-8 + C:/Users/wpilibj-buildmaster/maven-repository + + + + + + + org.codehaus.mojo + native-maven-plugin + 1.0-alpha-7 + true + + + arm-none-linux-gnueabi-g++ + + -march=armv7 -mcpu=cortex-a9 -mfloat-abi=softfp -fPIC + + + -O0 -g3 -Wall + + + arm-none-linux-gnueabi-ar* + + -r + + + + + src/main/native + + **/*.cpp + + + + src/main/include + + + true + + + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + native-maven-plugin + [0.0,) + + unzipinc + initialize + compile + link + javah + + + + + + + + + + + + + + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/maven-utilities/azalea/cpp-executable/pom.xml b/maven-utilities/azalea/cpp-executable/pom.xml new file mode 100644 index 0000000000..3a72798a1d --- /dev/null +++ b/maven-utilities/azalea/cpp-executable/pom.xml @@ -0,0 +1,65 @@ + + + 4.0.0 + edu.wpi.first.wpilib.templates.azalea + cpp-executable + 0.1.0-SNAPSHOT + pom + + + UTF-8 + UTF-8 + C:/Users/wpilibj-buildmaster/maven-repository + + + + + + + org.codehaus.mojo + native-maven-plugin + 1.0-alpha-7 + true + + + ccppc + ccppc* + + + -g -mcpu=603 -mstrict-align -mno-implicit-fp -mlongcall -ansi -Wall -mlongcall -IC:/WindRiver/vxworks-6.3/target/h/wrn/coreip + + + -DCPU=PPC603 -DTOOL_FAMILY=gnu -DTOOL=gnu -D_WRS_KERNEL + + + + -r -nostdlib -Wl,-X -T C:/WindRiver/vxworks-6.3/target/h/tool/gnu/ldscripts/link.OUT + + + + + src/main/native + + **/*.cpp + + + + + + + + + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/maven-utilities/azalea/library-jar/pom.xml b/maven-utilities/azalea/library-jar/pom.xml new file mode 100644 index 0000000000..44080e33c4 --- /dev/null +++ b/maven-utilities/azalea/library-jar/pom.xml @@ -0,0 +1,111 @@ + + + 4.0.0 + edu.wpi.first.wpilib.templates.azalea + library-jar + pom + 0.1.0-SNAPSHOT + + + UTF-8 + UTF-8 + ${env.HOME}/sunspotfrcsdk + C:/Users/wpilibj-buildmaster/maven-repository + + + + + + com.sun.squawk + runtime + 0.1.0.qualifier + system + ${sunspot.home}/lib/squawk.jar + + + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.1 + + 1.3 + 1.2 + true + true + + + + org.codehaus.mojo + exec-maven-plugin + 1.2.1 + + + preverify + compile + + exec + + + ${sunspot.home}/bin/preverify + compile + + -d + ${project.build.directory}/classes + -classpath + + ${project.build.directory}/classes + + + + + + + org.apache.maven.plugins + maven-source-plugin + 2.2.1 + + + attach-sources + package + + jar-no-fork + + + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9.1 + + + attach-javadoc + package + + jar + + + + + + + + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/maven-utilities/azalea/pom.xml b/maven-utilities/azalea/pom.xml new file mode 100644 index 0000000000..4e060f9696 --- /dev/null +++ b/maven-utilities/azalea/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + edu.wpi.first.wpilib.templates + azalea + pom + 0.1.0-SNAPSHOT + + + static-library + cpp-executable + library-jar + + + + C:/Users/wpilibj-buildmaster/maven-repository + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/maven-utilities/azalea/static-library/pom.xml b/maven-utilities/azalea/static-library/pom.xml new file mode 100644 index 0000000000..01c1616731 --- /dev/null +++ b/maven-utilities/azalea/static-library/pom.xml @@ -0,0 +1,72 @@ + + + 4.0.0 + edu.wpi.first.wpilib.templates.azalea + static-library + 0.1.0-SNAPSHOT + pom + + + UTF-8 + UTF-8 + C:/Users/wpilibj-buildmaster/maven-repository + + + + + + + org.codehaus.mojo + native-maven-plugin + 1.0-alpha-7 + true + + + ccppc + ar + arppc* + + + -g -mcpu=603 -mstrict-align -mno-implicit-fp -mlongcall -ansi -Wall -mlongcall -IC:/WindRiver/vxworks-6.3/target/h/wrn/coreip + + + -DCPU=PPC603 -DTOOL_FAMILY=gnu -DTOOL=gnu -D_WRS_KERNEL + + + + crus + + + + + src/main/native + + **/*.cpp + + + + src/main/include + + + true + + + + + + + + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/maven-utilities/include/pom.xml b/maven-utilities/include/pom.xml new file mode 100644 index 0000000000..0d53f1ed3f --- /dev/null +++ b/maven-utilities/include/pom.xml @@ -0,0 +1,54 @@ + + + 4.0.0 + edu.wpi.first.wpilib.templates + include + 0.1.0-SNAPSHOT + pom + + + UTF-8 + UTF-8 + C:/Users/wpilibj-buildmaster/maven-repository + + + + + + + org.codehaus.mojo + native-maven-plugin + 1.0-alpha-7 + true + + + echo + echo* + + + + src/main/include + + + true + + + + + + + + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/maven-utilities/pom.xml b/maven-utilities/pom.xml new file mode 100644 index 0000000000..abdd5ee17b --- /dev/null +++ b/maven-utilities/pom.xml @@ -0,0 +1,30 @@ + + + 4.0.0 + edu.wpi.first.wpilib + templates + pom + 0.1.0-SNAPSHOT + + + athena + azalea + include + + + + C:/Users/wpilibj-buildmaster/maven-repository + + + + jenkins + + + myrepository + file:${local-repository} + + + + + diff --git a/networktables/.gitignore b/networktables/.gitignore new file mode 100644 index 0000000000..0cd54c0a43 --- /dev/null +++ b/networktables/.gitignore @@ -0,0 +1,5 @@ +*~ +target/ +build/ +dist/ +/OutlineViewer/nbproject/private/ \ No newline at end of file diff --git a/networktables/IterativeNetworkTablesTest/build.properties b/networktables/IterativeNetworkTablesTest/build.properties new file mode 100644 index 0000000000..db3b66e3bd --- /dev/null +++ b/networktables/IterativeNetworkTablesTest/build.properties @@ -0,0 +1,11 @@ +# Properties file for a Sun Spot Application +# +# build.properties +# +# This file is the default location for user properties that over-ride the +# defaults in ${sunspot.home}/default.properties. See that file for a full +# listing of the properties that may be set. This file is minimal and contains +# only those properties that a user would generally need to set right away. +# +#user.classpath=${wpilibj.home}/classes.jar +user.classpath=${wpilibj.home}/src diff --git a/networktables/IterativeNetworkTablesTest/build.xml b/networktables/IterativeNetworkTablesTest/build.xml new file mode 100644 index 0000000000..f51c532e56 --- /dev/null +++ b/networktables/IterativeNetworkTablesTest/build.xml @@ -0,0 +1,93 @@ + + + + + + + + + + + + + \ No newline at end of file diff --git a/networktables/IterativeNetworkTablesTest/nbproject/project.bak.xml b/networktables/IterativeNetworkTablesTest/nbproject/project.bak.xml new file mode 100644 index 0000000000..7f5536edd7 --- /dev/null +++ b/networktables/IterativeNetworkTablesTest/nbproject/project.bak.xml @@ -0,0 +1,92 @@ + + + org.netbeans.modules.ant.freeform + + + Iterative Network Tables Test + + ${user.home}/.sunspotfrc.properties + build.properties + ${sunspot.home}/default.properties + + + + + java + src + + + + + jar-app + + + clean + + + deploy + run + + + clean + jar-app + + + deploy + debug-run + + + javadoc + + + + folder + build + jar-app + + + + + + src + + + build.xml + + + + + + + + + + + + deploy + + + + jar-deploy + + + + + + + + + src + ${sunspot.home}\lib\squawk.jar + D:\Projects\WPILibJ-trunk\WPILibJ\dist\lib\wpilibj.jar;D:\Projects\NetworkTables2.0\trunk\java\dist\lib\networktables-crio.jar;${sunspot.home}\lib\sunit-server.jar + build + 1.4 + + + + diff --git a/networktables/IterativeNetworkTablesTest/nbproject/project.xml b/networktables/IterativeNetworkTablesTest/nbproject/project.xml new file mode 100644 index 0000000000..7f5536edd7 --- /dev/null +++ b/networktables/IterativeNetworkTablesTest/nbproject/project.xml @@ -0,0 +1,92 @@ + + + org.netbeans.modules.ant.freeform + + + Iterative Network Tables Test + + ${user.home}/.sunspotfrc.properties + build.properties + ${sunspot.home}/default.properties + + + + + java + src + + + + + jar-app + + + clean + + + deploy + run + + + clean + jar-app + + + deploy + debug-run + + + javadoc + + + + folder + build + jar-app + + + + + + src + + + build.xml + + + + + + + + + + + + deploy + + + + jar-deploy + + + + + + + + + src + ${sunspot.home}\lib\squawk.jar + D:\Projects\WPILibJ-trunk\WPILibJ\dist\lib\wpilibj.jar;D:\Projects\NetworkTables2.0\trunk\java\dist\lib\networktables-crio.jar;${sunspot.home}\lib\sunit-server.jar + build + 1.4 + + + + diff --git a/networktables/IterativeNetworkTablesTest/resources/META-INF/MANIFEST.MF b/networktables/IterativeNetworkTablesTest/resources/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..a3b50ce99b --- /dev/null +++ b/networktables/IterativeNetworkTablesTest/resources/META-INF/MANIFEST.MF @@ -0,0 +1,6 @@ +MIDlet-Name: Iterative Network Tables Test +MIDlet-Version: 1.0.0 +MIDlet-Vendor: FIRST +MIDlet-1: RobotTemplate, , edu.wpi.first.wpilibj.templates.RobotTemplate +MicroEdition-Profile: IMP-1.0 +MicroEdition-Configuration: CLDC-1.1 diff --git a/networktables/IterativeNetworkTablesTest/src/edu/wpi/first/wpilibj/templates/RobotTemplate.java b/networktables/IterativeNetworkTablesTest/src/edu/wpi/first/wpilibj/templates/RobotTemplate.java new file mode 100644 index 0000000000..4186a6630d --- /dev/null +++ b/networktables/IterativeNetworkTablesTest/src/edu/wpi/first/wpilibj/templates/RobotTemplate.java @@ -0,0 +1,140 @@ +/*----------------------------------------------------------------------------*/ +/* Copyright (c) FIRST 2008. All Rights Reserved. */ +/* Open Source Software - may be modified and shared by FRC teams. The code */ +/* must be accompanied by the FIRST BSD license file in the root directory of */ +/* the project. */ +/*----------------------------------------------------------------------------*/ + +package edu.wpi.first.wpilibj.templates; + + +import com.sun.squawk.GC; +import com.sun.squawk.VM; +import edu.wpi.first.wpilibj.IterativeRobot; +import edu.wpi.first.wpilibj.networktables.NetworkTable; +import java.io.IOException; +import java.util.Hashtable; + +/** + * The VM is configured to automatically run this class, and to call the + * functions corresponding to each mode, as described in the IterativeRobot + * documentation. If you change the name of this class or the package after + * creating this project, you must also update the manifest file in the resource + * directory. + */ +public class RobotTemplate extends IterativeRobot { + int numVars = 100; + + static { + try { + NetworkTable.setServerMode(); + NetworkTable.initialize(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + + NetworkTable table = NetworkTable.getTable("SmartDashboard"); + //Hashtable table = new Hashtable(); + String[] vars = new String[numVars]; + { + for (int i = 0; i < numVars; i++) { + vars[i] = "Variable"+i; + } + } + + double counter = 1; + boolean value = false; + + public void teleopInit() { + totTime = System.currentTimeMillis() - startTime; + waitTime = VM.Stats.getTotalWaitTime() - waitTime; + System.out.println("Baseline CPU Usage: "+(100*(1-(waitTime/((double) totTime))))+"%"); + System.out.println("\n"); + counter = 0; + initProfiling(); + } + + /** + * This function is called periodically during operator control + */ + public void teleopPeriodic() { + counter++; + value = !value; + for (int v = 0; v < numVars; v++) { + table.putBoolean(vars[v], value); + //table.putNumber(vars[v], counter); + //table.putBoolean(vars[v], value); + //table.putString(vars[v], "String"); + } + } + + public void disabledInit() { + endProfiling(); + printReport(numVars, counter); + startTime = System.currentTimeMillis(); + waitTime = VM.Stats.getTotalWaitTime(); + } + + long startTime, totTime, waitTime, gcTime, bytesAllocated; + Object monitor; + public void initProfiling() { + contentions = VM.Stats.getContendedMontorEnterCount(); + monitors = VM.Stats.getMonitorsAllocatedCount(); + threadSwitches = VM.Stats.getThreadSwitchCount(); + exceptions = VM.Stats.getThrowCount(); + waitTime = VM.Stats.getTotalWaitTime(); + + monitor = new Object(); + bytesAllocated = GC.getCollector().getBytesAllocatedTotal(); + VM.collectGarbage(true); + gcTime = GC.getCollector().getTotalGCTime(); + startTime = System.currentTimeMillis(); + } + + double runTime; + int contentions, monitors, threadSwitches, exceptions; + public void endProfiling() { + totTime = System.currentTimeMillis() - startTime; + bytesAllocated = GC.getCollector().getBytesAllocatedTotal() - bytesAllocated; + //VM.collectGarbage(true); + gcTime = GC.getCollector().getTotalGCTime() - gcTime; + + runTime = ((double) totTime)/1000; + contentions = VM.Stats.getContendedMontorEnterCount() - contentions; + VM.Stats.getMonitorsAllocatedCount(); + monitors = VM.Stats.getMonitorsAllocatedCount() - monitors; + threadSwitches = VM.Stats.getThreadSwitchCount() - threadSwitches; + exceptions = VM.Stats.getThrowCount() - exceptions; + waitTime = VM.Stats.getTotalWaitTime() - waitTime; + } + + public void printReport(int numVars, double loops) { + System.out.println("REPORT:"); + System.out.println("Test of "+numVars+" vars and "+loops+" loops took " + +runTime+" seconds."); + System.out.println("CPU Usage: "+(100*(1-(waitTime/((double) totTime))))+"%"); + System.out.println(); + System.out.println("Update Frequency (updates/second): "+ + (((double)(numVars*loops))/(runTime-(((double)waitTime)/1000)))); + System.out.println("Time per update (microseconds/update): "+ + (1000000*(runTime-(((double)waitTime)/1000))/((double)(numVars*loops)))); + System.out.println("Bytes Allocated: "+bytesAllocated); + System.out.println("Bytes per update (bytes/update): "+ + (bytesAllocated/((double)(numVars*loops)))); + System.out.println("GC Time (ms): "+gcTime); + System.out.println("GCTime per update (microseconds/update): "+ + (1000*gcTime/((double)(numVars*loops)))); + System.out.println(); + System.out.println("Number of contentions: "+contentions); + System.out.println("Number of monitors used: "+monitors); + System.out.println("Number of thread switches: "+threadSwitches); + System.out.println("Number of exceptions: "+exceptions); + System.out.println("Time spent waiting on IO: "+waitTime); + System.out.println(); + //VM.Stats.printHeapStats(monitor, false); + + + System.out.println(); System.out.println(); + } +} diff --git a/networktables/NetworkTableViewer/build.xml b/networktables/NetworkTableViewer/build.xml new file mode 100644 index 0000000000..ef802797f8 --- /dev/null +++ b/networktables/NetworkTableViewer/build.xml @@ -0,0 +1,53 @@ + + Builds, tests, and runs the project JavaNetworkTableViewer. + + + diff --git a/networktables/NetworkTableViewer/lib/nblibraries.properties b/networktables/NetworkTableViewer/lib/nblibraries.properties new file mode 100644 index 0000000000..2f89633424 --- /dev/null +++ b/networktables/NetworkTableViewer/lib/nblibraries.properties @@ -0,0 +1,18 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar +libs.CopyLibs.displayName=CopyLibs Task +libs.CopyLibs.prop-version=1.0 +libs.junit.classpath=\ + ${base}/junit/junit-3.8.2.jar +libs.junit.displayName=JUnit 3.8.2 +libs.junit.javadoc=\ + ${base}/junit/junit-3.8.2-api.zip +libs.junit.prop-maven-dependencies=junit:junit:3.8.2:jar +libs.junit_4.classpath=\ + ${base}/junit_4/junit-4.10.jar +libs.junit_4.displayName=JUnit 4.10 +libs.junit_4.javadoc=\ + ${base}/junit_4/junit-4.10-javadoc.jar +libs.junit_4.prop-maven-dependencies=junit:junit:4.10:jar +libs.junit_4.src=\ + ${base}/junit_4/junit-4.10-sources.jar diff --git a/networktables/NetworkTableViewer/lib/networktables-desktop.jar b/networktables/NetworkTableViewer/lib/networktables-desktop.jar new file mode 100644 index 0000000000..1c88da9b87 Binary files /dev/null and b/networktables/NetworkTableViewer/lib/networktables-desktop.jar differ diff --git a/networktables/NetworkTableViewer/manifest.mf b/networktables/NetworkTableViewer/manifest.mf new file mode 100644 index 0000000000..328e8e5bc3 --- /dev/null +++ b/networktables/NetworkTableViewer/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/networktables/NetworkTableViewer/nbproject/build-impl.xml b/networktables/NetworkTableViewer/nbproject/build-impl.xml new file mode 100644 index 0000000000..ce72d2f2f8 --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/build-impl.xml @@ -0,0 +1,1470 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set platform.home + Must set platform.bootcp + Must set platform.java + Must set platform.javac + + The J2SE Platform is not correctly set up. + Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. + Either open the project in the IDE and setup the Platform with the same name or add it manually. + For example like this: + ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) + or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + ${platform.java} -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + ${platform.java} -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/networktables/NetworkTableViewer/nbproject/configs/Run_as_WebStart.properties b/networktables/NetworkTableViewer/nbproject/configs/Run_as_WebStart.properties new file mode 100644 index 0000000000..670fff03e4 --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/configs/Run_as_WebStart.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +$label=Run as WebStart diff --git a/networktables/NetworkTableViewer/nbproject/configs/Run_in_Browser.properties b/networktables/NetworkTableViewer/nbproject/configs/Run_in_Browser.properties new file mode 100644 index 0000000000..f2a5a657cc --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/configs/Run_in_Browser.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +$label=Run in Browser diff --git a/networktables/NetworkTableViewer/nbproject/genfiles.properties b/networktables/NetworkTableViewer/nbproject/genfiles.properties new file mode 100644 index 0000000000..36a1d767f0 --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=c8c66866 +build.xml.script.CRC32=d06c8c20 +build.xml.stylesheet.CRC32=28e38971@1.56.1.46 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=9e01e615 +nbproject/build-impl.xml.script.CRC32=31676db4 +nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46 diff --git a/networktables/NetworkTableViewer/nbproject/jfx-impl.xml b/networktables/NetworkTableViewer/nbproject/jfx-impl.xml new file mode 100644 index 0000000000..f7a88ecc28 --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/jfx-impl.xml @@ -0,0 +1,3213 @@ + + + + + JavaFX-specific Ant calls + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${cssfileslist} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/networktables/NetworkTableViewer/nbproject/private/configs/Run_as_WebStart.properties b/networktables/NetworkTableViewer/nbproject/private/configs/Run_as_WebStart.properties new file mode 100644 index 0000000000..e8be0ee398 --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/private/configs/Run_as_WebStart.properties @@ -0,0 +1,4 @@ +# Do not modify this property in this configuration. It can be re-generated. +$label=Run as WebStart +# Do not modify this property in this configuration. It can be re-generated. +javafx.run.as=webstart diff --git a/networktables/NetworkTableViewer/nbproject/private/configs/Run_in_Browser.properties b/networktables/NetworkTableViewer/nbproject/private/configs/Run_in_Browser.properties new file mode 100644 index 0000000000..1be80d6a11 --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/private/configs/Run_in_Browser.properties @@ -0,0 +1,4 @@ +# Do not modify this property in this configuration. It can be re-generated. +$label=Run in Browser +# Do not modify this property in this configuration. It can be re-generated. +javafx.run.as=embedded diff --git a/networktables/NetworkTableViewer/nbproject/private/private.properties b/networktables/NetworkTableViewer/nbproject/private/private.properties new file mode 100644 index 0000000000..3b3de5ccbf --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/private/private.properties @@ -0,0 +1,12 @@ +auxiliary.org-netbeans-modules-projectapi.issue214819_5f_fx_5f_enabled=true +compile.on.save=true +do.depend=false +do.jar=true +# No need to modify this property unless customizing JavaFX Ant task infrastructure +endorsed.javafx.ant.classpath=. +javac.debug=true +javadoc.preview=true +javafx.run.as=standalone +javafx.run.inbrowser= +javafx.run.inbrowser.path=C:\\Users\\Sam\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe +user.properties.file=C:\\Users\\Sam\\AppData\\Roaming\\NetBeans\\7.3\\build.properties diff --git a/networktables/NetworkTableViewer/nbproject/private/private.xml b/networktables/NetworkTableViewer/nbproject/private/private.xml new file mode 100644 index 0000000000..475096252c --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/networktables/NetworkTableViewer/nbproject/project.properties b/networktables/NetworkTableViewer/nbproject/project.properties new file mode 100644 index 0000000000..dc3b352b19 --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/project.properties @@ -0,0 +1,120 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=NetworkTableViewer +application.vendor= +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +compile.on.save=true +compile.on.save.unsupported.javafx=true +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/NetworkTableViewer.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.networktables-desktop.jar=lib\\networktables-desktop.jar +includes=** +# Non-JavaFX jar file creation is deactivated in JavaFX 2.0+ projects +jar.archive.disabled=true +jar.compress=false +javac.classpath=\ + ${javafx.runtime}/lib/jfxrt.jar:\ + ${javafx.runtime}/lib/deploy.jar:\ + ${javafx.runtime}/lib/javaws.jar:\ + ${javafx.runtime}/lib/plugin.jar:\ + ${file.reference.networktables-desktop.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=true +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +javafx.binarycss=false +javafx.deploy.adddesktopshortcut=false +javafx.deploy.addstartmenushortcut=false +javafx.deploy.allowoffline=true +# If true, application update mode is set to 'background', if false, update mode is set to 'eager' +javafx.deploy.backgroundupdate=false +javafx.deploy.embedJNLP=true +javafx.deploy.includeDT=true +javafx.deploy.installpermanently=false +javafx.deploy.permissionselevated=true +# Set true to prevent creation of temporary copy of deployment artifacts before each run (disables concurrent runs) +javafx.disable.concurrent.runs=false +# Set true to enable multiple concurrent runs of the same WebStart or Run-in-Browser project +javafx.enable.concurrent.external.runs=false +# This is a JavaFX project +javafx.enabled=true +javafx.fallback.class=com.javafx.main.NoJavaFXFallback +# Main class for JavaFX +javafx.main.class=edu.wpi.first.tableviewer.NetworkTableViewer +javafx.native.bundling.enabled=false +javafx.native.bundling.type=all +javafx.preloader.class= +# This project does not use Preloader +javafx.preloader.enabled=false +javafx.preloader.jar.filename= +javafx.preloader.jar.path= +javafx.preloader.project.path= +javafx.preloader.type=none +# Set true for GlassFish only. Rebases manifest classpaths of JARs in lib dir. Not usable with signed JARs. +javafx.rebase.libs=false +javafx.run.height=600 +javafx.run.width=800 +javafx.runtime=${platforms.JDK_1.7.0_21.javafx.runtime.home} +javafx.sdk=${platforms.JDK_1.7.0_21.javafx.sdk.home} +javafx.signing.enabled=true +javafx.signing.type=self +# Pre-JavaFX 2.0 WebStart is deactivated in JavaFX 2.0+ projects +jnlp.enabled=false +# Main class for Java launcher +main.class=com.javafx.main.Main +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=JDK_1.7.0_21 +run.classpath=\ + ${dist.jar}:\ + ${javac.classpath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +source.reference.networktables-desktop.jar=../java/dist/desktop-lib/networktables-desktop.src.zip +src.dir=src +test.src.dir=test diff --git a/networktables/NetworkTableViewer/nbproject/project.xml b/networktables/NetworkTableViewer/nbproject/project.xml new file mode 100644 index 0000000000..341c9f1e8b --- /dev/null +++ b/networktables/NetworkTableViewer/nbproject/project.xml @@ -0,0 +1,35 @@ + + + org.netbeans.modules.java.j2seproject + + + + + + + + + + + + + + + + NetworkTableViewer + + + + + + + + + + .\lib\nblibraries.properties + + + popup + + + diff --git a/networktables/NetworkTableViewer/src.zip b/networktables/NetworkTableViewer/src.zip new file mode 100644 index 0000000000..f7bfe5c278 Binary files /dev/null and b/networktables/NetworkTableViewer/src.zip differ diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/NetworkTableViewer.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/NetworkTableViewer.java new file mode 100644 index 0000000000..1cb6367de6 --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/NetworkTableViewer.java @@ -0,0 +1,27 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer; + +import edu.wpi.first.tableviewer.popup.PreferencesPopup; +import edu.wpi.first.tableviewer.treeview.TableTreeView; + +import javafx.application.Application; +import javafx.stage.Stage; + +/** + * + * @author Sam + */ +public class NetworkTableViewer extends Application { + + @Override + public void start(Stage stage) { + PreferencesPopup preferencesPopup = new PreferencesPopup(); + preferencesPopup.showPopup(); + + TableTreeView view = new TableTreeView(preferencesPopup.getNode()); + view.show(); + } +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/AddValuePopup.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/AddValuePopup.java new file mode 100644 index 0000000000..b0a246f382 --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/AddValuePopup.java @@ -0,0 +1,159 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +import edu.wpi.first.wpilibj.tables.ITable; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Control; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.GridPane; +import javafx.scene.paint.Color; +import javafx.stage.Modality; + +/** + * + * @author Sam + */ +class AddValuePopup extends Popup { + + public enum InputType { + BOOLEAN, NUMBER, STRING, SUBTABLE + } + + private final InputType type; + private final ITable table; + + public AddValuePopup(ITable table, InputType type) { + super(); + + this.table = table; + this.type = type; + + initModality(Modality.WINDOW_MODAL); + } + + @Override + public void showPopup() { + initComponents(); + showAndWait(); + } + + @Override + public void initComponents() { + initComponents(type); + } + + private void initComponents(final InputType type) { + final Scene scene = new Scene(new Group()); + scene.setFill(Color.WHITESMOKE); + scene.getStylesheets().add( + "edu/wpi/first/tableviewer/stylesheets/ViewerStyleSheet.css"); + final Label messageLabel = new Label(); + final Label keyLabel = new Label("Key:"); + final Label valueLabel = new Label("Value:"); + final TextField keyField = new TextField(); + final Button confirm = new Button("Add"); + + keyField.setPromptText("Key"); + keyField.setPrefWidth(100); + + final Control valueControl; + ObservableList booleanOptions = FXCollections.observableArrayList("True", "False"); + switch (type) { + case BOOLEAN: + messageLabel.setText("Add boolean"); + valueControl = new ComboBox(booleanOptions); + ((ComboBox) valueControl).getSelectionModel().select(0); + confirm.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + if (table.containsKey(keyField.getText())) { + PopupFactory.showErrorDialog("Key already in use!"); + } else { + table.putBoolean(keyField.getText(), ((ComboBox) valueControl).getSelectionModel().isSelected(0)); + close(); + } + } + }); + break; + case NUMBER: + messageLabel.setText("Add number"); + valueControl = new TextField(); + ((TextField) valueControl).setPromptText("Number"); + confirm.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + try { + if (table.containsKey(keyField.getText())) { + PopupFactory.showErrorDialog("Key already in use!"); + } else { + table.putNumber(keyField.getText(), Double.parseDouble(((TextField) valueControl).getText())); + close(); + } + } catch (NumberFormatException ex) { + PopupFactory.showErrorDialog("Invalid number!"); + } + } + }); + break; + case STRING: + messageLabel.setText("Add string"); + valueControl = new TextField(); + ((TextField) valueControl).setPromptText("Text"); + confirm.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + if (table.containsKey(keyField.getText())) { + PopupFactory.showErrorDialog("Key already in use!"); + } else { + table.putString(keyField.getText(), ((TextField) valueControl).getText()); + close(); + } + } + }); + break; + case SUBTABLE: + keyLabel.setText("Table name"); + keyField.setPromptText("Name"); + valueControl = null; + confirm.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + //TODO make a subtable show up without putting a value + ITable i = table.getSubTable(keyField.getText()); + close(); + } + }); + break; + default: + return; + } + + final GridPane grid = new GridPane(); + grid.setHgap(10); + grid.setVgap(5); + grid.add(keyLabel, 1, 1); + grid.add(keyField, 2, 1); + if (type != InputType.SUBTABLE) { + grid.add(valueLabel, 1, 2); + grid.add(valueControl, 2, 2); + valueControl.setPrefWidth(100); + } + grid.add(confirm, 2, 3); + + ((Group) scene.getRoot()).getChildren().add(grid); + setScene(scene); + + } +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/EditorPopup.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/EditorPopup.java new file mode 100644 index 0000000000..351091df09 --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/EditorPopup.java @@ -0,0 +1,128 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +import edu.wpi.first.tableviewer.treeview.TableLeaf; +import javafx.collections.FXCollections; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.GridPane; +import javafx.scene.paint.Color; + +/** + * + * @author Sam + */ +public class EditorPopup extends Popup { + + private final Label inputLabel = new Label(); + private final TextField inputField = new TextField(); + private final ComboBox booleanBox = new ComboBox(FXCollections.observableArrayList("True", "False")); + private final Button okayButton = new Button("OK"), + cancelButton = new Button("Cancel"); + + private final String itemType; + private final TableLeaf leaf; + + public EditorPopup(TableLeaf leaf) { + super("Edit Value", null, null); + this.leaf = leaf; + + String tableValue = leaf.getTableValue().toString(); + String tableKey = leaf.getTableKey(); + + inputLabel.setText(tableKey+":"); + + inputField.setText(tableValue); + inputField.setPromptText("New value"); + inputField.setPrefWidth(100); + + booleanBox.getSelectionModel().selectFirst(); + + itemType = leaf.getType().toString(); + cancelButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + close(); + } + }); + } + + @Override + public void initComponents() { + initComponents(itemType); + } + + private void initComponents(final String type) { + final Scene scene = new Scene(new Group()); + scene.setFill(Color.WHITESMOKE); + scene.getStylesheets().add( + "edu/wpi/first/tableviewer/stylesheets/ViewerStyleSheet.css"); + + final GridPane grid = new GridPane(); + grid.setHgap(10); + grid.setVgap(15); + grid.setPadding(new Insets(5, 5, 5, 5)); + grid.setAlignment(Pos.CENTER); + grid.add(inputLabel, 0, 1); + + ((Group) scene.getRoot()).getChildren().add(grid); + setScene(scene); + + switch (type.toLowerCase()) { + case "boolean": + grid.add(booleanBox, 1, 1); + okayButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + leaf.updateValue(booleanBox.getSelectionModel().isSelected(0)); + leaf.setExpanded(false); // refresh the leaf to updateValue the shown value + leaf.setExpanded(true); + close(); + } + }); + break; + case "number": + grid.add(inputField, 1, 1); + okayButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + try { + leaf.updateValue(Double.parseDouble(inputField.getText())); + leaf.setExpanded(false); // refresh the leaf to updateValue the shown value + leaf.setExpanded(true); + close(); + } catch (NumberFormatException ex) { + PopupFactory.showErrorDialog("Invalid number value!"); + } + } + }); + break; + case "string": + grid.add(inputField, 1, 1); + okayButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + leaf.updateValue(inputField.getText()); + leaf.setExpanded(false); // refresh the leaf to updateValue the shown value + leaf.setExpanded(true); + close(); + } + }); + break; + } + grid.add(okayButton, 0, 2); + grid.add(cancelButton, 1, 2); + + } +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/IPopup.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/IPopup.java new file mode 100644 index 0000000000..5b70890c17 --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/IPopup.java @@ -0,0 +1,35 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +/** + * An interface for defining popups. + * @author Sam + * @see Popup + * @see InputPopup + */ +public interface IPopup { + + /** + * An enumeration representing the type of popup this is. + */ + public enum Type { + MESSAGE, + WARNING, + ERROR, + INPUT + } + + /** + * A method used to show this popup. + */ + public void showPopup(); + + /** + * Initialize all components in this popup. + */ + public void initComponents(); + +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/Popup.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/Popup.java new file mode 100644 index 0000000000..e97df7e5f8 --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/Popup.java @@ -0,0 +1,115 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.scene.text.TextAlignment; +import javafx.stage.Modality; +import javafx.stage.Stage; + +/** + * A generic popup. Call + * {@link PopupFactory Popupfactory}.{@code showXXXXDialog()} to show a + * predefined popup of a specific type. + * + * @see IPopup + * @see InputPopup + * @see PopupFactory + * @author Sam + */ +class Popup extends Stage implements IPopup { + + protected final String message; + protected final Type type; + + Popup() { + this(null, null, Type.INPUT); + } + + Popup(String title, String message, Type type) { + super(); + this.message = message; + this.type = type; + + setTitle(title); + setWidth(200); + setHeight(150); + setResizable(false); + + initModality(Modality.WINDOW_MODAL); + } + + private void initComponents(Type messageType) { + final Scene scene = new Scene(new Group()); + scene.setFill(Color.WHITESMOKE); + final Label messageText = new Label(message); + final Button okayButton = new Button("Okay"); + final VBox box = new VBox(); + + messageText.setAlignment(Pos.CENTER); + messageText.setTextAlignment(TextAlignment.CENTER); + messageText.setWrapText(true); + okayButton.setAlignment(Pos.CENTER); + + okayButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + close(); + } + }); + + String messageClass = ""; + switch (messageType) { + case MESSAGE: + messageClass = ""; + box.setPadding(new Insets(10, 0, 0, 0)); + break; + case WARNING: + messageClass = "warning-"; + box.setPadding(new Insets(10, 0, 0, 0)); + break; + case ERROR: + messageClass = "error-"; + box.setPadding(new Insets(30, 0, 0, 0)); + break; + default: + break; + } + + scene.getStylesheets().add( + "edu/wpi/first/tableviewer/stylesheets/PopupCSS.css"); + messageText.getStyleClass().add(messageClass + "message"); + + box.setPrefWidth(200); + box.setSpacing(15); + box.setAlignment(Pos.CENTER); + + box.getChildren().addAll(messageText, okayButton); + + ((Group) scene.getRoot()).getChildren().addAll(box); + + setScene(scene); + } + + @Override + public void initComponents() { + initComponents(type); + } + + @Override + public void showPopup() { + initComponents(); + showAndWait(); + } +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/PopupFactory.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/PopupFactory.java new file mode 100644 index 0000000000..9867130c54 --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/PopupFactory.java @@ -0,0 +1,65 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +import edu.wpi.first.tableviewer.popup.IPopup.Type; +import edu.wpi.first.tableviewer.popup.AddValuePopup.InputType; +import edu.wpi.first.tableviewer.treeview.TableLeaf; +import edu.wpi.first.wpilibj.tables.ITable; + +/** + * A factory for creating and showing {@link Popup Popups} of a defined type. + * @author Sam + */ +public final class PopupFactory { + + public static void showMessageDialog(String title, String message) { + IPopup popup = new Popup(title, message, Type.MESSAGE); + popup.showPopup(); + } + + public static void showMessageDialog(String message) { + showMessageDialog("", message); + } + + public static void showWarningDialog(String title, String message) { + IPopup popup = new Popup(title, message, Type.WARNING); + popup.showPopup(); + } + + public static void showWarningDialog(String message) { + showWarningDialog("", message); + } + + public static void showErrorDialog(String title, String message) { + IPopup popup = new Popup(title, message, Type.ERROR); + popup.showPopup(); + } + + public static void showErrorDialog(String message) { + showErrorDialog("", message); + } + + public static void showAddBooleanDialog(ITable table) { + IPopup popup = new AddValuePopup(table, InputType.BOOLEAN); + popup.showPopup(); + } + + public static void showAddNumberDialog(ITable table) { + IPopup popup = new AddValuePopup(table, InputType.NUMBER); + popup.showPopup(); + } + + public static void showAddStringDialog(ITable table) { + IPopup popup = new AddValuePopup(table, InputType.STRING); + popup.showPopup(); + } + + public static void showEditorDialog(TableLeaf leaf) { + IPopup popup = new EditorPopup(leaf); + popup.showPopup(); + } + +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/PreferencesPopup.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/PreferencesPopup.java new file mode 100644 index 0000000000..95eaed86ad --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/popup/PreferencesPopup.java @@ -0,0 +1,136 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +import edu.wpi.first.tableviewer.NetworkTableViewer; +import edu.wpi.first.tableviewer.treeview.TableTreeView; + +import edu.wpi.first.wpilibj.networktables2.NetworkTableNode; +import edu.wpi.first.wpilibj.networktables2.client.NetworkTableClient; +import edu.wpi.first.wpilibj.networktables2.server.NetworkTableServer; +import edu.wpi.first.wpilibj.networktables2.stream.SocketStreams; + +import java.io.IOException; +import java.util.prefs.Preferences; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.CheckBox; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.GridPane; +import javafx.stage.WindowEvent; + +/** + * + * @author Sam + */ +public class PreferencesPopup extends Popup { + + public static final int DEFAULT_PORT = 1735; + private final Preferences prefs = Preferences.userNodeForPackage(NetworkTableViewer.class); + private String host = "localhost"; + private NetworkTableNode node; + + public PreferencesPopup() { + super("Preferences", null, null); + setWidth(215); + setHeight(160); + } + + public NetworkTableNode getNode() { + return node; + } + + @Override + public void initComponents() { + try { + host = prefs.get("host", "localhost"); + } catch (NullPointerException e) { + host = "localhost"; + } + + final Scene scene = new Scene(new Group()); + scene.getStylesheets().add("edu/wpi/first/tableviewer/stylesheets/ViewerStyleSheet.css"); + + final Label hostLabel = new Label("Host:"); + final CheckBox clientBox = new CheckBox("Client"); + clientBox.setSelected(true); // default to client + final TextField hostField = new TextField("localhost"); + final Button okayButton = new Button("OK"); + final Button cancelButton = new Button("Cancel"); + + hostField.setMaxWidth(100); + + hostField.setPromptText("Host"); + + hostField.setText(prefs.get("host", "localhost")); + + okayButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + try { + host = hostField.getText(); + if (clientBox.isSelected()) { // client + setClient(host, DEFAULT_PORT); + System.out.println("Connecting client to " + host + ":" + DEFAULT_PORT); + } else { // server + setServer(DEFAULT_PORT); + System.out.println("Starting server on port " + DEFAULT_PORT); + } + TableTreeView.setRootNode(node); + prefs.put("host", host); + close(); + } catch (NumberFormatException ex) { // invalid team number + PopupFactory.showErrorDialog("Invalid team number!"); + } catch (IOException ex) { + System.err.println("Error creating table node: " + + ex.getClass().toString().substring(ex.getClass().toString().lastIndexOf(".") + 1) + ": " + + ex.getMessage()); + } + } + }); + + cancelButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + System.exit(0); + } + }); + + setOnCloseRequest(new EventHandler() { + @Override + public void handle(WindowEvent t) { + System.exit(0); + } + }); + + GridPane grid = new GridPane(); + grid.setHgap(10); + grid.setVgap(5); + grid.add(clientBox, 1, 1); + grid.add(hostLabel, 1, 2); + grid.add(hostField, 2, 2); + grid.add(okayButton, 1, 3); + grid.add(cancelButton, 2, 3); + + ((Group) scene.getRoot()).getChildren().addAll(grid); + + setScene(scene); + } + + private void setServer(int port) throws IOException { + this.node = new NetworkTableServer(SocketStreams.newStreamProvider(port)); + } + + private void setClient(String host, int port) throws IOException { + this.node = new NetworkTableClient(SocketStreams.newStreamFactory(host, port)); + ((NetworkTableClient)node).reconnect(); + } + +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/stylesheets/PopupCSS.css b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/stylesheets/PopupCSS.css new file mode 100644 index 0000000000..92d7cff0ed --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/stylesheets/PopupCSS.css @@ -0,0 +1,32 @@ +/* + Document : ErrorMessageCSS + Created on : Apr 23, 2013, 4:23:41 PM + Author : Sam + Description: + Purpose of the stylesheet follows. +*/ + +root { + display: block; + -fx-font-family: "Trebuchet MS"; + -fx-background: #000000; +} + +.message { + -fx-text-fill: #000000; /* black */ + -fx-font-size: 14pt; + -fx-font-weight: bold; +} + +.warning-message { + -fx-text-fill: #FF5500; /* yellow */ + -fx-font-size: 14pt; + -fx-font-weight: bold; +} + +/* Might need to change this*/ +.error-message { + -fx-text-fill: #CC0000; /* red */ + -fx-font-size: 14pt; + -fx-font-weight: bold; +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/stylesheets/ViewerStyleSheet.css b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/stylesheets/ViewerStyleSheet.css new file mode 100644 index 0000000000..e5ef25f3d8 --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/stylesheets/ViewerStyleSheet.css @@ -0,0 +1,71 @@ + +root { + display: block; + -fx-font-family: "Trebuchet MS"; +} + +.button { + -fx-text-fill: #111111; + -fx-border-color: #000000; + -fx-background-color: linear-gradient(#DDDDDD, #AAAAAA); + -fx-border-radius: 5; + -fx-padding: 3 6 6 6; +} + +.button:hover { + -fx-background-color: linear-gradient(#FFFFFF, #CCCCCC); +} + +.button:focused { + -fx-background-color: linear-gradient(#FFFFFF, #CCCCCC); +} + +.combo-box { + -fx-text-fill: #111111; + -fx-border-color: #000000; + -fx-background-color: linear-gradient(#DDDDDD, #AAAAAA); + -fx-border-radius: 5; +} + +.combo-box:focused { + -fx-background-color: linear-gradient(#FFFFFF, #CCCCCC); +} + +.text-field { + -fx-text-fill: #111111; + -fx-prompt-text-fill: #444444; + -fx-border-color: #000000; + -fx-background-color: #CCCCCC; + -fx-border-radius: 5; +} + +.text-field:focused { + -fx-background-color: #EEEEEE; +} + +.scroll-bar .track{ + -fx-background-color: #EFEFEF; +} + +.scroll-bar .thumb { + -fx-background-color: linear-gradient(to right, #AAAAAA, #CCCCCC); + -fx-border-radius: 5; +} + +.tree-cell { + -fx-font: 12pt "Trebuchet MS"; + -fx-text-fill: #111111; + -fx-border-color: #DDDDFF; +} + +.tree-cell:selected:focused { + -fx-background-color: #CCCCCC; +} + +.tree-cell:odd { + -fx-background-color: rgb(240,240,255); +} + +.tree-cell:even { + -fx-background-color: rgb(255,255,255); +} \ No newline at end of file diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/ITableItem.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/ITableItem.java new file mode 100644 index 0000000000..15ad57caef --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/ITableItem.java @@ -0,0 +1,24 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.treeview; + +import javafx.scene.control.TreeItem; + +/** + * + * @author Sam + */ +public abstract class ITableItem extends TreeItem { + + public ITableItem() { + super(); + } + + @Override + public abstract String toString(); + + @Override + public abstract boolean isLeaf(); +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableBranch.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableBranch.java new file mode 100644 index 0000000000..fff45bff3e --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableBranch.java @@ -0,0 +1,119 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.treeview; + +import edu.wpi.first.wpilibj.networktables.NetworkTableProvider; +import edu.wpi.first.wpilibj.networktables2.NetworkTableNode; +import edu.wpi.first.wpilibj.tables.ITable; +import edu.wpi.first.wpilibj.tables.ITableListener; +import java.util.ArrayList; +import java.util.Collections; + +import java.util.HashMap; +import java.util.List; +import javafx.beans.property.SimpleBooleanProperty; + +import javafx.scene.control.TreeItem; + +/** + * A {@link TreeItem} responsible for displaying all the data within a certain + * {@link ITable}. It can contain {@link TableLeaf TableLeaves} and other + * {@code TableBranches} if there are subtables in the given {@code ITable}. + * + * @see TableLeaf + * @author Sam + */ +public class TableBranch extends ITableItem implements ITableListener { + + /** + * Keeps track of values in the table. + */ + private HashMap entries = new HashMap<>(); + private final ITable table; + + /** + * Constructs a TableBranch that displays data from the given ITable. + * + * @param table The ITable to show the data of. + */ + public TableBranch(final ITable table) { + super(); + this.table = table; + table.addTableListener(this, true); + table.addSubTableListener(this); + setExpanded(true); + setValue(this); + expandedProperty().bind(new SimpleBooleanProperty(true)); //REMOVEME + } + + /** + * This should only be called once, when making the root TableBranch. + * + * @param node The root node to listen to. Sibling or parent nodes, if they + * exist, will be ignored. + * @see TableBranch(ITable) + */ + public TableBranch(NetworkTableNode node) { + this(new NetworkTableProvider(node).getRootTable()); + } + + @Override + public void valueChanged(ITable source, String key, Object value, boolean isNew) { + if (isNew && !entries.containsKey(key)) { + if (value.toString().startsWith("NetworkTable: /")) { + String tableName = value.toString().substring(source.toString().length() + 1); + TableBranch branch = new TableBranch(source.getSubTable(tableName)); + this.getChildren().add(branch); + entries.put(key, branch); + } else { + TableLeaf leaf = new TableLeaf(source, key, value); + entries.put(key, leaf); + this.getChildren().add(leaf); + this.getChildren().removeAll(getLeaves()); + this.getChildren().addAll(sortLeaves(getLeaves())); + } + } else if (!isNew && entries.get(key) instanceof TableLeaf) { + ((TableLeaf) entries.get(key)).setTableValue(value); + } + } + + /** + * Sorts + * + * @param leaves + * @return + */ + private List sortLeaves(List leaves) { + List list = leaves.subList(0, leaves.size()); + System.out.print(leaves + "->" + list + "\t"); + Collections.sort(list); + System.out.println(list); + return list; + } + + private List getLeaves() { + List leaves = new ArrayList<>(); + for (ITableItem item : entries.values()) { + if (item instanceof TableLeaf) { + leaves.add((TableLeaf) item); + } + } + return leaves; + } + + public ITable getTable() { + return table; + } + + @Override + public boolean isLeaf() { + return false; + } + + @Override + public String toString() { + return table.toString().substring(table.toString().lastIndexOf("/") + 1); + } +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableLeaf.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableLeaf.java new file mode 100644 index 0000000000..ab70bb89cd --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableLeaf.java @@ -0,0 +1,102 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.treeview; + +import edu.wpi.first.wpilibj.tables.ITable; + +/** + * + * @author Sam + */ +public class TableLeaf extends ITableItem implements Comparable { + + private final ITable table; + private String entryKey; + private Object entryValue; + private EntryType entryType = EntryType.UNSUPPORTED; + + @Override + public int compareTo(Object o) { + return this.getTableKey().toLowerCase().compareTo(((TableLeaf)o).getTableKey().toLowerCase()); + } + + public enum EntryType { + BOOLEAN, NUMBER, STRING, UNSUPPORTED + } + + public TableLeaf(ITable table, String key, Object value) { + super(); + this.table = table; + this.entryKey = key; + this.entryValue = value; + this.entryType = getTypeFromValue(value); + setValue(this); + } + + public ITable getTable() { + return table; + } + + public String getTableKey() { + return entryKey; + } + + public Object getTableValue() { + return entryValue; + } + + /** + * Sets the display value of this TableLeaf to a new value. + * + * @param newValue The new value of this leaf. + */ + public void setTableValue(Object newValue) { + entryValue = newValue; + entryType = getTypeFromValue(newValue); + setValue(null); + setValue(this); + + } + + private EntryType getTypeFromValue(Object value) { + String valueClassName = value.getClass().toString().substring(value.getClass().toString().lastIndexOf(".") + 1); + switch (valueClassName.toLowerCase()) { + case "boolean": + return EntryType.BOOLEAN; + case "double": + return EntryType.NUMBER; + case "string": + return EntryType.STRING; + default: + return EntryType.UNSUPPORTED; + } + } + + /** + * Updates the value in this TableLeaf's ITable and updates the displayed + * value. + * + * @param newValue The new value of this entry. + * @see #setTableValue + */ + public void updateValue(Object newValue) { + setTableValue(newValue); + table.putValue(entryKey, entryValue); + } + + public EntryType getType() { + return entryType; + } + + @Override + public String toString() { + return entryKey + " = " + entryValue; + } + + @Override + public boolean isLeaf() { + return true; + } +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableTreeCell.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableTreeCell.java new file mode 100644 index 0000000000..f0873633b9 --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableTreeCell.java @@ -0,0 +1,143 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.treeview; + +import edu.wpi.first.tableviewer.popup.PopupFactory; +import edu.wpi.first.tableviewer.treeview.TableLeaf.EntryType; +import java.util.ArrayList; +import java.util.List; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.control.ContextMenu; +import javafx.scene.control.Label; +import javafx.scene.control.MenuItem; +import javafx.scene.control.TreeCell; +import javafx.scene.input.MouseEvent; +import javafx.scene.layout.GridPane; + +/** + * + * @author Sam + */ +public class TableTreeCell extends TreeCell { + + private GridPane grid = new GridPane(); + private Label key = new Label(), + value = new Label(), + type = new Label(); + + // Very hackish but it almost works. Just don't collapse tables. + // I blame JavaFX/Patrick for making me do this. + private static List cells = new ArrayList<>(); + private static int currentCell = 0; + private static int maxCells = 200; + + static { + for (int i = 0; i < maxCells; i++) { + cells.add(new TableTreeCell()); + } + } + + public static TableTreeCell getCell() { + if (currentCell >= maxCells) { + currentCell = 0; + } + return cells.get(currentCell++); + } + + private TableTreeCell() { + super(); + genGrid(); + this.setOnMouseClicked(new EventHandler() { + @Override + public void handle(MouseEvent t) { + ITableItem selected = getItem(); + if (selected instanceof TableLeaf && t.getClickCount() == 2) { + TableLeaf leaf = (TableLeaf) selected; + PopupFactory.showEditorDialog(leaf); + } + } + }); + } + + private void genGrid() { + key.setPrefWidth(50); + value.setPrefWidth(125); + type.setPrefWidth(75); + grid.add(key, 0, 0); + grid.add(value, 1, 0); + grid.add(type, 2, 0); + grid.setHgap(15); + } + + @Override + public void updateItem(ITableItem tableItem, boolean empty) { + super.updateItem(tableItem, empty); + if (tableItem != null && !empty) { + if (tableItem instanceof TableBranch) { + setContextMenu(getBranchMenu((TableBranch) tableItem)); + setText(tableItem.toString()); + setGraphic(null); + } else if (tableItem instanceof TableLeaf) { + TableLeaf leaf = (TableLeaf) tableItem; + + key.setText(leaf.getTableKey()); + value.setText(leaf.getTableValue().toString()); + type.setText(leaf.getType().name()); + + setText(null); + setGraphic(grid); + setContextMenu(getLeafMenu(leaf)); + } + } + } + + private ContextMenu getBranchMenu(final TableBranch branch) { + MenuItem addBoolean = new MenuItem("Add boolean"); + MenuItem addNumber = new MenuItem("Add number"); + MenuItem addString = new MenuItem("Add string"); + + addBoolean.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + PopupFactory.showAddBooleanDialog(branch.getTable()); + } + }); + + addNumber.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + PopupFactory.showAddNumberDialog(branch.getTable()); + } + }); + + addString.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + PopupFactory.showAddStringDialog(branch.getTable()); + } + }); + + ContextMenu cMenu = new ContextMenu(); + cMenu.getItems().addAll(addBoolean, addNumber, addString); + return cMenu; + } + + private ContextMenu getLeafMenu(final TableLeaf leaf) { + MenuItem edit = new MenuItem("Edit"); + + edit.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + PopupFactory.showEditorDialog(leaf); + } + }); + + ContextMenu cMenu = new ContextMenu(edit); + return cMenu; + + } +} diff --git a/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableTreeView.java b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableTreeView.java new file mode 100644 index 0000000000..568570e5c0 --- /dev/null +++ b/networktables/NetworkTableViewer/src/edu/wpi/first/tableviewer/treeview/TableTreeView.java @@ -0,0 +1,74 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.treeview; + +import edu.wpi.first.wpilibj.networktables2.NetworkTableNode; +import edu.wpi.first.wpilibj.networktables2.server.NetworkTableServer; + +import javafx.event.EventHandler; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.TreeCell; +import javafx.scene.control.TreeItem; +import javafx.scene.control.TreeView; +import javafx.stage.Stage; +import javafx.stage.WindowEvent; +import javafx.util.Callback; + +/** + * + * @author Sam + */ +public class TableTreeView extends Stage { + + private TreeView tree; + private static NetworkTableNode rootNode; + + public static void setRootNode(NetworkTableNode node) { + rootNode = node; + } + + public TableTreeView(NetworkTableNode node) { + Scene scene = initTree(); + setTitle("Network Table Viewer " + ((node instanceof NetworkTableServer) ? "Server" : "Client")); + setMinHeight(500); + setMinWidth(360); + setScene(scene); + setOnCloseRequest(new EventHandler() { + @Override + public void handle(WindowEvent t) { + // network tables keep the application running, so exit + System.exit(0); + } + }); + } + + private Scene initTree() { + Scene scene = new Scene(new Group()); + + scene.getStylesheets().add("edu/wpi/first/tableviewer/stylesheets/ViewerStyleSheet.css"); + TableBranch rootBranch = new TableBranch(rootNode); // create a branch to show the entire contents of the node + + TreeItem root = new TreeItem<>(); + root.getChildren().add(rootBranch); + + tree = new TreeView(root); + tree.setShowRoot(false); + tree.prefWidthProperty().bind(scene.widthProperty()); + tree.prefHeightProperty().bind(scene.heightProperty()); + + tree.setCellFactory(new Callback, TreeCell>() { + int calls = 0; + @Override + public TreeCell call(TreeView p) { +// System.out.println(++calls); + return TableTreeCell.getCell(); + } + }); + + ((Group) scene.getRoot()).getChildren().add(tree); + return scene; + } +} diff --git a/networktables/NetworkTableViewerFX/build.xml b/networktables/NetworkTableViewerFX/build.xml new file mode 100644 index 0000000000..ef802797f8 --- /dev/null +++ b/networktables/NetworkTableViewerFX/build.xml @@ -0,0 +1,53 @@ + + Builds, tests, and runs the project JavaNetworkTableViewer. + + + diff --git a/networktables/NetworkTableViewerFX/lib/nblibraries.properties b/networktables/NetworkTableViewerFX/lib/nblibraries.properties new file mode 100644 index 0000000000..2f89633424 --- /dev/null +++ b/networktables/NetworkTableViewerFX/lib/nblibraries.properties @@ -0,0 +1,18 @@ +libs.CopyLibs.classpath=\ + ${base}/CopyLibs/org-netbeans-modules-java-j2seproject-copylibstask.jar +libs.CopyLibs.displayName=CopyLibs Task +libs.CopyLibs.prop-version=1.0 +libs.junit.classpath=\ + ${base}/junit/junit-3.8.2.jar +libs.junit.displayName=JUnit 3.8.2 +libs.junit.javadoc=\ + ${base}/junit/junit-3.8.2-api.zip +libs.junit.prop-maven-dependencies=junit:junit:3.8.2:jar +libs.junit_4.classpath=\ + ${base}/junit_4/junit-4.10.jar +libs.junit_4.displayName=JUnit 4.10 +libs.junit_4.javadoc=\ + ${base}/junit_4/junit-4.10-javadoc.jar +libs.junit_4.prop-maven-dependencies=junit:junit:4.10:jar +libs.junit_4.src=\ + ${base}/junit_4/junit-4.10-sources.jar diff --git a/networktables/NetworkTableViewerFX/lib/networktables-desktop.jar b/networktables/NetworkTableViewerFX/lib/networktables-desktop.jar new file mode 100644 index 0000000000..1c88da9b87 Binary files /dev/null and b/networktables/NetworkTableViewerFX/lib/networktables-desktop.jar differ diff --git a/networktables/NetworkTableViewerFX/manifest.mf b/networktables/NetworkTableViewerFX/manifest.mf new file mode 100644 index 0000000000..328e8e5bc3 --- /dev/null +++ b/networktables/NetworkTableViewerFX/manifest.mf @@ -0,0 +1,3 @@ +Manifest-Version: 1.0 +X-COMMENT: Main-Class will be added automatically by build + diff --git a/networktables/NetworkTableViewerFX/nbproject/build-impl.xml b/networktables/NetworkTableViewerFX/nbproject/build-impl.xml new file mode 100644 index 0000000000..ce72d2f2f8 --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/build-impl.xml @@ -0,0 +1,1470 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set platform.home + Must set platform.bootcp + Must set platform.java + Must set platform.javac + + The J2SE Platform is not correctly set up. + Your active platform is: ${platform.active}, but the corresponding property "platforms.${platform.active}.home" is not found in the project's properties files. + Either open the project in the IDE and setup the Platform with the same name or add it manually. + For example like this: + ant -Duser.properties.file=<path_to_property_file> jar (where you put the property "platforms.${platform.active}.home" in a .properties file) + or ant -Dplatforms.${platform.active}.home=<path_to_JDK_home> jar (where no properties file is used) + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set src.dir + Must set test.src.dir + Must set build.dir + Must set dist.dir + Must set build.classes.dir + Must set dist.javadoc.dir + Must set build.test.classes.dir + Must set build.test.results.dir + Must set build.classes.excludes + Must set dist.jar + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + No tests executed. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must set JVM to use for profiling in profiler.info.jvm + Must set profiler agent JVM arguments in profiler.info.jvmargs.agent + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + + + + + + ${platform.java} -cp "${run.classpath.with.dist.jar}" ${main.class} + + + + + + + + + + + + + + + + + + + + + + + + + To run this application from the command line without Ant, try: + + ${platform.java} -jar "${dist.jar.resolved}" + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + Must select one file in the IDE or set run.class + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set debug.class + + + + + Must select one file in the IDE or set debug.class + + + + + Must set fix.includes + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + Must select one file in the IDE or set profile.class + This target only works when run from inside the NetBeans IDE. + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + This target only works when run from inside the NetBeans IDE. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select one file in the IDE or set run.class + + + + + + Must select some files in the IDE or set test.includes + + + + + Must select one file in the IDE or set run.class + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Must select some files in the IDE or set javac.includes + + + + + + + + + + + + + + + + + + + + Some tests failed; see details above. + + + + + + + + + Must select some files in the IDE or set test.includes + + + + Some tests failed; see details above. + + + + Must select some files in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + Some tests failed; see details above. + + + + + Must select one file in the IDE or set test.class + + + + Must select one file in the IDE or set test.class + Must select some method in the IDE or set test.method + + + + + + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + Must select one file in the IDE or set applet.url + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/networktables/NetworkTableViewerFX/nbproject/configs/Run_as_WebStart.properties b/networktables/NetworkTableViewerFX/nbproject/configs/Run_as_WebStart.properties new file mode 100644 index 0000000000..670fff03e4 --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/configs/Run_as_WebStart.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +$label=Run as WebStart diff --git a/networktables/NetworkTableViewerFX/nbproject/configs/Run_in_Browser.properties b/networktables/NetworkTableViewerFX/nbproject/configs/Run_in_Browser.properties new file mode 100644 index 0000000000..f2a5a657cc --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/configs/Run_in_Browser.properties @@ -0,0 +1,2 @@ +# Do not modify this property in this configuration. It can be re-generated. +$label=Run in Browser diff --git a/networktables/NetworkTableViewerFX/nbproject/genfiles.properties b/networktables/NetworkTableViewerFX/nbproject/genfiles.properties new file mode 100644 index 0000000000..36a1d767f0 --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/genfiles.properties @@ -0,0 +1,8 @@ +build.xml.data.CRC32=c8c66866 +build.xml.script.CRC32=d06c8c20 +build.xml.stylesheet.CRC32=28e38971@1.56.1.46 +# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. +# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. +nbproject/build-impl.xml.data.CRC32=9e01e615 +nbproject/build-impl.xml.script.CRC32=31676db4 +nbproject/build-impl.xml.stylesheet.CRC32=c6d2a60f@1.56.1.46 diff --git a/networktables/NetworkTableViewerFX/nbproject/jfx-impl.xml b/networktables/NetworkTableViewerFX/nbproject/jfx-impl.xml new file mode 100644 index 0000000000..f7a88ecc28 --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/jfx-impl.xml @@ -0,0 +1,3213 @@ + + + + + JavaFX-specific Ant calls + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${cssfileslist} + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/networktables/NetworkTableViewerFX/nbproject/private/configs/Run_as_WebStart.properties b/networktables/NetworkTableViewerFX/nbproject/private/configs/Run_as_WebStart.properties new file mode 100644 index 0000000000..e8be0ee398 --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/private/configs/Run_as_WebStart.properties @@ -0,0 +1,4 @@ +# Do not modify this property in this configuration. It can be re-generated. +$label=Run as WebStart +# Do not modify this property in this configuration. It can be re-generated. +javafx.run.as=webstart diff --git a/networktables/NetworkTableViewerFX/nbproject/private/configs/Run_in_Browser.properties b/networktables/NetworkTableViewerFX/nbproject/private/configs/Run_in_Browser.properties new file mode 100644 index 0000000000..1be80d6a11 --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/private/configs/Run_in_Browser.properties @@ -0,0 +1,4 @@ +# Do not modify this property in this configuration. It can be re-generated. +$label=Run in Browser +# Do not modify this property in this configuration. It can be re-generated. +javafx.run.as=embedded diff --git a/networktables/NetworkTableViewerFX/nbproject/private/private.properties b/networktables/NetworkTableViewerFX/nbproject/private/private.properties new file mode 100644 index 0000000000..3b3de5ccbf --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/private/private.properties @@ -0,0 +1,12 @@ +auxiliary.org-netbeans-modules-projectapi.issue214819_5f_fx_5f_enabled=true +compile.on.save=true +do.depend=false +do.jar=true +# No need to modify this property unless customizing JavaFX Ant task infrastructure +endorsed.javafx.ant.classpath=. +javac.debug=true +javadoc.preview=true +javafx.run.as=standalone +javafx.run.inbrowser= +javafx.run.inbrowser.path=C:\\Users\\Sam\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe +user.properties.file=C:\\Users\\Sam\\AppData\\Roaming\\NetBeans\\7.3\\build.properties diff --git a/networktables/NetworkTableViewerFX/nbproject/private/private.xml b/networktables/NetworkTableViewerFX/nbproject/private/private.xml new file mode 100644 index 0000000000..475096252c --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/private/private.xml @@ -0,0 +1,4 @@ + + + + diff --git a/networktables/NetworkTableViewerFX/nbproject/project.properties b/networktables/NetworkTableViewerFX/nbproject/project.properties new file mode 100644 index 0000000000..dc3b352b19 --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/project.properties @@ -0,0 +1,120 @@ +annotation.processing.enabled=true +annotation.processing.enabled.in.editor=false +annotation.processing.processors.list= +annotation.processing.run.all.processors=true +annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output +application.title=NetworkTableViewer +application.vendor= +build.classes.dir=${build.dir}/classes +build.classes.excludes=**/*.java,**/*.form +# This directory is removed when the project is cleaned: +build.dir=build +build.generated.dir=${build.dir}/generated +build.generated.sources.dir=${build.dir}/generated-sources +# Only compile against the classpath explicitly listed here: +build.sysclasspath=ignore +build.test.classes.dir=${build.dir}/test/classes +build.test.results.dir=${build.dir}/test/results +compile.on.save=true +compile.on.save.unsupported.javafx=true +# Uncomment to specify the preferred debugger connection transport: +#debug.transport=dt_socket +debug.classpath=\ + ${run.classpath} +debug.test.classpath=\ + ${run.test.classpath} +# This directory is removed when the project is cleaned: +dist.dir=dist +dist.jar=${dist.dir}/NetworkTableViewer.jar +dist.javadoc.dir=${dist.dir}/javadoc +endorsed.classpath= +excludes= +file.reference.networktables-desktop.jar=lib\\networktables-desktop.jar +includes=** +# Non-JavaFX jar file creation is deactivated in JavaFX 2.0+ projects +jar.archive.disabled=true +jar.compress=false +javac.classpath=\ + ${javafx.runtime}/lib/jfxrt.jar:\ + ${javafx.runtime}/lib/deploy.jar:\ + ${javafx.runtime}/lib/javaws.jar:\ + ${javafx.runtime}/lib/plugin.jar:\ + ${file.reference.networktables-desktop.jar} +# Space-separated list of extra javac options +javac.compilerargs= +javac.deprecation=false +javac.processorpath=\ + ${javac.classpath} +javac.source=1.7 +javac.target=1.7 +javac.test.classpath=\ + ${javac.classpath}:\ + ${build.classes.dir}:\ + ${libs.junit_4.classpath} +javac.test.processorpath=\ + ${javac.test.classpath} +javadoc.additionalparam= +javadoc.author=true +javadoc.encoding=${source.encoding} +javadoc.noindex=false +javadoc.nonavbar=false +javadoc.notree=false +javadoc.private=false +javadoc.splitindex=true +javadoc.use=true +javadoc.version=false +javadoc.windowtitle= +javafx.binarycss=false +javafx.deploy.adddesktopshortcut=false +javafx.deploy.addstartmenushortcut=false +javafx.deploy.allowoffline=true +# If true, application update mode is set to 'background', if false, update mode is set to 'eager' +javafx.deploy.backgroundupdate=false +javafx.deploy.embedJNLP=true +javafx.deploy.includeDT=true +javafx.deploy.installpermanently=false +javafx.deploy.permissionselevated=true +# Set true to prevent creation of temporary copy of deployment artifacts before each run (disables concurrent runs) +javafx.disable.concurrent.runs=false +# Set true to enable multiple concurrent runs of the same WebStart or Run-in-Browser project +javafx.enable.concurrent.external.runs=false +# This is a JavaFX project +javafx.enabled=true +javafx.fallback.class=com.javafx.main.NoJavaFXFallback +# Main class for JavaFX +javafx.main.class=edu.wpi.first.tableviewer.NetworkTableViewer +javafx.native.bundling.enabled=false +javafx.native.bundling.type=all +javafx.preloader.class= +# This project does not use Preloader +javafx.preloader.enabled=false +javafx.preloader.jar.filename= +javafx.preloader.jar.path= +javafx.preloader.project.path= +javafx.preloader.type=none +# Set true for GlassFish only. Rebases manifest classpaths of JARs in lib dir. Not usable with signed JARs. +javafx.rebase.libs=false +javafx.run.height=600 +javafx.run.width=800 +javafx.runtime=${platforms.JDK_1.7.0_21.javafx.runtime.home} +javafx.sdk=${platforms.JDK_1.7.0_21.javafx.sdk.home} +javafx.signing.enabled=true +javafx.signing.type=self +# Pre-JavaFX 2.0 WebStart is deactivated in JavaFX 2.0+ projects +jnlp.enabled=false +# Main class for Java launcher +main.class=com.javafx.main.Main +manifest.file=manifest.mf +meta.inf.dir=${src.dir}/META-INF +mkdist.disabled=false +platform.active=JDK_1.7.0_21 +run.classpath=\ + ${dist.jar}:\ + ${javac.classpath} +run.test.classpath=\ + ${javac.test.classpath}:\ + ${build.test.classes.dir} +source.encoding=UTF-8 +source.reference.networktables-desktop.jar=../java/dist/desktop-lib/networktables-desktop.src.zip +src.dir=src +test.src.dir=test diff --git a/networktables/NetworkTableViewerFX/nbproject/project.xml b/networktables/NetworkTableViewerFX/nbproject/project.xml new file mode 100644 index 0000000000..341c9f1e8b --- /dev/null +++ b/networktables/NetworkTableViewerFX/nbproject/project.xml @@ -0,0 +1,35 @@ + + + org.netbeans.modules.java.j2seproject + + + + + + + + + + + + + + + + NetworkTableViewer + + + + + + + + + + .\lib\nblibraries.properties + + + popup + + + diff --git a/networktables/NetworkTableViewerFX/src.zip b/networktables/NetworkTableViewerFX/src.zip new file mode 100644 index 0000000000..a151d9c80f Binary files /dev/null and b/networktables/NetworkTableViewerFX/src.zip differ diff --git a/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/EntryData.java b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/EntryData.java new file mode 100644 index 0000000000..a084c99769 --- /dev/null +++ b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/EntryData.java @@ -0,0 +1,81 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer; + +import edu.wpi.first.tableviewer.treeview.ITableItem; +import edu.wpi.first.tableviewer.treeview.TableBranch; +import edu.wpi.first.tableviewer.treeview.TableLeaf; +import edu.wpi.first.tableviewer.treeview.TableLeaf.EntryType; +import java.util.HashMap; +import java.util.Map; + +/** + * + * @author Sam + */ +public class EntryData { + + public static final EntryData EMPTY = new EntryData(null, null, null); + + private String key; + private Object value; + private EntryType type; + + private boolean representsLeaf = true; + private ITableItem tableItem; + + public EntryData(String key, Object value, EntryType type) { + this.key = key; + this.value = value; + this.type = type; + } + + public EntryData(TableLeaf leaf) { + this(leaf.getTableKey(), leaf.getTableValue(), leaf.getEntryType()); + tableItem = leaf; + } + + public EntryData(TableBranch branch) { + key = branch.toString(); + representsLeaf = false; + tableItem = branch; + } + + public boolean representsLeaf() { + return representsLeaf; + } + + public void setTableItem(ITableItem item) { + tableItem = item; + } + + public ITableItem getTableItem() { + return tableItem; + } + + public void setKey(String key) { + this.key = key; + } + + public void setValue(Object value) { + this.value = value; + } + + public void setType(EntryType type) { + this.type = type; + } + + public String getKey() { + return key; + } + + public Object getValue() { + return value; + } + + public EntryType getType() { + return type; + } +} diff --git a/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/NetworkTableViewer.java b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/NetworkTableViewer.java new file mode 100644 index 0000000000..f45d960669 --- /dev/null +++ b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/NetworkTableViewer.java @@ -0,0 +1,59 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer; + +import edu.wpi.first.tableviewer.popup.PreferencesDialog; +import edu.wpi.first.tableviewer.tableview.TableTableView; +import edu.wpi.first.wpilibj.networktables2.NetworkTableNode; +import java.nio.charset.Charset; + +import javafx.application.Application; +import javafx.event.EventHandler; +import javafx.fxml.FXMLLoader; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.layout.BorderPane; +import javafx.stage.Modality; +import javafx.stage.Stage; +import javafx.stage.StageStyle; +import javafx.stage.WindowEvent; + +/** + * + * @author Sam + */ +public class NetworkTableViewer extends Application { + + @Override + public void start(Stage primaryStage) { + FXMLLoader loader = new FXMLLoader(PreferencesDialog.class.getResource("PreferencesDialog.fxml")); + Scene scene; + PreferencesDialog controller = null; + try { + scene = new Scene(new Group()); + ((Group)scene.getRoot()).getChildren().add((BorderPane)loader.load()); + controller = loader.getController(); + Stage s = new Stage(); + controller.setStage(s); + s.setResizable(false); + s.initStyle(StageStyle.UTILITY); + s.initModality(Modality.WINDOW_MODAL); + s.setScene(scene); + s.setOnCloseRequest(new EventHandler() { + @Override + public void handle(WindowEvent t) { + System.exit(0); + } + }); + s.showAndWait(); + } catch (Exception e) { + e.printStackTrace(); + } + + NetworkTableNode node = controller.getNode(); + TableTableView view = new TableTableView(node); + view.show(); + } +} diff --git a/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/AddValuePopup.java b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/AddValuePopup.java new file mode 100644 index 0000000000..b0a246f382 --- /dev/null +++ b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/AddValuePopup.java @@ -0,0 +1,159 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +import edu.wpi.first.wpilibj.tables.ITable; + +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Control; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.GridPane; +import javafx.scene.paint.Color; +import javafx.stage.Modality; + +/** + * + * @author Sam + */ +class AddValuePopup extends Popup { + + public enum InputType { + BOOLEAN, NUMBER, STRING, SUBTABLE + } + + private final InputType type; + private final ITable table; + + public AddValuePopup(ITable table, InputType type) { + super(); + + this.table = table; + this.type = type; + + initModality(Modality.WINDOW_MODAL); + } + + @Override + public void showPopup() { + initComponents(); + showAndWait(); + } + + @Override + public void initComponents() { + initComponents(type); + } + + private void initComponents(final InputType type) { + final Scene scene = new Scene(new Group()); + scene.setFill(Color.WHITESMOKE); + scene.getStylesheets().add( + "edu/wpi/first/tableviewer/stylesheets/ViewerStyleSheet.css"); + final Label messageLabel = new Label(); + final Label keyLabel = new Label("Key:"); + final Label valueLabel = new Label("Value:"); + final TextField keyField = new TextField(); + final Button confirm = new Button("Add"); + + keyField.setPromptText("Key"); + keyField.setPrefWidth(100); + + final Control valueControl; + ObservableList booleanOptions = FXCollections.observableArrayList("True", "False"); + switch (type) { + case BOOLEAN: + messageLabel.setText("Add boolean"); + valueControl = new ComboBox(booleanOptions); + ((ComboBox) valueControl).getSelectionModel().select(0); + confirm.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + if (table.containsKey(keyField.getText())) { + PopupFactory.showErrorDialog("Key already in use!"); + } else { + table.putBoolean(keyField.getText(), ((ComboBox) valueControl).getSelectionModel().isSelected(0)); + close(); + } + } + }); + break; + case NUMBER: + messageLabel.setText("Add number"); + valueControl = new TextField(); + ((TextField) valueControl).setPromptText("Number"); + confirm.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + try { + if (table.containsKey(keyField.getText())) { + PopupFactory.showErrorDialog("Key already in use!"); + } else { + table.putNumber(keyField.getText(), Double.parseDouble(((TextField) valueControl).getText())); + close(); + } + } catch (NumberFormatException ex) { + PopupFactory.showErrorDialog("Invalid number!"); + } + } + }); + break; + case STRING: + messageLabel.setText("Add string"); + valueControl = new TextField(); + ((TextField) valueControl).setPromptText("Text"); + confirm.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + if (table.containsKey(keyField.getText())) { + PopupFactory.showErrorDialog("Key already in use!"); + } else { + table.putString(keyField.getText(), ((TextField) valueControl).getText()); + close(); + } + } + }); + break; + case SUBTABLE: + keyLabel.setText("Table name"); + keyField.setPromptText("Name"); + valueControl = null; + confirm.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + //TODO make a subtable show up without putting a value + ITable i = table.getSubTable(keyField.getText()); + close(); + } + }); + break; + default: + return; + } + + final GridPane grid = new GridPane(); + grid.setHgap(10); + grid.setVgap(5); + grid.add(keyLabel, 1, 1); + grid.add(keyField, 2, 1); + if (type != InputType.SUBTABLE) { + grid.add(valueLabel, 1, 2); + grid.add(valueControl, 2, 2); + valueControl.setPrefWidth(100); + } + grid.add(confirm, 2, 3); + + ((Group) scene.getRoot()).getChildren().add(grid); + setScene(scene); + + } +} diff --git a/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/EditorPopup.java b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/EditorPopup.java new file mode 100644 index 0000000000..32686d7e5c --- /dev/null +++ b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/EditorPopup.java @@ -0,0 +1,128 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +import edu.wpi.first.tableviewer.treeview.TableLeaf; +import javafx.collections.FXCollections; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.ComboBox; +import javafx.scene.control.Label; +import javafx.scene.control.TextField; +import javafx.scene.layout.GridPane; +import javafx.scene.paint.Color; + +/** + * + * @author Sam + */ +public class EditorPopup extends Popup { + + private final Label inputLabel = new Label(); + private final TextField inputField = new TextField(); + private final ComboBox booleanBox = new ComboBox(FXCollections.observableArrayList("True", "False")); + private final Button okayButton = new Button("OK"), + cancelButton = new Button("Cancel"); + + private final String itemType; + private final TableLeaf leaf; + + public EditorPopup(TableLeaf leaf) { + super("Edit Value", null, null); + this.leaf = leaf; + + String tableValue = leaf.getTableValue().toString(); + String tableKey = leaf.getTableKey(); + + inputLabel.setText(tableKey+":"); + + inputField.setText(tableValue); + inputField.setPromptText("New value"); + inputField.setPrefWidth(100); + + booleanBox.getSelectionModel().selectFirst(); + + itemType = leaf.getEntryType().toString(); + cancelButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + close(); + } + }); + } + + @Override + public void initComponents() { + initComponents(itemType); + } + + private void initComponents(final String type) { + final Scene scene = new Scene(new Group()); + scene.setFill(Color.WHITESMOKE); + scene.getStylesheets().add( + "edu/wpi/first/tableviewer/stylesheets/ViewerStyleSheet.css"); + + final GridPane grid = new GridPane(); + grid.setHgap(10); + grid.setVgap(15); + grid.setPadding(new Insets(5, 5, 5, 5)); + grid.setAlignment(Pos.CENTER); + grid.add(inputLabel, 0, 1); + + ((Group) scene.getRoot()).getChildren().add(grid); + setScene(scene); + + switch (type.toLowerCase()) { + case "boolean": + grid.add(booleanBox, 1, 1); + okayButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + leaf.updateValue(booleanBox.getSelectionModel().isSelected(0)); + leaf.setExpanded(false); // refresh the leaf to updateValue the shown value + leaf.setExpanded(true); + close(); + } + }); + break; + case "number": + grid.add(inputField, 1, 1); + okayButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + try { + leaf.updateValue(Double.parseDouble(inputField.getText())); + leaf.setExpanded(false); // refresh the leaf to updateValue the shown value + leaf.setExpanded(true); + close(); + } catch (NumberFormatException ex) { + PopupFactory.showErrorDialog("Invalid number value!"); + } + } + }); + break; + case "string": + grid.add(inputField, 1, 1); + okayButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + leaf.updateValue(inputField.getText()); + leaf.setExpanded(false); // refresh the leaf to updateValue the shown value + leaf.setExpanded(true); + close(); + } + }); + break; + } + grid.add(okayButton, 0, 2); + grid.add(cancelButton, 1, 2); + + } +} diff --git a/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/ErrorDialog.fxml b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/ErrorDialog.fxml new file mode 100644 index 0000000000..11ee571c43 --- /dev/null +++ b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/ErrorDialog.fxml @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/IPopup.java b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/IPopup.java new file mode 100644 index 0000000000..5b70890c17 --- /dev/null +++ b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/IPopup.java @@ -0,0 +1,35 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +/** + * An interface for defining popups. + * @author Sam + * @see Popup + * @see InputPopup + */ +public interface IPopup { + + /** + * An enumeration representing the type of popup this is. + */ + public enum Type { + MESSAGE, + WARNING, + ERROR, + INPUT + } + + /** + * A method used to show this popup. + */ + public void showPopup(); + + /** + * Initialize all components in this popup. + */ + public void initComponents(); + +} diff --git a/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/Popup.java b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/Popup.java new file mode 100644 index 0000000000..e97df7e5f8 --- /dev/null +++ b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/Popup.java @@ -0,0 +1,115 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.Group; +import javafx.scene.Scene; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.layout.VBox; +import javafx.scene.paint.Color; +import javafx.scene.text.TextAlignment; +import javafx.stage.Modality; +import javafx.stage.Stage; + +/** + * A generic popup. Call + * {@link PopupFactory Popupfactory}.{@code showXXXXDialog()} to show a + * predefined popup of a specific type. + * + * @see IPopup + * @see InputPopup + * @see PopupFactory + * @author Sam + */ +class Popup extends Stage implements IPopup { + + protected final String message; + protected final Type type; + + Popup() { + this(null, null, Type.INPUT); + } + + Popup(String title, String message, Type type) { + super(); + this.message = message; + this.type = type; + + setTitle(title); + setWidth(200); + setHeight(150); + setResizable(false); + + initModality(Modality.WINDOW_MODAL); + } + + private void initComponents(Type messageType) { + final Scene scene = new Scene(new Group()); + scene.setFill(Color.WHITESMOKE); + final Label messageText = new Label(message); + final Button okayButton = new Button("Okay"); + final VBox box = new VBox(); + + messageText.setAlignment(Pos.CENTER); + messageText.setTextAlignment(TextAlignment.CENTER); + messageText.setWrapText(true); + okayButton.setAlignment(Pos.CENTER); + + okayButton.setOnAction(new EventHandler() { + @Override + public void handle(ActionEvent t) { + close(); + } + }); + + String messageClass = ""; + switch (messageType) { + case MESSAGE: + messageClass = ""; + box.setPadding(new Insets(10, 0, 0, 0)); + break; + case WARNING: + messageClass = "warning-"; + box.setPadding(new Insets(10, 0, 0, 0)); + break; + case ERROR: + messageClass = "error-"; + box.setPadding(new Insets(30, 0, 0, 0)); + break; + default: + break; + } + + scene.getStylesheets().add( + "edu/wpi/first/tableviewer/stylesheets/PopupCSS.css"); + messageText.getStyleClass().add(messageClass + "message"); + + box.setPrefWidth(200); + box.setSpacing(15); + box.setAlignment(Pos.CENTER); + + box.getChildren().addAll(messageText, okayButton); + + ((Group) scene.getRoot()).getChildren().addAll(box); + + setScene(scene); + } + + @Override + public void initComponents() { + initComponents(type); + } + + @Override + public void showPopup() { + initComponents(); + showAndWait(); + } +} diff --git a/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/PopupFactory.java b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/PopupFactory.java new file mode 100644 index 0000000000..9867130c54 --- /dev/null +++ b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/PopupFactory.java @@ -0,0 +1,65 @@ +/* + * To change this template, choose Tools | Templates + * and open the template in the editor. + */ +package edu.wpi.first.tableviewer.popup; + +import edu.wpi.first.tableviewer.popup.IPopup.Type; +import edu.wpi.first.tableviewer.popup.AddValuePopup.InputType; +import edu.wpi.first.tableviewer.treeview.TableLeaf; +import edu.wpi.first.wpilibj.tables.ITable; + +/** + * A factory for creating and showing {@link Popup Popups} of a defined type. + * @author Sam + */ +public final class PopupFactory { + + public static void showMessageDialog(String title, String message) { + IPopup popup = new Popup(title, message, Type.MESSAGE); + popup.showPopup(); + } + + public static void showMessageDialog(String message) { + showMessageDialog("", message); + } + + public static void showWarningDialog(String title, String message) { + IPopup popup = new Popup(title, message, Type.WARNING); + popup.showPopup(); + } + + public static void showWarningDialog(String message) { + showWarningDialog("", message); + } + + public static void showErrorDialog(String title, String message) { + IPopup popup = new Popup(title, message, Type.ERROR); + popup.showPopup(); + } + + public static void showErrorDialog(String message) { + showErrorDialog("", message); + } + + public static void showAddBooleanDialog(ITable table) { + IPopup popup = new AddValuePopup(table, InputType.BOOLEAN); + popup.showPopup(); + } + + public static void showAddNumberDialog(ITable table) { + IPopup popup = new AddValuePopup(table, InputType.NUMBER); + popup.showPopup(); + } + + public static void showAddStringDialog(ITable table) { + IPopup popup = new AddValuePopup(table, InputType.STRING); + popup.showPopup(); + } + + public static void showEditorDialog(TableLeaf leaf) { + IPopup popup = new EditorPopup(leaf); + popup.showPopup(); + } + +} diff --git a/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/PreferencesDialog.css b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/PreferencesDialog.css new file mode 100644 index 0000000000..a10957e37b --- /dev/null +++ b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/PreferencesDialog.css @@ -0,0 +1,7 @@ +/* + * Empty Stylesheet file. + */ + +.mainFxmlClass { + +} diff --git a/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/PreferencesDialog.fxml b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/PreferencesDialog.fxml new file mode 100644 index 0000000000..dd59415409 --- /dev/null +++ b/networktables/NetworkTableViewerFX/src/edu/wpi/first/tableviewer/popup/PreferencesDialog.fxml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + +