From 891ba007a455590ac544bbebd270ebe8d3417f2c Mon Sep 17 00:00:00 2001 From: FreeArtMan Date: Thu, 31 Dec 2015 13:43:51 +0000 Subject: Add eeprom dump test --- hw/hw_eeprom.c | 47 ++++++++++++++++++++++++++++++++++ hw/hw_eeprom.h | 15 +++++++++++ test/.gitignore | 2 ++ test/dump_eeprom.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 138 insertions(+) create mode 100644 test/dump_eeprom.c diff --git a/hw/hw_eeprom.c b/hw/hw_eeprom.c index e69de29..10ae817 100644 --- a/hw/hw_eeprom.c +++ b/hw/hw_eeprom.c @@ -0,0 +1,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; +} + + diff --git a/hw/hw_eeprom.h b/hw/hw_eeprom.h index e69de29..ac3ec0a 100644 --- a/hw/hw_eeprom.h +++ b/hw/hw_eeprom.h @@ -0,0 +1,15 @@ +#ifndef __RADIOLA_HW_EEPROM_H +#define __RADIOLA_HW_EEPROM_H + +#include "hw.h" + +#define EEPROM_SIZE 256 + +int dump_eeprom( rtlsdr_dev_t *dev, uint8_t *data, uint16_t len ); +int restore_eeprom( rtlsdr_dev_t *dev, uint8_t *data, uint16_t len ); + +//int eeprom_read_config(); +//int eeprom_write_config(); + + +#endif \ No newline at end of file diff --git a/test/.gitignore b/test/.gitignore index 7bd96c4..a37bb52 100644 --- a/test/.gitignore +++ b/test/.gitignore @@ -8,3 +8,5 @@ ui_gl_filter sdr_fm div20 *.o +dump0 +dump_eeprom diff --git a/test/dump_eeprom.c b/test/dump_eeprom.c new file mode 100644 index 0000000..b32e74e --- /dev/null +++ b/test/dump_eeprom.c @@ -0,0 +1,74 @@ +#include +#include +#include + +//rtlsdr +#include +#include +#include +#include + +int print_dump( uint8_t *data, uint16_t size ) +{ + int i; + const int line_sz = 32; + for (i=0; i