Sample SPI drivers for a number of the Adesto Technologies flash devices.
Functions | Variables
dataflash.c File Reference

Detailed Description

Definitions of Dataflash functions.

Definition in file dataflash.c.

#include "dataflash.h"

Go to the source code of this file.

Functions

void dataflashWaitOnReady ()
 : Wait while Read/Busy Status bit in SRB is 1 (device is busy). More...
 
void dataflashReadMID (uint8_t *rxBuffer)
 OPCODE: 0x9F
Reads the manufacturer ID and stores the data in rxBuffer. More...
 
void dataflashReadSR (uint8_t *rxBuffer)
 OPCODE: 0xD7
Reads the value in the device status register (bytes 1 and 2). More...
 
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 array rxBuffer. This command reads from a page in main memory and bypasses the buffer leaving their contents untouched as specified in the datasheet. More...
 
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 array rxBuffer. This command reads from a page in main memory at a lower frequency than other commands in order to minimize power consumption as specified in the datasheet. More...
 
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 array rxBuffer. This command reads from a page in main memory at a lower frequency than other commands as specified in the datasheet. More...
 
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 array rxBuffer. This command reads from a page in main memory at a higher frequency than other commands as specified in the datasheet. More...
 
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 array rxBuffer. This command reads from a page in main memory at a higher frequency than other commands as specified in the datasheet. More...
 
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 array rxBuffer. This command reads from a page in main memory as specified in the datasheet. More...
 
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 the byte array rxBuffer. This command reads from buffer 1 at a lower frequency than other commands as specified in the datasheet. More...
 
void dataflashBuffer1ReadHighFreq (uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
 OPCODE: 0xD4
More...
 
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 address. More...
 
void dataflashBuffer1ToMainMemoryWithErase (uint32_t address)
 OPCODE: 0x83
Programs the entire buffer 1 page to main memory starting at the address indicated by 'address' with the build in erase feature. More...
 
void dataflashBuffer1ToMainMemoryWithoutErase (uint32_t address)
 OPCODE: 0x88
Programs the entire buffer 1 page to main memory starting at the address indicated by 'address'. The data in the page indicated at address will be not erased before the data in buffer 1 is programmed to main memory. It is therefore recommended that the user erase the page beforehand. More...
 
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' with the built in erase feature. More...
 
void dataflashMemoryProgramThruBuffer1WithoutErase (uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
 OPCODE: 0x02
More...
 
void dataflashPageErase (uint32_t address)
 OPCODE: 0x81
Erases a page of data (256/264 Bytes) starting from page address 'address.'. More...
 
void dataflashBlockErase (uint32_t address)
 OPCODE: 0x50
Erases a block of data (8 pages) starting from page address 'address.'. More...
 
void dataflashSectorErase (uint32_t address)
 OPCODE: 0x7C
More...
 
void dataflashChipErase ()
 OPCODE: 0xC794_809A
Erases the entire chip by setting all bits. More...
 
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 with built in erase. More...
 
void dataflashEnableSectorProtection ()
 OPCODE: 0x3D_2A_7F_A9
Enables sector protection. More...
 
void dataflashDisableSectorProtection ()
 OPCODE: 0x3D_2A_7F_9A
Disables sector protection. More...
 
void dataflashEraseSectorProtectionReg ()
 OPCODE: 0x3D_2A_7F_CF
Erases the sector protection register. Erasing is required for modification/setting bits in the register. More...
 
void dataflashProgSectorProtectionReg (uint8_t *txBuffer, uint32_t txNumBytes)
 OPCODE: 0x3D_2A_7F_FC
Program the sector protection register with the data in txBuffer. More...
 
void dataflashReadSectorProtectionReg (uint8_t *rxBuffer, uint32_t rxNumBytes)
 OPCODE: 0x32
Reads 'txNumBytes' bytes of data in from the SPR register. More...
 
void dataflashReadSecurityReg (uint8_t *rxBuffer, uint32_t rxNumBytes)
 OPCODE: 0x77 Reads 'rxNumBytes' bytes of data in from the security register. More...
 
void dataflashMemtoBuffer1Transfer (uint32_t address)
 OPCODE: 0x53
Transfer the contents of a page in main memory at the address indicated by 'address' to buffer 1. More...
 
void dataflashMemtoBuffer1Compare (uint32_t address)
 OPCODE: 0x60
Compare the contents of a page in main memory to the contents of buffer 1. The status register should be read, and the 6th bit of byte 1 examined to determine the result.
0 -> Main memory page data matches buffer data.
1 -> Main memory page data does not match buffer data. More...
 
void dataflashAutoPageRewrite1 (uint32_t address)
 OPCODE: 0x58 Rewrite the page in main memory at address 'address.' This performs a refresh of stored data. Data is stored in buffer 1 from main memory, then written back in. More...
 
void dataflashDPD ()
 OPCODE: 0xB9 Put the device into deep power down mode. Call dataflashResumeFromDPD() to wake up, or perform a hardware reset dataflashHardwareReset(). More...
 
void dataflashUDPDMode ()
 OPCODE: 0x79
Put the device into ultra deep power down mode. Wake the device with dataflashHardwareReset(). More...
 
void dataflashHardwareReset ()
 Perform a JEDEC reset on the flash device. More...
 
void dataflashResumeFromDPD ()
 OPCODE: 0xAB
Wake the device from deep power down mode. See dataflashDPD(). More...
 
void dataflashConfigurePower2PageSize ()
 OPCODE: 0x3D_2A_80_A6
Configure the device to read and write with pages configured to 256 bytes. More...
 
void dataflashConfigureStandardPageSize ()
 OPCODE: 0x3D_2A_80_A7
Configure the device to read and write with pages configured to 264 bytes. More...
 
void dataflashSoftwareReset ()
 OPCODE: 0xF0_00_00_00
Perform a software reset on the device. This will terminate any read or write operation in progress. More...
 
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 data in the byte array rxBuffer. More...
 
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 byte array rxBuffer. More...
 
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 byte array rxBuffer. More...
 
void dataflashReadSRLegacy (uint8_t *rxBuffer)
 OPCODE: 0x57
LEGACY: Reads the value in the device status register (bytes 1 and 2). More...
 
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 SI and SO as inputs to master. More...
 
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, SO, WPb, and HOLDb as inputs to master. More...
 
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 address using SI and SO as inputs for dual input. More...
 
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 address using SI and SO as inputs for dual input. More...
 
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 address using SI, SO, WPb, and RESETb as inputs for quad input. More...
 
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 address using SI, SO, WPb, and RESETb as inputs for quad input. More...
 
void dataflashReadConfigRegister (uint8_t *rxBuffer)
 OPCODE: 0x3F
Reads the configuration register and returns the 1-byte value in rxBuffer. More...
 
void dataflashQuadEnable ()
 OPCODE: 0x3D2A8166
Programs the NV-QE bit to a logical 1 to enable the Quad I/O commands. More...
 
void dataflashQuadDisable ()
 OPCODE: 0x3D2A8167
Programs the NV-QE bit to a logical 0 to disable the Quad I/O commands. More...
 
void dataflashProgramEraseSuspend ()
 OPCODE: 0xB0
Suspends a program or erase operation in progress to a particular 64KB sector of the main memory array so that other device operations can be performed. More...
 
void dataflashProgramEraseResume ()
 OPCODE: 0xD0
Resumes a suspended program or erase operation. See dataflashProgramEraseSuspend(). More...
 
void dataflashSectorLockdown (uint32_t address)
 OPCODE: 0x3D_2A_7F_30
Permanently a sector to prevent erasing or programming the stored data. More...
 
void dataflashReadSectorLockdownReg (uint8_t *rxBuffer, uint32_t rxNumBytes)
 OPCODE: 0x35 Reads 'rxNumBytes' bytes of data in from the SL register. More...
 
void dataflashFreezeSectorLockdown ()
 OPCODE: 0x34_55_AA_40
Permanently freeze the sector lockdown register to prevent any future changes and disable the sector lockdown command. The current state will be preserved. More...
 
void dataflashProgSecurityReg (uint8_t *txBuffer, uint32_t txNumBytes)
 OPCODE: 0x9B_00_00_00
Program the security register with the data in txBuffer. More...
 
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 the byte array rxBuffer. This command reads from buffer 2 at a lower frequency than other commands as specified in the datasheet. More...
 
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 the byte array rxBuffer. This command reads from buffer 2 at a higher frequency than other commands as specified in the datasheet. More...
 
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 address. More...
 
void dataflashBuffer2ToMainMemoryWithErase (uint32_t address)
 OPCODE: 0x86
Programs the entire buffer 2 page to main memory starting at the address indicated by 'address'. with the build in erase feature. More...
 
void dataflashBuffer2ToMainMemoryWithoutErase (uint32_t address)
 OPCODE: 0x89
Programs the entire buffer 2 page to main memory starting at the address indicated by 'address'. The data in the page indicated at address will be not erased before the data in buffer 2 is programmed to main memory. It is therefore recommended that the user erase the page beforehand. More...
 
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' with the built in erase feature. More...
 
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 with built in erase. More...
 
void dataflashMemtoBuffer2Transfer (uint32_t address)
 OPCODE: 0x55
More...
 
void dataflashMemtoBuffer2Compare (uint32_t address)
 OPCODE: 0x61
Compare the contents of a page in main memory to the contents of buffer 2. The status register should be read, and the 6th bit of byte 1 examined to determine the result.
0 -> Main memory page data matches buffer data.
1 -> Main memory page data does not match buffer data. More...
 
void dataflashAutoPageRewrite2 (uint32_t address)
 OPCODE: 0x59 Rewrite the page in main memory at address 'address.' This performs a refresh of stored data. Data is stored in buffer 2 from main memory, then written back in. More...
 
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 data in the byte array rxBuffer. More...
 

Variables

uint8_t txDataflashInternalBuffer [MAXIMUM_TX_BYTES]
 

Function Documentation

◆ dataflashArrayReadHighFreq0()

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 array rxBuffer. This command reads from a page in main memory at a higher frequency than other commands as specified in the datasheet.

Parameters
address3 byte address starting from which the data in memory will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 126 of file dataflash.c.

◆ dataflashArrayReadHighFreq1()

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 array rxBuffer. This command reads from a page in main memory at a higher frequency than other commands as specified in the datasheet.

Parameters
address3 byte address starting from which the data in memory will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 136 of file dataflash.c.

◆ dataflashArrayReadLegacy()

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 array rxBuffer. This command reads from a page in main memory as specified in the datasheet.

Parameters
address3 byte address starting from which the data in memory will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 146 of file dataflash.c.

◆ dataflashArrayReadLowFreq()

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 array rxBuffer. This command reads from a page in main memory at a lower frequency than other commands as specified in the datasheet.

Parameters
address3 byte address starting from which the data in memory will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 116 of file dataflash.c.

◆ dataflashArrayReadLowPower()

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 array rxBuffer. This command reads from a page in main memory at a lower frequency than other commands in order to minimize power consumption as specified in the datasheet.

Parameters
address3 byte address starting from which the data in memory will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 106 of file dataflash.c.

◆ dataflashAutoPageRewrite1()

void dataflashAutoPageRewrite1 ( uint32_t  address)

OPCODE: 0x58 Rewrite the page in main memory at address 'address.' This performs a refresh of stored data. Data is stored in buffer 1 from main memory, then written back in.

Parameters
addressThe page address in main memory from which data will be transferred to buffer 1.
Return values
void

Definition at line 405 of file dataflash.c.

◆ dataflashAutoPageRewrite2()

void dataflashAutoPageRewrite2 ( uint32_t  address)

OPCODE: 0x59 Rewrite the page in main memory at address 'address.' This performs a refresh of stored data. Data is stored in buffer 2 from main memory, then written back in.

Parameters
addressThe page address in main memory from which data will be transferred to buffer 2.
Return values
void

Definition at line 858 of file dataflash.c.

◆ dataflashBlockErase()

void dataflashBlockErase ( uint32_t  address)

OPCODE: 0x50
Erases a block of data (8 pages) starting from page address 'address.'.

Parameters
addressThe 3 byte page address at which the block erase will start.
Return values
void

Definition at line 257 of file dataflash.c.

◆ dataflashBuffer1ReadHighFreq()

void dataflashBuffer1ReadHighFreq ( uint32_t  address,
uint8_t *  rxBuffer,
uint32_t  rxNumBytes 
)

OPCODE: 0xD4

OPCODE: 0xD4
Reads rxNumBytes starting from location 'address' in buffer 1 and stores the data in the byte array rxBuffer. This command reads from buffer 1 at a higher frequency than other commands as specified in the datasheet.

Parameters
address3 byte address starting from which the data in buffer 1 will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 166 of file dataflash.c.

◆ dataflashBuffer1ReadLegacy()

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 data in the byte array rxBuffer.

Parameters
address3 byte address starting from which the data in buffer 2 will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 489 of file dataflash.c.

◆ dataflashBuffer1ReadLowFreq()

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 the byte array rxBuffer. This command reads from buffer 1 at a lower frequency than other commands as specified in the datasheet.

Parameters
address3 byte address starting from which the data in buffer 1 will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 156 of file dataflash.c.

◆ dataflashBuffer1ToMainMemoryWithErase()

void dataflashBuffer1ToMainMemoryWithErase ( uint32_t  address)

OPCODE: 0x83
Programs the entire buffer 1 page to main memory starting at the address indicated by 'address' with the build in erase feature.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
Return values
void

Definition at line 193 of file dataflash.c.

◆ dataflashBuffer1ToMainMemoryWithoutErase()

void dataflashBuffer1ToMainMemoryWithoutErase ( uint32_t  address)

OPCODE: 0x88
Programs the entire buffer 1 page to main memory starting at the address indicated by 'address'. The data in the page indicated at address will be not erased before the data in buffer 1 is programmed to main memory. It is therefore recommended that the user erase the page beforehand.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
Return values
void

Definition at line 203 of file dataflash.c.

◆ dataflashBuffer1Write()

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 address.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
txBufferPointer to the tx bytes that will be stored in buffer 1. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to buffer 1. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 176 of file dataflash.c.

◆ dataflashBuffer2ReadHighFreq()

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 the byte array rxBuffer. This command reads from buffer 2 at a higher frequency than other commands as specified in the datasheet.

Parameters
address3 byte address starting from which the data in buffer 2 will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 757 of file dataflash.c.

◆ dataflashBuffer2ReadLegacy()

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 data in the byte array rxBuffer.

Parameters
address3 byte address starting from which the data in buffer 2 will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 868 of file dataflash.c.

◆ dataflashBuffer2ReadLowFreq()

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 the byte array rxBuffer. This command reads from buffer 2 at a lower frequency than other commands as specified in the datasheet.

Parameters
address3 byte address starting from which the data in buffer 2 will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 747 of file dataflash.c.

◆ dataflashBuffer2ToMainMemoryWithErase()

void dataflashBuffer2ToMainMemoryWithErase ( uint32_t  address)

OPCODE: 0x86
Programs the entire buffer 2 page to main memory starting at the address indicated by 'address'. with the build in erase feature.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
Return values
void

Definition at line 784 of file dataflash.c.

◆ dataflashBuffer2ToMainMemoryWithoutErase()

void dataflashBuffer2ToMainMemoryWithoutErase ( uint32_t  address)

OPCODE: 0x89
Programs the entire buffer 2 page to main memory starting at the address indicated by 'address'. The data in the page indicated at address will be not erased before the data in buffer 2 is programmed to main memory. It is therefore recommended that the user erase the page beforehand.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
Return values
void

Definition at line 794 of file dataflash.c.

◆ dataflashBuffer2Write()

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 address.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
txBufferPointer to the tx bytes that will be stored in buffer 2. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to buffer 2. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 767 of file dataflash.c.

◆ dataflashChipErase()

void dataflashChipErase ( )

OPCODE: 0xC794_809A
Erases the entire chip by setting all bits.

Return values
void

Definition at line 277 of file dataflash.c.

◆ dataflashConfigurePower2PageSize()

void dataflashConfigurePower2PageSize ( )

OPCODE: 0x3D_2A_80_A6
Configure the device to read and write with pages configured to 256 bytes.

Return values
void

Definition at line 450 of file dataflash.c.

◆ dataflashConfigureStandardPageSize()

void dataflashConfigureStandardPageSize ( )

OPCODE: 0x3D_2A_80_A7
Configure the device to read and write with pages configured to 264 bytes.

Return values
void

Definition at line 463 of file dataflash.c.

◆ dataflashContinuousArrayReadLegacy()

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 byte array rxBuffer.

Parameters
address3 byte address starting from which the data in memory will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 509 of file dataflash.c.

◆ dataflashDisableSectorProtection()

void dataflashDisableSectorProtection ( )

OPCODE: 0x3D_2A_7F_9A
Disables sector protection.

Return values
void

Definition at line 320 of file dataflash.c.

◆ dataflashDPD()

void dataflashDPD ( )

OPCODE: 0xB9 Put the device into deep power down mode. Call dataflashResumeFromDPD() to wake up, or perform a hardware reset dataflashHardwareReset().

Return values
void

Definition at line 415 of file dataflash.c.

◆ dataflashDualInputBuffer1Write()

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 address using SI and SO as inputs for dual input.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
txBufferPointer to the tx bytes that will be stored in buffer 2. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to buffer 2. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 551 of file dataflash.c.

◆ dataflashDualInputBuffer2Write()

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 address using SI and SO as inputs for dual input.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
txBufferPointer to the tx bytes that will be stored in buffer 2. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to buffer 2. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 566 of file dataflash.c.

◆ dataflashDualOutputRead()

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 SI and SO as inputs to master.

Parameters
addressAddress starting from which the data in memory will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 531 of file dataflash.c.

◆ dataflashEnableSectorProtection()

void dataflashEnableSectorProtection ( )

OPCODE: 0x3D_2A_7F_A9
Enables sector protection.

Return values
void

Definition at line 307 of file dataflash.c.

◆ dataflashEraseSectorProtectionReg()

void dataflashEraseSectorProtectionReg ( )

OPCODE: 0x3D_2A_7F_CF
Erases the sector protection register. Erasing is required for modification/setting bits in the register.

Return values
void

Definition at line 333 of file dataflash.c.

◆ dataflashFreezeSectorLockdown()

void dataflashFreezeSectorLockdown ( )

OPCODE: 0x34_55_AA_40
Permanently freeze the sector lockdown register to prevent any future changes and disable the sector lockdown command. The current state will be preserved.

Warning
This command permanently disables the sector lockdown command.

Definition at line 703 of file dataflash.c.

◆ dataflashHardwareReset()

void dataflashHardwareReset ( )

Perform a JEDEC reset on the flash device.

Return values
void

Definition at line 435 of file dataflash.c.

◆ dataflashMemoryPageRead()

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 array rxBuffer. This command reads from a page in main memory and bypasses the buffer leaving their contents untouched as specified in the datasheet.

Parameters
address3 byte address starting from which the data in memory will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 96 of file dataflash.c.

◆ dataflashMemoryProgramThruBuffer1WithErase()

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' with the built in erase feature.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
txBufferPointer to the tx bytes that will be stored in buffer 2. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to buffer 2. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 213 of file dataflash.c.

◆ dataflashMemoryProgramThruBuffer1WithoutErase()

void dataflashMemoryProgramThruBuffer1WithoutErase ( uint32_t  address,
uint8_t *  txBuffer,
uint32_t  txNumBytes 
)

OPCODE: 0x02

OPCODE: 0x02
Programs main memory through buffer 1 starting at the address indicated by 'address'. The data in the page indicated at address will be not erased before the data in buffer 2 is programmed to main memory. It is therefore recommended that the user erase the page beforehand.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
txBufferPointer to the tx bytes that will be stored in buffer 2. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to buffer 2. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 230 of file dataflash.c.

◆ dataflashMemoryProgramThruBuffer2WithErase()

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' with the built in erase feature.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
txBufferPointer to the tx bytes that will be stored in buffer 2. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to buffer 2. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 804 of file dataflash.c.

◆ dataflashMemPageReadLegacy()

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 byte array rxBuffer.

Parameters
address3 byte address starting from which the data in memory will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 499 of file dataflash.c.

◆ dataflashMemtoBuffer1Compare()

void dataflashMemtoBuffer1Compare ( uint32_t  address)

OPCODE: 0x60
Compare the contents of a page in main memory to the contents of buffer 1. The status register should be read, and the 6th bit of byte 1 examined to determine the result.
0 -> Main memory page data matches buffer data.
1 -> Main memory page data does not match buffer data.

Parameters
addressThe page address in main memory from which data will be transferred to buffer 1.
Return values
void

Definition at line 395 of file dataflash.c.

◆ dataflashMemtoBuffer1Transfer()

void dataflashMemtoBuffer1Transfer ( uint32_t  address)

OPCODE: 0x53
Transfer the contents of a page in main memory at the address indicated by 'address' to buffer 1.

Parameters
addressThe page address in main memory from which data will be transferred to buffer 1.
Return values
void

Definition at line 385 of file dataflash.c.

◆ dataflashMemtoBuffer2Compare()

void dataflashMemtoBuffer2Compare ( uint32_t  address)

OPCODE: 0x61
Compare the contents of a page in main memory to the contents of buffer 2. The status register should be read, and the 6th bit of byte 1 examined to determine the result.
0 -> Main memory page data matches buffer data.
1 -> Main memory page data does not match buffer data.

Parameters
addressThe page address in main memory from which data will be transferred to buffer 2.
Return values
void

Definition at line 848 of file dataflash.c.

◆ dataflashMemtoBuffer2Transfer()

void dataflashMemtoBuffer2Transfer ( uint32_t  address)

OPCODE: 0x55

Definition at line 838 of file dataflash.c.

◆ dataflashPageErase()

void dataflashPageErase ( uint32_t  address)

OPCODE: 0x81
Erases a page of data (256/264 Bytes) starting from page address 'address.'.

Parameters
addressThe 3 byte page address at which the page erase will start.
Return values
void

Definition at line 247 of file dataflash.c.

◆ dataflashProgramEraseResume()

void dataflashProgramEraseResume ( )

OPCODE: 0xD0
Resumes a suspended program or erase operation. See dataflashProgramEraseSuspend().

Return values
void

Definition at line 667 of file dataflash.c.

◆ dataflashProgramEraseSuspend()

void dataflashProgramEraseSuspend ( )

OPCODE: 0xB0
Suspends a program or erase operation in progress to a particular 64KB sector of the main memory array so that other device operations can be performed.

Return values
void

Definition at line 657 of file dataflash.c.

◆ dataflashProgSectorProtectionReg()

void dataflashProgSectorProtectionReg ( uint8_t *  txBuffer,
uint32_t  txNumBytes 
)

OPCODE: 0x3D_2A_7F_FC
Program the sector protection register with the data in txBuffer.

Warning
The user must send 8 bytes of data. Fewer than 8 bytes results in indeterminate data being stored in the SPRs
Parameters
txBufferPointer to the tx bytes that will be stored in memory. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to the device. txBuffer must have a minimum of this many elements..
Return values
void

Definition at line 346 of file dataflash.c.

◆ dataflashProgSecurityReg()

void dataflashProgSecurityReg ( uint8_t *  txBuffer,
uint32_t  txNumBytes 
)

OPCODE: 0x9B_00_00_00
Program the security register with the data in txBuffer.

Parameters
txBufferPointer to the tx bytes that will be stored in memory. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to the device. txBuffer must have a minimum of this many elements.
Warning
The user must send 64 bytes of data. Fewer than 64 bytes results in indeterminate data being stored in the SPRs. The bits in this register can only be cleared, and never set. As such each bit is one time erasable.
Return values
void

Definition at line 716 of file dataflash.c.

◆ dataflashQuadDisable()

void dataflashQuadDisable ( )

OPCODE: 0x3D2A8167
Programs the NV-QE bit to a logical 0 to disable the Quad I/O commands.

Return values
0

Definition at line 634 of file dataflash.c.

◆ dataflashQuadEnable()

void dataflashQuadEnable ( )

OPCODE: 0x3D2A8166
Programs the NV-QE bit to a logical 1 to enable the Quad I/O commands.

Return values
0

Definition at line 621 of file dataflash.c.

◆ dataflashQuadInputBuffer1Write()

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 address using SI, SO, WPb, and RESETb as inputs for quad input.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
txBufferPointer to the tx bytes that will be stored in buffer 2. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to buffer 2. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 581 of file dataflash.c.

◆ dataflashQuadInputBuffer2Write()

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 address using SI, SO, WPb, and RESETb as inputs for quad input.

Parameters
addressThe 3 bytes address indicating the first location to be written to. Note page restrictions in manual.
txBufferPointer to the tx bytes that will be stored in buffer 2. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to buffer 2. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 596 of file dataflash.c.

◆ dataflashQuadOutputRead()

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, SO, WPb, and HOLDb as inputs to master.

Parameters
addressAddress starting from which the data in memory will be read.
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the memory. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 541 of file dataflash.c.

◆ dataflashReadConfigRegister()

void dataflashReadConfigRegister ( uint8_t *  rxBuffer)

OPCODE: 0x3F
Reads the configuration register and returns the 1-byte value in rxBuffer.

Parameters
rxBufferthe buffer in which the 1-byte value will be stored.
Return values
void

Definition at line 611 of file dataflash.c.

◆ dataflashReadMID()

void dataflashReadMID ( uint8_t *  rxBuffer)

OPCODE: 0x9F
Reads the manufacturer ID and stores the data in rxBuffer.

Parameters
rxBufferPointer to a byte array in which the data will be stored. Minimum of 8 bytes required.
Return values
void

Definition at line 76 of file dataflash.c.

◆ dataflashReadSectorLockdownReg()

void dataflashReadSectorLockdownReg ( uint8_t *  rxBuffer,
uint32_t  rxNumBytes 
)

OPCODE: 0x35 Reads 'rxNumBytes' bytes of data in from the SL register.

Parameters
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the register. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 693 of file dataflash.c.

◆ dataflashReadSectorProtectionReg()

void dataflashReadSectorProtectionReg ( uint8_t *  rxBuffer,
uint32_t  rxNumBytes 
)

OPCODE: 0x32
Reads 'txNumBytes' bytes of data in from the SPR register.

Parameters
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the register. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 365 of file dataflash.c.

◆ dataflashReadSecurityReg()

void dataflashReadSecurityReg ( uint8_t *  rxBuffer,
uint32_t  rxNumBytes 
)

OPCODE: 0x77 Reads 'rxNumBytes' bytes of data in from the security register.

Parameters
rxBufferPointer to the byte array in which the read data will be stored. Must have at least rxNumBytes elements.
rxNumBytesNumber of bytes to be read from the register. rxBuffer must have a minimum of this many elements.
Return values
void

Definition at line 375 of file dataflash.c.

◆ dataflashReadSR()

void dataflashReadSR ( uint8_t *  rxBuffer)

OPCODE: 0xD7
Reads the value in the device status register (bytes 1 and 2).

Parameters
rxBufferPointer to the byte array in which the read data will be stored. Must have at least 2 elements.
Return values
void

Definition at line 86 of file dataflash.c.

◆ dataflashReadSRLegacy()

void dataflashReadSRLegacy ( uint8_t *  rxBuffer)

OPCODE: 0x57
LEGACY: Reads the value in the device status register (bytes 1 and 2).

Parameters
rxBufferPointer to the byte array in which the read data will be stored. Must have at least 2 elements.
Return values
void

Definition at line 519 of file dataflash.c.

◆ dataflashResumeFromDPD()

void dataflashResumeFromDPD ( )

OPCODE: 0xAB
Wake the device from deep power down mode. See dataflashDPD().

Return values
void

Definition at line 440 of file dataflash.c.

◆ dataflashRMWThruBuffer1()

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 with built in erase.

Parameters
addressThe 3 bytes address indicating the first location to be written to.
txBufferPointer to the tx bytes that will be stored in memory. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to the device. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 290 of file dataflash.c.

◆ dataflashRMWThruBuffer2()

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 with built in erase.

Parameters
addressThe 3 bytes address indicating the first location to be written to.
txBufferPointer to the tx bytes that will be stored in memory. Must have a minimum of txNumBytes elements.
txNumBytesNumber of bytes to be written to the device. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 821 of file dataflash.c.

◆ dataflashSectorErase()

void dataflashSectorErase ( uint32_t  address)

OPCODE: 0x7C

OPCODE: 0x7C
Erases a sector of data starting from page address 'address.'

Parameters
addressThe 3 byte page address at which the block erase will start.
Return values
void

Definition at line 267 of file dataflash.c.

◆ dataflashSectorLockdown()

void dataflashSectorLockdown ( uint32_t  address)

OPCODE: 0x3D_2A_7F_30
Permanently a sector to prevent erasing or programming the stored data.

Parameters
addressThe address of the sector to be locked.
Warning
Once a sector is locked it can never be unlocked!

Definition at line 677 of file dataflash.c.

◆ dataflashSoftwareReset()

void dataflashSoftwareReset ( )

OPCODE: 0xF0_00_00_00
Perform a software reset on the device. This will terminate any read or write operation in progress.

Definition at line 476 of file dataflash.c.

◆ dataflashUDPDMode()

void dataflashUDPDMode ( )

OPCODE: 0x79
Put the device into ultra deep power down mode. Wake the device with dataflashHardwareReset().

Return values
void

Definition at line 425 of file dataflash.c.

◆ dataflashWaitOnReady()

void dataflashWaitOnReady ( )

: Wait while Read/Busy Status bit in SRB is 1 (device is busy).

Return values
void

Definition at line 65 of file dataflash.c.

Variable Documentation

◆ txDataflashInternalBuffer

uint8_t txDataflashInternalBuffer[MAXIMUM_TX_BYTES]

Definition at line 61 of file dataflash.c.