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
60
61
62
63
64
65
66
67
68
69
|
/**
* File: voiceinit.c
*
* Initializes Voice Recognition System control structure and hardware
*/
#include "ultra64.h"
#include "PR/controller_voice.h"
#include "PR/os_voice.h"
#include "PR/controller.h"
#include "macros.h"
static u8 sCmds[] = {
0x1E, 0x6E, 0x08, 0x56, 0x03,
};
s32 osVoiceInit(OSMesgQueue* mq, OSVoiceHandle* hd, int channel) {
s32 errorCode;
s32 i;
u8 status = 0;
u8 data[4];
hd->__channel = channel;
hd->__mq = mq;
hd->__mode = VOICE_HANDLE_MODE_0;
errorCode = __osVoiceGetStatus(mq, channel, &status);
if (errorCode != 0) {
return errorCode;
}
if (__osContChannelReset(mq, channel) != 0) {
return CONT_ERR_CONTRFAIL;
}
for (i = 0; i < ARRAY_COUNT(sCmds); i++) {
errorCode = __osVoiceSetADConverter(mq, channel, sCmds[i]);
if (errorCode != 0) {
return errorCode;
}
}
errorCode = __osVoiceGetStatus(mq, channel, &status);
if (errorCode != 0) {
return errorCode;
}
if (status & 2) {
return CONT_ERR_VOICE_NO_RESPONSE;
}
/**
* data[0] = 0
* data[1] = 0
* data[2] = 1
* data[3] = 0
*/
*(u32*)data = 0x100;
errorCode = __osVoiceContWrite4(mq, channel, 0, data);
if (errorCode != 0) {
return errorCode;
}
errorCode = __osVoiceCheckResult(hd, &status);
if (errorCode & 0xFF00) {
errorCode = CONT_ERR_INVALID;
}
return errorCode;
}
|