GodMode9/arm9/source/system/spiflash.c
Wolfvak 9ecb90a2ba make interrupt handlers more lazy, most processing is done in interruptible context now
- completely moved MCU interrupt handling outside of the critical section
- refactored a bit of the PXI code and command names
- merge the I2C read and write cmds to be one
- remove SET_VMODE cmd, now it's always initialized to BGR565 on boot and to RGB565 on firmlaunch
- atomic-ize more stuff
2021-02-21 14:40:33 +01:00

34 lines
610 B
C
Executable File

#include "common.h"
#include "arm.h"
#include "pxi.h"
#include "shmem.h"
bool spiflash_get_status(void)
{
return PXI_DoCMD(PXICMD_NVRAM_ONLINE, NULL, 0);
}
bool spiflash_read(u32 offset, u32 size, u8 *buf)
{
u32 args[2];
while(size > 0) {
u32 blksz = min(size, SPI_SHARED_BUFSZ);
args[0] = offset;
args[1] = blksz;
ARM_WbDC_Range(ARM_GetSHMEM()->spiBuffer, blksz);
PXI_DoCMD(PXICMD_NVRAM_READ, args, 2);
ARM_InvDC_Range(ARM_GetSHMEM()->spiBuffer, blksz);
ARM_DSB();
memcpy(buf, ARM_GetSHMEM()->spiBuffer, blksz);
buf += blksz;
size -= blksz;
offset += blksz;
}
return true;
}