mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-22 01:11:42 +00:00
Simulate ADX* family of accelerometers and gyros (#688)
This commit is contained in:
committed by
Peter Johnson
parent
cd1dbb1e3a
commit
303c259b89
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "AccelerometerDataInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "AnalogGyroDataInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "AnalogInDataInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "AnalogOutDataInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "AnalogTriggerDataInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "DIODataInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "DigitalPWMDataInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include "DriverStationDataInternal.h"
|
||||
#include "HAL/cpp/make_unique.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
namespace hal {
|
||||
struct JoystickOutputStore {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "EncoderDataInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "I2CDataInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
|
||||
@@ -1,44 +0,0 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) 2017 FIRST. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include "MockData/NotifyListenerVector.h"
|
||||
|
||||
std::shared_ptr<hal::NotifyListenerVector> RegisterCallback(
|
||||
std::shared_ptr<hal::NotifyListenerVector> currentVector, const char* name,
|
||||
HAL_NotifyCallback callback, void* param, int32_t* newUid);
|
||||
|
||||
std::shared_ptr<hal::NotifyListenerVector> CancelCallback(
|
||||
std::shared_ptr<hal::NotifyListenerVector> currentVector, int32_t uid);
|
||||
|
||||
void InvokeCallback(std::shared_ptr<hal::NotifyListenerVector> currentVector,
|
||||
const char* name, const HAL_Value* value);
|
||||
|
||||
std::shared_ptr<hal::BufferListenerVector> RegisterCallback(
|
||||
std::shared_ptr<hal::BufferListenerVector> currentVector, const char* name,
|
||||
HAL_BufferCallback callback, void* param, int32_t* newUid);
|
||||
|
||||
std::shared_ptr<hal::BufferListenerVector> CancelCallback(
|
||||
std::shared_ptr<hal::BufferListenerVector> currentVector, int32_t uid);
|
||||
|
||||
void InvokeCallback(std::shared_ptr<hal::BufferListenerVector> currentVector,
|
||||
const char* name, uint8_t* buffer, int32_t count);
|
||||
|
||||
std::shared_ptr<hal::ConstBufferListenerVector> RegisterCallback(
|
||||
std::shared_ptr<hal::ConstBufferListenerVector> currentVector,
|
||||
const char* name, HAL_ConstBufferCallback callback, void* param,
|
||||
int32_t* newUid);
|
||||
|
||||
std::shared_ptr<hal::ConstBufferListenerVector> CancelCallback(
|
||||
std::shared_ptr<hal::ConstBufferListenerVector> currentVector, int32_t uid);
|
||||
|
||||
void InvokeCallback(
|
||||
std::shared_ptr<hal::ConstBufferListenerVector> currentVector,
|
||||
const char* name, const uint8_t* buffer, int32_t count);
|
||||
@@ -6,7 +6,7 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
#include "PCMDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
#include "PDPDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
#include "PWMDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
#include "RelayDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
#include "RoboRioDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
#include "SPIAccelerometerDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "../PortsInternal.h"
|
||||
#include "NotifyCallbackHelpers.h"
|
||||
#include "MockData/NotifyCallbackHelpers.h"
|
||||
#include "SPIDataInternal.h"
|
||||
|
||||
using namespace hal;
|
||||
@@ -178,6 +178,9 @@ int32_t SPIData::Write(const uint8_t* dataToSend, int32_t sendSize) {
|
||||
int32_t SPIData::Transaction(const uint8_t* dataToSend, uint8_t* dataReceived,
|
||||
int32_t size) {
|
||||
std::lock_guard<wpi::mutex> lock(m_dataMutex);
|
||||
InvokeCallback(m_writeCallbacks, "Write", dataToSend, size);
|
||||
InvokeCallback(m_readCallbacks, "Read", dataReceived, size);
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user