diff options
Diffstat (limited to 'gba/source/link.c')
-rw-r--r-- | gba/source/link.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/gba/source/link.c b/gba/source/link.c new file mode 100644 index 0000000..c84e44d --- /dev/null +++ b/gba/source/link.c | |||
@@ -0,0 +1,38 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2017 hatkirby | ||
3 | * | ||
4 | * This software may be modified and distributed under the terms | ||
5 | * of the MIT license. See the LICENSE file for details. | ||
6 | */ | ||
7 | #include "link.h" | ||
8 | |||
9 | #define JOY_WRITE 2 | ||
10 | #define JOY_READ 4 | ||
11 | #define JOY_RW 6 | ||
12 | |||
13 | void initializeLink() | ||
14 | { | ||
15 | REG_HS_CTRL |= JOY_RW; | ||
16 | REG_JOYTR = 0; | ||
17 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | ||
18 | REG_HS_CTRL |= JOY_RW; | ||
19 | } | ||
20 | |||
21 | void waitForAck() | ||
22 | { | ||
23 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | ||
24 | REG_HS_CTRL |= JOY_RW; | ||
25 | REG_JOYTR = 0; | ||
26 | while ((REG_HS_CTRL & JOY_WRITE) == 0); | ||
27 | REG_HS_CTRL |= JOY_RW; | ||
28 | } | ||
29 | |||
30 | void sendS32(s32 val) | ||
31 | { | ||
32 | REG_JOYTR = val; | ||
33 | } | ||
34 | |||
35 | void sendU32(u32 val) | ||
36 | { | ||
37 | REG_JOYTR = val; | ||
38 | } | ||