mirror of
https://github.com/d0k3/GodMode9.git
synced 2025-06-26 21:52:48 +00:00
Add a timeout to SPIWaitWriteEnd
Solves the WarioWare issue
This commit is contained in:
parent
556c75c337
commit
fd48c95deb
@ -18,6 +18,7 @@
|
|||||||
|
|
||||||
#include "spi.h"
|
#include "spi.h"
|
||||||
#include "spicard.h"
|
#include "spicard.h"
|
||||||
|
#include "timer.h"
|
||||||
#include "ui.h"
|
#include "ui.h"
|
||||||
|
|
||||||
// Deliberately written in C! (except for a few lines)
|
// Deliberately written in C! (except for a few lines)
|
||||||
@ -44,10 +45,12 @@ int SPIWriteRead(CardType type, void* cmd, u32 cmdSize, void* answer, u32 answer
|
|||||||
int SPIWaitWriteEnd(CardType type) {
|
int SPIWaitWriteEnd(CardType type) {
|
||||||
u8 cmd = SPI_CMD_RDSR, statusReg = 0;
|
u8 cmd = SPI_CMD_RDSR, statusReg = 0;
|
||||||
int res = 0;
|
int res = 0;
|
||||||
|
u64 time_start = timer_start();
|
||||||
|
|
||||||
do{
|
do{
|
||||||
res = SPIWriteRead(type, &cmd, 1, &statusReg, 1, 0, 0);
|
res = SPIWriteRead(type, &cmd, 1, &statusReg, 1, 0, 0);
|
||||||
if(res) return res;
|
if(res) return res;
|
||||||
|
if(timer_msec(time_start) > 1000) return 1;
|
||||||
} while(statusReg & SPI_FLG_WIP);
|
} while(statusReg & SPI_FLG_WIP);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user