#include "src/W25QXXArduino/w25qxx.h"
#include "src/FATS/ff.h"
void setup() {
  // put your setup code here, to run once:
  uint8_t table[256]={0};
  Serial.begin(115200);
  Serial.setTimeout(10);
  Serial.setRxBufferSize(256);
  Serial.onReceive(SerialRe,true);
  W25QXX_Init();
  delay(3000);
}

void loop() {
  // put your main code here, to run repeatedly:
  delay(1000);
}
void SerialRe(){
  // uint8_t buffer[256]={0};
  // static int pagecnt = 0;
  // if(Serial.available()){  
  //   Serial.readBytes(buffer,256);  
  // }  
  //   W25QXX_Write_Page(buffer,256*pagecnt,256);
  //   pagecnt++;
  //   Serial.printf("page %02d\n",pagecnt);  
    int i;
    uint8_t buffer[16]={0};
    if(Serial.available()){
     i = Serial.parseInt();
     Serial.printf("read %0d\n",i);
     W25QXX_Read(buffer,i,16);
     for(uint8_t temp:buffer){
       Serial.printf("%02X ",temp);
     }
  }
}
