1 /*---------------------------------------------------------------------------*
2 Project: CARD API attach test
3 File: attach.c
4
5 Copyright 2000 Nintendo. All rights reserved.
6
7 These coded instructions, statements, and computer programs contain
8 proprietary information of Nintendo of America Inc. and/or Nintendo
9 Company Ltd., and are protected by Federal copyright law. They may
10 not be disclosed to third parties or copied or duplicated in any form,
11 in whole or in part, without the prior written consent of Nintendo.
12
13 $Log: format.c,v $
14 Revision 1.3 2007/07/03 04:47:31 mitu
15 added the message of the end of the program.
16
17 Revision 1.2 2006/02/20 04:13:08 mitu
18 changed include path from dolphin/ to revolution/.
19
20 Revision 1.1 2006/01/31 10:48:30 mitu
21 (none)
22
23
24 2 01/02/22 13:02 Shiki
25 Added support for multiple sector sizes.
26
27 1 11/28/00 2:13p Tian
28 Moved from card tests directories.
29
30 2 9/06/00 8:23p Shiki
31 Revised to use EXIProbe() first.
32
33 1 7/14/00 4:16p Shiki
34 Initial check-in.
35 $NoKeywords: $
36 *---------------------------------------------------------------------------*/
37
38 #include <revolution.h>
39
40 #define CARD_CHAN 1
41
42 u8 CardWorkArea[CARD_WORKAREA_SIZE] ATTRIBUTE_ALIGN(32);
43
main(void)44 int main(void)
45 {
46 s32 result;
47 u16 encode;
48 u16 size;
49 u32 sectorSize;
50
51 OSInit();
52 CARDInit();
53
54 // Probe
55 OSReport("Insert card in slot %c.\n", "AB"[CARD_CHAN]);
56 while (!CARDProbe(CARD_CHAN))
57 {
58 ;
59 }
60
61 // Mount
62 OSReport("CARDMount ");
63 result = CARDMountAsync(CARD_CHAN, CardWorkArea, 0, 0);
64 if (result < 0)
65 {
66 OSReport("failed. (%d)\n", result);
67 return 1;
68 }
69 while ((result = CARDGetResultCode(CARD_CHAN)) == CARD_RESULT_BUSY)
70 {
71 ;
72 }
73 switch (result)
74 {
75 case CARD_RESULT_READY:
76 OSReport("done. (%d)\n", result);
77 break;
78 case CARD_RESULT_BROKEN:
79 case CARD_RESULT_ENCODING:
80 OSReport("failed. (%d)\n", result);
81 break;
82 default:
83 OSReport("failed. (%d)\n", result);
84 return 1;
85 break;
86 }
87
88 // Format
89 OSReport("CARDFormat ");
90 result = CARDFormatAsync(CARD_CHAN, 0);
91 if (result < 0)
92 {
93 OSReport("failed. (%d)\n", result);
94 return 1;
95 }
96 while ((result = CARDGetResultCode(CARD_CHAN)) == CARD_RESULT_BUSY)
97 {
98 ;
99 }
100 if (result < 0)
101 {
102 OSReport("failed. (%d)\n", result);
103 return 1;
104 }
105 OSReport("done. (%d)\n", result);
106
107 result = CARDGetEncoding(CARD_CHAN, &encode);
108 if (0 <= result)
109 {
110 OSReport("Character encoding: %s(%d)\n",
111 encode == CARD_ENCODE_SJIS ? "SJIS" : "ANSI", encode);
112 }
113
114 // Memory size
115 result = CARDGetMemSize(CARD_CHAN, &size);
116 if (result < 0)
117 {
118 OSReport("CARDGetMemSize() failed. (%d)\n", result);
119 return 1;
120 }
121 OSReport("%u Mbits memory card.\n", size);
122
123 // Sector size
124 result = CARDGetSectorSize(CARD_CHAN, §orSize);
125 if (result < 0)
126 {
127 OSReport("CARDGetSectorSize() failed. (%d)\n", result);
128 return 1;
129 }
130 OSReport("Sector size %u bytes.\n", sectorSize);
131
132 // Unmount
133 CARDUnmount(CARD_CHAN);
134
135 OSReport("End of program\n");
136
137 return 0;
138 }
139