summaryrefslogtreecommitdiff
path: root/src/driver/eeprom24lc64.cc
blob: 745514bcbcbefd2a62c1c419e2b13c4fc7a3f238 (plain)
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
#include <stdlib.h>
#include "driver/eeprom24lc64.h"
#if defined(MULTIPASS_ARCH_HAS_I2C) && !defined(DRIVER_SOFTI2C)
#include "driver/i2c.h"
#else
#include "driver/soft_i2c.h"
#endif

void EEPROM24LC64::readPage(unsigned short addr, char *data)
{
	txbuf[0] = addr >> 8;
	txbuf[1] = addr & 0x00ff;
	i2c.xmit(address, 2, txbuf, 32, (unsigned char *)data);
}

void EEPROM24LC64::writePage(unsigned short addr, char *data)
{
	txbuf[0] = addr >> 8;
	txbuf[1] = addr & 0x00ff;
	for (unsigned char i = 0; i < 32; i++) {
		txbuf[i+2] = data[i];
	}
	i2c.xmit(address, 34, txbuf, 0, NULL);
}

EEPROM24LC64 eeprom24lc64(0x50);