Squashed 'third_party/allwpilib_2019/' changes from e20d96ea4e..b0167e6337

32c62449be Add ArrayRef overloads to new command classes (#2216)
6190fcb237 Run wpiformat (#2218)
012d93b2bd Use an explicit stack instead of recursion when parameterizing splines (#2197)
222669dc2c Fix trapezoidal profile PID controller setpoint bug (#2210)
abe25b795b TrajectoryUtil.toPathweaverJson: Create parent directories (#2214)
354185189c Update ProjectYear to 2020 (#2212)
f14fe434a1 Add (Old) qualifier to old subsystem (#2211)
e874ba9313 Add Color classes for use with AddressableLED (#2127)
96348e835a Fix C++ SendableRegistry::AddChild() (#2207)
d91796f8d2 fix clang-format version number (#2206)
9abce8eb06 Fix subsystem LiveWindow usage (#2202)
8b4508ad53 Use default path for networktables.ini in simulation (#2205)
5b7dd186d2 Add templates for new commands for vscode plugin (#2016)
6ea13ea8f3 ntcore: Add support for local-only operation (#2204)
44bcf7fb4d Java examples: use non-static imports for constants (#2191)
c7a1dfc0bc Add SlewRateLimiter class (#2192)
a12bb447e4 Fail cmake build if python3 generate_numbers.py fails (#2203)
c4bd54ef44 Add JNI binding to suppress driver station error/warning messages (#2200)
f9a11cce5e Remove -no-module-directories flag from javadoc build (#2201)
6008671c30 Report WPILib version as part of usage reporting (#2199)
7b952d599d Add usage reporting for many new things (#2184)
93cdf68694 Add Constants.cpp for MecanumControllerCommand example (#2196)
0c6f24562f Fix bug in ULEB128 decoding (#2195)
bdc1cab013 Add support for configuring SPI Auto Stall Config (#2193)
3259cffc63 Add transform methods to Trajectory (#2187)
67b59f2b31 Minor improvements/fixes to new command framework (#2186)
1ce24a7a2f Add 2020 speed controllers (#2188)
635882a9f7 Add getter for initial pose in Trajectory (#2180)
71a22861eb Use ManagedStatic for CameraServer (#2174)
9cb69c5b46 Add a way to pass in a preconstructed value to ManagedStatic (#2175)
5e08bb28f8 Add docs and lifecycle tasks for faster dev builds (#2182)
ea4d1a39e1 Update characterization values to match real robot (#2183)
31b588d961 Fix ArmFeedforward Javadocs (#2176)
0b80d566ad Use ChipObject HMB function for LED (#2173)
f8294e689b Sim GUI: Add a bit of spacing to the analog inputs (#2170)
b78f115fcf Work around VS2019 16.4.0 bugs (#2171)
b468c51251 Change AddressableLED example to use consistent PWM port (#2168)
023c088290 Add toString() to relevant kinematics classes (#2160)
8a11d13a39 Fix C++ DutyCycleEncoder int constructor (#2166)
daa81c64a7 Minor javadoc fix in SwerveDriveKinematicsConstraint (#2167)

Change-Id: Ied6a4d039f2b95381e1d2124fcc70d52580cc165
git-subtree-dir: third_party/allwpilib_2019
git-subtree-split: b0167e6337135545e7053acb89dd5726accc7dec
diff --git a/hal/src/main/native/athena/AddressableLED.cpp b/hal/src/main/native/athena/AddressableLED.cpp
index 9ecc4c4..64b6457 100644
--- a/hal/src/main/native/athena/AddressableLED.cpp
+++ b/hal/src/main/native/athena/AddressableLED.cpp
@@ -9,6 +9,8 @@
 
 #include <cstring>
 
+#include <FRC_FPGA_ChipObject/fpgainterfacecapi/NiFpga_HMB.h>
+
 #include "ConstantsInternal.h"
 #include "DigitalInternal.h"
 #include "HALInitializer.h"
@@ -19,14 +21,6 @@
 
 using namespace hal;
 
-extern "C" {
-NiFpga_Status NiFpga_ClientFunctionCall(NiFpga_Session session, uint32_t group,
-                                        uint32_t functionId,
-                                        const void* inBuffer,
-                                        size_t inBufferSize, void* outBuffer,
-                                        size_t outBufferSize);
-}  // extern "C"
-
 namespace {
 struct AddressableLED {
   std::unique_ptr<tLED> led;
@@ -52,43 +46,6 @@
 }  // namespace init
 }  // namespace hal
 
-// Shim for broken ChipObject function
-static const uint32_t clientFeature_hostMemoryBuffer = 0;
-static const uint32_t hostMemoryBufferFunction_open = 2;
-
-// Input arguments for HMB open
-struct AtomicHMBOpenInputs {
-  const char* memoryName;
-};
-
-// Output arguments for HMB open
-struct AtomicHMBOpenOutputs {
-  size_t size;
-  void* virtualAddress;
-};
-
-static NiFpga_Status OpenHostMemoryBuffer(NiFpga_Session session,
-                                          const char* memoryName,
-                                          void** virtualAddress, size_t* size) {
-  struct AtomicHMBOpenOutputs outputs;
-
-  struct AtomicHMBOpenInputs inputs;
-  inputs.memoryName = memoryName;
-
-  NiFpga_Status retval = NiFpga_ClientFunctionCall(
-      session, clientFeature_hostMemoryBuffer, hostMemoryBufferFunction_open,
-      &inputs, sizeof(struct AtomicHMBOpenInputs), &outputs,
-      sizeof(struct AtomicHMBOpenOutputs));
-  if (NiFpga_IsError(retval)) {
-    return retval;
-  }
-  *virtualAddress = outputs.virtualAddress;
-  if (size != NULL) {
-    *size = outputs.size;
-  }
-  return retval;
-}
-
 extern "C" {
 
 HAL_AddressableLEDHandle HAL_InitializeAddressableLED(
@@ -146,8 +103,8 @@
 
   uint32_t session = led->led->getSystemInterface()->getHandle();
 
-  *status = OpenHostMemoryBuffer(session, "HMB_0_LED", &led->ledBuffer,
-                                 &led->ledBufferSize);
+  *status = NiFpga_OpenHostMemoryBuffer(session, "HMB_0_LED", &led->ledBuffer,
+                                        &led->ledBufferSize);
 
   if (*status != 0) {
     addressableLEDHandles->Free(handle);
diff --git a/hal/src/main/native/athena/SPI.cpp b/hal/src/main/native/athena/SPI.cpp
index 80cbf09..37c5f0e 100644
--- a/hal/src/main/native/athena/SPI.cpp
+++ b/hal/src/main/native/athena/SPI.cpp
@@ -631,12 +631,21 @@
   return spiSystem->readTransferSkippedFullCount(status);
 }
 
-// These 2 functions are so the new stall functionality
-// can be tested. How they're used is not very clear
-// but I want them to be testable so we can add an impl.
-// We will not be including these in the headers
-void* HAL_GetSPIDMAManager() { return spiAutoDMA.get(); }
+void HAL_ConfigureSPIAutoStall(HAL_SPIPort port, int32_t csToSclkTicks,
+                               int32_t stallTicks, int32_t pow2BytesPerRead,
+                               int32_t* status) {
+  std::scoped_lock lock(spiAutoMutex);
+  // FPGA only has one auto SPI engine
+  if (port != spiAutoPort) {
+    *status = INCOMPATIBLE_STATE;
+    return;
+  }
 
-void* HAL_GetSPISystem() { return spiSystem.get(); }
+  tSPI::tStallConfig stallConfig;
+  stallConfig.CsToSclkTicks = static_cast<uint8_t>(csToSclkTicks);
+  stallConfig.StallTicks = static_cast<uint16_t>(stallTicks);
+  stallConfig.Pow2BytesPerRead = static_cast<uint8_t>(pow2BytesPerRead);
+  spiSystem->writeStallConfig(stallConfig, status);
+}
 
 }  // extern "C"