44 #if (PARTNO == AT45DB021E) || \ 45 (PARTNO == AT45DB041E) || \ 46 (PARTNO == AT45DB081E) || \ 47 (PARTNO == AT45DB161E) || \ 48 (PARTNO == AT45DB321E) || \ 49 (PARTNO == AT45DB641E) || \ 50 (PARTNO == AT45DQ161) || \ 51 (PARTNO == AT45DQ321) || \ 52 (PARTNO == AT25PE20) || \ 53 (PARTNO == AT25PE40) || \ 54 (PARTNO == AT25PE80) || \ 55 (PARTNO == AT25PE16) || \ 58 static bool DISPLAY_OUTPUT = 0;
60 static void debugOn() {DISPLAY_OUTPUT = 1;};
61 static void debugOff() {DISPLAY_OUTPUT = 0;};
73 while(!(SR[0] & (1<<7)));
180 uint32_t totalBytes = txNumBytes + 4;
182 for(uint32_t j = 0; j < txNumBytes; j++)
217 uint32_t totalBytes = txNumBytes + 4;
219 for(uint32_t j = 0; j < txNumBytes; j++)
234 uint32_t totalBytes = txNumBytes + 4;
236 for(uint32_t j = 0; j < txNumBytes; j++)
294 uint32_t totalBytes = txNumBytes + 4;
296 for(uint32_t j = 0; j < txNumBytes; j++)
352 uint32_t totalBytes = txNumBytes + 4;
354 for(uint32_t j = 0; j < txNumBytes; j++)
528 #if (PARTNO == AT45DQ161) || \ 529 (PARTNO == AT45DQ321) || \ 554 for(uint32_t j = 0; j < txNumBytes; j++)
569 for(uint32_t j = 0; j < txNumBytes; j++)
584 for(uint32_t j = 0; j < txNumBytes; j++)
599 for(uint32_t j = 0; j < txNumBytes; j++)
648 #if (PARTNO == AT45DB021E) || \ 649 (PARTNO == AT45DB041E) || \ 650 (PARTNO == AT45DB081E) || \ 651 (PARTNO == AT45DB161E) || \ 652 (PARTNO == AT45DB321E) || \ 653 (PARTNO == AT45DB641E) || \ 654 (PARTNO == AT45DQ161) || \ 655 (PARTNO == AT45DQ321) || \ 722 uint32_t totalBytes = txNumBytes + 4;
724 for(uint32_t j = 0; j < txNumBytes; j++)
735 #if (PARTNO == AT45DB021E) || \ 736 (PARTNO == AT45DB041E) || \ 737 (PARTNO == AT45DB081E) || \ 738 (PARTNO == AT45DB161E) || \ 739 (PARTNO == AT45DB321E) || \ 740 (PARTNO == AT45DB641E) || \ 741 (PARTNO == AT45DQ161) || \ 742 (PARTNO == AT45DQ321) || \ 743 (PARTNO == AT25PE40) || \ 744 (PARTNO == AT25PE80) || \ 745 (PARTNO == AT25PE16) || \ 771 uint32_t totalBytes = txNumBytes + 4;
773 for(uint32_t j = 0; j < txNumBytes; j++)
808 uint32_t totalBytes = txNumBytes + 4;
810 for(uint32_t j = 0; j < txNumBytes; j++)
825 uint32_t totalBytes = txNumBytes + 4;
827 for(uint32_t j = 0; j < txNumBytes; j++)
void dataflashBuffer1ReadLegacy(uint8_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x54 LEGACY: Reads rxNumBytes starting from location 'address' in buffer 2 and stores the dat...
#define CMD_DATAFLASH_ARRAY_READ_LF
#define CMD_DATAFLASH_QUAD_DISABLE
void dataflashArrayReadLowPower(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x01 Reads rxNumBytes starting from location 'address' and stores the data in the byte arra...
#define CMD_DATAFLASH_BUFFER1_READ_HF
void dataflashMemoryProgramThruBuffer1WithErase(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x82 Programs main memory through buffer 1 starting at the address indicated by 'address' w...
void SPI_JEDECReset()
Performs a JEDEC reset on the SPI device.
#define CMD_DATAFLASH_PROGRAM_ERASE_SUSPEND
void dataflashBuffer2Write(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x87 Programs 'txNumBytes' bytes of data to buffer 2 starting at the address indicated by a...
void dataflashBlockErase(uint32_t address)
OPCODE: 0x50 Erases a block of data (8 pages) starting from page address 'address.'.
#define CMD_DATAFLASH_READ_SR
#define CMD_DATAFLASH_CONFIGURE_P2_PG_SIZE
void dataflashDPD()
OPCODE: 0xB9 Put the device into deep power down mode. Call dataflashResumeFromDPD() to wake up...
void dataflashContinuousArrayReadLegacy(uint8_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x68 LEGACY: Reads rxNumBytes starting from location 'address' and stores the data in the b...
void SPI_QuadExchange(uint8_t standardSPINumBytes, uint8_t *txBuffer, uint32_t txNumBytes, uint8_t *rxBuffer, uint32_t rxNumBytes, uint32_t dummyNumBytes)
Sends and receives bytes based on the function parameters. MOSI can used for the opcode and address...
#define CMD_DATAFLASH_ENABLE_SECT_PROTECTION
#define CMD_DATAFLASH_SECTOR_ERASE
void printSPIExchange(uint8_t *txBuffer, uint32_t txNumBytes, uint8_t *rxBuffer, uint32_t rxNumBytes)
Prints the byte array in hexadecimal with a formatted output. Indicates what bytes were sent...
#define CMD_DATAFLASH_ARRAY_READ_LP
#define CMD_DATAFLASH_READ_CONFIG_REGISTER
#define CMD_DATAFLASH_MEM_BUF2_COMPARE
uint8_t txDataflashInternalBuffer[MAXIMUM_TX_BYTES]
#define CMD_DATAFLASH_DUAL_INPUT_BUFFER1_WRITE
void dataflashArrayReadHighFreq0(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x0B Reads rxNumBytes starting from location 'address' and stores the data in the byte arra...
void dataflashBuffer2ReadLowFreq(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0xD3 Reads rxNumBytes starting from location 'address' in buffer 2 and stores the data in t...
Declarations of Dataflash functions.
void dataflashQuadInputBuffer2Write(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x47 Programs 'txNumBytes' bytes of data to buffer 2 starting at the address indicated by a...
#define CMD_DATAFLASH_SOFTWARE_RESET
#define CMD_DATAFLASH_MEM_BUF2_TRANSFER
#define CMD_DATAFLASH_QUAD_ENABLE
void dataflashProgSectorProtectionReg(uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x3D_2A_7F_FC Program the sector protection register with the data in txBuffer.
void dataflashMemtoBuffer1Compare(uint32_t address)
OPCODE: 0x60 Compare the contents of a page in main memory to the contents of buffer 1...
#define CMD_DATAFLASH_MEM_PAGE_READ_LEG
#define CMD_DATAFLASH_SECTOR_LOCKDOWN
void dataflashReadSectorLockdownReg(uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x35 Reads 'rxNumBytes' bytes of data in from the SL register.
void dataflashProgramEraseSuspend()
OPCODE: 0xB0 Suspends a program or erase operation in progress to a particular 64KB sector of the m...
void dataflashBuffer1ToMainMemoryWithoutErase(uint32_t address)
OPCODE: 0x88 Programs the entire buffer 1 page to main memory starting at the address indicated by ...
#define CMD_DATAFLASH_DUAL_INPUT_BUFFER2_WRITE
#define CMD_DATAFLASH_DEEP_POWER_DOWN
void dataflashAutoPageRewrite2(uint32_t address)
OPCODE: 0x59 Rewrite the page in main memory at address 'address.' This performs a refresh of stored ...
#define CMD_DATAFLASH_CONTINUOUS_ARRAY_READ_LEG
void dataflashBuffer2ToMainMemoryWithoutErase(uint32_t address)
OPCODE: 0x89 Programs the entire buffer 2 page to main memory starting at the address indicated by ...
#define CMD_DATAFLASH_PAGE_ERASE
#define CMD_DATAFLASH_ARRAY_READ_HF0
void dataflashUDPDMode()
OPCODE: 0x79 Put the device into ultra deep power down mode. Wake the device with dataflashHardware...
#define CMD_DATAFLASH_CHIP_ERASE
#define CMD_DATAFLASH_MEM_PAGE_READ
Dataflash Devices and Opcodes AT45DB021E AT45DB041E AT45DB081E AT45DB161E AT45DB321E AT45DB641E AT45D...
void dataflashSoftwareReset()
OPCODE: 0xF0_00_00_00 Perform a software reset on the device. This will terminate any read or write...
void dataflashDisableSectorProtection()
OPCODE: 0x3D_2A_7F_9A Disables sector protection.
#define CMD_DATAFLASH_READ_SECT_PROT_REG
#define CMD_DATAFLASH_ARRAY_READ_HF1
#define CMD_DATAFLASH_UDPD_MODE
void dataflashArrayReadLegacy(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0xE8 Reads rxNumBytes starting from location 'address' and stores the data in the byte arra...
void dataflashRMWThruBuffer1(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x58 Reads main memory to buffer 1, modifies it, then writes the data back to main memory w...
void dataflashAutoPageRewrite1(uint32_t address)
OPCODE: 0x58 Rewrite the page in main memory at address 'address.' This performs a refresh of stored ...
#define CMD_DATAFLASH_ERASE_SECT_PROT_REG
void dataflashQuadEnable()
OPCODE: 0x3D2A8166 Programs the NV-QE bit to a logical 1 to enable the Quad I/O commands...
void dataflashBuffer2ReadLegacy(uint8_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x56 LEGACY: Reads rxNumBytes starting from location 'address' in buffer 2 and stores the d...
void dataflashHardwareReset()
Perform a JEDEC reset on the flash device.
void dataflashMemPageReadLegacy(uint8_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x52 LEGACY: Reads rxNumBytes starting from location 'address' and stores the data in the b...
#define CMD_DATAFLASH_QUAD_OUTPUT_READ_ARRAY
void dataflashBuffer2ToMainMemoryWithErase(uint32_t address)
OPCODE: 0x86 Programs the entire buffer 2 page to main memory starting at the address indicated by ...
#define CMD_DATAFLASH_BUF1_2MEM_WO_ERASE
void dataflashDualOutputRead(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x3B Reads 'txNumBytes' bytes of data in Dual Output Mode starting at 'address' using both ...
void dataflashSectorLockdown(uint32_t address)
OPCODE: 0x3D_2A_7F_30 Permanently a sector to prevent erasing or programming the stored data...
void dataflashBuffer1ReadLowFreq(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0xD1 Reads rxNumBytes starting from location 'address' in buffer 1 and stores the data in t...
void dataflashReadSR(uint8_t *rxBuffer)
OPCODE: 0xD7 Reads the value in the device status register (bytes 1 and 2).
#define CMD_DATAFLASH_QUAD_INPUT_BUFFER1_WRITE
void dataflashReadSRLegacy(uint8_t *rxBuffer)
OPCODE: 0x57 LEGACY: Reads the value in the device status register (bytes 1 and 2)...
#define CMD_DATAFLASH_BUFFER2_WRITE
void dataflashEraseSectorProtectionReg()
OPCODE: 0x3D_2A_7F_CF Erases the sector protection register. Erasing is required for modification/s...
#define CMD_DATAFLASH_BUFFER2_READ_HF
#define CMD_DATAFLASH_BUF2_2MEM_W_ERASE
void dataflashReadSectorProtectionReg(uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x32 Reads 'txNumBytes' bytes of data in from the SPR register.
#define CMD_DATAFLASH_MEM_BUF1_TRANSFER
void dataflashReadConfigRegister(uint8_t *rxBuffer)
OPCODE: 0x3F Reads the configuration register and returns the 1-byte value in rxBuffer.
void dataflashFreezeSectorLockdown()
OPCODE: 0x34_55_AA_40 Permanently freeze the sector lockdown register to prevent any future changes...
#define CMD_DATAFLASH_DISABLE_SECT_PROTECTION
#define CMD_DATAFLASH_MEM_PRGM_BUF2_W_ERASE
void dataflashArrayReadLowFreq(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x03 Reads rxNumBytes starting from location 'address' and stores the data in the byte arra...
#define CMD_DATAFLASH_MEM_PRGM_BUF1_W_ERASE
#define CMD_DATAFLASH_BUF2_2MEM_WO_ERASE
void load4BytesToTxBuffer(uint8_t *txBuffer, uint8_t opcode, uint32_t address)
Loads 1 byte of opcode followed by 3 address bytes into the txBuffer. The data is stored at the first...
void dataflashReadMID(uint8_t *rxBuffer)
OPCODE: 0x9F Reads the manufacturer ID and stores the data in rxBuffer.
#define CMD_DATAFLASH_PROGRAM_SECT_PROT_REG
void dataflashProgSecurityReg(uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x9B_00_00_00 Program the security register with the data in txBuffer.
void dataflashDualInputBuffer2Write(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x24 Programs 'txNumBytes' bytes of data to buffer 2 starting at the address indicated by a...
void dataflashPageErase(uint32_t address)
OPCODE: 0x81 Erases a page of data (256/264 Bytes) starting from page address 'address.'.
#define CMD_DATAFLASH_QUAD_INPUT_BUFFER2_WRITE
void dataflashQuadInputBuffer1Write(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x44 Programs 'txNumBytes' bytes of data to buffer 2 starting at the address indicated by a...
void dataflashBuffer1ReadHighFreq(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0xD4
#define CMD_DATAFLASH_READ_SECURITY_REG
#define CMD_DATAFLASH_FREEZE_SECTOR_LOCKDOWN
#define CMD_DATAFLASH_BUFFER1_READ_LF
void SPI_DualExchange(uint8_t standardSPINumBytes, uint8_t *txBuffer, uint32_t txNumBytes, uint8_t *rxBuffer, uint32_t rxNumBytes, uint32_t dummyNumBytes)
Sends and receives bytes based on the function parameters. MOSI is used for the opcode and address...
void dataflashSectorErase(uint32_t address)
OPCODE: 0x7C
#define CMD_DATAFLASH_READ_SECT_LOCK_REG
void dataflashMemoryPageRead(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0xD2 Reads rxNumBytes starting from location 'address' and stores the data in the byte arra...
#define CMD_DATAFLASH_READ_MID
#define CMD_DATAFLASH_BUFFER1_WRITE
void dataflashBuffer1Write(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x84 Programs 'txNumBytes' bytes of data to buffer 1 starting at the address indicated by a...
#define CMD_DATAFLASH_BUFFER2_READ_LF
void dataflashBuffer1ToMainMemoryWithErase(uint32_t address)
OPCODE: 0x83 Programs the entire buffer 1 page to main memory starting at the address indicated by ...
void dataflashResumeFromDPD()
OPCODE: 0xAB Wake the device from deep power down mode. See dataflashDPD().
#define CMD_DATAFLASH_BUF1_READ_LEG
#define CMD_DATAFLASH_MEM_BUF1_COMPARE
void SPI_Delay(uint32_t delayTime)
Performs a delayTime number of NOPs.
void dataflashProgramEraseResume()
OPCODE: 0xD0 Resumes a suspended program or erase operation. See dataflashProgramEraseSuspend().
#define CMD_DATAFLASH_BUF1_2MEM_W_ERASE
#define CMD_DATAFLASH_PROGRAM_SECURITY_REG
void dataflashWaitOnReady()
: Wait while Read/Busy Status bit in SRB is 1 (device is busy).
void dataflashQuadOutputRead(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x6B Reads 'txNumBytes' bytes of data in Quad Output Mode starting at 'address' using SI...
void dataflashChipErase()
OPCODE: 0xC794_809A Erases the entire chip by setting all bits.
#define CMD_DATAFLASH_SR_READ_LEG
void dataflashMemtoBuffer2Compare(uint32_t address)
OPCODE: 0x61 Compare the contents of a page in main memory to the contents of buffer 2...
#define CMD_DATAFLASH_BUF2_READ_LEG
void dataflashRMWThruBuffer2(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x59 Reads main memory to buffer 1, modifies it, then writes the data back to main memory w...
#define CMD_DATAFLASH_RD_MOD_WR_THRU_BUF1
#define CMD_DATAFLASH_PROGRAM_ERASE_RESUME
#define CMD_DATAFLASH_DUAL_OUTPUT_READ_ARRAY
void dataflashBuffer2ReadHighFreq(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0xD6 Reads rxNumBytes starting from location 'address' in buffer 2 and stores the data in t...
void dataflashConfigurePower2PageSize()
OPCODE: 0x3D_2A_80_A6 Configure the device to read and write with pages configured to 256 bytes...
void dataflashMemtoBuffer1Transfer(uint32_t address)
OPCODE: 0x53 Transfer the contents of a page in main memory at the address indicated by 'address' t...
void dataflashEnableSectorProtection()
OPCODE: 0x3D_2A_7F_A9 Enables sector protection.
#define CMD_DATAFLASH_MEM_PRGM_BUF1_WO_ERASE
void dataflashMemoryProgramThruBuffer1WithoutErase(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x02
#define CMD_DATAFLASH_AUTO_PAGE_REWRITE1
#define CMD_DATAFLASH_RD_MOD_WR_THRU_BUF2
#define CMD_DATAFLASH_CONFIGURE_STD_PG_SIZE
#define CMD_DATAFLASH_BLOCK_ERASE
void dataflashMemtoBuffer2Transfer(uint32_t address)
OPCODE: 0x55
void dataflashArrayReadHighFreq1(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x1B Reads rxNumBytes starting from location 'address' and stores the data in the byte arra...
void dataflashDualInputBuffer1Write(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x24 Programs 'txNumBytes' bytes of data to buffer 1 starting at the address indicated by a...
void dataflashConfigureStandardPageSize()
OPCODE: 0x3D_2A_80_A7 Configure the device to read and write with pages configured to 264 bytes...
#define CMD_DATAFLASH_RESUME_FROM_DPD
#define CMD_DATAFLASH_AUTO_PAGE_REWRITE2
void SPI_Exchange(uint8_t *txBuffer, uint32_t txNumBytes, uint8_t *rxBuffer, uint32_t rxNumBytes, uint32_t dummyNumBytes)
Sends and receives bytes based on the function parameters. MISO and MOSI fill their standard SPI role...
void dataflashQuadDisable()
OPCODE: 0x3D2A8167 Programs the NV-QE bit to a logical 0 to disable the Quad I/O commands...
void dataflashReadSecurityReg(uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x77 Reads 'rxNumBytes' bytes of data in from the security register.
void dataflashMemoryProgramThruBuffer2WithErase(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x85 Programs main memory through buffer 2 starting at the address indicated by 'address' w...
#define CMD_DATAFLASH_ARRAY_READ_LEG