Skip to content

Commit

Permalink
Fix spi and i2c
Browse files Browse the repository at this point in the history
  • Loading branch information
rzblue committed Aug 30, 2024
1 parent 77c7751 commit 9216158
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 17 deletions.
4 changes: 1 addition & 3 deletions hal/src/main/native/cpp/jni/I2CJNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,7 @@ JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_I2CJNI_i2CClose
(JNIEnv*, jclass, jint port)
{
if (port != HAL_kInvalidHandle) {
HAL_CloseI2C(static_cast<HAL_I2CPort>(port));
}
HAL_CloseI2C(static_cast<HAL_I2CPort>(port));
}

} // extern "C"
4 changes: 1 addition & 3 deletions hal/src/main/native/cpp/jni/SPIJNI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,7 @@ JNIEXPORT void JNICALL
Java_edu_wpi_first_hal_SPIJNI_spiClose
(JNIEnv*, jclass, jint port)
{
if (port != HAL_kInvalidHandle) {
HAL_CloseSPI(static_cast<HAL_SPIPort>(port));
}
HAL_CloseSPI(static_cast<HAL_SPIPort>(port));
}

/*
Expand Down
4 changes: 0 additions & 4 deletions wpilibc/src/main/native/cpp/I2C.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ I2C::I2C(Port port, int deviceAddress)
HAL_Report(HALUsageReporting::kResourceType_I2C, deviceAddress);
}

I2C::~I2C() {
HAL_CloseI2C(m_port);
}

I2C::Port I2C::GetPort() const {
return static_cast<Port>(static_cast<int>(m_port));
}
Expand Down
4 changes: 1 addition & 3 deletions wpilibc/src/main/native/cpp/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,7 @@ SPI::SPI(Port port) : m_port(static_cast<HAL_SPIPort>(port)) {
static_cast<uint8_t>(port) + 1);
}

SPI::~SPI() {
HAL_CloseSPI(m_port);
}
SPI::~SPI() = default;

SPI::Port SPI::GetPort() const {
return static_cast<Port>(static_cast<int>(m_port));
Expand Down
2 changes: 0 additions & 2 deletions wpilibc/src/main/native/include/frc/I2C.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ class I2C {
*/
I2C(Port port, int deviceAddress);

~I2C();

I2C(I2C&&) = default;
I2C& operator=(I2C&&) = default;

Expand Down
4 changes: 2 additions & 2 deletions wpilibc/src/main/native/include/frc/SPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,11 @@ class SPI {
*/
explicit SPI(Port port);

virtual ~SPI();

SPI(SPI&&) = default;
SPI& operator=(SPI&&) = default;

virtual ~SPI();

/**
* Returns the SPI port.
*
Expand Down

0 comments on commit 9216158

Please sign in to comment.