/home/mooz/bin/arduino-0009/lib/targets/libraries/at45db161d/at45db161d.h

Go to the documentation of this file.
00001 
00005 #ifndef AT45DB161D_H
00006 #define AT45DB161D_H
00007 
00008 extern "C" {
00009 
00010 #include <avr/pgmspace.h>
00011 #include <inttypes.h>
00012 #include "WConstants.h"
00013 
00014 };
00015 
00016 #include "at45db161d_commands.h"
00017 
00027 #ifndef SPI
00028 
00033 #define DATAOUT     11
00034 
00035 #define DATAIN      12
00036 
00037 #define SPICLOCK    13
00038 
00039 #define SLAVESELECT 10
00040 
00041 #define RESET        8
00042 
00043 #define WP           7
00044 
00054 inline uint8_t spi_transfer(uint8_t data)
00055 {
00056         SPDR = data;
00057         while(!(SPSR & (1 << SPIF))) ;
00058         return SPDR;
00059 }
00060 
00062 #define DF_CS_inactive digitalWrite(SLAVESELECT,HIGH)
00063 
00064 #define DF_CS_active digitalWrite(SLAVESELECT,LOW)
00065 
00066 #endif /* SPI */
00067 
00081 #define READY_BUSY 0x80
00082 
00088 #define COMPARE 0x40
00089 
00096 #define PROTECT 0x02
00097 
00102 #define PAGE_SIZE 0x01
00103 
00111 #define DEVICE_DENSITY 0x2C 
00112 
00124 class ATD45DB161D
00125 {
00126         public:
00132                 struct ID
00133                 {
00134                         uint8_t manufacturer;       
00135                         uint8_t device[2];          
00136                         uint8_t extendedInfoLength; 
00137                 };
00138 
00139         public:
00141                 ATD45DB161D();
00143                 ~ATD45DB161D();
00144 
00146                 void Init();
00147 
00152                 uint8_t ReadStatusRegister();
00153 
00161                 void ReadManufacturerAndDeviceID(struct ATD45DB161D::ID *id);
00162                 
00170                 void ReadMainMemoryPage(uint16_t page, uint16_t offset);
00171 
00180                 void ContinuousArrayRead(uint16_t page, uint16_t offset, uint8_t low);
00181 
00188                 void BufferRead(uint8_t bufferNum, uint16_t offset, uint8_t low);
00189 
00199                 void BufferWrite(uint8_t bufferNum, uint16_t offset);
00200                 
00208                 void BufferToPage(uint8_t bufferNum, uint16_t page, uint8_t erase);             
00209 
00215                 void PageToBuffer(uint16_t page, uint8_t bufferNum);
00216 
00222                 void PageErase(uint16_t page);
00223                 
00229                 void BlockErase(uint16_t block);
00230 
00237                 void SectoreErase(uint8_t sector);
00238 
00244                 void ChipErase();
00245 
00255                 void BeginPageWriteThroughBuffer(uint16_t page, uint16_t offset, uint8_t bufferNum);
00256                 
00261                 void EndAndWait();
00262 
00272                 int8_t ComparePageToBuffer(uint16_t page, uint8_t bufferNum);
00273 
00281                 void DeepPowerDown();
00282 
00287                 void ResumeFromDeepPowerDown();
00288 
00289         private:
00290                 /* Nothing atm but who knows... */
00291 };
00292 
00297 #endif /* AT45DB161D_H */

Generated on Sun Oct 21 18:24:47 2007 for at45db161d by  doxygen 1.5.2