Hardware SPI interface with arduino

pi-guy3

Member
OP
Newcomer
Joined
Sep 28, 2017
Messages
10
Trophies
0
Age
23
XP
58
Country
United States
hi how can i directly control the save game spi bus on the 3ds like send a 13 and get 1011 on the output here is my code for a ds it works in twloader but i want it as a 3dsx or cia,
and i get 13 on the serial monitor of the arduino conected to the ds cards spi bus on my 3ds

#include <nds.h>
#define REG_AUXSPICNT (*(vu16*)0x040001A0)
#define REG_AUXSPIDATA (*(vu8*)0x040001A2)

static inline void spiWaitBusy() {
while (REG_AUXSPICNT & 0x80 /*spi busy*/);
}

u8 spiSend(u8 command) {
u8 retval;

REG_AUXSPICNT = 0x8000/*slot enable*/ | 0x2000 /*slot mode*/ | 0x40 /*chipselect line*/ /*| 0x3 /*speed*/;
REG_AUXSPIDATA = command;
spiWaitBusy();
retval = REG_AUXSPIDATA;
REG_AUXSPICNT = 0x40 /*chipselect line*/ ;
return retval;
}

int main(void) {
sysSetBusOwners(true, true);
while(1){
spiSend(13);
}
}

/*
http://problemkaputt.de/gbatek.htm#dsiomaps


40001A0h - NDS7/NDS9 - AUXSPICNT - Gamecard ROM and SPI Control
0-1 SPI Baudrate (0=4MHz/Default, 1=2MHz, 2=1MHz, 3=512KHz)
2-5 Not used (always zero)
6 SPI Hold Chipselect (0=Deselect after transfer, 1=Keep selected)
7 SPI Busy (0=Ready, 1=Busy) (presumably Read-only)
8-12 Not used (always zero)
13 NDS Slot Mode (0=Parallel/ROM, 1=Serial/SPI-Backup)
14 Transfer Ready IRQ (0=Disable, 1=Enable) (for ROM, not for AUXSPI)
15 NDS Slot Enable (0=Disable, 1=Enable) (for both ROM and AUXSPI)
*/
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Veho @ Veho: Firefox users be like "look at what they have to do to mimic a fraction of our power."