Changeset a6ae6ac in avrstuff for EPRoxygen/at29c040.cpp
- Timestamp:
- Jul 9, 2012, 11:05:43 PM (12 years ago)
- Branches:
- main
- Children:
- 16cf6ff
- Parents:
- 34c57e8
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
EPRoxygen/at29c040.cpp
r34c57e8 ra6ae6ac 14 14 Device::write(CTRL, 0b10011111 | CTRLmask); 15 15 Device::write(VOLT, 0b11001000 | VOLTmask); 16 outb(port + 2, NONE); 16 17 } 17 18 … … 20 21 // All pins of the ROM are put either in high-Z, or 0V when it's not 21 22 // possible 22 Device::write(CTRL, 0 x62);23 Device::write(VOLT, 0 x7F);23 Device::write(CTRL, 0b01100010); 24 Device::write(VOLT, 0b01111111); 24 25 outb(port + 2, NONE); 25 26 } … … 51 52 { 52 53 // Chip enable 53 Device::write(CTRL, CTRLmask | CE);54 Device::write(CTRL, CTRLmask | WE | OE | CE | A17); 54 55 // Address bits low, WE = 1, CE = 0, OE = 1 55 56 // TC and TD = 1 … … 60 61 61 62 wr16(0x5555, 0xAA); 62 wr16(0x 2AAA, 0x55);63 wr16(0xAAAA, 0x55); 63 64 wr16(0x5555, 0x90); 64 65 … … 70 71 // Read the result now 71 72 Device::write(ADR0, 0x00); 72 Device::write(ADR1, 0x00); 73 Device::write(CTRL, WE | CE | CTRLmask); 73 usleep(1000); 74 Device::write(ADR1, 0x00 ^ A13); 75 usleep(1000); 76 Device::write(CTRL, WE | A17 | CTRLmask); 77 usleep(1000); 74 78 uint8_t manufacturer = Device::read(); 75 79 76 getchar();77 80 78 Device::write(CTRL, OE | WE | CE | CTRLmask); 81 Device::write(CTRL, CE | OE | WE | A17 | CTRLmask); 82 usleep(1000); 79 83 Device::write(ADR0, 0x01); 80 Device::write(CTRL, WE | CE | CTRLmask); 84 usleep(1000); 85 Device::write(CTRL, WE | A17 | CTRLmask); 86 usleep(1000); 81 87 82 88 uint8_t product = Device::read(); 83 89 90 Device::write(CTRL, CE | WE | OE | A17 | CTRLmask); 91 usleep(1000); 84 92 // re enable DOE, we are going to write again... 85 Device::write(CTRL, WE | OE | CE | CTRLmask);86 93 Device::write(VOLT, VOLTmask); 94 usleep(1000); 87 95 88 96 wr16(0x5555, 0xAA); 89 wr16(0x 2AAA, 0x55);97 wr16(0xAAAA, 0x55); 90 98 wr16(0x5555, 0xF0); 91 99 usleep(10000); … … 93 101 // Chip disable - we're done ! 94 102 Device::write(CTRL, 0xFF | CTRLmask); 103 usleep(1000); 95 104 96 105 bool ok = (manufacturer == 0x1F && product == 0xA4);
Note:
See TracChangeset
for help on using the changeset viewer.