summaryrefslogtreecommitdiff
path: root/src/hw/hw_eeprom.c
blob: 10ae8177e7381dcea7e2c9f41e8c96424e5ba800 (plain) (blame)
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
#include "hw_eeprom.h"



int dump_eeprom( rtlsdr_dev_t *dev, uint8_t *data, uint16_t len )
{
	int fret = 0;

	if ( len != EEPROM_SIZE )
	{
		printf("EEPROM sump size expected to be %d\n", EEPROM_SIZE);
		return -1;
	}

	fret = hw_read_eeprom( dev, data, 0, len );
	if ( fret != 0 )
	{
		printf("Cannot read eeprom rtlsdr err (%d)\n", fret);
		return -1;
	}

	return 0;
}


int restore_eeprom( rtlsdr_dev_t *dev, uint8_t *data, uint16_t len )
{
	int fret = 0;

	if ( len != EEPROM_SIZE )
	{
		printf("EEPROM sump size expected to be %d\n", EEPROM_SIZE);
		return -1;
	}

	fret = hw_write_eeprom( dev, data, 0, len );
	if ( fret != 0 )
	{
		printf("Cannot write eeprom rtlsdr err(%d)\n", fret);
		return -1;
	}


	return 0;
}