I use the code below for acces sd card on a esp32.
The goal is to read blocks. This is my routine to read a Forth screen into the memory.
This is part of my 6502 emulator running with the teensy 4.1.
.
Is this possible, and what to change to get it running on my teensy.
Thanks for any help.
Cheers,
Jan
The goal is to read blocks. This is my routine to read a Forth screen into the memory.
This is part of my 6502 emulator running with the teensy 4.1.
.
Is this possible, and what to change to get it running on my teensy.
Thanks for any help.
Cheers,
Jan
C++:
#include "SdFat.h"
SdFat32 sd; // for FAT16/FAT32
File32 file;
File32 file_RW;
void RW(byte *codebuffer, int adr, int blk, int f)
{
int bytes_per_block = 128;
if (f==1) /* read from disk to memory */
{
file_RW.seekSet(blk*bytes_per_block);
for (int i=0; i<bytes_per_block; i++) codebuffer[adr+i] = file_RW.read() & 0x7f;
}
else /* write from disk to memory */
{
file_RW.seekSet(blk*bytes_per_block);
for (int i=0; i<bytes_per_block; i++) file_RW.write(codebuffer[adr+i]);
}
}
void setup()
{
Serial.begin(115200);
SPI.begin(14, 2, 15, 13); //SCK, MISO, MOSI,SS
Wire.begin();
if (!sd.begin(13,SD_CONFIG))
{
Serial.println("sd.begin failed!");
return;
}
else Serial.println("sd active");
}