Skip to content

Commit 343ed66

Browse files
treewide: switch from CARD_CR1 to REG_AUXSPICNT and related defines
1 parent 7921347 commit 343ed66

File tree

9 files changed

+41
-41
lines changed

9 files changed

+41
-41
lines changed

blocksds/source/platform/ez5h/io_ez5.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
#define REG_CARD_COMMAND ((vuint8*)0x040001A8)
3333
#define REG_CARD_DATA_RD (*(vuint32*)0x04100010)
3434

35-
#define CARD_CR1_ENABLE 0x80 // in byte 1, i.e. 0x8000
36-
#define CARD_CR1_IRQ 0x40 // in byte 1, i.e. 0x4000
35+
#define CARD_SPICNTH_ENABLE (1 << 7) // In byte 1, i.e. 0x8000
36+
#define CARD_SPICNTH_IRQ (1 << 6) // In byte 1, i.e. 0x4000
3737
#define CARD_BUSY (1<<31) // when reading, still expecting incomming data?
3838
#define CARD_DATA_READY (1<<23) // when reading, REG_CARD_DATA_RD has another word of data and is good to go
3939

@@ -110,7 +110,7 @@ void dsCardi_SetRomOP(uint8 * command)
110110
}while(status&0x80000000);
111111

112112

113-
REG_AUXSPICNTH = CARD_CR1_IRQ|CARD_CR1_ENABLE ;
113+
REG_AUXSPICNTH = CARD_SPICNTH_IRQ|CARD_SPICNTH_ENABLE ;
114114

115115
for (index = 0; index < 8; index++) {
116116
REG_CARD_COMMAND[7-index] = command[index];
@@ -121,7 +121,7 @@ void cardWriteCommand(uint8 * command)
121121
{
122122
int index;
123123

124-
REG_AUXSPICNTH = CARD_CR1_ENABLE | CARD_CR1_IRQ;
124+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE | CARD_SPICNTH_IRQ;
125125

126126
for (index = 0; index < 8; index++) {
127127
REG_CARD_COMMAND[7-index] = command[index];

blocksds/source/platform/mati/MartCartop.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
#define REG_CARD_COMMAND ((vuint8*)0x040001A8)
1111
#define REG_CARD_DATA_RD (*(vuint32*)0x04100010)
1212

13-
#define CARD_CR1_ENABLE 0x80 // in byte 1, i.e. 0x8000
14-
#define CARD_CR1_IRQ 0x40 // in byte 1, i.e. 0x4000
13+
#define CARD_SPICNTH_ENABLE (1 << 7) // In byte 1, i.e. 0x8000
14+
#define CARD_SPICNTH_IRQ (1 << 6) // In byte 1, i.e. 0x4000
1515
#define CARD_BUSY (1<<31) // when reading, still expecting incomming data?
1616
#define CARD_DATA_READY (1<<23) // when reading, REG_CARD_DATA_RD has another word of data and is good to go
1717

blocksds/source/platform/mati/iointerface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ void Mart_SetRomOP(u8 * command)
2828
//5 SPI Enable (Both Bit13 and Bit15 must be set for SPI)
2929
//6 Transfer Ready IRQ (0=Disable, 1=Enable) (for ROM, not for AUXSPI)
3030
//7 NDS Slot Enable (0=Disable, 1=Enable) (for both ROM and AUXSPI)
31-
REG_AUXSPICNTH = CARD_CR1_IRQ|CARD_CR1_ENABLE ;
31+
REG_AUXSPICNTH = CARD_SPICNTH_IRQ|CARD_SPICNTH_ENABLE ;
3232

3333
for (index = 0; index < 8; index++) {
3434
REG_CARD_COMMAND[7-index] = command[index];
@@ -57,7 +57,7 @@ void cardWriteCommand(const u8 * command)
5757
{
5858
int index;
5959

60-
REG_AUXSPICNTH = CARD_CR1_ENABLE | CARD_CR1_IRQ;
60+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE | CARD_SPICNTH_IRQ;
6161

6262
for (index = 0; index < 8; index++) {
6363
REG_CARD_COMMAND[7-index] = command[index];

source/gmtf/source/gmtf.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@
5353
#define REG_AUXSPIDATA (*(vu8*)0x040001A2)
5454
#define REG_ROMCTRL (*(vu32*)0x040001A4)
5555
#define REG_CARD_COMMAND ((vu8*)0x040001A8)
56-
#define CARD_CR1_ENABLE 0x80 // in byte 1, i.e. 0x8000
57-
#define CARD_CR1_IRQ 0x40 // in byte 1, i.e. 0x4000
56+
#define CARD_SPICNTH_ENABLE (1 << 7) // In byte 1, i.e. 0x8000
57+
#define CARD_SPICNTH_IRQ (1 << 6) // In byte 1, i.e. 0x4000
5858
#define CARD_BUSY (1<<31) // when reading, still expecting incomming data?
59-
#define CARD_SPI_BUSY (1<<7)
60-
#define CARD_CR1_EN 0x8000
61-
#define CARD_CR1_SPI_EN 0x2000
62-
#define CARD_CR1_SPI_HOLD 0x40
59+
#define CARD_ENABLE BIT(15)
60+
#define CARD_SPI_ENABLE BIT(13)
61+
#define CARD_SPI_BUSY BIT(7)
62+
#define CARD_SPI_HOLD BIT(6)
6363
//---------------------------------------------------------------------------------
6464

6565
#define SD_COMMAND_TIMEOUT 0xFFF
@@ -74,7 +74,7 @@ void openSpi (void)
7474
{
7575
volatile u32 temp;
7676

77-
REG_AUXSPICNTH = CARD_CR1_ENABLE | CARD_CR1_IRQ;
77+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE | CARD_SPICNTH_IRQ;
7878
REG_CARD_COMMAND[0] = 0xF2;
7979
REG_CARD_COMMAND[1] = 0x00;
8080
REG_CARD_COMMAND[2] = 0x00;
@@ -89,14 +89,14 @@ void openSpi (void)
8989
temp = REG_CARD_DATA_RD;
9090
}
9191

92-
REG_AUXSPICNT = CARD_CR1_EN | CARD_CR1_SPI_EN | CARD_CR1_SPI_HOLD;
92+
REG_AUXSPICNT = CARD_ENABLE | CARD_SPI_ENABLE | CARD_SPI_HOLD;
9393
}
9494

9595
void closeSpi (void)
9696
{
9797
volatile u32 temp;
9898

99-
REG_AUXSPICNTH = CARD_CR1_ENABLE | CARD_CR1_IRQ;
99+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE | CARD_SPICNTH_IRQ;
100100
REG_CARD_COMMAND[0] = 0xF2;
101101
REG_CARD_COMMAND[1] = 0x00;
102102
REG_CARD_COMMAND[2] = 0x00;
@@ -111,7 +111,7 @@ void closeSpi (void)
111111
temp = REG_CARD_DATA_RD;
112112
}
113113

114-
REG_AUXSPICNT = CARD_CR1_EN | CARD_CR1_SPI_EN | CARD_CR1_SPI_HOLD;
114+
REG_AUXSPICNT = CARD_ENABLE | CARD_SPI_ENABLE | CARD_SPI_HOLD;
115115
REG_AUXSPIDATA = 0xFF;
116116

117117
while (REG_AUXSPICNT & CARD_SPI_BUSY) {};

staging/dlms4/source/iointerface_asm.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
@***********************************************************
22
@
3-
@ by Rudolph (c’é)
3+
@ by Rudolph (�c��)
44
@ 2006/11/24 First release
55
@
66
@-----------------------------------------------------------

staging/gmtf2/source/gmtf.c

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,13 @@
5353
#define REG_AUXSPIDATA (*(vu8*)0x040001A2)
5454
#define REG_ROMCTRL (*(vu32*)0x040001A4)
5555
#define REG_CARD_COMMAND ((vu8*)0x040001A8)
56-
#define CARD_CR1_ENABLE 0x80 // in byte 1, i.e. 0x8000
57-
#define CARD_CR1_IRQ 0x40 // in byte 1, i.e. 0x4000
56+
#define CARD_SPICNTH_ENABLE (1 << 7) // In byte 1, i.e. 0x8000
57+
#define CARD_SPICNTH_IRQ (1 << 6) // In byte 1, i.e. 0x4000
5858
#define CARD_BUSY (1<<31) // when reading, still expecting incomming data?
59-
#define CARD_SPI_BUSY (1<<7)
60-
#define CARD_CR1_EN 0x8000
61-
#define CARD_CR1_SPI_EN 0x2000
62-
#define CARD_CR1_SPI_HOLD 0x40
59+
#define CARD_ENABLE BIT(15)
60+
#define CARD_SPI_ENABLE BIT(13)
61+
#define CARD_SPI_BUSY BIT(7)
62+
#define CARD_SPI_HOLD BIT(6)
6363
//---------------------------------------------------------------------------------
6464

6565
#define SD_COMMAND_TIMEOUT 0xFFF
@@ -90,7 +90,7 @@ void openSpi (void)
9090
{
9191
volatile u32 temp;
9292

93-
REG_AUXSPICNTH = CARD_CR1_ENABLE | CARD_CR1_IRQ;
93+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE | CARD_SPICNTH_IRQ;
9494
REG_CARD_COMMAND[0] = 0xF2;
9595
REG_CARD_COMMAND[1] = 0x00;
9696
REG_CARD_COMMAND[2] = 0x00;
@@ -105,14 +105,14 @@ void openSpi (void)
105105
temp = REG_CARD_DATA_RD;
106106
}
107107

108-
REG_AUXSPICNT = CARD_CR1_EN | CARD_CR1_SPI_EN | CARD_CR1_SPI_HOLD;
108+
REG_AUXSPICNT = CARD_ENABLE | CARD_SPI_ENABLE | CARD_SPI_HOLD;
109109
}
110110

111111
void closeSpi (void)
112112
{
113113
volatile u32 temp;
114114

115-
REG_AUXSPICNTH = CARD_CR1_ENABLE | CARD_CR1_IRQ;
115+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE | CARD_SPICNTH_IRQ;
116116
REG_CARD_COMMAND[0] = 0xF2;
117117
REG_CARD_COMMAND[1] = 0x00;
118118
REG_CARD_COMMAND[2] = 0x00;
@@ -127,7 +127,7 @@ void closeSpi (void)
127127
temp = REG_CARD_DATA_RD;
128128
}
129129

130-
REG_AUXSPICNT = CARD_CR1_EN | CARD_CR1_SPI_EN | CARD_CR1_SPI_HOLD;
130+
REG_AUXSPICNT = CARD_ENABLE | CARD_SPI_ENABLE | CARD_SPI_HOLD;
131131
REG_SPIDATA = 0xFF;
132132

133133
while (REG_AUXSPICNT & CARD_SPI_BUSY) {};

staging/njsd/source/io_njsd.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ static inline void _NJSD_writeCardCommand
107107

108108
static bool _NJSD_reset (void) {
109109
int i;
110-
CARD_CR1H = CARD_CR1_ENABLE;
110+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE;
111111
_NJSD_writeCardCommand (0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
112112
CARD_CR2 = 0xA0406000;
113113
i = RESET_TIMEOUT;
@@ -155,7 +155,7 @@ static bool _NJSD_sendCMDR (int speed, u8 *rsp_buf, int type, u8 cmd, u32 param)
155155

156156
REG_IF = 0x100000;
157157

158-
CARD_CR1H = CARD_CR1_ENABLE;
158+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE;
159159

160160
if ((type & 3) < 2) {
161161
CARD_COMMAND[0] = 0xF0 | (speed << 2) | 1 | (type << 1);
@@ -233,7 +233,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) {
233233
REG_IME = 0;
234234
#endif
235235

236-
CARD_CR1H = CARD_CR1_ENABLE;
236+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE;
237237
_NJSD_writeCardCommand (0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00);
238238
CARD_CR2 = 0xA0406000;
239239
i = COMMAND_TIMEOUT;
@@ -247,7 +247,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) {
247247

248248
for (i = 0; i < 65; i++)
249249
{
250-
CARD_CR1H = CARD_CR1_ENABLE; // | CARD_CR1_IRQ;
250+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE; // | CARD_SPICNTH_IRQ;
251251
if (i < 64)
252252
{
253253
_NJSD_writeCardCommand (buffer[i*8+0], buffer[i*8+1], buffer[i*8+2], buffer[i*8+3],
@@ -266,7 +266,7 @@ static bool _NJSD_writeSector (u8 *buffer, u8 *crc_buf, u32 offset) {
266266
} while (CARD_CR2 & CARD_BUSY);
267267
}
268268

269-
CARD_CR1H = CARD_CR1_ENABLE;
269+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE;
270270
_NJSD_writeCardCommand (0xF0 | (1 << 2) | 1, 0x80, 0x40 | WRITE_BLOCK, (u8)(offset>>24),
271271
(u8)(offset>>16), (u8)(offset>>8), (u8)(offset>>0), 0x00);
272272
CARD_CR2 = 0xA7406000;
@@ -329,7 +329,7 @@ static bool _NJSD_sendCLK (int speed, int count) {
329329
REG_IF = 0x100000;
330330
#endif
331331

332-
//CARD_CR1H = CARD_CR1_ENABLE; // | CARD_CR1_IRQ;
332+
//REG_AUXSPICNTH = CARD_SPICNTH_ENABLE; // | CARD_SPICNTH_IRQ;
333333
_NJSD_writeCardCommand (0xE0 | ((speed & 3) << 2), 0, (count - 1), 0, 0, 0, 0, 0);
334334

335335
CARD_CR2 = _NJSD_cardFlags;
@@ -367,7 +367,7 @@ static bool _NJSD_sendCMDN (int speed, u8 cmd, u32 param) {
367367

368368
REG_IF = 0x100000;
369369

370-
CARD_CR1H = CARD_CR1_ENABLE; // | CARD_CR1_IRQ;
370+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE; // | CARD_SPICNTH_IRQ;
371371
_NJSD_writeCardCommand (0xF0 | ((speed & 3) << 2), 0x00, 0x40 | cmd, (param>>24) & 0xFF,
372372
(param>>16) & 0xFF, (param>>8) & 0xFF, (param>>0) & 0xFF, 0x00);
373373

staging/nmmc/source/io_nmmc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,19 +63,19 @@ int _NMMC_spi_freq = 3;
6363

6464
static inline void _Neo_OpenSPI( u8 frequency )
6565
{
66-
CARD_CR1 = 0x0000A040 | frequency;
66+
REG_AUXSPICNT = 0x0000A040 | frequency;
6767
}
6868

6969
static inline u8 _Neo_SPI( u8 dataByte )
7070
{
7171
CARD_EEPDATA = dataByte;
72-
while (CARD_CR1 & 0x80); // card busy
72+
while (REG_AUXSPICNT & 0x80); // card busy
7373
return CARD_EEPDATA;
7474
}
7575

7676
static inline void _Neo_CloseSPI ( void )
7777
{
78-
CARD_CR1 = 0;
78+
REG_AUXSPICNT = 0;
7979
}
8080

8181
static inline void _Neo_MK2GameMode() {

staging/rpg_nand/source/rpgprotocol.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ void __attribute__((naked)) ioRpgDelay(u32 us)
3939

4040
void ioRpgSendCommand( u32 command[2], u32 pageSize, u32 latency, void * buffer )
4141
{
42-
REG_AUXSPICNTH = CARD_CR1_ENABLE | CARD_CR1_IRQ;
42+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE | CARD_SPICNTH_IRQ;
4343

4444
for( u32 i=0; i<2; ++i )
4545
{
@@ -115,7 +115,7 @@ bool ioRpgWaitCmdBusy( bool forceWait )
115115
{
116116
bool timeout = true;
117117
while( timeout && forceWait ) {
118-
REG_AUXSPICNTH = CARD_CR1_ENABLE | CARD_CR1_IRQ;
118+
REG_AUXSPICNTH = CARD_SPICNTH_ENABLE | CARD_SPICNTH_IRQ;
119119
for( u32 i=0; i<8; ++i )
120120
CARD_COMMAND[i] = 0xB8;
121121
// go

0 commit comments

Comments
 (0)