Update to the 2019 wpilib

Lots of gratuitious incompatibilities to deal with. Started sanifying a
few classes rather than figuring out how to update them too. Has not yet
been tested on a robot, but everything still builds so it should be
fine.

Also ported over our FPGA timestamp fixes, which were previously only in
allwpilib_2018.

Also upgraded to the new roborio compiler, which has to happen at the
same time due to incompatible pre-compiled libraries.

Change-Id: Ib9b6ad8fc0112d90a9855afe1b706588ef4ebde9
diff --git a/frc971/wpilib/ADIS16448.cc b/frc971/wpilib/ADIS16448.cc
index 6c4a6d1..21a5e2c 100644
--- a/frc971/wpilib/ADIS16448.cc
+++ b/frc971/wpilib/ADIS16448.cc
@@ -236,7 +236,10 @@
     }
 
     auto message = imu_values.MakeMessage();
-    message->fpga_timestamp = dio1_->ReadRisingTimestamp();
+    message->fpga_timestamp =
+        chrono::duration_cast<chrono::duration<double>>(
+            dio1_->ReadRisingTimestamp().time_since_epoch())
+            .count();
     message->monotonic_timestamp_ns =
         chrono::duration_cast<chrono::nanoseconds>(read_time.time_since_epoch())
             .count();
diff --git a/frc971/wpilib/ahal/AnalogInput.cc b/frc971/wpilib/ahal/AnalogInput.cc
index fc2e5a7..1694708 100644
--- a/frc971/wpilib/ahal/AnalogInput.cc
+++ b/frc971/wpilib/ahal/AnalogInput.cc
@@ -6,12 +6,12 @@
 /*----------------------------------------------------------------------------*/
 
 #include "frc971/wpilib/ahal/AnalogInput.h"
-#include "HAL/AnalogInput.h"
+#include "hal/AnalogInput.h"
 
 #include <sstream>
 
-#include "HAL/HAL.h"
-#include "HAL/Ports.h"
+#include "hal/HAL.h"
+#include "hal/Ports.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
 
 using namespace frc;
diff --git a/frc971/wpilib/ahal/AnalogInput.h b/frc971/wpilib/ahal/AnalogInput.h
index 5398eec..4540bbe 100644
--- a/frc971/wpilib/ahal/AnalogInput.h
+++ b/frc971/wpilib/ahal/AnalogInput.h
@@ -10,7 +10,7 @@
 #include <memory>
 #include <string>
 
-#include "HAL/Types.h"
+#include "hal/Types.h"
 #include "frc971/wpilib/ahal/SensorBase.h"
 
 namespace frc {
diff --git a/frc971/wpilib/ahal/AnalogTrigger.cc b/frc971/wpilib/ahal/AnalogTrigger.cc
index c9028ae..194537c 100644
--- a/frc971/wpilib/ahal/AnalogTrigger.cc
+++ b/frc971/wpilib/ahal/AnalogTrigger.cc
@@ -9,7 +9,7 @@
 
 #include <memory>
 
-#include <HAL/HAL.h>
+#include <hal/HAL.h>
 
 #include "frc971/wpilib/ahal/AnalogInput.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
diff --git a/frc971/wpilib/ahal/AnalogTrigger.h b/frc971/wpilib/ahal/AnalogTrigger.h
index 7b6fc92..30a07d1 100644
--- a/frc971/wpilib/ahal/AnalogTrigger.h
+++ b/frc971/wpilib/ahal/AnalogTrigger.h
@@ -9,7 +9,7 @@
 
 #include <memory>
 
-#include "HAL/Types.h"
+#include "hal/Types.h"
 #include "frc971/wpilib/ahal/AnalogTriggerOutput.h"
 #include "frc971/wpilib/ahal/SensorBase.h"
 
diff --git a/frc971/wpilib/ahal/AnalogTriggerOutput.cc b/frc971/wpilib/ahal/AnalogTriggerOutput.cc
index bdc47b6..d95b1d7 100644
--- a/frc971/wpilib/ahal/AnalogTriggerOutput.cc
+++ b/frc971/wpilib/ahal/AnalogTriggerOutput.cc
@@ -7,7 +7,7 @@
 
 #include "frc971/wpilib/ahal/AnalogTriggerOutput.h"
 
-#include <HAL/HAL.h>
+#include <hal/HAL.h>
 
 #include "frc971/wpilib/ahal/AnalogTrigger.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
diff --git a/frc971/wpilib/ahal/AnalogTriggerOutput.h b/frc971/wpilib/ahal/AnalogTriggerOutput.h
index 0ddaae0..7eb3163 100644
--- a/frc971/wpilib/ahal/AnalogTriggerOutput.h
+++ b/frc971/wpilib/ahal/AnalogTriggerOutput.h
@@ -7,7 +7,7 @@
 
 #pragma once
 
-#include "HAL/AnalogTrigger.h"
+#include "hal/AnalogTrigger.h"
 #include "frc971/wpilib/ahal/DigitalSource.h"
 
 namespace frc {
diff --git a/frc971/wpilib/ahal/Compressor.cc b/frc971/wpilib/ahal/Compressor.cc
index 2967f05..4a17f76 100644
--- a/frc971/wpilib/ahal/Compressor.cc
+++ b/frc971/wpilib/ahal/Compressor.cc
@@ -6,11 +6,11 @@
 /*----------------------------------------------------------------------------*/
 
 #include "frc971/wpilib/ahal/Compressor.h"
-#include "HAL/Compressor.h"
+#include "hal/Compressor.h"
 
-#include "HAL/HAL.h"
-#include "HAL/Ports.h"
-#include "HAL/Solenoid.h"
+#include "hal/HAL.h"
+#include "hal/Ports.h"
+#include "hal/Solenoid.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
 
 using namespace frc;
diff --git a/frc971/wpilib/ahal/Compressor.h b/frc971/wpilib/ahal/Compressor.h
index 60e21d9..c358ce1 100644
--- a/frc971/wpilib/ahal/Compressor.h
+++ b/frc971/wpilib/ahal/Compressor.h
@@ -10,7 +10,7 @@
 #include <memory>
 #include <string>
 
-#include "HAL/Types.h"
+#include "hal/Types.h"
 #include "frc971/wpilib/ahal/SensorBase.h"
 
 namespace frc {
diff --git a/frc971/wpilib/ahal/ControllerPower.cc b/frc971/wpilib/ahal/ControllerPower.cc
index e045fdc..9637d17 100644
--- a/frc971/wpilib/ahal/ControllerPower.cc
+++ b/frc971/wpilib/ahal/ControllerPower.cc
@@ -9,8 +9,8 @@
 
 #include <stdint.h>
 
-#include "HAL/HAL.h"
-#include "HAL/Power.h"
+#include "hal/HAL.h"
+#include "hal/Power.h"
 #include "frc971/wpilib/ahal/ErrorBase.h"
 
 using namespace frc;
diff --git a/frc971/wpilib/ahal/Counter.cc b/frc971/wpilib/ahal/Counter.cc
index 352904b..3614b8c 100644
--- a/frc971/wpilib/ahal/Counter.cc
+++ b/frc971/wpilib/ahal/Counter.cc
@@ -7,7 +7,7 @@
 
 #include "frc971/wpilib/ahal/Counter.h"
 
-#include "HAL/HAL.h"
+#include "hal/HAL.h"
 #include "frc971/wpilib/ahal/AnalogTrigger.h"
 #include "frc971/wpilib/ahal/DigitalInput.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
diff --git a/frc971/wpilib/ahal/Counter.h b/frc971/wpilib/ahal/Counter.h
index c32dd33..26ae7a2 100644
--- a/frc971/wpilib/ahal/Counter.h
+++ b/frc971/wpilib/ahal/Counter.h
@@ -10,8 +10,8 @@
 #include <memory>
 #include <string>
 
-#include "HAL/Counter.h"
-#include "HAL/Types.h"
+#include "hal/Counter.h"
+#include "hal/Types.h"
 #include "frc971/wpilib/ahal/AnalogTrigger.h"
 #include "frc971/wpilib/ahal/CounterBase.h"
 #include "frc971/wpilib/ahal/SensorBase.h"
diff --git a/frc971/wpilib/ahal/DigitalGlitchFilter.cc b/frc971/wpilib/ahal/DigitalGlitchFilter.cc
index 76e2b3b..cddfcf0 100644
--- a/frc971/wpilib/ahal/DigitalGlitchFilter.cc
+++ b/frc971/wpilib/ahal/DigitalGlitchFilter.cc
@@ -10,9 +10,9 @@
 #include <algorithm>
 #include <array>
 
-#include "HAL/Constants.h"
-#include "HAL/DIO.h"
-#include "HAL/HAL.h"
+#include "hal/Constants.h"
+#include "hal/DIO.h"
+#include "hal/HAL.h"
 #include "frc971/wpilib/ahal/Counter.h"
 #include "frc971/wpilib/ahal/Encoder.h"
 #include "frc971/wpilib/ahal/Utility.h"
@@ -31,7 +31,7 @@
   m_channelIndex = std::distance(m_filterAllocated.begin(), index);
   *index = true;
 
-  HAL_Report(HALUsageReporting::kResourceType_DigitalFilter, m_channelIndex);
+  HAL_Report(HALUsageReporting::kResourceType_DigitalGlitchFilter, m_channelIndex);
 }
 
 DigitalGlitchFilter::~DigitalGlitchFilter() {
diff --git a/frc971/wpilib/ahal/DigitalGlitchFilter.h b/frc971/wpilib/ahal/DigitalGlitchFilter.h
index 1864542..d31b9d5 100644
--- a/frc971/wpilib/ahal/DigitalGlitchFilter.h
+++ b/frc971/wpilib/ahal/DigitalGlitchFilter.h
@@ -10,7 +10,7 @@
 #include <array>
 
 #include "frc971/wpilib/ahal/DigitalSource.h"
-// #include "HAL/cpp/priority_mutex.h"
+// #include "hal/cpp/priority_mutex.h"
 
 namespace frc {
 
diff --git a/frc971/wpilib/ahal/DigitalInput.cc b/frc971/wpilib/ahal/DigitalInput.cc
index 45e405d..e0121ea 100644
--- a/frc971/wpilib/ahal/DigitalInput.cc
+++ b/frc971/wpilib/ahal/DigitalInput.cc
@@ -10,9 +10,9 @@
 #include <limits>
 #include <sstream>
 
-#include "HAL/DIO.h"
-#include "HAL/HAL.h"
-#include "HAL/Ports.h"
+#include "hal/DIO.h"
+#include "hal/HAL.h"
+#include "hal/Ports.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
 
 using namespace frc;
diff --git a/frc971/wpilib/ahal/DigitalOutput.cc b/frc971/wpilib/ahal/DigitalOutput.cc
index 7f8495b..f4b2781 100644
--- a/frc971/wpilib/ahal/DigitalOutput.cc
+++ b/frc971/wpilib/ahal/DigitalOutput.cc
@@ -10,9 +10,9 @@
 #include <limits>
 #include <sstream>
 
-#include "HAL/DIO.h"
-#include "HAL/HAL.h"
-#include "HAL/Ports.h"
+#include "hal/DIO.h"
+#include "hal/HAL.h"
+#include "hal/Ports.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
 
 using namespace frc;
diff --git a/frc971/wpilib/ahal/DigitalOutput.h b/frc971/wpilib/ahal/DigitalOutput.h
index e1f7080..c6139ce 100644
--- a/frc971/wpilib/ahal/DigitalOutput.h
+++ b/frc971/wpilib/ahal/DigitalOutput.h
@@ -10,7 +10,7 @@
 #include <memory>
 #include <string>
 
-#include "HAL/Types.h"
+#include "hal/Types.h"
 #include "frc971/wpilib/ahal/DigitalSource.h"
 
 namespace frc {
diff --git a/frc971/wpilib/ahal/DigitalSource.h b/frc971/wpilib/ahal/DigitalSource.h
index 6844923..f5ece9c 100644
--- a/frc971/wpilib/ahal/DigitalSource.h
+++ b/frc971/wpilib/ahal/DigitalSource.h
@@ -7,7 +7,7 @@
 
 #pragma once
 
-#include "HAL/Types.h"
+#include "hal/Types.h"
 #include "frc971/wpilib/ahal/InterruptableSensorBase.h"
 
 namespace frc {
diff --git a/frc971/wpilib/ahal/DriverStation.cc b/frc971/wpilib/ahal/DriverStation.cc
index c34db1b..8420a9e 100644
--- a/frc971/wpilib/ahal/DriverStation.cc
+++ b/frc971/wpilib/ahal/DriverStation.cc
@@ -10,13 +10,13 @@
 #include <chrono>
 
 #include "FRC_NetworkCommunication/FRCComm.h"
-#include "HAL/HAL.h"
-#include "HAL/Power.h"
 #include "aos/make_unique.h"
 #include "frc971/wpilib/ahal/AnalogInput.h"
 #include "frc971/wpilib/ahal/Utility.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
-#include "llvm/SmallString.h"
+#include "hal/HAL.h"
+#include "hal/Power.h"
+#include "wpi/SmallString.h"
 
 using namespace frc;
 
@@ -43,9 +43,10 @@
  *
  * The error is also printed to the program console.
  */
-void DriverStation::ReportError(llvm::StringRef error) {
-  llvm::SmallString<128> temp;
-  HAL_SendError(1, 1, 0, error.c_str(temp), "", "", 1);
+void DriverStation::ReportError(const wpi::Twine &error) {
+  wpi::SmallString<128> temp;
+  HAL_SendError(1, 1, 0, error.toNullTerminatedStringRef(temp).data(), "", "",
+                1);
 }
 
 /**
@@ -53,9 +54,10 @@
  *
  * The warning is also printed to the program console.
  */
-void DriverStation::ReportWarning(llvm::StringRef error) {
-  llvm::SmallString<128> temp;
-  HAL_SendError(0, 1, 0, error.c_str(temp), "", "", 1);
+void DriverStation::ReportWarning(const wpi::Twine &error) {
+  wpi::SmallString<128> temp;
+  HAL_SendError(0, 1, 0, error.toNullTerminatedStringRef(temp).data(), "", "",
+                1);
 }
 
 /**
@@ -64,13 +66,16 @@
  * The error is also printed to the program console.
  */
 void DriverStation::ReportError(bool is_error, int32_t code,
-                                llvm::StringRef error, llvm::StringRef location,
-                                llvm::StringRef stack) {
-  llvm::SmallString<128> errorTemp;
-  llvm::SmallString<128> locationTemp;
-  llvm::SmallString<128> stackTemp;
-  HAL_SendError(is_error, code, 0, error.c_str(errorTemp),
-                location.c_str(locationTemp), stack.c_str(stackTemp), 1);
+                                const wpi::Twine &error,
+                                const wpi::Twine &location,
+                                const wpi::Twine &stack) {
+  wpi::SmallString<128> errorTemp;
+  wpi::SmallString<128> locationTemp;
+  wpi::SmallString<128> stackTemp;
+  HAL_SendError(is_error, code, 0,
+                error.toNullTerminatedStringRef(errorTemp).data(),
+                location.toNullTerminatedStringRef(locationTemp).data(),
+                stack.toNullTerminatedStringRef(stackTemp).data(), 1);
 }
 
 /**
@@ -394,17 +399,17 @@
   // DS, and if the DS thinks you don't have robot code, then you can't enable).
   HAL_ObserveUserProgramStarting();
 
-  m_joystickAxes = std::make_unique<HAL_JoystickAxes[]>(kJoystickPorts);
-  m_joystickPOVs = std::make_unique<HAL_JoystickPOVs[]>(kJoystickPorts);
-  m_joystickButtons = std::make_unique<HAL_JoystickButtons[]>(kJoystickPorts);
+  m_joystickAxes = aos::make_unique<HAL_JoystickAxes[]>(kJoystickPorts);
+  m_joystickPOVs = aos::make_unique<HAL_JoystickPOVs[]>(kJoystickPorts);
+  m_joystickButtons = aos::make_unique<HAL_JoystickButtons[]>(kJoystickPorts);
   m_joystickDescriptor =
-      std::make_unique<HAL_JoystickDescriptor[]>(kJoystickPorts);
-  m_joystickAxesCache = std::make_unique<HAL_JoystickAxes[]>(kJoystickPorts);
-  m_joystickPOVsCache = std::make_unique<HAL_JoystickPOVs[]>(kJoystickPorts);
+      aos::make_unique<HAL_JoystickDescriptor[]>(kJoystickPorts);
+  m_joystickAxesCache = aos::make_unique<HAL_JoystickAxes[]>(kJoystickPorts);
+  m_joystickPOVsCache = aos::make_unique<HAL_JoystickPOVs[]>(kJoystickPorts);
   m_joystickButtonsCache =
-      std::make_unique<HAL_JoystickButtons[]>(kJoystickPorts);
+      aos::make_unique<HAL_JoystickButtons[]>(kJoystickPorts);
   m_joystickDescriptorCache =
-      std::make_unique<HAL_JoystickDescriptor[]>(kJoystickPorts);
+      aos::make_unique<HAL_JoystickDescriptor[]>(kJoystickPorts);
 
   // All joysticks should default to having zero axes, povs and buttons, so
   // uninitialized memory doesn't get sent to speed controllers.
diff --git a/frc971/wpilib/ahal/DriverStation.h b/frc971/wpilib/ahal/DriverStation.h
index f1d0804..2fbac9c 100644
--- a/frc971/wpilib/ahal/DriverStation.h
+++ b/frc971/wpilib/ahal/DriverStation.h
@@ -13,9 +13,9 @@
 #include <string>
 #include <thread>
 
-#include "HAL/DriverStation.h"
+#include "hal/DriverStation.h"
 #include "frc971/wpilib/ahal/SensorBase.h"
-#include "llvm/StringRef.h"
+#include "wpi/Twine.h"
 
 namespace frc {
 
@@ -29,10 +29,10 @@
 
   virtual ~DriverStation();
   static DriverStation &GetInstance();
-  static void ReportError(llvm::StringRef error);
-  static void ReportWarning(llvm::StringRef error);
-  static void ReportError(bool is_error, int code, llvm::StringRef error,
-                          llvm::StringRef location, llvm::StringRef stack);
+  static void ReportError(const wpi::Twine &error);
+  static void ReportWarning(const wpi::Twine &error);
+  static void ReportError(bool is_error, int code, const wpi::Twine &error,
+                          const wpi::Twine &location, const wpi::Twine &stack);
 
   static const int kJoystickPorts = 6;
 
diff --git a/frc971/wpilib/ahal/Encoder.cc b/frc971/wpilib/ahal/Encoder.cc
index 8d57eda..b452720 100644
--- a/frc971/wpilib/ahal/Encoder.cc
+++ b/frc971/wpilib/ahal/Encoder.cc
@@ -7,7 +7,7 @@
 
 #include "frc971/wpilib/ahal/Encoder.h"
 
-#include "HAL/HAL.h"
+#include "hal/HAL.h"
 #include "frc971/wpilib/ahal/DigitalInput.h"
 
 using namespace frc;
diff --git a/frc971/wpilib/ahal/Encoder.h b/frc971/wpilib/ahal/Encoder.h
index 2f06e65..56e499f 100644
--- a/frc971/wpilib/ahal/Encoder.h
+++ b/frc971/wpilib/ahal/Encoder.h
@@ -10,7 +10,7 @@
 #include <memory>
 #include <string>
 
-#include "HAL/Encoder.h"
+#include "hal/Encoder.h"
 
 namespace frc {
 
diff --git a/frc971/wpilib/ahal/ErrorBase.h b/frc971/wpilib/ahal/ErrorBase.h
index 0f4e377..8228df1 100644
--- a/frc971/wpilib/ahal/ErrorBase.h
+++ b/frc971/wpilib/ahal/ErrorBase.h
@@ -8,7 +8,7 @@
 #pragma once
 
 #include "frc971/wpilib/ahal/Base.h"
-#include "llvm/StringRef.h"
+#include "wpi/StringRef.h"
 
 #define wpi_setErrnoErrorWithContext(context) \
   this->SetErrnoError((context), __FILE__, __FUNCTION__, __LINE__)
diff --git a/frc971/wpilib/ahal/InterruptableSensorBase.cc b/frc971/wpilib/ahal/InterruptableSensorBase.cc
index a757bee..4becafc 100644
--- a/frc971/wpilib/ahal/InterruptableSensorBase.cc
+++ b/frc971/wpilib/ahal/InterruptableSensorBase.cc
@@ -7,47 +7,50 @@
 
 #include "frc971/wpilib/ahal/InterruptableSensorBase.h"
 
-#include "HAL/HAL.h"
+#include "hal/HAL.h"
 #include "frc971/wpilib/ahal/Utility.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
 
 using namespace frc;
 
-InterruptableSensorBase::InterruptableSensorBase() {}
+namespace {
 
-/**
- * Request one of the 8 interrupts asynchronously on this digital input.
- *
- * Request interrupts in asynchronous mode where the user's interrupt handler
- * will be called when the interrupt fires. Users that want control over the
- * thread priority should use the synchronous method with their own spawned
- * thread. The default is interrupt on rising edges only.
- */
-void InterruptableSensorBase::RequestInterrupts(
-    HAL_InterruptHandlerFunction handler, void *param) {
-  if (StatusIsFatal()) return;
+// Converts a freestanding lower half to a 64 bit FPGA timestamp
+//
+// Note: This is making the assumption that the timestamp being converted is
+// always in the past.  If you call this with a future timestamp, it probably
+// will make it in the past.  If you wait over 70 minutes between capturing the
+// bottom 32 bits of the timestamp and expanding it, you will be off by
+// multiples of 1<<32 microseconds.
+//
+// @return The current time in microseconds according to the FPGA (since FPGA
+// reset) as a 64 bit number.
+uint64_t HAL_ExpandFPGATime(uint32_t unexpanded_lower, 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);
+  if (*status != 0) return 0;
 
-  wpi_assert(m_interrupt == HAL_kInvalidHandle);
-  AllocateInterrupts(false);
-  if (StatusIsFatal()) return;  // if allocate failed, out of interrupts
+  // Now, we need to detect the case where the lower bits rolled over after we
+  // sampled.  In that case, the upper bits will be 1 bigger than they should
+  // be.
 
-  int32_t status = 0;
-  HAL_RequestInterrupts(
-      m_interrupt, GetPortHandleForRouting(),
-      static_cast<HAL_AnalogTriggerType>(GetAnalogTriggerTypeForRouting()),
-      &status);
-  SetUpSourceEdge(true, false);
-  HAL_AttachInterruptHandler(m_interrupt, handler, param, &status);
-  wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
+  // Break it into lower and upper portions.
+  uint32_t lower = fpga_time & ((uint64_t)0xffffffff);
+  uint64_t upper = (fpga_time >> 32) & 0xffffffff;
+
+  // The time was sampled *before* the current time, so roll it back.
+  if (lower < unexpanded_lower) {
+    --upper;
+  }
+
+  return (upper << 32) + static_cast<uint64_t>(unexpanded_lower);
 }
 
-/**
- * Request one of the 8 interrupts synchronously on this digital input.
- *
- * Request interrupts in synchronous mode where the user program will have to
- * explicitly wait for the interrupt to occur using WaitForInterrupt.
- * The default is interrupt on rising edges only.
- */
+}  // namespace
+
+InterruptableSensorBase::InterruptableSensorBase() {}
+
 void InterruptableSensorBase::RequestInterrupts() {
   if (StatusIsFatal()) return;
 
@@ -72,11 +75,6 @@
   wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
 }
 
-/**
- * Cancel interrupts on this device.
- *
- * This deallocates all the chipobject structures and disables any interrupts.
- */
 void InterruptableSensorBase::CancelInterrupts() {
   if (StatusIsFatal()) return;
   wpi_assert(m_interrupt != HAL_kInvalidHandle);
@@ -86,18 +84,6 @@
   m_interrupt = HAL_kInvalidHandle;
 }
 
-/**
- * In synchronous mode, wait for the defined interrupt to occur.
- *
- * You should <b>NOT</b> attempt to read the sensor from another thread while
- * waiting for an interrupt. This is not threadsafe, and can cause memory
- * corruption
- *
- * @param timeout        Timeout in seconds
- * @param ignorePrevious If true, ignore interrupts that happened before
- *                       WaitForInterrupt was called.
- * @return What interrupts fired
- */
 InterruptableSensorBase::WaitResult InterruptableSensorBase::WaitForInterrupt(
     double timeout, bool ignorePrevious) {
   if (StatusIsFatal()) return InterruptableSensorBase::kTimeout;
@@ -117,13 +103,6 @@
   return static_cast<WaitResult>(falling | rising);
 }
 
-/**
- * Enable interrupts to occur on this input.
- *
- * Interrupts are disabled when the RequestInterrupt call is made. This gives
- * time to do the setup of the other options before starting to field
- * interrupts.
- */
 void InterruptableSensorBase::EnableInterrupts() {
   if (StatusIsFatal()) return;
   wpi_assert(m_interrupt != HAL_kInvalidHandle);
@@ -132,59 +111,26 @@
   wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
 }
 
-/**
- * Disable Interrupts without without deallocating structures.
- */
-void InterruptableSensorBase::DisableInterrupts() {
-  if (StatusIsFatal()) return;
+hal::fpga_clock::time_point InterruptableSensorBase::ReadRisingTimestamp() {
+  if (StatusIsFatal()) return hal::fpga_clock::min_time;
   wpi_assert(m_interrupt != HAL_kInvalidHandle);
   int32_t status = 0;
-  HAL_DisableInterrupts(m_interrupt, &status);
+  uint64_t timestamp = HAL_ReadInterruptRisingTimestamp(m_interrupt, &status);
+  timestamp = HAL_ExpandFPGATime(timestamp, &status);
   wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
+  return hal::fpga_clock::time_point(hal::fpga_clock::duration(timestamp));
 }
 
-/**
- * Return the timestamp for the rising interrupt that occurred most recently.
- *
- * This is in the same time domain as GetClock().
- * The rising-edge interrupt should be enabled with
- * {@link #DigitalInput.SetUpSourceEdge}
- *
- * @return Timestamp in seconds since boot.
- */
-double InterruptableSensorBase::ReadRisingTimestamp() {
-  if (StatusIsFatal()) return 0.0;
+hal::fpga_clock::time_point InterruptableSensorBase::ReadFallingTimestamp() {
+  if (StatusIsFatal()) return hal::fpga_clock::min_time;
   wpi_assert(m_interrupt != HAL_kInvalidHandle);
   int32_t status = 0;
-  double timestamp = HAL_ReadInterruptRisingTimestamp(m_interrupt, &status);
+  uint64_t timestamp = HAL_ReadInterruptFallingTimestamp(m_interrupt, &status);
+  timestamp = HAL_ExpandFPGATime(timestamp, &status);
   wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
-  return timestamp;
+  return hal::fpga_clock::time_point(hal::fpga_clock::duration(timestamp));
 }
 
-/**
- * Return the timestamp for the falling interrupt that occurred most recently.
- *
- * This is in the same time domain as GetClock().
- * The falling-edge interrupt should be enabled with
- * {@link #DigitalInput.SetUpSourceEdge}
- *
- * @return Timestamp in seconds since boot.
-*/
-double InterruptableSensorBase::ReadFallingTimestamp() {
-  if (StatusIsFatal()) return 0.0;
-  wpi_assert(m_interrupt != HAL_kInvalidHandle);
-  int32_t status = 0;
-  double timestamp = HAL_ReadInterruptFallingTimestamp(m_interrupt, &status);
-  wpi_setErrorWithContext(status, HAL_GetErrorMessage(status));
-  return timestamp;
-}
-
-/**
- * Set which edge to trigger interrupts on
- *
- * @param risingEdge  true to interrupt on rising edge
- * @param fallingEdge true to interrupt on falling edge
- */
 void InterruptableSensorBase::SetUpSourceEdge(bool risingEdge,
                                               bool fallingEdge) {
   if (StatusIsFatal()) return;
diff --git a/frc971/wpilib/ahal/InterruptableSensorBase.h b/frc971/wpilib/ahal/InterruptableSensorBase.h
index e19e09b..59ddc9e 100644
--- a/frc971/wpilib/ahal/InterruptableSensorBase.h
+++ b/frc971/wpilib/ahal/InterruptableSensorBase.h
@@ -9,9 +9,10 @@
 
 #include <memory>
 
-#include "HAL/Interrupts.h"
 #include "frc971/wpilib/ahal/AnalogTriggerType.h"
 #include "frc971/wpilib/ahal/SensorBase.h"
+#include "hal/Interrupts.h"
+#include "hal/cpp/fpga_clock.h"
 
 namespace frc {
 
@@ -26,24 +27,36 @@
 
   InterruptableSensorBase();
   virtual ~InterruptableSensorBase() = default;
+
   virtual HAL_Handle GetPortHandleForRouting() const = 0;
   virtual AnalogTriggerType GetAnalogTriggerTypeForRouting() const = 0;
-  virtual void RequestInterrupts(
-      HAL_InterruptHandlerFunction handler,
-      void *param);                  ///< Asynchronous handler version.
-  virtual void RequestInterrupts();  ///< Synchronous Wait version.
-  virtual void
-  CancelInterrupts();  ///< Free up the underlying chipobject functions.
-  virtual WaitResult WaitForInterrupt(
-      double timeout,
-      bool ignorePrevious = true);  ///< Synchronous version.
-  virtual void
-  EnableInterrupts();  ///< Enable interrupts - after finishing setup.
-  virtual void DisableInterrupts();       ///< Disable, but don't deallocate.
-  virtual double ReadRisingTimestamp();   ///< Return the timestamp for the
-                                          /// rising interrupt that occurred.
-  virtual double ReadFallingTimestamp();  ///< Return the timestamp for the
-                                          /// falling interrupt that occurred.
+
+  // Requests interrupts in synchronous mode. This means you should call
+  // WaitForInterrupt to receive interrupts.
+  virtual void RequestInterrupts();
+
+  // Prevents any more interrupts from occuring.
+  virtual void CancelInterrupts();
+
+  // Waits for an interrupt or timeout to occur.
+  //
+  // Must be synchronized with all other operations on the input.
+  //
+  // timeout is in seconds.
+  virtual WaitResult WaitForInterrupt(double timeout,
+                                      bool ignorePrevious = true);
+
+  // Enables interrupts to occur based on the current configuration.
+  virtual void EnableInterrupts();
+
+  // Returns the timestamp for the most recent rising interrupt.
+  virtual hal::fpga_clock::time_point ReadRisingTimestamp();
+  // Returns the timestamp for the most recent falling interrupt.
+  virtual hal::fpga_clock::time_point ReadFallingTimestamp();
+
+  // Configures which edges to interrupt on.
+  //
+  // The default is on rising edges only.
   virtual void SetUpSourceEdge(bool risingEdge, bool fallingEdge);
 
  protected:
diff --git a/frc971/wpilib/ahal/PWM.cc b/frc971/wpilib/ahal/PWM.cc
index 9407a9c..0bf38a3 100644
--- a/frc971/wpilib/ahal/PWM.cc
+++ b/frc971/wpilib/ahal/PWM.cc
@@ -5,13 +5,13 @@
 /* the project.                                                               */
 /*----------------------------------------------------------------------------*/
 
-#include "HAL/PWM.h"
+#include "hal/PWM.h"
 #include "frc971/wpilib/ahal/PWM.h"
 
 #include <sstream>
 
-#include "HAL/HAL.h"
-#include "HAL/Ports.h"
+#include "hal/HAL.h"
+#include "hal/Ports.h"
 #include "frc971/wpilib/ahal/Utility.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
 
diff --git a/frc971/wpilib/ahal/PWM.h b/frc971/wpilib/ahal/PWM.h
index 9af8d0f..c6e7a25 100644
--- a/frc971/wpilib/ahal/PWM.h
+++ b/frc971/wpilib/ahal/PWM.h
@@ -10,7 +10,7 @@
 #include <memory>
 #include <string>
 
-#include "HAL/Types.h"
+#include "hal/Types.h"
 #include "frc971/wpilib/ahal/SensorBase.h"
 
 namespace frc {
diff --git a/frc971/wpilib/ahal/PowerDistributionPanel.cc b/frc971/wpilib/ahal/PowerDistributionPanel.cc
index 90655c2..d9d106b 100644
--- a/frc971/wpilib/ahal/PowerDistributionPanel.cc
+++ b/frc971/wpilib/ahal/PowerDistributionPanel.cc
@@ -9,9 +9,9 @@
 
 #include <sstream>
 
-#include "HAL/HAL.h"
-#include "HAL/PDP.h"
-#include "HAL/Ports.h"
+#include "hal/HAL.h"
+#include "hal/PDP.h"
+#include "hal/Ports.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
 
 using namespace frc;
diff --git a/frc971/wpilib/ahal/Relay.cc b/frc971/wpilib/ahal/Relay.cc
index b69e7af..e0cd090 100644
--- a/frc971/wpilib/ahal/Relay.cc
+++ b/frc971/wpilib/ahal/Relay.cc
@@ -5,13 +5,13 @@
 /* the project.                                                               */
 /*----------------------------------------------------------------------------*/
 
-#include "HAL/Relay.h"
+#include "hal/Relay.h"
 #include "frc971/wpilib/ahal/Relay.h"
 
 #include <sstream>
 
-#include "HAL/HAL.h"
-#include "HAL/Ports.h"
+#include "hal/HAL.h"
+#include "hal/Ports.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
 
 using namespace frc;
diff --git a/frc971/wpilib/ahal/Relay.h b/frc971/wpilib/ahal/Relay.h
index ecdd8af..389947c 100644
--- a/frc971/wpilib/ahal/Relay.h
+++ b/frc971/wpilib/ahal/Relay.h
@@ -10,7 +10,7 @@
 #include <memory>
 #include <string>
 
-#include "HAL/Types.h"
+#include "hal/Types.h"
 #include "frc971/wpilib/ahal/SensorBase.h"
 
 namespace frc {
diff --git a/frc971/wpilib/ahal/RobotBase.cc b/frc971/wpilib/ahal/RobotBase.cc
index 35e5570..1ce1d4e 100644
--- a/frc971/wpilib/ahal/RobotBase.cc
+++ b/frc971/wpilib/ahal/RobotBase.cc
@@ -9,7 +9,7 @@
 
 #include <cstdio>
 
-#include "HAL/HAL.h"
+#include "hal/HAL.h"
 #include "frc971/wpilib/ahal/DriverStation.h"
 #include "frc971/wpilib/ahal/Utility.h"
 #include "frc971/wpilib/ahal/WPILibVersion.h"
diff --git a/frc971/wpilib/ahal/RobotBase.h b/frc971/wpilib/ahal/RobotBase.h
index da37e06..df91525 100644
--- a/frc971/wpilib/ahal/RobotBase.h
+++ b/frc971/wpilib/ahal/RobotBase.h
@@ -11,7 +11,7 @@
 #include <iostream>
 #include <thread>
 
-#include "HAL/HAL.h"
+#include "hal/HAL.h"
 #include "frc971/wpilib/ahal/Base.h"
 
 namespace frc {
diff --git a/frc971/wpilib/ahal/SPI.cc b/frc971/wpilib/ahal/SPI.cc
index 84a72db..00e7dc9 100644
--- a/frc971/wpilib/ahal/SPI.cc
+++ b/frc971/wpilib/ahal/SPI.cc
@@ -5,13 +5,13 @@
 /* the project.                                                               */
 /*----------------------------------------------------------------------------*/
 
-#include "HAL/SPI.h"
+#include "hal/SPI.h"
 #include "frc971/wpilib/ahal/SPI.h"
 
 #include <cstring>
 
-#include "HAL/HAL.h"
-#include "llvm/SmallVector.h"
+#include "hal/HAL.h"
+#include "wpi/SmallVector.h"
 
 using namespace frc;
 
@@ -87,7 +87,7 @@
 int SPI::Read(bool initiate, uint8_t *dataReceived, int size) {
   int retVal = 0;
   if (initiate) {
-    llvm::SmallVector<uint8_t, 32> dataToSend;
+    wpi::SmallVector<uint8_t, 32> dataToSend;
     dataToSend.resize(size);
     retVal = HAL_TransactionSPI(m_port, dataToSend.data(), dataReceived, size);
   } else {
diff --git a/frc971/wpilib/ahal/SPI.h b/frc971/wpilib/ahal/SPI.h
index dbac4ae..898f426 100644
--- a/frc971/wpilib/ahal/SPI.h
+++ b/frc971/wpilib/ahal/SPI.h
@@ -7,7 +7,7 @@
 
 #pragma once
 
-#include "HAL/SPI.h"
+#include "hal/SPI.h"
 
 namespace frc {
 
diff --git a/frc971/wpilib/ahal/SensorBase.cc b/frc971/wpilib/ahal/SensorBase.cc
index c6db447..0b796f1 100644
--- a/frc971/wpilib/ahal/SensorBase.cc
+++ b/frc971/wpilib/ahal/SensorBase.cc
@@ -8,15 +8,15 @@
 #include "frc971/wpilib/ahal/SensorBase.h"
 
 #include "FRC_NetworkCommunication/LoadOut.h"
-#include "HAL/AnalogInput.h"
-#include "HAL/AnalogOutput.h"
-#include "HAL/DIO.h"
-#include "HAL/HAL.h"
-#include "HAL/PDP.h"
-#include "HAL/PWM.h"
-#include "HAL/Ports.h"
-#include "HAL/Relay.h"
-#include "HAL/Solenoid.h"
+#include "hal/AnalogInput.h"
+#include "hal/AnalogOutput.h"
+#include "hal/DIO.h"
+#include "hal/HAL.h"
+#include "hal/PDP.h"
+#include "hal/PWM.h"
+#include "hal/Ports.h"
+#include "hal/Relay.h"
+#include "hal/Solenoid.h"
 #include "frc971/wpilib/ahal/WPIErrors.h"
 
 namespace frc {
diff --git a/frc971/wpilib/ahal/Spark.cc b/frc971/wpilib/ahal/Spark.cc
index 9127931..deb891b 100644
--- a/frc971/wpilib/ahal/Spark.cc
+++ b/frc971/wpilib/ahal/Spark.cc
@@ -7,7 +7,7 @@
 
 #include "frc971/wpilib/ahal/Spark.h"
 
-#include <HAL/HAL.h>
+#include <hal/HAL.h>
 
 using namespace frc;
 
diff --git a/frc971/wpilib/ahal/Talon.cc b/frc971/wpilib/ahal/Talon.cc
index 40d8a77..e3af567 100644
--- a/frc971/wpilib/ahal/Talon.cc
+++ b/frc971/wpilib/ahal/Talon.cc
@@ -7,7 +7,7 @@
 
 #include "frc971/wpilib/ahal/Talon.h"
 
-#include "HAL/HAL.h"
+#include "hal/HAL.h"
 
 using namespace frc;
 
diff --git a/frc971/wpilib/ahal/Utility.cc b/frc971/wpilib/ahal/Utility.cc
index 7a00e42..f4b9f38 100644
--- a/frc971/wpilib/ahal/Utility.cc
+++ b/frc971/wpilib/ahal/Utility.cc
@@ -15,10 +15,12 @@
 #include <cstring>
 #include <sstream>
 
-#include "HAL/DriverStation.h"
-#include "HAL/HAL.h"
 #include "frc971/wpilib/ahal/ErrorBase.h"
-#include "llvm/SmallString.h"
+#include "hal/DriverStation.h"
+#include "hal/HAL.h"
+#include "wpi/Path.h"
+#include "wpi/SmallString.h"
+#include "wpi/raw_ostream.h"
 
 using namespace frc;
 
@@ -28,31 +30,31 @@
  * The users don't call this, but instead use the wpi_assert macros in
  * Utility.h.
  */
-bool wpi_assert_impl(bool conditionValue, llvm::StringRef conditionText,
-                     llvm::StringRef message, llvm::StringRef fileName,
-                     int lineNumber, llvm::StringRef funcName) {
+bool wpi_assert_impl(bool conditionValue, const wpi::Twine &conditionText,
+                     const wpi::Twine &message, wpi::StringRef fileName,
+                     int lineNumber, wpi::StringRef funcName) {
   if (!conditionValue) {
-    std::stringstream locStream;
-    locStream << funcName << " [";
-    llvm::SmallString<128> fileTemp;
-    locStream << basename(fileName.c_str(fileTemp)) << ":" << lineNumber << "]";
+    wpi::SmallString<128> locBuf;
+    wpi::raw_svector_ostream locStream(locBuf);
+    locStream << funcName << " [" << wpi::sys::path::filename(fileName) << ":"
+              << lineNumber << "]";
 
-    std::stringstream errorStream;
+    wpi::SmallString<128> errorBuf;
+    wpi::raw_svector_ostream errorStream(errorBuf);
 
     errorStream << "Assertion \"" << conditionText << "\" ";
 
-    if (message[0] != '\0') {
-      errorStream << "failed: " << message << std::endl;
+    if (message.isTriviallyEmpty() ||
+        (message.isSingleStringRef() && message.getSingleStringRef().empty())) {
+      errorStream << "failed.\n";
     } else {
-      errorStream << "failed." << std::endl;
+      errorStream << "failed: " << message << "\n";
     }
 
     std::string stack = GetStackTrace(2);
-    std::string location = locStream.str();
-    std::string error = errorStream.str();
 
     // Print the error and send it to the DriverStation
-    HAL_SendError(1, 1, 0, error.c_str(), location.c_str(), stack.c_str(), 1);
+    HAL_SendError(1, 1, 0, errorBuf.c_str(), locBuf.c_str(), stack.c_str(), 1);
   }
 
   return conditionValue;
@@ -63,33 +65,34 @@
  * This should not be called directly; it should only be used by
  * wpi_assertEqual_impl and wpi_assertNotEqual_impl.
  */
-void wpi_assertEqual_common_impl(llvm::StringRef valueA, llvm::StringRef valueB,
-                                 llvm::StringRef equalityType,
-                                 llvm::StringRef message,
-                                 llvm::StringRef fileName, int lineNumber,
-                                 llvm::StringRef funcName) {
-  std::stringstream locStream;
-  locStream << funcName << " [";
-  llvm::SmallString<128> fileTemp;
-  locStream << basename(fileName.c_str(fileTemp)) << ":" << lineNumber << "]";
+void wpi_assertEqual_common_impl(const wpi::Twine &valueA,
+                                 const wpi::Twine &valueB,
+                                 const wpi::Twine &equalityType,
+                                 const wpi::Twine &message,
+                                 wpi::StringRef fileName, int lineNumber,
+                                 wpi::StringRef funcName) {
+  wpi::SmallString<128> locBuf;
+  wpi::raw_svector_ostream locStream(locBuf);
+  locStream << funcName << " [" << wpi::sys::path::filename(fileName) << ":"
+            << lineNumber << "]";
 
-  std::stringstream errorStream;
+  wpi::SmallString<128> errorBuf;
+  wpi::raw_svector_ostream errorStream(errorBuf);
 
   errorStream << "Assertion \"" << valueA << " " << equalityType << " "
               << valueB << "\" ";
 
-  if (message[0] != '\0') {
-    errorStream << "failed: " << message << std::endl;
+  if (message.isTriviallyEmpty() ||
+      (message.isSingleStringRef() && message.getSingleStringRef().empty())) {
+    errorStream << "failed.\n";
   } else {
-    errorStream << "failed." << std::endl;
+    errorStream << "failed: " << message << "\n";
   }
 
   std::string trace = GetStackTrace(3);
-  std::string location = locStream.str();
-  std::string error = errorStream.str();
 
   // Print the error and send it to the DriverStation
-  HAL_SendError(1, 1, 0, error.c_str(), location.c_str(), trace.c_str(), 1);
+  HAL_SendError(1, 1, 0, errorBuf.c_str(), locBuf.c_str(), trace.c_str(), 1);
 }
 
 /**
@@ -99,10 +102,11 @@
  * The users don't call this, but instead use the wpi_assertEqual macros in
  * Utility.h.
  */
-bool wpi_assertEqual_impl(int valueA, int valueB, llvm::StringRef valueAString,
-                          llvm::StringRef valueBString, llvm::StringRef message,
-                          llvm::StringRef fileName, int lineNumber,
-                          llvm::StringRef funcName) {
+bool wpi_assertEqual_impl(int valueA, int valueB,
+                          const wpi::Twine &valueAString,
+                          const wpi::Twine &valueBString,
+                          const wpi::Twine &message, wpi::StringRef fileName,
+                          int lineNumber, wpi::StringRef funcName) {
   if (!(valueA == valueB)) {
     wpi_assertEqual_common_impl(valueAString, valueBString, "==", message,
                                 fileName, lineNumber, funcName);
@@ -118,10 +122,10 @@
  * Utility.h.
  */
 bool wpi_assertNotEqual_impl(int valueA, int valueB,
-                             llvm::StringRef valueAString,
-                             llvm::StringRef valueBString,
-                             llvm::StringRef message, llvm::StringRef fileName,
-                             int lineNumber, llvm::StringRef funcName) {
+                             const wpi::Twine &valueAString,
+                             const wpi::Twine &valueBString,
+                             const wpi::Twine &message, wpi::StringRef fileName,
+                             int lineNumber, wpi::StringRef funcName) {
   if (!(valueA != valueB)) {
     wpi_assertEqual_common_impl(valueAString, valueBString, "!=", message,
                                 fileName, lineNumber, funcName);
diff --git a/frc971/wpilib/ahal/Utility.h b/frc971/wpilib/ahal/Utility.h
index bf97692..be8dc35 100644
--- a/frc971/wpilib/ahal/Utility.h
+++ b/frc971/wpilib/ahal/Utility.h
@@ -15,7 +15,8 @@
 
 #include <string>
 
-#include "llvm/StringRef.h"
+#include "wpi/StringRef.h"
+#include "wpi/Twine.h"
 
 #define wpi_assert(condition) \
   wpi_assert_impl(condition, #condition, "", __FILE__, __LINE__, __FUNCTION__)
@@ -34,18 +35,19 @@
   wpi_assertNotEqual_impl(a, b, #a, #b, message, __FILE__, __LINE__, \
                           __FUNCTION__)
 
-bool wpi_assert_impl(bool conditionValue, llvm::StringRef conditionText,
-                     llvm::StringRef message, llvm::StringRef fileName,
-                     int lineNumber, llvm::StringRef funcName);
-bool wpi_assertEqual_impl(int valueA, int valueB, llvm::StringRef valueAString,
-                          llvm::StringRef valueBString, llvm::StringRef message,
-                          llvm::StringRef fileName, int lineNumber,
-                          llvm::StringRef funcName);
+bool wpi_assert_impl(bool conditionValue, const wpi::Twine &conditionText,
+                     const wpi::Twine &message, wpi::StringRef fileName,
+                     int lineNumber, wpi::StringRef funcName);
+bool wpi_assertEqual_impl(int valueA, int valueB,
+                          const wpi::Twine &valueAString,
+                          const wpi::Twine &valueBString,
+                          const wpi::Twine &message, wpi::StringRef fileName,
+                          int lineNumber, wpi::StringRef funcName);
 bool wpi_assertNotEqual_impl(int valueA, int valueB,
-                             llvm::StringRef valueAString,
-                             llvm::StringRef valueBString,
-                             llvm::StringRef message, llvm::StringRef fileName,
-                             int lineNumber, llvm::StringRef funcName);
+                             const wpi::Twine &valueAString,
+                             const wpi::Twine &valueBString,
+                             const wpi::Twine &message, wpi::StringRef fileName,
+                             int lineNumber, wpi::StringRef funcName);
 
 void wpi_suspendOnAssertEnabled(bool enabled);
 
diff --git a/frc971/wpilib/ahal/VictorSP.cc b/frc971/wpilib/ahal/VictorSP.cc
index 7d1741b..fee03a9 100644
--- a/frc971/wpilib/ahal/VictorSP.cc
+++ b/frc971/wpilib/ahal/VictorSP.cc
@@ -7,7 +7,7 @@
 
 #include "frc971/wpilib/ahal/VictorSP.h"
 
-#include "HAL/HAL.h"
+#include "hal/HAL.h"
 
 using namespace frc;
 
diff --git a/frc971/wpilib/buffered_pcm.cc b/frc971/wpilib/buffered_pcm.cc
index 9625073..de8c547 100644
--- a/frc971/wpilib/buffered_pcm.cc
+++ b/frc971/wpilib/buffered_pcm.cc
@@ -2,10 +2,10 @@
 
 #include <inttypes.h>
 
-#include <HAL/HAL.h>
-#include <HAL/Ports.h>
-#include <HAL/Solenoid.h>
 #include "aos/logging/logging.h"
+#include "hal/HAL.h"
+#include "hal/Ports.h"
+#include "hal/Solenoid.h"
 
 namespace frc971 {
 namespace wpilib {
diff --git a/frc971/wpilib/buffered_pcm.h b/frc971/wpilib/buffered_pcm.h
index 877e830..033ded6 100644
--- a/frc971/wpilib/buffered_pcm.h
+++ b/frc971/wpilib/buffered_pcm.h
@@ -3,7 +3,7 @@
 
 #include <memory>
 
-#include <HAL/HAL.h>
+#include <hal/HAL.h>
 
 #include "frc971/wpilib/buffered_solenoid.h"
 
diff --git a/frc971/wpilib/dma.cc b/frc971/wpilib/dma.cc
index a379262..b990532 100644
--- a/frc971/wpilib/dma.cc
+++ b/frc971/wpilib/dma.cc
@@ -5,10 +5,10 @@
 #include <algorithm>
 #include <type_traits>
 
-#include "HAL/HAL.h"
 #include "frc971/wpilib/ahal/AnalogInput.h"
 #include "frc971/wpilib/ahal/DigitalSource.h"
 #include "frc971/wpilib/ahal/Encoder.h"
+#include "hal/HAL.h"
 
 // Interface to the roboRIO FPGA's DMA features.
 
diff --git a/frc971/wpilib/dma.h b/frc971/wpilib/dma.h
index c870728..6d82af8 100644
--- a/frc971/wpilib/dma.h
+++ b/frc971/wpilib/dma.h
@@ -9,7 +9,7 @@
 #include <array>
 #include <memory>
 
-#include "HAL/ChipObject.h"
+#include "hal/ChipObject.h"
 
 class DMA;
 namespace frc {
diff --git a/frc971/wpilib/joystick_sender.cc b/frc971/wpilib/joystick_sender.cc
index e005475..6a3281b 100644
--- a/frc971/wpilib/joystick_sender.cc
+++ b/frc971/wpilib/joystick_sender.cc
@@ -5,8 +5,8 @@
 #include "aos/network/team_number.h"
 #include "aos/logging/queue_logging.h"
 
-#include "HAL/HAL.h"
 #include "frc971/wpilib/ahal/DriverStation.h"
+#include "hal/HAL.h"
 
 namespace frc971 {
 namespace wpilib {
@@ -32,7 +32,6 @@
         new_state->scale_left = match_info.gameSpecificMessage[1] == 'L' ||
                                 match_info.gameSpecificMessage[1] == 'l';
       }
-      HAL_FreeMatchInfo(&match_info);
 
       new_state->test_mode = ds->IsTestMode();
       new_state->fms_attached = ds->IsFmsAttached();
diff --git a/frc971/wpilib/wpilib_interface.cc b/frc971/wpilib/wpilib_interface.cc
index 8db81e1..4dddd91 100644
--- a/frc971/wpilib/wpilib_interface.cc
+++ b/frc971/wpilib/wpilib_interface.cc
@@ -3,7 +3,7 @@
 #include "aos/robot_state/robot_state.q.h"
 #include "aos/logging/queue_logging.h"
 
-#include <HAL/HAL.h>
+#include "hal/HAL.h"
 
 namespace frc971 {
 namespace wpilib {