4141 // SAMD51 has configurable MAX_SPI, else use peripheral clock default.
4242 // Update: changing MAX_SPI via compiler flags is DEPRECATED, because
4343 // this affects ALL SPI peripherals including some that should NOT be
44- // changed (e.g. anything using SD card). Use the setClockSources ()
44+ // changed (e.g. anything using SD card). Use the setClockSource ()
4545 // function instead. This is left here for compatibility with interim code.
4646 #if !defined(MAX_SPI)
4747 #define MAX_SPI 24000000
@@ -107,17 +107,6 @@ class SPISettings {
107107 friend class SPIClass ;
108108};
109109
110- #if defined(__SAMD51__)
111- enum SPIClockSource {
112- SPI_CLOCK_SOURCE_NO_CHANGE, // Leave clock source setting unchanged
113- SPI_CLOCK_SOURCE_FCPU, // F_CPU clock (GCLK0)
114- SPI_CLOCK_SOURCE_48M, // 48 MHz peripheral clock (GCLK1) (standard)
115- SPI_CLOCK_SOURCE_100M, // 100 MHz peripheral clock (GCLK2)
116- SPI_CLOCK_SOURCE_32K, // XOSC32K clock (GCLK3)
117- SPI_CLOCK_SOURCE_12M // 12 MHz peripheral clock (GCLK4)
118- };
119- #endif // end __SAMD51__
120-
121110class SPIClass {
122111 public:
123112 SPIClass (SERCOM *p_sercom, uint8_t uc_pinMISO, uint8_t uc_pinSCK, uint8_t uc_pinMOSI, SercomSpiTXPad, SercomRXPad);
@@ -143,15 +132,17 @@ class SPIClass {
143132 void setDataMode (uint8_t uc_mode);
144133 void setClockDivider (uint8_t uc_div);
145134
146- # if defined(__SAMD21__) || defined(__SAMD51__)
135+ // SERCOM lookup functions are available on both SAMD51 and 21.
147136 volatile uint32_t *getDataRegister (void );
148- int getDMACID (void );
149- # endif
137+ int getDMACID (void );
138+ uint8_t getSercomIndex ( void ) { return _p_sercom-> getSercomIndex (); };
150139#if defined(__SAMD51__)
151- void setClockSources (
152- SercomClockSource core = SERCOM_CLOCK_SOURCE_NO_CHANGE,
153- SercomClockSource slow = SERCOM_CLOCK_SOURCE_NO_CHANGE);
154- uint32_t getMaxBitrate (void ) { return maxBitrate; };
140+ // SERCOM clock source override is available only on SAMD51.
141+ void setClockSource (SercomClockSource clk);
142+ #else
143+ // On SAMD21, this compiles to nothing, so user code doesn't need to
144+ // check and conditionally compile lines for different architectures.
145+ void setClockSource (SercomClockSource clk) { };
155146#endif // end __SAMD51__
156147
157148 private:
@@ -170,9 +161,6 @@ class SPIClass {
170161 uint8_t interruptMode;
171162 char interruptSave;
172163 uint32_t interruptMask;
173- #if defined(__SAMD51__)
174- uint32_t maxBitrate;
175- #endif
176164};
177165
178166#if SPI_INTERFACES_COUNT > 0
0 commit comments