main
Last change
on this file since 34c57e8 was 34c57e8, checked in by Adrien Destugues <pulkomandy@…>, 12 years ago |
More work.
- Power on/off sequence OK
- Code to read chip ID written, but not working yet...
git-svn-id: svn://pulkomandy.tk/avrstuff@59 c6672c3c-f6b6-47f9-9001-1fd6b12fecbe
|
-
Property mode
set to
100644
|
File size:
637 bytes
|
Rev | Line | |
---|
[d09030d] | 1 | #include "device.h"
|
---|
| 2 |
|
---|
| 3 | class AT29C040: public Device
|
---|
| 4 | {
|
---|
| 5 | public:
|
---|
[34c57e8] | 6 | AT29C040();
|
---|
| 7 |
|
---|
| 8 | void power(void);
|
---|
| 9 | void shutdown(void);
|
---|
[d09030d] | 10 | void read(const char* filename);
|
---|
| 11 | void write(const char* filename);
|
---|
| 12 | void erase(void);
|
---|
[34c57e8] | 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(ADR0, addr);
|
---|
| 20 | Device::write(ADR1, addr >> 8);
|
---|
| 21 |
|
---|
| 22 | Device::write(CTRL, OE | CTRLmask);
|
---|
| 23 |
|
---|
| 24 | Device::write(DATA, val);
|
---|
| 25 |
|
---|
| 26 | Device::write(CTRL, WE | OE | CTRLmask);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
| 29 | static const uint8_t CTRLmask = 0b01100000;
|
---|
| 30 | static const uint8_t VOLTmask = 0b10110011;
|
---|
[d09030d] | 31 | };
|
---|
| 32 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.