Marzogh / SPIMemory

Arduino library for Flash Memory Chips (SPI based only). Formerly SPIFlash
http://spimemory.readthedocs.io/en/latest/
GNU General Public License v3.0
426 stars 135 forks source link

Cannot figure out Constructor for SAMD51 M4 #189

Open Wadreon opened 4 years ago

Wadreon commented 4 years ago

What would the constructor look like for an M4? I am trying to use with an feather M4 express. I gather if working with metro, should definitely work with feather. Though not certain on how to create constructor? Do not see a QSPI class. Thank You:)

vslinuxdotnet commented 4 years ago

Hello, That it a point of the constructor... I Also try with other M4 devices without luck.

Ex: for Adafruit ItsyBitsy

//QSPI Pins
#define PIN_QSPI_SCK    (32u)//CLK
#define PIN_QSPI_CS     (33u)//CS
#define PIN_QSPI_IO0    (34u)//MOSI
#define PIN_QSPI_IO1    (35u)//MISO
#define PIN_QSPI_IO2    (36u)//WP
#define PIN_QSPI_IO3    (37u)//HOLD

SPIClass SPI1 (&sercom1, PIN_QSPI_IO1, PIN_QSPI_SCK, PIN_QSPI_IO0, SPI_PAD_0_SCK_1, SERCOM_RX_PAD_3);
SPIFlash flash(PIN_QSPI_CS, &SPI1);

From the Adafruit_SPIFlash lib:

  MCLK->APBCMASK.bit.QSPI_ = true;
  MCLK->AHBMASK.bit.QSPI_ = true;
  MCLK->AHBMASK.bit.QSPI_2X_ = false; // Only true if we are doing DDR.

  QSPI->CTRLA.bit.SWRST = 1;

  // set all pins to QSPI periph
  pinPeripheral(PIN_QSPI_SCK, PIO_COM);
  pinPeripheral(PIN_QSPI_CS, PIO_COM);
  pinPeripheral(PIN_QSPI_IO0, PIO_COM);
  pinPeripheral(PIN_QSPI_IO1, PIO_COM);
  pinPeripheral(PIN_QSPI_IO2, PIO_COM);
  pinPeripheral(PIN_QSPI_IO3, PIO_COM);

But don't detected any flash...

Any help ?