Skip to content

Commit 04731bc

Browse files
committed
not having any SPI breaks things - maybe just have a 'fake' sck+mosi only SPI for sercom 0?
1 parent de847a1 commit 04731bc

File tree

2 files changed

+20
-4
lines changed

2 files changed

+20
-4
lines changed

variants/gemma_m0/variant.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,13 @@
6161
const PinDescription g_APinDescription[]=
6262
{
6363
// GPIO 0, 1, 2 on external pads
64-
// 0 - SERCOM0 for I2C SDA or UART TX, Captouch, IRQ, PWM out TCC0/WO[0], and gen purpose pin
64+
// 0 - SERCOM0.0 for I2C SDA, UART TX, SPI MOSI, Captouch, IRQ, PWM out TCC0/WO[0], and gen purpose pin
6565
{ PORTA, 4, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM0_CH0, TCC0_CH0, EXTERNAL_INT_4 }, // TCC0/WO[0]
6666

6767
// 1 - ADC, DAC, IRQ, Captouch and general purpose pin - no timer
6868
{ PORTA, 2, PIO_ANALOG, PIN_ATTR_ANALOG, ADC_Channel0, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_2 }, // ADC/AIN[0]
6969

70-
// 2 - SERCOM0 for I2C SCL or UART RX, Captouch, IRQ, PWM out TCC0/WO[1], and gen purpose pin
70+
// 2 - SERCOM0 for I2C SCL, UART RX, SPI CLK, Captouch, IRQ, PWM out TCC0/WO[1], and gen purpose pin
7171
{ PORTA, 5, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM0_CH1, TCC0_CH1, EXTERNAL_INT_5 }, // TCC0/WO[1]
7272

7373
// GPIO 3 & 4 - DotStar internal data/clock
@@ -101,7 +101,10 @@ const PinDescription g_APinDescription[]=
101101
{ PORTA, 10, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_10 },
102102
{ PORTA, 11, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_11 },
103103

104-
// For unknown reasons we need to have gpio 16-21 so here are 6 extra pins (shrug)
104+
// Placeholder #16 - extra Sercom/SPI pin that doesnt actually get used
105+
{ PORTA, 6, PIO_SERCOM_ALT, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM1_CH0, TCC1_CH0, EXTERNAL_INT_6 }, // TCC0/WO[1]
106+
107+
// For unknown reasons we need to have gpio 17-21 so here are extra pins (shrug)
105108
{ PORTA, 14, PIO_DIGITAL, (PIN_ATTR_DIGITAL), No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_14 },
106109
{ PORTA, 15, PIO_DIGITAL, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM3_CH1, TC3_CH1, EXTERNAL_INT_15 },
107110
{ PORTA, 16, PIO_TIMER, (PIN_ATTR_DIGITAL|PIN_ATTR_PWM|PIN_ATTR_TIMER), No_ADC_Channel, PWM2_CH0, TCC2_CH0, EXTERNAL_INT_0 }, // TCC2/WO[0]

variants/gemma_m0/variant.h

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,20 @@ static const uint8_t DAC0 = PIN_DAC0;
116116
/*
117117
* SPI Interfaces
118118
*/
119-
#define SPI_INTERFACES_COUNT 0 // :( not enough pins
119+
#define SPI_INTERFACES_COUNT 1 // we'll just have SPI CLK and MOSI on sercom 0, no MISO
120+
121+
#define PIN_SPI_MISO (6u) // PA06, not actually available
122+
#define PIN_SPI_MOSI (0ul) // PA04
123+
#define PIN_SPI_SCK (2ul) // PA05
124+
#define PERIPH_SPI sercom0
125+
#define PAD_SPI_TX SPI_PAD_0_SCK_1
126+
#define PAD_SPI_RX SERCOM_RX_PAD_2
127+
128+
static const uint8_t SS = 1 ; // only pin remaining (shrug)
129+
static const uint8_t MOSI = PIN_SPI_MOSI ;
130+
static const uint8_t MISO = PIN_SPI_MISO ;
131+
static const uint8_t SCK = PIN_SPI_SCK ;
132+
120133

121134
/*
122135
* Wire Interfaces

0 commit comments

Comments
 (0)