2 * Copyright (C) 2009 Ubixum, Inc.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 #include <fx2macros.h>
29 #define LG_PROM 0x51 // large prom ( is 16 bit addr mode)
33 xdata BYTE buf[READ_SIZE];
36 extern xdata BYTE fx2_c0[];
39 Modified eeprom_write that always uses two byte buffer.
40 So can write to LG_PROM w/ out recompiling lib.
41 (The library dynamically detects the prom based on the startup state.
42 On the dev board, you can switch the prom with EEPROM select while
43 the firmware is running.)
45 void eeprom_write_local(BYTE prom_addr, WORD addr, WORD length, BYTE* buf) {
47 // 1st bytes of buffer are address and next byte is value
51 while ( cur_byte<length ) {
53 printf ( "%d %04x:%02x\n", cur_byte, addr, buf[cur_byte]);
54 data_buffer[addr_len++] = MSB(addr);
55 data_buffer[addr_len++] = LSB(addr);
56 data_buffer[addr_len++] = buf[cur_byte++];
57 i2c_write ( prom_addr, addr_len, data_buffer, 0, NULL );
58 ++addr; // next byte goes to next address
72 eeprom_write_local(LG_PROM, 0, IIC_SIZE, fx2_c0);
77 if (on) {d5on();} else {d5off();}