Browse Source

SPI performance tweak

Scott Lahteine 4 years ago
parent
commit
eebb68cd7f

+ 1
- 1
Marlin/src/HAL/LPC1768/include/SPI.h View File

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

+ 2
- 2
Marlin/src/HAL/STM32F1/SPI.cpp View File

@@ -243,7 +243,7 @@ void SPIClass::setDataMode(uint8_t dataMode) {
243 243
   _currentSetting->spi_d->regs->CR1 = cr1 | (dataMode & (SPI_CR1_CPOL|SPI_CR1_CPHA));
244 244
 }
245 245
 
246
-void SPIClass::beginTransaction(uint8_t pin, SPISettings settings) {
246
+void SPIClass::beginTransaction(uint8_t pin, const SPISettings &settings) {
247 247
   setBitOrder(settings.bitOrder);
248 248
   setDataMode(settings.dataMode);
249 249
   setDataSize(settings.dataSize);
@@ -251,7 +251,7 @@ void SPIClass::beginTransaction(uint8_t pin, SPISettings settings) {
251 251
   begin();
252 252
 }
253 253
 
254
-void SPIClass::beginTransactionSlave(SPISettings settings) {
254
+void SPIClass::beginTransactionSlave(const SPISettings &settings) {
255 255
   setBitOrder(settings.bitOrder);
256 256
   setDataMode(settings.dataMode);
257 257
   setDataSize(settings.dataSize);

+ 4
- 3
Marlin/src/HAL/STM32F1/SPI.h View File

@@ -126,6 +126,7 @@ private:
126 126
     bitOrder = inBitOrder;
127 127
     dataMode = inDataMode;
128 128
     dataSize = inDataSize;
129
+    //state    = SPI_STATE_IDLE;
129 130
   }
130 131
   uint32_t clock;
131 132
   uint32_t dataSize;
@@ -187,11 +188,11 @@ public:
187 188
    */
188 189
   void end();
189 190
 
190
-  void beginTransaction(SPISettings settings) { beginTransaction(BOARD_SPI_DEFAULT_SS, settings); }
191
-  void beginTransaction(uint8_t pin, SPISettings settings);
191
+  void beginTransaction(const SPISettings &settings) { beginTransaction(BOARD_SPI_DEFAULT_SS, settings); }
192
+  void beginTransaction(uint8_t pin, const SPISettings &settings);
192 193
   void endTransaction();
193 194
 
194
-  void beginTransactionSlave(SPISettings settings);
195
+  void beginTransactionSlave(const SPISettings &settings);
195 196
 
196 197
   void setClockDivider(uint32_t clockDivider);
197 198
   void setBitOrder(BitOrder bitOrder);

Loading…
Cancel
Save