mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
Makes SPI edge changes more obvious (#1056)
Rising and Falling mean the opposite when active is set high vs low. Leading and trailing makes much more sense. Closes #925
This commit is contained in:
committed by
Peter Johnson
parent
560123ab7d
commit
ab70220ecf
@@ -92,7 +92,7 @@ public class ADXL345_SPI extends SensorBase implements Accelerometer, Sendable {
|
||||
private void init(Range range) {
|
||||
m_spi.setClockRate(500000);
|
||||
m_spi.setMSBFirst();
|
||||
m_spi.setSampleDataOnFalling();
|
||||
m_spi.setSampleDataOnTrailingEdge();
|
||||
m_spi.setClockActiveLow();
|
||||
m_spi.setChipSelectActiveHigh();
|
||||
|
||||
|
||||
@@ -83,7 +83,7 @@ public class ADXL362 extends SensorBase implements Accelerometer, Sendable {
|
||||
|
||||
m_spi.setClockRate(3000000);
|
||||
m_spi.setMSBFirst();
|
||||
m_spi.setSampleDataOnFalling();
|
||||
m_spi.setSampleDataOnTrailingEdge();
|
||||
m_spi.setClockActiveLow();
|
||||
m_spi.setChipSelectActiveLow();
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ public class ADXRS450_Gyro extends GyroBase implements Gyro, PIDSource, Sendable
|
||||
|
||||
m_spi.setClockRate(3000000);
|
||||
m_spi.setMSBFirst();
|
||||
m_spi.setSampleDataOnRising();
|
||||
m_spi.setSampleDataOnLeadingEdge();
|
||||
m_spi.setClockActiveHigh();
|
||||
m_spi.setChipSelectActiveLow();
|
||||
|
||||
|
||||
@@ -107,8 +107,29 @@ public class SPI {
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure that the data is stable on the falling edge and the data changes on the rising edge.
|
||||
* Configure that the data is stable on the leading edge and the data changes on the trailing
|
||||
* edge.
|
||||
*/
|
||||
public final void setSampleDataOnLeadingEdge() {
|
||||
m_dataOnTrailing = 0;
|
||||
SPIJNI.spiSetOpts(m_port, m_bitOrder, m_dataOnTrailing, m_clockPolarity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure that the data is stable on the trailing edge and the data changes on the leading
|
||||
* edge.
|
||||
*/
|
||||
public final void setSampleDataOnTrailingEdge() {
|
||||
m_dataOnTrailing = 1;
|
||||
SPIJNI.spiSetOpts(m_port, m_bitOrder, m_dataOnTrailing, m_clockPolarity);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure that the data is stable on the falling edge and the data changes on the rising edge.
|
||||
* Note this gets reversed is setClockActiveLow is set.
|
||||
* @deprecated use {@link #setSampleDataOnTrailingEdge()} in most cases.
|
||||
*/
|
||||
@Deprecated
|
||||
public final void setSampleDataOnFalling() {
|
||||
m_dataOnTrailing = 1;
|
||||
SPIJNI.spiSetOpts(m_port, m_bitOrder, m_dataOnTrailing, m_clockPolarity);
|
||||
@@ -116,12 +137,17 @@ public class SPI {
|
||||
|
||||
/**
|
||||
* Configure that the data is stable on the rising edge and the data changes on the falling edge.
|
||||
* Note this gets reversed is setClockActiveLow is set.
|
||||
* @deprecated use {@link #setSampleDataOnLeadingEdge()} in most cases.
|
||||
*/
|
||||
@Deprecated
|
||||
public final void setSampleDataOnRising() {
|
||||
m_dataOnTrailing = 0;
|
||||
SPIJNI.spiSetOpts(m_port, m_bitOrder, m_dataOnTrailing, m_clockPolarity);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Configure the chip select line to be active high.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user