SPIClass Metro M0 Express question


Im trying to interface with the Adafruit Metro M0 Express’s builtin SPI Flash chip. I looked into Adafruits SPIFlash library, but it forces me to use my SPI flashchip as a SD card(fafts). I dont want to do this. All I would like to do is write a single byte to a address,then read it. But it seems im misunderstanding something. Code is posted below.

According to Adafruit FLASH SPI PINS are:
MISO = 36
MOSI = 37
SCK = 38
CS = 39

And looking at datasheet of SAMD21, these use SERCOM5 with the respected PAD associated to them.

I believe I setup my SPIClass correctly,and have the correct commands I need to send to the flash chip(write/read/erase chip commands).Says write command is (0x06) and read command is (0x03) and erase chip is (0x60). It compiles,but doesnt send my data = 20 to address 0…

Links to datasheets with pages:

https://www.cypress.com/file/196886/download FLASH CHIP DATASHEET(page 63 is the command list)

SAMD21 Datasheet(go to page 23): https://cdn.sparkfun.com/assets/6/3/d/d/2/Atmel-42181-SAM-D21_Datasheet.pdf

Adafruit Metro M0 Express Overview: Overview | Adafruit Metro M0 Express - Designed for CircuitPython | Adafruit Learning System


#include <SPI.h>
#include "wiring_private.h" // pinPeripheral() function
// FLASH SCK pin is #38, MISO is #36,  MOSI is #37, and CS is #39


SPIClass mySPI (&sercom5, 36, 38, 37, SPI_PAD_2_SCK_3, SERCOM_RX_PAD_1);
#define CSPIN 39

uint32_t addr = 0;
uint8_t data = 20;
uint8_t datasent;
void setup(void) {

  pinPeripheral(37, PIO_SERCOM);// Assign MOSI
  pinPeripheral(38, PIO_SERCOM); // Assign SCK
  pinPeripheral(36, PIO_SERCOM);// Assign MISO

  // Assign CS

  pinMode(CSPIN, OUTPUT);
  digitalWrite(CSPIN, HIGH);

  mySPI.beginTransaction(SPISettings(20000000, MSBFIRST, SPI_MODE0));

  //chip erase
  digitalWrite(CSPIN, LOW);
  mySPI.transfer(0x06);//write enable on
  mySPI.transfer(0x60);//erase command
  digitalWrite(CSPIN, HIGH);


void loop(void) {

  //write byte to address
  digitalWrite(CSPIN, LOW);
  mySPI.transfer(0x06);//write enable on

  addr = mySPI.transfer(0x00); //address
  datasent = mySPI.transfer(data); //data to send

  Serial.println(" addr=");
  Serial.println("datasent =");
  Serial.println( datasent);

  digitalWrite(CSPIN, HIGH);

  //read byte at address

  digitalWrite(CSPIN, LOW);

  mySPI.transfer(0x03);//read command


  // send a value of 0 to read the first byte returned:
  uint8_t result = mySPI.transfer(0x00);

  Serial.println(" result = ");

  digitalWrite(CSPIN, HIGH);


Any advice would be great, if theres a better way, or if im going about this all wrong.