diff options
Diffstat (limited to 'gba/source/link.c')
-rw-r--r-- | gba/source/link.c | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/gba/source/link.c b/gba/source/link.c new file mode 100644 index 0000000..e695622 --- /dev/null +++ b/gba/source/link.c | |||
@@ -0,0 +1,41 @@ | |||
1 | #include "link.h" | ||
2 | |||
3 | #define JOY_WRITE 2 | ||
4 | #define JOY_READ 4 | ||
5 | #define JOY_RW 6 | ||
6 | |||
7 | void waitForWriteAccess() | ||
8 | { | ||
9 | //while ((REG_HS_CTRL & JOY_READ) == 0); | ||
10 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | ||
11 | REG_HS_CTRL |= JOY_RW; | ||
12 | } | ||
13 | |||
14 | void waitForAck() | ||
15 | { | ||
16 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | ||
17 | REG_HS_CTRL |= JOY_RW; | ||
18 | REG_JOYTR = 0; | ||
19 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | ||
20 | REG_HS_CTRL |= JOY_RW; | ||
21 | } | ||
22 | |||
23 | void sendS32(s32 val) | ||
24 | { | ||
25 | REG_JOYTR = val; | ||
26 | //waitForWriteAccess(); | ||
27 | } | ||
28 | |||
29 | void sendU32(u32 val) | ||
30 | { | ||
31 | REG_JOYTR = val; | ||
32 | //waitForWriteAccess(); | ||
33 | } | ||
34 | |||
35 | u32 recieveU32() | ||
36 | { | ||
37 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | ||
38 | REG_HS_CTRL |= JOY_RW; | ||
39 | return REG_JOYRE; | ||
40 | } | ||
41 | |||