Compare commits

...

70 Commits

Author SHA1 Message Date
Vasista Vovveti
38611e9dd7 [hal] Fix REVPH Analog Pressure channel selection (#3716) 2021-11-10 18:22:18 -08:00
sciencewhiz
4d78def31e [wpilib] Add DeadbandElimination forwarding to PWMMotorController (#3714) 2021-11-09 21:24:47 -08:00
Tyler Veness
3be0c1217a [wpilibcExamples] Make GearsBot use idiomatic C++ (#3711)
Replace pointer constructor arguments with references, and const qualify
getters where possible.

Also remove redundant simulation P gain.

Fixes #1146.
2021-11-09 20:11:50 -08:00
Tyler Veness
42d3a50aa2 [hal] Check error codes during serial port initialization (#3712)
Throw if serial port init fails.

Fixes #2036.
2021-11-09 20:10:48 -08:00
PJ Reiniger
52f1464029 Add project with field images and their json config files (#3668) 2021-11-08 22:48:16 -08:00
Thad House
68ce62e2e9 [hal] Add autodetect for power modules (#3706)
Default autodetect to REV if no devices are found, as only the REV devices have control functionality (the switchable output).
2021-11-07 13:53:38 -08:00
Thad House
3dd41c0d37 [wpilib] Don't print PD errors for LiveWindow reads (#3708)
If something happens with the PD connection, these would have spammed messages continuously.
This wasn't the case previously, and we don't want this behavior now.
2021-11-07 13:45:28 -08:00
Thad House
7699a1f827 [hal] Fix sim not working with automatic PD type and default module (#3707) 2021-11-05 23:30:10 -07:00
Peter Johnson
e473a00f97 [wpiutil] Base64: Add unsigned span/vector variants (#3702) 2021-11-01 07:48:26 -07:00
Peter Johnson
52f2d580eb [wpiutil] raw_uv_ostream: Add reset() (#3701)
This enables reuse of a raw_uv_ostream object.
2021-11-01 07:47:13 -07:00
Peter Johnson
d7b1e3576f [wpiutil] WebSocket: move std::function (#3700) 2021-11-01 07:46:15 -07:00
sciencewhiz
93799fbe9d [examples] Fix description of TrapezoidProfileSubsystem (#3699) 2021-11-01 00:08:53 -07:00
Tyler Veness
b84644740d [wpimath] Document pose estimator states, inputs, and outputs (#3698)
Fixes #3244.
2021-10-29 17:37:13 -07:00
Tyler Veness
2dc35c1399 [wpimath] Fix classpaths for JNI class loads (#3697)
Found by inspecting the results of the following rg commands:
`rg --multiline 'FindClass\(\s*"'`
`rg 'JClass' -A 1`

Fixes #3660.
2021-10-29 16:23:46 -07:00
Tyler Veness
2cb171f6f5 [docs] Set Doxygen extract_all to true and fix Doxygen failures (#3695)
The template argument order for UnscentedTransform was reversed to match
all the other UKF classes. Since UnscentedTransform is intended as a
class for internal use only, this shouldn't cause much breakage.
2021-10-29 15:07:05 -07:00
Tyler Veness
a939cd9c89 [wpimath] Print uncontrollable/unobservable models in LQR and KF (#3694)
IsDetectable() was added to make the code easier to read.
2021-10-29 00:03:02 -07:00
Tyler Veness
d5270d113b [wpimath] Clean up C++ StateSpaceUtil tests (#3692) 2021-10-29 00:02:03 -07:00
Tyler Veness
b20903960b [wpimath] Remove redundant discretization tests from StateSpaceUtilTest (#3689)
DiscretizationTest already does these.
2021-10-29 00:01:41 -07:00
Tyler Veness
c0cb545b41 [wpilibc] Add deprecated Doxygen attribute to SpeedController (#3691)
Fixes #3690.
2021-10-29 00:01:04 -07:00
Tyler Veness
35c9f66a75 [wpilib] Rename PneumaticsHub to PneumaticHub (#3686)
Fixes #3684.
2021-10-29 00:00:31 -07:00
Tyler Veness
796d03d105 [wpiutil] Remove unused LLVM header (#3688) 2021-10-28 00:18:26 -07:00
Tyler Veness
8723caf78d [wpilibj] Make Java TrapezoidProfile.Constraints an immutable class (#3687) 2021-10-28 00:17:36 -07:00
Tyler Veness
187f50a344 [wpimath] Catch incorrect parameters to state-space models earlier (#3680)
This allows giving more descriptive exceptions than if they are thrown
later in KalmanFilter, for example.

Fixes #3678.
2021-10-27 20:18:57 -07:00
Tyler Veness
8d04606c4d Replace instances of frc-characterization with SysId (NFC) (#3681) 2021-10-27 06:40:17 -07:00
Peter Johnson
b82d4f6e58 [hal, cscore, ntcore] Use WPI common handle type base 2021-10-26 23:39:11 -07:00
Peter Johnson
87e34967ef [wpiutil] Add synchronization primitives
These enable more consistent use of synchronization across the
native libraries.  Users can create Event and Semaphore primitives, but
in addition, libraries can set up any handle as an Event-type signal.
2021-10-26 23:39:11 -07:00
Peter Johnson
e32499c546 [wpiutil] Add ParallelTcpConnector (#3655)
This is a libuv-based parallel, repeating TCP connector for making
multiple parallel DNS resolution and TCP connection attempts to a
network server.
2021-10-26 23:37:58 -07:00
Tyler Veness
aa0b49228d [wpilib] Remove redundant "quick turn" docs for curvature drive (NFC) (#3674)
The parameter docs for allowTurnInPlace say the same thing, and it's no
longer called "quick turn".
2021-10-26 23:37:11 -07:00
Noah Andrews
57301a7f9c [hal] REVPH: Start closed-loop compressor control on init (#3673)
Similar to the PCM, we're going to make the PH not do anything with the compressor until the PH HAL object has been initialized. The mechanism we're going to use to signal to the PH that that has happened is to begin sending the state of the solenoids (which will all be set to off at this point).
2021-10-26 23:36:47 -07:00
sciencewhiz
d1842ea8fb [wpilib] Improve interrupt docs (NFC) (#3679) 2021-10-26 23:35:01 -07:00
Peter Johnson
558151061e [wpiutil] Add DsClient (#3654)
This is a libuv-based implementation of the Driver Station client
for getting robot IPs from the Driver Station port 1742 server.
2021-10-26 23:34:27 -07:00
Tyler Veness
181723e573 Replace .to<double>() and .template to<double>() with .value() (#3667)
It's a less verbose way to do the same thing.
2021-10-25 08:58:12 -07:00
sciencewhiz
6bc1db44bc [commands] Add pointer overload of AddRequirements (artf6003) (#3669)
Also update documentation in CommandBase.
2021-10-25 08:57:22 -07:00
Tyler Veness
737b57ed5f [wpimath] Update to drake v0.35.0 (#3665) 2021-10-22 23:02:08 -07:00
Austin Shalit
4d287d1ae2 [build] Upgrade WPIJREArtifact to JRE 2022-11.0.12u5 (#3666) 2021-10-22 23:01:09 -07:00
apple
f26eb5ada4 [hal] Fix another typo (get -> gets) (NFC) (#3663) 2021-10-22 11:49:21 -07:00
apple
94ed275ba6 [hal] Fix misspelling (numer -> number) (NFC) (#3662) 2021-10-22 07:23:13 -07:00
Peter Johnson
ac2f44da33 [wpiutil] uv: use move for std::function (#3653)
Also use function_ref for Loop::Walk().
2021-10-20 23:24:59 -07:00
Peter Johnson
75fa1fbfbf [wpiutil] json::serializer: Optimize construction (#3647)
Remove unused locale pointer.
2021-10-20 21:09:04 -07:00
Peter Johnson
5e689faea8 [wpiutil] Import MessagePack implementation (mpack) (#3650) 2021-10-20 21:08:31 -07:00
Peter Johnson
649a50b401 [wpiutil] Add LEB128 byte-by-byte reader (#3652)
This is needed for compatibility with streaming data (e.g. libuv) where partial data
may be received.  Also add raw_ostream writer.
2021-10-20 18:50:20 -07:00
Peter Johnson
e94397a97d [wpiutil] Move json_serializer.h to public headers (#3646)
This makes it possible to do "manual" JSON-compliant serialization more efficiently
(e.g. without needing to construct a full json object).
2021-10-20 11:18:13 -07:00
Peter Johnson
4ec58724d7 [wpiutil] uv::Tcp: Clarify SetNoDelay documentation (#3649) 2021-10-20 08:46:44 -07:00
Peter Johnson
8cb294aa4a [wpiutil] WebSocket: Make Shutdown() public (#3651) 2021-10-20 08:45:58 -07:00
Peter Johnson
2b3a9a52b3 [wpiutil] json: Fix map iterator key() for std::string_view (#3645) 2021-10-20 08:45:16 -07:00
Peter Johnson
138cbb94b2 [wpiutil] uv::Async: Add direct call for no-parameter specialization (#3648) 2021-10-20 08:44:33 -07:00
sciencewhiz
e56d6dea81 [ci] Update testbench pool image to ubuntu-latest (#3643) 2021-10-18 21:39:43 -07:00
sciencewhiz
43f30e44e4 [build] Enable comments in doxygen source files (#3644) 2021-10-18 21:39:22 -07:00
sciencewhiz
9e6db17ef4 [build] Enable doxygen preprocessor expansion of WPI_DEPRECATED (#3642)
This fixes documentation for SpeedController and SpeedControllerGroup
2021-10-18 21:29:23 -07:00
sciencewhiz
0e631ad2f2 Add WPILib version to issue template (#3641) 2021-10-18 09:09:57 -07:00
Austin Shalit
6229d8d2ff [build] Docs: set case_sense_names to false (#3392)
This means the output will be consistent for all 3 major os and prevent case issues when sharing files.
2021-10-15 00:37:59 -07:00
Tyler Veness
4647d09b50 [docs] Fix Doxygen warnings, add CI docs lint job (#3639)
The CI docs lint build is configured to fail on Doxygen warnings.
2021-10-14 18:09:38 -07:00
sciencewhiz
4ad3a54026 [hal] Fix PWM allocation channel (#3637)
Previously it showed 31 when 0 was doubly allocated
2021-10-14 07:28:49 -07:00
sciencewhiz
05e5feac41 [docs] Fix brownout docs (NFC) (#3638) 2021-10-14 07:28:21 -07:00
Prateek Machiraju
67df469c58 [examples] Remove old command-based templates and examples (#3263)
Co-authored-by: Tyler Veness <calcmogul@gmail.com>
2021-10-13 19:17:58 -07:00
Thad House
689e9ccfb5 [hal, wpilib] Add brownout voltage configuration (#3632) 2021-10-13 19:14:27 -07:00
sciencewhiz
9cd4bc407a [docs] Add useLocal to avoid using installer artifacts (#3634) 2021-10-13 10:38:33 -07:00
Peter Johnson
61996c2bbf [cscore] Fix Java direct callback notifications (#3631)
These relied on the OnStart and OnExit callbacks which were not present
in the wpiutil common CallbackManager code.  Add support for these and
fix up other use cases.

Also fixes notifications to correctly filter on event kind.

This fixes a breakage caused by #3133.
2021-10-13 08:46:07 -07:00
Thad House
6d3dd99eb2 [build] Update to newest native-utils (#3633) 2021-10-13 07:47:10 -07:00
Tyler Veness
f0b484892c [wpiutil] Fix StringMap iterator equality check (#3629)
This fixes the following warning.
The member function operator== only works in C++17, and the friend operator== only works in C++20.

```
 /Users/runner/.gradle/caches/transforms-2/files-2.1/c671f5a5dff922b8870f4eb33f4c8e2a/wpiutil-cpp-2022.1.1-alpha-3-1-g4e3fd7d-headers/wpi/json.h:1847:46: warning: ISO C++20 considers use of overloaded operator '==' (with operand types 'const typename json::object_t::iterator' (aka 'const StringMapIterator<wpi::json>') and 'const typename json::object_t::iterator') to be ambiguous despite there being a unique best viable function [-Wambiguous-reversed-operator]
                return (m_it.object_iterator == other.m_it.object_iterator);
                        ~~~~~~~~~~~~~~~~~~~~ ^  ~~~~~~~~~~~~~~~~~~~~~~~~~~
/Users/runner/.gradle/caches/transforms-2/files-2.1/c671f5a5dff922b8870f4eb33f4c8e2a/wpiutil-cpp-2022.1.1-alpha-3-1-g4e3fd7d-headers/wpi/json.h:1863:20: note: in instantiation of member function 'wpi::detail::iter_impl<const wpi::json>::operator==' requested here
        return not operator==(other);
                   ^
/Users/runner/.gradle/caches/transforms-2/files-2.1/c671f5a5dff922b8870f4eb33f4c8e2a/wpiutil-cpp-2022.1.1-alpha-3-1-g4e3fd7d-headers/wpi/json.h:5008:20: note: in instantiation of member function 'wpi::detail::iter_impl<const wpi::json>::operator!=' requested here
            if (it != end())
                   ^
/Users/runner/.gradle/caches/transforms-2/files-2.1/c671f5a5dff922b8870f4eb33f4c8e2a/wpiutil-cpp-2022.1.1-alpha-3-1-g4e3fd7d-headers/wpi/json.h:5025:16: note: in instantiation of function template specialization 'wpi::json::value<std::basic_string<char>, 0>' requested here
        return value(key, std::string(default_value));
               ^
/Users/runner/.gradle/caches/transforms-2/files-2.1/c671f5a5dff922b8870f4eb33f4c8e2a/wpiutil-cpp-2022.1.1-alpha-3-1-g4e3fd7d-headers/wpi/StringMap.h:442:8: note: ambiguity is between a regular call to this operator and a call with the argument order reversed
  bool operator==(const DerivedTy &RHS) const { return Ptr == RHS.Ptr; }
       ^
```
2021-10-12 23:28:26 -07:00
Lucas
8352cbb7a3 Update development build instructions for 2022 (#3616)
Updates the instructions for development and local WPILib builds as per the GradleRIO 2022 updates.
2021-10-12 22:47:16 -07:00
sciencewhiz
6da08b71dc [examples] Fix Intermediate Vision Java Example description (#3628)
Copy from C++
2021-10-11 22:55:33 -07:00
Peter Johnson
5d99059bf9 [wpiutil] Remove optional.h (#3627)
This has been replaced fully by std::optional and deprecated for a year.
2021-10-11 22:54:33 -07:00
Tyler Veness
fa41b106ab [glass, wpiutil] Add missing format args (#3626)
These were caught by compile-time format string parsing in C++20.
2021-10-11 22:54:20 -07:00
Thad House
4e3fd7d420 [build] Enable Zc:__cplusplus for Windows (#3625)
This makes the version actually be correct.
2021-10-11 20:30:22 -07:00
Starlight220
791d8354da [build] Suppress deprecation/removal warnings for old commands (#3618) 2021-10-10 20:07:12 -07:00
Thad House
10f19e6fc3 [hal, wpilib] Add REV PneumaticsHub (#3600) 2021-10-10 20:04:50 -07:00
Peter Johnson
4c61a13057 [ntcore] Revert to per-element copy for toNative() (#3621)
arraycopy() does not unbox values, so throws an exception.

This was broken in #3419 due to a false positive in PMD
(see https://sourceforge.net/p/pmd/bugs/804/).
2021-10-10 15:53:35 -07:00
Peter Johnson
7b3f62244f [wpiutil] SendableRegistry: Print exception stacktrace (#3620) 2021-10-10 15:53:11 -07:00
Thad House
d347928e4d [hal] Use better error for when console out is enabled while attempting to use onboard serial port (#3622) 2021-10-10 15:52:50 -07:00
596 changed files with 30716 additions and 5981 deletions

View File

@@ -22,7 +22,8 @@ A clear and concise description of what you expected to happen.
If applicable, add screenshots to help explain your problem.
**Desktop (please complete the following information):**
- OS: [e.g. Windows]
- WPILib Version: [e.g. 2021.3.1]
- OS: [e.g. Windows 11]
- Java version [e.g. 1.10.2]
- C++ version [e.g. 17]

View File

@@ -84,3 +84,17 @@ jobs:
- name: Generate diff
run: git diff HEAD > javaformat-fixes.patch
if: ${{ failure() }}
documentation:
name: "Documentation"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- uses: actions/setup-java@v1
with:
java-version: 13
- name: Install libclang-9
run: sudo apt update && sudo apt install -y libclang-cpp9 libclang1-9
- name: Build with Gradle
run: ./gradlew docs:zipDocs -PbuildServer -PdocWarningsAsErrors ${{ env.EXTRA_GRADLE_ARGS }}

View File

@@ -16,6 +16,7 @@ modifiableFileExclude {
generatedFileExclude {
FRCNetComm\.java$
simulation/gz_msgs/src/include/simulation/gz_msgs/msgs\.h$
fieldImages/src/main/native/resources/
}
repoRootNameOverride {

View File

@@ -119,13 +119,6 @@ FATAL: Cannot build wpilib without wpimath.
")
endif()
if (NOT WITH_OLD_COMMANDS AND WITH_EXAMPLES)
message(FATAL_ERROR "
FATAL: Cannot build examples with old commands disabled.
Enable old commands by setting WITH_OLD_COMMANDS=ON
")
endif()
set( wpilib_dest wpilib)
set( include_dest wpilib/include )
set( main_lib_dest wpilib/lib )
@@ -246,6 +239,7 @@ if (WITH_TESTS)
include(GoogleTest)
endif()
add_subdirectory(fieldImages)
add_subdirectory(wpiutil)
add_subdirectory(ntcore)

View File

@@ -12,8 +12,8 @@ In order to build a project using a development build, find the build.gradle fil
```groovy
wpi.maven.useDevelopment = true
wpi.wpilibVersion = 'YEAR.+'
wpi.wpimathVersion = 'YEAR.+
wpi.versions.wpilibVersion = 'YEAR.+'
wpi.versions.wpimathVersion = 'YEAR.+
```
The top of your ``build.gradle`` file should now look similar to the code below. Ignore any differences in versions.
@@ -22,12 +22,13 @@ Java
```groovy
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2020.3.2"
id "edu.wpi.first.GradleRIO" version "2022.1.1"
}
wpi.maven.useLocal = false
wpi.maven.useDevelopment = true
wpi.wpilibVersion = '2021.+'
wpi.wpimathVersion = '2021.+'
wpi.versions.wpilibVersion = '2022.+'
wpi.versions.wpimathVersion = '2022.+'
```
C++
@@ -35,12 +36,13 @@ C++
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2020.3.2"
id "edu.wpi.first.GradleRIO" version "2022.1.1"
}
wpi.maven.useLocal = false
wpi.maven.useDevelopment = true
wpi.wpilibVersion = '2021.+'
wpi.wpimathVersion = '2021.+'
wpi.versions.wpilibVersion = '2022.+'
wpi.versions.wpimathVersion = '2022.+'
```
## Local Build
@@ -51,12 +53,13 @@ Java
```groovy
plugins {
id "java"
id "edu.wpi.first.GradleRIO" version "2020.3.2"
id "edu.wpi.first.GradleRIO" version "2022.1.1"
}
wpi.maven.useLocal = false
wpi.maven.useFrcMavenLocalDevelopment = true
wpi.wpilibVersion = 'YEAR.424242.+'
wpi.wpimathVersion = 'YEAR.424242.+'
wpi.versions.wpilibVersion = 'YEAR.424242.+'
wpi.versions.wpimathVersion = 'YEAR.424242.+'
```
C++
@@ -64,12 +67,13 @@ C++
plugins {
id "cpp"
id "google-test-test-suite"
id "edu.wpi.first.GradleRIO" version "2020.3.2"
id "edu.wpi.first.GradleRIO" version "2022.1.1"
}
wpi.maven.useLocal = false
wpi.maven.useFrcMavenLocalDevelopment = true
wpi.wpilibVersion = 'YEAR.424242.+'
wpi.wpimathVersion = 'YEAR.424242.+'
wpi.versions.wpilibVersion = 'YEAR.424242.+'
wpi.versions.wpimathVersion = 'YEAR.424242.+'
```
# roboRIO Development

View File

@@ -32,6 +32,8 @@ sigslot wpiutil/src/main/native/include/wpi/Signal.h
wpiutil/src/test/native/cpp/sigslot/
tcpsockets wpiutil/src/main/native/cpp/TCP{Stream,Connector,Acceptor}.cpp
wpiutil/src/main/native/include/wpi/TCP*.h
MPack wpiutil/src/main/native/include/mpack.h
wpiutil/src/main/native/cpp/mpack.cpp
Bootstrap wpiutil/src/main/native/resources/bootstrap-*
CoreUI wpiutil/src/main/native/resources/coreui-*
Feather Icons wpiutil/src/main/native/resources/feather-*
@@ -235,6 +237,32 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================
MPacks License
==============================================================================
The MIT License (MIT)
Copyright (c) 2015-2021 Nicholas Fraser and the MPack authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
==============================================================================
Bootstrap License
==============================================================================

View File

@@ -12,7 +12,7 @@ stages:
- job: IntegrationTests
displayName: Integration Tests
pool:
vmImage: "Ubuntu 16.04"
vmImage: 'ubuntu-latest'
container:
image: wpilib/roborio-cross-ubuntu:2022-18.04

View File

@@ -5,5 +5,5 @@ repositories {
}
}
dependencies {
implementation "edu.wpi.first:native-utils:2022.3.0"
implementation "edu.wpi.first:native-utils:2022.3.1"
}

View File

@@ -24,7 +24,7 @@ public class WPIJREArtifact extends MavenArtifact {
this.configName = configName;
Project project = target.getProject();
getConfiguration().set(project.getConfigurations().create(configName));
getDependency().set(project.getDependencies().add(configName, "edu.wpi.first.jdk:roborio-2022:11.0.9u12-1"));
getDependency().set(project.getDependencies().add(configName, "edu.wpi.first.jdk:roborio-2022:11.0.12u5-1"));
setOnlyIf(new PredicateWrapper({ DeployContext ctx ->
return jreMissing(ctx) || project.hasProperty("force-redeploy-jre");

View File

@@ -229,6 +229,7 @@ class CameraServer {
* Adds a MJPEG server.
*
* @param name Server name
* @param port Port number
*/
static cs::MjpegServer AddServer(std::string_view name, int port);

View File

@@ -44,7 +44,7 @@ class VisionRunnerBase {
*
* <p>This method is exposed to allow teams to add additional functionality or
* have their own ways to run the pipeline. Most teams, however, should just
* use {@link #runForever} in its own thread using a std::thread.</p>
* use RunForever() in its own thread using a std::thread.</p>
*/
void RunOnce();

View File

@@ -5,6 +5,8 @@
#ifndef CSCORE_HANDLE_H_
#define CSCORE_HANDLE_H_
#include <wpi/Synchronization.h>
#include "cscore_c.h"
namespace cs {
@@ -18,7 +20,7 @@ class Handle {
public:
enum Type {
kUndefined = 0,
kProperty = 0x40,
kProperty = wpi::kHandleTypeCSBase,
kSource,
kSink,
kListener,

View File

@@ -35,8 +35,11 @@ struct ListenerData : public wpi::CallbackListenerData<
class NotifierThread
: public wpi::CallbackThread<NotifierThread, RawEvent, ListenerData> {
public:
bool Matches(const ListenerData& /*listener*/, const RawEvent& /*data*/) {
return true;
NotifierThread(std::function<void()> on_start, std::function<void()> on_exit)
: CallbackThread(std::move(on_start), std::move(on_exit)) {}
bool Matches(const ListenerData& listener, const RawEvent& data) {
return (data.kind & listener.eventMask) != 0;
}
void SetListener(RawEvent* data, unsigned int listener_uid) {

View File

@@ -708,9 +708,13 @@ void ReleaseSink(CS_Sink sink, CS_Status* status) {
// Listener Functions
//
void SetListenerOnStart(std::function<void()> onStart) {}
void SetListenerOnStart(std::function<void()> onStart) {
Instance::GetInstance().notifier.SetOnStart(onStart);
}
void SetListenerOnExit(std::function<void()> onExit) {}
void SetListenerOnExit(std::function<void()> onExit) {
Instance::GetInstance().notifier.SetOnExit(onExit);
}
static void StartBackground(int eventMask, bool immediateNotify) {
auto& inst = Instance::GetInstance();

View File

@@ -570,7 +570,6 @@ class AxisCamera : public HttpCamera {
*
* @param name Source name (arbitrary unique identifier)
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
* @param kind Camera kind (e.g. kAxis)
*/
AxisCamera(std::string_view name, std::string_view host);
@@ -579,7 +578,6 @@ class AxisCamera : public HttpCamera {
*
* @param name Source name (arbitrary unique identifier)
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
* @param kind Camera kind (e.g. kAxis)
*/
AxisCamera(std::string_view name, const char* host);
@@ -588,7 +586,6 @@ class AxisCamera : public HttpCamera {
*
* @param name Source name (arbitrary unique identifier)
* @param host Camera host IP or DNS name (e.g. "10.x.y.11")
* @param kind Camera kind (e.g. kAxis)
*/
AxisCamera(std::string_view name, const std::string& host);
@@ -597,7 +594,6 @@ class AxisCamera : public HttpCamera {
*
* @param name Source name (arbitrary unique identifier)
* @param hosts Array of Camera host IPs/DNS names
* @param kind Camera kind (e.g. kAxis)
*/
AxisCamera(std::string_view name, wpi::span<const std::string> hosts);
@@ -606,7 +602,6 @@ class AxisCamera : public HttpCamera {
*
* @param name Source name (arbitrary unique identifier)
* @param hosts Array of Camera host IPs/DNS names
* @param kind Camera kind (e.g. kAxis)
*/
template <typename T>
AxisCamera(std::string_view name, std::initializer_list<T> hosts);
@@ -623,6 +618,8 @@ class ImageSource : public VideoSource {
/**
* Signal sinks that an error has occurred. This should be called instead
* of NotifyFrame when an error occurs.
*
* @param msg Notification message.
*/
void NotifyError(std::string_view msg);
@@ -686,7 +683,6 @@ class ImageSource : public VideoSource {
* Create a string property.
*
* @param name Property name
* @param defaultValue Default value
* @param value Current value
* @return Property
*/

View File

@@ -56,29 +56,108 @@ doxygen {
}
}
exclude 'Eigen/**'
exclude 'unsupported/**'
exclude 'units/**'
exclude 'uv.h'
exclude 'uv/**'
if (project.hasProperty('docWarningsAsErrors')) {
// C++20 shims
exclude 'wpi/ghc/filesystem.hpp'
exclude 'wpi/span.h'
// Drake
exclude 'drake/common/**'
// Eigen
exclude 'Eigen/**'
exclude 'unsupported/**'
// LLVM
exclude 'wpi/AlignOf.h'
exclude 'wpi/Chrono.h'
exclude 'wpi/Compiler.h'
exclude 'wpi/ConvertUTF.h'
exclude 'wpi/DenseMap.h'
exclude 'wpi/DenseMapInfo.h'
exclude 'wpi/Endian.h'
exclude 'wpi/EpochTracker.h'
exclude 'wpi/Errc.h'
exclude 'wpi/Errno.h'
exclude 'wpi/ErrorHandling.h'
exclude 'wpi/fs.h'
exclude 'wpi/FunctionExtras.h'
exclude 'wpi/function_ref.h'
exclude 'wpi/Hashing.h'
exclude 'wpi/iterator.h'
exclude 'wpi/iterator_range.h'
exclude 'wpi/ManagedStatic.h'
exclude 'wpi/MapVector.h'
exclude 'wpi/MathExtras.h'
exclude 'wpi/MemAlloc.h'
exclude 'wpi/PointerIntPair.h'
exclude 'wpi/PointerLikeTypeTraits.h'
exclude 'wpi/PointerUnion.h'
exclude 'wpi/raw_os_ostream.h'
exclude 'wpi/raw_ostream.h'
exclude 'wpi/SmallPtrSet.h'
exclude 'wpi/SmallSet.h'
exclude 'wpi/SmallString.h'
exclude 'wpi/SmallVector.h'
exclude 'wpi/StringExtras.h'
exclude 'wpi/StringMap.h'
exclude 'wpi/SwapByteOrder.h'
exclude 'wpi/type_traits.h'
exclude 'wpi/VersionTuple.h'
exclude 'wpi/WindowsError.h'
// fmtlib
exclude 'fmt/**'
// libuv
exclude 'uv.h'
exclude 'uv/**'
exclude 'wpi/uv/**'
// json
exclude 'wpi/json.h'
// mpack
exclude 'wpi/mpack.h'
// units
exclude 'units/**'
}
case_sense_names false
extension_mapping 'inc=C++'
extract_all true
extract_static true
full_path_names true
generate_html true
generate_latex false
generate_treeview true
html_extra_stylesheet 'theme.css'
html_timestamp true
javadoc_autobrief true
project_name 'WPILibC++'
project_logo '../wpiutil/src/main/native/resources/wpilib-128.png'
project_number wpilibVersioning.version.get()
javadoc_autobrief true
recursive true
quiet true
warnings false
warn_if_undocumented false
generate_latex false
use_mathjax true
html_timestamp true
generate_treeview true
extract_static true
full_path_names true
recursive true
strip_code_comments false
strip_from_inc_path cppIncludeRoots as String[]
strip_from_path cppIncludeRoots as String[]
use_mathjax true
warnings false
warn_if_incomplete_doc true
warn_if_undocumented false
warn_no_paramdoc true
//enable doxygen preprocessor expansion of WPI_DEPRECATED to fix SpeedController docs
enable_preprocessing true
macro_expansion true
expand_only_predef true
predefined "WPI_DEPRECATED(x)=[[deprecated(x)]]"
if (project.hasProperty('docWarningsAsErrors')) {
warn_as_error 'FAIL_ON_WARNINGS'
}
}
tasks.register("zipCppDocs", Zip) {
@@ -133,7 +212,7 @@ task generateJavaDocs(type: Javadoc) {
title = "WPILib API ${wpilibVersioning.version.get()}"
ext.entryPoint = "$destinationDir/index.html"
if (JavaVersion.current().isJava8Compatible() && project.hasProperty('buildServer')) {
if (JavaVersion.current().isJava8Compatible() && project.hasProperty('docWarningsAsErrors')) {
// Treat javadoc warnings as errors.
//
// The second argument '-quiet' is a hack. The one paramater

View File

@@ -0,0 +1,37 @@
project(fieldImages)
include(CompileWarnings)
include(GenResources)
if (WITH_JAVA)
find_package(Java REQUIRED)
include(UseJava)
file(GLOB_RECURSE JAVA_SOURCES src/main/java/*.java)
file(GLOB_RECURSE JAVA_RESOURCES src/main/native/resources/*.json src/main/native/resources/*.png src/main/native/resources/*.jpg)
add_jar(field_images_jar SOURCES ${JAVA_SOURCES} RESOURCES NAMESPACE "edu/wpi/first/fields" ${JAVA_RESOURCES} OUTPUT_NAME fieldImages)
get_property(FIELD_IMAGES_JAR_FILE TARGET field_images_jar PROPERTY JAR_FILE)
install(FILES ${FIELD_IMAGES_JAR_FILE} DESTINATION "${java_lib_dest}")
set_property(TARGET field_images_jar PROPERTY FOLDER "java")
endif()
GENERATE_RESOURCES(src/main/native/resources/edu/wpi/first/fields generated/main/cpp FIELDS fields field_images_resources_src)
add_library(fieldImages ${field_images_resources_src})
set_target_properties(fieldImages PROPERTIES DEBUG_POSTFIX "d")
set_property(TARGET fieldImages PROPERTY FOLDER "libraries")
target_compile_features(fieldImages PUBLIC cxx_std_17)
if (MSVC)
target_compile_options(fieldImages PUBLIC /bigobj)
endif()
wpilib_target_warnings(fieldImages)
target_include_directories(fieldImages PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/main/native/include>
$<INSTALL_INTERFACE:${include_dest}/fields>)

66
fieldImages/build.gradle Normal file
View File

@@ -0,0 +1,66 @@
import org.gradle.internal.os.OperatingSystem
if (!project.hasProperty('onlylinuxathena') && !project.hasProperty('onlylinuxraspbian') && !project.hasProperty('onlylinuxaarch64bionic')) {
apply plugin: 'cpp'
apply plugin: 'c'
apply plugin: 'java'
apply plugin: 'google-test-test-suite'
apply plugin: 'visual-studio'
apply plugin: 'edu.wpi.first.NativeUtils'
if (OperatingSystem.current().isWindows()) {
apply plugin: 'windows-resources'
}
ext {
nativeName = 'fieldImages'
}
apply from: "${rootDir}/shared/resources.gradle"
apply from: "${rootDir}/shared/config.gradle"
def generateTask = createGenerateResourcesTask('main', 'FIELDS', 'fields', project)
project(':').libraryBuild.dependsOn build
tasks.withType(CppCompile) {
dependsOn generateTask
}
sourceSets {
main {
resources {
srcDirs 'src/main/native/resources'
}
}
}
model {
components {
"${nativeName}"(NativeLibrarySpec) {
baseName = 'fieldImages'
sources {
cpp {
source {
srcDirs "$buildDir/generated/main/cpp"
include '**/*.cpp'
}
exportedHeaders {
srcDirs 'src/main/native/include'
}
}
if (OperatingSystem.current().isWindows()) {
rc {
source {
srcDirs 'src/main/native/win'
include '*.rc'
}
}
}
}
}
}
}
apply from: 'publish.gradle'
}

View File

@@ -0,0 +1,71 @@
apply plugin: 'maven-publish'
def baseArtifactId = 'fieldImages'
def artifactGroupId = 'edu.wpi.first.fieldImages'
def zipBaseName = '_GROUP_edu_wpi_first_field_images_ID_CLS'
def outputsFolder = file("$project.buildDir/outputs")
task cppSourcesZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
classifier = "sources"
from(licenseFile) {
into '/'
}
from('src/main/native/cpp') {
into '/'
}
from("$buildDir/generated/cpp") {
into '/'
}
}
task cppHeadersZip(type: Zip) {
destinationDirectory = outputsFolder
archiveBaseName = zipBaseName
classifier = "headers"
from(licenseFile) {
into '/'
}
ext.includeDirs = [
project.file('src/main/native/include')
]
ext.includeDirs.each {
from(it) {
into '/'
}
}
}
build.dependsOn cppHeadersZip
build.dependsOn cppSourcesZip
addTaskToCopyAllOutputs(cppHeadersZip)
addTaskToCopyAllOutputs(cppSourcesZip)
model {
publishing {
def wpilibCTaskList = createComponentZipTasks($.components, ['fieldImages'], zipBaseName, Zip, project, includeStandardZipFormat)
publications {
cpp(MavenPublication) {
wpilibCTaskList.each {
artifact it
}
artifact cppHeadersZip
artifact cppSourcesZip
artifactId = baseArtifactId
groupId artifactGroupId
version wpilibVersioning.version.get()
}
}
}
}

View File

@@ -0,0 +1,23 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package edu.wpi.fields;
public class FieldImages {
public static final String k2018PowerUpFieldConfig = "/edu/wpi/first/fields/2018-powerup.json";
public static final String k2019DeepSpaceFieldConfig =
"/edu/wpi/first/fields/2019-deepspace.json";
public static final String k2020InfiniteRechargeFieldConfig =
"/edu/wpi/first/fields/2020-infiniterecharge.json";
public static final String k2021InfiniteRechargeFieldConfig =
"/edu/wpi/first/fields/2021-infiniterecharge.json";
public static final String k2021BarrelFieldConfig =
"/edu/wpi/first/fields/2021-barrelracingpath.json";
public static final String k2021BounceFieldConfig = "/edu/wpi/first/fields/2021-bouncepath.json";
public static final String k2021GalacticSearchAFieldConfig =
"/edu/wpi/first/fields/2021-galacticsearcha.json";
public static final String k2021GalacticSearchBFieldConfig =
"/edu/wpi/first/fields/2021-galacticsearchb.json";
public static final String k2021SlalomFieldConfig = "/edu/wpi/first/fields/2021-slalompath.json";
}

View File

@@ -4,12 +4,9 @@
#pragma once
#include <frc/commands/CommandGroup.h>
#include <string_view>
/**
* Get the robot set to collect balls.
*/
class Collect : public frc::CommandGroup {
public:
Collect();
};
namespace fields {
std::string_view GetResource_2018_powerup_json();
std::string_view GetResource_2018_field_jpg();
} // namespace fields

View File

@@ -4,12 +4,9 @@
#pragma once
#include <frc/commands/CommandGroup.h>
#include <string_view>
/**
* Shoot the ball at the current angle.
*/
class Shoot : public frc::CommandGroup {
public:
Shoot();
};
namespace fields {
std::string_view GetResource_2019_deepspace_json();
std::string_view GetResource_2019_field_jpg();
} // namespace fields

View File

@@ -4,14 +4,9 @@
#pragma once
#include <frc/commands/Command.h>
#include <string_view>
/**
* Opens the claw
*/
class OpenClaw : public frc::Command {
public:
OpenClaw();
void Initialize() override;
bool IsFinished() override;
};
namespace fields {
std::string_view GetResource_2020_infiniterecharge_json();
std::string_view GetResource_2020_field_png();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_barrelracingpath_json();
std::string_view GetResource_2021_barrel_png();
} // namespace fields

View File

@@ -4,7 +4,9 @@
#pragma once
class OI {
public:
OI();
};
#include <string_view>
namespace fields {
std::string_view GetResource_2021_bouncepath_json();
std::string_view GetResource_2021_bounce_png();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_galacticsearcha_json();
std::string_view GetResource_2021_galacticsearcha_png();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_galacticsearchb_json();
std::string_view GetResource_2021_galacticsearchb_png();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_field_png();
std::string_view GetResource_2021_infiniterecharge_json();
} // namespace fields

View File

@@ -0,0 +1,12 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#pragma once
#include <string_view>
namespace fields {
std::string_view GetResource_2021_slalompath_json();
std::string_view GetResource_2021_slalom_png();
} // namespace fields

Binary file not shown.

After

Width:  |  Height:  |  Size: 191 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "FIRST Power Up",
"field-image": "2018-field.jpg",
"field-corners": {
"top-left": [125, 20],
"bottom-right": [827, 370]
},
"field-size": [54, 27],
"field-unit": "feet"
}

View File

@@ -0,0 +1,10 @@
{
"game" : "Destination: Deep Space",
"field-image" : "2019-field.jpg",
"field-corners": {
"top-left" : [217, 40],
"bottom-right" : [1372, 615]
},
"field-size" : [54, 27],
"field-unit" : "foot"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 257 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 747 KiB

View File

@@ -0,0 +1,10 @@
{
"game" : "Infinite Recharge",
"field-image" : "2020-field.png",
"field-corners": {
"top-left" : [96, 25],
"bottom-right" : [1040, 514]
},
"field-size" : [52.4375, 26.9375],
"field-unit" : "foot"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 34 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "Barrel Racing Path",
"field-image": "2021-barrel.png",
"field-corners": {
"top-left": [20, 20],
"bottom-right": [780, 400]
},
"field-size": [30, 15],
"field-unit": "feet"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "Bounce Path",
"field-image": "2021-bounce.png",
"field-corners": {
"top-left": [20, 20],
"bottom-right": [780, 400]
},
"field-size": [30, 15],
"field-unit": "feet"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

View File

@@ -0,0 +1,10 @@
{
"game": "Galactic Search A",
"field-image": "2021-galacticsearcha.png",
"field-corners": {
"top-left": [20, 20],
"bottom-right": [780, 400]
},
"field-size": [30, 15],
"field-unit": "feet"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "Galactic Search B",
"field-image": "2021-galacticsearchb.png",
"field-corners": {
"top-left": [20, 20],
"bottom-right": [780, 400]
},
"field-size": [30, 15],
"field-unit": "feet"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "Infinite Recharge 2021",
"field-image": "2021-field.png",
"field-corners": {
"top-left": [127, 34],
"bottom-right": [1323, 649]
},
"field-size": [52.4375, 26.9375],
"field-unit": "foot"
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

View File

@@ -0,0 +1,10 @@
{
"game": "Slalom Path",
"field-image": "2021-slalom.png",
"field-corners": {
"top-left": [20, 20],
"bottom-right": [780, 400]
},
"field-size": [30, 15],
"field-unit": "feet"
}

View File

@@ -261,17 +261,17 @@ static DisplayUnits gDisplayUnits = kDisplayMeters;
static double ConvertDisplayLength(units::meter_t v) {
switch (gDisplayUnits) {
case kDisplayFeet:
return v.convert<units::feet>().to<double>();
return v.convert<units::feet>().value();
case kDisplayInches:
return v.convert<units::inches>().to<double>();
return v.convert<units::inches>().value();
case kDisplayMeters:
default:
return v.to<double>();
return v.value();
}
}
static double ConvertDisplayAngle(units::degree_t v) {
return v.to<double>();
return v.value();
}
static bool InputLength(const char* label, units::meter_t* v, double step = 0.0,

View File

@@ -32,10 +32,12 @@ class RoboRioModel : public Model {
virtual DataSource* GetUserButton() = 0;
virtual DataSource* GetVInVoltageData() = 0;
virtual DataSource* GetVInCurrentData() = 0;
virtual DataSource* GetBrownoutVoltage() = 0;
virtual void SetUserButton(bool val) = 0;
virtual void SetVInVoltage(double val) = 0;
virtual void SetVInCurrent(double val) = 0;
virtual void SetBrownoutVoltage(double val) = 0;
};
void DisplayRoboRio(RoboRioModel* model);

View File

@@ -94,9 +94,9 @@ void NTField2DModel::ObjectModel::UpdateNT() {
wpi::SmallVector<double, 9> arr;
for (auto&& pose : m_poses) {
auto& translation = pose.Translation();
arr.push_back(translation.X().to<double>());
arr.push_back(translation.Y().to<double>());
arr.push_back(pose.Rotation().Degrees().to<double>());
arr.push_back(translation.X().value());
arr.push_back(translation.Y().value());
arr.push_back(pose.Rotation().Degrees().value());
}
nt::SetEntryTypeValue(m_entry, nt::Value::MakeDoubleArray(arr));
} else {
@@ -107,13 +107,13 @@ void NTField2DModel::ObjectModel::UpdateNT() {
for (auto&& pose : m_poses) {
auto& translation = pose.Translation();
wpi::support::endian::write64be(
p, wpi::DoubleToBits(translation.X().to<double>()));
p, wpi::DoubleToBits(translation.X().value()));
p += 8;
wpi::support::endian::write64be(
p, wpi::DoubleToBits(translation.Y().to<double>()));
p, wpi::DoubleToBits(translation.Y().value()));
p += 8;
wpi::support::endian::write64be(
p, wpi::DoubleToBits(pose.Rotation().Degrees().to<double>()));
p, wpi::DoubleToBits(pose.Rotation().Degrees().value()));
p += 8;
}
nt::SetEntryTypeValue(m_entry,

View File

@@ -17,7 +17,7 @@ NTSpeedControllerModel::NTSpeedControllerModel(NT_Inst instance,
: m_nt(instance),
m_value(m_nt.GetEntry(fmt::format("{}/Value", path))),
m_name(m_nt.GetEntry(fmt::format("{}/.name", path))),
m_controllable(m_nt.GetEntry(fmt::format("{}/.controllable"))),
m_controllable(m_nt.GetEntry(fmt::format("{}/.controllable", path))),
m_valueData(fmt::format("NT_SpdCtrl:{}", path)),
m_nameValue(wpi::rsplit(path, '/').second) {
m_nt.AddListener(m_value);

View File

@@ -45,4 +45,8 @@ public class PortsJNI extends JNIWrapper {
public static native int getNumREVPDHModules();
public static native int getNumREVPDHChannels();
public static native int getNumREVPHModules();
public static native int getNumREVPHChannels();
}

View File

@@ -46,4 +46,14 @@ public class PowerDistributionJNI extends JNIWrapper {
public static native boolean getSwitchableChannel(int handle);
public static native void setSwitchableChannel(int handle, boolean enabled);
public static native double getVoltageNoError(int handle);
public static native double getChannelCurrentNoError(int handle, int channel);
public static native double getTotalCurrentNoError(int handle);
public static native boolean getSwitchableChannelNoError(int handle);
public static native void setSwitchableChannelNoError(int handle, boolean enabled);
}

View File

@@ -32,4 +32,8 @@ public class PowerJNI extends JNIWrapper {
public static native boolean getUserActive3V3();
public static native int getUserCurrentFaults3V3();
public static native void setBrownoutVoltage(double voltage);
public static native double getBrownoutVoltage();
}

View File

@@ -0,0 +1,32 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.hal;
@SuppressWarnings("AbbreviationAsWordInName")
public class REVPHJNI extends JNIWrapper {
public static native int initialize(int module);
public static native void free(int handle);
public static native boolean checkSolenoidChannel(int channel);
public static native boolean getCompressor(int handle);
public static native void setClosedLoopControl(int handle, boolean enabled);
public static native boolean getClosedLoopControl(int handle);
public static native boolean getPressureSwitch(int handle);
public static native double getAnalogPressure(int handle, int channel);
public static native double getCompressorCurrent(int handle);
public static native int getSolenoids(int handle);
public static native void setSolenoids(int handle, int mask, int values);
public static native void fireOneShot(int handle, int index, int durMs);
}

View File

@@ -0,0 +1,72 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.hal.simulation;
import edu.wpi.first.hal.JNIWrapper;
@SuppressWarnings("AbbreviationAsWordInName")
public class REVPHDataJNI extends JNIWrapper {
public static native int registerInitializedCallback(
int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelInitializedCallback(int index, int uid);
public static native boolean getInitialized(int index);
public static native void setInitialized(int index, boolean initialized);
public static native int registerSolenoidOutputCallback(
int index, int channel, NotifyCallback callback, boolean initialNotify);
public static native void cancelSolenoidOutputCallback(int index, int channel, int uid);
public static native boolean getSolenoidOutput(int index, int channel);
public static native void setSolenoidOutput(int index, int channel, boolean solenoidOutput);
public static native int registerCompressorOnCallback(
int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelCompressorOnCallback(int index, int uid);
public static native boolean getCompressorOn(int index);
public static native void setCompressorOn(int index, boolean compressorOn);
public static native int registerClosedLoopEnabledCallback(
int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelClosedLoopEnabledCallback(int index, int uid);
public static native boolean getClosedLoopEnabled(int index);
public static native void setClosedLoopEnabled(int index, boolean closeLoopEnabled);
public static native int registerPressureSwitchCallback(
int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelPressureSwitchCallback(int index, int uid);
public static native boolean getPressureSwitch(int index);
public static native void setPressureSwitch(int index, boolean pressureSwitch);
public static native int registerCompressorCurrentCallback(
int index, NotifyCallback callback, boolean initialNotify);
public static native void cancelCompressorCurrentCallback(int index, int uid);
public static native double getCompressorCurrent(int index);
public static native void setCompressorCurrent(int index, double compressorCurrent);
public static native void registerAllNonSolenoidCallbacks(
int index, NotifyCallback callback, boolean initialNotify);
public static native void registerAllSolenoidCallbacks(
int index, int channel, NotifyCallback callback, boolean initialNotify);
public static native void resetData(int index);
}

View File

@@ -146,5 +146,14 @@ public class RoboRioDataJNI extends JNIWrapper {
public static native void setUserFaults3V3(int userFaults3V3);
public static native int registerBrownoutVoltageCallback(
NotifyCallback callback, boolean initialNotify);
public static native void cancelBrownoutVoltageCallback(int uid);
public static native double getBrownoutVoltage();
public static native void setBrownoutVoltage(double brownoutVoltage);
public static native void resetData();
}

View File

@@ -44,7 +44,7 @@ int32_t HAL_GetPDPModuleNumber(HAL_PDPHandle handle, int32_t* status);
* Checks if a PDP channel is valid.
*
* @param channel the channel to check
* @return true if the channel is valid, otherwise false
* @return true if the channel is valid, otherwise false
*/
HAL_Bool HAL_CheckPDPChannel(int32_t channel);
@@ -52,7 +52,7 @@ HAL_Bool HAL_CheckPDPChannel(int32_t channel);
* Checks if a PDP module is valid.
*
* @param channel the module to check
* @return true if the module is valid, otherwise false
* @return true if the module is valid, otherwise false
*/
HAL_Bool HAL_CheckPDPModule(int32_t module);
@@ -60,7 +60,7 @@ HAL_Bool HAL_CheckPDPModule(int32_t module);
* Gets the temperature of the PDP.
*
* @param handle the module handle
* @return the module temperature (celsius)
* @return the module temperature (celsius)
*/
double HAL_GetPDPTemperature(HAL_PDPHandle handle, int32_t* status);
@@ -68,7 +68,7 @@ double HAL_GetPDPTemperature(HAL_PDPHandle handle, int32_t* status);
* Gets the PDP input voltage.
*
* @param handle the module handle
* @return the input voltage (volts)
* @return the input voltage (volts)
*/
double HAL_GetPDPVoltage(HAL_PDPHandle handle, int32_t* status);
@@ -77,7 +77,7 @@ double HAL_GetPDPVoltage(HAL_PDPHandle handle, int32_t* status);
*
* @param module the module
* @param channel the channel
* @return the channel current (amps)
* @return the channel current (amps)
*/
double HAL_GetPDPChannelCurrent(HAL_PDPHandle handle, int32_t channel,
int32_t* status);
@@ -97,7 +97,7 @@ void HAL_GetPDPAllChannelCurrents(HAL_PDPHandle handle, double* currents,
* Gets the total current of the PDP.
*
* @param handle the module handle
* @return the total current (amps)
* @return the total current (amps)
*/
double HAL_GetPDPTotalCurrent(HAL_PDPHandle handle, int32_t* status);
@@ -105,7 +105,7 @@ double HAL_GetPDPTotalCurrent(HAL_PDPHandle handle, int32_t* status);
* Gets the total power of the PDP.
*
* @param handle the module handle
* @return the total power (watts)
* @return the total power (watts)
*/
double HAL_GetPDPTotalPower(HAL_PDPHandle handle, int32_t* status);
@@ -113,7 +113,7 @@ double HAL_GetPDPTotalPower(HAL_PDPHandle handle, int32_t* status);
* Gets the total energy of the PDP.
*
* @param handle the module handle
* @return the total energy (joules)
* @return the total energy (joules)
*/
double HAL_GetPDPTotalEnergy(HAL_PDPHandle handle, int32_t* status);

View File

@@ -69,15 +69,15 @@ static int32_t HAL_GetJoystickButtonsInternal(int32_t joystickNum,
joystickNum, &buttons->buttons, &buttons->count);
}
/**
* Retrieve the Joystick Descriptor for particular slot
* @param desc [out] descriptor (data transfer object) to fill in. desc is
* filled in regardless of success. In other words, if descriptor is not
* available, desc is filled in with default values matching the init-values in
* Java and C++ Driverstation for when caller requests a too-large joystick
* index.
* Retrieve the Joystick Descriptor for particular slot.
*
* @param[out] desc descriptor (data transfer object) to fill in. desc is filled
* in regardless of success. In other words, if descriptor is
* not available, desc is filled in with default values
* matching the init-values in Java and C++ Driverstation for
* when caller requests a too-large joystick index.
* @return error code reported from Network Comm back-end. Zero is good,
* nonzero is bad.
* nonzero is bad.
*/
static int32_t HAL_GetJoystickDescriptorInternal(int32_t joystickNum,
HAL_JoystickDescriptor* desc) {

View File

@@ -34,6 +34,7 @@ using namespace hal;
static std::unique_ptr<tGlobal> global;
static std::unique_ptr<tSysWatchdog> watchdog;
static uint64_t dsStartTime;
using namespace hal;
@@ -41,6 +42,7 @@ namespace hal {
namespace init {
void InitializeHAL() {
InitializeCTREPCM();
InitializeREVPH();
InitializeAddressableLED();
InitializeAccelerometer();
InitializeAnalogAccumulator();
@@ -85,6 +87,11 @@ void ReleaseFPGAInterrupt(int32_t interruptNumber) {
&status);
global->strobeInterruptForceOnce(&status);
}
uint64_t GetDSInitializeTime() {
return dsStartTime;
}
} // namespace hal
extern "C" {
@@ -226,6 +233,8 @@ const char* HAL_GetErrorMessage(int32_t code) {
return HAL_INVALID_DMA_ADDITION_MESSAGE;
case HAL_USE_LAST_ERROR:
return HAL_USE_LAST_ERROR_MESSAGE;
case HAL_CONSOLE_OUT_ENABLED_ERROR:
return HAL_CONSOLE_OUT_ENABLED_ERROR_MESSAGE;
default:
return "Unknown error status";
}
@@ -277,10 +286,10 @@ uint64_t HAL_GetFPGATime(int32_t* status) {
return (upper2 << 32) + lower;
}
uint64_t HAL_ExpandFPGATime(uint32_t unexpanded_lower, int32_t* status) {
uint64_t HAL_ExpandFPGATime(uint32_t unexpandedLower, int32_t* status) {
// Capture the current FPGA time. This will give us the upper half of the
// clock.
uint64_t fpga_time = HAL_GetFPGATime(status);
uint64_t fpgaTime = HAL_GetFPGATime(status);
if (*status != 0) {
return 0;
}
@@ -290,15 +299,15 @@ uint64_t HAL_ExpandFPGATime(uint32_t unexpanded_lower, int32_t* status) {
// be.
// Break it into lower and upper portions.
uint32_t lower = fpga_time & 0xffffffffull;
uint64_t upper = (fpga_time >> 32) & 0xffffffff;
uint32_t lower = fpgaTime & 0xffffffffull;
uint64_t upper = (fpgaTime >> 32) & 0xffffffff;
// The time was sampled *before* the current time, so roll it back.
if (lower < unexpanded_lower) {
if (lower < unexpandedLower) {
--upper;
}
return (upper << 32) + static_cast<uint64_t>(unexpanded_lower);
return (upper << 32) + static_cast<uint64_t>(unexpandedLower);
}
HAL_Bool HAL_GetFPGAButton(int32_t* status) {
@@ -417,6 +426,11 @@ HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode) {
HAL_InitializeDriverStation();
dsStartTime = HAL_GetFPGATime(&status);
if (status != 0) {
return false;
}
// Set WPI_Now to use FPGA timestamp
wpi::SetNowImpl([]() -> uint64_t {
int32_t status = 0;

View File

@@ -17,6 +17,7 @@ inline void CheckInit() {
}
extern void InitializeCTREPCM();
extern void InitializeREVPH();
extern void InitializeAccelerometer();
extern void InitializeAddressableLED();
extern void InitializeAnalogAccumulator();

View File

@@ -17,4 +17,5 @@ void SetLastErrorIndexOutOfRange(int32_t* status, std::string_view message,
void SetLastErrorPreviouslyAllocated(int32_t* status, std::string_view message,
int32_t channel,
std::string_view previousAllocation);
uint64_t GetDSInitializeTime();
} // namespace hal

View File

@@ -98,11 +98,11 @@ HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
if (*status != 0) {
if (port) {
hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", channel,
hal::SetLastErrorPreviouslyAllocated(status, "PWM or DIO", origChannel,
port->previousAllocation);
} else {
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for PWM", 0,
kNumPWMChannels, channel);
kNumPWMChannels, origChannel);
}
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}

View File

@@ -74,6 +74,12 @@ int32_t HAL_GetNumREVPDHModules(void) {
int32_t HAL_GetNumREVPDHChannels(void) {
return kNumREVPDHChannels;
}
int32_t HAL_GetNumREVPHModules(void) {
return kNumREVPHModules;
}
int32_t HAL_GetNumREVPHChannels(void) {
return kNumREVPHChannels;
}
int32_t HAL_GetNumDutyCycles(void) {
return kNumDutyCycles;
}

View File

@@ -36,5 +36,7 @@ constexpr int32_t kNumREVPDHModules = 63;
constexpr int32_t kNumREVPDHChannels = 24;
constexpr int32_t kNumDutyCycles = tDutyCycle::kNumSystems;
constexpr int32_t kNumAddressableLEDs = tLED::kNumSystems;
constexpr int32_t kNumREVPHModules = 63;
constexpr int32_t kNumREVPHChannels = 16;
} // namespace hal

View File

@@ -103,4 +103,22 @@ int32_t HAL_GetUserCurrentFaults3V3(int32_t* status) {
power->readFaultCounts_OverCurrentFaultCount3V3(status));
}
void HAL_SetBrownoutVoltage(double voltage, int32_t* status) {
initializePower(status);
if (voltage < 0) {
voltage = 0;
}
if (voltage > 50) {
voltage = 50;
}
power->writeBrownoutVoltage250mV(static_cast<unsigned char>(voltage * 4),
status);
}
double HAL_GetBrownoutVoltage(int32_t* status) {
initializePower(status);
auto brownout = power->readBrownoutVoltage250mV(status);
return brownout / 4.0;
}
} // extern "C"

View File

@@ -4,11 +4,14 @@
#include "hal/PowerDistribution.h"
#include <thread>
#include "CTREPDP.h"
#include "HALInternal.h"
#include "PortsInternal.h"
#include "REVPDH.h"
#include "hal/Errors.h"
#include "hal/HALBase.h"
#include "hal/handles/HandlesInternal.h"
using namespace hal;
@@ -19,7 +22,41 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
int32_t moduleNumber, HAL_PowerDistributionType type,
const char* allocationLocation, int32_t* status) {
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kAutomatic) {
type = HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE;
if (moduleNumber != HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(
status, "Automatic PowerDistributionType must have default module");
return HAL_kInvalidHandle;
}
uint64_t waitTime = hal::GetDSInitializeTime() + 400000;
// Ensure we have been alive for long enough to receive a few Power packets.
do {
uint64_t currentTime = HAL_GetFPGATime(status);
if (*status != 0) {
return HAL_kInvalidHandle;
}
if (currentTime >= waitTime) {
break;
}
std::this_thread::sleep_for(
std::chrono::microseconds(waitTime - currentTime));
} while (true);
// Try PDP first
auto pdpHandle = HAL_InitializePDP(0, allocationLocation, status);
if (pdpHandle != HAL_kInvalidHandle) {
*status = 0;
HAL_GetPDPVoltage(pdpHandle, status);
if (*status == 0 || *status == HAL_CAN_TIMEOUT) {
return static_cast<HAL_PowerDistributionHandle>(pdpHandle);
}
HAL_CleanPDP(pdpHandle);
}
*status = 0;
auto pdhHandle = HAL_REV_InitializePDH(1, allocationLocation, status);
return static_cast<HAL_PowerDistributionHandle>(pdhHandle);
}
if (type == HAL_PowerDistributionType::HAL_PowerDistributionType_kCTRE) {
@@ -27,7 +64,7 @@ HAL_PowerDistributionHandle HAL_InitializePowerDistribution(
moduleNumber = 0;
}
return static_cast<HAL_PowerDistributionHandle>(
HAL_InitializePDP(moduleNumber, allocationLocation, status)); // TODO
HAL_InitializePDP(moduleNumber, allocationLocation, status));
} else {
if (moduleNumber == HAL_DEFAULT_POWER_DISTRIBUTION_MODULE) {
moduleNumber = 1;

View File

@@ -30,7 +30,7 @@ extern "C" {
* Initializes a REV Power Distribution Hub (PDH) device.
*
* @param module the device CAN ID (1 .. 63)
* @return the created PDH handle
* @return the created PDH handle
*/
HAL_REVPDHHandle HAL_REV_InitializePDH(int32_t module,
const char* allocationLocation,
@@ -54,7 +54,7 @@ int32_t HAL_REV_GetPDHModuleNumber(HAL_REVPDHHandle handle, int32_t* status);
* Does not check if a PDH device with this module has been initialized.
*
* @param module module number (1 .. 63)
* @return 1 if the module number is valid; 0 otherwise
* @return 1 if the module number is valid; 0 otherwise
*/
HAL_Bool HAL_REV_CheckPDHModuleNumber(int32_t module);
@@ -62,7 +62,7 @@ HAL_Bool HAL_REV_CheckPDHModuleNumber(int32_t module);
* Checks if a PDH channel number is valid.
*
* @param module channel number (0 .. HAL_REV_PDH_NUM_CHANNELS)
* @return 1 if the channel number is valid; 0 otherwise
* @return 1 if the channel number is valid; 0 otherwise
*/
HAL_Bool HAL_REV_CheckPDHChannelNumber(int32_t channel);
@@ -73,7 +73,7 @@ HAL_Bool HAL_REV_CheckPDHChannelNumber(int32_t channel);
* @param channel the channel to retrieve the current of (0 ..
* HAL_REV_PDH_NUM_CHANNELS)
*
* @return the current of the PDH channel in Amps
* @return the current of the PDH channel in Amps
*/
double HAL_REV_GetPDHChannelCurrent(HAL_REVPDHHandle handle, int32_t channel,
int32_t* status);
@@ -91,7 +91,7 @@ void HAL_REV_GetPDHAllChannelCurrents(HAL_REVPDHHandle handle, double* currents,
*
* @param handle PDH handle
*
* @return the total current of the PDH in Amps
* @return the total current of the PDH in Amps
*/
uint16_t HAL_REV_GetPDHTotalCurrent(HAL_REVPDHHandle handle, int32_t* status);
@@ -112,7 +112,7 @@ void HAL_REV_SetPDHSwitchableChannel(HAL_REVPDHHandle handle, HAL_Bool enabled,
* fresh as the last packet received.
*
* @param handle PDH handle
* @return 1 if the switchable channel is enabled; 0 otherwise
* @return 1 if the switchable channel is enabled; 0 otherwise
*/
HAL_Bool HAL_REV_GetPDHSwitchableChannelState(HAL_REVPDHHandle handle,
int32_t* status);
@@ -125,7 +125,7 @@ HAL_Bool HAL_REV_GetPDHSwitchableChannelState(HAL_REVPDHHandle handle,
* @param handle PDH handle
* @param channel the channel to retrieve the brownout status of
*
* @return 1 if the channel is experiencing a brownout; 0 otherwise
* @return 1 if the channel is experiencing a brownout; 0 otherwise
*/
HAL_Bool HAL_REV_CheckPDHChannelBrownout(HAL_REVPDHHandle handle,
int32_t channel, int32_t* status);
@@ -135,7 +135,7 @@ HAL_Bool HAL_REV_CheckPDHChannelBrownout(HAL_REVPDHHandle handle,
*
* @param handle PDH handle
*
* @return the voltage at the input of the PDH in Volts
* @return the voltage at the input of the PDH in Volts
*/
double HAL_REV_GetPDHSupplyVoltage(HAL_REVPDHHandle handle, int32_t* status);
@@ -144,7 +144,7 @@ double HAL_REV_GetPDHSupplyVoltage(HAL_REVPDHHandle handle, int32_t* status);
*
* @param handle PDH handle
*
* @return 1 if the PDH is enabled; 0 otherwise
* @return 1 if the PDH is enabled; 0 otherwise
*/
HAL_Bool HAL_REV_IsPDHEnabled(HAL_REVPDHHandle handle, int32_t* status);
@@ -156,7 +156,7 @@ HAL_Bool HAL_REV_IsPDHEnabled(HAL_REVPDHHandle handle, int32_t* status);
*
* @param handle PDH handle
*
* @return 1 if the PDH is experiencing a brownout; 0 otherwise
* @return 1 if the PDH is experiencing a brownout; 0 otherwise
*/
HAL_Bool HAL_REV_CheckPDHBrownout(HAL_REVPDHHandle handle, int32_t* status);
@@ -168,7 +168,7 @@ HAL_Bool HAL_REV_CheckPDHBrownout(HAL_REVPDHHandle handle, int32_t* status);
*
* @param handle PDH handle
*
* @return 1 if the device has exceeded the warning threshold; 0
* @return 1 if the device has exceeded the warning threshold; 0
* otherwise
*/
HAL_Bool HAL_REV_CheckPDHCANWarning(HAL_REVPDHHandle handle, int32_t* status);
@@ -180,7 +180,7 @@ HAL_Bool HAL_REV_CheckPDHCANWarning(HAL_REVPDHHandle handle, int32_t* status);
*
* @param handle PDH handle
*
* @return 1 if the device is in a hardware fault state; 0
* @return 1 if the device is in a hardware fault state; 0
* otherwise
*/
HAL_Bool HAL_REV_CheckPDHHardwareFault(HAL_REVPDHHandle handle,
@@ -194,7 +194,7 @@ HAL_Bool HAL_REV_CheckPDHHardwareFault(HAL_REVPDHHandle handle,
*
* @param handle PDH handle
*
* @return 1 if the device has had a brownout; 0 otherwise
* @return 1 if the device has had a brownout; 0 otherwise
*/
HAL_Bool HAL_REV_CheckPDHStickyBrownout(HAL_REVPDHHandle handle,
int32_t* status);
@@ -207,7 +207,7 @@ HAL_Bool HAL_REV_CheckPDHStickyBrownout(HAL_REVPDHHandle handle,
*
* @param handle PDH handle
*
* @return 1 if the device has exceeded the CAN warning threshold;
* @return 1 if the device has exceeded the CAN warning threshold;
* 0 otherwise
*/
HAL_Bool HAL_REV_CheckPDHStickyCANWarning(HAL_REVPDHHandle handle,
@@ -221,7 +221,7 @@ HAL_Bool HAL_REV_CheckPDHStickyCANWarning(HAL_REVPDHHandle handle,
*
* @param handle PDH handle
*
* @return 1 if the device has experienced a 'Bus Off' event; 0
* @return 1 if the device has experienced a 'Bus Off' event; 0
* otherwise
*/
HAL_Bool HAL_REV_CheckPDHStickyCANBusOff(HAL_REVPDHHandle handle,
@@ -234,7 +234,7 @@ HAL_Bool HAL_REV_CheckPDHStickyCANBusOff(HAL_REVPDHHandle handle,
*
* @param handle PDH handle
*
* @return 1 if the device has had a malfunction; 0 otherwise
* @return 1 if the device has had a malfunction; 0 otherwise
*/
HAL_Bool HAL_REV_CheckPDHStickyHardwareFault(HAL_REVPDHHandle handle,
int32_t* status);
@@ -247,7 +247,7 @@ HAL_Bool HAL_REV_CheckPDHStickyHardwareFault(HAL_REVPDHHandle handle,
*
* @param handle PDH handle
*
* @return 1 if the device has had a malfunction and reset; 0
* @return 1 if the device has had a malfunction and reset; 0
* otherwise
*/
HAL_Bool HAL_REV_CheckPDHStickyFirmwareFault(HAL_REVPDHHandle handle,
@@ -264,7 +264,7 @@ HAL_Bool HAL_REV_CheckPDHStickyFirmwareFault(HAL_REVPDHHandle handle,
* 23)
*
*
* @return 1 if the channel has had a brownout; 0 otherwise
* @return 1 if the channel has had a brownout; 0 otherwise
*/
HAL_Bool HAL_REV_CheckPDHStickyChannelBrownout(HAL_REVPDHHandle handle,
int32_t channel,
@@ -277,7 +277,7 @@ HAL_Bool HAL_REV_CheckPDHStickyChannelBrownout(HAL_REVPDHHandle handle,
*
* @param handle PDH handle
*
* @return 1 if the device has reset; 0 otherwise
* @return 1 if the device has reset; 0 otherwise
*/
HAL_Bool HAL_REV_CheckPDHStickyHasReset(HAL_REVPDHHandle handle,
int32_t* status);
@@ -287,7 +287,7 @@ HAL_Bool HAL_REV_CheckPDHStickyHasReset(HAL_REVPDHHandle handle,
*
* @param handle PDH handle
*
* @return version information
* @return version information
*/
REV_PDH_Version HAL_REV_GetPDHVersion(HAL_REVPDHHandle handle, int32_t* status);

View File

@@ -0,0 +1,480 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "hal/REVPH.h"
#include <fmt/format.h>
#include "HALInitializer.h"
#include "HALInternal.h"
#include "PortsInternal.h"
#include "hal/CANAPI.h"
#include "hal/Errors.h"
#include "hal/handles/IndexedHandleResource.h"
#include "rev/PHFrames.h"
using namespace hal;
static constexpr HAL_CANManufacturer manufacturer =
HAL_CANManufacturer::HAL_CAN_Man_kREV;
static constexpr HAL_CANDeviceType deviceType =
HAL_CANDeviceType::HAL_CAN_Dev_kPneumatics;
static constexpr int32_t kDefaultControlPeriod = 20;
// static constexpr uint8_t kDefaultSensorMask = (1 <<
// HAL_REV_PHSENSOR_DIGITAL);
static constexpr uint8_t kDefaultCompressorDuty = 255;
static constexpr uint8_t kDefaultPressureTarget = 120;
static constexpr uint8_t kDefaultPressureHysteresis = 60;
#define HAL_REV_MAX_PULSE_TIME 65534
#define HAL_REV_MAX_PRESSURE_TARGET 120
#define HAL_REV_MAX_PRESSURE_HYSTERESIS HAL_REV_MAX_PRESSURE_TARGET
static constexpr uint32_t APIFromExtId(uint32_t extId) {
return (extId >> 6) & 0x3FF;
}
static constexpr uint32_t PH_SET_ALL_FRAME_API =
APIFromExtId(PH_SET_ALL_FRAME_ID);
static constexpr uint32_t PH_PULSE_ONCE_FRAME_API =
APIFromExtId(PH_PULSE_ONCE_FRAME_ID);
static constexpr uint32_t PH_STATUS0_FRAME_API =
APIFromExtId(PH_STATUS0_FRAME_ID);
static constexpr uint32_t PH_STATUS1_FRAME_API =
APIFromExtId(PH_STATUS1_FRAME_ID);
static constexpr int32_t kPHFrameStatus0Timeout = 50;
static constexpr int32_t kPHFrameStatus1Timeout = 50;
namespace {
struct REV_PHObj {
int32_t controlPeriod;
PH_set_all_t desiredSolenoidsState;
wpi::mutex solenoidLock;
HAL_CANHandle hcan;
std::string previousAllocation;
};
} // namespace
static IndexedHandleResource<HAL_REVPHHandle, REV_PHObj, 63,
HAL_HandleEnum::REVPH>* REVPHHandles;
namespace hal::init {
void InitializeREVPH() {
static IndexedHandleResource<HAL_REVPHHandle, REV_PHObj, kNumREVPHModules,
HAL_HandleEnum::REVPH>
rH;
REVPHHandles = &rH;
}
} // namespace hal::init
static PH_status0_t HAL_REV_ReadPHStatus0(HAL_CANHandle hcan, int32_t* status) {
uint8_t packedData[8] = {0};
int32_t length = 0;
uint64_t timestamp = 0;
PH_status0_t result = {};
HAL_ReadCANPacketTimeout(hcan, PH_STATUS0_FRAME_API, packedData, &length,
&timestamp, kPHFrameStatus0Timeout * 2, status);
if (*status != 0) {
return result;
}
PH_status0_unpack(&result, packedData, PH_STATUS0_LENGTH);
return result;
}
static PH_status1_t HAL_REV_ReadPHStatus1(HAL_CANHandle hcan, int32_t* status) {
uint8_t packedData[8] = {0};
int32_t length = 0;
uint64_t timestamp = 0;
PH_status1_t result = {};
HAL_ReadCANPacketTimeout(hcan, PH_STATUS1_FRAME_API, packedData, &length,
&timestamp, kPHFrameStatus1Timeout * 2, status);
if (*status != 0) {
return result;
}
PH_status1_unpack(&result, packedData, PH_STATUS1_LENGTH);
return result;
}
enum REV_SolenoidState {
kSolenoidDisabled = 0,
kSolenoidEnabled,
kSolenoidControlledViaPulse
};
static void HAL_REV_UpdateDesiredPHSolenoidState(REV_PHObj* hph,
int32_t solenoid,
REV_SolenoidState state) {
switch (solenoid) {
case 0:
hph->desiredSolenoidsState.channel_0 = state;
break;
case 1:
hph->desiredSolenoidsState.channel_1 = state;
break;
case 2:
hph->desiredSolenoidsState.channel_2 = state;
break;
case 3:
hph->desiredSolenoidsState.channel_3 = state;
break;
case 4:
hph->desiredSolenoidsState.channel_4 = state;
break;
case 5:
hph->desiredSolenoidsState.channel_5 = state;
break;
case 6:
hph->desiredSolenoidsState.channel_6 = state;
break;
case 7:
hph->desiredSolenoidsState.channel_7 = state;
break;
case 8:
hph->desiredSolenoidsState.channel_8 = state;
break;
case 9:
hph->desiredSolenoidsState.channel_9 = state;
break;
case 10:
hph->desiredSolenoidsState.channel_10 = state;
break;
case 11:
hph->desiredSolenoidsState.channel_11 = state;
break;
case 12:
hph->desiredSolenoidsState.channel_12 = state;
break;
case 13:
hph->desiredSolenoidsState.channel_13 = state;
break;
case 14:
hph->desiredSolenoidsState.channel_14 = state;
break;
case 15:
hph->desiredSolenoidsState.channel_15 = state;
break;
}
}
static void HAL_REV_SendSolenoidsState(REV_PHObj* hph, int32_t* status) {
uint8_t packedData[PH_SET_ALL_LENGTH] = {0};
PH_set_all_pack(packedData, &(hph->desiredSolenoidsState), PH_SET_ALL_LENGTH);
HAL_WriteCANPacketRepeating(hph->hcan, packedData, PH_SET_ALL_LENGTH,
PH_SET_ALL_FRAME_API, hph->controlPeriod, status);
}
static HAL_Bool HAL_REV_CheckPHPulseTime(int32_t time) {
return ((time > 0) && (time <= HAL_REV_MAX_PULSE_TIME)) ? 1 : 0;
}
HAL_REVPHHandle HAL_InitializeREVPH(int32_t module,
const char* allocationLocation,
int32_t* status) {
hal::init::CheckInit();
if (!HAL_CheckREVPHModuleNumber(module)) {
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
kNumREVPHModules, module);
return HAL_kInvalidHandle;
}
HAL_REVPHHandle handle;
auto hph = REVPHHandles->Allocate(module, &handle, status);
if (*status != 0) {
if (hph) {
hal::SetLastErrorPreviouslyAllocated(status, "REV PH", module,
hph->previousAllocation);
} else {
hal::SetLastErrorIndexOutOfRange(status, "Invalid Index for REV PH", 1,
kNumREVPHModules, module);
}
return HAL_kInvalidHandle; // failed to allocate. Pass error back.
}
HAL_CANHandle hcan =
HAL_InitializeCAN(manufacturer, module, deviceType, status);
if (*status != 0) {
REVPHHandles->Free(handle);
return HAL_kInvalidHandle;
}
hph->previousAllocation = allocationLocation ? allocationLocation : "";
hph->hcan = hcan;
hph->controlPeriod = kDefaultControlPeriod;
// Start closed-loop compressor control by starting solenoid state updates
HAL_REV_SendSolenoidsState(hph.get(), status);
return handle;
}
void HAL_FreeREVPH(HAL_REVPHHandle handle) {
auto hph = REVPHHandles->Get(handle);
if (hph == nullptr)
return;
HAL_CleanCAN(hph->hcan);
REVPHHandles->Free(handle);
}
HAL_Bool HAL_CheckREVPHModuleNumber(int32_t module) {
return module >= 1 && module < kNumREVPDHModules;
}
HAL_Bool HAL_CheckREVPHSolenoidChannel(int32_t channel) {
return channel >= 0 && channel < kNumREVPHChannels;
}
HAL_Bool HAL_GetREVPHCompressor(HAL_REVPHHandle handle, int32_t* status) {
auto ph = REVPHHandles->Get(handle);
if (ph == nullptr) {
*status = HAL_HANDLE_ERROR;
return false;
}
PH_status0_t status0 = HAL_REV_ReadPHStatus0(ph->hcan, status);
if (*status != 0) {
return false;
}
return status0.compressor_on;
}
void HAL_SetREVPHClosedLoopControl(HAL_REVPHHandle handle, HAL_Bool enabled,
int32_t* status) {
// TODO
}
HAL_Bool HAL_GetREVPHClosedLoopControl(HAL_REVPHHandle handle,
int32_t* status) {
return false; // TODO
}
HAL_Bool HAL_GetREVPHPressureSwitch(HAL_REVPHHandle handle, int32_t* status) {
auto ph = REVPHHandles->Get(handle);
if (ph == nullptr) {
*status = HAL_HANDLE_ERROR;
return false;
}
PH_status0_t status0 = HAL_REV_ReadPHStatus0(ph->hcan, status);
if (*status != 0) {
return false;
}
return status0.digital_sensor;
}
double HAL_GetREVPHCompressorCurrent(HAL_REVPHHandle handle, int32_t* status) {
auto ph = REVPHHandles->Get(handle);
if (ph == nullptr) {
*status = HAL_HANDLE_ERROR;
return 0;
}
PH_status1_t status1 = HAL_REV_ReadPHStatus1(ph->hcan, status);
if (*status != 0) {
return 0;
}
return PH_status1_compressor_current_decode(status1.compressor_current);
}
double HAL_GetREVPHAnalogPressure(HAL_REVPHHandle handle, int32_t channel,
int32_t* status) {
auto ph = REVPHHandles->Get(handle);
if (ph == nullptr) {
*status = HAL_HANDLE_ERROR;
return 0;
}
if (channel < 0 || channel > 1) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastErrorIndexOutOfRange(status, "Invalid REV Analog Index", 0, 2,
channel);
return 0;
}
PH_status0_t status0 = HAL_REV_ReadPHStatus0(ph->hcan, status);
if (*status != 0) {
return 0;
}
if (channel == 0) {
return PH_status0_analog_0_decode(status0.analog_0);
}
return PH_status0_analog_1_decode(status0.analog_1);
}
int32_t HAL_GetREVPHSolenoids(HAL_REVPHHandle handle, int32_t* status) {
auto ph = REVPHHandles->Get(handle);
if (ph == nullptr) {
*status = HAL_HANDLE_ERROR;
return 0;
}
PH_status0_t status0 = HAL_REV_ReadPHStatus0(ph->hcan, status);
if (*status != 0) {
return 0;
}
uint32_t result = status0.channel_0;
result |= status0.channel_1 << 1;
result |= status0.channel_2 << 2;
result |= status0.channel_3 << 3;
result |= status0.channel_4 << 4;
result |= status0.channel_5 << 5;
result |= status0.channel_6 << 6;
result |= status0.channel_7 << 7;
result |= status0.channel_8 << 8;
result |= status0.channel_9 << 9;
result |= status0.channel_10 << 10;
result |= status0.channel_11 << 11;
result |= status0.channel_12 << 12;
result |= status0.channel_13 << 13;
result |= status0.channel_14 << 14;
result |= status0.channel_15 << 15;
return result;
}
void HAL_SetREVPHSolenoids(HAL_REVPHHandle handle, int32_t mask, int32_t values,
int32_t* status) {
auto ph = REVPHHandles->Get(handle);
if (ph == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
std::scoped_lock lock{ph->solenoidLock};
for (int solenoid = 0; solenoid < kNumREVPHChannels; solenoid++) {
if (mask & (1 << solenoid)) {
// The mask bit for the solenoid is set, so we update the solenoid state
REV_SolenoidState desiredSolenoidState =
values & (1 << solenoid) ? kSolenoidEnabled : kSolenoidDisabled;
HAL_REV_UpdateDesiredPHSolenoidState(ph.get(), solenoid,
desiredSolenoidState);
}
}
HAL_REV_SendSolenoidsState(ph.get(), status);
}
void HAL_FireREVPHOneShot(HAL_REVPHHandle handle, int32_t index, int32_t durMs,
int32_t* status) {
auto ph = REVPHHandles->Get(handle);
if (ph == nullptr) {
*status = HAL_HANDLE_ERROR;
return;
}
if (index >= kNumREVPHChannels || index < 0) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(
status,
fmt::format("Only [0-15] are valid index values. Requested {}", index));
return;
}
if (!HAL_REV_CheckPHPulseTime(durMs)) {
*status = PARAMETER_OUT_OF_RANGE;
hal::SetLastError(
status,
fmt::format("Time not within expected range [0-65534]. Requested {}",
durMs));
return;
}
{
std::scoped_lock lock{ph->solenoidLock};
HAL_REV_UpdateDesiredPHSolenoidState(ph.get(), index,
kSolenoidControlledViaPulse);
HAL_REV_SendSolenoidsState(ph.get(), status);
}
if (*status != 0) {
return;
}
PH_pulse_once_t pulse = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
pulse.pulse_length_ms = durMs;
// Specify which solenoid should be pulsed
// The protocol supports specifying any number of solenoids to be pulsed at
// the same time, should that functionality be exposed to users in the future.
switch (index) {
case 0:
pulse.channel_0 = true;
break;
case 1:
pulse.channel_1 = true;
break;
case 2:
pulse.channel_2 = true;
break;
case 3:
pulse.channel_3 = true;
break;
case 4:
pulse.channel_4 = true;
break;
case 5:
pulse.channel_5 = true;
break;
case 6:
pulse.channel_6 = true;
break;
case 7:
pulse.channel_7 = true;
break;
case 8:
pulse.channel_8 = true;
break;
case 9:
pulse.channel_9 = true;
break;
case 10:
pulse.channel_10 = true;
break;
case 11:
pulse.channel_11 = true;
break;
case 12:
pulse.channel_12 = true;
break;
case 13:
pulse.channel_13 = true;
break;
case 14:
pulse.channel_14 = true;
break;
case 15:
pulse.channel_15 = true;
break;
}
// Send pulse command
uint8_t packedData[PH_PULSE_ONCE_LENGTH] = {0};
PH_pulse_once_pack(packedData, &pulse, PH_PULSE_ONCE_LENGTH);
HAL_WriteCANPacket(ph->hcan, packedData, PH_PULSE_ONCE_LENGTH,
PH_PULSE_ONCE_FRAME_API, status);
}

View File

@@ -83,7 +83,10 @@ HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
serialPort->portId = open(portName, O_RDWR | O_NOCTTY);
if (serialPort->portId < 0) {
*status = errno;
*status = -errno;
if (*status == EACCES) {
*status = HAL_CONSOLE_OUT_ENABLED_ERROR;
}
serialPortHandles->Free(handle);
return HAL_kInvalidHandle;
}
@@ -91,8 +94,20 @@ HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
std::memset(&serialPort->tty, 0, sizeof(serialPort->tty));
serialPort->baudRate = B9600;
cfsetospeed(&serialPort->tty, static_cast<speed_t>(serialPort->baudRate));
cfsetispeed(&serialPort->tty, static_cast<speed_t>(serialPort->baudRate));
if (cfsetospeed(&serialPort->tty,
static_cast<speed_t>(serialPort->baudRate)) != 0) {
*status = -errno;
close(serialPort->portId);
serialPortHandles->Free(handle);
return HAL_kInvalidHandle;
}
if (cfsetispeed(&serialPort->tty,
static_cast<speed_t>(serialPort->baudRate)) != 0) {
*status = -errno;
close(serialPort->portId);
serialPortHandles->Free(handle);
return HAL_kInvalidHandle;
}
serialPort->tty.c_cflag &= ~PARENB;
serialPort->tty.c_cflag &= ~CSTOPB;
@@ -112,9 +127,14 @@ HAL_SerialPortHandle HAL_InitializeSerialPortDirect(HAL_SerialPort port,
*/
serialPort->tty.c_oflag = ~OPOST;
tcflush(serialPort->portId, TCIOFLUSH);
if (tcflush(serialPort->portId, TCIOFLUSH) != 0) {
*status = -errno;
close(serialPort->portId);
serialPortHandles->Free(handle);
return HAL_kInvalidHandle;
}
if (tcsetattr(serialPort->portId, TCSANOW, &serialPort->tty) != 0) {
*status = errno;
*status = -errno;
close(serialPort->portId);
serialPortHandles->Free(handle);
return HAL_kInvalidHandle;

View File

@@ -0,0 +1,37 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include "hal/simulation/REVPHData.h"
#include "hal/simulation/SimDataValue.h"
extern "C" {
void HALSIM_ResetREVPHData(int32_t index) {}
#define DEFINE_CAPI(TYPE, CAPINAME, RETURN) \
HAL_SIMDATAVALUE_STUB_CAPI(TYPE, HALSIM, REVPH##CAPINAME, RETURN)
HAL_SIMDATAVALUE_STUB_CAPI_CHANNEL(HAL_Bool, HALSIM, REVPHSolenoidOutput, false)
DEFINE_CAPI(HAL_Bool, Initialized, false)
DEFINE_CAPI(HAL_Bool, CompressorOn, false)
DEFINE_CAPI(HAL_Bool, ClosedLoopEnabled, false)
DEFINE_CAPI(HAL_Bool, PressureSwitch, false)
DEFINE_CAPI(double, CompressorCurrent, 0)
void HALSIM_GetREVPHAllSolenoids(int32_t index, uint8_t* values) {
*values = 0;
}
void HALSIM_SetREVPHAllSolenoids(int32_t index, uint8_t values) {}
void HALSIM_RegisterREVPHAllNonSolenoidCallbacks(int32_t index,
HAL_NotifyCallback callback,
void* param,
HAL_Bool initialNotify) {}
void HALSIM_RegisterREVPHAllSolenoidCallbacks(int32_t index, int32_t channel,
HAL_NotifyCallback callback,
void* param,
HAL_Bool initialNotify) {}
} // extern "C"

View File

@@ -27,6 +27,7 @@ DEFINE_CAPI(HAL_Bool, UserActive3V3, false)
DEFINE_CAPI(int32_t, UserFaults6V, 0)
DEFINE_CAPI(int32_t, UserFaults5V, 0)
DEFINE_CAPI(int32_t, UserFaults3V3, 0)
DEFINE_CAPI(double, BrownoutVoltage, 6.75)
void HALSIM_RegisterRoboRioAllCallbacks(HAL_NotifyCallback callback,
void* param, HAL_Bool initialNotify) {}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -272,4 +272,30 @@ Java_edu_wpi_first_hal_PortsJNI_getNumREVPDHChannels
jint value = HAL_GetNumREVPDHChannels();
return value;
}
/*
* Class: edu_wpi_first_hal_PortsJNI
* Method: getNumREVPHModules
* Signature: ()I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_PortsJNI_getNumREVPHModules
(JNIEnv* env, jclass)
{
jint value = HAL_GetNumREVPHModules();
return value;
}
/*
* Class: edu_wpi_first_hal_PortsJNI
* Method: getNumREVPHChannels
* Signature: ()I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_PortsJNI_getNumREVPHChannels
(JNIEnv* env, jclass)
{
jint value = HAL_GetNumREVPHChannels();
return value;
}
} // extern "C"

View File

@@ -292,4 +292,74 @@ Java_edu_wpi_first_hal_PowerDistributionJNI_getSwitchableChannel
return state;
}
/*
* Class: edu_wpi_first_hal_PowerDistributionJNI
* Method: getVoltageNoError
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_getVoltageNoError
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
double voltage = HAL_GetPowerDistributionVoltage(handle, &status);
return voltage;
}
/*
* Class: edu_wpi_first_hal_PowerDistributionJNI
* Method: getChannelCurrentNoError
* Signature: (II)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_getChannelCurrentNoError
(JNIEnv* env, jclass, jint handle, jint channel)
{
int32_t status = 0;
double current =
HAL_GetPowerDistributionChannelCurrent(handle, channel, &status);
return current;
}
/*
* Class: edu_wpi_first_hal_PowerDistributionJNI
* Method: getTotalCurrentNoError
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_getTotalCurrentNoError
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
double current = HAL_GetPowerDistributionTotalCurrent(handle, &status);
return current;
}
/*
* Class: edu_wpi_first_hal_PowerDistributionJNI
* Method: setSwitchableChannelNoError
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_setSwitchableChannelNoError
(JNIEnv* env, jclass, jint handle, jboolean enabled)
{
int32_t status = 0;
HAL_SetPowerDistributionSwitchableChannel(handle, enabled, &status);
}
/*
* Class: edu_wpi_first_hal_PowerDistributionJNI
* Method: getSwitchableChannelNoError
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_PowerDistributionJNI_getSwitchableChannelNoError
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto state = HAL_GetPowerDistributionSwitchableChannel(handle, &status);
return state;
}
} // extern "C"

View File

@@ -222,4 +222,33 @@ Java_edu_wpi_first_hal_PowerJNI_getUserCurrentFaults3V3
return val;
}
/*
* Class: edu_wpi_first_hal_PowerJNI
* Method: setBrownoutVoltage
* Signature: (D)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_PowerJNI_setBrownoutVoltage
(JNIEnv* env, jclass, jdouble brownoutVoltage)
{
int32_t status = 0;
HAL_SetBrownoutVoltage(brownoutVoltage, &status);
CheckStatus(env, status);
}
/*
* Class: edu_wpi_first_hal_PowerJNI
* Method: getBrownoutVoltage
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_PowerJNI_getBrownoutVoltage
(JNIEnv* env, jclass)
{
int32_t status = 0;
double val = HAL_GetBrownoutVoltage(&status);
CheckStatus(env, status);
return val;
}
} // extern "C"

View File

@@ -0,0 +1,191 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <jni.h>
#include <wpi/jni_util.h>
#include "HALUtil.h"
#include "edu_wpi_first_hal_REVPHJNI.h"
#include "hal/Ports.h"
#include "hal/REVPH.h"
#include "hal/handles/HandlesInternal.h"
using namespace hal;
extern "C" {
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: initialize
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_REVPHJNI_initialize
(JNIEnv* env, jclass, jint module)
{
int32_t status = 0;
auto stack = wpi::java::GetJavaStackTrace(env, "edu.wpi.first");
auto handle = HAL_InitializeREVPH(module, stack.c_str(), &status);
CheckStatusForceThrow(env, status);
return handle;
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: free
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_REVPHJNI_free
(JNIEnv* env, jclass, jint handle)
{
HAL_FreeREVPH(handle);
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: checkSolenoidChannel
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_REVPHJNI_checkSolenoidChannel
(JNIEnv*, jclass, jint channel)
{
return HAL_CheckREVPHSolenoidChannel(channel);
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: getCompressor
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_REVPHJNI_getCompressor
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto result = HAL_GetREVPHCompressor(handle, &status);
CheckStatus(env, status, false);
return result;
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: setClosedLoopControl
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_REVPHJNI_setClosedLoopControl
(JNIEnv* env, jclass, jint handle, jboolean enabled)
{
int32_t status = 0;
HAL_SetREVPHClosedLoopControl(handle, enabled, &status);
CheckStatus(env, status, false);
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: getClosedLoopControl
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_REVPHJNI_getClosedLoopControl
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto result = HAL_GetREVPHClosedLoopControl(handle, &status);
CheckStatus(env, status, false);
return result;
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: getPressureSwitch
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_REVPHJNI_getPressureSwitch
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto result = HAL_GetREVPHPressureSwitch(handle, &status);
CheckStatus(env, status, false);
return result;
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: getAnalogPressure
* Signature: (II)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_REVPHJNI_getAnalogPressure
(JNIEnv* env, jclass, jint handle, jint channel)
{
int32_t status = 0;
auto result = HAL_GetREVPHAnalogPressure(handle, channel, &status);
CheckStatus(env, status, false);
return result;
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: getCompressorCurrent
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_REVPHJNI_getCompressorCurrent
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto result = HAL_GetREVPHCompressorCurrent(handle, &status);
CheckStatus(env, status, false);
return result;
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: getSolenoids
* Signature: (I)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_REVPHJNI_getSolenoids
(JNIEnv* env, jclass, jint handle)
{
int32_t status = 0;
auto result = HAL_GetREVPHSolenoids(handle, &status);
CheckStatus(env, status, false);
return result;
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: setSolenoids
* Signature: (III)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_REVPHJNI_setSolenoids
(JNIEnv* env, jclass, jint handle, jint mask, jint value)
{
int32_t status = 0;
HAL_SetREVPHSolenoids(handle, mask, value, &status);
CheckStatus(env, status, false);
}
/*
* Class: edu_wpi_first_hal_REVPHJNI
* Method: fireOneShot
* Signature: (III)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_REVPHJNI_fireOneShot
(JNIEnv* env, jclass, jint handle, jint index, jint durMs)
{
int32_t status = 0;
HAL_FireREVPHOneShot(handle, index, durMs, &status);
CheckStatus(env, status, false);
}
} // extern "C"

View File

@@ -0,0 +1,365 @@
// Copyright (c) FIRST and other WPILib contributors.
// Open Source Software; you can modify and/or share it under the terms of
// the WPILib BSD license file in the root directory of this project.
#include <jni.h>
#include "CallbackStore.h"
#include "edu_wpi_first_hal_simulation_REVPHDataJNI.h"
#include "hal/simulation/REVPHData.h"
using namespace hal;
extern "C" {
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: registerInitializedCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_registerInitializedCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterREVPHInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: cancelInitializedCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_cancelInitializedCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelREVPHInitializedCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: getInitialized
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_getInitialized
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetREVPHInitialized(index);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: setInitialized
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_setInitialized
(JNIEnv*, jclass, jint index, jboolean value)
{
HALSIM_SetREVPHInitialized(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: registerSolenoidOutputCallback
* Signature: (IILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_registerSolenoidOutputCallback
(JNIEnv* env, jclass, jint index, jint channel, jobject callback,
jboolean initialNotify)
{
return sim::AllocateChannelCallback(
env, index, channel, callback, initialNotify,
&HALSIM_RegisterREVPHSolenoidOutputCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: cancelSolenoidOutputCallback
* Signature: (III)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_cancelSolenoidOutputCallback
(JNIEnv* env, jclass, jint index, jint channel, jint handle)
{
return sim::FreeChannelCallback(env, handle, index, channel,
&HALSIM_CancelREVPHSolenoidOutputCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: getSolenoidOutput
* Signature: (II)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_getSolenoidOutput
(JNIEnv*, jclass, jint index, jint channel)
{
return HALSIM_GetREVPHSolenoidOutput(index, channel);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: setSolenoidOutput
* Signature: (IIZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_setSolenoidOutput
(JNIEnv*, jclass, jint index, jint channel, jboolean value)
{
HALSIM_SetREVPHSolenoidOutput(index, channel, value);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: registerCompressorOnCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_registerCompressorOnCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterREVPHCompressorOnCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: cancelCompressorOnCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_cancelCompressorOnCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelREVPHCompressorOnCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: getCompressorOn
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_getCompressorOn
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetREVPHCompressorOn(index);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: setCompressorOn
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_setCompressorOn
(JNIEnv*, jclass, jint index, jboolean value)
{
HALSIM_SetREVPHCompressorOn(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: registerClosedLoopEnabledCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_registerClosedLoopEnabledCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterREVPHClosedLoopEnabledCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: cancelClosedLoopEnabledCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_cancelClosedLoopEnabledCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelREVPHClosedLoopEnabledCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: getClosedLoopEnabled
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_getClosedLoopEnabled
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetREVPHClosedLoopEnabled(index);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: setClosedLoopEnabled
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_setClosedLoopEnabled
(JNIEnv*, jclass, jint index, jboolean value)
{
HALSIM_SetREVPHClosedLoopEnabled(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: registerPressureSwitchCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_registerPressureSwitchCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterREVPHPressureSwitchCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: cancelPressureSwitchCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_cancelPressureSwitchCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelREVPHPressureSwitchCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: getPressureSwitch
* Signature: (I)Z
*/
JNIEXPORT jboolean JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_getPressureSwitch
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetREVPHPressureSwitch(index);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: setPressureSwitch
* Signature: (IZ)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_setPressureSwitch
(JNIEnv*, jclass, jint index, jboolean value)
{
HALSIM_SetREVPHPressureSwitch(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: registerCompressorCurrentCallback
* Signature: (ILjava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_registerCompressorCurrentCallback
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallback(env, index, callback, initialNotify,
&HALSIM_RegisterREVPHCompressorCurrentCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: cancelCompressorCurrentCallback
* Signature: (II)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_cancelCompressorCurrentCallback
(JNIEnv* env, jclass, jint index, jint handle)
{
return sim::FreeCallback(env, handle, index,
&HALSIM_CancelREVPHCompressorCurrentCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: getCompressorCurrent
* Signature: (I)D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_getCompressorCurrent
(JNIEnv*, jclass, jint index)
{
return HALSIM_GetREVPHCompressorCurrent(index);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: setCompressorCurrent
* Signature: (ID)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_setCompressorCurrent
(JNIEnv*, jclass, jint index, jdouble value)
{
HALSIM_SetREVPHCompressorCurrent(index, value);
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: registerAllNonSolenoidCallbacks
* Signature: (ILjava/lang/Object;Z)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_registerAllNonSolenoidCallbacks
(JNIEnv* env, jclass, jint index, jobject callback, jboolean initialNotify)
{
sim::AllocateCallback(
env, index, callback, initialNotify,
[](int32_t index, HAL_NotifyCallback cb, void* param, HAL_Bool in) {
HALSIM_RegisterREVPHAllNonSolenoidCallbacks(index, cb, param, in);
return 0;
});
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: registerAllSolenoidCallbacks
* Signature: (IILjava/lang/Object;Z)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_registerAllSolenoidCallbacks
(JNIEnv* env, jclass, jint index, jint channel, jobject callback,
jboolean initialNotify)
{
sim::AllocateChannelCallback(
env, index, channel, callback, initialNotify,
[](int32_t index, int32_t channel, HAL_NotifyCallback cb, void* param,
HAL_Bool in) {
HALSIM_RegisterREVPHAllSolenoidCallbacks(index, channel, cb, param, in);
return 0;
});
}
/*
* Class: edu_wpi_first_hal_simulation_REVPHDataJNI
* Method: resetData
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_REVPHDataJNI_resetData
(JNIEnv*, jclass, jint index)
{
HALSIM_ResetREVPHData(index);
}
} // extern "C"

View File

@@ -774,6 +774,57 @@ Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setUserFaults3V3
HALSIM_SetRoboRioUserFaults3V3(value);
}
/*
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
* Method: registerBrownoutVoltageCallback
* Signature: (Ljava/lang/Object;Z)I
*/
JNIEXPORT jint JNICALL
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_registerBrownoutVoltageCallback
(JNIEnv* env, jclass, jobject callback, jboolean initialNotify)
{
return sim::AllocateCallbackNoIndex(
env, callback, initialNotify,
&HALSIM_RegisterRoboRioBrownoutVoltageCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
* Method: cancelBrownoutVoltageCallback
* Signature: (I)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_cancelBrownoutVoltageCallback
(JNIEnv* env, jclass, jint handle)
{
return sim::FreeCallbackNoIndex(env, handle,
&HALSIM_CancelRoboRioBrownoutVoltageCallback);
}
/*
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
* Method: getBrownoutVoltage
* Signature: ()D
*/
JNIEXPORT jdouble JNICALL
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_getBrownoutVoltage
(JNIEnv*, jclass)
{
return HALSIM_GetRoboRioBrownoutVoltage();
}
/*
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
* Method: setBrownoutVoltage
* Signature: (D)V
*/
JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_simulation_RoboRioDataJNI_setBrownoutVoltage
(JNIEnv*, jclass, jdouble value)
{
HALSIM_SetRoboRioBrownoutVoltage(value);
}
/*
* Class: edu_wpi_first_hal_simulation_RoboRioDataJNI
* Method: resetData

View File

@@ -21,7 +21,8 @@ extern "C" {
/**
* Is the channel attached to an accumulator.
*
* @param analogPortHandle Handle to the analog port.
* @param[in] analogPortHandle Handle to the analog port.
* @param[out] status Error status variable. 0 on success.
* @return The analog channel is attached to an accumulator.
*/
HAL_Bool HAL_IsAccumulatorChannel(HAL_AnalogInputHandle analogPortHandle,
@@ -30,7 +31,8 @@ HAL_Bool HAL_IsAccumulatorChannel(HAL_AnalogInputHandle analogPortHandle,
/**
* Initialize the accumulator.
*
* @param analogPortHandle Handle to the analog port.
* @param[in] analogPortHandle Handle to the analog port.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_InitAccumulator(HAL_AnalogInputHandle analogPortHandle,
int32_t* status);
@@ -38,7 +40,8 @@ void HAL_InitAccumulator(HAL_AnalogInputHandle analogPortHandle,
/**
* Resets the accumulator to the initial value.
*
* @param analogPortHandle Handle to the analog port.
* @param[in] analogPortHandle Handle to the analog port.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ResetAccumulator(HAL_AnalogInputHandle analogPortHandle,
int32_t* status);
@@ -55,8 +58,9 @@ void HAL_ResetAccumulator(HAL_AnalogInputHandle analogPortHandle,
* source from channel 1. Because of this, any non-zero oversample bits will
* affect the size of the value for this field.
*
* @param analogPortHandle Handle to the analog port.
* @param center The center value of the accumulator.
* @param[in] analogPortHandle Handle to the analog port.
* @param[in] center The center value of the accumulator.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAccumulatorCenter(HAL_AnalogInputHandle analogPortHandle,
int32_t center, int32_t* status);
@@ -64,8 +68,9 @@ void HAL_SetAccumulatorCenter(HAL_AnalogInputHandle analogPortHandle,
/**
* Set the accumulator's deadband.
*
* @param analogPortHandle Handle to the analog port.
* @param deadband The deadband of the accumulator.
* @param[in] analogPortHandle Handle to the analog port.
* @param[in] deadband The deadband of the accumulator.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAccumulatorDeadband(HAL_AnalogInputHandle analogPortHandle,
int32_t deadband, int32_t* status);
@@ -76,7 +81,8 @@ void HAL_SetAccumulatorDeadband(HAL_AnalogInputHandle analogPortHandle,
* Read the value that has been accumulating on channel 1.
* The accumulator is attached after the oversample and average engine.
*
* @param analogPortHandle Handle to the analog port.
* @param[in] analogPortHandle Handle to the analog port.
* @param[out] status Error status variable. 0 on success.
* @return The 64-bit value accumulated since the last Reset().
*/
int64_t HAL_GetAccumulatorValue(HAL_AnalogInputHandle analogPortHandle,
@@ -88,7 +94,8 @@ int64_t HAL_GetAccumulatorValue(HAL_AnalogInputHandle analogPortHandle,
* Read the count of the accumulated values since the accumulator was last
* Reset().
*
* @param analogPortHandle Handle to the analog port.
* @param[in] analogPortHandle Handle to the analog port.
* @param[out] status Error status variable. 0 on success.
* @return The number of times samples from the channel were accumulated.
*/
int64_t HAL_GetAccumulatorCount(HAL_AnalogInputHandle analogPortHandle,
@@ -100,9 +107,10 @@ int64_t HAL_GetAccumulatorCount(HAL_AnalogInputHandle analogPortHandle,
* This function reads the value and count from the FPGA atomically.
* This can be used for averaging.
*
* @param analogPortHandle Handle to the analog port.
* @param value Pointer to the 64-bit accumulated output.
* @param count Pointer to the number of accumulation cycles.
* @param[in] analogPortHandle Handle to the analog port.
* @param[in] value Pointer to the 64-bit accumulated output.
* @param[in] count Pointer to the number of accumulation cycles.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_GetAccumulatorOutput(HAL_AnalogInputHandle analogPortHandle,
int64_t* value, int64_t* count, int32_t* status);

View File

@@ -21,10 +21,11 @@ extern "C" {
/**
* Initializes an analog gyro.
*
* @param handle handle to the analog port
* @param allocationLocation the location where the allocation is occuring
* (can be null)
* @return the initialized gyro handle
* @param[in] handle handle to the analog port
* @param[in] allocationLocation the location where the allocation is occuring
* (can be null)
* @param[out] status the error code, or 0 for success
* @return the initialized gyro handle
*/
HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle handle,
const char* allocationLocation,
@@ -34,7 +35,8 @@ HAL_GyroHandle HAL_InitializeAnalogGyro(HAL_AnalogInputHandle handle,
* Sets up an analog gyro with the proper offsets and settings for the KOP
* analog gyro.
*
* @param handle the gyro handle
* @param[in] handle the gyro handle
* @param[out] status the error code, or 0 for success
*/
void HAL_SetupAnalogGyro(HAL_GyroHandle handle, int32_t* status);
@@ -51,10 +53,11 @@ void HAL_FreeAnalogGyro(HAL_GyroHandle handle);
* This is meant to be used if you want to reuse the values from a previous
* calibration.
*
* @param handle the gyro handle
* @param voltsPerDegreePerSecond the gyro volts scaling
* @param offset the gyro offset
* @param center the gyro center
* @param[in] handle the gyro handle
* @param[in] voltsPerDegreePerSecond the gyro volts scaling
* @param[in] offset the gyro offset
* @param[in] center the gyro center
* @param[out] status the error code, or 0 for success
*/
void HAL_SetAnalogGyroParameters(HAL_GyroHandle handle,
double voltsPerDegreePerSecond, double offset,
@@ -63,8 +66,9 @@ void HAL_SetAnalogGyroParameters(HAL_GyroHandle handle,
/**
* Sets the analog gyro volts per degrees per second scaling.
*
* @param handle the gyro handle
* @param voltsPerDegreePerSecond the gyro volts scaling
* @param[in] handle the gyro handle
* @param[in] voltsPerDegreePerSecond the gyro volts scaling
* @param[out] status the error code, or 0 for success
*/
void HAL_SetAnalogGyroVoltsPerDegreePerSecond(HAL_GyroHandle handle,
double voltsPerDegreePerSecond,
@@ -73,7 +77,8 @@ void HAL_SetAnalogGyroVoltsPerDegreePerSecond(HAL_GyroHandle handle,
/**
* Resets the analog gyro value to 0.
*
* @param handle the gyro handle
* @param[in] handle the gyro handle
* @param[out] status the error code, or 0 for success
*/
void HAL_ResetAnalogGyro(HAL_GyroHandle handle, int32_t* status);
@@ -84,15 +89,17 @@ void HAL_ResetAnalogGyro(HAL_GyroHandle handle, int32_t* status);
* setting that as the center. Note that this call blocks for 5 seconds to
* perform this.
*
* @param handle the gyro handle
* @param[in] handle the gyro handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_CalibrateAnalogGyro(HAL_GyroHandle handle, int32_t* status);
/**
* Sets the deadband of the analog gyro.
*
* @param handle the gyro handle
* @param volts the voltage deadband
* @param[in] handle the gyro handle
* @param[in] volts the voltage deadband
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAnalogGyroDeadband(HAL_GyroHandle handle, double volts,
int32_t* status);
@@ -100,7 +107,8 @@ void HAL_SetAnalogGyroDeadband(HAL_GyroHandle handle, double volts,
/**
* Gets the gyro angle in degrees.
*
* @param handle the gyro handle
* @param[in] handle the gyro handle
* @param[out] status Error status variable. 0 on success.
* @return the gyro angle in degrees
*/
double HAL_GetAnalogGyroAngle(HAL_GyroHandle handle, int32_t* status);
@@ -108,7 +116,8 @@ double HAL_GetAnalogGyroAngle(HAL_GyroHandle handle, int32_t* status);
/**
* Gets the gyro rate in degrees/second.
*
* @param handle the gyro handle
* @param[in] handle the gyro handle
* @param[out] status Error status variable. 0 on success.
* @return the gyro rate in degrees/second
*/
double HAL_GetAnalogGyroRate(HAL_GyroHandle handle, int32_t* status);
@@ -118,7 +127,8 @@ double HAL_GetAnalogGyroRate(HAL_GyroHandle handle, int32_t* status);
*
* Can be used to not repeat a calibration but reconstruct the gyro object.
*
* @param handle the gyro handle
* @param[in] handle the gyro handle
* @param[out] status Error status variable. 0 on success.
* @return the gryo offset
*/
double HAL_GetAnalogGyroOffset(HAL_GyroHandle handle, int32_t* status);
@@ -128,7 +138,8 @@ double HAL_GetAnalogGyroOffset(HAL_GyroHandle handle, int32_t* status);
*
* Can be used to not repeat a calibration but reconstruct the gyro object.
*
* @param handle the gyro handle
* @param[in] handle the gyro handle
* @param[out] status Error status variable. 0 on success.
* @return the gyro center
*/
int32_t HAL_GetAnalogGyroCenter(HAL_GyroHandle handle, int32_t* status);

View File

@@ -21,10 +21,11 @@ extern "C" {
/**
* Initializes the analog input port using the given port object.
*
* @param portHandle Handle to the port to initialize.
* @param allocationLocation the location where the allocation is occuring
* (can be null)
* @return the created analog input handle
* @param[in] portHandle Handle to the port to initialize.
* @param[in] allocationLocation the location where the allocation is occuring
* (can be null)
* @param[out] status the error code, or 0 for success
* @return the created analog input handle
*/
HAL_AnalogInputHandle HAL_InitializeAnalogInputPort(
HAL_PortHandle portHandle, const char* allocationLocation, int32_t* status);
@@ -68,7 +69,8 @@ void HAL_SetAnalogInputSimDevice(HAL_AnalogInputHandle handle,
*
* This is a global setting for the Athena and effects all channels.
*
* @param samplesPerSecond The number of samples per channel per second.
* @param[in] samplesPerSecond The number of samples per channel per second.
* @param[out] status the error code, or 0 for success
*/
void HAL_SetAnalogSampleRate(double samplesPerSecond, int32_t* status);
@@ -78,6 +80,7 @@ void HAL_SetAnalogSampleRate(double samplesPerSecond, int32_t* status);
* This assumes one entry in the scan list.
* This is a global setting for the Athena and effects all channels.
*
* @param[out] status the error code, or 0 for success
* @return Sample rate.
*/
double HAL_GetAnalogSampleRate(int32_t* status);
@@ -89,8 +92,9 @@ double HAL_GetAnalogSampleRate(int32_t* status);
* 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 analogPortHandle Handle to the analog port to configure.
* @param bits Number of bits to average.
* @param[in] analogPortHandle Handle to the analog port to configure.
* @param[in] bits Number of bits to average.
* @param[out] status the error code, or 0 for success
*/
void HAL_SetAnalogAverageBits(HAL_AnalogInputHandle analogPortHandle,
int32_t bits, int32_t* status);
@@ -101,7 +105,8 @@ void HAL_SetAnalogAverageBits(HAL_AnalogInputHandle analogPortHandle,
* 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 analogPortHandle Handle to the analog port to use.
* @param[in] analogPortHandle Handle to the analog port to use.
* @param[out] status the error code, or 0 for success
* @return Bits to average.
*/
int32_t HAL_GetAnalogAverageBits(HAL_AnalogInputHandle analogPortHandle,
@@ -115,8 +120,9 @@ int32_t HAL_GetAnalogAverageBits(HAL_AnalogInputHandle analogPortHandle,
* measurements at the expense of sampling rate. The oversampling is done
* automatically in the FPGA.
*
* @param analogPortHandle Handle to the analog port to use.
* @param bits Number of bits to oversample.
* @param[in] analogPortHandle Handle to the analog port to use.
* @param[in] bits Number of bits to oversample.
* @param[out] status the error code, or 0 for success
*/
void HAL_SetAnalogOversampleBits(HAL_AnalogInputHandle analogPortHandle,
int32_t bits, int32_t* status);
@@ -128,7 +134,8 @@ void HAL_SetAnalogOversampleBits(HAL_AnalogInputHandle analogPortHandle,
* oversampled values is 2**bits. The oversampling is done automatically in the
* FPGA.
*
* @param analogPortHandle Handle to the analog port to use.
* @param[in] analogPortHandle Handle to the analog port to use.
* @param[out] status the error code, or 0 for success
* @return Bits to oversample.
*/
int32_t HAL_GetAnalogOversampleBits(HAL_AnalogInputHandle analogPortHandle,
@@ -141,7 +148,8 @@ int32_t HAL_GetAnalogOversampleBits(HAL_AnalogInputHandle analogPortHandle,
* converter in the module. The units are in A/D converter codes. Use
* GetVoltage() to get the analog value in calibrated units.
*
* @param analogPortHandle Handle to the analog port to use.
* @param[in] analogPortHandle Handle to the analog port to use.
* @param[out] status the error code, or 0 for success
* @return A sample straight from the channel on this module.
*/
int32_t HAL_GetAnalogValue(HAL_AnalogInputHandle analogPortHandle,
@@ -158,7 +166,8 @@ int32_t HAL_GetAnalogValue(HAL_AnalogInputHandle analogPortHandle,
* the module on this channel. Use GetAverageVoltage() to get the analog value
* in calibrated units.
*
* @param analogPortHandle Handle to the analog port to use.
* @param[in] analogPortHandle Handle to the analog port to use.
* @param[out] status the error code, or 0 for success
* @return A sample from the oversample and average engine for the channel.
*/
int32_t HAL_GetAnalogAverageValue(HAL_AnalogInputHandle analogPortHandle,
@@ -172,8 +181,9 @@ int32_t HAL_GetAnalogAverageValue(HAL_AnalogInputHandle analogPortHandle,
*
* @todo This assumes raw values. Oversampling not supported as is.
*
* @param analogPortHandle Handle to the analog port to use.
* @param voltage The voltage to convert.
* @param[in] analogPortHandle Handle to the analog port to use.
* @param[in] voltage The voltage to convert.
* @param[out] status the error code, or 0 for success
* @return The raw value for the channel.
*/
int32_t HAL_GetAnalogVoltsToValue(HAL_AnalogInputHandle analogPortHandle,
@@ -185,7 +195,8 @@ int32_t HAL_GetAnalogVoltsToValue(HAL_AnalogInputHandle analogPortHandle,
* The value is scaled to units of Volts using the calibrated scaling data from
* GetLSBWeight() and GetOffset().
*
* @param analogPortHandle Handle to the analog port to use.
* @param[in] analogPortHandle Handle to the analog port to use.
* @param[out] status the error code, or 0 for success
* @return A scaled sample straight from the channel on this module.
*/
double HAL_GetAnalogVoltage(HAL_AnalogInputHandle analogPortHandle,
@@ -200,7 +211,8 @@ double HAL_GetAnalogVoltage(HAL_AnalogInputHandle analogPortHandle,
* 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 analogPortHandle Handle to the analog port to use.
* @param[in] analogPortHandle Handle to the analog port to use.
* @param[out] status the error code, or 0 for success
* @return A scaled sample from the output of the oversample and average engine
* for the channel.
*/
@@ -214,7 +226,8 @@ double HAL_GetAnalogAverageVoltage(HAL_AnalogInputHandle analogPortHandle,
*
* Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
*
* @param analogPortHandle Handle to the analog port to use.
* @param[in] analogPortHandle Handle to the analog port to use.
* @param[out] status the error code, or 0 for success
* @return Least significant bit weight.
*/
int32_t HAL_GetAnalogLSBWeight(HAL_AnalogInputHandle analogPortHandle,
@@ -227,7 +240,8 @@ int32_t HAL_GetAnalogLSBWeight(HAL_AnalogInputHandle analogPortHandle,
*
* Volts = ((LSB_Weight * 1e-9) * raw) - (Offset * 1e-9)
*
* @param analogPortHandle Handle to the analog port to use.
* @param[in] analogPortHandle Handle to the analog port to use.
* @param[out] status Error status variable. 0 on success.
* @return Offset constant.
*/
int32_t HAL_GetAnalogOffset(HAL_AnalogInputHandle analogPortHandle,
@@ -236,9 +250,11 @@ int32_t HAL_GetAnalogOffset(HAL_AnalogInputHandle analogPortHandle,
/**
* Get the analog voltage from a raw value.
*
* @param analogPortHandle Handle to the analog port the values were read from.
* @param rawValue The raw analog value
* @return The voltage relating to the value
* @param[in] analogPortHandle Handle to the analog port the values were read
* from.
* @param[in] rawValue The raw analog value
* @param[out] status Error status variable. 0 on success.
* @return The voltage relating to the value
*/
double HAL_GetAnalogValueToVolts(HAL_AnalogInputHandle analogPortHandle,
int32_t rawValue, int32_t* status);

View File

@@ -21,10 +21,11 @@ extern "C" {
/**
* Initializes the analog output port using the given port object.
*
* @param handle handle to the port
* @param allocationLocation the location where the allocation is occuring
* (can be null)
* @return the created analog output handle
* @param[in] portHandle handle to the port
* @param[in] allocationLocation the location where the allocation is occuring
* (can be null)
* @param[out] status Error status variable. 0 on success.
* @return the created analog output handle
*/
HAL_AnalogOutputHandle HAL_InitializeAnalogOutputPort(
HAL_PortHandle portHandle, const char* allocationLocation, int32_t* status);
@@ -39,8 +40,9 @@ void HAL_FreeAnalogOutputPort(HAL_AnalogOutputHandle analogOutputHandle);
/**
* Sets an analog output value.
*
* @param analogOutputHandle the analog output handle
* @param voltage the voltage (0-5v) to output
* @param[in] analogOutputHandle the analog output handle
* @param[in] voltage the voltage (0-5v) to output
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAnalogOutput(HAL_AnalogOutputHandle analogOutputHandle,
double voltage, int32_t* status);
@@ -48,8 +50,9 @@ void HAL_SetAnalogOutput(HAL_AnalogOutputHandle analogOutputHandle,
/**
* Gets the current analog output value.
*
* @param analogOutputHandle the analog output handle
* @return the current output voltage (0-5v)
* @param[in] analogOutputHandle the analog output handle
* @param[out] status Error status variable. 0 on success.
* @return the current output voltage (0-5v)
*/
double HAL_GetAnalogOutput(HAL_AnalogOutputHandle analogOutputHandle,
int32_t* status);

View File

@@ -33,8 +33,9 @@ extern "C" {
/**
* Initializes an analog trigger.
*
* @param portHandle the analog input to use for triggering
* @return the created analog trigger handle
* @param[in] portHandle the analog input to use for triggering
* @param[out] status Error status variable. 0 on success.
* @return the created analog trigger handle
*/
HAL_AnalogTriggerHandle HAL_InitializeAnalogTrigger(
HAL_AnalogInputHandle portHandle, int32_t* status);
@@ -42,6 +43,8 @@ HAL_AnalogTriggerHandle HAL_InitializeAnalogTrigger(
/**
* Initializes an analog trigger with a Duty Cycle input
*
* @param[in] dutyCycleHandle the analog input to use for duty cycle
* @param[out] status Error status variable. 0 on success.
*/
HAL_AnalogTriggerHandle HAL_InitializeAnalogTriggerDutyCycle(
HAL_DutyCycleHandle dutyCycleHandle, int32_t* status);
@@ -49,7 +52,8 @@ HAL_AnalogTriggerHandle HAL_InitializeAnalogTriggerDutyCycle(
/**
* Frees an analog trigger.
*
* @param analogTriggerHandle the trigger handle
* @param[in] analogTriggerHandle the trigger handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_CleanAnalogTrigger(HAL_AnalogTriggerHandle analogTriggerHandle,
int32_t* status);
@@ -60,9 +64,10 @@ void HAL_CleanAnalogTrigger(HAL_AnalogTriggerHandle analogTriggerHandle,
* HAL_SetAnalogTriggerLimitsVoltage or HAL_SetAnalogTriggerLimitsDutyCycle
* is likely better in most cases.
*
* @param analogTriggerHandle the trigger handle
* @param lower the lower ADC value
* @param upper the upper ADC value
* @param[in] analogTriggerHandle the trigger handle
* @param[in] lower the lower ADC value
* @param[in] upper the upper ADC value
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAnalogTriggerLimitsRaw(HAL_AnalogTriggerHandle analogTriggerHandle,
int32_t lower, int32_t upper,
@@ -73,14 +78,25 @@ void HAL_SetAnalogTriggerLimitsRaw(HAL_AnalogTriggerHandle analogTriggerHandle,
*
* The limits are given as floating point voltage values.
*
* @param analogTriggerHandle the trigger handle
* @param lower the lower voltage value
* @param upper the upper voltage value
* @param[in] analogTriggerHandle the trigger handle
* @param[in] lower the lower voltage value
* @param[in] upper the upper voltage value
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAnalogTriggerLimitsVoltage(
HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper,
int32_t* status);
/**
* Sets the upper and lower limits of the analog trigger.
*
* The limits are given as floating point duty cycle values.
*
* @param[in] analogTriggerHandle the trigger handle
* @param[in] lower the lower duty cycle value
* @param[in] upper the upper duty cycle value
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAnalogTriggerLimitsDutyCycle(
HAL_AnalogTriggerHandle analogTriggerHandle, double lower, double upper,
int32_t* status);
@@ -94,8 +110,9 @@ void HAL_SetAnalogTriggerLimitsDutyCycle(
* This is not allowed to be used if filtered mode is set.
* This is not allowed to be used with Duty Cycle based inputs.
*
* @param analogTriggerHandle the trigger handle
* @param useAveragedValue true to use averaged values, false for raw
* @param[in] analogTriggerHandle the trigger handle
* @param[in] useAveragedValue true to use averaged values, false for raw
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAnalogTriggerAveraged(HAL_AnalogTriggerHandle analogTriggerHandle,
HAL_Bool useAveragedValue, int32_t* status);
@@ -109,9 +126,10 @@ void HAL_SetAnalogTriggerAveraged(HAL_AnalogTriggerHandle analogTriggerHandle,
*
* This is not allowed to be used if averaged mode is set.
*
* @param analogTriggerHandle the trigger handle
* @param useFilteredValue true to use filtered values, false for average or
* raw
* @param[in] analogTriggerHandle the trigger handle
* @param[in] useFilteredValue true to use filtered values, false for average
* or raw
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetAnalogTriggerFiltered(HAL_AnalogTriggerHandle analogTriggerHandle,
HAL_Bool useFilteredValue, int32_t* status);
@@ -121,8 +139,9 @@ void HAL_SetAnalogTriggerFiltered(HAL_AnalogTriggerHandle analogTriggerHandle,
*
* True if the analog input is between the upper and lower limits.
*
* @param analogTriggerHandle the trigger handle
* @return the InWindow output of the analog trigger
* @param[in] analogTriggerHandle the trigger handle
* @param[out] status Error status variable. 0 on success.
* @return the InWindow output of the analog trigger
*/
HAL_Bool HAL_GetAnalogTriggerInWindow(
HAL_AnalogTriggerHandle analogTriggerHandle, int32_t* status);
@@ -134,8 +153,9 @@ HAL_Bool HAL_GetAnalogTriggerInWindow(
* False if below lower limit.
* If in Hysteresis, maintain previous state.
*
* @param analogTriggerHandle the trigger handle
* @return the TriggerState output of the analog trigger
* @param[in] analogTriggerHandle the trigger handle
* @param[out] status Error status variable. 0 on success.
* @return the TriggerState output of the analog trigger
*/
HAL_Bool HAL_GetAnalogTriggerTriggerState(
HAL_AnalogTriggerHandle analogTriggerHandle, int32_t* status);
@@ -143,9 +163,10 @@ HAL_Bool HAL_GetAnalogTriggerTriggerState(
/**
* Gets the state of the analog trigger output.
*
* @param analogTriggerHandle the trigger handle
* @param type the type of trigger to trigger on
* @return the state of the analog trigger output
* @param[in] analogTriggerHandle the trigger handle
* @param[in] type the type of trigger to trigger on
* @param[out] status Error status variable. 0 on success.
* @return the state of the analog trigger output
*/
HAL_Bool HAL_GetAnalogTriggerOutput(HAL_AnalogTriggerHandle analogTriggerHandle,
HAL_AnalogTriggerType type,
@@ -154,7 +175,8 @@ HAL_Bool HAL_GetAnalogTriggerOutput(HAL_AnalogTriggerHandle analogTriggerHandle,
/**
* Get the FPGA index for the AnlogTrigger.
*
* @param analogTriggerHandle the trigger handle
* @param[in] analogTriggerHandle the trigger handle
* @param[out] status Error status variable. 0 on success.
* @return the FPGA index
*/
int32_t HAL_GetAnalogTriggerFPGAIndex(

View File

@@ -45,11 +45,12 @@ extern "C" {
/**
* Sends a CAN message.
*
* @param messageID the CAN ID to send
* @param data the data to send (0-8 bytes)
* @param dataSize the size of the data to send (0-8 bytes)
* @param periodMs the period to repeat the packet at. Use
* HAL_CAN_SEND_PERIOD_NO_REPEAT to not repeat.
* @param[in] messageID the CAN ID to send
* @param[in] data the data to send (0-8 bytes)
* @param[in] dataSize the size of the data to send (0-8 bytes)
* @param[in] periodMs the period to repeat the packet at. Use
* HAL_CAN_SEND_PERIOD_NO_REPEAT to not repeat.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_CAN_SendMessage(uint32_t messageID, const uint8_t* data,
uint8_t dataSize, int32_t periodMs, int32_t* status);
@@ -57,12 +58,13 @@ void HAL_CAN_SendMessage(uint32_t messageID, const uint8_t* data,
/**
* Receives a CAN message.
*
* @param messageID store for the received message ID
* @param messageIDMask the message ID mask to look for
* @param data data output (8 bytes)
* @param dataSize data length (0-8 bytes)
* @param timeStamp the packet received timestamp (based off of
* CLOCK_MONOTONIC)
* @param[out] messageID store for the received message ID
* @param[in] messageIDMask the message ID mask to look for
* @param[out] data data output (8 bytes)
* @param[out] dataSize data length (0-8 bytes)
* @param[out] timeStamp the packet received timestamp (based off of
* CLOCK_MONOTONIC)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_CAN_ReceiveMessage(uint32_t* messageID, uint32_t messageIDMask,
uint8_t* data, uint8_t* dataSize,
@@ -71,10 +73,11 @@ void HAL_CAN_ReceiveMessage(uint32_t* messageID, uint32_t messageIDMask,
/**
* Opens a CAN stream.
*
* @param sessionHandle output for the session handle
* @param messageID the message ID to read
* @param messageIDMask the mssage ID mask
* @param maxMessages the maximum number of messages to stream
* @param[out] sessionHandle output for the session handle
* @param[in] messageID the message ID to read
* @param[in] messageIDMask the mssage ID mask
* @param[in] maxMessages the maximum number of messages to stream
* @param[out] status Error status variable. 0 on success.
*/
void HAL_CAN_OpenStreamSession(uint32_t* sessionHandle, uint32_t messageID,
uint32_t messageIDMask, uint32_t maxMessages,
@@ -90,10 +93,11 @@ void HAL_CAN_CloseStreamSession(uint32_t sessionHandle);
/**
* Reads a CAN stream message.
*
* @param sessionHandle the session handle
* @param messages array of messages
* @param messagesToRead the max number of messages to read
* @param messageRead the number of messages actually read
* @param[in] sessionHandle the session handle
* @param[in] messages array of messages
* @param[in] messagesToRead the max number of messages to read
* @param[out] messagesRead the number of messages actually read
* @param[out] status Error status variable. 0 on success.
*/
void HAL_CAN_ReadStreamSession(uint32_t sessionHandle,
struct HAL_CANStreamMessage* messages,
@@ -103,11 +107,12 @@ void HAL_CAN_ReadStreamSession(uint32_t sessionHandle,
/**
* Gets CAN status information.
*
* @param percentBusUtilization the bus utilization
* @param busOffCount the number of bus off errors
* @param txFullCount the number of tx full errors
* @param receiveErrorCount the number of receive errors
* @param transmitErrorCount the number of transmit errors
* @param[out] percentBusUtilization the bus utilization
* @param[out] busOffCount the number of bus off errors
* @param[out] txFullCount the number of tx full errors
* @param[out] receiveErrorCount the number of receive errors
* @param[out] transmitErrorCount the number of transmit errors
* @param[out] status Error status variable. 0 on success.
*/
void HAL_CAN_GetCANStatus(float* percentBusUtilization, uint32_t* busOffCount,
uint32_t* txFullCount, uint32_t* receiveErrorCount,

View File

@@ -24,10 +24,11 @@ extern "C" {
*
* These follow the FIRST standard CAN layout. Link TBD
*
* @param manufacturer the can manufacturer
* @param deviceId the device ID (0-63)
* @param deviceType the device type
* @return the created CAN handle
* @param[in] manufacturer the can manufacturer
* @param[in] deviceId the device ID (0-63)
* @param[in] deviceType the device type
* @param[out] status Error status variable. 0 on success.
* @return the created CAN handle
*/
HAL_CANHandle HAL_InitializeCAN(HAL_CANManufacturer manufacturer,
int32_t deviceId, HAL_CANDeviceType deviceType,
@@ -45,10 +46,11 @@ void HAL_CleanCAN(HAL_CANHandle handle);
*
* This ID is 10 bits.
*
* @param handle the CAN handle
* @param data the data to write (0-8 bytes)
* @param length the length of data (0-8)
* @param apiId the ID to write (0-1023 bits)
* @param[in] handle the CAN handle
* @param[in] data the data to write (0-8 bytes)
* @param[in] length the length of data (0-8)
* @param[in] apiId the ID to write (0-1023 bits)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_WriteCANPacket(HAL_CANHandle handle, const uint8_t* data,
int32_t length, int32_t apiId, int32_t* status);
@@ -60,11 +62,12 @@ void HAL_WriteCANPacket(HAL_CANHandle handle, const uint8_t* data,
*
* The RoboRIO will automatically repeat the packet at the specified interval
*
* @param handle the CAN handle
* @param data the data to write (0-8 bytes)
* @param length the length of data (0-8)
* @param apiId the ID to write (0-1023)
* @param repeatMs the period to repeat in ms
* @param[in] handle the CAN handle
* @param[in] data the data to write (0-8 bytes)
* @param[in] length the length of data (0-8)
* @param[in] apiId the ID to write (0-1023)
* @param[in] repeatMs the period to repeat in ms
* @param[out] status Error status variable. 0 on success.
*/
void HAL_WriteCANPacketRepeating(HAL_CANHandle handle, const uint8_t* data,
int32_t length, int32_t apiId,
@@ -77,9 +80,10 @@ void HAL_WriteCANPacketRepeating(HAL_CANHandle handle, const uint8_t* data,
* By spec, the length must be equal to the length sent by the other device,
* otherwise behavior is unspecified.
*
* @param handle the CAN handle
* @param length the length of data to request (0-8)
* @param apiId the ID to write (0-1023)
* @param[in] handle the CAN handle
* @param[in] length the length of data to request (0-8)
* @param[in] apiId the ID to write (0-1023)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_WriteCANRTRFrame(HAL_CANHandle handle, int32_t length, int32_t apiId,
int32_t* status);
@@ -89,8 +93,9 @@ void HAL_WriteCANRTRFrame(HAL_CANHandle handle, int32_t length, int32_t apiId,
*
* This ID is 10 bits.
*
* @param handle the CAN handle
* @param apiId the ID to stop repeating (0-1023)
* @param[in] handle the CAN handle
* @param[in] apiId the ID to stop repeating (0-1023)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_StopCANPacketRepeating(HAL_CANHandle handle, int32_t apiId,
int32_t* status);
@@ -101,12 +106,13 @@ void HAL_StopCANPacketRepeating(HAL_CANHandle handle, int32_t apiId,
* This will only return properly once per packet received. Multiple calls
* without receiving another packet will return an error code.
*
* @param handle the CAN handle
* @param apiId the ID to read (0-1023)
* @param data the packet data (8 bytes)
* @param length the received length (0-8 bytes)
* @param receivedTimestamp the packet received timestamp (based off of
* CLOCK_MONOTONIC)
* @param[in] handle the CAN handle
* @param[in] apiId the ID to read (0-1023)
* @param[out] data the packet data (8 bytes)
* @param[out] length the received length (0-8 bytes)
* @param[out] receivedTimestamp the packet received timestamp (based off of
* CLOCK_MONOTONIC)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ReadCANPacketNew(HAL_CANHandle handle, int32_t apiId, uint8_t* data,
int32_t* length, uint64_t* receivedTimestamp,
@@ -116,12 +122,13 @@ void HAL_ReadCANPacketNew(HAL_CANHandle handle, int32_t apiId, uint8_t* data,
* Reads a CAN packet. The will continuously return the last packet received,
* without accounting for packet age.
*
* @param handle the CAN handle
* @param apiId the ID to read (0-1023)
* @param data the packet data (8 bytes)
* @param length the received length (0-8 bytes)
* @param receivedTimestamp the packet received timestamp (based off of
* CLOCK_MONOTONIC)
* @param[in] handle the CAN handle
* @param[in] apiId the ID to read (0-1023)
* @param[out] data the packet data (8 bytes)
* @param[out] length the received length (0-8 bytes)
* @param[out] receivedTimestamp the packet received timestamp (based off of
* CLOCK_MONOTONIC)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ReadCANPacketLatest(HAL_CANHandle handle, int32_t apiId, uint8_t* data,
int32_t* length, uint64_t* receivedTimestamp,
@@ -132,13 +139,14 @@ void HAL_ReadCANPacketLatest(HAL_CANHandle handle, int32_t apiId, uint8_t* data,
* packet is older then the requested timeout. Then it will return an error
* code.
*
* @param handle the CAN handle
* @param apiId the ID to read (0-1023)
* @param data the packet data (8 bytes)
* @param length the received length (0-8 bytes)
* @param receivedTimestamp the packet received timestamp (based off of
* CLOCK_MONOTONIC)
* @param timeoutMs the timeout time for the packet
* @param[in] handle the CAN handle
* @param[in] apiId the ID to read (0-1023)
* @param[out] data the packet data (8 bytes)
* @param[out] length the received length (0-8 bytes)
* @param[out] receivedTimestamp the packet received timestamp (based off of
* CLOCK_MONOTONIC)
* @param[out] timeoutMs the timeout time for the packet
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ReadCANPacketTimeout(HAL_CANHandle handle, int32_t apiId,
uint8_t* data, int32_t* length,

View File

@@ -34,9 +34,10 @@ extern "C" {
/**
* Initializes a counter.
*
* @param mode the counter mode
* @param index the compressor index (output)
* @return the created handle
* @param[in] mode the counter mode
* @param[in] index the compressor index (output)
* @param[out] status Error status variable. 0 on success.
* @return the created handle
*/
HAL_CounterHandle HAL_InitializeCounter(HAL_Counter_Mode mode, int32_t* index,
int32_t* status);
@@ -44,15 +45,17 @@ HAL_CounterHandle HAL_InitializeCounter(HAL_Counter_Mode mode, int32_t* index,
/**
* Frees a counter.
*
* @param counterHandle the counter handle
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_FreeCounter(HAL_CounterHandle counterHandle, int32_t* status);
/**
* Sets the average sample size of a counter.
*
* @param counterHandle the counter handle
* @param size the size of samples to average
* @param[in] counterHandle the counter handle
* @param[in] size the size of samples to average
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterAverageSize(HAL_CounterHandle counterHandle, int32_t size,
int32_t* status);
@@ -60,11 +63,13 @@ void HAL_SetCounterAverageSize(HAL_CounterHandle counterHandle, int32_t size,
/**
* Sets the source object that causes the counter to count up.
*
* @param counterHandle the counter handle
* @param digitalSourceHandle the digital source handle (either a
* HAL_AnalogTriggerHandle or a HAL_DigitalHandle)
* @param analogTriggerType the analog trigger type if the source is an analog
* trigger
* @param[in] counterHandle the counter handle
* @param[in] digitalSourceHandle the digital source handle (either a
* HAL_AnalogTriggerHandle or a
* HAL_DigitalHandle)
* @param[in] analogTriggerType the analog trigger type if the source is an
* analog trigger
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterUpSource(HAL_CounterHandle counterHandle,
HAL_Handle digitalSourceHandle,
@@ -76,9 +81,10 @@ void HAL_SetCounterUpSource(HAL_CounterHandle counterHandle,
*
* Note that both are allowed to be set true at the same time without issues.
*
* @param counterHandle the counter handle
* @param risingEdge true to trigger on rising
* @param fallingEdge true to trigger on falling
* @param[in] counterHandle the counter handle
* @param[in] risingEdge true to trigger on rising
* @param[in] fallingEdge true to trigger on falling
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterUpSourceEdge(HAL_CounterHandle counterHandle,
HAL_Bool risingEdge, HAL_Bool fallingEdge,
@@ -87,18 +93,21 @@ void HAL_SetCounterUpSourceEdge(HAL_CounterHandle counterHandle,
/**
* Disables the up counting source to the counter.
*
* @param counterHandle the counter handle
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ClearCounterUpSource(HAL_CounterHandle counterHandle, int32_t* status);
/**
* Sets the source object that causes the counter to count down.
*
* @param counterHandle the counter handle
* @param digitalSourceHandle the digital source handle (either a
* HAL_AnalogTriggerHandle or a HAL_DigitalHandle)
* @param analogTriggerType the analog trigger type if the source is an analog
* trigger
* @param[in] counterHandle the counter handle
* @param[in] digitalSourceHandle the digital source handle (either a
* HAL_AnalogTriggerHandle or a
* HAL_DigitalHandle)
* @param[in] analogTriggerType the analog trigger type if the source is an
* analog trigger
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterDownSource(HAL_CounterHandle counterHandle,
HAL_Handle digitalSourceHandle,
@@ -109,9 +118,10 @@ void HAL_SetCounterDownSource(HAL_CounterHandle counterHandle,
* Sets the down source to either detect rising edges or falling edges.
* Note that both are allowed to be set true at the same time without issues.
*
* @param counterHandle the counter handle
* @param risingEdge true to trigger on rising
* @param fallingEdge true to trigger on falling
* @param[in] counterHandle the counter handle
* @param[in] risingEdge true to trigger on rising
* @param[in] fallingEdge true to trigger on falling
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterDownSourceEdge(HAL_CounterHandle counterHandle,
HAL_Bool risingEdge, HAL_Bool fallingEdge,
@@ -120,7 +130,8 @@ void HAL_SetCounterDownSourceEdge(HAL_CounterHandle counterHandle,
/**
* Disables the down counting source to the counter.
*
* @param counterHandle the counter handle
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ClearCounterDownSource(HAL_CounterHandle counterHandle,
int32_t* status);
@@ -130,7 +141,8 @@ void HAL_ClearCounterDownSource(HAL_CounterHandle counterHandle,
*
* Up and down counts are sourced independently from two inputs.
*
* @param counterHandle the counter handle
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterUpDownMode(HAL_CounterHandle counterHandle, int32_t* status);
@@ -140,7 +152,8 @@ void HAL_SetCounterUpDownMode(HAL_CounterHandle counterHandle, int32_t* status);
* The direction is determined by the B input, with counting happening with the
* A input.
*
* @param counterHandle the counter handle
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterExternalDirectionMode(HAL_CounterHandle counterHandle,
int32_t* status);
@@ -151,8 +164,10 @@ void HAL_SetCounterExternalDirectionMode(HAL_CounterHandle counterHandle,
* The counter counts up based on the time the input is triggered. High or Low
* depends on the highSemiPeriod parameter.
*
* @param counterHandle the counter handle
* @param highSemiPeriod true for counting when the input is high, false for low
* @param[in] counterHandle the counter handle
* @param[in] highSemiPeriod true for counting when the input is high, false for
* low
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterSemiPeriodMode(HAL_CounterHandle counterHandle,
HAL_Bool highSemiPeriod, int32_t* status);
@@ -163,9 +178,10 @@ void HAL_SetCounterSemiPeriodMode(HAL_CounterHandle counterHandle,
*
* This mode is most useful for direction sensitive gear tooth sensors.
*
* @param counterHandle the counter handle
* @param threshold The pulse length beyond which the counter counts the
* opposite direction (seconds)
* @param[in] counterHandle the counter handle
* @param[in] threshold The pulse length beyond which the counter counts the
* opposite direction (seconds)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterPulseLengthMode(HAL_CounterHandle counterHandle,
double threshold, int32_t* status);
@@ -175,7 +191,8 @@ void HAL_SetCounterPulseLengthMode(HAL_CounterHandle counterHandle,
* timer to average when calculating the period. Perform averaging to account
* for mechanical imperfections or as oversampling to increase resolution.
*
* @param counterHandle the counter handle
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
* @return SamplesToAverage The number of samples being averaged (from 1 to 127)
*/
int32_t HAL_GetCounterSamplesToAverage(HAL_CounterHandle counterHandle,
@@ -186,8 +203,9 @@ int32_t HAL_GetCounterSamplesToAverage(HAL_CounterHandle counterHandle,
* timer to average when calculating the period. Perform averaging to account
* for mechanical imperfections or as oversampling to increase resolution.
*
* @param counterHandle the counter handle
* @param samplesToAverage The number of samples to average from 1 to 127
* @param[in] counterHandle the counter handle
* @param[in] samplesToAverage The number of samples to average from 1 to 127
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterSamplesToAverage(HAL_CounterHandle counterHandle,
int32_t samplesToAverage, int32_t* status);
@@ -198,7 +216,8 @@ void HAL_SetCounterSamplesToAverage(HAL_CounterHandle counterHandle,
* Sets the counter value to zero. This does not effect the running state of the
* counter, just sets the current value to zero.
*
* @param counterHandle the counter handle
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ResetCounter(HAL_CounterHandle counterHandle, int32_t* status);
@@ -208,8 +227,9 @@ void HAL_ResetCounter(HAL_CounterHandle counterHandle, int32_t* status);
* Reads 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.
*
* @param counterHandle the counter handle
* @return the current counter value
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
* @return the current counter value
*/
int32_t HAL_GetCounter(HAL_CounterHandle counterHandle, int32_t* status);
@@ -219,8 +239,9 @@ int32_t HAL_GetCounter(HAL_CounterHandle counterHandle, int32_t* status);
* Returns the time interval of the most recent count. This can be used for
* velocity calculations to determine shaft speed.
*
* @param counterHandle the counter handle
* @returns the period of the last two pulses in units of seconds
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
* @return the period of the last two pulses in units of seconds
*/
double HAL_GetCounterPeriod(HAL_CounterHandle counterHandle, int32_t* status);
@@ -231,9 +252,10 @@ double HAL_GetCounterPeriod(HAL_CounterHandle counterHandle, int32_t* status);
* used to determine the "stopped" state of the counter using the
* HAL_GetCounterStopped method.
*
* @param counterHandle the counter handle
* @param maxPeriod the maximum period where the counted device is
* considered moving in seconds
* @param[in] counterHandle the counter handle
* @param[in] maxPeriod the maximum period where the counted device is
* considered moving in seconds
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterMaxPeriod(HAL_CounterHandle counterHandle, double maxPeriod,
int32_t* status);
@@ -258,8 +280,9 @@ void HAL_SetCounterMaxPeriod(HAL_CounterHandle counterHandle, double maxPeriod,
* (since it is updated at the end of an average and there are no samples to
* average).
*
* @param counterHandle the counter handle
* @param enabled true to enable counter updating with no samples
* @param[in] counterHandle the counter handle
* @param[in] enabled true to enable counter updating with no samples
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterUpdateWhenEmpty(HAL_CounterHandle counterHandle,
HAL_Bool enabled, int32_t* status);
@@ -271,9 +294,10 @@ void HAL_SetCounterUpdateWhenEmpty(HAL_CounterHandle counterHandle,
* using the SetMaxPeriod method. If the clock exceeds the MaxPeriod, then the
* device (and counter) are assumed to be stopped and it returns true.
*
* @param counterHandle the counter handle
* @return true if the most recent counter period exceeds the
* MaxPeriod value set by SetMaxPeriod
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
* @return true if the most recent counter period exceeds the MaxPeriod value
* set by SetMaxPeriod
*/
HAL_Bool HAL_GetCounterStopped(HAL_CounterHandle counterHandle,
int32_t* status);
@@ -281,8 +305,9 @@ HAL_Bool HAL_GetCounterStopped(HAL_CounterHandle counterHandle,
/**
* Gets the last direction the counter value changed.
*
* @param counterHandle the counter handle
* @return the last direction the counter value changed
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
* @return the last direction the counter value changed
*/
HAL_Bool HAL_GetCounterDirection(HAL_CounterHandle counterHandle,
int32_t* status);
@@ -293,8 +318,9 @@ HAL_Bool HAL_GetCounterDirection(HAL_CounterHandle counterHandle,
* 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 counterHandle the counter handle
* @param reverseDirection true if the value counted should be negated.
* @param[in] counterHandle the counter handle
* @param[in] reverseDirection true if the value counted should be negated.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetCounterReverseDirection(HAL_CounterHandle counterHandle,
HAL_Bool reverseDirection, int32_t* status);

View File

@@ -21,11 +21,12 @@ extern "C" {
/**
* Creates a new instance of a digital port.
*
* @param portHandle the port handle to create from
* @param input true for input, false for output
* @param allocationLocation the location where the allocation is occuring
* (can be null)
* @return the created digital handle
* @param[in] portHandle the port handle to create from
* @param[in] input true for input, false for output
* @param[in] allocationLocation the location where the allocation is occuring
* (can be null)
* @param[out] status Error status variable. 0 on success.
* @return the created digital handle
*/
HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle portHandle,
HAL_Bool input,
@@ -36,14 +37,14 @@ HAL_DigitalHandle HAL_InitializeDIOPort(HAL_PortHandle portHandle,
* Checks if a DIO channel is valid.
*
* @param channel the channel number to check
* @return true if the channel is correct, otherwise false
* @return true if the channel is correct, otherwise false
*/
HAL_Bool HAL_CheckDIOChannel(int32_t channel);
/**
* Frees a DIO port.
*
* @param handle the DIO channel handle
* @param dioPortHandle the DIO channel handle
*/
void HAL_FreeDIOPort(HAL_DigitalHandle dioPortHandle);
@@ -58,6 +59,7 @@ void HAL_SetDIOSimDevice(HAL_DigitalHandle handle, HAL_SimDeviceHandle device);
/**
* Allocates a DO PWM Generator.
*
* @param[out] status Error status variable. 0 on success.
* @return the allocated digital PWM handle
*/
HAL_DigitalPWMHandle HAL_AllocateDigitalPWM(int32_t* status);
@@ -65,7 +67,8 @@ HAL_DigitalPWMHandle HAL_AllocateDigitalPWM(int32_t* status);
/**
* Frees the resource associated with a DO PWM generator.
*
* @param pwmGenerator the digital PWM handle
* @param[in] pwmGenerator the digital PWM handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_FreeDigitalPWM(HAL_DigitalPWMHandle pwmGenerator, int32_t* status);
@@ -76,15 +79,17 @@ void HAL_FreeDigitalPWM(HAL_DigitalPWMHandle pwmGenerator, int32_t* status);
*
* The frequency resolution is logarithmic.
*
* @param rate the frequency to output all digital output PWM signals
* @param[in] rate the frequency to output all digital output PWM signals
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetDigitalPWMRate(double rate, int32_t* status);
/**
* Configures the duty-cycle of the PWM generator.
*
* @param pwmGenerator the digital PWM handle
* @param dutyCycle the percent duty cycle to output [0..1]
* @param[in] pwmGenerator the digital PWM handle
* @param[in] dutyCycle the percent duty cycle to output [0..1]
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetDigitalPWMDutyCycle(HAL_DigitalPWMHandle pwmGenerator,
double dutyCycle, int32_t* status);
@@ -92,8 +97,9 @@ void HAL_SetDigitalPWMDutyCycle(HAL_DigitalPWMHandle pwmGenerator,
/**
* Configures which DO channel the PWM signal is output on.
*
* @param pwmGenerator the digital PWM handle
* @param channel the channel to output on
* @param[in] pwmGenerator the digital PWM handle
* @param[in] channel the channel to output on
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetDigitalPWMOutputChannel(HAL_DigitalPWMHandle pwmGenerator,
int32_t channel, int32_t* status);
@@ -101,9 +107,10 @@ void HAL_SetDigitalPWMOutputChannel(HAL_DigitalPWMHandle pwmGenerator,
/**
* Writes a digital value to a DIO channel.
*
* @param dioPortHandle the digital port handle
* @param value the state to set the digital channel (if it is
* configured as an output)
* @param[in] dioPortHandle the digital port handle
* @param[in] value the state to set the digital channel (if it is
* configured as an output)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetDIO(HAL_DigitalHandle dioPortHandle, HAL_Bool value,
int32_t* status);
@@ -111,8 +118,9 @@ void HAL_SetDIO(HAL_DigitalHandle dioPortHandle, HAL_Bool value,
/**
* Sets the direction of a DIO channel.
*
* @param dioPortHandle the digital port handle
* @param input true to set input, false for output
* @param[in] dioPortHandle the digital port handle
* @param[in] input true to set input, false for output
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetDIODirection(HAL_DigitalHandle dioPortHandle, HAL_Bool input,
int32_t* status);
@@ -120,16 +128,18 @@ void HAL_SetDIODirection(HAL_DigitalHandle dioPortHandle, HAL_Bool input,
/**
* Reads a digital value from a DIO channel.
*
* @param dioPortHandle the digital port handle
* @return the state of the specified channel
* @param[in] dioPortHandle the digital port handle
* @param[out] status Error status variable. 0 on success.
* @return the state of the specified channel
*/
HAL_Bool HAL_GetDIO(HAL_DigitalHandle dioPortHandle, int32_t* status);
/**
* Reads the direction of a DIO channel.
*
* @param dioPortHandle the digital port handle
* @return true for input, false for output
* @param[in] dioPortHandle the digital port handle
* @param[out] status Error status variable. 0 on success.
* @return true for input, false for output
*/
HAL_Bool HAL_GetDIODirection(HAL_DigitalHandle dioPortHandle, int32_t* status);
@@ -139,8 +149,9 @@ HAL_Bool HAL_GetDIODirection(HAL_DigitalHandle dioPortHandle, int32_t* status);
* Write a pulse to the specified digital output channel. There can only be a
* single pulse going at any time.
*
* @param dioPortHandle the digital port handle
* @param pulseLength the active length of the pulse (in seconds)
* @param[in] dioPortHandle the digital port handle
* @param[in] pulseLength the active length of the pulse (in seconds)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLength,
int32_t* status);
@@ -148,6 +159,8 @@ void HAL_Pulse(HAL_DigitalHandle dioPortHandle, double pulseLength,
/**
* Checks a DIO line to see if it is currently generating a pulse.
*
* @param[in] dioPortHandle the digital port handle
* @param[out] status Error status variable. 0 on success.
* @return true if a pulse is in progress, otherwise false
*/
HAL_Bool HAL_IsPulsing(HAL_DigitalHandle dioPortHandle, int32_t* status);
@@ -155,6 +168,7 @@ HAL_Bool HAL_IsPulsing(HAL_DigitalHandle dioPortHandle, int32_t* status);
/**
* Checks if any DIO line is currently generating a pulse.
*
* @param[out] status Error status variable. 0 on success.
* @return true if a pulse on some line is in progress
*/
HAL_Bool HAL_IsAnyPulsing(int32_t* status);
@@ -164,9 +178,11 @@ HAL_Bool HAL_IsAnyPulsing(int32_t* status);
*
* Set the filter index used to filter out short pulses.
*
* @param dioPortHandle the digital port handle
* @param filterIndex the filter index (Must be in the range 0 - 3, where 0
* means "none" and 1 - 3 means filter # filterIndex - 1)
* @param[in] dioPortHandle the digital port handle
* @param[in] filterIndex the filter index (Must be in the range 0 - 3, where
* 0 means "none" and 1 - 3 means filter # filterIndex
* - 1)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetFilterSelect(HAL_DigitalHandle dioPortHandle, int32_t filterIndex,
int32_t* status);
@@ -176,9 +192,10 @@ void HAL_SetFilterSelect(HAL_DigitalHandle dioPortHandle, int32_t filterIndex,
*
* Gets the filter index used to filter out short pulses.
*
* @param dioPortHandle the digital port handle
* @return filterIndex the filter index (Must be in the range 0 - 3,
* where 0 means "none" and 1 - 3 means filter # filterIndex - 1)
* @param[in] dioPortHandle the digital port handle
* @param[out] status Error status variable. 0 on success.
* @return filterIndex the filter index (Must be in the range 0 - 3, where 0
* means "none" and 1 - 3 means filter # filterIndex - 1)
*/
int32_t HAL_GetFilterSelect(HAL_DigitalHandle dioPortHandle, int32_t* status);
@@ -189,9 +206,10 @@ int32_t HAL_GetFilterSelect(HAL_DigitalHandle dioPortHandle, int32_t* status);
* filter index domains (MXP vs HDR), ignore that distinction for now since it
* compilicates the interface. That can be changed later.
*
* @param filterIndex the filter index, 0 - 2
* @param value the number of cycles that the signal must not transition
* to be counted as a transition.
* @param[in] filterIndex the filter index, 0 - 2
* @param[in] value the number of cycles that the signal must not
* transition to be counted as a transition.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetFilterPeriod(int32_t filterIndex, int64_t value, int32_t* status);
@@ -203,9 +221,8 @@ void HAL_SetFilterPeriod(int32_t filterIndex, int64_t value, int32_t* status);
* compilicates the interface. Set status to NiFpga_Status_SoftwareFault if the
* filter values miss-match.
*
* @param filterIndex the filter index, 0 - 2
* @param value the number of cycles that the signal must not transition
* to be counted as a transition.
* @param[in] filterIndex the filter index, 0 - 2
* @param[out] status Error status variable. 0 on success.
*/
int64_t HAL_GetFilterPeriod(int32_t filterIndex, int32_t* status);
#ifdef __cplusplus

View File

@@ -42,6 +42,7 @@ extern "C" {
/**
* Initializes an object for peforming DMA transfers.
*
* @param[out] status Error status variable. 0 on success.
* @return the created dma handle
*/
HAL_DMAHandle HAL_InitializeDMA(int32_t* status);
@@ -58,8 +59,9 @@ void HAL_FreeDMA(HAL_DMAHandle handle);
*
* This can only be called while DMA is running.
*
* @param handle the dma handle
* @param pause true to pause transfers, false to resume.
* @param[in] handle the dma handle
* @param[in] pause true to pause transfers, false to resume.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetDMAPause(HAL_DMAHandle handle, HAL_Bool pause, int32_t* status);
@@ -72,8 +74,9 @@ void HAL_SetDMAPause(HAL_DMAHandle handle, HAL_Bool pause, int32_t* status);
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param periodSeconds the period to trigger in seconds
* @param[in] handle the dma handle
* @param[in] periodSeconds the period to trigger in seconds
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetDMATimedTrigger(HAL_DMAHandle handle, double periodSeconds,
int32_t* status);
@@ -91,8 +94,9 @@ void HAL_SetDMATimedTrigger(HAL_DMAHandle handle, double periodSeconds,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param cycles the period to trigger in FPGA cycles
* @param[in] handle the dma handle
* @param[in] cycles the period to trigger in FPGA cycles
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetDMATimedTriggerCycles(HAL_DMAHandle handle, uint32_t cycles,
int32_t* status);
@@ -102,8 +106,9 @@ void HAL_SetDMATimedTriggerCycles(HAL_DMAHandle handle, uint32_t cycles,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param encoderHandle the encoder to add
* @param[in] handle the dma handle
* @param[in] encoderHandle the encoder to add
* @param[out] status Error status variable. 0 on success.
*/
void HAL_AddDMAEncoder(HAL_DMAHandle handle, HAL_EncoderHandle encoderHandle,
int32_t* status);
@@ -113,8 +118,9 @@ void HAL_AddDMAEncoder(HAL_DMAHandle handle, HAL_EncoderHandle encoderHandle,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param encoderHandle the encoder to add
* @param[in] handle the dma handle
* @param[in] encoderHandle the encoder to add
* @param[out] status Error status variable. 0 on success.
*/
void HAL_AddDMAEncoderPeriod(HAL_DMAHandle handle,
HAL_EncoderHandle encoderHandle, int32_t* status);
@@ -124,8 +130,9 @@ void HAL_AddDMAEncoderPeriod(HAL_DMAHandle handle,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param counterHandle the counter to add
* @param[in] handle the dma handle
* @param[in] counterHandle the counter to add
* @param[out] status Error status variable. 0 on success.
*/
void HAL_AddDMACounter(HAL_DMAHandle handle, HAL_CounterHandle counterHandle,
int32_t* status);
@@ -133,8 +140,9 @@ void HAL_AddDMACounter(HAL_DMAHandle handle, HAL_CounterHandle counterHandle,
/**
* Adds timer data for an counter to be collected by DMA.
*
* @param handle the dma handle
* @param counterHandle the counter to add
* @param[in] handle the dma handle
* @param[in] counterHandle the counter to add
* @param[out] status Error status variable. 0 on success.
*/
void HAL_AddDMACounterPeriod(HAL_DMAHandle handle,
HAL_CounterHandle counterHandle, int32_t* status);
@@ -144,8 +152,9 @@ void HAL_AddDMACounterPeriod(HAL_DMAHandle handle,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param digitalSourceHandle the digital source to add
* @param[in] handle the dma handle
* @param[in] digitalSourceHandle the digital source to add
* @param[out] status Error status variable. 0 on success.
*/
void HAL_AddDMADigitalSource(HAL_DMAHandle handle,
HAL_Handle digitalSourceHandle, int32_t* status);
@@ -155,8 +164,9 @@ void HAL_AddDMADigitalSource(HAL_DMAHandle handle,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param aInHandle the analog input to add
* @param[in] handle the dma handle
* @param[in] aInHandle the analog input to add
* @param[out] status Error status variable. 0 on success.
*/
void HAL_AddDMAAnalogInput(HAL_DMAHandle handle,
HAL_AnalogInputHandle aInHandle, int32_t* status);
@@ -166,8 +176,9 @@ void HAL_AddDMAAnalogInput(HAL_DMAHandle handle,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param aInHandle the analog input to add
* @param[in] handle the dma handle
* @param[in] aInHandle the analog input to add
* @param[out] status Error status variable. 0 on success.
*/
void HAL_AddDMAAveragedAnalogInput(HAL_DMAHandle handle,
HAL_AnalogInputHandle aInHandle,
@@ -178,8 +189,9 @@ void HAL_AddDMAAveragedAnalogInput(HAL_DMAHandle handle,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param aInHandle the analog input to add
* @param[in] handle the dma handle
* @param[in] aInHandle the analog input to add
* @param[out] status Error status variable. 0 on success.
*/
void HAL_AddDMAAnalogAccumulator(HAL_DMAHandle handle,
HAL_AnalogInputHandle aInHandle,
@@ -190,8 +202,9 @@ void HAL_AddDMAAnalogAccumulator(HAL_DMAHandle handle,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param dutyCycleHandle the duty cycle input to add
* @param[in] handle the dma handle
* @param[in] dutyCycleHandle the duty cycle input to add
* @param[out] status Error status variable. 0 on success.
*/
void HAL_AddDMADutyCycle(HAL_DMAHandle handle,
HAL_DutyCycleHandle dutyCycleHandle, int32_t* status);
@@ -205,13 +218,15 @@ void HAL_AddDMADutyCycle(HAL_DMAHandle handle,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param digitalSourceHandle the digital source handle (either a
* HAL_AnalogTriggerHandle or a HAL_DigitalHandle)
* @param analogTriggerType the analog trigger type if the source is an analog
* trigger
* @param risingEdge true to trigger on rising
* @param fallingEdge true to trigger on falling
* @param[in] handle the dma handle
* @param[in] digitalSourceHandle the digital source handle (either a
* HAL_AnalogTriggerHandle or a
* HAL_DigitalHandle)
* @param[in] analogTriggerType the analog trigger type if the source is an
* analog trigger
* @param[in] rising true to trigger on rising edge
* @param[in] falling true to trigger on falling edge
* @param[out] status Error status variable. 0 on success.
* @return the index of the trigger
*/
int32_t HAL_SetDMAExternalTrigger(HAL_DMAHandle handle,
@@ -225,7 +240,8 @@ int32_t HAL_SetDMAExternalTrigger(HAL_DMAHandle handle,
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param[in] handle the dma handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ClearDMASensors(HAL_DMAHandle handle, int32_t* status);
@@ -234,22 +250,25 @@ void HAL_ClearDMASensors(HAL_DMAHandle handle, int32_t* status);
*
* This can only be called if DMA is not started.
*
* @param handle the dma handle
* @param[in] handle the dma handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ClearDMAExternalTriggers(HAL_DMAHandle handle, int32_t* status);
/**
* Starts DMA Collection.
*
* @param handle the dma handle
* @param queueDepth the number of objects to be able to queue
* @param[in] handle the dma handle
* @param[in] queueDepth the number of objects to be able to queue
* @param[out] status Error status variable. 0 on success.
*/
void HAL_StartDMA(HAL_DMAHandle handle, int32_t queueDepth, int32_t* status);
/**
* Stops DMA Collection.
*
* @param handle the dma handle
* @param[in] handle the dma handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_StopDMA(HAL_DMAHandle handle, int32_t* status);
@@ -268,7 +287,12 @@ void* HAL_GetDMADirectPointer(HAL_DMAHandle handle);
*
* See HAL_ReadDMA for full documentation.
*
* @param handle the dma handle
* @param[in] dmaPointer direct DMA pointer
* @param[in] dmaSample the sample object to place data into
* @param[in] timeoutSeconds the time to wait for data to be queued before
* timing out
* @param[in] remainingOut the number of samples remaining in the queue
* @param[out] status Error status variable. 0 on success.
*/
enum HAL_DMAReadStatus HAL_ReadDMADirect(void* dmaPointer,
HAL_DMASample* dmaSample,
@@ -280,11 +304,12 @@ enum HAL_DMAReadStatus HAL_ReadDMADirect(void* dmaPointer,
* Reads a DMA sample from the queue.
*
*
* @param handle the dma handle
* @param dmaSample the sample object to place data into
* @param timeoutSeconds the time to wait for data to be queued before timing
* out
* @param remainingOut the number of samples remaining in the queue
* @param[in] handle the dma handle
* @param[in] dmaSample the sample object to place data into
* @param[in] timeoutSeconds the time to wait for data to be queued before
* timing out
* @param[in] remainingOut the number of samples remaining in the queue
* @param[out] status Error status variable. 0 on success.
* @return the succes result of the sample read
*/
enum HAL_DMAReadStatus HAL_ReadDMA(HAL_DMAHandle handle,
@@ -298,7 +323,8 @@ enum HAL_DMAReadStatus HAL_ReadDMA(HAL_DMAHandle handle,
* Returns the timestamp of the sample.
* This is in the same time domain as HAL_GetFPGATime().
*
* @param dmaSample the sample to read from
* @param[in] dmaSample the sample to read from
* @param[out] status Error status variable. 0 on success.
* @return timestamp in microseconds since FPGA Initialization
*/
uint64_t HAL_GetDMASampleTime(const HAL_DMASample* dmaSample, int32_t* status);
@@ -309,8 +335,9 @@ uint64_t HAL_GetDMASampleTime(const HAL_DMASample* dmaSample, int32_t* status);
* This can be scaled with DistancePerPulse and DecodingScaleFactor to match the
* result of GetDistance()
*
* @param dmaSample the sample to read from
* @param encoderHandle the encoder handle
* @param[in] dmaSample the sample to read from
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return raw encoder ticks
*/
int32_t HAL_GetDMASampleEncoderRaw(const HAL_DMASample* dmaSample,
@@ -320,8 +347,9 @@ int32_t HAL_GetDMASampleEncoderRaw(const HAL_DMASample* dmaSample,
/**
* Returns the distance data for an counter from the sample.
*
* @param dmaSample the sample to read from
* @param counterHandle the counter handle
* @param[in] dmaSample the sample to read from
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
* @return counter ticks
*/
int32_t HAL_GetDMASampleCounter(const HAL_DMASample* dmaSample,
@@ -334,8 +362,9 @@ int32_t HAL_GetDMASampleCounter(const HAL_DMASample* dmaSample,
* This can be scaled with DistancePerPulse and DecodingScaleFactor to match the
* result of GetRate()
*
* @param dmaSample the sample to read from
* @param encoderHandle the encoder handle
* @param[in] dmaSample the sample to read from
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return raw encoder period
*/
int32_t HAL_GetDMASampleEncoderPeriodRaw(const HAL_DMASample* dmaSample,
@@ -345,8 +374,9 @@ int32_t HAL_GetDMASampleEncoderPeriodRaw(const HAL_DMASample* dmaSample,
/**
* Returns the period data for an counter from the sample.
*
* @param dmaSample the sample to read from
* @param counterHandle the counter handle
* @param[in] dmaSample the sample to read from
* @param[in] counterHandle the counter handle
* @param[out] status Error status variable. 0 on success.
* @return counter period
*/
int32_t HAL_GetDMASampleCounterPeriod(const HAL_DMASample* dmaSample,
@@ -356,8 +386,9 @@ int32_t HAL_GetDMASampleCounterPeriod(const HAL_DMASample* dmaSample,
/**
* Returns the state of a digital source from the sample.
*
* @param dmaSample the sample to read from
* @param dSourceHandle the digital source handle
* @param[in] dmaSample the sample to read from
* @param[in] dSourceHandle the digital source handle
* @param[out] status Error status variable. 0 on success.
* @return digital source state
*/
HAL_Bool HAL_GetDMASampleDigitalSource(const HAL_DMASample* dmaSample,
@@ -369,8 +400,9 @@ HAL_Bool HAL_GetDMASampleDigitalSource(const HAL_DMASample* dmaSample,
*
* This can be scaled with HAL_GetAnalogValueToVolts to match GetVoltage().
*
* @param dmaSample the sample to read from
* @param aInHandle the analog input handle
* @param[in] dmaSample the sample to read from
* @param[in] aInHandle the analog input handle
* @param[out] status Error status variable. 0 on success.
* @return raw analog data
*/
int32_t HAL_GetDMASampleAnalogInputRaw(const HAL_DMASample* dmaSample,
@@ -383,8 +415,9 @@ int32_t HAL_GetDMASampleAnalogInputRaw(const HAL_DMASample* dmaSample,
* This can be scaled with HAL_GetAnalogValueToVolts to match
* GetAveragedVoltage().
*
* @param dmaSample the sample to read from
* @param aInHandle the analog input handle
* @param[in] dmaSample the sample to read from
* @param[in] aInHandle the analog input handle
* @param[out] status Error status variable. 0 on success.
* @return raw averaged analog data
*/
int32_t HAL_GetDMASampleAveragedAnalogInputRaw(const HAL_DMASample* dmaSample,
@@ -394,10 +427,11 @@ int32_t HAL_GetDMASampleAveragedAnalogInputRaw(const HAL_DMASample* dmaSample,
/**
* Returns the analog accumulator data for an analog input from the sample.
*
* @param dmaSample the sample to read from
* @param aInHandle the analog input handle
* @param count the accumulator count
* @param value the accumulator value
* @param[in] dmaSample the sample to read from
* @param[in] aInHandle the analog input handle
* @param[in] count the accumulator count
* @param[in] value the accumulator value
* @param[out] status Error status variable. 0 on success.
*/
void HAL_GetDMASampleAnalogAccumulator(const HAL_DMASample* dmaSample,
HAL_AnalogInputHandle aInHandle,
@@ -409,8 +443,9 @@ void HAL_GetDMASampleAnalogAccumulator(const HAL_DMASample* dmaSample,
*
* Use HAL_GetDutyCycleOutputScaleFactor to scale this to a percentage.
*
* @param dmaSample the sample to read from
* @param dutyCycleHandle the duty cycle handle
* @param[in] dmaSample the sample to read from
* @param[in] dutyCycleHandle the duty cycle handle
* @param[out] status Error status variable. 0 on success.
* @return raw duty cycle input data
*/
int32_t HAL_GetDMASampleDutyCycleOutputRaw(const HAL_DMASample* dmaSample,

View File

@@ -27,7 +27,7 @@ extern "C" {
* @param isLVCode true for a LV error code, false for a standard error code
* @param details the details of the error
* @param location the file location of the errror
* @param callstack the callstack of the error
* @param callStack the callstack of the error
* @param printMsg true to print the error message to stdout as well as to the
* DS
*/
@@ -47,15 +47,15 @@ int32_t HAL_SendConsoleLine(const char* line);
* The control work contains the robot state.
*
* @param controlWord the control word (out)
* @return the error code, or 0 for success
* @return the error code, or 0 for success
*/
int32_t HAL_GetControlWord(HAL_ControlWord* controlWord);
/**
* Gets the current alliance station ID.
*
* @param status the error code, or 0 for success
* @return the alliance station ID
* @param[out] status the error code, or 0 for success
* @return the alliance station ID
*/
HAL_AllianceStationID HAL_GetAllianceStation(int32_t* status);
@@ -64,7 +64,7 @@ HAL_AllianceStationID HAL_GetAllianceStation(int32_t* status);
*
* @param joystickNum the joystick number
* @param axes the axes values (output)
* @return the error code, or 0 for success
* @return the error code, or 0 for success
*/
int32_t HAL_GetJoystickAxes(int32_t joystickNum, HAL_JoystickAxes* axes);
@@ -73,7 +73,7 @@ int32_t HAL_GetJoystickAxes(int32_t joystickNum, HAL_JoystickAxes* axes);
*
* @param joystickNum the joystick number
* @param povs the POV values (output)
* @return the error code, or 0 for success
* @return the error code, or 0 for success
*/
int32_t HAL_GetJoystickPOVs(int32_t joystickNum, HAL_JoystickPOVs* povs);
@@ -82,7 +82,7 @@ int32_t HAL_GetJoystickPOVs(int32_t joystickNum, HAL_JoystickPOVs* povs);
*
* @param joystickNum the joystick number
* @param buttons the button values (output)
* @return the error code, or 0 for success
* @return the error code, or 0 for success
*/
int32_t HAL_GetJoystickButtons(int32_t joystickNum,
HAL_JoystickButtons* buttons);
@@ -90,14 +90,15 @@ int32_t HAL_GetJoystickButtons(int32_t joystickNum,
/**
* Retrieves the Joystick Descriptor for particular slot.
*
* @param desc [out] descriptor (data transfer object) to fill in. desc is
* filled in regardless of success. In other words, if descriptor is not
* available, desc is filled in with default values matching the init-values in
* Java and C++ Driverstation for when caller requests a too-large joystick
* index.
*
* @param joystickNum the joystick number
* @param[out] desc descriptor (data transfer object) to fill in. desc is
* filled in regardless of success. In other words, if
* descriptor is not available, desc is filled in with
* default values matching the init-values in Java and C++
* Driver Station for when caller requests a too-large
* joystick index.
* @return error code reported from Network Comm back-end. Zero is good,
* nonzero is bad.
* nonzero is bad.
*/
int32_t HAL_GetJoystickDescriptor(int32_t joystickNum,
HAL_JoystickDescriptor* desc);
@@ -106,7 +107,7 @@ int32_t HAL_GetJoystickDescriptor(int32_t joystickNum,
* Gets is a specific joystick is considered to be an XBox controller.
*
* @param joystickNum the joystick number
* @return true if xbox, false otherwise
* @return true if xbox, false otherwise
*/
HAL_Bool HAL_GetJoystickIsXbox(int32_t joystickNum);
@@ -117,7 +118,7 @@ HAL_Bool HAL_GetJoystickIsXbox(int32_t joystickNum);
* the joystick uses.
*
* @param joystickNum the joystick number
* @return the enumerated joystick type
* @return the enumerated joystick type
*/
int32_t HAL_GetJoystickType(int32_t joystickNum);
@@ -129,7 +130,7 @@ int32_t HAL_GetJoystickType(int32_t joystickNum);
* Will be null terminated.
*
* @param joystickNum the joystick number
* @return the joystick name
* @return the joystick name
*/
char* HAL_GetJoystickName(int32_t joystickNum);
@@ -148,18 +149,18 @@ void HAL_FreeJoystickName(char* name);
*
* @param joystickNum the joystick number
* @param axis the axis number
* @return the enumerated axis type
* @return the enumerated axis type
*/
int32_t HAL_GetJoystickAxisType(int32_t joystickNum, int32_t axis);
/**
* Set joystick outputs.
*
* @param joystickNum the joystick numer
* @param joystickNum the joystick number
* @param outputs bitmask of outputs, 1 for on 0 for off
* @param leftRumble the left rumble value (0-FFFF)
* @param rightRumble the right rumble value (0-FFFF)
* @return the error code, or 0 for success
* @return the error code, or 0 for success
*/
int32_t HAL_SetJoystickOutputs(int32_t joystickNum, int64_t outputs,
int32_t leftRumble, int32_t rightRumble);
@@ -177,7 +178,7 @@ int32_t HAL_SetJoystickOutputs(int32_t joystickNum, int64_t outputs,
* The Practice Match function of the DS approximates the behavior seen on
* the field.
*
* @param status the error code, or 0 for success
* @param[out] status the error code, or 0 for success
* @return time remaining in current match period (auto or teleop)
*/
double HAL_GetMatchTime(int32_t* status);
@@ -185,8 +186,8 @@ double HAL_GetMatchTime(int32_t* status);
/**
* Gets info about a specific match.
*
* @param info the match info (output)
* @return the error code, or 0 for success
* @param[in] info the match info (output)
* @return the error code, or 0 for success
*/
int32_t HAL_GetMatchInfo(HAL_MatchInfo* info);
@@ -217,8 +218,8 @@ void HAL_WaitForDSData(void);
* forever. Otherwise, it will wait until either a new packet, or the timeout
* time has passed.
*
* @param timeout timeout in seconds
* @return true for new data, false for timeout
* @param[in] timeout timeout in seconds
* @return true for new data, false for timeout
*/
HAL_Bool HAL_WaitForDSDataTimeout(double timeout);
@@ -240,7 +241,7 @@ void HAL_ObserveUserProgramStarting(void);
* Sets the disabled flag in the DS.
*
* This is used for the DS to ensure the robot is properly responding to its
* state request. Ensure this get called about every 50ms, or the robot will be
* state request. Ensure this gets called about every 50ms, or the robot will be
* disabled by the DS.
*/
void HAL_ObserveUserProgramDisabled(void);
@@ -249,7 +250,7 @@ void HAL_ObserveUserProgramDisabled(void);
* Sets the autonomous enabled flag in the DS.
*
* This is used for the DS to ensure the robot is properly responding to its
* state request. Ensure this get called about every 50ms, or the robot will be
* state request. Ensure this gets called about every 50ms, or the robot will be
* disabled by the DS.
*/
void HAL_ObserveUserProgramAutonomous(void);
@@ -258,7 +259,7 @@ void HAL_ObserveUserProgramAutonomous(void);
* Sets the teleoperated enabled flag in the DS.
*
* This is used for the DS to ensure the robot is properly responding to its
* state request. Ensure this get called about every 50ms, or the robot will be
* state request. Ensure this gets called about every 50ms, or the robot will be
* disabled by the DS.
*/
void HAL_ObserveUserProgramTeleop(void);
@@ -267,7 +268,7 @@ void HAL_ObserveUserProgramTeleop(void);
* Sets the test mode flag in the DS.
*
* This is used for the DS to ensure the robot is properly responding to its
* state request. Ensure this get called about every 50ms, or the robot will be
* state request. Ensure this gets called about every 50ms, or the robot will be
* disabled by the DS.
*/
void HAL_ObserveUserProgramTest(void);

View File

@@ -20,10 +20,12 @@ extern "C" {
/**
* Initialize a DutyCycle input.
*
* @param digitalSourceHandle the digital source to use (either a
* HAL_DigitalHandle or a HAL_AnalogTriggerHandle)
* @param triggerType the analog trigger type of the source if it is
* an analog trigger
* @param[in] digitalSourceHandle the digital source to use (either a
* HAL_DigitalHandle or a
* HAL_AnalogTriggerHandle)
* @param[in] triggerType the analog trigger type of the source if it is
* an analog trigger
* @param[out] status Error status variable. 0 on success.
* @return thre created duty cycle handle
*/
HAL_DutyCycleHandle HAL_InitializeDutyCycle(HAL_Handle digitalSourceHandle,
@@ -49,7 +51,8 @@ void HAL_SetDutyCycleSimDevice(HAL_DutyCycleHandle handle,
/**
* Get the frequency of the duty cycle signal.
*
* @param dutyCycleHandle the duty cycle handle
* @param[in] dutyCycleHandle the duty cycle handle
* @param[out] status Error status variable. 0 on success.
* @return frequency in Hertz
*/
int32_t HAL_GetDutyCycleFrequency(HAL_DutyCycleHandle dutyCycleHandle,
@@ -60,7 +63,8 @@ int32_t HAL_GetDutyCycleFrequency(HAL_DutyCycleHandle dutyCycleHandle,
*
* <p> 0 means always low, 1 means always high.
*
* @param dutyCycleHandle the duty cycle handle
* @param[in] dutyCycleHandle the duty cycle handle
* @param[out] status Error status variable. 0 on success.
* @return output ratio between 0 and 1
*/
double HAL_GetDutyCycleOutput(HAL_DutyCycleHandle dutyCycleHandle,
@@ -72,7 +76,8 @@ double HAL_GetDutyCycleOutput(HAL_DutyCycleHandle dutyCycleHandle,
* <p> 0 means always low, an output equal to
* GetOutputScaleFactor() means always high.
*
* @param dutyCycleHandle the duty cycle handle
* @param[in] dutyCycleHandle the duty cycle handle
* @param[out] status Error status variable. 0 on success.
* @return output ratio in raw units
*/
int32_t HAL_GetDutyCycleOutputRaw(HAL_DutyCycleHandle dutyCycleHandle,
@@ -85,7 +90,8 @@ int32_t HAL_GetDutyCycleOutputRaw(HAL_DutyCycleHandle dutyCycleHandle,
* down to 0. Divide the result of getOutputRaw by this in order to get the
* percentage between 0 and 1.
*
* @param dutyCycleHandle the duty cycle handle
* @param[in] dutyCycleHandle the duty cycle handle
* @param[out] status Error status variable. 0 on success.
* @return the output scale factor
*/
int32_t HAL_GetDutyCycleOutputScaleFactor(HAL_DutyCycleHandle dutyCycleHandle,
@@ -94,7 +100,8 @@ int32_t HAL_GetDutyCycleOutputScaleFactor(HAL_DutyCycleHandle dutyCycleHandle,
/**
* Get the FPGA index for the DutyCycle.
*
* @param dutyCycleHandle the duty cycle handle
* @param[in] dutyCycleHandle the duty cycle handle
* @param[out] status Error status variable. 0 on success.
* @return the FPGA index
*/
int32_t HAL_GetDutyCycleFPGAIndex(HAL_DutyCycleHandle dutyCycleHandle,

View File

@@ -43,18 +43,19 @@ extern "C" {
/**
* Initializes an encoder.
*
* @param digitalSourceHandleA the A source (either a HAL_DigitalHandle or a
* HAL_AnalogTriggerHandle)
* @param analogTriggerTypeA the analog trigger type of the A source if it is
* an analog trigger
* @param digitalSourceHandleB the B source (either a HAL_DigitalHandle or a
* HAL_AnalogTriggerHandle)
* @param analogTriggerTypeB the analog trigger type of the B source if it is
* an analog trigger
* @param reverseDirection true to reverse the counting direction from
* standard, otherwise false
* @param encodingType the encoding type
@return the created encoder handle
* @param[in] digitalSourceHandleA the A source (either a HAL_DigitalHandle or a
* HAL_AnalogTriggerHandle)
* @param[in] analogTriggerTypeA the analog trigger type of the A source if it
* is an analog trigger
* @param[in] digitalSourceHandleB the B source (either a HAL_DigitalHandle or a
* HAL_AnalogTriggerHandle)
* @param[in] analogTriggerTypeB the analog trigger type of the B source if it
* is an analog trigger
* @param[in] reverseDirection true to reverse the counting direction from
* standard, otherwise false
* @param[in] encodingType the encoding type
* @param[out] status Error status variable. 0 on success.
* @return the created encoder handle
*/
HAL_EncoderHandle HAL_InitializeEncoder(
HAL_Handle digitalSourceHandleA, HAL_AnalogTriggerType analogTriggerTypeA,
@@ -65,7 +66,8 @@ HAL_EncoderHandle HAL_InitializeEncoder(
/**
* Frees an encoder.
*
* @param encoderHandle the encoder handle
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_FreeEncoder(HAL_EncoderHandle encoderHandle, int32_t* status);
@@ -83,7 +85,8 @@ void HAL_SetEncoderSimDevice(HAL_EncoderHandle handle,
*
* This is scaled by the value passed duing initialization to encodingType.
*
* @param encoderHandle the encoder handle
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the current scaled count
*/
int32_t HAL_GetEncoder(HAL_EncoderHandle encoderHandle, int32_t* status);
@@ -93,8 +96,9 @@ int32_t HAL_GetEncoder(HAL_EncoderHandle encoderHandle, int32_t* status);
*
* This is not scaled by any values.
*
* @param encoderHandle the encoder handle
* @return the raw encoder count
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the raw encoder count
*/
int32_t HAL_GetEncoderRaw(HAL_EncoderHandle encoderHandle, int32_t* status);
@@ -103,8 +107,9 @@ int32_t HAL_GetEncoderRaw(HAL_EncoderHandle encoderHandle, int32_t* status);
*
* This is set by the value passed during initialization to encodingType.
*
* @param encoderHandle the encoder handle
* @return the encoder scale value
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the encoder scale value
*/
int32_t HAL_GetEncoderEncodingScale(HAL_EncoderHandle encoderHandle,
int32_t* status);
@@ -115,8 +120,8 @@ int32_t HAL_GetEncoderEncodingScale(HAL_EncoderHandle encoderHandle,
* 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.
*
* @param encoderHandle the encoder handle
* @return the current encoder value
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ResetEncoder(HAL_EncoderHandle encoderHandle, int32_t* status);
@@ -126,8 +131,9 @@ void HAL_ResetEncoder(HAL_EncoderHandle encoderHandle, int32_t* status);
* Returns the time interval of the most recent count. This can be used for
* velocity calculations to determine shaft speed.
*
* @param encoderHandle the encoder handle
* @returns the period of the last two pulses in units of seconds
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @returns the period of the last two pulses in units of seconds
*/
double HAL_GetEncoderPeriod(HAL_EncoderHandle encoderHandle, int32_t* status);
@@ -138,9 +144,10 @@ double HAL_GetEncoderPeriod(HAL_EncoderHandle encoderHandle, int32_t* status);
* used to determine the "stopped" state of the encoder using the
* HAL_GetEncoderStopped method.
*
* @param encoderHandle the encoder handle
* @param maxPeriod the maximum period where the counted device is
* considered moving in seconds
* @param[in] encoderHandle the encoder handle
* @param[in] maxPeriod the maximum period where the counted device is
* considered moving in seconds
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetEncoderMaxPeriod(HAL_EncoderHandle encoderHandle, double maxPeriod,
int32_t* status);
@@ -152,9 +159,10 @@ void HAL_SetEncoderMaxPeriod(HAL_EncoderHandle encoderHandle, double maxPeriod,
* using the SetMaxPeriod method. If the clock exceeds the MaxPeriod, then the
* device (and encoder) are assumed to be stopped and it returns true.
*
* @param encoderHandle the encoder handle
* @return true if the most recent encoder period exceeds the
* MaxPeriod value set by SetMaxPeriod
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return true if the most recent encoder period exceeds the MaxPeriod value
* set by SetMaxPeriod
*/
HAL_Bool HAL_GetEncoderStopped(HAL_EncoderHandle encoderHandle,
int32_t* status);
@@ -162,8 +170,9 @@ HAL_Bool HAL_GetEncoderStopped(HAL_EncoderHandle encoderHandle,
/**
* Gets the last direction the encoder value changed.
*
* @param encoderHandle the encoder handle
* @return the last direction the encoder value changed
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the last direction the encoder value changed
*/
HAL_Bool HAL_GetEncoderDirection(HAL_EncoderHandle encoderHandle,
int32_t* status);
@@ -174,9 +183,10 @@ HAL_Bool HAL_GetEncoderDirection(HAL_EncoderHandle encoderHandle,
* This is the encoder count scaled by the distance per pulse set for the
* encoder.
*
* @param encoderHandle the encoder handle
* @return the encoder distance (units are determined by the units
* passed to HAL_SetEncoderDistancePerPulse)
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the encoder distance (units are determined by the units
* passed to HAL_SetEncoderDistancePerPulse)
*/
double HAL_GetEncoderDistance(HAL_EncoderHandle encoderHandle, int32_t* status);
@@ -186,9 +196,10 @@ double HAL_GetEncoderDistance(HAL_EncoderHandle encoderHandle, int32_t* status);
* This is the encoder period scaled by the distance per pulse set for the
* encoder.
*
* @param encoderHandle the encoder handle
* @return the encoder rate (units are determined by the units
* passed to HAL_SetEncoderDistancePerPulse, time value is seconds)
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the encoder rate (units are determined by the units passed to
* HAL_SetEncoderDistancePerPulse, time value is seconds)
*/
double HAL_GetEncoderRate(HAL_EncoderHandle encoderHandle, int32_t* status);
@@ -198,10 +209,12 @@ double HAL_GetEncoderRate(HAL_EncoderHandle encoderHandle, int32_t* status);
* Units need to match what is set by HAL_SetEncoderDistancePerPulse, with time
* as seconds.
*
* @param encoderHandle the encoder handle
* @param minRate the minimum rate to be considered moving (units are
* determined by the units passed to HAL_SetEncoderDistancePerPulse, time value
* is seconds)
* @param[in] encoderHandle the encoder handle
* @param[in] minRate the minimum rate to be considered moving (units are
* determined by the units passed to
* HAL_SetEncoderDistancePerPulse, time value is
* seconds)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetEncoderMinRate(HAL_EncoderHandle encoderHandle, double minRate,
int32_t* status);
@@ -210,9 +223,10 @@ void HAL_SetEncoderMinRate(HAL_EncoderHandle encoderHandle, double minRate,
* Sets the distance traveled per encoder pulse. This is used as a scaling
* factor for the rate and distance calls.
*
* @param encoderHandle the encoder handle
* @param distancePerPulse the distance traveled per encoder pulse (units user
* defined)
* @param[in] encoderHandle the encoder handle
* @param[in] distancePerPulse the distance traveled per encoder pulse (units
* user defined)
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetEncoderDistancePerPulse(HAL_EncoderHandle encoderHandle,
double distancePerPulse, int32_t* status);
@@ -222,8 +236,9 @@ void HAL_SetEncoderDistancePerPulse(HAL_EncoderHandle encoderHandle,
*
* Note that this is not a toggle. It is an absolute set.
*
* @param encoderHandle the encoder handle
* @param reverseDirection true to reverse the direction, false to not.
* @param[in] encoderHandle the encoder handle
* @param[in] reverseDirection true to reverse the direction, false to not.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetEncoderReverseDirection(HAL_EncoderHandle encoderHandle,
HAL_Bool reverseDirection, int32_t* status);
@@ -231,8 +246,9 @@ void HAL_SetEncoderReverseDirection(HAL_EncoderHandle encoderHandle,
/**
* Sets the number of encoder samples to average when calculating encoder rate.
*
* @param encoderHandle the encoder handle
* @param samplesToAverage the number of samples to average
* @param[in] encoderHandle the encoder handle
* @param[in] samplesToAverage the number of samples to average
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetEncoderSamplesToAverage(HAL_EncoderHandle encoderHandle,
int32_t samplesToAverage, int32_t* status);
@@ -240,8 +256,9 @@ void HAL_SetEncoderSamplesToAverage(HAL_EncoderHandle encoderHandle,
/**
* Gets the current samples to average value.
*
* @param encoderHandle the encoder handle
* @return the current samples to average value
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the current samples to average value
*/
int32_t HAL_GetEncoderSamplesToAverage(HAL_EncoderHandle encoderHandle,
int32_t* status);
@@ -252,12 +269,14 @@ int32_t HAL_GetEncoderSamplesToAverage(HAL_EncoderHandle encoderHandle,
* The index pulse can be used to cause an encoder to reset based on an external
* input.
*
* @param encoderHandle the encoder handle
* @param digitalSourceHandle the index source handle (either a
* HAL_AnalogTriggerHandle or a HAL_DigitalHandle)
* @param analogTriggerType the analog trigger type if the source is an analog
* trigger
* @param type the index triggering type
* @param[in] encoderHandle the encoder handle
* @param[in] digitalSourceHandle the index source handle (either a
* HAL_AnalogTriggerHandle or a
* HAL_DigitalHandle)
* @param[in] analogTriggerType the analog trigger type if the source is an
* analog trigger
* @param[in] type the index triggering type
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetEncoderIndexSource(HAL_EncoderHandle encoderHandle,
HAL_Handle digitalSourceHandle,
@@ -267,8 +286,9 @@ void HAL_SetEncoderIndexSource(HAL_EncoderHandle encoderHandle,
/**
* Gets the FPGA index of the encoder.
*
* @param encoderHandle the encoder handle
* @return the FPGA index of the encoder
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the FPGA index of the encoder
*/
int32_t HAL_GetEncoderFPGAIndex(HAL_EncoderHandle encoderHandle,
int32_t* status);
@@ -278,8 +298,9 @@ int32_t HAL_GetEncoderFPGAIndex(HAL_EncoderHandle encoderHandle,
*
* This is used to perform the scaling from raw to type scaled values.
*
* @param encoderHandle the encoder handle
* @return the scale value for the encoder
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the scale value for the encoder
*/
double HAL_GetEncoderDecodingScaleFactor(HAL_EncoderHandle encoderHandle,
int32_t* status);
@@ -287,8 +308,9 @@ double HAL_GetEncoderDecodingScaleFactor(HAL_EncoderHandle encoderHandle,
/**
* Gets the user set distance per pulse of the encoder.
*
* @param encoderHandle the encoder handle
* @return the set distance per pulse
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the set distance per pulse
*/
double HAL_GetEncoderDistancePerPulse(HAL_EncoderHandle encoderHandle,
int32_t* status);
@@ -296,8 +318,9 @@ double HAL_GetEncoderDistancePerPulse(HAL_EncoderHandle encoderHandle,
/**
* Gets the encoding type of the encoder.
*
* @param encoderHandle the encoder handle
* @return the encoding type
* @param[in] encoderHandle the encoder handle
* @param[out] status Error status variable. 0 on success.
* @return the encoding type
*/
HAL_EncoderEncodingType HAL_GetEncoderEncodingType(
HAL_EncoderHandle encoderHandle, int32_t* status);

View File

@@ -135,6 +135,11 @@
#define HAL_USE_LAST_ERROR_MESSAGE \
"HAL: Use HAL_GetLastError(status) to get last error"
#define HAL_CONSOLE_OUT_ENABLED_ERROR -1157
#define HAL_CONSOLE_OUT_ENABLED_ERROR_MESSAGE \
"HAL: Onboard serial port is requested, but Console Out is enabled. " \
"Disable Console Out using imaging tool"
#define HAL_CAN_BUFFER_OVERRUN -35007
#define HAL_CAN_BUFFER_OVERRUN_MESSAGE \
"HAL: CAN Output Buffer Full. Ensure a device is attached"

View File

@@ -32,7 +32,7 @@ extern "C" {
* Expected to be called internally, not by users.
*
* @param library the library path
* @return the succes state of the initialization
* @return the succes state of the initialization
*/
int HAL_LoadOneExtension(const char* library);
@@ -40,7 +40,7 @@ int HAL_LoadOneExtension(const char* library);
* Loads any extra halsim libraries provided in the HALSIM_EXTENSIONS
* environment variable.
*
* @return the succes state of the initialization
* @return the succes state of the initialization
*/
int HAL_LoadExtensions(void);

View File

@@ -28,10 +28,10 @@ extern "C" {
* If passed HAL_USE_LAST_ERROR, the last error set on the thread will be
* returned.
*
* @param code the status code, set to the error status code if input is
* HAL_USE_LAST_ERROR
* @return the error message for the code. This does not need to be freed,
* but can be overwritten by another hal call on the same thread.
* @param[out] status the status code, set to the error status code if input is
* HAL_USE_LAST_ERROR
* @return the error message for the code. This does not need to be freed,
* but can be overwritten by another hal call on the same thread.
*/
const char* HAL_GetLastError(int32_t* status);
@@ -39,7 +39,7 @@ const char* HAL_GetLastError(int32_t* status);
* Gets the error message for a specific status code.
*
* @param code the status code
* @return the error message for the code. This does not need to be freed.
* @return the error message for the code. This does not need to be freed.
*/
const char* HAL_GetErrorMessage(int32_t code);
@@ -48,6 +48,7 @@ const char* HAL_GetErrorMessage(int32_t code);
*
* For now, expect this to be competition year.
*
* @param[out] status the error code, or 0 for success
* @return FPGA Version number.
*/
int32_t HAL_GetFPGAVersion(int32_t* status);
@@ -60,6 +61,7 @@ int32_t HAL_GetFPGAVersion(int32_t* status);
* the next 8 bits are the Minor Revision.
* The 12 least significant bits are the Build Number.
*
* @param[out] status the error code, or 0 for success
* @return FPGA Revision number.
*/
int64_t HAL_GetFPGARevision(int32_t* status);
@@ -74,6 +76,7 @@ HAL_RuntimeType HAL_GetRuntimeType(void);
/**
* Gets the state of the "USER" button on the roboRIO.
*
* @param[out] status the error code, or 0 for success
* @return true if the button is currently pressed down
*/
HAL_Bool HAL_GetFPGAButton(int32_t* status);
@@ -81,6 +84,7 @@ HAL_Bool HAL_GetFPGAButton(int32_t* status);
/**
* Gets if the system outputs are currently active
*
* @param[out] status the error code, or 0 for success
* @return true if the system outputs are active, false if disabled
*/
HAL_Bool HAL_GetSystemActive(int32_t* status);
@@ -88,6 +92,7 @@ HAL_Bool HAL_GetSystemActive(int32_t* status);
/**
* Gets if the system is in a browned out state.
*
* @param[out] status the error code, or 0 for success
* @return true if the system is in a low voltage brown out, false otherwise
*/
HAL_Bool HAL_GetBrownedOut(int32_t* status);
@@ -98,7 +103,7 @@ HAL_Bool HAL_GetBrownedOut(int32_t* status);
* The created handle does not need to be freed.
*
* @param channel the channel number
* @return the created port
* @return the created port
*/
HAL_PortHandle HAL_GetPort(int32_t channel);
@@ -112,13 +117,14 @@ HAL_PortHandle HAL_GetPort(int32_t channel);
*
* @param module the module number
* @param channel the channel number
* @return the created port
* @return the created port
*/
HAL_PortHandle HAL_GetPortWithModule(int32_t module, int32_t channel);
/**
* Reads the microsecond-resolution timer on the FPGA.
*
* @param[out] status the error code, or 0 for success
* @return The current time in microseconds according to the FPGA (since FPGA
* reset).
*/
@@ -133,10 +139,12 @@ uint64_t HAL_GetFPGATime(int32_t* status);
* bottom 32 bits of the timestamp and expanding it, you will be off by
* multiples of 1<<32 microseconds.
*
* @param[in] unexpandedLower 32 bit FPGA time
* @param[out] status the error code, or 0 for success
* @return The current time in microseconds according to the FPGA (since FPGA
* reset) as a 64 bit number.
* reset) as a 64 bit number.
*/
uint64_t HAL_ExpandFPGATime(uint32_t unexpanded_lower, int32_t* status);
uint64_t HAL_ExpandFPGATime(uint32_t unexpandedLower, int32_t* status);
/**
* Call this to start up HAL. This is required for robot programs.
@@ -160,7 +168,7 @@ uint64_t HAL_ExpandFPGATime(uint32_t unexpanded_lower, int32_t* status);
*
* @param timeout the initialization timeout (ms)
* @param mode the initialization mode (see remarks)
* @return true if initialization was successful, otherwise false.
* @return true if initialization was successful, otherwise false.
*/
HAL_Bool HAL_Initialize(int32_t timeout, int32_t mode);

View File

@@ -24,7 +24,8 @@ extern "C" {
* Opens the port if necessary and saves the handle.
* If opening the MXP port, also sets up the channel functions appropriately.
*
* @param port The port to open, 0 for the on-board, 1 for the MXP.
* @param[in] port The port to open, 0 for the on-board, 1 for the MXP.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status);
@@ -35,6 +36,8 @@ void HAL_InitializeI2C(HAL_I2CPort port, int32_t* status);
* over each transaction.
*
* @param port The I2C port, 0 for the on-board, 1 for the MXP.
* @param deviceAddress The address of the register on the device to be
* read/written.
* @param dataToSend Buffer of data to send as part of the transaction.
* @param sendSize Number of bytes to send as part of the transaction.
* @param dataReceived Buffer to read data into.
@@ -52,9 +55,10 @@ int32_t HAL_TransactionI2C(HAL_I2CPort port, int32_t deviceAddress,
* transaction is complete.
*
* @param port The I2C port, 0 for the on-board, 1 for the MXP.
* @param registerAddress The address of the register on the device to be
* written.
* @param data The byte to write to the register on the device.
* @param deviceAddress The address of the register on the device to be
* written.
* @param dataToSend The byte to write to the register on the device.
* @param sendSize Number of bytes to send.
* @return >= 0 on success or -1 on transfer abort.
*/
int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
@@ -68,7 +72,7 @@ int32_t HAL_WriteI2C(HAL_I2CPort port, int32_t deviceAddress,
* you to read consecutive registers on a device in a single transaction.
*
* @param port The I2C port, 0 for the on-board, 1 for the MXP.
* @param registerAddress The register to read first in the transaction.
* @param deviceAddress The register to read first in the transaction.
* @param count The number of bytes to read in the transaction.
* @param buffer A pointer to the array of bytes to store the data read from the
* device.

View File

@@ -22,8 +22,8 @@ extern "C" {
/**
* Initializes an interrupt.
*
* @param watcher true for synchronous interrupts, false for asynchronous
* @return the created interrupt handle
* @param[out] status Error status variable. 0 on success.
* @return the created interrupt handle
*/
HAL_InterruptHandle HAL_InitializeInterrupts(int32_t* status);
@@ -37,11 +37,12 @@ void HAL_CleanInterrupts(HAL_InterruptHandle interruptHandle);
/**
* In synchronous mode, waits for the defined interrupt to occur.
*
* @param interruptHandle the interrupt handle
* @param timeout timeout in seconds
* @param ignorePrevious if true, ignore interrupts that happened before
* waitForInterrupt was called
* @return the mask of interrupts that fired
* @param[in] interruptHandle the interrupt handle
* @param[in] timeout timeout in seconds
* @param[in] ignorePrevious if true, ignore interrupts that happened before
* waitForInterrupt was called
* @param[out] status Error status variable. 0 on success.
* @return the mask of interrupts that fired
*/
int64_t HAL_WaitForInterrupt(HAL_InterruptHandle interruptHandle,
double timeout, HAL_Bool ignorePrevious,
@@ -54,8 +55,9 @@ int64_t HAL_WaitForInterrupt(HAL_InterruptHandle interruptHandle,
* bottom 32 bits of the timestamp. If your robot has been running for over 1
* hour, you will need to fill in the upper 32 bits yourself.
*
* @param interruptHandle the interrupt handle
* @return timestamp in microseconds since FPGA Initialization
* @param[in] interruptHandle the interrupt handle
* @param[out] status Error status variable. 0 on success.
* @return timestamp in microseconds since FPGA Initialization
*/
int64_t HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interruptHandle,
int32_t* status);
@@ -67,8 +69,9 @@ int64_t HAL_ReadInterruptRisingTimestamp(HAL_InterruptHandle interruptHandle,
* bottom 32 bits of the timestamp. If your robot has been running for over 1
* hour, you will need to fill in the upper 32 bits yourself.
*
* @param interruptHandle the interrupt handle
* @return timestamp in microseconds since FPGA Initialization
* @param[in] interruptHandle the interrupt handle
* @param[out] status Error status variable. 0 on success.
* @return timestamp in microseconds since FPGA Initialization
*/
int64_t HAL_ReadInterruptFallingTimestamp(HAL_InterruptHandle interruptHandle,
int32_t* status);
@@ -76,10 +79,13 @@ int64_t HAL_ReadInterruptFallingTimestamp(HAL_InterruptHandle interruptHandle,
/**
* Requests interrupts on a specific digital source.
*
* @param interruptHandle the interrupt handle
* @param digitalSourceHandle the digital source handle (either a
* HAL_AnalogTriggerHandle or a HAL_DigitalHandle)
* @param analogTriggerType the trigger type if the source is an AnalogTrigger
* @param[in] interruptHandle the interrupt handle
* @param[in] digitalSourceHandle the digital source handle (either a
* HAL_AnalogTriggerHandle or a
* HAL_DigitalHandle)
* @param[in] analogTriggerType the trigger type if the source is an
* AnalogTrigger
* @param[out] status Error status variable. 0 on success.
*/
void HAL_RequestInterrupts(HAL_InterruptHandle interruptHandle,
HAL_Handle digitalSourceHandle,
@@ -91,9 +97,10 @@ void HAL_RequestInterrupts(HAL_InterruptHandle interruptHandle,
*
* Note that both edges triggered is a valid configuration.
*
* @param interruptHandle the interrupt handle
* @param risingEdge true for triggering on rising edge
* @param fallingEdge true for triggering on falling edge
* @param[in] interruptHandle the interrupt handle
* @param[in] risingEdge true for triggering on rising edge
* @param[in] fallingEdge true for triggering on falling edge
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetInterruptUpSourceEdge(HAL_InterruptHandle interruptHandle,
HAL_Bool risingEdge, HAL_Bool fallingEdge,
@@ -104,7 +111,8 @@ void HAL_SetInterruptUpSourceEdge(HAL_InterruptHandle interruptHandle,
*
* This will release both rising and falling waiters.
*
* @param interruptHandle the interrupt handle to release
* @param[in] interruptHandle the interrupt handle to release
* @param[out] status Error status variable. 0 on success.
*/
void HAL_ReleaseWaitingInterrupt(HAL_InterruptHandle interruptHandle,
int32_t* status);

View File

@@ -26,6 +26,7 @@ extern "C" {
* A notifier is an FPGA controller timer that triggers at requested intervals
* based on the FPGA time. This can be used to make precise control loops.
*
* @param[out] status Error status variable. 0 on success.
* @return the created notifier
*/
HAL_NotifierHandle HAL_InitializeNotifier(int32_t* status);
@@ -38,13 +39,13 @@ HAL_NotifierHandle HAL_InitializeNotifier(int32_t* status);
* Giving the HAL notifier thread real-time priority helps ensure the user's
* real-time Notifiers, if any, are notified to run in a timely manner.
*
* @param realTime Set to true to set a real-time priority, false for standard
* priority.
* @param priority Priority to set the thread to. For real-time, this is 1-99
* with 99 being highest. For non-real-time, this is forced to
* 0. See "man 7 sched" for more details.
* @param status Error status variable. 0 on success.
* @return True on success.
* @param[in] realTime Set to true to set a real-time priority, false for
* standard priority.
* @param[in] priority Priority to set the thread to. For real-time, this is
* 1-99 with 99 being highest. For non-real-time, this is
* forced to 0. See "man 7 sched" for more details.
* @param[out] status Error status variable. 0 on success.
* @return True on success.
*/
HAL_Bool HAL_SetNotifierThreadPriority(HAL_Bool realTime, int32_t priority,
int32_t* status);
@@ -52,8 +53,9 @@ HAL_Bool HAL_SetNotifierThreadPriority(HAL_Bool realTime, int32_t priority,
/**
* Sets the name of a notifier.
*
* @param notifierHandle the notifier handle
* @param name name
* @param[in] notifierHandle the notifier handle
* @param[in] name name
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetNotifierName(HAL_NotifierHandle notifierHandle, const char* name,
int32_t* status);
@@ -63,7 +65,8 @@ void HAL_SetNotifierName(HAL_NotifierHandle notifierHandle, const char* name,
*
* This will cause any call into HAL_WaitForNotifierAlarm to return.
*
* @param notifierHandle the notifier handle
* @param[in] notifierHandle the notifier handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_StopNotifier(HAL_NotifierHandle notifierHandle, int32_t* status);
@@ -72,7 +75,8 @@ void HAL_StopNotifier(HAL_NotifierHandle notifierHandle, int32_t* status);
*
* Note this also stops a notifier if it is already running.
*
* @param notifierHandle the notifier handle
* @param[in] notifierHandle the notifier handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_CleanNotifier(HAL_NotifierHandle notifierHandle, int32_t* status);
@@ -81,8 +85,9 @@ void HAL_CleanNotifier(HAL_NotifierHandle notifierHandle, int32_t* status);
*
* Note that this time is an absolute time relative to HAL_GetFPGATime()
*
* @param notifierHandle the notifier handle
* @param triggerTime the updated trigger time
* @param[in] notifierHandle the notifier handle
* @param[in] triggerTime the updated trigger time
* @param[out] status Error status variable. 0 on success.
*/
void HAL_UpdateNotifierAlarm(HAL_NotifierHandle notifierHandle,
uint64_t triggerTime, int32_t* status);
@@ -92,7 +97,8 @@ void HAL_UpdateNotifierAlarm(HAL_NotifierHandle notifierHandle,
*
* This does not cause HAL_WaitForNotifierAlarm to return.
*
* @param notifierHandle the notifier handle
* @param[in] notifierHandle the notifier handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle,
int32_t* status);
@@ -105,8 +111,9 @@ void HAL_CancelNotifierAlarm(HAL_NotifierHandle notifierHandle,
* loops using this function should exit. Failing to do so can lead to
* use-after-frees.
*
* @param notifierHandle the notifier handle
* @return the FPGA time the notifier returned
* @param[in] notifierHandle the notifier handle
* @param[out] status Error status variable. 0 on success.
* @return the FPGA time the notifier returned
*/
WPI_NODISCARD
uint64_t HAL_WaitForNotifierAlarm(HAL_NotifierHandle notifierHandle,

View File

@@ -21,10 +21,11 @@ extern "C" {
/**
* Initializes a PWM port.
*
* @param portHandle the port to initialize
* @param allocationLocation the location where the allocation is occuring
* (can be null)
* @return the created pwm handle
* @param[in] portHandle the port to initialize
* @param[in] allocationLocation the location where the allocation is occuring
* (can be null)
* @param[out] status Error status variable. 0 on success.
* @return the created pwm handle
*/
HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
const char* allocationLocation,
@@ -33,7 +34,8 @@ HAL_DigitalHandle HAL_InitializePWMPort(HAL_PortHandle portHandle,
/**
* Frees a PWM port.
*
* @param pwmPortHandle the pwm handle
* @param[in] pwmPortHandle the pwm handle
* @param[out] status Error status variable. 0 on success.
*/
void HAL_FreePWMPort(HAL_DigitalHandle pwmPortHandle, int32_t* status);
@@ -41,7 +43,7 @@ void HAL_FreePWMPort(HAL_DigitalHandle pwmPortHandle, int32_t* status);
* Checks if a pwm channel is valid.
*
* @param channel the channel to check
* @return true if the channel is valid, otherwise false
* @return true if the channel is valid, otherwise false
*/
HAL_Bool HAL_CheckPWMChannel(int32_t channel);
@@ -50,12 +52,13 @@ HAL_Bool HAL_CheckPWMChannel(int32_t channel);
*
* All values are in milliseconds.
*
* @param pwmPortHandle the PWM handle
* @param maxPwm the maximum PWM value
* @param deadbandMaxPwm the high range of the center deadband
* @param centerPwm the center PWM value
* @param deadbandMinPwm the low range of the center deadband
* @param minPwm the minimum PWM value
* @param[in] pwmPortHandle the PWM handle
* @param[in] maxPwm the maximum PWM value
* @param[in] deadbandMaxPwm the high range of the center deadband
* @param[in] centerPwm the center PWM value
* @param[in] deadbandMinPwm the low range of the center deadband
* @param[in] minPwm the minimum PWM value
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetPWMConfig(HAL_DigitalHandle pwmPortHandle, double maxPwm,
double deadbandMaxPwm, double centerPwm,
@@ -69,12 +72,13 @@ void HAL_SetPWMConfig(HAL_DigitalHandle pwmPortHandle, double maxPwm,
*
* Values are in raw FPGA units.
*
* @param pwmPortHandle the PWM handle
* @param maxPwm the maximum PWM value
* @param deadbandMaxPwm the high range of the center deadband
* @param centerPwm the center PWM value
* @param deadbandMinPwm the low range of the center deadband
* @param minPwm the minimum PWM value
* @param[in] pwmPortHandle the PWM handle
* @param[in] maxPwm the maximum PWM value
* @param[in] deadbandMaxPwm the high range of the center deadband
* @param[in] centerPwm the center PWM value
* @param[in] deadbandMinPwm the low range of the center deadband
* @param[in] minPwm the minimum PWM value
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetPWMConfigRaw(HAL_DigitalHandle pwmPortHandle, int32_t maxPwm,
int32_t deadbandMaxPwm, int32_t centerPwm,
@@ -87,12 +91,13 @@ void HAL_SetPWMConfigRaw(HAL_DigitalHandle pwmPortHandle, int32_t maxPwm,
* Values are in raw FPGA units. These units have the potential to change for
* any FPGA release.
*
* @param pwmPortHandle the PWM handle
* @param maxPwm the maximum PWM value
* @param deadbandMaxPwm the high range of the center deadband
* @param centerPwm the center PWM value
* @param deadbandMinPwm the low range of the center deadband
* @param minPwm the minimum PWM value
* @param[in] pwmPortHandle the PWM handle
* @param[in] maxPwm the maximum PWM value
* @param[in] deadbandMaxPwm the high range of the center deadband
* @param[in] centerPwm the center PWM value
* @param[in] deadbandMinPwm the low range of the center deadband
* @param[in] minPwm the minimum PWM value
* @param[out] status Error status variable. 0 on success.
*/
void HAL_GetPWMConfigRaw(HAL_DigitalHandle pwmPortHandle, int32_t* maxPwm,
int32_t* deadbandMaxPwm, int32_t* centerPwm,
@@ -103,8 +108,9 @@ void HAL_GetPWMConfigRaw(HAL_DigitalHandle pwmPortHandle, int32_t* maxPwm,
* Sets if the FPGA should output the center value if the input value is within
* the deadband.
*
* @param pwmPortHandle the PWM handle
* @param eliminateDeadband true to eliminate deadband, otherwise false
* @param[in] pwmPortHandle the PWM handle
* @param[in] eliminateDeadband true to eliminate deadband, otherwise false
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetPWMEliminateDeadband(HAL_DigitalHandle pwmPortHandle,
HAL_Bool eliminateDeadband, int32_t* status);
@@ -112,8 +118,9 @@ void HAL_SetPWMEliminateDeadband(HAL_DigitalHandle pwmPortHandle,
/**
* Gets the current eliminate deadband value.
*
* @param pwmPortHandle the PWM handle
* @return true if set, otherwise false
* @param[in] pwmPortHandle the PWM handle
* @param[out] status Error status variable. 0 on success.
* @return true if set, otherwise false
*/
HAL_Bool HAL_GetPWMEliminateDeadband(HAL_DigitalHandle pwmPortHandle,
int32_t* status);
@@ -124,8 +131,9 @@ HAL_Bool HAL_GetPWMEliminateDeadband(HAL_DigitalHandle pwmPortHandle,
* The values are in raw FPGA units, and have the potential to change with any
* FPGA release.
*
* @param pwmPortHandle the PWM handle
* @param value the PWM value to set
* @param[in] pwmPortHandle the PWM handle
* @param[in] value the PWM value to set
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetPWMRaw(HAL_DigitalHandle pwmPortHandle, int32_t value,
int32_t* status);
@@ -136,8 +144,9 @@ void HAL_SetPWMRaw(HAL_DigitalHandle pwmPortHandle, int32_t value,
* The values range from -1 to 1 and the period is controlled by the PWM Period
* and MinHigh registers.
*
* @param pwmPortHandle the PWM handle
* @param value the scaled PWM value to set
* @param[in] pwmPortHandle the PWM handle
* @param[in] speed the scaled PWM value to set
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetPWMSpeed(HAL_DigitalHandle pwmPortHandle, double speed,
int32_t* status);
@@ -148,8 +157,9 @@ void HAL_SetPWMSpeed(HAL_DigitalHandle pwmPortHandle, double speed,
* The values range from 0 to 1 and the period is controlled by the PWM Period
* and MinHigh registers.
*
* @param pwmPortHandle the PWM handle
* @param value the positional PWM value to set
* @param[in] pwmPortHandle the PWM handle
* @param[in] position the positional PWM value to set
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetPWMPosition(HAL_DigitalHandle pwmPortHandle, double position,
int32_t* status);
@@ -161,7 +171,8 @@ void HAL_SetPWMPosition(HAL_DigitalHandle pwmPortHandle, double position,
* from just setting a 0 speed, as this will actively stop all signaling on the
* channel.
*
* @param pwmPortHandle the PWM handle.
* @param[in] pwmPortHandle the PWM handle.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetPWMDisabled(HAL_DigitalHandle pwmPortHandle, int32_t* status);
@@ -171,8 +182,9 @@ void HAL_SetPWMDisabled(HAL_DigitalHandle pwmPortHandle, int32_t* status);
* The values are in raw FPGA units, and have the potential to change with any
* FPGA release.
*
* @param pwmPortHandle the PWM handle
* @return the current raw PWM value
* @param[in] pwmPortHandle the PWM handle
* @param[out] status Error status variable. 0 on success.
* @return the current raw PWM value
*/
int32_t HAL_GetPWMRaw(HAL_DigitalHandle pwmPortHandle, int32_t* status);
@@ -181,8 +193,9 @@ int32_t HAL_GetPWMRaw(HAL_DigitalHandle pwmPortHandle, int32_t* status);
*
* The values range from -1 to 1.
*
* @param pwmPortHandle the PWM handle
* @return the current speed PWM value
* @param[in] pwmPortHandle the PWM handle
* @param[out] status Error status variable. 0 on success.
* @return the current speed PWM value
*/
double HAL_GetPWMSpeed(HAL_DigitalHandle pwmPortHandle, int32_t* status);
@@ -191,23 +204,26 @@ double HAL_GetPWMSpeed(HAL_DigitalHandle pwmPortHandle, int32_t* status);
*
* The values range from 0 to 1.
*
* @param pwmPortHandle the PWM handle
* @return the current positional PWM value
* @param[in] pwmPortHandle the PWM handle
* @param[out] status Error status variable. 0 on success.
* @return the current positional PWM value
*/
double HAL_GetPWMPosition(HAL_DigitalHandle pwmPortHandle, int32_t* status);
/**
* Forces a PWM signal to go to 0 temporarily.
*
* @param pwmPortHandle the PWM handle.
* @param[in] pwmPortHandle the PWM handle.
* @param[out] status Error status variable. 0 on success.
*/
void HAL_LatchPWMZero(HAL_DigitalHandle pwmPortHandle, int32_t* status);
/**
* Sets how how often the PWM signal is squelched, thus scaling the period.
*
* @param pwmPortHandle the PWM handle.
* @param squelchMask the 2-bit mask of outputs to squelch
* @param[in] pwmPortHandle the PWM handle.
* @param[in] squelchMask the 2-bit mask of outputs to squelch
* @param[out] status Error status variable. 0 on success.
*/
void HAL_SetPWMPeriodScale(HAL_DigitalHandle pwmPortHandle, int32_t squelchMask,
int32_t* status);
@@ -215,6 +231,7 @@ void HAL_SetPWMPeriodScale(HAL_DigitalHandle pwmPortHandle, int32_t squelchMask,
/**
* Gets the loop timing of the PWM system.
*
* @param[out] status Error status variable. 0 on success.
* @return the loop time
*/
int32_t HAL_GetPWMLoopTiming(int32_t* status);
@@ -224,6 +241,7 @@ int32_t HAL_GetPWMLoopTiming(int32_t* status);
*
* This time is relative to the FPGA time.
*
* @param[out] status Error status variable. 0 on success.
* @return the pwm cycle start time
*/
uint64_t HAL_GetPWMCycleStartTime(int32_t* status);

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