mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Initial commit of cross connect integration test project (#3434)
Adding as a separate project so current integration tests stay working.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// 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 <array>
|
||||
#include <utility>
|
||||
|
||||
namespace hlt {
|
||||
|
||||
constexpr static std::array<std::pair<int, int>, 22> DIOCrossConnects{
|
||||
std::pair{20, 25},
|
||||
std::pair{19, 24},
|
||||
std::pair{17, 13},
|
||||
std::pair{16, 12},
|
||||
std::pair{15, 11},
|
||||
std::pair{14, 10},
|
||||
std::pair{26, 2},
|
||||
std::pair{27, 1},
|
||||
std::pair{28, 0},
|
||||
std::pair{29, 3},
|
||||
std::pair{30, 4},
|
||||
|
||||
// Opposite direction
|
||||
std::pair{25, 20},
|
||||
std::pair{24, 19},
|
||||
std::pair{13, 17},
|
||||
std::pair{12, 16},
|
||||
std::pair{11, 15},
|
||||
std::pair{10, 14},
|
||||
std::pair{2, 26},
|
||||
std::pair{1, 27},
|
||||
std::pair{0, 28},
|
||||
std::pair{3, 29},
|
||||
std::pair{4, 30},
|
||||
};
|
||||
|
||||
// PWM on left, DIO on right
|
||||
constexpr static std::array<std::pair<int, int>, 2> PWMCrossConnects{
|
||||
std::pair{0, 18},
|
||||
std::pair{16, 25},
|
||||
};
|
||||
|
||||
} // namespace hlt
|
||||
@@ -0,0 +1,82 @@
|
||||
// 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 <hal/HAL.h>
|
||||
|
||||
namespace hlt {
|
||||
|
||||
struct InterruptHandle {
|
||||
public:
|
||||
explicit InterruptHandle(int32_t* status) {
|
||||
handle = HAL_InitializeInterrupts(status);
|
||||
}
|
||||
InterruptHandle(const InterruptHandle&) = delete;
|
||||
InterruptHandle operator=(const InterruptHandle&) = delete;
|
||||
|
||||
InterruptHandle(InterruptHandle&&) = default;
|
||||
InterruptHandle& operator=(InterruptHandle&&) = default;
|
||||
|
||||
~InterruptHandle() { HAL_CleanInterrupts(handle); }
|
||||
|
||||
operator HAL_InterruptHandle() const { return handle; }
|
||||
|
||||
private:
|
||||
HAL_InterruptHandle handle = 0;
|
||||
};
|
||||
|
||||
struct DIOHandle {
|
||||
public:
|
||||
DIOHandle() {}
|
||||
DIOHandle(const DIOHandle&) = delete;
|
||||
DIOHandle operator=(const DIOHandle&) = delete;
|
||||
|
||||
DIOHandle(DIOHandle&&) = default;
|
||||
DIOHandle& operator=(DIOHandle&&) = default;
|
||||
|
||||
DIOHandle(int32_t port, HAL_Bool input, int32_t* status) {
|
||||
handle = HAL_InitializeDIOPort(HAL_GetPort(port), input, nullptr, status);
|
||||
}
|
||||
|
||||
~DIOHandle() { HAL_FreeDIOPort(handle); }
|
||||
|
||||
operator HAL_DigitalHandle() const { return handle; }
|
||||
|
||||
private:
|
||||
HAL_DigitalHandle handle = 0;
|
||||
};
|
||||
|
||||
struct PWMHandle {
|
||||
public:
|
||||
PWMHandle() {}
|
||||
PWMHandle(const PWMHandle&) = delete;
|
||||
PWMHandle operator=(const PWMHandle&) = delete;
|
||||
|
||||
PWMHandle(PWMHandle&&) = default;
|
||||
PWMHandle& operator=(PWMHandle&&) = default;
|
||||
|
||||
PWMHandle(int32_t port, int32_t* status) {
|
||||
handle = HAL_InitializePWMPort(HAL_GetPort(port), nullptr, status);
|
||||
}
|
||||
|
||||
~PWMHandle() {
|
||||
int32_t status = 0;
|
||||
HAL_FreePWMPort(handle, &status);
|
||||
}
|
||||
|
||||
operator HAL_DigitalHandle() const { return handle; }
|
||||
|
||||
private:
|
||||
HAL_DigitalHandle handle = 0;
|
||||
};
|
||||
|
||||
#define ASSERT_LAST_ERROR_STATUS(status, x) \
|
||||
do { \
|
||||
ASSERT_EQ(status, HAL_USE_LAST_ERROR); \
|
||||
const char* lastErrorMessageInMacro = HAL_GetLastError(&status); \
|
||||
ASSERT_EQ(status, x); \
|
||||
} while (0)
|
||||
|
||||
} // namespace hlt
|
||||
Reference in New Issue
Block a user