// Copyright 2008-2010 Segher Boessenkool // Licensed under the terms of the GNU GPL, version 2 // http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt #include #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) { // fprintf(stderr, "---> 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; //fprintf(stderr, "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 };