Commit ab6c0dee authored by David Košenina's avatar David Košenina

use callibration from eeprom

parent 48f29b62
...@@ -2323,6 +2323,7 @@ void OsciloskopOsciloskop::m_menuItemResetEEPROMOnMenuSelection(wxCommandEvent& ...@@ -2323,6 +2323,7 @@ void OsciloskopOsciloskop::m_menuItemResetEEPROMOnMenuSelection(wxCommandEvent&
void OsciloskopOsciloskop::m_buttonConnectOnButtonClick(wxCommandEvent& event) void OsciloskopOsciloskop::m_buttonConnectOnButtonClick(wxCommandEvent& event)
{ {
pOsciloscope->thread.openUSB(pOsciloscope->settings.getHardware()); pOsciloscope->thread.openUSB(pOsciloscope->settings.getHardware());
pOsciloscope->thread.useEepromCallibration(pOsciloscope->settings.getHardware());
} }
void OsciloskopOsciloskop::m_buttonDisconnectOnButtonClick(wxCommandEvent& event) void OsciloskopOsciloskop::m_buttonDisconnectOnButtonClick(wxCommandEvent& event)
......
...@@ -570,8 +570,10 @@ int ThreadApi::writeFpgaToArtix7(SHardware1* ctrl1, SHardware2* ctrl2, OscHardwa ...@@ -570,8 +570,10 @@ int ThreadApi::writeFpgaToArtix7(SHardware1* ctrl1, SHardware2* ctrl2, OscHardwa
} }
// open // open
function(afOpenUsb); openUSB(hw);
wait();
// callibration
useEepromCallibration(hw);
// fpga // fpga
function(afUploadFpga); function(afUploadFpga);
...@@ -604,24 +606,27 @@ int ThreadApi::openUSB(OscHardware* hw) ...@@ -604,24 +606,27 @@ int ThreadApi::openUSB(OscHardware* hw)
function(afOpenUsb); function(afOpenUsb);
wait(); wait();
} }
}
return 0;
}
int ThreadApi::useEepromCallibration(OscHardware* hw)
{
// callibration
if (SDL_AtomicGet(&open) == 1)
{
SDL_AtomicLock(&lock);
eepromSize = sizeof(OscHardware);
eepromOffset = 256000;
SDL_AtomicUnlock(&lock);
function(afEEPROMRead);
wait();
// callibration // use callibration from eeprom
if (SDL_AtomicGet(&open) == 1) if (result(afEEPROMRead) == 0 || eepromData.data.bytes[0] == 0)
{ {
SDL_AtomicLock(&lock); cJSON* json = hw->json;
eepromSize = sizeof(OscHardware); SDL_memcpy(hw, &eepromData, eepromSize);
eepromOffset = 256000; hw->json = json;
SDL_AtomicUnlock(&lock);
function(afEEPROMRead);
wait();
// use callibration from eeprom
if (result(afEEPROMRead) == 0 || eepromData.data.bytes[0] == 0)
{
cJSON* json = hw->json;
SDL_memcpy(hw, &eepromData, eepromSize);
hw->json = json;
}
} }
} }
return 0; return 0;
......
...@@ -904,6 +904,7 @@ public: ...@@ -904,6 +904,7 @@ public:
public: public:
// controlThread // controlThread
int openUSB(OscHardware* hw); int openUSB(OscHardware* hw);
int useEepromCallibration(OscHardware* hw);
int writeFpgaToArtix7(SHardware1* ctrl1, SHardware2* ctrl2, OscHardware* hw); int writeFpgaToArtix7(SHardware1* ctrl1, SHardware2* ctrl2, OscHardware* hw);
int writeUsbToEEPROM(OscHardware* hw); int writeUsbToEEPROM(OscHardware* hw);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment