[wpilibc] Use std::atomic in ADIS classes (#6217)

This commit is contained in:
Isaac Turner
2024-01-16 14:42:19 +08:00
committed by GitHub
parent 5bc942f532
commit 30965b20cf
4 changed files with 228 additions and 11 deletions

View File

@@ -15,6 +15,7 @@
#include <stdint.h>
#include <atomic>
#include <thread>
#include <hal/SimDevice.h>
@@ -114,8 +115,8 @@ class ADIS16448_IMU : public wpi::Sendable,
~ADIS16448_IMU() override;
ADIS16448_IMU(ADIS16448_IMU&&) = default;
ADIS16448_IMU& operator=(ADIS16448_IMU&&) = default;
ADIS16448_IMU(ADIS16448_IMU&&);
ADIS16448_IMU& operator=(ADIS16448_IMU&&);
/**
* Initialize the IMU.
@@ -414,10 +415,10 @@ class ADIS16448_IMU : public wpi::Sendable,
double CompFilterProcess(double compAngle, double accelAngle, double omega);
// State and resource variables
volatile bool m_thread_active = false;
volatile bool m_first_run = true;
volatile bool m_thread_idle = false;
volatile bool m_start_up_mode = true;
std::atomic<bool> m_thread_active = false;
std::atomic<bool> m_first_run = true;
std::atomic<bool> m_thread_idle = false;
std::atomic<bool> m_start_up_mode = true;
bool m_auto_configured = false;
SPI::Port m_spi_port;

View File

@@ -15,6 +15,7 @@
#include <stdint.h>
#include <atomic>
#include <thread>
#include <hal/SimDevice.h>
@@ -143,8 +144,8 @@ class ADIS16470_IMU : public wpi::Sendable,
~ADIS16470_IMU() override;
ADIS16470_IMU(ADIS16470_IMU&&) = default;
ADIS16470_IMU& operator=(ADIS16470_IMU&&) = default;
ADIS16470_IMU(ADIS16470_IMU&& other);
ADIS16470_IMU& operator=(ADIS16470_IMU&& other);
/**
* Configures the decimation rate of the IMU.
@@ -500,9 +501,9 @@ class ADIS16470_IMU : public wpi::Sendable,
double CompFilterProcess(double compAngle, double accelAngle, double omega);
// State and resource variables
volatile bool m_thread_active = false;
volatile bool m_first_run = true;
volatile bool m_thread_idle = false;
std::atomic<bool> m_thread_active = false;
std::atomic<bool> m_first_run = true;
std::atomic<bool> m_thread_idle = false;
bool m_auto_configured = false;
SPI::Port m_spi_port;
uint16_t m_calibration_time = 0;