use constants
This commit is contained in:
+1
-1
@@ -204,7 +204,7 @@ loop:
|
|||||||
jump_intr:
|
jump_intr:
|
||||||
strh r0, [r3, OFFSET_REG_IF - 0x200]
|
strh r0, [r3, OFFSET_REG_IF - 0x200]
|
||||||
bic r2, r2, r0
|
bic r2, r2, r0
|
||||||
ldr r0, =gRfuState
|
ldr r0, =gSTWIStatus
|
||||||
ldr r0, [r0]
|
ldr r0, [r0]
|
||||||
ldrb r0, [r0, 0xA]
|
ldrb r0, [r0, 0xA]
|
||||||
mov r1, 0x8
|
mov r1, 0x8
|
||||||
|
|||||||
+14
-14
@@ -9,7 +9,7 @@
|
|||||||
IntrSIO32: @ 81DFC50
|
IntrSIO32: @ 81DFC50
|
||||||
mov r12, sp
|
mov r12, sp
|
||||||
stmdb sp!, {r11,r12,lr,pc}
|
stmdb sp!, {r11,r12,lr,pc}
|
||||||
ldr r3, _081DFCB0 @ =gRfuState
|
ldr r3, _081DFCB0 @ =gSTWIStatus
|
||||||
ldr r0, [r3]
|
ldr r0, [r3]
|
||||||
ldr r2, [r0]
|
ldr r2, [r0]
|
||||||
sub r11, r12, 0x4
|
sub r11, r12, 0x4
|
||||||
@@ -34,7 +34,7 @@ _081DFCA4:
|
|||||||
ldmdb r11, {r11,sp,lr}
|
ldmdb r11, {r11,sp,lr}
|
||||||
bx lr
|
bx lr
|
||||||
.align 2, 0
|
.align 2, 0
|
||||||
_081DFCB0: .4byte gRfuState
|
_081DFCB0: .4byte gSTWIStatus
|
||||||
arm_func_end IntrSIO32
|
arm_func_end IntrSIO32
|
||||||
|
|
||||||
arm_func_start sio32intr_clock_master
|
arm_func_start sio32intr_clock_master
|
||||||
@@ -45,7 +45,7 @@ sio32intr_clock_master: @ 81DFCB4
|
|||||||
sub r11, r12, 0x4
|
sub r11, r12, 0x4
|
||||||
bl STWI_set_timer_in_RAM
|
bl STWI_set_timer_in_RAM
|
||||||
mov r4, 0x120
|
mov r4, 0x120
|
||||||
ldr r2, _081DFF28 @ =gRfuState
|
ldr r2, _081DFF28 @ =gSTWIStatus
|
||||||
add r4, r4, 0x4000000
|
add r4, r4, 0x4000000
|
||||||
ldr lr, [r4]
|
ldr lr, [r4]
|
||||||
ldr r12, [r2]
|
ldr r12, [r2]
|
||||||
@@ -208,7 +208,7 @@ _081DFEFC:
|
|||||||
bl sub_81E05A4
|
bl sub_81E05A4
|
||||||
b _081DFF3C
|
b _081DFF3C
|
||||||
.align 2, 0
|
.align 2, 0
|
||||||
_081DFF28: .4byte gRfuState
|
_081DFF28: .4byte gSTWIStatus
|
||||||
_081DFF2C:
|
_081DFF2C:
|
||||||
add r3, r5, 0x3
|
add r3, r5, 0x3
|
||||||
strh r3, [r4]
|
strh r3, [r4]
|
||||||
@@ -223,7 +223,7 @@ _081DFF3C:
|
|||||||
sio32intr_clock_slave: @ 81DFF44
|
sio32intr_clock_slave: @ 81DFF44
|
||||||
mov r12, sp
|
mov r12, sp
|
||||||
stmdb sp!, {r4-r6,r11,r12,lr,pc}
|
stmdb sp!, {r4-r6,r11,r12,lr,pc}
|
||||||
ldr r4, _081E02F0 @ =gRfuState
|
ldr r4, _081E02F0 @ =gSTWIStatus
|
||||||
mov r0, 0x64
|
mov r0, 0x64
|
||||||
ldr r3, [r4]
|
ldr r3, [r4]
|
||||||
mov r6, 0
|
mov r6, 0
|
||||||
@@ -473,7 +473,7 @@ _081E02E0:
|
|||||||
bhi _081E02E0
|
bhi _081E02E0
|
||||||
b _081E031C
|
b _081E031C
|
||||||
.align 2, 0
|
.align 2, 0
|
||||||
_081E02F0: .4byte gRfuState
|
_081E02F0: .4byte gSTWIStatus
|
||||||
_081E02F4: .4byte 0x996601ee
|
_081E02F4: .4byte 0x996601ee
|
||||||
_081E02F8:
|
_081E02F8:
|
||||||
mov r2, 0xFF00
|
mov r2, 0xFF00
|
||||||
@@ -510,7 +510,7 @@ handshake_wait: @ 81E0350
|
|||||||
mov r1, 0x128
|
mov r1, 0x128
|
||||||
add r1, r1, 0x4000000
|
add r1, r1, 0x4000000
|
||||||
mov r0, r0, lsl 16
|
mov r0, r0, lsl 16
|
||||||
ldr r2, _081E03B4 @ =gRfuState
|
ldr r2, _081E03B4 @ =gSTWIStatus
|
||||||
sub r11, r12, 0x4
|
sub r11, r12, 0x4
|
||||||
mov lr, r0, lsr 14
|
mov lr, r0, lsr 14
|
||||||
ldr r12, [r2]
|
ldr r12, [r2]
|
||||||
@@ -533,7 +533,7 @@ _081E03A0:
|
|||||||
ldmdb r11, {r11,sp,lr}
|
ldmdb r11, {r11,sp,lr}
|
||||||
bx lr
|
bx lr
|
||||||
.align 2, 0
|
.align 2, 0
|
||||||
_081E03B4: .4byte gRfuState
|
_081E03B4: .4byte gSTWIStatus
|
||||||
arm_func_end handshake_wait
|
arm_func_end handshake_wait
|
||||||
|
|
||||||
arm_func_start STWI_set_timer_in_RAM
|
arm_func_start STWI_set_timer_in_RAM
|
||||||
@@ -544,7 +544,7 @@ STWI_set_timer_in_RAM: @ 81E03B8
|
|||||||
add r1, r1, 0x4000000
|
add r1, r1, 0x4000000
|
||||||
mov r3, 0
|
mov r3, 0
|
||||||
sub r11, r12, 0x4
|
sub r11, r12, 0x4
|
||||||
ldr r12, _081E0470 @ =gRfuState
|
ldr r12, _081E0470 @ =gSTWIStatus
|
||||||
and lr, r0, 0xFF
|
and lr, r0, 0xFF
|
||||||
ldr r2, [r12]
|
ldr r2, [r12]
|
||||||
cmp lr, 0x50
|
cmp lr, 0x50
|
||||||
@@ -589,7 +589,7 @@ _081E0458:
|
|||||||
mov r3, 0x3
|
mov r3, 0x3
|
||||||
b _081E0488
|
b _081E0488
|
||||||
.align 2, 0
|
.align 2, 0
|
||||||
_081E0470: .4byte gRfuState
|
_081E0470: .4byte gSTWIStatus
|
||||||
_081E0474:
|
_081E0474:
|
||||||
mvn r3, 0x850
|
mvn r3, 0x850
|
||||||
sub r3, r3, 0x2
|
sub r3, r3, 0x2
|
||||||
@@ -621,7 +621,7 @@ STWI_stop_timer_in_RAM: @ 81E04C8
|
|||||||
mov r12, sp
|
mov r12, sp
|
||||||
stmdb sp!, {r11,r12,lr,pc}
|
stmdb sp!, {r11,r12,lr,pc}
|
||||||
mov r1, 0x100
|
mov r1, 0x100
|
||||||
ldr lr, _081E0514 @ =gRfuState
|
ldr lr, _081E0514 @ =gSTWIStatus
|
||||||
add r0, r1, 0x4000000
|
add r0, r1, 0x4000000
|
||||||
ldr r2, [lr]
|
ldr r2, [lr]
|
||||||
sub r11, r12, 0x4
|
sub r11, r12, 0x4
|
||||||
@@ -638,14 +638,14 @@ STWI_stop_timer_in_RAM: @ 81E04C8
|
|||||||
ldmdb r11, {r11,sp,lr}
|
ldmdb r11, {r11,sp,lr}
|
||||||
bx lr
|
bx lr
|
||||||
.align 2, 0
|
.align 2, 0
|
||||||
_081E0514: .4byte gRfuState
|
_081E0514: .4byte gSTWIStatus
|
||||||
arm_func_end STWI_stop_timer_in_RAM
|
arm_func_end STWI_stop_timer_in_RAM
|
||||||
|
|
||||||
arm_func_start STWI_init_slave
|
arm_func_start STWI_init_slave
|
||||||
STWI_init_slave: @ 81E0518
|
STWI_init_slave: @ 81E0518
|
||||||
mov r12, sp
|
mov r12, sp
|
||||||
stmdb sp!, {r11,r12,lr,pc}
|
stmdb sp!, {r11,r12,lr,pc}
|
||||||
ldr r0, _081E05A0 @ =gRfuState
|
ldr r0, _081E05A0 @ =gSTWIStatus
|
||||||
ldr r2, [r0]
|
ldr r2, [r0]
|
||||||
mov r3, 0x5
|
mov r3, 0x5
|
||||||
str r3, [r2]
|
str r3, [r2]
|
||||||
@@ -678,7 +678,7 @@ STWI_init_slave: @ 81E0518
|
|||||||
ldmdb r11, {r11,sp,lr}
|
ldmdb r11, {r11,sp,lr}
|
||||||
bx lr
|
bx lr
|
||||||
.align 2, 0
|
.align 2, 0
|
||||||
_081E05A0: .4byte gRfuState
|
_081E05A0: .4byte gSTWIStatus
|
||||||
arm_func_end STWI_init_slave
|
arm_func_end STWI_init_slave
|
||||||
|
|
||||||
arm_func_start sub_81E05A4
|
arm_func_start sub_81E05A4
|
||||||
|
|||||||
+2
-2
@@ -132,7 +132,7 @@ _080F86F0: .4byte 0x04000208
|
|||||||
thumb_func_start sub_80F86F4
|
thumb_func_start sub_80F86F4
|
||||||
sub_80F86F4: @ 80F86F4
|
sub_80F86F4: @ 80F86F4
|
||||||
push {r4,lr}
|
push {r4,lr}
|
||||||
ldr r0, _080F8728 @ =gUnknown_3001190
|
ldr r0, _080F8728 @ =gRfuAPIBuffer
|
||||||
ldr r1, _080F872C @ =0x00000e64
|
ldr r1, _080F872C @ =0x00000e64
|
||||||
ldr r4, _080F8730 @ =gIntrTable + 0x4
|
ldr r4, _080F8730 @ =gIntrTable + 0x4
|
||||||
adds r2, r4, 0
|
adds r2, r4, 0
|
||||||
@@ -155,7 +155,7 @@ _080F8722:
|
|||||||
pop {r0}
|
pop {r0}
|
||||||
bx r0
|
bx r0
|
||||||
.align 2, 0
|
.align 2, 0
|
||||||
_080F8728: .4byte gUnknown_3001190
|
_080F8728: .4byte gRfuAPIBuffer
|
||||||
_080F872C: .4byte 0x00000e64
|
_080F872C: .4byte 0x00000e64
|
||||||
_080F8730: .4byte gIntrTable + 0x4
|
_080F8730: .4byte gIntrTable + 0x4
|
||||||
_080F8734: .4byte gLinkType
|
_080F8734: .4byte gLinkType
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
gRfuState
|
|
||||||
gRfuSlotStatusUNI
|
gRfuSlotStatusUNI
|
||||||
gRfuSlotStatusNI
|
gRfuSlotStatusNI
|
||||||
gRfuLinkStatus
|
gRfuLinkStatus
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
gSTWIStatus
|
||||||
+17
-12
@@ -137,18 +137,20 @@
|
|||||||
// Definition Data Returned by Return Values for Library Functions
|
// Definition Data Returned by Return Values for Library Functions
|
||||||
// *******************************************************
|
// *******************************************************
|
||||||
|
|
||||||
|
// The function doesn't have return value.
|
||||||
// Value of u8 *status for rfu_REQ_pollConnectParent (Connection Trial Status)
|
// Value of u8 *status for rfu_REQ_pollConnectParent (Connection Trial Status)
|
||||||
#define CP_STATUS_DONE 0x00 // Connection successful
|
// #define CP_STATUS_DONE 0x00 // Connection successful
|
||||||
#define CP_STATUS_IN_PROCESS 0x01 // Connecting
|
// #define CP_STATUS_IN_PROCESS 0x01 // Connecting
|
||||||
#define CP_STATUS_SLOT_CLOSED 0x02 // Parent device is not in connection mode with child device
|
// #define CP_STATUS_SLOT_CLOSED 0x02 // Parent device is not in connection mode with child device
|
||||||
#define CP_STATUS_DISCONNECTED 0x03 // Disconnected by parent device while connecting
|
// #define CP_STATUS_DISCONNECTED 0x03 // Disconnected by parent device while connecting
|
||||||
#define CP_STATUS_UNKNOWN 0xff // Cannot read status due to REQ-API execution error
|
// #define CP_STATUS_UNKNOWN 0xff // Cannot read status due to REQ-API execution error
|
||||||
|
|
||||||
|
// The function doesn't exist.
|
||||||
// Value of u8 *status argument for rfu_REQ_pollRecoveryConnect (Link Restore Status)
|
// Value of u8 *status argument for rfu_REQ_pollRecoveryConnect (Link Restore Status)
|
||||||
#define RC_STATUS_DONE 0x00 // Connection restore successful
|
// #define RC_STATUS_DONE 0x00 // Connection restore successful
|
||||||
#define RC_STATUS_FAILED 0x01 // Connection restore failure (meaningless to try anymore)
|
// #define RC_STATUS_FAILED 0x01 // Connection restore failure (meaningless to try anymore)
|
||||||
#define RC_STATUS_SEARCHING_PARENT 0x02 // Searching for parent device
|
// #define RC_STATUS_SEARCHING_PARENT 0x02 // Searching for parent device
|
||||||
#define RC_STATUS_UNKNOWN 0xff // Cannot read status due to REQ-API execution error
|
// #define RC_STATUS_UNKNOWN 0xff // Cannot read status due to REQ-API execution error
|
||||||
|
|
||||||
// Value of u8 *linkLossReason argument for rfu_REQBN_watchLink (Reason for Link Loss)
|
// Value of u8 *linkLossReason argument for rfu_REQBN_watchLink (Reason for Link Loss)
|
||||||
#define REASON_DISCONNECTED 0x00 // State of complete disconnection with rfuLL_disconnect and no possibility of restoring the link (can detect only child device)
|
#define REASON_DISCONNECTED 0x00 // State of complete disconnection with rfuLL_disconnect and no possibility of restoring the link (can detect only child device)
|
||||||
@@ -189,6 +191,7 @@
|
|||||||
|
|
||||||
// Error codes returned by rfu_NI_setSendData, rfu_UNI_setSendData, and rfu_NI_CHILD_setSendGameName
|
// Error codes returned by rfu_NI_setSendData, rfu_UNI_setSendData, and rfu_NI_CHILD_setSendGameName
|
||||||
#define ERR_MODE 0x0300
|
#define ERR_MODE 0x0300
|
||||||
|
#define ERR_MODE_NOT_PARENT (ERR_MODE | 0x0000) // not in SDK
|
||||||
#define ERR_MODE_NOT_CONNECTED (ERR_MODE | 0x0001) // RFU is not in connection mode (parent or child)
|
#define ERR_MODE_NOT_CONNECTED (ERR_MODE | 0x0001) // RFU is not in connection mode (parent or child)
|
||||||
|
|
||||||
#define ERR_SLOT 0x0400
|
#define ERR_SLOT 0x0400
|
||||||
@@ -215,6 +218,8 @@
|
|||||||
// Error code during UNI-type communication (code entered into gRfuSlotStatusUNI[x]->recv.errorCode)
|
// Error code during UNI-type communication (code entered into gRfuSlotStatusUNI[x]->recv.errorCode)
|
||||||
#define ERR_RECV_DATA_OVERWRITED (ERR_DATA_RECV | 0x0008) // Received new data when gRfuSlotStatusUNI[x]->recv.newDataFlag=1
|
#define ERR_RECV_DATA_OVERWRITED (ERR_DATA_RECV | 0x0008) // Received new data when gRfuSlotStatusUNI[x]->recv.newDataFlag=1
|
||||||
|
|
||||||
|
// not in SDK header
|
||||||
|
#define ERR_RECV_UNK (ERR_DATA_RECV | 0x0001 | 0x0008)
|
||||||
|
|
||||||
// *******************************************************
|
// *******************************************************
|
||||||
// Definition Data Used by Global Variables in the Library
|
// Definition Data Used by Global Variables in the Library
|
||||||
@@ -496,7 +501,7 @@ struct RfuS32Id
|
|||||||
u16 unkA;
|
u16 unkA;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct RfuStructsBuffer
|
struct RfuAPIBuffer
|
||||||
{
|
{
|
||||||
struct RfuLinkStatus linkStatus;
|
struct RfuLinkStatus linkStatus;
|
||||||
struct RfuStatic static_;
|
struct RfuStatic static_;
|
||||||
@@ -506,7 +511,7 @@ struct RfuStructsBuffer
|
|||||||
struct RfuIntrStruct intr;
|
struct RfuIntrStruct intr;
|
||||||
};
|
};
|
||||||
|
|
||||||
extern struct STWIStatus *gRfuState;
|
extern struct STWIStatus *gSTWIStatus;
|
||||||
extern struct RfuLinkStatus *gRfuLinkStatus;
|
extern struct RfuLinkStatus *gRfuLinkStatus;
|
||||||
extern struct RfuStatic *gRfuStatic;
|
extern struct RfuStatic *gRfuStatic;
|
||||||
extern struct RfuFixed *gRfuFixed;
|
extern struct RfuFixed *gRfuFixed;
|
||||||
@@ -522,7 +527,7 @@ s32 AgbRFU_checkID(u8);
|
|||||||
// librfu_rfu
|
// librfu_rfu
|
||||||
// API Initialization and Initial Settings
|
// API Initialization and Initial Settings
|
||||||
// API Initialization
|
// API Initialization
|
||||||
u16 rfu_initializeAPI(struct RfuStructsBuffer *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p, bool8 copyInterruptToRam);
|
u16 rfu_initializeAPI(struct RfuAPIBuffer *APIBuffer, u16 buffByteSize, IntrFunc *sioIntrTable_p, bool8 copyInterruptToRam);
|
||||||
// Set Timer Interrupt
|
// Set Timer Interrupt
|
||||||
void rfu_setTimerInterrupt(u8 timerNo, IntrFunc *timerIntrTable_p);
|
void rfu_setTimerInterrupt(u8 timerNo, IntrFunc *timerIntrTable_p);
|
||||||
// Resident Function called from within a V-Blank Interrupt
|
// Resident Function called from within a V-Blank Interrupt
|
||||||
|
|||||||
+166
-167
File diff suppressed because it is too large
Load Diff
+4
-4
@@ -17,10 +17,10 @@ s32 AgbRFU_checkID(u8 r5)
|
|||||||
if (REG_IME == 0)
|
if (REG_IME == 0)
|
||||||
return -1;
|
return -1;
|
||||||
r8 = REG_IE;
|
r8 = REG_IE;
|
||||||
gRfuState->state = 10;
|
gSTWIStatus->state = 10;
|
||||||
STWI_set_Callback_ID(Sio32IDIntr);
|
STWI_set_Callback_ID(Sio32IDIntr);
|
||||||
Sio32IDInit();
|
Sio32IDInit();
|
||||||
r4 = ®_TMCNT_L(gRfuState->timerSelect);
|
r4 = ®_TMCNT_L(gSTWIStatus->timerSelect);
|
||||||
r5 *= 8;
|
r5 *= 8;
|
||||||
while (--r5 != 0xFF)
|
while (--r5 != 0xFF)
|
||||||
{
|
{
|
||||||
@@ -38,7 +38,7 @@ s32 AgbRFU_checkID(u8 r5)
|
|||||||
REG_IME = 0;
|
REG_IME = 0;
|
||||||
REG_IE = r8;
|
REG_IE = r8;
|
||||||
REG_IME = 1;
|
REG_IME = 1;
|
||||||
gRfuState->state = 0;
|
gSTWIStatus->state = 0;
|
||||||
STWI_set_Callback_ID(NULL);
|
STWI_set_Callback_ID(NULL);
|
||||||
return r6;
|
return r6;
|
||||||
}
|
}
|
||||||
@@ -46,7 +46,7 @@ s32 AgbRFU_checkID(u8 r5)
|
|||||||
static void Sio32IDInit(void)
|
static void Sio32IDInit(void)
|
||||||
{
|
{
|
||||||
REG_IME = 0;
|
REG_IME = 0;
|
||||||
REG_IE &= ~((8 << gRfuState->timerSelect) | INTR_FLAG_SERIAL);
|
REG_IE &= ~((8 << gSTWIStatus->timerSelect) | INTR_FLAG_SERIAL);
|
||||||
REG_IME = 1;
|
REG_IME = 1;
|
||||||
REG_RCNT = 0;
|
REG_RCNT = 0;
|
||||||
REG_SIOCNT = SIO_32BIT_MODE;
|
REG_SIOCNT = SIO_32BIT_MODE;
|
||||||
|
|||||||
+146
-144
@@ -8,6 +8,8 @@ static void STWI_stop_timer(void);
|
|||||||
static s32 STWI_restart_Command(void);
|
static s32 STWI_restart_Command(void);
|
||||||
static s32 STWI_reset_ClockCounter(void);
|
static s32 STWI_reset_ClockCounter(void);
|
||||||
|
|
||||||
|
struct STWIStatus *gSTWIStatus;
|
||||||
|
|
||||||
void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 copyInterruptToRam)
|
void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, bool8 copyInterruptToRam)
|
||||||
{
|
{
|
||||||
// If we're copying our interrupt into RAM, DMA it to block1 and use
|
// If we're copying our interrupt into RAM, DMA it to block1 and use
|
||||||
@@ -17,27 +19,27 @@ void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, b
|
|||||||
{
|
{
|
||||||
*interrupt = (IntrFunc)interruptStruct->block1;
|
*interrupt = (IntrFunc)interruptStruct->block1;
|
||||||
DmaCopy16(3, &IntrSIO32, interruptStruct->block1, sizeof(interruptStruct->block1));
|
DmaCopy16(3, &IntrSIO32, interruptStruct->block1, sizeof(interruptStruct->block1));
|
||||||
gRfuState = &interruptStruct->block2;
|
gSTWIStatus = &interruptStruct->block2;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
*interrupt = IntrSIO32;
|
*interrupt = IntrSIO32;
|
||||||
gRfuState = (struct STWIStatus *)interruptStruct->block1;
|
gSTWIStatus = (struct STWIStatus *)interruptStruct->block1;
|
||||||
}
|
}
|
||||||
gRfuState->rxPacket = &interruptStruct->rxPacketAlloc;
|
gSTWIStatus->rxPacket = &interruptStruct->rxPacketAlloc;
|
||||||
gRfuState->txPacket = &interruptStruct->txPacketAlloc;
|
gSTWIStatus->txPacket = &interruptStruct->txPacketAlloc;
|
||||||
gRfuState->msMode = 1;
|
gSTWIStatus->msMode = 1;
|
||||||
gRfuState->state = 0;
|
gSTWIStatus->state = 0;
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
gRfuState->reqNext = 0;
|
gSTWIStatus->reqNext = 0;
|
||||||
gRfuState->ackLength = 0;
|
gSTWIStatus->ackLength = 0;
|
||||||
gRfuState->ackNext = 0;
|
gSTWIStatus->ackNext = 0;
|
||||||
gRfuState->ackActiveCommand = 0;
|
gSTWIStatus->ackActiveCommand = 0;
|
||||||
gRfuState->timerState = 0;
|
gSTWIStatus->timerState = 0;
|
||||||
gRfuState->timerActive = 0;
|
gSTWIStatus->timerActive = 0;
|
||||||
gRfuState->error = 0;
|
gSTWIStatus->error = 0;
|
||||||
gRfuState->recoveryCount = 0;
|
gSTWIStatus->recoveryCount = 0;
|
||||||
gRfuState->unk_2c = 0;
|
gSTWIStatus->unk_2c = 0;
|
||||||
REG_RCNT = 0x100; // TODO: mystery bit?
|
REG_RCNT = 0x100; // TODO: mystery bit?
|
||||||
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
|
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
|
||||||
STWI_init_Callback_M();
|
STWI_init_Callback_M();
|
||||||
@@ -48,8 +50,8 @@ void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, b
|
|||||||
void STWI_init_timer(IntrFunc *interrupt, s32 timerSelect)
|
void STWI_init_timer(IntrFunc *interrupt, s32 timerSelect)
|
||||||
{
|
{
|
||||||
*interrupt = STWI_intr_timer;
|
*interrupt = STWI_intr_timer;
|
||||||
gRfuState->timerSelect = timerSelect;
|
gSTWIStatus->timerSelect = timerSelect;
|
||||||
IntrEnable(INTR_FLAG_TIMER0 << gRfuState->timerSelect);
|
IntrEnable(INTR_FLAG_TIMER0 << gSTWIStatus->timerSelect);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AgbRFU_SoftReset(void)
|
void AgbRFU_SoftReset(void)
|
||||||
@@ -59,8 +61,8 @@ void AgbRFU_SoftReset(void)
|
|||||||
|
|
||||||
REG_RCNT = 0x8000;
|
REG_RCNT = 0x8000;
|
||||||
REG_RCNT = 0x80A0; // all these bits are undocumented
|
REG_RCNT = 0x80A0; // all these bits are undocumented
|
||||||
timerL = ®_TMCNT_L(gRfuState->timerSelect);
|
timerL = ®_TMCNT_L(gSTWIStatus->timerSelect);
|
||||||
timerH = ®_TMCNT_H(gRfuState->timerSelect);
|
timerH = ®_TMCNT_H(gSTWIStatus->timerSelect);
|
||||||
*timerH = 0;
|
*timerH = 0;
|
||||||
*timerL = 0;
|
*timerL = 0;
|
||||||
*timerH = TIMER_ENABLE | TIMER_1024CLK;
|
*timerH = TIMER_ENABLE | TIMER_1024CLK;
|
||||||
@@ -69,24 +71,24 @@ void AgbRFU_SoftReset(void)
|
|||||||
*timerH = 3;
|
*timerH = 3;
|
||||||
REG_RCNT = 0x80A0;
|
REG_RCNT = 0x80A0;
|
||||||
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
|
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
|
||||||
gRfuState->state = 0;
|
gSTWIStatus->state = 0;
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
gRfuState->reqNext = 0;
|
gSTWIStatus->reqNext = 0;
|
||||||
gRfuState->reqActiveCommand = 0;
|
gSTWIStatus->reqActiveCommand = 0;
|
||||||
gRfuState->ackLength = 0;
|
gSTWIStatus->ackLength = 0;
|
||||||
gRfuState->ackNext = 0;
|
gSTWIStatus->ackNext = 0;
|
||||||
gRfuState->ackActiveCommand = 0;
|
gSTWIStatus->ackActiveCommand = 0;
|
||||||
gRfuState->timerState = 0;
|
gSTWIStatus->timerState = 0;
|
||||||
gRfuState->timerActive = 0;
|
gSTWIStatus->timerActive = 0;
|
||||||
gRfuState->error = 0;
|
gSTWIStatus->error = 0;
|
||||||
gRfuState->msMode = 1;
|
gSTWIStatus->msMode = 1;
|
||||||
gRfuState->recoveryCount = 0;
|
gSTWIStatus->recoveryCount = 0;
|
||||||
gRfuState->unk_2c = 0;
|
gSTWIStatus->unk_2c = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STWI_set_MS_mode(u8 mode)
|
void STWI_set_MS_mode(u8 mode)
|
||||||
{
|
{
|
||||||
gRfuState->msMode = mode;
|
gSTWIStatus->msMode = mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 STWI_read_status(u8 index)
|
u16 STWI_read_status(u8 index)
|
||||||
@@ -94,13 +96,13 @@ u16 STWI_read_status(u8 index)
|
|||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
return gRfuState->error;
|
return gSTWIStatus->error;
|
||||||
case 1:
|
case 1:
|
||||||
return gRfuState->msMode;
|
return gSTWIStatus->msMode;
|
||||||
case 2:
|
case 2:
|
||||||
return gRfuState->state;
|
return gSTWIStatus->state;
|
||||||
case 3:
|
case 3:
|
||||||
return gRfuState->reqActiveCommand;
|
return gSTWIStatus->reqActiveCommand;
|
||||||
default:
|
default:
|
||||||
return 0xFFFF;
|
return 0xFFFF;
|
||||||
}
|
}
|
||||||
@@ -119,31 +121,31 @@ void STWI_init_Callback_S(void)
|
|||||||
// The callback can take 2 or 3 arguments.
|
// The callback can take 2 or 3 arguments.
|
||||||
void STWI_set_Callback_M(void *callbackM)
|
void STWI_set_Callback_M(void *callbackM)
|
||||||
{
|
{
|
||||||
gRfuState->callbackM = callbackM;
|
gSTWIStatus->callbackM = callbackM;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STWI_set_Callback_S(void (*callbackS)(u16))
|
void STWI_set_Callback_S(void (*callbackS)(u16))
|
||||||
{
|
{
|
||||||
gRfuState->callbackS = callbackS;
|
gSTWIStatus->callbackS = callbackS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STWI_set_Callback_ID(void (*func)(void)) // name in SDK, but is actually setting a function pointer
|
void STWI_set_Callback_ID(void (*func)(void)) // name in SDK, but is actually setting a function pointer
|
||||||
{
|
{
|
||||||
gRfuState->unk_20 = func;
|
gSTWIStatus->unk_20 = func;
|
||||||
}
|
}
|
||||||
|
|
||||||
u16 STWI_poll_CommandEnd(void)
|
u16 STWI_poll_CommandEnd(void)
|
||||||
{
|
{
|
||||||
while (gRfuState->unk_2c == TRUE)
|
while (gSTWIStatus->unk_2c == TRUE)
|
||||||
;
|
;
|
||||||
return gRfuState->error;
|
return gSTWIStatus->error;
|
||||||
}
|
}
|
||||||
|
|
||||||
void STWI_send_ResetREQ(void)
|
void STWI_send_ResetREQ(void)
|
||||||
{
|
{
|
||||||
if (!STWI_init(ID_RESET_REQ))
|
if (!STWI_init(ID_RESET_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -152,7 +154,7 @@ void STWI_send_LinkStatusREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_LINK_STATUS_REQ))
|
if (!STWI_init(ID_LINK_STATUS_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -161,7 +163,7 @@ void STWI_send_VersionStatusREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_VERSION_STATUS_REQ))
|
if (!STWI_init(ID_VERSION_STATUS_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -170,7 +172,7 @@ void STWI_send_SystemStatusREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_SYSTEM_STATUS_REQ))
|
if (!STWI_init(ID_SYSTEM_STATUS_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -179,7 +181,7 @@ void STWI_send_SlotStatusREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_SLOT_STATUS_REQ))
|
if (!STWI_init(ID_SLOT_STATUS_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -188,7 +190,7 @@ void STWI_send_ConfigStatusREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_CONFIG_STATUS_REQ))
|
if (!STWI_init(ID_CONFIG_STATUS_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -200,9 +202,9 @@ void STWI_send_GameConfigREQ(const u8 *unk1, const u8 *data)
|
|||||||
|
|
||||||
if (!STWI_init(ID_GAME_CONFIG_REQ))
|
if (!STWI_init(ID_GAME_CONFIG_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 6;
|
gSTWIStatus->reqLength = 6;
|
||||||
// TODO: what is unk1
|
// TODO: what is unk1
|
||||||
packetBytes = gRfuState->txPacket->rfuPacket8.data;
|
packetBytes = gSTWIStatus->txPacket->rfuPacket8.data;
|
||||||
packetBytes += sizeof(u32);
|
packetBytes += sizeof(u32);
|
||||||
*(u16 *)packetBytes = *(u16 *)unk1;
|
*(u16 *)packetBytes = *(u16 *)unk1;
|
||||||
packetBytes += sizeof(u16);
|
packetBytes += sizeof(u16);
|
||||||
@@ -229,8 +231,8 @@ void STWI_send_SystemConfigREQ(u16 unk1, u8 unk2, u8 unk3)
|
|||||||
{
|
{
|
||||||
u8 *packetBytes;
|
u8 *packetBytes;
|
||||||
|
|
||||||
gRfuState->reqLength = 1;
|
gSTWIStatus->reqLength = 1;
|
||||||
packetBytes = gRfuState->txPacket->rfuPacket8.data;
|
packetBytes = gSTWIStatus->txPacket->rfuPacket8.data;
|
||||||
packetBytes += sizeof(u32);
|
packetBytes += sizeof(u32);
|
||||||
*packetBytes++ = unk3;
|
*packetBytes++ = unk3;
|
||||||
*packetBytes++ = unk2;
|
*packetBytes++ = unk2;
|
||||||
@@ -243,7 +245,7 @@ void STWI_send_SC_StartREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_SC_START_REQ))
|
if (!STWI_init(ID_SC_START_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -252,7 +254,7 @@ void STWI_send_SC_PollingREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_SC_POLL_REQ))
|
if (!STWI_init(ID_SC_POLL_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -261,7 +263,7 @@ void STWI_send_SC_EndREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_SC_END_REQ))
|
if (!STWI_init(ID_SC_END_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -270,7 +272,7 @@ void STWI_send_SP_StartREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_SP_START_REQ))
|
if (!STWI_init(ID_SP_START_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -279,7 +281,7 @@ void STWI_send_SP_PollingREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_SP_POLL_REQ))
|
if (!STWI_init(ID_SP_POLL_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -288,7 +290,7 @@ void STWI_send_SP_EndREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_SP_END_REQ))
|
if (!STWI_init(ID_SP_END_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -297,8 +299,8 @@ void STWI_send_CP_StartREQ(u16 unk1)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_CP_START_REQ))
|
if (!STWI_init(ID_CP_START_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 1;
|
gSTWIStatus->reqLength = 1;
|
||||||
gRfuState->txPacket->rfuPacket32.data[0] = unk1;
|
gSTWIStatus->txPacket->rfuPacket32.data[0] = unk1;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -307,7 +309,7 @@ void STWI_send_CP_PollingREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_CP_POLL_REQ))
|
if (!STWI_init(ID_CP_POLL_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,7 +318,7 @@ void STWI_send_CP_EndREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_CP_END_REQ))
|
if (!STWI_init(ID_CP_END_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -328,8 +330,8 @@ void STWI_send_DataTxREQ(const void *in, u8 size)
|
|||||||
u8 reqLength = (size / sizeof(u32));
|
u8 reqLength = (size / sizeof(u32));
|
||||||
if (size & (sizeof(u32) - 1))
|
if (size & (sizeof(u32) - 1))
|
||||||
reqLength += 1;
|
reqLength += 1;
|
||||||
gRfuState->reqLength = reqLength;
|
gSTWIStatus->reqLength = reqLength;
|
||||||
CpuCopy32(in, gRfuState->txPacket->rfuPacket32.data, gRfuState->reqLength * sizeof(u32));
|
CpuCopy32(in, gSTWIStatus->txPacket->rfuPacket32.data, gSTWIStatus->reqLength * sizeof(u32));
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -341,8 +343,8 @@ void STWI_send_DataTxAndChangeREQ(const void *in, u8 size)
|
|||||||
u8 reqLength = (size / sizeof(u32));
|
u8 reqLength = (size / sizeof(u32));
|
||||||
if (size & (sizeof(u32) - 1))
|
if (size & (sizeof(u32) - 1))
|
||||||
reqLength += 1;
|
reqLength += 1;
|
||||||
gRfuState->reqLength = reqLength;
|
gSTWIStatus->reqLength = reqLength;
|
||||||
CpuCopy32(in, gRfuState->txPacket->rfuPacket32.data, gRfuState->reqLength * sizeof(u32));
|
CpuCopy32(in, gSTWIStatus->txPacket->rfuPacket32.data, gSTWIStatus->reqLength * sizeof(u32));
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -351,7 +353,7 @@ void STWI_send_DataRxREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_DATA_RX_REQ))
|
if (!STWI_init(ID_DATA_RX_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -360,7 +362,7 @@ void STWI_send_MS_ChangeREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_MS_CHANGE_REQ))
|
if (!STWI_init(ID_MS_CHANGE_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -371,14 +373,14 @@ void STWI_send_DataReadyAndChangeREQ(u8 unk)
|
|||||||
{
|
{
|
||||||
if (!unk)
|
if (!unk)
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
u8 *packetBytes;
|
u8 *packetBytes;
|
||||||
|
|
||||||
gRfuState->reqLength = 1;
|
gSTWIStatus->reqLength = 1;
|
||||||
packetBytes = gRfuState->txPacket->rfuPacket8.data;
|
packetBytes = gSTWIStatus->txPacket->rfuPacket8.data;
|
||||||
packetBytes += sizeof(u32);
|
packetBytes += sizeof(u32);
|
||||||
*packetBytes++ = unk;
|
*packetBytes++ = unk;
|
||||||
*packetBytes++ = 0;
|
*packetBytes++ = 0;
|
||||||
@@ -395,8 +397,8 @@ void STWI_send_DisconnectedAndChangeREQ(u8 unk0, u8 unk1)
|
|||||||
{
|
{
|
||||||
u8 *packetBytes;
|
u8 *packetBytes;
|
||||||
|
|
||||||
gRfuState->reqLength = 1;
|
gSTWIStatus->reqLength = 1;
|
||||||
packetBytes = gRfuState->txPacket->rfuPacket8.data;
|
packetBytes = gSTWIStatus->txPacket->rfuPacket8.data;
|
||||||
packetBytes += sizeof(u32);
|
packetBytes += sizeof(u32);
|
||||||
*packetBytes++ = unk0;
|
*packetBytes++ = unk0;
|
||||||
*packetBytes++ = unk1;
|
*packetBytes++ = unk1;
|
||||||
@@ -410,7 +412,7 @@ void STWI_send_ResumeRetransmitAndChangeREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_RESUME_RETRANSMIT_AND_CHANGE_REQ))
|
if (!STWI_init(ID_RESUME_RETRANSMIT_AND_CHANGE_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -419,8 +421,8 @@ void STWI_send_DisconnectREQ(u8 unk)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_DISCONNECT_REQ))
|
if (!STWI_init(ID_DISCONNECT_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 1;
|
gSTWIStatus->reqLength = 1;
|
||||||
gRfuState->txPacket->rfuPacket32.data[0] = unk;
|
gSTWIStatus->txPacket->rfuPacket32.data[0] = unk;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -429,8 +431,8 @@ void STWI_send_TestModeREQ(u8 unk0, u8 unk1)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_TEST_MODE_REQ))
|
if (!STWI_init(ID_TEST_MODE_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 1;
|
gSTWIStatus->reqLength = 1;
|
||||||
gRfuState->txPacket->rfuPacket32.data[0] = unk0 | (unk1 << 8);
|
gSTWIStatus->txPacket->rfuPacket32.data[0] = unk0 | (unk1 << 8);
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -442,9 +444,9 @@ void STWI_send_CPR_StartREQ(u16 unk0, u16 unk1, u8 unk2)
|
|||||||
|
|
||||||
if (!STWI_init(ID_CPR_START_REQ))
|
if (!STWI_init(ID_CPR_START_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 2;
|
gSTWIStatus->reqLength = 2;
|
||||||
arg1 = unk1 | (unk0 << 16);
|
arg1 = unk1 | (unk0 << 16);
|
||||||
packetData = gRfuState->txPacket->rfuPacket32.data;
|
packetData = gSTWIStatus->txPacket->rfuPacket32.data;
|
||||||
packetData[0] = arg1;
|
packetData[0] = arg1;
|
||||||
packetData[1] = unk2;
|
packetData[1] = unk2;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
@@ -455,7 +457,7 @@ void STWI_send_CPR_PollingREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_CPR_POLL_REQ))
|
if (!STWI_init(ID_CPR_POLL_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -464,7 +466,7 @@ void STWI_send_CPR_EndREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_CPR_END_REQ))
|
if (!STWI_init(ID_CPR_END_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -473,18 +475,18 @@ void STWI_send_StopModeREQ(void)
|
|||||||
{
|
{
|
||||||
if (!STWI_init(ID_STOP_MODE_REQ))
|
if (!STWI_init(ID_STOP_MODE_REQ))
|
||||||
{
|
{
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void STWI_intr_timer(void)
|
static void STWI_intr_timer(void)
|
||||||
{
|
{
|
||||||
switch (gRfuState->timerState)
|
switch (gSTWIStatus->timerState)
|
||||||
{
|
{
|
||||||
// TODO: Make an enum for these
|
// TODO: Make an enum for these
|
||||||
case 2:
|
case 2:
|
||||||
gRfuState->timerActive = 1;
|
gSTWIStatus->timerActive = 1;
|
||||||
STWI_set_timer(50);
|
STWI_set_timer(50);
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@@ -493,11 +495,11 @@ static void STWI_intr_timer(void)
|
|||||||
STWI_restart_Command();
|
STWI_restart_Command();
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
gRfuState->timerActive = 1;
|
gSTWIStatus->timerActive = 1;
|
||||||
STWI_stop_timer();
|
STWI_stop_timer();
|
||||||
STWI_reset_ClockCounter();
|
STWI_reset_ClockCounter();
|
||||||
if (gRfuState->callbackM != NULL)
|
if (gSTWIStatus->callbackM != NULL)
|
||||||
gRfuState->callbackM(255, 0);
|
gSTWIStatus->callbackM(255, 0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -507,78 +509,78 @@ static void STWI_set_timer(u8 unk)
|
|||||||
vu16 *timerL;
|
vu16 *timerL;
|
||||||
vu16 *timerH;
|
vu16 *timerH;
|
||||||
|
|
||||||
timerL = ®_TMCNT_L(gRfuState->timerSelect);
|
timerL = ®_TMCNT_L(gSTWIStatus->timerSelect);
|
||||||
timerH = ®_TMCNT_H(gRfuState->timerSelect);
|
timerH = ®_TMCNT_H(gSTWIStatus->timerSelect);
|
||||||
REG_IME = 0;
|
REG_IME = 0;
|
||||||
switch (unk)
|
switch (unk)
|
||||||
{
|
{
|
||||||
case 50:
|
case 50:
|
||||||
*timerL = 0xFCCB;
|
*timerL = 0xFCCB;
|
||||||
gRfuState->timerState = 1;
|
gSTWIStatus->timerState = 1;
|
||||||
break;
|
break;
|
||||||
case 80:
|
case 80:
|
||||||
*timerL = 0xFAE0;
|
*timerL = 0xFAE0;
|
||||||
gRfuState->timerState = 2;
|
gSTWIStatus->timerState = 2;
|
||||||
break;
|
break;
|
||||||
case 100:
|
case 100:
|
||||||
*timerL = 0xF996;
|
*timerL = 0xF996;
|
||||||
gRfuState->timerState = 3;
|
gSTWIStatus->timerState = 3;
|
||||||
break;
|
break;
|
||||||
case 130:
|
case 130:
|
||||||
*timerL = 0xF7AD;
|
*timerL = 0xF7AD;
|
||||||
gRfuState->timerState = 4;
|
gSTWIStatus->timerState = 4;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
*timerH = TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_1024CLK;
|
*timerH = TIMER_ENABLE | TIMER_INTR_ENABLE | TIMER_1024CLK;
|
||||||
REG_IF = INTR_FLAG_TIMER0 << gRfuState->timerSelect;
|
REG_IF = INTR_FLAG_TIMER0 << gSTWIStatus->timerSelect;
|
||||||
REG_IME = 1;
|
REG_IME = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void STWI_stop_timer(void)
|
static void STWI_stop_timer(void)
|
||||||
{
|
{
|
||||||
gRfuState->timerState = 0;
|
gSTWIStatus->timerState = 0;
|
||||||
REG_TMCNT_L(gRfuState->timerSelect) = 0;
|
REG_TMCNT_L(gSTWIStatus->timerSelect) = 0;
|
||||||
REG_TMCNT_H(gRfuState->timerSelect) = 0;
|
REG_TMCNT_H(gSTWIStatus->timerSelect) = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u16 STWI_init(u8 request)
|
static u16 STWI_init(u8 request)
|
||||||
{
|
{
|
||||||
if (!REG_IME)
|
if (!REG_IME)
|
||||||
{
|
{
|
||||||
gRfuState->error = 6;
|
gSTWIStatus->error = ERR_REQ_CMD_IME_DISABLE;
|
||||||
if (gRfuState->callbackM != NULL)
|
if (gSTWIStatus->callbackM != NULL)
|
||||||
gRfuState->callbackM(request, gRfuState->error);
|
gSTWIStatus->callbackM(request, gSTWIStatus->error);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if (gRfuState->unk_2c == TRUE)
|
else if (gSTWIStatus->unk_2c == TRUE)
|
||||||
{
|
{
|
||||||
gRfuState->error = 2;
|
gSTWIStatus->error = ERR_REQ_CMD_SENDING;
|
||||||
gRfuState->unk_2c = FALSE;
|
gSTWIStatus->unk_2c = FALSE;
|
||||||
if (gRfuState->callbackM != NULL)
|
if (gSTWIStatus->callbackM != NULL)
|
||||||
gRfuState->callbackM(request, gRfuState->error);
|
gSTWIStatus->callbackM(request, gSTWIStatus->error);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else if(!gRfuState->msMode)
|
else if(!gSTWIStatus->msMode)
|
||||||
{
|
{
|
||||||
gRfuState->error = 4;
|
gSTWIStatus->error = ERR_REQ_CMD_CLOCK_SLAVE;
|
||||||
if (gRfuState->callbackM != NULL)
|
if (gSTWIStatus->callbackM != NULL)
|
||||||
gRfuState->callbackM(request, gRfuState->error, gRfuState);
|
gSTWIStatus->callbackM(request, gSTWIStatus->error, gSTWIStatus);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gRfuState->unk_2c = TRUE;
|
gSTWIStatus->unk_2c = TRUE;
|
||||||
gRfuState->reqActiveCommand = request;
|
gSTWIStatus->reqActiveCommand = request;
|
||||||
gRfuState->state = 0;
|
gSTWIStatus->state = 0;
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
gRfuState->reqNext = 0;
|
gSTWIStatus->reqNext = 0;
|
||||||
gRfuState->ackLength = 0;
|
gSTWIStatus->ackLength = 0;
|
||||||
gRfuState->ackNext = 0;
|
gSTWIStatus->ackNext = 0;
|
||||||
gRfuState->ackActiveCommand = 0;
|
gSTWIStatus->ackActiveCommand = 0;
|
||||||
gRfuState->timerState = 0;
|
gSTWIStatus->timerState = 0;
|
||||||
gRfuState->timerActive = 0;
|
gSTWIStatus->timerActive = 0;
|
||||||
gRfuState->error = 0;
|
gSTWIStatus->error = 0;
|
||||||
gRfuState->recoveryCount = 0;
|
gSTWIStatus->recoveryCount = 0;
|
||||||
REG_RCNT = 0x100;
|
REG_RCNT = 0x100;
|
||||||
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
|
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@@ -589,15 +591,15 @@ static s32 STWI_start_Command(void)
|
|||||||
{
|
{
|
||||||
u16 imeTemp;
|
u16 imeTemp;
|
||||||
|
|
||||||
// equivalent to gRfuState->txPacket->rfuPacket32.command,
|
// equivalent to gSTWIStatus->txPacket->rfuPacket32.command,
|
||||||
// but the cast here is required to avoid register issue
|
// but the cast here is required to avoid register issue
|
||||||
*(u32 *)gRfuState->txPacket->rfuPacket8.data = 0x99660000 | (gRfuState->reqLength << 8) | gRfuState->reqActiveCommand;
|
*(u32 *)gSTWIStatus->txPacket->rfuPacket8.data = 0x99660000 | (gSTWIStatus->reqLength << 8) | gSTWIStatus->reqActiveCommand;
|
||||||
REG_SIODATA32 = gRfuState->txPacket->rfuPacket32.command;
|
REG_SIODATA32 = gSTWIStatus->txPacket->rfuPacket32.command;
|
||||||
gRfuState->state = 0;
|
gSTWIStatus->state = 0;
|
||||||
gRfuState->reqNext = 1;
|
gSTWIStatus->reqNext = 1;
|
||||||
imeTemp = REG_IME;
|
imeTemp = REG_IME;
|
||||||
REG_IME = 0;
|
REG_IME = 0;
|
||||||
REG_IE |= (INTR_FLAG_TIMER0 << gRfuState->timerSelect);
|
REG_IE |= (INTR_FLAG_TIMER0 << gSTWIStatus->timerSelect);
|
||||||
REG_IE |= INTR_FLAG_SERIAL;
|
REG_IE |= INTR_FLAG_SERIAL;
|
||||||
REG_IME = imeTemp;
|
REG_IME = imeTemp;
|
||||||
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_MULTI_BUSY | SIO_115200_BPS;
|
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_MULTI_BUSY | SIO_115200_BPS;
|
||||||
@@ -606,27 +608,27 @@ static s32 STWI_start_Command(void)
|
|||||||
|
|
||||||
static s32 STWI_restart_Command(void)
|
static s32 STWI_restart_Command(void)
|
||||||
{
|
{
|
||||||
if (gRfuState->recoveryCount <= 1)
|
if (gSTWIStatus->recoveryCount <= 1)
|
||||||
{
|
{
|
||||||
++gRfuState->recoveryCount;
|
++gSTWIStatus->recoveryCount;
|
||||||
STWI_start_Command();
|
STWI_start_Command();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (gRfuState->reqActiveCommand == ID_MS_CHANGE_REQ || gRfuState->reqActiveCommand == ID_DATA_TX_AND_CHANGE_REQ || gRfuState->reqActiveCommand == ID_UNK35_REQ || gRfuState->reqActiveCommand == ID_RESUME_RETRANSMIT_AND_CHANGE_REQ)
|
if (gSTWIStatus->reqActiveCommand == ID_MS_CHANGE_REQ || gSTWIStatus->reqActiveCommand == ID_DATA_TX_AND_CHANGE_REQ || gSTWIStatus->reqActiveCommand == ID_UNK35_REQ || gSTWIStatus->reqActiveCommand == ID_RESUME_RETRANSMIT_AND_CHANGE_REQ)
|
||||||
{
|
{
|
||||||
gRfuState->error = 1;
|
gSTWIStatus->error = ERR_REQ_CMD_CLOCK_DRIFT;
|
||||||
gRfuState->unk_2c = 0;
|
gSTWIStatus->unk_2c = 0;
|
||||||
if (gRfuState->callbackM != NULL)
|
if (gSTWIStatus->callbackM != NULL)
|
||||||
gRfuState->callbackM(gRfuState->reqActiveCommand, gRfuState->error);
|
gSTWIStatus->callbackM(gSTWIStatus->reqActiveCommand, gSTWIStatus->error);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
gRfuState->error = 1;
|
gSTWIStatus->error = ERR_REQ_CMD_CLOCK_DRIFT;
|
||||||
gRfuState->unk_2c = 0;
|
gSTWIStatus->unk_2c = 0;
|
||||||
if (gRfuState->callbackM != NULL)
|
if (gSTWIStatus->callbackM != NULL)
|
||||||
gRfuState->callbackM(gRfuState->reqActiveCommand, gRfuState->error);
|
gSTWIStatus->callbackM(gSTWIStatus->reqActiveCommand, gSTWIStatus->error);
|
||||||
gRfuState->state = 4; // TODO: what's 4
|
gSTWIStatus->state = 4; // TODO: what's 4
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@@ -634,9 +636,9 @@ static s32 STWI_restart_Command(void)
|
|||||||
|
|
||||||
static s32 STWI_reset_ClockCounter(void)
|
static s32 STWI_reset_ClockCounter(void)
|
||||||
{
|
{
|
||||||
gRfuState->state = 5; // TODO: what is 5
|
gSTWIStatus->state = 5; // TODO: what is 5
|
||||||
gRfuState->reqLength = 0;
|
gSTWIStatus->reqLength = 0;
|
||||||
gRfuState->reqNext = 0;
|
gSTWIStatus->reqNext = 0;
|
||||||
REG_SIODATA32 = (1 << 31);
|
REG_SIODATA32 = (1 << 31);
|
||||||
REG_SIOCNT = 0;
|
REG_SIOCNT = 0;
|
||||||
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
|
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
|
||||||
|
|||||||
+1
-1
@@ -74,7 +74,7 @@ gUnknown_3000FE8: @ 3000FE8
|
|||||||
gUnknown_3001188: @ 3001188
|
gUnknown_3001188: @ 3001188
|
||||||
.space 0x8
|
.space 0x8
|
||||||
|
|
||||||
gUnknown_3001190: @ 3001190
|
gRfuAPIBuffer: @ 3001190
|
||||||
.space 0xE68
|
.space 0xE68
|
||||||
|
|
||||||
gUnknown_3001FF8: @ 3001FF8
|
gUnknown_3001FF8: @ 3001FF8
|
||||||
|
|||||||
@@ -160,6 +160,8 @@ gUnknown_3005E94: @ 3005E94
|
|||||||
.include "m4a.o"
|
.include "m4a.o"
|
||||||
.include "agb_flash.o"
|
.include "agb_flash.o"
|
||||||
.align 2
|
.align 2
|
||||||
|
.include "librfu_stwi.o"
|
||||||
|
.align 4
|
||||||
.include "librfu_rfu.o"
|
.include "librfu_rfu.o"
|
||||||
.align 4
|
.align 4
|
||||||
.include "librfu_s32id.o"
|
.include "librfu_s32id.o"
|
||||||
|
|||||||
Reference in New Issue
Block a user