Sample SPI drivers for a number of the Adesto Technologies flash devices.
fusion.h
Go to the documentation of this file.
1 /*
2  * The Clear BSD License
3  * Copyright (c) 2018 Adesto Technologies Corporation, Inc
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without modification,
7  * are permitted (subject to the limitations in the disclaimer below) provided
8  * that the following conditions are met:
9  *
10  * o Redistributions of source code must retain the above copyright notice, this list
11  * of conditions and the following disclaimer.
12  *
13  * o Redistributions in binary form must reproduce the above copyright notice, this
14  * list of conditions and the following disclaimer in the documentation and/or
15  * other materials provided with the distribution.
16  *
17  * o Neither the name of the copyright holder nor the names of its
18  * contributors may be used to endorse or promote products derived from this
19  * software without specific prior written permission.
20  *
21  * NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE GRANTED BY THIS LICENSE.
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
23  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
24  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
25  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
26  * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
27  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
29  * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
31  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
42 #ifndef FUSION_H_
43 #define FUSION_H_
44 
45 #include "cmd_defs.h"
46 #include "spi_driver.h"
47 #include "helper_functions.h"
48 #include <stdio.h>
49 #include <stdlib.h>
50 
51 #if (PARTNO == AT25XE512C) || \
52  (PARTNO == AT25XE011) || \
53  (PARTNO == AT25XE021A) || \
54  (PARTNO == AT25XE041B) || \
55  (PARTNO == AT25DN256) || \
56  (PARTNO == AT25DN512C) || \
57  (PARTNO == AT25DN011) || \
58  (PARTNO == AT25DF256) || \
59  (PARTNO == AT25DF512C) || \
60  (PARTNO == AT25DF011) || \
61  (PARTNO == AT25DF021A) || \
62  (PARTNO == AT25DF041B) || \
63  (PARTNO == AT25XV021A) || \
64  (PARTNO == AT25XV041B) || \
65  (ALL == 1)
66 
68 
69 /******************************************
70  *
71  *
72  * Fusion Commands
73  *
74  *
75  ******************************************/
76 
82 void fusionWaitOnReady();
83 
90 void fusionGlobalProtect();
91 
99 
114 void fusionReadArray(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes);
115 
129 void fusionReadArrayLF(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes);
130 
144 void fusionDualOutputRead(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes);
145 
154 void fusionPageErase(uint32_t address);
155 
164 void fusionBlockErase4K(uint32_t address);
165 
172 void fusionChipErase();
173 
189 void fusionProgramArray(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes);
190 
197 void fusionWriteEnable();
198 
205 void fusionWriteDisable();
206 
216 void fusionReadSR(uint8_t *rxBuffer);
217 
226 void fusionWriteSRB1(uint8_t data);
227 
236 void fusionWriteSRB2(uint8_t data);
237 
245 void fusionReset();
246 
256 void fusionReadMID(uint8_t *rxBuffer);
257 
265 void fusionDeepPowerDown();
266 
274 
282 void fusionUDPDMode();
283 #endif
284 
285 #if (PARTNO == AT25XE021A) || \
286  (PARTNO == AT25XE041B) || \
287  (PARTNO == AT25DF021A) || \
288  (PARTNO == AT25DF041B) || \
289  (PARTNO == AT25XV021A) || \
290  (PARTNO == AT25XV041B) || \
291  (ALL == 1)
292 
301 void fusionSequentialProgramMode(uint8_t txBuffer);
302 
316 void fusionDualInputProgram(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes);
317 
326 void fusionProtectSector(uint32_t address);
327 
335 void fusionUnprotectSector(uint32_t address);
336 
348 void fusionReadSectorProtectionRegisters(uint32_t address, uint8_t *rxBuffer);
349 
360 void fusionSequentialProgramModeEnable(uint32_t address, uint8_t txBuffer);
361 
367 void fusionHardwareReset();
368 
369 #endif
370 
371 #endif /* DATAFLASH_H_ */
void fusionReadSectorProtectionRegisters(uint32_t address, uint8_t *rxBuffer)
OPCODE: 0x3C Reads the sector protection register at address &#39;address.&#39; 0x00 -> Sector is unprotect...
Definition: fusion.c:326
void fusionReadSR(uint8_t *rxBuffer)
OPCODE: 0x05 Reads the value in the status register (bytes 1 and 2).
Definition: fusion.c:187
void fusionBlockErase4K(uint32_t address)
OPCODE: 0x20 Erases a block of data (4 KBytes) starting from page address &#39;address.&#39;.
Definition: fusion.c:130
void fusionReadMID(uint8_t *rxBuffer)
OPCODE: 0x9F Reads the manufacturer ID and stores the data in rxBuffer.
Definition: fusion.c:230
void fusionPageErase(uint32_t address)
OPCODE: 0x81 Erases a page of data (256 Bytes) starting from page address &#39;address.&#39;.
Definition: fusion.c:120
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().
Definition: fusion.c:78
void fusionReset()
OPCODE: 0xF0 Resets the flash device for immediately, regardless of what current operation is being...
Definition: fusion.c:219
void fusionHardwareReset()
Performs a hardware (JEDEC) reset on the device.
Definition: fusion.c:348
void fusionWriteSRB1(uint8_t data)
OPCODE: 0x01 Writes the value in data to status register byte 1.
Definition: fusion.c:197
uint8_t txFusionInternalBuffer[MAXIMUM_TX_BYTES]
Definition: fusion.c:63
void fusionProtectSector(uint32_t address)
OPCODE: 0x36 Sends opcode to disable writing.
Definition: fusion.c:306
void fusionDualOutputRead(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x3B Reads &#39;txNumBytes&#39; bytes of data in Dual Output Mode starting at &#39;address&#39; using both ...
Definition: fusion.c:110
void fusionSequentialProgramModeEnable(uint32_t address, uint8_t txBuffer)
OPCODE: 0xAD Enables sequential program mode and loads the starting address into the device...
Definition: fusion.c:336
void fusionSequentialProgramMode(uint8_t txBuffer)
OPCODE: 0xAD Sends the byte in txBuffer to the flash device for programming. This command should on...
Definition: fusion.c:278
void fusionDeepPowerDown()
OPCODE: 0xB9 Enters the device into Deep Power Down mode. fusionResumeFromDeepPowerDown() will wake...
Definition: fusion.c:240
Definitions for opcodes.
#define MAXIMUM_TX_BYTES
Definition: cmd_defs.h:46
void fusionWaitOnReady()
: Wait while Read/Busy Status bit in SRB is 1 (device is busy).
Definition: fusion.c:67
void fusionReadArrayLF(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x03 Reads rxNumBytes starting from location &#39;address&#39; and stores the data in the byte arra...
Definition: fusion.c:100
void fusionUDPDMode()
OPCODE: 0x79 Sends the device into Ultra Deep Power Down Mode. Exit UDPD Mode by toggling CS with c...
Definition: fusion.c:260
void fusionWriteEnable()
OPCODE: 0x06 Sends opcode to enable writing.
Definition: fusion.c:167
Declarations of spi_driver functions.
void fusionResumeFromDeepPowerDown()
OPCODE: 0xAB Wakes the device up from Deep Power Down mode (fusionDeepPowerDown()).
Definition: fusion.c:250
void fusionWriteDisable()
OPCODE: 0x04 Sends opcode to disable writing.
Definition: fusion.c:177
void fusionProgramArray(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0x02 Programs &#39;txNumBytes&#39; bytes of data starting at the address indicated by address...
Definition: fusion.c:150
void fusionReadArray(uint32_t address, uint8_t *rxBuffer, uint32_t rxNumBytes)
OPCODE: 0x0B Reads rxNumBytes starting from location &#39;address&#39; and stores the data in the byte arra...
Definition: fusion.c:90
void fusionWriteSRB2(uint8_t data)
OPCODE: 0x31 Writes the value in data to status register byte 2.
Definition: fusion.c:208
Declarations of helper functions.
void fusionDualInputProgram(uint32_t address, uint8_t *txBuffer, uint32_t txNumBytes)
OPCODE: 0xA2 Programs &#39;txNumBytes&#39; bytes of data in Dual Input Mode starting at &#39;address&#39; using bot...
Definition: fusion.c:289
void fusionChipErase()
OPCODE: 0x60 Erases the entire chip by setting all bits.
Definition: fusion.c:140
void fusionUnprotectSector(uint32_t address)
OPCODE: 0x39 Sends opcode to enable writing.
Definition: fusion.c:316
void fusionGlobalUnprotect()
Unprotects all sectors by issuing a WE, then write of 0x00 to status register byte 1...
Definition: fusion.c:84