Browse Source

SPI performance tweak

vanilla_fb_2.0.x
Scott Lahteine 5 years ago
parent
commit
eebb68cd7f
  1. 2
      Marlin/src/HAL/LPC1768/include/SPI.h
  2. 4
      Marlin/src/HAL/STM32F1/SPI.cpp
  3. 7
      Marlin/src/HAL/STM32F1/SPI.h

2
Marlin/src/HAL/LPC1768/include/SPI.h

@ -39,7 +39,7 @@ class SPISettings {
class SPIClass { class SPIClass {
public: public:
void begin(); void begin();
void beginTransaction(SPISettings); void beginTransaction(const SPISettings&);
void endTransaction() {}; void endTransaction() {};
uint8_t transfer(uint8_t data); uint8_t transfer(uint8_t data);
uint16_t transfer16(uint16_t data); uint16_t transfer16(uint16_t data);

4
Marlin/src/HAL/STM32F1/SPI.cpp

@ -243,7 +243,7 @@ void SPIClass::setDataMode(uint8_t dataMode) {
_currentSetting->spi_d->regs->CR1 = cr1 | (dataMode & (SPI_CR1_CPOL|SPI_CR1_CPHA)); _currentSetting->spi_d->regs->CR1 = cr1 | (dataMode & (SPI_CR1_CPOL|SPI_CR1_CPHA));
} }
void SPIClass::beginTransaction(uint8_t pin, SPISettings settings) { void SPIClass::beginTransaction(uint8_t pin, const SPISettings &settings) {
setBitOrder(settings.bitOrder); setBitOrder(settings.bitOrder);
setDataMode(settings.dataMode); setDataMode(settings.dataMode);
setDataSize(settings.dataSize); setDataSize(settings.dataSize);
@ -251,7 +251,7 @@ void SPIClass::beginTransaction(uint8_t pin, SPISettings settings) {
begin(); begin();
} }
void SPIClass::beginTransactionSlave(SPISettings settings) { void SPIClass::beginTransactionSlave(const SPISettings &settings) {
setBitOrder(settings.bitOrder); setBitOrder(settings.bitOrder);
setDataMode(settings.dataMode); setDataMode(settings.dataMode);
setDataSize(settings.dataSize); setDataSize(settings.dataSize);

7
Marlin/src/HAL/STM32F1/SPI.h

@ -126,6 +126,7 @@ private:
bitOrder = inBitOrder; bitOrder = inBitOrder;
dataMode = inDataMode; dataMode = inDataMode;
dataSize = inDataSize; dataSize = inDataSize;
//state = SPI_STATE_IDLE;
} }
uint32_t clock; uint32_t clock;
uint32_t dataSize; uint32_t dataSize;
@ -187,11 +188,11 @@ public:
*/ */
void end(); void end();
void beginTransaction(SPISettings settings) { beginTransaction(BOARD_SPI_DEFAULT_SS, settings); } void beginTransaction(const SPISettings &settings) { beginTransaction(BOARD_SPI_DEFAULT_SS, settings); }
void beginTransaction(uint8_t pin, SPISettings settings); void beginTransaction(uint8_t pin, const SPISettings &settings);
void endTransaction(); void endTransaction();
void beginTransactionSlave(SPISettings settings); void beginTransactionSlave(const SPISettings &settings);
void setClockDivider(uint32_t clockDivider); void setClockDivider(uint32_t clockDivider);
void setBitOrder(BitOrder bitOrder); void setBitOrder(BitOrder bitOrder);

Loading…
Cancel
Save