-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathboard-BAT.c
64 lines (52 loc) · 1.22 KB
/
board-BAT.c
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
// Copyright 2008-2010 Segher Boessenkool <[email protected]>
// Licensed under the terms of the GNU GPL, version 2
// http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
#include <stdio.h>
#include "types.h"
#include "emu.h"
#include "platform.h"
#include "i2c.h"
#include "board.h"
static struct i2c_bus *i2c_bus;
static u16 gpio(u32 n, u16 what, __unused u16 push, __unused u16 pull, __unused u16 special)
{
// debug("---> PORT %c what=%04x push=%04x pull=%04x\n",
// 'A' + n, what, push, pull);
if (n == 0) {
if (button_up)
what |= 0x8000;
if (button_down)
what |= 0x4000;
if (button_left)
what |= 0x2000;
if (button_right)
what |= 0x1000;
if (button_A)
what |= 0x0800;
if (button_menu)
what |= 0x0400;
if (button_B)
what |= 0x0200;
if (button_C)
what |= 0x0100;
}
if (n == 2) {
int sda = what & 1;
int scl = (what >> 1) & 1;
//debug("SDA=%d SCL=%d\n", sda, scl);
sda = i2c_bitbang(i2c_bus, sda, scl);
what = (what & ~1) | sda;
}
return what;
}
static void init(void)
{
i2c_bus = i2c_bitbang_bus_create();
i2c_eeprom_create(i2c_bus, 0x200, 0xa0, "BAT");
}
struct board board_BAT = {
.idle_pc = 0x5ce1,
.use_centered_coors = 1,
.init = init,
.gpio = gpio
};