gbpakpower.c
1.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*---------------------------------------------------------------------
Copyright (C) 1997, Nintendo.
File gbpakpower.c
Coded by Koji Mitsunari. Oct 2, 1997.
Modified by Koji Mitsunari. Apr 16, 1998.
Comments 64GB-PAK Power ON/OFF
$Id:
---------------------------------------------------------------------*/
/**************************************************************************
*
* $Revision: 1.2 $
* $Date: 2003/03/25 20:42:32 $
* $Source:
*
**************************************************************************/
#include "osint.h"
#include "controller.h"
#define GBPAK_POWER_WAIT 120000 /* micro sec. */
#ifndef BBPLAYER
extern OSTimer __osGbpakTimer;
extern OSMesgQueue __osGbpakTimerQ;
extern OSMesg __osGbpakTimerMsg;
#endif
s32
osGbpakPower(OSPfs *pfs, s32 flag) /* flag OS_GBPAK_ON or OS_GBPAK_OFF */
{
#ifdef BBPLAYER
return PFS_ERR_DEVICE;
#else
s32 i, ret;
u8 temp[BLOCKSIZE];
for ( i = 0 ; i < BLOCKSIZE ; temp[i++] = (u8)flag);
ret = __osContRamWrite(pfs->queue, pfs->channel, GB_POWER_ADDR, temp, 0);
if (ret == PFS_ERR_NEW_PACK) {
ret = osGbpakInit(pfs->queue, pfs, pfs->channel);
if (ret == 0) {
ret = __osContRamWrite(pfs->queue, pfs->channel, GB_POWER_ADDR, temp, 0);
if (ret == PFS_ERR_NEW_PACK) {
ret = PFS_ERR_CONTRFAIL;
}
}
}
if (flag != OS_GBPAK_POWER_OFF) {
osSetTimer(&__osGbpakTimer, OS_USEC_TO_CYCLES(GBPAK_POWER_WAIT), 0,
&__osGbpakTimerQ, &__osGbpakTimerMsg);
(void)osRecvMesg(&__osGbpakTimerQ, NULL, OS_MESG_BLOCK);
}
return(ret);
#endif
}