source: avrstuff/EPRoxygen/27c020.cpp@ 16cf6ff

main
Last change on this file since 16cf6ff was 16cf6ff, checked in by Adrien Destugues <pulkomandy@…>, 12 years ago

Add some suport for reading 27c020 chips.

Should be usable with most other ROMs as well.

git-svn-id: svn://pulkomandy.tk/avrstuff@61 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe

  • Property mode set to 100644
File size: 1.0 KB
Line 
1#include "27c020.h"
2
3#include <stdio.h>
4#include <unistd.h>
5
6
7x27C020::x27C020()
8 : Device()
9{
10}
11
12void x27C020::power()
13{
14 Device::write(CTRL, 0b10011111 | CTRLmask);
15 Device::write(VOLT, 0b11001000 | VOLTmask);
16 outb(port + 2, NONE);
17}
18
19void x27C020::read(const char* filename)
20{
21 for (int address = 0; address < 256*1024; address++)
22 {
23 Device::write(VOLT, DOE | VOLTmask);
24 Device::write(CTRL, CE | OE | WE | A17 | CTRLmask);
25 usleep(1000);
26
27 Device::write(ADR0, address);
28 usleep(1000);
29 Device::write(ADR1, address >> 8);
30 usleep(1000);
31 // TODO A16, A17
32 Device::write(CTRL, WE | A17 | CTRLmask);
33 usleep(1000);
34 uint8_t val = Device::read();
35 Device::write(CTRL, CE | OE | WE | A17 | CTRLmask);
36
37 // TODO write to file, or stdout if file is null
38 putc(val, stdout);
39 // TODO flush every 512 bytes or so
40 fflush(stdout);
41 }
42}
43
44void x27C020::write(const char* filename)
45{
46 // TODO support it !
47 puts("Writing not supported");
48}
49
50void x27C020::erase(void)
51{
52 // TODO return error
53 puts("Erasing not supported");
54}
55
Note: See TracBrowser for help on using the repository browser.