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

Detailed Description

Declarations of Fusion functions.

Definition in file fusion.h.

#include "cmd_defs.h"
#include "spi_driver.h"
#include "helper_functions.h"
#include <stdio.h>
#include <stdlib.h>

Go to the source code of this file.

Functions

void fusionWaitOnReady ()
 : Wait while Read/Busy Status bit in SRB is 1 (device is busy). More...
 
void fusionGlobalProtect ()
 Protects all sectors by issuing a WE, then write of 0x7F to status register byte 1. These 2 write are accomplished with fusionWriteEnable() and fusionWriteSRB1(). More...
 
void fusionGlobalUnprotect ()
 Unprotects all sectors by issuing a WE, then write of 0x00 to status register byte 1. These 2 write are accomplished with fusionWriteEnable() and fusionWriteSRB1(). More...
 
void fusionReadArray (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 can read at multiple frequencies but necessitates the use of a dummy cycle. More...
 
void fusionReadArrayLF (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 uses a low frequency read as specified in the datasheet. More...
 
void fusionDualOutputRead (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 fusionPageErase (uint32_t address)
 OPCODE: 0x81
Erases a page of data (256 Bytes) starting from page address 'address.'. More...
 
void fusionBlockErase4K (uint32_t address)
 OPCODE: 0x20
Erases a block of data (4 KBytes) starting from page address 'address.'. More...
 
void fusionChipErase ()
 OPCODE: 0x60
Erases the entire chip by setting all bits. More...
 
void fusionProgramArray (uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
 OPCODE: 0x02
Programs 'txNumBytes' bytes of data starting at the address indicated by address. More...
 
void fusionWriteEnable ()
 OPCODE: 0x06
Sends opcode to enable writing. More...
 
void fusionWriteDisable ()
 OPCODE: 0x04
Sends opcode to disable writing. More...
 
void fusionReadSR (uint8_t *rxBuffer)
 OPCODE: 0x05
Reads the value in the status register (bytes 1 and 2). More...
 
void fusionWriteSRB1 (uint8_t data)
 OPCODE: 0x01
Writes the value in data to status register byte 1. More...
 
void fusionWriteSRB2 (uint8_t data)
 OPCODE: 0x31
Writes the value in data to status register byte 2. More...
 
void fusionReset ()
 OPCODE: 0xF0
Resets the flash device for immediately, regardless of what current operation is being performed. More...
 
void fusionReadMID (uint8_t *rxBuffer)
 OPCODE: 0x9F
Reads the manufacturer ID and stores the data in rxBuffer. More...
 
void fusionDeepPowerDown ()
 OPCODE: 0xB9
Enters the device into Deep Power Down mode. fusionResumeFromDeepPowerDown() will wake it back up again. More...
 
void fusionResumeFromDeepPowerDown ()
 OPCODE: 0xAB
Wakes the device up from Deep Power Down mode (fusionDeepPowerDown()). More...
 
void fusionUDPDMode ()
 OPCODE: 0x79
Sends the device into Ultra Deep Power Down Mode. Exit UDPD Mode by toggling CS with command ___ or using a JEDEC reset with command fusionHardwareReset(). More...
 
void fusionSequentialProgramMode (uint8_t txBuffer)
 OPCODE: 0xAD
Sends the byte in txBuffer to the flash device for programming. This command should only be called after fusionSequentialProgramModeEnbale(). More...
 
void fusionDualInputProgram (uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
 OPCODE: 0xA2
Programs 'txNumBytes' bytes of data in Dual Input Mode starting at 'address' using both SI and SO as outputs from master. More...
 
void fusionProtectSector (uint32_t address)
 OPCODE: 0x36
Sends opcode to disable writing. More...
 
void fusionUnprotectSector (uint32_t address)
 OPCODE: 0x39
Sends opcode to enable writing. More...
 
void fusionReadSectorProtectionRegisters (uint32_t address, uint8_t *rxBuffer)
 OPCODE: 0x3C
Reads the sector protection register at address 'address.' 0x00 -> Sector is unprotected. 0xFF -> Sector is protected. More...
 
void fusionSequentialProgramModeEnable (uint32_t address, uint8_t txBuffer)
 OPCODE: 0xAD
Enables sequential program mode and loads the starting address into the device. The first byte of data is also stored. More...
 
void fusionHardwareReset ()
 Performs a hardware (JEDEC) reset on the device. More...
 

Variables

uint8_t txFusionInternalBuffer [MAXIMUM_TX_BYTES]
 

Function Documentation

◆ fusionBlockErase4K()

void fusionBlockErase4K ( uint32_t  address)

OPCODE: 0x20
Erases a block of data (4 KBytes) starting from page address 'address.'.

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

Definition at line 130 of file fusion.c.

◆ fusionChipErase()

void fusionChipErase ( )

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

Return values
void

Definition at line 140 of file fusion.c.

◆ fusionDeepPowerDown()

void fusionDeepPowerDown ( )

OPCODE: 0xB9
Enters the device into Deep Power Down mode. fusionResumeFromDeepPowerDown() will wake it back up again.

Return values
void

Definition at line 240 of file fusion.c.

◆ fusionDualInputProgram()

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

OPCODE: 0xA2
Programs 'txNumBytes' bytes of data in Dual Input Mode starting at 'address' using both SI and SO as outputs from master.

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 non dummy bytes to be written to the device. txBuffer must have a minimum of this many elements.
Return values
void

Definition at line 289 of file fusion.c.

◆ fusionDualOutputRead()

void fusionDualOutputRead ( 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 110 of file fusion.c.

◆ fusionGlobalProtect()

void fusionGlobalProtect ( )

Protects all sectors by issuing a WE, then write of 0x7F to status register byte 1. These 2 write are accomplished with fusionWriteEnable() and fusionWriteSRB1().

Return values
void

Definition at line 78 of file fusion.c.

◆ fusionGlobalUnprotect()

void fusionGlobalUnprotect ( )

Unprotects all sectors by issuing a WE, then write of 0x00 to status register byte 1. These 2 write are accomplished with fusionWriteEnable() and fusionWriteSRB1().

Return values
void

Definition at line 84 of file fusion.c.

◆ fusionHardwareReset()

void fusionHardwareReset ( )

Performs a hardware (JEDEC) reset on the device.

Return values
void

Definition at line 348 of file fusion.c.

◆ fusionPageErase()

void fusionPageErase ( uint32_t  address)

OPCODE: 0x81
Erases a page of data (256 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 120 of file fusion.c.

◆ fusionProgramArray()

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

OPCODE: 0x02
Programs 'txNumBytes' bytes of data starting at the address indicated by address.

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
Warning
Check datasheet for the maximum number of bytes that can be written, as well as the device behavior if writing goes beyond the page boundary.

Definition at line 150 of file fusion.c.

◆ fusionProtectSector()

void fusionProtectSector ( uint32_t  address)

OPCODE: 0x36
Sends opcode to disable writing.

Parameters
address3 byte address for the sector that will be protected.
Return values
void

Definition at line 306 of file fusion.c.

◆ fusionReadArray()

void fusionReadArray ( 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 can read at multiple frequencies but necessitates the use of a dummy cycle.

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 90 of file fusion.c.

◆ fusionReadArrayLF()

void fusionReadArrayLF ( 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 uses a low frequency read 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 100 of file fusion.c.

◆ fusionReadMID()

void fusionReadMID ( 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 4 bytes required.
Return values
void

Definition at line 230 of file fusion.c.

◆ fusionReadSectorProtectionRegisters()

void fusionReadSectorProtectionRegisters ( uint32_t  address,
uint8_t *  rxBuffer 
)

OPCODE: 0x3C
Reads the sector protection register at address 'address.' 0x00 -> Sector is unprotected. 0xFF -> Sector is protected.

Parameters
address3 byte address for the sector of interest.
rxBufferThe byte buffer in which the value of the protection register will be stored.
Return values
void

Definition at line 326 of file fusion.c.

◆ fusionReadSR()

void fusionReadSR ( uint8_t *  rxBuffer)

OPCODE: 0x05
Reads the value in the 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 187 of file fusion.c.

◆ fusionReset()

void fusionReset ( )

OPCODE: 0xF0
Resets the flash device for immediately, regardless of what current operation is being performed.

Return values
void

Definition at line 219 of file fusion.c.

◆ fusionResumeFromDeepPowerDown()

void fusionResumeFromDeepPowerDown ( )

OPCODE: 0xAB
Wakes the device up from Deep Power Down mode (fusionDeepPowerDown()).

Return values
void

Definition at line 250 of file fusion.c.

◆ fusionSequentialProgramMode()

void fusionSequentialProgramMode ( uint8_t  txBuffer)

OPCODE: 0xAD
Sends the byte in txBuffer to the flash device for programming. This command should only be called after fusionSequentialProgramModeEnbale().

Parameters
txBufferThe byte of data to be programmed.
Return values
void

Definition at line 278 of file fusion.c.

◆ fusionSequentialProgramModeEnable()

void fusionSequentialProgramModeEnable ( uint32_t  address,
uint8_t  txBuffer 
)

OPCODE: 0xAD
Enables sequential program mode and loads the starting address into the device. The first byte of data is also stored.

Parameters
addressThe address from which the sequential programming will begin.
txBufferThe first byte of data to be stored in flash memory.
Return values
void

Definition at line 336 of file fusion.c.

◆ fusionUDPDMode()

void fusionUDPDMode ( )

OPCODE: 0x79
Sends the device into Ultra Deep Power Down Mode. Exit UDPD Mode by toggling CS with command ___ or using a JEDEC reset with command fusionHardwareReset().

Return values
void

Definition at line 260 of file fusion.c.

◆ fusionUnprotectSector()

void fusionUnprotectSector ( uint32_t  address)

OPCODE: 0x39
Sends opcode to enable writing.

Parameters
address3 byte address for the sector that will be unprotected.
Return values
void

Definition at line 316 of file fusion.c.

◆ fusionWaitOnReady()

void fusionWaitOnReady ( )

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

Return values
void

Definition at line 67 of file fusion.c.

◆ fusionWriteDisable()

void fusionWriteDisable ( )

OPCODE: 0x04
Sends opcode to disable writing.

Return values
void

Definition at line 177 of file fusion.c.

◆ fusionWriteEnable()

void fusionWriteEnable ( )

OPCODE: 0x06
Sends opcode to enable writing.

Return values
void

Definition at line 167 of file fusion.c.

◆ fusionWriteSRB1()

void fusionWriteSRB1 ( uint8_t  data)

OPCODE: 0x01
Writes the value in data to status register byte 1.

Parameters
dataByte of data to be written into status register byte 1.
Return values
void

Definition at line 197 of file fusion.c.

◆ fusionWriteSRB2()

void fusionWriteSRB2 ( uint8_t  data)

OPCODE: 0x31
Writes the value in data to status register byte 2.

Parameters
dataByte of data to be written into status register byte 2.
Return values
void

Definition at line 208 of file fusion.c.

Variable Documentation

◆ txFusionInternalBuffer

uint8_t txFusionInternalBuffer[MAXIMUM_TX_BYTES]

Definition at line 63 of file fusion.c.