name STWIStatus.unk_2c
This commit is contained in:
+1
-1
@@ -316,7 +316,7 @@ struct STWIStatus
|
||||
void (*callbackID)(void);
|
||||
union RfuPacket *txPacket;
|
||||
union RfuPacket *rxPacket;
|
||||
vu8 unk_2c;
|
||||
vu8 sending;
|
||||
};
|
||||
|
||||
// This struct is used as u8 array in SDK.
|
||||
|
||||
+1
-1
@@ -133,7 +133,7 @@ static void sio32intr_clock_master(void)
|
||||
gSTWIStatus->state = 4; // error
|
||||
}
|
||||
}
|
||||
gSTWIStatus->unk_2c = 0;
|
||||
gSTWIStatus->sending = 0;
|
||||
if (gSTWIStatus->callbackM != NULL)
|
||||
Callback_Dummy_M(gSTWIStatus->reqActiveCommand, gSTWIStatus->error, gSTWIStatus->callbackM);
|
||||
}
|
||||
|
||||
+4
-4
@@ -1144,11 +1144,11 @@ bool8 rfu_getMasterSlave(void)
|
||||
|
||||
if (masterSlave == AGB_CLK_MASTER)
|
||||
{
|
||||
if (gSTWIStatus->unk_2c)
|
||||
if (gSTWIStatus->sending)
|
||||
{
|
||||
if (gSTWIStatus->reqActiveCommand == 39
|
||||
|| gSTWIStatus->reqActiveCommand == 37
|
||||
|| gSTWIStatus->reqActiveCommand == 55)
|
||||
if (gSTWIStatus->reqActiveCommand == ID_MS_CHANGE_REQ
|
||||
|| gSTWIStatus->reqActiveCommand == ID_DATA_TX_AND_CHANGE_REQ
|
||||
|| gSTWIStatus->reqActiveCommand == ID_RESUME_RETRANSMIT_AND_CHANGE_REQ)
|
||||
masterSlave = AGB_CLK_SLAVE;
|
||||
}
|
||||
}
|
||||
|
||||
+22
-19
@@ -39,7 +39,7 @@ void STWI_init_all(struct RfuIntrStruct *interruptStruct, IntrFunc *interrupt, b
|
||||
gSTWIStatus->timerActive = 0;
|
||||
gSTWIStatus->error = 0;
|
||||
gSTWIStatus->recoveryCount = 0;
|
||||
gSTWIStatus->unk_2c = 0;
|
||||
gSTWIStatus->sending = 0;
|
||||
REG_RCNT = 0x100; // TODO: mystery bit?
|
||||
REG_SIOCNT = SIO_INTR_ENABLE | SIO_32BIT_MODE | SIO_115200_BPS;
|
||||
STWI_init_Callback_M();
|
||||
@@ -83,7 +83,7 @@ void AgbRFU_SoftReset(void)
|
||||
gSTWIStatus->error = 0;
|
||||
gSTWIStatus->msMode = AGB_CLK_MASTER;
|
||||
gSTWIStatus->recoveryCount = 0;
|
||||
gSTWIStatus->unk_2c = 0;
|
||||
gSTWIStatus->sending = 0;
|
||||
}
|
||||
|
||||
void STWI_set_MS_mode(u8 mode)
|
||||
@@ -136,7 +136,7 @@ void STWI_set_Callback_ID(void (*func)(void)) // name in SDK, but is actually se
|
||||
|
||||
u16 STWI_poll_CommandEnd(void)
|
||||
{
|
||||
while (gSTWIStatus->unk_2c == TRUE)
|
||||
while (gSTWIStatus->sending == 1)
|
||||
;
|
||||
return gSTWIStatus->error;
|
||||
}
|
||||
@@ -203,7 +203,6 @@ void STWI_send_GameConfigREQ(const u8 *serial_gname, const u8 *uname)
|
||||
if (!STWI_init(ID_GAME_CONFIG_REQ))
|
||||
{
|
||||
gSTWIStatus->reqLength = 6;
|
||||
// TODO: what is unk1
|
||||
packetBytes = gSTWIStatus->txPacket->rfuPacket8.data;
|
||||
packetBytes += sizeof(u32);
|
||||
*(u16 *)packetBytes = *(u16 *)serial_gname;
|
||||
@@ -499,20 +498,17 @@ static void STWI_intr_timer(void)
|
||||
STWI_stop_timer();
|
||||
STWI_reset_ClockCounter();
|
||||
if (gSTWIStatus->callbackM != NULL)
|
||||
gSTWIStatus->callbackM(255, 0);
|
||||
gSTWIStatus->callbackM(ID_CLOCK_SLAVE_MS_CHANGE_ERROR_BY_DMA_REQ, 0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void STWI_set_timer(u8 unk)
|
||||
static void STWI_set_timer(u8 count)
|
||||
{
|
||||
vu16 *timerL;
|
||||
vu16 *timerH;
|
||||
|
||||
timerL = ®_TMCNT_L(gSTWIStatus->timerSelect);
|
||||
timerH = ®_TMCNT_H(gSTWIStatus->timerSelect);
|
||||
vu16 *timerL = ®_TMCNT_L(gSTWIStatus->timerSelect);
|
||||
vu16 *timerH = ®_TMCNT_H(gSTWIStatus->timerSelect);
|
||||
REG_IME = 0;
|
||||
switch (unk)
|
||||
switch (count)
|
||||
{
|
||||
case 50:
|
||||
*timerL = 0xFCCB;
|
||||
@@ -543,25 +539,31 @@ static void STWI_stop_timer(void)
|
||||
REG_TMCNT_H(gSTWIStatus->timerSelect) = 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Set up STWI to send REQ. Returns 1 if error (see below).
|
||||
*/
|
||||
static u16 STWI_init(u8 request)
|
||||
{
|
||||
if (!REG_IME)
|
||||
{
|
||||
// Can't start sending if IME is disabled.
|
||||
gSTWIStatus->error = ERR_REQ_CMD_IME_DISABLE;
|
||||
if (gSTWIStatus->callbackM != NULL)
|
||||
gSTWIStatus->callbackM(request, gSTWIStatus->error);
|
||||
return TRUE;
|
||||
}
|
||||
else if (gSTWIStatus->unk_2c == TRUE)
|
||||
else if (gSTWIStatus->sending == 1)
|
||||
{
|
||||
// Already sending something. Cancel and error.
|
||||
gSTWIStatus->error = ERR_REQ_CMD_SENDING;
|
||||
gSTWIStatus->unk_2c = FALSE;
|
||||
gSTWIStatus->sending = 0;
|
||||
if (gSTWIStatus->callbackM != NULL)
|
||||
gSTWIStatus->callbackM(request, gSTWIStatus->error);
|
||||
return TRUE;
|
||||
}
|
||||
else if(!gSTWIStatus->msMode)
|
||||
else if (gSTWIStatus->msMode == AGB_CLK_SLAVE)
|
||||
{
|
||||
// Can't send if clock slave
|
||||
gSTWIStatus->error = ERR_REQ_CMD_CLOCK_SLAVE;
|
||||
if (gSTWIStatus->callbackM != NULL)
|
||||
gSTWIStatus->callbackM(request, gSTWIStatus->error, gSTWIStatus);
|
||||
@@ -569,7 +571,8 @@ static u16 STWI_init(u8 request)
|
||||
}
|
||||
else
|
||||
{
|
||||
gSTWIStatus->unk_2c = TRUE;
|
||||
// Good to go, start sending
|
||||
gSTWIStatus->sending = 1;
|
||||
gSTWIStatus->reqActiveCommand = request;
|
||||
gSTWIStatus->state = 0; // master send req
|
||||
gSTWIStatus->reqLength = 0;
|
||||
@@ -608,7 +611,7 @@ static s32 STWI_start_Command(void)
|
||||
|
||||
static s32 STWI_restart_Command(void)
|
||||
{
|
||||
if (gSTWIStatus->recoveryCount <= 1)
|
||||
if (gSTWIStatus->recoveryCount < 2)
|
||||
{
|
||||
++gSTWIStatus->recoveryCount;
|
||||
STWI_start_Command();
|
||||
@@ -618,14 +621,14 @@ static s32 STWI_restart_Command(void)
|
||||
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)
|
||||
{
|
||||
gSTWIStatus->error = ERR_REQ_CMD_CLOCK_DRIFT;
|
||||
gSTWIStatus->unk_2c = 0;
|
||||
gSTWIStatus->sending = 0;
|
||||
if (gSTWIStatus->callbackM != NULL)
|
||||
gSTWIStatus->callbackM(gSTWIStatus->reqActiveCommand, gSTWIStatus->error);
|
||||
}
|
||||
else
|
||||
{
|
||||
gSTWIStatus->error = ERR_REQ_CMD_CLOCK_DRIFT;
|
||||
gSTWIStatus->unk_2c = 0;
|
||||
gSTWIStatus->sending = 0;
|
||||
if (gSTWIStatus->callbackM != NULL)
|
||||
gSTWIStatus->callbackM(gSTWIStatus->reqActiveCommand, gSTWIStatus->error);
|
||||
gSTWIStatus->state = 4; // error
|
||||
|
||||
Reference in New Issue
Block a user