|
28 | 28 | #if !defined(__AVR_ATtiny85__)
|
29 | 29 | #include "./../SPI/src/SPI.h"
|
30 | 30 | #endif
|
31 |
| - |
| 31 | +SPIClass SPI2; |
32 | 32 | #define USE_HW_SPI 255 // Assign this to dataPin to indicate 'hard' SPI
|
33 | 33 |
|
34 | 34 | // Constructor for hardware SPI -- must connect to MOSI, SCK pins
|
@@ -112,30 +112,30 @@ void Adafruit_DotStar::hw_spi_init(void) { // Initialize hardware SPI
|
112 | 112 | PORTB &= ~(_BV(PORTB1) | _BV(PORTB2)); // Outputs
|
113 | 113 | DDRB |= _BV(PORTB1) | _BV(PORTB2); // DO (NOT MOSI) + SCK
|
114 | 114 | #elif (SPI_INTERFACES_COUNT > 0) || !defined(SPI_INTERFACES_COUNT)
|
115 |
| - SPI.begin(); |
| 115 | + SPI2.begin(); |
116 | 116 | #if defined(__AVR__) || defined(CORE_TEENSY) || defined(__ARDUINO_ARC__) || defined(__ARDUINO_X86__)
|
117 |
| - SPI.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (6 MHz on Pro Trinket 3V) |
| 117 | + SPI2.setClockDivider(SPI_CLOCK_DIV2); // 8 MHz (6 MHz on Pro Trinket 3V) |
118 | 118 | #else
|
119 | 119 | #if defined(ESP8266) || defined(ESP31B) || defined(ESP32)
|
120 |
| - SPI.setFrequency(8000000L); |
| 120 | + SPI2.setFrequency(8000000L); |
121 | 121 | #elif defined(PIC32)
|
122 | 122 | // Use begin/end transaction to set SPI clock rate
|
123 |
| - SPI.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); |
124 |
| - SPI.endTransaction(); |
| 123 | + SPI2.beginTransaction(SPISettings(8000000, MSBFIRST, SPI_MODE0)); |
| 124 | + SPI2.endTransaction(); |
125 | 125 | #else
|
126 |
| - SPI.setClockDivider((F_CPU + 4000000L) / 8000000L); // 8-ish MHz on Due |
| 126 | + SPI2.setClockDivider((F_CPU + 4000000L) / 8000000L); // 8-ish MHz on Due |
127 | 127 | #endif
|
128 | 128 | #endif
|
129 |
| - SPI.setBitOrder(MSBFIRST); |
130 |
| - SPI.setDataMode(SPI_MODE0); |
| 129 | + SPI2.setBitOrder(MSBFIRST); |
| 130 | + SPI2.setDataMode(SPI_MODE0); |
131 | 131 | #endif
|
132 | 132 | }
|
133 | 133 |
|
134 | 134 | void Adafruit_DotStar::hw_spi_end(void) { // Stop hardware SPI
|
135 | 135 | #ifdef __AVR_ATtiny85__
|
136 | 136 | DDRB &= ~(_BV(PORTB1) | _BV(PORTB2)); // Inputs
|
137 | 137 | #elif (SPI_INTERFACES_COUNT > 0) || !defined(SPI_INTERFACES_COUNT)
|
138 |
| - SPI.end(); |
| 138 | + SPI2.end(); |
139 | 139 | #endif
|
140 | 140 | }
|
141 | 141 |
|
@@ -177,7 +177,7 @@ static void spi_out(uint8_t n) { // Clock out one byte
|
177 | 177 |
|
178 | 178 | // All other boards have full-featured hardware support for SPI
|
179 | 179 |
|
180 |
| -#define spi_out(n) (void)SPI.transfer(n) |
| 180 | +#define spi_out(n) (void)SPI2.transfer(n) |
181 | 181 | // Pipelining reads next byte while current byte is clocked out
|
182 | 182 | #if (defined(__AVR__) && !defined(__AVR_ATtiny85__)) || defined(CORE_TEENSY)
|
183 | 183 | #define SPI_PIPELINE
|
|
0 commit comments