Add kInvalid value to HAL_I2CPort and HAL_SPIPort (#1329)

This allows HAL_CloseI2C() and HAL_CloseSPI() to be noops, which makes
enabling move semantics in the I2C and SPI wpilibc classes easier and
cleaner.

Fixes #1328.
This commit is contained in:
Tyler Veness
2018-09-23 21:14:04 -07:00
committed by Peter Johnson
parent b505bbefd1
commit 467c9fd686
6 changed files with 23 additions and 23 deletions

View File

@@ -9,9 +9,9 @@
#include <stdint.h>
#include "frc/ErrorBase.h"
#include <hal/I2C.h>
enum HAL_I2CPort : int32_t;
#include "frc/ErrorBase.h"
namespace frc {
@@ -135,7 +135,7 @@ class I2C : public ErrorBase {
bool VerifySensor(int registerAddress, int count, const uint8_t* expected);
private:
HAL_I2CPort m_port;
HAL_I2CPort m_port = HAL_I2C_kInvalid;
int m_deviceAddress;
};

View File

@@ -11,13 +11,12 @@
#include <memory>
#include <hal/SPI.h>
#include <wpi/ArrayRef.h>
#include <wpi/deprecated.h>
#include "frc/ErrorBase.h"
enum HAL_SPIPort : int32_t;
namespace frc {
class DigitalSource;
@@ -315,7 +314,7 @@ class SPI : public ErrorBase {
void GetAccumulatorOutput(int64_t& value, int64_t& count) const;
protected:
HAL_SPIPort m_port;
HAL_SPIPort m_port = HAL_SPI_kInvalid;
bool m_msbFirst = false; // Default little-endian
bool m_sampleOnTrailing = false; // Default data updated on falling edge
bool m_clockIdleHigh = false; // Default clock active high