tstDevEEPROM.cpp revision 627bf68711ac042ab548c6085bc0c7e5c8b91c41
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna * EEPROM 93C46 unit tests.
031b91a62d25106ae69d4693475c79618dd5e884fielding * Copyright (C) 2007-2010 Oracle Corporation
031b91a62d25106ae69d4693475c79618dd5e884fielding * Oracle Corporation confidential
031b91a62d25106ae69d4693475c79618dd5e884fielding * All rights reserved
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna 0x0000, 0x0001, 0x0002, 0x0003, 0x0004, 0x0005, 0x0006, 0x0007,
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna 0x0008, 0x0009, 0x000a, 0x000b, 0x000c, 0x000d, 0x000e, 0x000f,
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna 0x0010, 0x0011, 0x0012, 0x0013, 0x0014, 0x0015, 0x0016, 0x0017,
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna 0x0018, 0x0019, 0x001a, 0x001b, 0x001c, 0x001d, 0x001e, 0x001f,
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027,
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna 0x0028, 0x0029, 0x002a, 0x002b, 0x002c, 0x002d, 0x002e, 0x002f,
3ca6ee111e6044cb463e6dc45b9adcfa3050ff00rbowen 0x0030, 0x0031, 0x0032, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037,
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna 0x0038, 0x0039, 0x003a, 0x003b, 0x003c, 0x003d, 0x003e, 0x003f
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna * Test fixture for 93C46-compatible EEPROM device emulation.
44ee9a92415caf6322119d0ca2d20e169e3a1525takashi // Helper methods
6b797d6bd26bbf8589eb0e2b6cfa2fa808f456b1pquerna void writeOpAddr(int opCode, int opCodeBits, uint16_t addr, int addrBits);
7248fa34fc5d506ec1f37a929f939fe075c1a030niq void writeData(uint16_t value) { shiftOutBits(value, DATA_BITS); }
ea8572f0df1c69b398e9d677648a0fa5f31b2d60pquerna CPPUNIT_ASSERT_EQUAL( sizeof(initialContent), (size_t)EEPROM93C46::SIZE );
5c915a9a86688ef70d4e17a5a459f85e9f0e5d00niq for ( uint32_t wordAddr=0; wordAddr < EEPROM93C46::SIZE; wordAddr++ ) {
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna CPPUNIT_ASSERT_EQUAL( initialContent[wordAddr], (uint16_t)wordAddr );
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna CPPUNIT_ASSERT_EQUAL( initialContent[wordAddr], shiftInBits(DATA_BITS) );
5c3c22e3324f26848c1782e711c24faf28136012jerenkrantz for ( int wordAddr=0; wordAddr < EEPROM93C46::SIZE; wordAddr++ ) {
5c3c22e3324f26848c1782e711c24faf28136012jerenkrantz CPPUNIT_ASSERT_EQUAL( initialContent[wordAddr], shiftInBits(DATA_BITS) );
9cd3b05d7b70f07a742bbaf548fa4fa2bdbe5ce6noodl //unused: int i;
e678e297836a60ee5a456f110cac71377763b96etakashi // Enable write
e678e297836a60ee5a456f110cac71377763b96etakashi writeOpAddr(EWEN_OPCODE, EWEN_OPCODE_BITS, 0, EWEN_ADDR_BITS);
e678e297836a60ee5a456f110cac71377763b96etakashi for ( wordAddr=0; wordAddr < EEPROM93C46::SIZE; wordAddr++ ) {
e678e297836a60ee5a456f110cac71377763b96etakashi //writeOpAddr(WRITE_OPCODE, WRITE_OPCODE_BITS, (uint16_t)wordAddr, WRITE_ADDR_BITS);
5b6890f4bf64eff2abec93f06ad5b5cb7560f780pquerna // Disable write
82d4a929c9d891a758667c94e09c871358acf6ecjerenkrantz writeOpAddr(EWDS_OPCODE, EWDS_OPCODE_BITS, 0, EWDS_ADDR_BITS);
5b6890f4bf64eff2abec93f06ad5b5cb7560f780pquerna // Now check the result
5b6890f4bf64eff2abec93f06ad5b5cb7560f780pquerna writeOpAddr(READ_OPCODE, READ_OPCODE_BITS, 0, READ_ADDR_BITS);
5b6890f4bf64eff2abec93f06ad5b5cb7560f780pquerna for ( wordAddr=0; wordAddr < EEPROM93C46::SIZE; wordAddr++ ) {
5b6890f4bf64eff2abec93f06ad5b5cb7560f780pquerna CPPUNIT_ASSERT_EQUAL((uint16_t)(0x3F00 - (wordAddr<<8)), shiftInBits(DATA_BITS) );
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna // Write appears to be successful -- continue
5c3c22e3324f26848c1782e711c24faf28136012jerenkrantz // Enable write
d875a16355b0db5971788e6374841ea5aa6e6b86nilgun // Write successful -- continue
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna for (i = 0; i < 200; i++) {
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna //usec_delay(50);
a1ef40892ffa2b44fc249423c5b6c42a74a84c68nd if (i == 200) {
91be90604bd426eb406711cf00e1380966bdcf81jorton // Enable write
91be90604bd426eb406711cf00e1380966bdcf81jorton writeOpAddr(EWEN_OPCODE, EWEN_OPCODE_BITS, 0, EWEN_ADDR_BITS);
d875a16355b0db5971788e6374841ea5aa6e6b86nilgun // Fill all memory
91be90604bd426eb406711cf00e1380966bdcf81jorton writeOpAddr(WRAL_OPCODE, WRAL_OPCODE_BITS, 0, WRAL_ADDR_BITS);
7dd2be584ba36c686d9f748b55451f54f0043bccniq // Write successful -- verify all memory
d875a16355b0db5971788e6374841ea5aa6e6b86nilgun CPPUNIT_ASSERT_EQUAL((uint16_t)0xABBA, readAt(addr));
0c294487ab3a4e567dc574bb2ad81c7ce07cfd31pquerna //unused: int i;
getReady();
standby();
writeData(0);
standby();
if (waitForCompletion()) {
stop();
getReady();
stop();
getReady();
standby();
if (!waitForCompletion()) {
stop();
standby();
stop();
getReady();
stop();
} while (mask);
uint32_t i;
data = 0;
for (i = 0; i < count; i++) {
return data;
getReady();
stop();
return value;
standby();
return waitForCompletion();
standby();