mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +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
@@ -23,7 +23,7 @@ ADXL345_SPI::ADXL345_SPI(SPI::Port port, ADXL345_SPI::Range range)
|
||||
: m_spi(port) {
|
||||
m_spi.SetClockRate(500000);
|
||||
m_spi.SetMSBFirst();
|
||||
m_spi.SetSampleDataOnFalling();
|
||||
m_spi.SetSampleDataOnTrailingEdge();
|
||||
m_spi.SetClockActiveLow();
|
||||
m_spi.SetChipSelectActiveHigh();
|
||||
|
||||
|
||||
@@ -47,7 +47,7 @@ ADXL362::ADXL362(Range range) : ADXL362(SPI::Port::kOnboardCS1, range) {}
|
||||
ADXL362::ADXL362(SPI::Port port, Range range) : m_spi(port) {
|
||||
m_spi.SetClockRate(3000000);
|
||||
m_spi.SetMSBFirst();
|
||||
m_spi.SetSampleDataOnFalling();
|
||||
m_spi.SetSampleDataOnTrailingEdge();
|
||||
m_spi.SetClockActiveLow();
|
||||
m_spi.SetChipSelectActiveLow();
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ ADXRS450_Gyro::ADXRS450_Gyro() : ADXRS450_Gyro(SPI::kOnboardCS0) {}
|
||||
ADXRS450_Gyro::ADXRS450_Gyro(SPI::Port port) : m_spi(port) {
|
||||
m_spi.SetClockRate(3000000);
|
||||
m_spi.SetMSBFirst();
|
||||
m_spi.SetSampleDataOnRising();
|
||||
m_spi.SetSampleDataOnLeadingEdge();
|
||||
m_spi.SetClockActiveHigh();
|
||||
m_spi.SetChipSelectActiveLow();
|
||||
|
||||
|
||||
@@ -174,6 +174,24 @@ void SPI::SetLSBFirst() {
|
||||
HAL_SetSPIOpts(m_port, m_msbFirst, m_sampleOnTrailing, m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure that the data is stable on the leading edge and the data
|
||||
* changes on the trailing edge.
|
||||
*/
|
||||
void SPI::SetSampleDataOnLeadingEdge() {
|
||||
m_sampleOnTrailing = false;
|
||||
HAL_SetSPIOpts(m_port, m_msbFirst, m_sampleOnTrailing, m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure that the data is stable on the trailing edge and the data
|
||||
* changes on the leading edge.
|
||||
*/
|
||||
void SPI::SetSampleDataOnTrailingEdge() {
|
||||
m_sampleOnTrailing = true;
|
||||
HAL_SetSPIOpts(m_port, m_msbFirst, m_sampleOnTrailing, m_clk_idle_high);
|
||||
}
|
||||
|
||||
/**
|
||||
* Configure that the data is stable on the falling edge and the data
|
||||
* changes on the rising edge.
|
||||
|
||||
Reference in New Issue
Block a user