source: avrstuff/EPRoxygen/at29c040.h

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

Still not working...
Added very agressive timing, fixed some potential glitches, but still not enough to even read the device ID !

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

  • Property mode set to 100644
File size: 866 bytes
Line 
1#include "device.h"
2
3class AT29C040: public Device
4{
5 public:
6 AT29C040();
7
8 void power(void);
9 void shutdown(void);
10 void read(const char* filename);
11 void write(const char* filename);
12 void erase(void);
13 private:
14 bool checkId(void);
15
16 // Write a byte to a 16-bit address (bits 16 17 18 are 0)
17 inline void wr16(uint16_t addr, uint8_t val)
18 {
19 Device::write(CTRL, A17 | CE | WE | OE | CTRLmask);
20 usleep(10000);
21
22 Device::write(ADR1, (addr >> 8) ^ A13);
23 usleep(10000);
24 Device::write(ADR0, addr);
25 usleep(10000);
26
27 Device::write(DATA, val);
28 usleep(10000);
29 Device::write(CTRL, A17 | OE | CTRLmask);
30 usleep(10000);
31
32printf("W %X %X", addr, val);
33getchar();
34 Device::write(CTRL, A17 | CE | WE | OE | CTRLmask);
35 usleep(10000);
36 }
37
38 static const uint8_t CTRLmask = 0b01100000;
39 static const uint8_t VOLTmask = 0b10110011;
40};
41
Note: See TracBrowser for help on using the repository browser.