#include <at45db161d.h>
Public Member Functions | |
ATD45DB161D () | |
~ATD45DB161D () | |
void | Init () |
uint8_t | ReadStatusRegister () |
void | ReadManufacturerAndDeviceID (struct ATD45DB161D::ID *id) |
void | ReadMainMemoryPage (uint16_t page, uint16_t offset) |
void | ContinuousArrayRead (uint16_t page, uint16_t offset, uint8_t low) |
void | BufferRead (uint8_t bufferNum, uint16_t offset, uint8_t low) |
void | BufferWrite (uint8_t bufferNum, uint16_t offset) |
void | BufferToPage (uint8_t bufferNum, uint16_t page, uint8_t erase) |
void | PageToBuffer (uint16_t page, uint8_t bufferNum) |
void | PageErase (uint16_t page) |
void | BlockErase (uint16_t block) |
void | SectoreErase (uint8_t sector) |
void | ChipErase () |
void | BeginPageWriteThroughBuffer (uint16_t page, uint16_t offset, uint8_t bufferNum) |
void | EndAndWait () |
int8_t | ComparePageToBuffer (uint16_t page, uint8_t bufferNum) |
void | DeepPowerDown () |
void | ResumeFromDeepPowerDown () |
Classes | |
struct | ID |
ID structure This structure contains various informations about the dataflash chip being used. More... |
Definition at line 124 of file at45db161d.h.
ATD45DB161D::ATD45DB161D | ( | ) |
CTOR
Definition at line 4 of file at45db161d.cpp.
ATD45DB161D::~ATD45DB161D | ( | ) |
DTOR
Definition at line 7 of file at45db161d.cpp.
void ATD45DB161D::Init | ( | ) |
Setup SPI and pinout
Definition at line 11 of file at45db161d.cpp.
References DATAIN, DATAOUT, DF_CS_inactive, SLAVESELECT, and SPICLOCK.
uint8_t ATD45DB161D::ReadStatusRegister | ( | ) |
Read status register
Definition at line 37 of file at45db161d.cpp.
References AT45DB161D_STATUS_REGISTER_READ, DF_CS_active, DF_CS_inactive, and spi_transfer().
Referenced by BlockErase(), BufferToPage(), ChipErase(), ComparePageToBuffer(), EndAndWait(), PageErase(), PageToBuffer(), and SectoreErase().
void ATD45DB161D::ReadManufacturerAndDeviceID | ( | struct ATD45DB161D::ID * | id | ) |
Read Manufacturer and Device ID
id | Pointer to the ID structure to initialize |
Definition at line 59 of file at45db161d.cpp.
References AT45DB161D_READ_MANUFACTURER_AND_DEVICE_ID, DF_CS_active, DF_CS_inactive, and spi_transfer().
void ATD45DB161D::ReadMainMemoryPage | ( | uint16_t | page, | |
uint16_t | offset | |||
) |
A main memory page read allows the user to read data directly from any one of the 4096 pages in the main memory, bypassing both of the data buffers and leaving the contents of the buffers unchanged.
page | Page of the main memory to read | |
offset | Starting byte address within the page |
Definition at line 88 of file at45db161d.cpp.
References AT45DB161D_PAGE_READ, DF_CS_active, DF_CS_inactive, and spi_transfer().
void ATD45DB161D::ContinuousArrayRead | ( | uint16_t | page, | |
uint16_t | offset, | |||
uint8_t | low | |||
) |
Sequentially read a continuous stream of data.
page | Page of the main memory where the sequential read will start | |
offset | Starting byte address within the page | |
low | If true the read operation will be performed in low speed mode (and in high speed mode if it's false). |
Definition at line 116 of file at45db161d.cpp.
References AT45DB161D_CONTINUOUS_READ_HIGH_FREQ, AT45DB161D_CONTINUOUS_READ_LOW_FREQ, DF_CS_active, DF_CS_inactive, and spi_transfer().
void ATD45DB161D::BufferRead | ( | uint8_t | bufferNum, | |
uint16_t | offset, | |||
uint8_t | low | |||
) |
Read the content of one of the SRAM data buffers (in low or high speed mode).
bufferNum | Buffer to read (1 or 2) | |
offset | Starting byte within the buffer | |
low | If true the read operation will be performed in low speed mode (and in high speed mode if it's false). |
Definition at line 138 of file at45db161d.cpp.
References AT45DB161D_BUFFER_1_READ, AT45DB161D_BUFFER_1_READ_LOW_FREQ, AT45DB161D_BUFFER_2_READ, AT45DB161D_BUFFER_2_READ_LOW_FREQ, DF_CS_active, DF_CS_inactive, and spi_transfer().
void ATD45DB161D::BufferWrite | ( | uint8_t | bufferNum, | |
uint16_t | offset | |||
) |
Write data to one of the SRAM data buffers. Any further call to spi_tranfer will return bytes contained in the data buffer until a low-to-high transition is detected on the CS pin. If the end of the data buffer is reached, the device will wrap around back to the beginning of the buffer.
bufferNum | Buffer to read (1 or 2) | |
offset | Starting byte within the buffer |
Definition at line 173 of file at45db161d.cpp.
References AT45DB161D_BUFFER_1_WRITE, AT45DB161D_BUFFER_2_WRITE, DF_CS_active, DF_CS_inactive, and spi_transfer().
void ATD45DB161D::BufferToPage | ( | uint8_t | bufferNum, | |
uint16_t | page, | |||
uint8_t | erase | |||
) |
Transfer data from buffer 1 or 2 to main memory page.
bufferNum | Buffer to use (1 or 2) | |
page | Page where the content of the buffer will transfered | |
erase | If set the page will be first erased before the buffer transfer. |
Definition at line 196 of file at45db161d.cpp.
References AT45DB161D_BUFFER_1_TO_PAGE_WITH_ERASE, AT45DB161D_BUFFER_1_TO_PAGE_WITHOUT_ERASE, AT45DB161D_BUFFER_2_TO_PAGE_WITH_ERASE, AT45DB161D_BUFFER_2_TO_PAGE_WITHOUT_ERASE, DF_CS_active, DF_CS_inactive, ReadStatusRegister(), READY_BUSY, and spi_transfer().
void ATD45DB161D::PageToBuffer | ( | uint16_t | page, | |
uint8_t | bufferNum | |||
) |
Transfer a page of data from main memory to buffer 1 or 2.
page | Main memory page to transfer | |
buffer | Buffer (1 or 2) where the data will be written |
Definition at line 237 of file at45db161d.cpp.
References AT45DB161D_TRANSFER_PAGE_TO_BUFFER_1, AT45DB161D_TRANSFER_PAGE_TO_BUFFER_2, DF_CS_active, DF_CS_inactive, ReadStatusRegister(), READY_BUSY, and spi_transfer().
void ATD45DB161D::PageErase | ( | uint16_t | page | ) |
Erase a page in the main memory array.
page | Page to erase |
Definition at line 269 of file at45db161d.cpp.
References AT45DB161D_PAGE_ERASE, DF_CS_active, DF_CS_inactive, ReadStatusRegister(), READY_BUSY, and spi_transfer().
void ATD45DB161D::BlockErase | ( | uint16_t | block | ) |
Erase a block of eight pages at one time.
block | Index of the block to erase |
Definition at line 300 of file at45db161d.cpp.
References AT45DB161D_BLOCK_ERASE, DF_CS_active, DF_CS_inactive, ReadStatusRegister(), READY_BUSY, and spi_transfer().
void ATD45DB161D::SectoreErase | ( | uint8_t | sector | ) |
Erase a sector in main memory. There are 16 sector on the at45db161d and only one can be erased at one time.
sector | Sector to erase |
Definition at line 331 of file at45db161d.cpp.
References AT45DB161D_SECTOR_ERASE, DF_CS_active, DF_CS_inactive, ReadStatusRegister(), READY_BUSY, and spi_transfer().
void ATD45DB161D::ChipErase | ( | ) |
Erase the entire chip memory. Sectors proteced or locked down will not be erased.
Definition at line 377 of file at45db161d.cpp.
References AT45DB161D_CHIP_ERASE_0, AT45DB161D_CHIP_ERASE_1, AT45DB161D_CHIP_ERASE_2, AT45DB161D_CHIP_ERASE_3, DF_CS_active, DF_CS_inactive, ReadStatusRegister(), READY_BUSY, and spi_transfer().
void ATD45DB161D::BeginPageWriteThroughBuffer | ( | uint16_t | page, | |
uint16_t | offset, | |||
uint8_t | bufferNum | |||
) |
This a combination of Buffer Write and Buffer to Page with Built-in Erase.
page | Page where the content of the buffer will transfered | |
offset | Starting byte address within the buffer | |
bufferNum | Buffer to use (1 or 2) |
Definition at line 405 of file at45db161d.cpp.
References AT45DB161D_PAGE_THROUGH_BUFFER_1, AT45DB161D_PAGE_THROUGH_BUFFER_2, DF_CS_active, DF_CS_inactive, and spi_transfer().
void ATD45DB161D::EndAndWait | ( | ) |
Perform a low-to-high transition on the CS pin and then poll the status register to check if the dataflash is busy.
Definition at line 424 of file at45db161d.cpp.
References DF_CS_active, DF_CS_inactive, ReadStatusRegister(), and READY_BUSY.
int8_t ATD45DB161D::ComparePageToBuffer | ( | uint16_t | page, | |
uint8_t | bufferNum | |||
) |
Compare a page of data in main memory to the data in buffer 1 or 2.
page | Page to test | |
bufferNum | Buffer number |
Definition at line 444 of file at45db161d.cpp.
References AT45DB161D_COMPARE_PAGE_TO_BUFFER_1, AT45DB161D_COMPARE_PAGE_TO_BUFFER_2, COMPARE, DF_CS_active, DF_CS_inactive, ReadStatusRegister(), READY_BUSY, and spi_transfer().
void ATD45DB161D::DeepPowerDown | ( | ) |
Put the device into the lowest power consumption mode. Once the device has entered the Deep Power-down mode, all instructions are ignored except the Resume from Deep Power-down command.
Definition at line 477 of file at45db161d.cpp.
References AT45DB161D_DEEP_POWER_DOWN, DF_CS_active, DF_CS_inactive, and spi_transfer().
void ATD45DB161D::ResumeFromDeepPowerDown | ( | ) |
Takes the device out of Deep Power-down mode.
Definition at line 495 of file at45db161d.cpp.
References AT45DB161D_RESUME_FROM_DEEP_POWER_DOWN, DF_CS_active, DF_CS_inactive, and spi_transfer().