Configuring a custom board to use Sercom 3

Hi everyone,

I’ve got a custom board, based on Arduino Zero, with a SAM D21 on board and a Winc1500 (like if it was merged with an Arduino Wifi Shield 101).

The Winc uses Sercom 3 to communicate with the Sam D21.

We are using the wifi101 library, that has the following instructions

Digital pins 11, 12, and 13 are used for SPI communication
Digital pin 10 is used as SS
Digital pin 7 is used as a handshake pin between the Wifi shield 101 and the underlying board

In my Variant.cpp I wrote this code

// 7
{ PORTA,  5, PIO_OUTPUT, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5}, // used as output only

[...]

// 10...13 - SPI Sercom 3
// 10
{ PORTA, 20, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_4 }, 	// PA20 - SSN: SERCOM3/PAD[2]
// 11
{ PORTA, 22, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_6 }, 	// PA22 - MOSI: SERCOM3/PAD[0]
// 12
{ PORTA, 21, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_5 }, 	// PA21 - MISO: SERCOM3/PAD[3]
// 13
{ PORTA, 23, PIO_SERCOM, PIN_ATTR_DIGITAL, No_ADC_Channel, NOT_ON_PWM, NOT_ON_TIMER, EXTERNAL_INT_7 }, 	// PA23 - SCK: SERCOM3/PAD[1]

This in my Variant.h

/*
 * SPI Interfaces
 */
#define SPI_INTERFACES_COUNT 1

#define PIN_SPI_MISO       (12u)
#define PIN_SPI_MOSI       (11u)
#define PIN_SPI_SCK         (13u)
#define PERIPH_SPI           sercom3
#define PAD_SPI_TX           SPI_PAD_0_SCK_3
#define PAD_SPI_RX           SERCOM_RX_PAD_1

static const uint8_t SS  = (10u); //PIN_A2 ;	
static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK  = PIN_SPI_SCK ;

Finally, this is my Arduino code

#include <SPI.h>
#include <WiFi101.h>

void setup() 
{
   
   SerialUSB.println("Get MacAddress...");
   // Print WiFi MAC address:
   printMacAddress();

   // scan for existing networks:
   SerialUSB.println("Scanning available networks...");
   listNetworks();
}

When I run this code, the serial monitor just reads “Get MacAddress…” and then it hangs, no reply is ever sent from the WINC.

Can someone help me to find what I’m doing wrong? Is anything else I need to modify in order to use the Sercom3 with the WINC1500?

Thank you!