Skip to content

Commit 1e6d346

Browse files
authored
Bugfix/desmakers 4316 spi normal pins 11 12 13 not functioning on xmc4700 relax kit (#325)
* fix: do not swap the spi default and SD card, only change the default pin * fix: refactor SD card functionality
1 parent 334c12a commit 1e6d346

File tree

2 files changed

+12
-17
lines changed

2 files changed

+12
-17
lines changed

libraries/SPI/src/HW_SPI.cpp

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,24 +29,18 @@
2929

3030
// swap SPI_default and SPI_for_xmc_SD if desired by user
3131
#if defined(USE_XMC_RELAX_KIT_SD) && defined(XMC_SPI_for_xmc_SD)
32-
SPIClass SPI(&XMC_SPI_for_xmc_SD);
33-
#if (NUM_SPI > 1)
34-
SPIClass SPI1(&XMC_SPI_default);
35-
#endif
36-
uint8_t SS = PIN_SPI_SS_SD;
37-
uint8_t MOSI = PIN_SPI_MOSI_SD;
38-
uint8_t MISO = PIN_SPI_MISO_SD;
39-
uint8_t SCK = PIN_SPI_SCK_SD;
32+
SPIClass SPI(&XMC_SPI_default);
33+
SPIClass SPI1(&XMC_SPI_for_xmc_SD);
4034
#else // normal behaviour
4135
SPIClass SPI(&XMC_SPI_default);
4236
#if (NUM_SPI > 1)
4337
SPIClass SPI1(&XMC_SPI_1);
4438
#endif
39+
#endif
4540
uint8_t SS = PIN_SPI_SS;
4641
uint8_t MOSI = PIN_SPI_MOSI;
4742
uint8_t MISO = PIN_SPI_MISO;
4843
uint8_t SCK = PIN_SPI_SCK;
49-
#endif
5044

5145
#if (NUM_SPI > 2)
5246
SPIClass SPI2(&XMC_SPI_2);

variants/XMC4700/config/XMC4700_Relax_Kit/pins_arduino.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ extern const uint8_t NUM_ANALOG_OUTPUTS;
6363

6464
// to use SPI_for_xmc_SD if desired by user
6565
#define XMC_SPI_for_xmc_SD XMC_SPI_1
66+
#define SDCARD_SPI SPI1
6667

6768
// Indicate unit has RTC/Alarm
6869
#define HAS_RTC 1
@@ -86,15 +87,15 @@ extern uint8_t MOSI;
8687
extern uint8_t MISO;
8788
extern uint8_t SCK;
8889

89-
#define PIN_SPI_SS_SD 26
90-
#define PIN_SPI_MOSI_SD 27
91-
#define PIN_SPI_MISO_SD 28
92-
#define PIN_SPI_SCK_SD 29
90+
#define SDCARD_SS_PIN 26
91+
#define SDCARD_MOSI_PIN 27
92+
#define SDCARD_MISO_PIN 28
93+
#define SDCARD_SCK_PIN 29
9394

94-
static const uint8_t SS_SD = PIN_SPI_SS_SD;
95-
static const uint8_t MOSI_SD = PIN_SPI_MOSI_SD;
96-
static const uint8_t MISO_SD = PIN_SPI_MISO_SD;
97-
static const uint8_t SCK_SD = PIN_SPI_SCK_SD;
95+
static const uint8_t SS_SD = SDCARD_SS_PIN;
96+
static const uint8_t MOSI_SD = SDCARD_MOSI_PIN;
97+
static const uint8_t MISO_SD = SDCARD_MISO_PIN;
98+
static const uint8_t SCK_SD = SDCARD_SCK_PIN;
9899

99100
// XMC_I2S defines
100101
/*U2C0*/

0 commit comments

Comments
 (0)