summaryrefslogtreecommitdiff
path: root/src/driver/eeprom24lc64.cc
blob: 88e039e692c734edef844a4a7bdfaf3a8db1b1db (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
27
28
29
30
31
/*
 * Copyright 2020 Birte Kristina Friesel
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */
#include <stdlib.h>
#include "driver/eeprom24lc64.h"
#if defined(CONFIG_meta_driver_hardware_i2c)
#include "driver/i2c.h"
#elif defined(CONFIG_driver_softi2c)
#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);