public static void PerformanceTest_ReadPage( EEPROM_25AA256 eeprom, int pageBatchCounter = 16 // Beyond 16 performance do not improve ) { var errorCount = 0; Console.WriteLine("PerformanceTest_ReadPage Start - pageBatchCounter:{0}, TransferBufferSize:{1}", pageBatchCounter, pageBatchCounter * eeprom.PAGE_SIZE); for (int p = 0; p < eeprom.MaxPage / pageBatchCounter; p++) { int addr = p * eeprom.PAGE_SIZE; var r = eeprom.ReadPageOptimized(addr, eeprom.PAGE_SIZE * pageBatchCounter); if (r.Succeeded) { for (var pbc = 0; pbc < pageBatchCounter; pbc++) { for (var x = 0; x < eeprom.PAGE_SIZE; x++) { var b = r.Buffer[(pbc * eeprom.PAGE_SIZE) + x]; var physicalPage = p + pbc; var expected = x; if (physicalPage == 2) { expected = REF_VALUE_2; } if (physicalPage == 3) { expected = REF_VALUE_3; } if (b != expected) { errorCount++; Console.WriteLine("Error page:{0}, baseAddress:{1}, actual:{2}, expected:{3}", p, (addr + pbc), b, expected); } } } } else { Console.WriteLine("Failed ReadPages"); } } Console.WriteLine("PerformanceTest_ReadPage End"); }
public static void Run(string[] args) { Console.WriteLine("Nusbio initialization"); var serialNumber = Nusbio.Detect(); if (serialNumber == null) // Detect the first Nusbio available { Console.WriteLine("nusbio not detected"); return; } using (var nusbio = new Nusbio(serialNumber)) { Cls(nusbio); _eeprom = new EEPROM_25AA256( nusbio: nusbio, clockPin: NusbioGpio.Gpio0, mosiPin: NusbioGpio.Gpio1, misoPin: NusbioGpio.Gpio2, selectPin: NusbioGpio.Gpio3 ); _eeprom.Begin(); while (nusbio.Loop()) { if (Console.KeyAvailable) { var k = Console.ReadKey(true).Key; if (k == ConsoleKey.W) { var a = ConsoleEx.Question(23, "Execute Write/Read/Write Test 32k now Y)es, N)o", new List <char>() { 'Y', 'N' }); if (a == 'Y') { var testValue = 1 + 4 + 16 + 64; WriteEEPROMPage(512, testValue); ReadAndVerifyEEPROMPage(512, testValue); WriteEEPROMPage(512); ReadAndVerifyEEPROMPage(512); } } if (k == ConsoleKey.R) { ReadAndVerifyEEPROMPage(10); Cls(nusbio); } if (k == ConsoleKey.A) { ReadAndVerifyEEPROMPage(512); ReadAndVerifyEEPROMPage_BatchRead(512); } if (k == ConsoleKey.B) { // This mode is slow, only read the first 64 pages out of 512 ReadAndVerifyEEPROMOnyByteAtTheTime(64); } if (k == ConsoleKey.Q) { break; } Cls(nusbio); } } } Console.Clear(); }