SPI / SPI1 this can't be right..?

Please tell us which board you are using.
For CircuitPython issues, ask in the Adafruit CircuitPython forum.

Moderators: adafruit_support_bill, adafruit

Please be positive and constructive with your questions and comments.
Locked
User avatar
tinker_curt
 
Posts: 7
Joined: Wed Mar 31, 2021 11:06 am

SPI / SPI1 this can't be right..?

Post by tinker_curt »

I'm working on a project that will use SPI1, checking variant files to be sure of pin definitions I ran across this in the Adafruit package file (....samd\1.7.11\variants\itsybitsy_m0\variant.h):

Code: Select all

/*
 * SPI Interfaces
 */
#define SPI_INTERFACES_COUNT 2

#define PIN_SPI_MISO         (28u)
#define PIN_SPI_MOSI         (29u)
#define PIN_SPI_SCK          (30u)
#define PERIPH_SPI           sercom4
#define PAD_SPI_TX           SPI_PAD_2_SCK_3
#define PAD_SPI_RX           SERCOM_RX_PAD_0

static const uint8_t SS	  = PIN_A2 ;	// SERCOM4 last PAD is present on A2 but HW SS isn't used. Set here only for reference.
static const uint8_t MOSI = PIN_SPI_MOSI ;
static const uint8_t MISO = PIN_SPI_MISO ;
static const uint8_t SCK  = PIN_SPI_SCK ;


#define PIN_SPI1_MISO         (36u)
#define PIN_SPI1_MOSI         (37u)
#define PIN_SPI1_SCK          (38u)
#define PERIPH_SPI1           sercom5
#define PAD_SPI1_TX           SPI_PAD_2_SCK_3
#define PAD_SPI1_RX           SERCOM_RX_PAD_1

static const uint8_t SS1   = 39 ;	// HW SS isn't used. Set here only for reference.
static const uint8_t MOSI1 = PIN_SPI_MOSI ; 
static const uint8_t MISO1 = PIN_SPI_MISO ;
static const uint8_t SCK1  = PIN_SPI_SCK ;
SS1 is defined to use the same pins as SS. Shouldn't it read:

Code: Select all

static const uint8_t MOSI1 = PIN_SPI1_MOSI ; 
static const uint8_t MISO1 = PIN_SPI1_MISO ;
static const uint8_t SCK1  = PIN_SPI1_SCK ;
Am I missing something important? Anyone trying to use SP1 would be in for a rude surprise but it seems unlikely no one has ever tried?

Looking for some guidance please.

-Curt

User avatar
adafruit_support_carter
 
Posts: 29168
Joined: Tue Nov 29, 2016 2:45 pm

Re: SPI / SPI1 this can't be right..?

Post by adafruit_support_carter »

Does look like a possible copy-paste type. The SAMD BSP code actually ends up using the PIN_SPI1_xxx defines, so SPI1 ends up setup on the correct pins and works. The secondary SPI pins (SPI1) are also not broken out. They are used for the onboard SPI flash.

https://learn.adafruit.com/introducing- ... /downloads

Locked
Please be positive and constructive with your questions and comments.

Return to “Itsy Bitsy Boards”