Compare commits

...

19 Commits

Author SHA1 Message Date
Patrick Plenefisch
8079482820 Create HOME on windows
Change-Id: Id16278b5280e25e383e474faf4b511c47e5d0751
2014-10-08 17:15:51 -04:00
Brad Miller (WPI)
0b828eec62 Merge "Disable CANJaguar current PID test" 2014-10-08 12:51:58 -07:00
Brad Miller (WPI)
49e06bd13b Merge "Move interrupt methods to InterruptableSensorBase" 2014-10-08 12:51:28 -07:00
Thomas Clark
eca4d36a4b Disable CANJaguar current PID test
The hardware setup makes this test basically useless

Change-Id: I40287313a1928dda897c8e35922216d44ab089d2
2014-10-08 15:02:01 -04:00
Thomas Clark
4d2a720f47 Move interrupt methods to InterruptableSensorBase
Analog interrupts work again now, and RequestInterrupts is no longer
duplicated three times.

Change-Id: I5244b76262d7620852141cd21b2429d627636793
2014-10-08 14:52:24 -04:00
Patrick Plenefisch
591e1de721 use WPILIB eclipse var & use luna to build
Change-Id: I5e8560329226fca3c60f337b6b4744c50a09cdc9
2014-10-08 10:39:06 -04:00
Brad Miller (WPI)
dc09233fca Merge "void* -> void by creating proxy fuction" 2014-10-07 14:21:45 -07:00
Patrick Plenefisch
037d3b2fb5 void* -> void by creating proxy fuction
Change-Id: I903c3d98f3210d1969b9aed6c84f5ccaa803a9ed
2014-10-07 17:19:32 -04:00
Kevin O'Connor
a3995a202d Fix bitfield indexing on PWM Latch
Change-Id: I63b423dbcab9f0f8b5b384654824f1c69b0fa052
2014-10-07 16:52:21 -04:00
Thomas Clark (WPI)
a71f07ed67 Merge "HAL: build shared library as well as static library." 2014-10-07 08:24:27 -07:00
Brad Miller (WPI)
cb81aa6fe9 Merge "Update headers and .sos to v15 image + most API changes" 2014-10-07 07:22:14 -07:00
Thomas Clark (WPI)
ace43a6a12 Merge "DigitalOutput: Fix enablePWM()." 2014-10-07 07:18:19 -07:00
Thomas Clark (WPI)
a4e8d65b71 Merge "Relay: In free(), set both forward and reverse to 0." 2014-10-07 07:17:10 -07:00
Brad Miller
bfd88f1dab Reserve network communications
Change-Id: Ie98e31baf9d5ce01056a89e009ec62c8bbb62f2e
2014-10-06 10:21:55 -04:00
Peter Johnson
a65cb500fb Relay: In free(), set both forward and reverse to 0.
Also, check status in between the two calls.

Change-Id: I5a6c24aefde3707a953a41cb7c56e8fb372e1ea0
2014-10-06 00:31:46 -07:00
Peter Johnson
f27df43b5b DigitalOutput: Fix enablePWM().
Previously enablePWM() wanted m_pwmGenerator to already be non-null on entry.
This is impossible as the only place m_pwmGenerator is set is later in this
function.

Also add correct m_pwmGenerator null checks to disablePWM() and
updateDutyCycle().

Change-Id: Ia5bbfdc62824e1cf4c2f503308313b7ef39ae2fe
2014-10-05 20:51:57 -07:00
Thomas Clark
7e9f183cf9 Update headers and .sos to v15 image + most API changes
Java still does not work

Change-Id: I172ac401a07b6703909068f82b7b6cc67e6075c0
2014-10-05 17:17:59 -04:00
Brad Miller
2f26361398 Added Mecanum drive sample program
Change-Id: I0538c21116cd6c8836f76b6d4446b83d8723a20f
2014-10-05 16:03:36 -04:00
Peter Johnson
52ecbd38ac HAL: build shared library as well as static library.
Change-Id: I02143d601dc1dc0a6f35d61b6d008340333ee98a
2014-10-03 19:13:34 -07:00
115 changed files with 3124 additions and 2908 deletions

View File

@@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.ui,
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"
org.eclipse.core.expressions;bundle-version="3.4.400",
org.eclipse.core.variables;bundle-version="3.2.700"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: edu.wpi.first.wpilib.plugins.core,

View File

@@ -83,5 +83,14 @@
content="WPILib Intro/sample.xml">
</configExtension>
</extension>
<extension
point="org.eclipse.core.variables.valueVariables">
<variable
name="WPILIB"
initialValue="${HOME}/wpilib"
description="WPILib Path"
>
</variable>
</extension>
</plugin>

View File

@@ -25,7 +25,8 @@ Require-Bundle: org.eclipse.ui,
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",
org.eclipse.cdt.debug.mi.core;bundle-version="7.2.0"
org.eclipse.cdt.debug.mi.core;bundle-version="7.2.0",
org.eclipse.core.variables
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.7
Export-Package: edu.wpi.first.wpilib.plugins.cpp,

View File

@@ -27,7 +27,7 @@
<option id="gnu.cpp.compiler.option.optimization.level.1204256582" name="Optimization Level" superClass="gnu.cpp.compiler.option.optimization.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.optimization.level.none" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.debugging.level.969129918" name="Debug Level" superClass="gnu.cpp.compiler.option.debugging.level" useByScannerDiscovery="false" value="gnu.cpp.compiler.debugging.level.max" valueType="enumerated"/>
<option id="gnu.cpp.compiler.option.include.paths.394786621" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" useByScannerDiscovery="false" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;$cpp-location/include&quot;"/>
<listOptionValue builtIn="false" value="&quot;${WPILIB}/cpp/current/include&quot;"/>
</option>
<option id="gnu.cpp.compiler.option.dialect.std.1060340803" name="Language standard" superClass="gnu.cpp.compiler.option.dialect.std" useByScannerDiscovery="true" value="gnu.cpp.compiler.dialect.c++1y" valueType="enumerated"/>
<inputType id="cdt.managedbuild.tool.gnu.cpp.compiler.input.1033680971" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.input"/>
@@ -38,7 +38,7 @@
<listOptionValue builtIn="false" value="wpi"/>
</option>
<option id="gnu.cpp.link.option.paths.1566479969" name="Library search path (-L)" superClass="gnu.cpp.link.option.paths" valueType="libPaths">
<listOptionValue builtIn="false" value="&quot;$cpp-location/lib&quot;"/>
<listOptionValue builtIn="false" value="&quot;${WPILIB}/cpp/current/lib&quot;"/>
</option>
<inputType id="cdt.managedbuild.tool.gnu.cpp.linker.input.132949138" superClass="cdt.managedbuild.tool.gnu.cpp.linker.input">
<additionalInput kind="additionalinputdependency" paths="$(USER_OBJS)"/>
@@ -126,7 +126,7 @@
<tool id="cdt.managedbuild.tool.gnu.cpp.compiler.base.2105416021" name="GCC C++ Compiler" superClass="cdt.managedbuild.tool.gnu.cpp.compiler.base">
<option id="gnu.cpp.compiler.option.include.paths.1645322059" name="Include paths (-I)" superClass="gnu.cpp.compiler.option.include.paths" valueType="includePath">
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/${ProjName}}/src&quot;"/>
<listOptionValue builtIn="false" value="$cpp-location/sim/include"/>
<listOptionValue builtIn="false" value="${WPILIB}/cpp/current/sim/include"/>
<listOptionValue builtIn="false" value="/usr/include"/>
<listOptionValue builtIn="false" value="/usr/include/gazebo-3.1"/>
<listOptionValue builtIn="false" value="/usr/include/sdformat-2.0"/>

View File

@@ -0,0 +1,49 @@
#include "WPILib.h"
/**
* This is a demo program showing how to use Mecanum control with the RobotDrive class.
*/
class Robot: public SampleRobot
{
// Channels for the wheels
const static int frontLeftChannel = 2;
const static int rearLeftChannel = 3;
const static int frontRightChannel = 1;
const static int rearRightChannel = 0;
const static int joystickChannel = 0;
RobotDrive robotDrive; // robot drive system
Joystick stick; // only joystick
public:
Robot() :
robotDrive(frontLeftChannel, rearLeftChannel,
frontRightChannel, rearRightChannel), // these must be initialized in the same order
stick(joystickChannel) // as they are declared above.
{
robotDrive.SetExpiration(0.1);
robotDrive.SetInvertedMotor(RobotDrive::kFrontLeftMotor, true); // invert the left side motors
robotDrive.SetInvertedMotor(RobotDrive::kRearLeftMotor, true); // you may need to change or remove this to match your robot
}
/**
* Runs the motors with Mecanum drive.
*/
void OperatorControl()
{
robotDrive.SetSafetyEnabled(false);
while (IsOperatorControl())
{
// Use the joystick X axis for lateral movement, Y axis for forward movement, and Z axis for rotation.
// This sample does not use field-oriented drive, so the gyro input is set to zero.
robotDrive.MecanumDrive_Cartesian(stick.GetX(), stick.GetY(), stick.GetZ());
Wait(0.005); // wait 5ms to avoid hogging CPU cycles
}
}
};
START_ROBOT_CLASS(Robot);

View File

@@ -105,6 +105,24 @@
</example>
<example>
<name>Mecanum Drive</name>
<description>An example program which the use of Mecanum Drive with the RobotDrive class</description>
<tags>
<tag>Getting Started with C++</tag>
<tag>Robot and Motor</tag>
<tag>Joystick</tag>
<tag>Complete List</tag>
</tags>
<packages>
<package>src</package>
</packages>
<files>
<file source="examples/MecanumDrive/src/Robot.cpp" destination="src/Robot.cpp"></file>
</files>
</example>
<example>
<name>Getting Started</name>
<description>An example program which demonstrates the simplest autonomous and

View File

@@ -1,6 +1,12 @@
package edu.wpi.first.wpilib.plugins.cpp.installer;
import java.io.InputStream;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.variables.IStringVariableManager;
import org.eclipse.core.variables.IValueVariable;
import org.eclipse.core.variables.VariablesPlugin;
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;
@@ -21,6 +27,26 @@ public class CPPInstaller extends AbstractInstaller {
protected void updateInstalledVersion(String version) {
WPILibCPPPlugin.getDefault().getPreferenceStore().setValue(PreferenceConstants.LIBRARY_INSTALLED,
version);
IStringVariableManager vm = VariablesPlugin.getDefault().getStringVariableManager();
try
{
if (System.getProperty("os.name").startsWith("Windows"))
{
IValueVariable vv = vm.getValueVariable("HOME");
if (vv == null)
vm.addVariables(new IValueVariable[]{vm.newValueVariable("HOME", "user.home directory", false,System.getProperty("user.home"))});
else
{
if (!System.getProperty("user.home").equals(vm.performStringSubstitution("${HOME}")))
vv.setValue(System.getProperty("user.home"));
}
}
} catch (CoreException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new RuntimeException(e);
}
}
@Override

View File

@@ -0,0 +1,53 @@
package org.usfirst.frc.team190.robot;
import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.RobotDrive;
import edu.wpi.first.wpilibj.RobotDrive.MotorType;
import edu.wpi.first.wpilibj.SampleRobot;
import edu.wpi.first.wpilibj.Timer;
/**
* This is a demo program showing how to use Mecanum control with the RobotDrive class.
*/
public class Robot extends SampleRobot {
RobotDrive robotDrive;
Joystick stick;
// Channels for the wheels
final int frontLeftChannel = 2;
final int rearLeftChannel = 3;
final int frontRightChannel = 1;
final int rearRightChannel = 0;
// The channel on the driver station that the joystick is connected to
final int joystickChannel = 0;
public Robot() {
robotDrive.setExpiration(0.1);
robotDrive = new RobotDrive(frontLeftChannel, rearLeftChannel, frontRightChannel, rearRightChannel);
robotDrive.setInvertedMotor(MotorType.kFrontLeft, true); // invert the left side motors
robotDrive.setInvertedMotor(MotorType.kRearLeft, true); // you may need to change or remove this to match your robot
stick = new Joystick(joystickChannel);
}
/**
* Runs the motors with Mecanum drive.
*/
public void operatorControl() {
robotDrive.setSafetyEnabled(true);
while (isOperatorControl()) {
// Use the joystick X axis for lateral movement, Y axis for forward movement, and Z axis for rotation.
// This sample does not use field-oriented drive, so the gyro input is set to zero.
robotDrive.mecanumDrive_Cartesian(stick.getX(), stick.getY(), stick.getZ(), 0);
Timer.delay(0.005); // wait 5ms to avoid hogging CPU cycles
}
}
}

View File

@@ -116,6 +116,25 @@
</files>
</example>
<example>
<name>Mecanum Drive</name>
<description>Demonstrate the use of the RobotDrive class doing teleop driving with Mecanum steering</description>
<tags>
<tag>Actuators</tag>
<tag>Complete List</tag>
<tag>Joystick</tag>
<tag>Robot and Motor</tag>
<tag>Safety</tag>
</tags>
<packages>
<package>src/$package-dir</package>
</packages>
<files>
<file source="examples/MecanumDrive/src/org/usfirst/frc/team190/robot/Robot.java"
destination="src/$package-dir/Robot.java"></file>
</files>
</example>
<example>
<name>Motor Controller</name>

View File

@@ -26,7 +26,7 @@
<repository>
<id>juno</id>
<layout>p2</layout>
<url>http://download.eclipse.org/releases/juno</url>
<url>http://download.eclipse.org/releases/luna</url>
</repository>
<repository>
<id>FRC Binaries</id>

View File

@@ -8,6 +8,10 @@ target_link_libraries(HALAthena ${NI_LIBS})
INSTALL(TARGETS HALAthena ARCHIVE DESTINATION lib COMPONENT lib)
INSTALL(FILES ${NI_LIBS} ${WPI_LD_LIBS} DESTINATION lib COMPONENT ni_lib)
INSTALL(DIRECTORY include DESTINATION ${CMAKE_INSTALL_PREFIX} COMPONENT headers)
add_library(HALAthena_shared SHARED ${SRC_FILES})
target_link_libraries(HALAthena_shared ${NI_LIBS})
INSTALL(TARGETS HALAthena_shared LIBRARY DESTINATION lib COMPONENT lib)
# lib/ c m gcc_s ld-linux
# usr/lib
# FRC_NetworkCommunication FRC_FPGA_ChipObject RoboRIO_FRC_ChipObject

View File

@@ -63,8 +63,6 @@ extern "C"
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);
@@ -78,8 +76,6 @@ extern "C"
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);

View File

@@ -16,10 +16,11 @@ extern "C"
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);
uint32_t waitForInterrupt(void* interrupt_pointer, double timeout, bool ignorePrevious, 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);
double readRisingTimestamp(void* interrupt_pointer, int32_t *status);
double readFallingTimestamp(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,

View File

@@ -11,6 +11,7 @@
#include <stdint.h>
#include "FRC_FPGA_ChipObject/RoboRIO_FRC_ChipObject_Aliases.h"
#include "FRC_FPGA_ChipObject/tDMAChannelDescriptor.h"
#include "FRC_FPGA_ChipObject/tDMAManager.h"
#include "FRC_FPGA_ChipObject/tInterruptManager.h"
#include "FRC_FPGA_ChipObject/tSystem.h"

View File

@@ -219,8 +219,8 @@ unsigned short getPWM(void* digital_port_pointer, int32_t *status) {
void latchPWMZero(void* digital_port_pointer, int32_t *status) {
DigitalPort* port = (DigitalPort*) digital_port_pointer;
pwmSystem->writeZeroLatch(1 << port->port.pin, true, status);
pwmSystem->writeZeroLatch(1 << port->port.pin, false, status);
pwmSystem->writeZeroLatch(port->port.pin, true, status);
pwmSystem->writeZeroLatch(port->port.pin, false, status);
}
/**
@@ -683,14 +683,11 @@ void setCounterUpSourceEdge(void* counter_pointer, bool risingEdge, bool falling
*/
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);
}
/**
@@ -738,14 +735,11 @@ void setCounterDownSourceEdge(void* counter_pointer, bool risingEdge, bool falli
*/
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);
}
/**
@@ -814,25 +808,6 @@ void setCounterSamplesToAverage(void* counter_pointer, int samplesToAverage, int
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
@@ -993,23 +968,6 @@ void freeEncoder(void* encoder_pointer, int32_t *status) {
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.

View File

@@ -4,7 +4,7 @@
#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
#define nInvariantFPGANamespace nFRC_C0EF_1_1_0
#endif // __FRC_FPGA_ChipObject_Aliases_h__

View File

@@ -4,6 +4,6 @@
#ifndef __RoboRIO_FRC_ChipObject_Aliases_h__
#define __RoboRIO_FRC_ChipObject_Aliases_h__
#define nRoboRIO_FPGANamespace nFRC_2015_1_0_8
#define nRoboRIO_FPGANamespace nFRC_2015_1_0_9
#endif // __RoboRIO_FRC_ChipObject_Aliases_h__

File diff suppressed because it is too large Load Diff

View File

@@ -1,15 +1,15 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_nInterfaceGlobals_h__
#define __nFRC_2015_1_0_8_nInterfaceGlobals_h__
#ifndef __nFRC_2015_1_0_9_nInterfaceGlobals_h__
#define __nFRC_2015_1_0_9_nInterfaceGlobals_h__
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
extern unsigned int g_currentTargetClass;
}
}
#endif // __nFRC_2015_1_0_8_nInterfaceGlobals_h__
#endif // __nFRC_2015_1_0_9_nInterfaceGlobals_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_AI_h__
#define __nFRC_2015_1_0_8_AI_h__
#ifndef __nFRC_2015_1_0_9_AI_h__
#define __nFRC_2015_1_0_9_AI_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tAI
@@ -140,4 +140,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_AI_h__
#endif // __nFRC_2015_1_0_9_AI_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_AO_h__
#define __nFRC_2015_1_0_8_AO_h__
#ifndef __nFRC_2015_1_0_9_AO_h__
#define __nFRC_2015_1_0_9_AO_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tAO
@@ -47,4 +47,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_AO_h__
#endif // __nFRC_2015_1_0_9_AO_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_Accel_h__
#define __nFRC_2015_1_0_8_Accel_h__
#ifndef __nFRC_2015_1_0_9_Accel_h__
#define __nFRC_2015_1_0_9_Accel_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tAccel
@@ -99,4 +99,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_Accel_h__
#endif // __nFRC_2015_1_0_9_Accel_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_Accumulator_h__
#define __nFRC_2015_1_0_8_Accumulator_h__
#ifndef __nFRC_2015_1_0_9_Accumulator_h__
#define __nFRC_2015_1_0_9_Accumulator_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tAccumulator
@@ -84,4 +84,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_Accumulator_h__
#endif // __nFRC_2015_1_0_9_Accumulator_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_Alarm_h__
#define __nFRC_2015_1_0_8_Alarm_h__
#ifndef __nFRC_2015_1_0_9_Alarm_h__
#define __nFRC_2015_1_0_9_Alarm_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tAlarm
@@ -54,4 +54,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_Alarm_h__
#endif // __nFRC_2015_1_0_9_Alarm_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_AnalogTrigger_h__
#define __nFRC_2015_1_0_8_AnalogTrigger_h__
#ifndef __nFRC_2015_1_0_9_AnalogTrigger_h__
#define __nFRC_2015_1_0_9_AnalogTrigger_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tAnalogTrigger
@@ -126,4 +126,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_AnalogTrigger_h__
#endif // __nFRC_2015_1_0_9_AnalogTrigger_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_BIST_h__
#define __nFRC_2015_1_0_8_BIST_h__
#ifndef __nFRC_2015_1_0_9_BIST_h__
#define __nFRC_2015_1_0_9_BIST_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tBIST
@@ -87,4 +87,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_BIST_h__
#endif // __nFRC_2015_1_0_9_BIST_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_Counter_h__
#define __nFRC_2015_1_0_8_Counter_h__
#ifndef __nFRC_2015_1_0_9_Counter_h__
#define __nFRC_2015_1_0_9_Counter_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tCounter
@@ -56,21 +56,21 @@ public:
unsigned IndexSource_Module : 1;
unsigned IndexSource_AnalogTrigger : 1;
unsigned IndexActiveHigh : 1;
unsigned IndexEdgeSensitive : 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 IndexEdgeSensitive : 1;
unsigned IndexActiveHigh : 1;
unsigned IndexSource_AnalogTrigger : 1;
unsigned IndexSource_Module : 1;
@@ -147,13 +147,13 @@ public:
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_IndexEdgeSensitive(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;
@@ -165,13 +165,13 @@ public:
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_IndexEdgeSensitive(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
@@ -216,4 +216,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_Counter_h__
#endif // __nFRC_2015_1_0_9_Counter_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_DIO_h__
#define __nFRC_2015_1_0_8_DIO_h__
#ifndef __nFRC_2015_1_0_9_DIO_h__
#define __nFRC_2015_1_0_9_DIO_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tDIO
@@ -245,4 +245,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_DIO_h__
#endif // __nFRC_2015_1_0_9_DIO_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_DMA_h__
#define __nFRC_2015_1_0_8_DMA_h__
#ifndef __nFRC_2015_1_0_9_DMA_h__
#define __nFRC_2015_1_0_9_DMA_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tDMA
@@ -185,4 +185,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_DMA_h__
#endif // __nFRC_2015_1_0_9_DMA_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_Encoder_h__
#define __nFRC_2015_1_0_8_Encoder_h__
#ifndef __nFRC_2015_1_0_9_Encoder_h__
#define __nFRC_2015_1_0_9_Encoder_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tEncoder
@@ -56,11 +56,11 @@ public:
unsigned IndexSource_Module : 1;
unsigned IndexSource_AnalogTrigger : 1;
unsigned IndexActiveHigh : 1;
unsigned IndexEdgeSensitive : 1;
unsigned Reverse : 1;
unsigned Enable : 1;
#else
unsigned Enable : 1;
unsigned Reverse : 1;
unsigned IndexEdgeSensitive : 1;
unsigned IndexActiveHigh : 1;
unsigned IndexSource_AnalogTrigger : 1;
unsigned IndexSource_Module : 1;
@@ -137,8 +137,8 @@ public:
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_IndexEdgeSensitive(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;
@@ -150,8 +150,8 @@ public:
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_IndexEdgeSensitive(tRioStatusCode *status) = 0;
virtual bool readConfig_Reverse(tRioStatusCode *status) = 0;
virtual bool readConfig_Enable(tRioStatusCode *status) = 0;
typedef enum
@@ -196,4 +196,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_Encoder_h__
#endif // __nFRC_2015_1_0_9_Encoder_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_Global_h__
#define __nFRC_2015_1_0_8_Global_h__
#ifndef __nFRC_2015_1_0_9_Global_h__
#define __nFRC_2015_1_0_9_Global_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tGlobal
@@ -101,4 +101,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_Global_h__
#endif // __nFRC_2015_1_0_9_Global_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_Interrupt_h__
#define __nFRC_2015_1_0_8_Interrupt_h__
#ifndef __nFRC_2015_1_0_9_Interrupt_h__
#define __nFRC_2015_1_0_9_Interrupt_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tInterrupt
@@ -54,9 +54,9 @@ public:
typedef enum
{
} tTimeStamp_IfaceConstants;
} tFallingTimeStamp_IfaceConstants;
virtual unsigned int readTimeStamp(tRioStatusCode *status) = 0;
virtual unsigned int readFallingTimeStamp(tRioStatusCode *status) = 0;
typedef enum
@@ -79,6 +79,13 @@ public:
virtual bool readConfig_WaitForAck(tRioStatusCode *status) = 0;
typedef enum
{
} tRisingTimeStamp_IfaceConstants;
virtual unsigned int readRisingTimeStamp(tRioStatusCode *status) = 0;
@@ -90,4 +97,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_Interrupt_h__
#endif // __nFRC_2015_1_0_9_Interrupt_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_PWM_h__
#define __nFRC_2015_1_0_8_PWM_h__
#ifndef __nFRC_2015_1_0_9_PWM_h__
#define __nFRC_2015_1_0_9_PWM_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tPWM
@@ -117,4 +117,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_PWM_h__
#endif // __nFRC_2015_1_0_9_PWM_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_Power_h__
#define __nFRC_2015_1_0_8_Power_h__
#ifndef __nFRC_2015_1_0_9_Power_h__
#define __nFRC_2015_1_0_9_Power_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tPower
@@ -214,4 +214,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_Power_h__
#endif // __nFRC_2015_1_0_9_Power_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_Relay_h__
#define __nFRC_2015_1_0_8_Relay_h__
#ifndef __nFRC_2015_1_0_9_Relay_h__
#define __nFRC_2015_1_0_9_Relay_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tRelay
@@ -65,4 +65,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_Relay_h__
#endif // __nFRC_2015_1_0_9_Relay_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_SPI_h__
#define __nFRC_2015_1_0_8_SPI_h__
#ifndef __nFRC_2015_1_0_9_SPI_h__
#define __nFRC_2015_1_0_9_SPI_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tSPI
@@ -65,4 +65,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_SPI_h__
#endif // __nFRC_2015_1_0_9_SPI_h__

View File

@@ -1,14 +1,14 @@
// Copyright (c) National Instruments 2008. All Rights Reserved.
// Do Not Edit... this file is generated!
#ifndef __nFRC_2015_1_0_8_SysWatchdog_h__
#define __nFRC_2015_1_0_8_SysWatchdog_h__
#ifndef __nFRC_2015_1_0_9_SysWatchdog_h__
#define __nFRC_2015_1_0_9_SysWatchdog_h__
#include "tSystemInterface.h"
namespace nFPGA
{
namespace nFRC_2015_1_0_8
namespace nFRC_2015_1_0_9
{
class tSysWatchdog
@@ -88,6 +88,13 @@ public:
virtual unsigned int readTimer(tRioStatusCode *status) = 0;
typedef enum
{
} tForcedKills_IfaceConstants;
virtual unsigned short readForcedKills(tRioStatusCode *status) = 0;
private:
@@ -98,4 +105,4 @@ private:
}
}
#endif // __nFRC_2015_1_0_8_SysWatchdog_h__
#endif // __nFRC_2015_1_0_9_SysWatchdog_h__

View File

@@ -0,0 +1,17 @@
// Describes the information needed to configure a DMA channel.
// Copyright (c) National Instruments 2008. All Rights Reserved.
#include <stdint.h>
#ifndef __tDMAChannelDescriptor_h__
#define __tDMAChannelDescriptor_h__
struct tDMAChannelDescriptor
{
uint32_t channel;
uint32_t baseAddress;
uint32_t depth;
bool targetToHost;
};
#endif // __tDMAChannelDescriptor_h__

View File

@@ -1,46 +1,41 @@
// Class for handling DMA transters.
// Class for handling DMA transfers.
// Copyright (c) National Instruments 2008. All Rights Reserved.
#ifndef __tDMAManager_h__
#define __tDMAManager_h__
#include "tSystem.h"
#include <stdint.h>
namespace nFPGA
{
// TODO: Implement DMA Manager
/*
class tDMAManager : public tSystem
{
public:
tDMAManager(tNIRIO_u32 dmaChannel, tNIRIO_u32 hostBufferSize, tRioStatusCode *status);
tDMAManager(uint32_t dmaChannel, uint32_t 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,
uint32_t* buf,
size_t num,
uint32_t timeout,
size_t* remaining,
tRioStatusCode *status);
void write(
tNIRIO_u32* buf,
tNIRIO_u32 num,
tNIRIO_u32 timeout,
tNIRIO_u32* remaining,
uint32_t* buf,
size_t num,
uint32_t timeout,
size_t* remaining,
tRioStatusCode *status);
private:
bool _started;
tNIRIO_u32 _dmaChannel;
tNIRIO_u32 _hostBufferSize;
tDMAChannelDescriptor const *_dmaChannelDescriptor;
uint32_t _dmaChannel;
uint32_t _hostBufferSize;
};
*/
}
#endif // __tDMAManager_h__

View File

@@ -28,11 +28,11 @@ 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);
uint32_t watch(int32_t timeoutInMs, bool ignorePrevious, tRioStatusCode *status);
void enable(tRioStatusCode *status);
void disable(tRioStatusCode *status);
bool isEnabled(tRioStatusCode *status);
private:
public:
class tInterruptThread;
friend class tInterruptThread;
void handler();
@@ -58,4 +58,3 @@ private:
#endif // __tInterruptManager_h__

View File

@@ -20,6 +20,7 @@ public:
tSystem(tRioStatusCode *status);
~tSystem();
void getFpgaGuid(uint32_t *guid_ptr, tRioStatusCode *status);
void reset(tRioStatusCode *status);
protected:
static NiFpga_Session _DeviceHandle;

View File

@@ -18,8 +18,10 @@ public:
virtual void getHardwareFpgaSignature(uint32_t *guid_ptr, tRioStatusCode *status)=0;
virtual uint32_t getLVHandle(tRioStatusCode *status)=0;
virtual uint32_t getHandle()=0;
virtual void reset(tRioStatusCode *status)=0;
};
}
#endif // __tSystemInterface_h__

View File

@@ -145,6 +145,7 @@ void HALSetNewDataSem(pthread_mutex_t * param)
*/
int HALInitialize(int mode)
{
FRC_NetworkCommunication_Reserve(nullptr);
// image 4; Fixes errors caused by multiple processes. Talk to NI about this
nFPGA::nRoboRIO_FPGANamespace::g_currentTargetClass =
nLoadOut::kTargetClass_RoboRIO;

View File

@@ -13,7 +13,8 @@ void* initializeInterrupts(uint32_t interruptIndex, bool watcher, int32_t *statu
// 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);
anInterrupt->manager = new tInterruptManager(
(1 << interruptIndex) | (1 << (interruptIndex + 8)), watcher, status);
return anInterrupt;
}
@@ -29,16 +30,29 @@ void cleanInterrupts(void* interrupt_pointer, int32_t *status)
/**
* In synchronous mode, wait for the defined interrupt to occur.
* @param timeout Timeout in seconds
* @param ignorePrevious If true, ignore interrupts that happened before
* waitForInterrupt was called.
* @return The mask of interrupts that fired.
*/
void waitForInterrupt(void* interrupt_pointer, double timeout, int32_t *status)
uint32_t waitForInterrupt(void* interrupt_pointer, double timeout, bool ignorePrevious, int32_t *status)
{
uint32_t result;
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
anInterrupt->manager->watch((int32_t)(timeout * 1e3), status);
result = anInterrupt->manager->watch((int32_t)(timeout * 1e3), ignorePrevious, status);
// Don't report a timeout as an error - the return code is enough to tell
// that a timeout happened.
if(*status == -NiFpga_Status_IrqTimeout) {
*status = NiFpga_Status_Success;
}
return result;
}
/**
* Enable interrupts to occur on this input.
* oInterrupts are disabled when the RequestInterrupt call is made. This gives time to do the
* Interrupts 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)
@@ -52,21 +66,31 @@ void enableInterrupts(void* interrupt_pointer, int32_t *status)
*/
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.
* Return the timestamp for the rising 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)
double readRisingTimestamp(void* interrupt_pointer, int32_t *status)
{
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
uint32_t timestamp = anInterrupt->anInterrupt->readTimeStamp(status);
uint32_t timestamp = anInterrupt->anInterrupt->readRisingTimeStamp(status);
return timestamp * 1e-6;
}
/**
* Return the timestamp for the falling interrupt that occurred most recently.
* This is in the same time domain as GetClock().
* @return Timestamp in seconds since boot.
*/
double readFallingTimestamp(void* interrupt_pointer, int32_t *status)
{
Interrupt* anInterrupt = (Interrupt*)interrupt_pointer;
uint32_t timestamp = anInterrupt->anInterrupt->readFallingTimeStamp(status);
return timestamp * 1e-6;
}

View File

@@ -32,6 +32,8 @@
#endif
#endif
#define ERR_FRCSystem_NetCommNotResponding -44049
enum AllianceStationID_t {
kAllianceStationID_red1,
kAllianceStationID_red2,
@@ -68,7 +70,7 @@ struct JoystickAxes_t {
struct JoystickPOV_t {
uint16_t count;
uint16_t povs[1];
int16_t povs[1];
};
#ifdef __cplusplus
@@ -81,9 +83,6 @@ extern "C" {
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);
#ifdef SIMULATION
@@ -101,9 +100,13 @@ extern "C" {
int EXPORT_FUNC FRC_NetworkCommunication_getControlWord(struct ControlWord_t *controlWord);
int EXPORT_FUNC FRC_NetworkCommunication_getAllianceStation(enum AllianceStationID_t *allianceStation);
int EXPORT_FUNC FRC_NetworkCommunication_getMatchTime(float *matchTime);
int EXPORT_FUNC FRC_NetworkCommunication_getJoystickAxes(uint8_t joystickNum, struct JoystickAxes_t *axes, uint8_t maxAxes);
int EXPORT_FUNC FRC_NetworkCommunication_getJoystickButtons(uint8_t joystickNum, uint32_t *buttons, uint8_t *count);
int EXPORT_FUNC FRC_NetworkCommunication_getJoystickPOVs(uint8_t joystickNum, struct JoystickPOV_t *povs, uint8_t maxPOVs);
int EXPORT_FUNC FRC_NetworkCommunication_setJoystickOutputs(uint8_t joystickNum, uint32_t hidOutputs, uint16_t leftRumble, uint16_t rightRumble);
int EXPORT_FUNC FRC_NetworkCommunication_getJoystickDesc(uint8_t joystickNum, uint8_t *isXBox, uint8_t *type, char *name,
uint8_t *axisCount, uint8_t *axisTypes, uint8_t *buttonCount, uint8_t *povCount);
void EXPORT_FUNC FRC_NetworkCommunication_getVersionString(char *version);
int EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramStarting(void);

BIN
ni-libraries/libFRC_NetworkCommunication.so.1.5.0 Normal file → Executable file

Binary file not shown.

BIN
ni-libraries/libFRC_NetworkCommunicationLV.so.1.5.0 Normal file → Executable file

Binary file not shown.

View File

@@ -1,2 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libNiFpga.so.13 )
GROUP ( libNiFpga.so.14 )

Binary file not shown.

View File

@@ -1,2 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libfrccansae.so.1 )
GROUP ( libNiFpga.so.14.0 )

View File

@@ -1,2 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libni_emb.so.6 )
GROUP ( libNiFpga.so.14.0.0 )

BIN
ni-libraries/libNiFpga.so.14.0.0 Executable file

Binary file not shown.

View File

@@ -1,2 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libNiFpgaLv.so.13 )
GROUP ( libNiFpgaLv.so.14 )

Binary file not shown.

View File

@@ -1,2 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libni_rtlog.so.2 )
GROUP ( libNiFpgaLv.so.14.0 )

View File

@@ -0,0 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libNiFpgaLv.so.14.0.0 )

Binary file not shown.

View File

@@ -1,2 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libNiRioSrv.so.13 )
GROUP ( libNiRioSrv.so.14 )

Binary file not shown.

View File

@@ -0,0 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libNiRioSrv.so.14.0 )

View File

@@ -0,0 +1,2 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libNiRioSrv.so.14.0.0 )

Binary file not shown.

BIN
ni-libraries/libRoboRIO_FRC_ChipObject.so.1.2.0 Normal file → Executable file

Binary file not shown.

Binary file not shown.

View File

@@ -1,2 +0,0 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libfrccansae.so.1.0.0 )

Binary file not shown.

Binary file not shown.

Binary file not shown.

0
ni-libraries/libi2c.so.1.0.0 Normal file → Executable file
View File

Binary file not shown.

Binary file not shown.

View File

@@ -1,2 +0,0 @@
OUTPUT_FORMAT(elf32-littlearm)
GROUP ( libnirio_emb_can.so.14 )

Binary file not shown.

Binary file not shown.

Binary file not shown.

0
ni-libraries/libspi.so.1.0.0 Normal file → Executable file
View File

Binary file not shown.

View File

@@ -9,7 +9,7 @@
#include "Task.h"
#include "HAL/cpp/Synchronized.hpp"
typedef void *(*TimerEventHandler)(void *param);
typedef void (*TimerEventHandler)(void *param);
class Notifier : public ErrorBase
{

View File

@@ -98,7 +98,7 @@ private:
void Initialize(float p, float i, float d, float f, PIDSource *source, PIDOutput *output,
float period = 0.05);
static void *CallCalculate(void *controller);
static void CallCalculate(void *controller);
virtual ITable* GetTable();
virtual std::string GetSmartDashboardType();

View File

@@ -14,15 +14,15 @@ class AnalogTrigger;
* This class is used to get the current output value and also as a DigitalSource
* to provide routing of an output to digital subsystems on the FPGA such as
* Counter, Encoder, and Interrupt.
*
*
* The TriggerState output indicates the primary output value of the trigger. If the analog
* signal is less than the lower limit, the output is false. If the analog value is greater
* than the upper limit, then the output is true. If the analog value is in between, then
* the trigger output state maintains its most recent value.
*
*
* The InWindow output indicates whether or not the analog signal is inside the range defined
* by the limits.
*
*
* The RisingPulse and FallingPulse outputs detect an instantaneous transition from above the
* upper limit to below the lower limit, and vise versa. These pulses represent a rollover
* condition of a sensor and can be routed to an up / down couter or to interrupts. Because
@@ -40,7 +40,7 @@ class AnalogTriggerOutput : public DigitalSource
{
friend class AnalogTrigger;
public:
virtual ~AnalogTriggerOutput();
bool Get();
@@ -48,8 +48,6 @@ public:
virtual uint32_t GetChannelForRouting();
virtual uint32_t GetModuleForRouting();
virtual bool GetAnalogTriggerForRouting();
virtual void RequestInterrupts(InterruptHandlerFunction handler, void *param = NULL); ///< Asynchronus handler version.
virtual void RequestInterrupts(); ///< Synchronus Wait version.
protected:
AnalogTriggerOutput(AnalogTrigger *trigger, AnalogTriggerType outputType);

View File

@@ -28,11 +28,6 @@ public:
virtual uint32_t GetModuleForRouting();
virtual bool GetAnalogTriggerForRouting();
// Interruptable Interface
virtual void RequestInterrupts(InterruptHandlerFunction handler, void *param = NULL); ///< Asynchronus handler version.
virtual void RequestInterrupts(); ///< Synchronus Wait version.
void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
void UpdateTable();
void StartLiveWindowMode();
void StopLiveWindowMode();

View File

@@ -32,10 +32,6 @@ public:
virtual uint32_t GetChannelForRouting();
virtual uint32_t GetModuleForRouting();
virtual bool GetAnalogTriggerForRouting();
virtual void RequestInterrupts(InterruptHandlerFunction handler, void *param);
virtual void RequestInterrupts();
void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
virtual void ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew);
void UpdateTable();

View File

@@ -21,6 +21,4 @@ public:
virtual uint32_t GetChannelForRouting() = 0;
virtual uint32_t GetModuleForRouting() = 0;
virtual bool GetAnalogTriggerForRouting() = 0;
virtual void RequestInterrupts(InterruptHandlerFunction handler, void *param) = 0;
virtual void RequestInterrupts() = 0;
};

View File

@@ -12,15 +12,27 @@
class InterruptableSensorBase : public SensorBase
{
public:
enum WaitResult {
kTimeout = 0x0,
kRisingEdge = 0x1,
kFallingEdge = 0x100,
kBoth = 0x101,
};
InterruptableSensorBase();
virtual ~InterruptableSensorBase();
virtual void RequestInterrupts(InterruptHandlerFunction handler, void *param) = 0; ///< Asynchronus handler version.
virtual void RequestInterrupts() = 0; ///< Synchronus Wait version.
virtual uint32_t GetChannelForRouting() = 0;
virtual uint32_t GetModuleForRouting() = 0;
virtual bool GetAnalogTriggerForRouting() = 0;
virtual void RequestInterrupts(InterruptHandlerFunction handler, void *param); ///< Asynchronus handler version.
virtual void RequestInterrupts(); ///< Synchronus Wait version.
virtual void CancelInterrupts(); ///< Free up the underlying chipobject functions.
virtual void WaitForInterrupt(float timeout); ///< Synchronus version.
virtual WaitResult WaitForInterrupt(float timeout, bool ignorePrevious = true); ///< Synchronus version.
virtual void EnableInterrupts(); ///< Enable interrupts - after finishing setup.
virtual void DisableInterrupts(); ///< Disable, but don't deallocate.
virtual double ReadInterruptTimestamp();///< Return the timestamp for the interrupt that occurred.
virtual double ReadRisingTimestamp();///< Return the timestamp for the rising interrupt that occurred.
virtual double ReadFallingTimestamp();///< Return the timestamp for the falling interrupt that occurred.
virtual void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
protected:
void* m_interrupt;
uint32_t m_interruptIndex;

View File

@@ -32,6 +32,8 @@
#endif
#endif
#define ERR_FRCSystem_NetCommNotResponding -44049
enum AllianceStationID_t {
kAllianceStationID_red1,
kAllianceStationID_red2,
@@ -68,7 +70,7 @@ struct JoystickAxes_t {
struct JoystickPOV_t {
uint16_t count;
uint16_t povs[1];
int16_t povs[1];
};
#ifdef __cplusplus
@@ -81,9 +83,6 @@ extern "C" {
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);
#ifdef SIMULATION
@@ -101,9 +100,13 @@ extern "C" {
int EXPORT_FUNC FRC_NetworkCommunication_getControlWord(struct ControlWord_t *controlWord);
int EXPORT_FUNC FRC_NetworkCommunication_getAllianceStation(enum AllianceStationID_t *allianceStation);
int EXPORT_FUNC FRC_NetworkCommunication_getMatchTime(float *matchTime);
int EXPORT_FUNC FRC_NetworkCommunication_getJoystickAxes(uint8_t joystickNum, struct JoystickAxes_t *axes, uint8_t maxAxes);
int EXPORT_FUNC FRC_NetworkCommunication_getJoystickButtons(uint8_t joystickNum, uint32_t *buttons, uint8_t *count);
int EXPORT_FUNC FRC_NetworkCommunication_getJoystickPOVs(uint8_t joystickNum, struct JoystickPOV_t *povs, uint8_t maxPOVs);
int EXPORT_FUNC FRC_NetworkCommunication_setJoystickOutputs(uint8_t joystickNum, uint32_t hidOutputs, uint16_t leftRumble, uint16_t rightRumble);
int EXPORT_FUNC FRC_NetworkCommunication_getJoystickDesc(uint8_t joystickNum, uint8_t *isXBox, uint8_t *type, char *name,
uint8_t *axisCount, uint8_t *axisTypes, uint8_t *buttonCount, uint8_t *povCount);
void EXPORT_FUNC FRC_NetworkCommunication_getVersionString(char *version);
int EXPORT_FUNC FRC_NetworkCommunication_observeUserProgramStarting(void);

View File

@@ -72,54 +72,3 @@ bool AnalogTriggerOutput::GetAnalogTriggerForRouting()
{
return true;
}
/**
* Request interrupts asynchronously on this analog trigger output.
* @param handler The address of the interrupt handler function of type tInterruptHandler that
* will be called whenever there is an interrupt on the digitial input port.
* Request interrupts in synchronus mode where the user program interrupt handler will be
* called when an interrupt occurs.
*/
void AnalogTriggerOutput::RequestInterrupts(InterruptHandlerFunction handler, void *param)
{
if (StatusIsFatal()) return;
uint32_t index = m_interrupts->Allocate("Async Interrupt");
if (index == ~0ul)
{
CloneError(m_interrupts);
return;
}
m_interruptIndex = index;
AllocateInterrupts(false);
int32_t status = 0;
requestInterrupts(m_interrupt, GetModuleForRouting(), GetChannelForRouting(),
GetAnalogTriggerForRouting(), &status);
attachInterruptHandler(m_interrupt, handler, param, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
/**
* Request interrupts synchronously on this analog trigger output.
* Request interrupts in asynchronus mode where the user program will have to
* explicitly wait for the interrupt to occur.
*/
void AnalogTriggerOutput::RequestInterrupts()
{
if (StatusIsFatal()) return;
uint32_t index = m_interrupts->Allocate("Sync Interrupt");
if (index == ~0ul)
{
CloneError(m_interrupts);
return;
}
m_interruptIndex = index;
AllocateInterrupts(true);
int32_t status = 0;
requestInterrupts(m_interrupt, GetModuleForRouting(), GetChannelForRouting(),
GetAnalogTriggerForRouting(), &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}

View File

@@ -32,11 +32,6 @@ void Counter::InitCounter(Mode mode)
m_allocatedDownSource = false;
HALReport(HALUsageReporting::kResourceType_Counter, index, mode);
if (StatusIsFatal()) return;
status = 0;
startCounter(m_counter, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
/**

View File

@@ -109,78 +109,6 @@ bool DigitalInput::GetAnalogTriggerForRouting()
return false;
}
/**
* Request interrupts asynchronously on this digital input.
* @param handler The address of the interrupt handler function of type tInterruptHandler that
* will be called whenever there is an interrupt on the digitial input port.
* Request interrupts in asynchronus mode where the user program interrupt handler will be
* called when an interrupt occurs.
* The default is interrupt on rising edges only.
*/
void DigitalInput::RequestInterrupts(InterruptHandlerFunction handler, void *param)
{
if (StatusIsFatal()) return;
uint32_t index = m_interrupts->Allocate("Async Interrupt");
if (index == ~0ul)
{
CloneError(m_interrupts);
return;
}
m_interruptIndex = index;
// Creates a manager too
AllocateInterrupts(false);
int32_t status = 0;
requestInterrupts(m_interrupt, GetModuleForRouting(), GetChannelForRouting(),
GetAnalogTriggerForRouting(), &status);
SetUpSourceEdge(true, false);
attachInterruptHandler(m_interrupt, handler, param, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
/**
* Request interrupts synchronously on this digital input.
* Request interrupts in synchronus mode where the user program will have to explicitly
* wait for the interrupt to occur.
* The default is interrupt on rising edges only.
*/
void DigitalInput::RequestInterrupts()
{
if (StatusIsFatal()) return;
uint32_t index = m_interrupts->Allocate("Sync Interrupt");
if (index == ~0ul)
{
CloneError(m_interrupts);
return;
}
m_interruptIndex = index;
AllocateInterrupts(true);
int32_t status = 0;
requestInterrupts(m_interrupt, GetModuleForRouting(), GetChannelForRouting(),
GetAnalogTriggerForRouting(), &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
SetUpSourceEdge(true, false);
}
void DigitalInput::SetUpSourceEdge(bool risingEdge, bool fallingEdge)
{
if (StatusIsFatal()) return;
if (m_interrupt == NULL)
{
wpi_setWPIErrorWithContext(NullParameter, "You must call RequestInterrupts before SetUpSourceEdge");
return;
}
if (m_interrupt != NULL)
{
int32_t status = 0;
setInterruptUpSourceEdge(m_interrupt, risingEdge, fallingEdge, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
void DigitalInput::UpdateTable() {
if (m_table != NULL) {
m_table->PutBoolean("Value", Get());

View File

@@ -222,78 +222,6 @@ bool DigitalOutput::GetAnalogTriggerForRouting()
return false;
}
/**
* Request interrupts asynchronously on this digital output.
* @param handler The address of the interrupt handler function of type tInterruptHandler that
* will be called whenever there is an interrupt on the digitial output port.
* Request interrupts in synchronus mode where the user program interrupt handler will be
* called when an interrupt occurs.
* The default is interrupt on rising edges only.
*/
void DigitalOutput::RequestInterrupts(InterruptHandlerFunction handler, void *param)
{
if (StatusIsFatal()) return;
uint32_t index = m_interrupts->Allocate("Sync Interrupt");
if (index == ~0ul)
{
CloneError(m_interrupts);
return;
}
m_interruptIndex = index;
// Creates a manager too
AllocateInterrupts(false);
int32_t status = 0;
requestInterrupts(m_interrupt, 1, GetChannelForRouting(),
GetAnalogTriggerForRouting(), &status);
SetUpSourceEdge(true, false);
attachInterruptHandler(m_interrupt, handler, param, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
/**
* Request interrupts synchronously on this digital output.
* Request interrupts in synchronus mode where the user program will have to explicitly
* wait for the interrupt to occur.
* The default is interrupt on rising edges only.
*/
void DigitalOutput::RequestInterrupts()
{
if (StatusIsFatal()) return;
uint32_t index = m_interrupts->Allocate("Sync Interrupt");
if (index == ~0ul)
{
CloneError(m_interrupts);
return;
}
m_interruptIndex = index;
AllocateInterrupts(true);
int32_t status = 0;
requestInterrupts(m_interrupt, GetModuleForRouting(), GetChannelForRouting(),
GetAnalogTriggerForRouting(), &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
SetUpSourceEdge(true, false);
}
void DigitalOutput::SetUpSourceEdge(bool risingEdge, bool fallingEdge)
{
if (StatusIsFatal()) return;
if (m_interrupt == NULL)
{
wpi_setWPIErrorWithContext(NullParameter, "You must call RequestInterrupts before SetUpSourceEdge");
return;
}
if (m_interrupt != NULL)
{
int32_t status = 0;
setInterruptUpSourceEdge(m_interrupt, risingEdge, fallingEdge, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
void DigitalOutput::ValueChanged(ITable* source, const std::string& key, EntryValue value, bool isNew) {
Set(value.b);
}

View File

@@ -67,13 +67,6 @@ void Encoder::InitEncoder(bool reverseDirection, EncodingType encodingType)
HALReport(HALUsageReporting::kResourceType_Encoder, index, encodingType);
LiveWindow::GetInstance()->AddSensor("Encoder", m_aSource->GetChannelForRouting(), this);
if (StatusIsFatal()) return;
if (!m_counter) {
int32_t status = 0;
startEncoder(m_encoder, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}
/**

View File

@@ -6,6 +6,7 @@
#include "InterruptableSensorBase.h"
#include "Utility.h"
#include "WPIErrors.h"
Resource *InterruptableSensorBase::m_interrupts = NULL;
@@ -20,6 +21,54 @@ InterruptableSensorBase::~InterruptableSensorBase()
}
void InterruptableSensorBase::RequestInterrupts(InterruptHandlerFunction handler, void *param)
{
if (StatusIsFatal()) return;
uint32_t index = m_interrupts->Allocate("Async Interrupt");
if (index == ~0ul)
{
CloneError(m_interrupts);
return;
}
m_interruptIndex = index;
// Creates a manager too
AllocateInterrupts(false);
int32_t status = 0;
requestInterrupts(m_interrupt, GetModuleForRouting(), GetChannelForRouting(),
GetAnalogTriggerForRouting(), &status);
SetUpSourceEdge(true, false);
attachInterruptHandler(m_interrupt, handler, param, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
/**
* Request interrupts synchronously on this digital input.
* Request interrupts in synchronus mode where the user program will have to explicitly
* wait for the interrupt to occur.
* The default is interrupt on rising edges only.
*/
void InterruptableSensorBase::RequestInterrupts()
{
if (StatusIsFatal()) return;
uint32_t index = m_interrupts->Allocate("Sync Interrupt");
if (index == ~0ul)
{
CloneError(m_interrupts);
return;
}
m_interruptIndex = index;
AllocateInterrupts(true);
int32_t status = 0;
requestInterrupts(m_interrupt, GetModuleForRouting(), GetChannelForRouting(),
GetAnalogTriggerForRouting(), &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
SetUpSourceEdge(true, false);
}
void InterruptableSensorBase::AllocateInterrupts(bool watcher)
{
wpi_assert(m_interrupt == NULL);
@@ -46,13 +95,20 @@ void InterruptableSensorBase::CancelInterrupts()
/**
* In synchronous mode, wait for the defined interrupt to occur.
* @param timeout Timeout in seconds
* @param ignorePrevious If true, ignore interrupts that happened before
* WaitForInterrupt was called.
* @return What interrupts fired
*/
void InterruptableSensorBase::WaitForInterrupt(float timeout)
InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(float timeout, bool ignorePrevious)
{
wpi_assert(m_interrupt != NULL);
int32_t status = 0;
waitForInterrupt(m_interrupt, timeout, &status);
uint32_t result;
result = waitForInterrupt(m_interrupt, timeout, ignorePrevious, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
return static_cast<WaitResult>(result);
}
/**
@@ -80,15 +136,57 @@ void InterruptableSensorBase::DisableInterrupts()
}
/**
* Return the timestamp for the interrupt that occurred most recently.
* Return the timestamp for the rising interrupt that occurred most recently.
* This is in the same time domain as GetClock().
* The rising-edge interrupt should be enabled with
* {@link #DigitalInput.SetUpSourceEdge}
* @return Timestamp in seconds since boot.
*/
double InterruptableSensorBase::ReadInterruptTimestamp()
double InterruptableSensorBase::ReadRisingTimestamp()
{
wpi_assert(m_interrupt != NULL);
int32_t status = 0;
double timestamp = readInterruptTimestamp(m_interrupt, &status);
double timestamp = readRisingTimestamp(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
return timestamp;
}
/**
* Return the timestamp for the falling interrupt that occurred most recently.
* This is in the same time domain as GetClock().
* The falling-edge interrupt should be enabled with
* {@link #DigitalInput.SetUpSourceEdge}
* @return Timestamp in seconds since boot.
*/
double InterruptableSensorBase::ReadFallingTimestamp()
{
wpi_assert(m_interrupt != NULL);
int32_t status = 0;
double timestamp = readFallingTimestamp(m_interrupt, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
return timestamp;
}
/**
* Set which edge to trigger interrupts on
*
* @param risingEdge
* true to interrupt on rising edge
* @param fallingEdge
* true to interrupt on falling edge
*/
void InterruptableSensorBase::SetUpSourceEdge(bool risingEdge, bool fallingEdge)
{
if (StatusIsFatal()) return;
if (m_interrupt == NULL)
{
wpi_setWPIErrorWithContext(NullParameter, "You must call RequestInterrupts before SetUpSourceEdge");
return;
}
if (m_interrupt != NULL)
{
int32_t status = 0;
setInterruptUpSourceEdge(m_interrupt, risingEdge, fallingEdge, &status);
wpi_setErrorWithContext(status, getHALErrorMessage(status));
}
}

View File

@@ -5,7 +5,6 @@
/*----------------------------------------------------------------------------*/
#include "PIDController.h"
//#include "NetworkCommunication/UsageReporting.h"
#include "Notifier.h"
#include "PIDSource.h"
#include "PIDOutput.h"
@@ -56,6 +55,20 @@ PIDController::PIDController(float Kp, float Ki, float Kd, float Kf,
Initialize(Kp, Ki, Kd, Kf, source, output, period);
}
struct CallerInfo
{
TimerEventHandler fn;
void* data;
};
static void* forwardCallCalculate(CallerInfo* rdata)
{
CallerInfo data = *rdata;
delete rdata;
data.fn(data.data);
return nullptr;
}
void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf,
PIDSource *source, PIDOutput *output,
float period)
@@ -92,7 +105,11 @@ void PIDController::Initialize(float Kp, float Ki, float Kd, float Kf,
pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
pthread_mutex_init(&m_mutex, &mutexattr);
pthread_create(&m_controlLoop, NULL, PIDController::CallCalculate, this);
CallerInfo *ci = new CallerInfo();
ci->fn = &CallCalculate;
ci->data = this;
pthread_create(&m_controlLoop, NULL, (void*(*)(void*))&forwardCallCalculate, ci);
//forwardCallCalculate will delete the obj, no need to delete it ourselves
static int32_t instances = 0;
instances++;
@@ -122,7 +139,7 @@ PIDController::~PIDController()
* This method is static and called by pthreads.
* @param controller the address of the PID controller object to use in the background loop
*/
void *PIDController::CallCalculate(void *data)
void PIDController::CallCalculate(void *data)
{
PIDController *controller = (PIDController*) data;
int destruct = 0;
@@ -137,8 +154,6 @@ void *PIDController::CallCalculate(void *data)
Wait(controller->m_period);
}
return NULL;
}
/**

View File

@@ -308,7 +308,7 @@ TEST_F(CANJaguarTest, PositionModeWorks) {
* Test if we can set a current setpoint with PID control on the Jaguar and get
* a corresponding output current
*/
TEST_F(CANJaguarTest, CurrentModeWorks) {
TEST_F(CANJaguarTest, DISABLED_CurrentModeWorks) {
m_jaguar->SetCurrentMode(10.0, 4.0, 1.0);
m_jaguar->EnableControl();

Some files were not shown because too many files have changed in this diff Show More