about summary refs log tree commit diff stats
path: root/gba/source/link.c
diff options
context:
space:
mode:
Diffstat (limited to 'gba/source/link.c')
-rw-r--r--gba/source/link.c23
1 files changed, 10 insertions, 13 deletions
diff --git a/gba/source/link.c b/gba/source/link.c index e695622..c84e44d 100644 --- a/gba/source/link.c +++ b/gba/source/link.c
@@ -1,13 +1,20 @@
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 */
1#include "link.h" 7#include "link.h"
2 8
3#define JOY_WRITE 2 9#define JOY_WRITE 2
4#define JOY_READ 4 10#define JOY_READ 4
5#define JOY_RW 6 11#define JOY_RW 6
6 12
7void waitForWriteAccess() 13void initializeLink()
8{ 14{
9 //while ((REG_HS_CTRL & JOY_READ) == 0); 15 REG_HS_CTRL |= JOY_RW;
10 while ((REG_HS_CTRL & JOY_WRITE) == 0); 16 REG_JOYTR = 0;
17 while ((REG_HS_CTRL & JOY_WRITE) == 0);
11 REG_HS_CTRL |= JOY_RW; 18 REG_HS_CTRL |= JOY_RW;
12} 19}
13 20
@@ -23,19 +30,9 @@ void waitForAck()
23void sendS32(s32 val) 30void sendS32(s32 val)
24{ 31{
25 REG_JOYTR = val; 32 REG_JOYTR = val;
26 //waitForWriteAccess();
27} 33}
28 34
29void sendU32(u32 val) 35void sendU32(u32 val)
30{ 36{
31 REG_JOYTR = val; 37 REG_JOYTR = val;
32 //waitForWriteAccess();
33}
34
35u32 recieveU32()
36{
37 while ((REG_HS_CTRL & JOY_WRITE) == 0);
38 REG_HS_CTRL |= JOY_RW;
39 return REG_JOYRE;
40} 38}
41