1 /* 2 * Copyright (c) 2022-2022 Huawei Device Co., Ltd. All rights reserved. 3 * 4 * Redistribution and use in source and binary forms, with or without modification, 5 * are permitted provided that the following conditions are met: 6 * 7 * 1. Redistributions of source code must retain the above copyright notice, this list of 8 * conditions and the following disclaimer. 9 * 10 * 2. Redistributions in binary form must reproduce the above copyright notice, this list 11 * of conditions and the following disclaimer in the documentation and/or other materials 12 * provided with the distribution. 13 * 14 * 3. Neither the name of the copyright holder nor the names of its contributors may be used 15 * to endorse or promote products derived from this software without specific prior written 16 * permission. 17 * 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 20 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR 22 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 23 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 24 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; 25 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, 26 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR 27 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF 28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 #ifndef __W25QXX_H 32 #define __W25QXX_H 33 34 #include "system.h" 35 36 #define W25Q128 0XEF17 37 38 #define W25X_CS PBout(14) 39 40 #define W25X_WRITEENABLE 0x06 41 #define W25X_WRITEDISABLE 0x04 42 #define W25X_READSTATUSREG 0x05 43 #define W25X_WRITESTATUSREG 0x01 44 #define W25X_READDATA 0x03 45 #define W25X_FASTREADDATA 0x0B 46 #define W25X_FASTREADDUAL 0x3B 47 #define W25X_PAGEPROGRAM 0x02 48 #define W25X_BLOCKERASE 0xD8 49 #define W25X_SECTORERASE 0x20 50 #define W25X_CHIPERASE 0xC7 51 #define W25X_POWERDOWN 0xB9 52 #define W25X_RELEASEPOWERDOWN 0xAB 53 #define W25X_DEVICEID 0xAB 54 #define W25X_MANUFACTDEVICEID 0x90 55 #define W25X_JEDECDEVICEID 0x9F 56 57 extern u16 W25QXX_TYPE; 58 59 void W25qxxInit(void); 60 u16 W25qxxReadID(void); 61 u8 W25qxxReadSR(void); 62 void W25qxxWriteSR(u8 sr); 63 void W25qxxWriteEnable(void); 64 void W25qxxWriteDisable(void); 65 void W25qxxWriteNoCheck(u8 *pBuffer, u32 writeAddr, u16 numByteToWrite); 66 void W25qxxRead(u8 *pBuffer, u32 readAddr, u16 numByteToRead); 67 void W25qxxWrite(u8 *pBuffer, u32 writeAddr, u16 numByteToWrite); 68 void W25qxxEraseChip(void); 69 void W25qxxEraseSector(u32 dstAddr); 70 void W25qxxWaitBusy(void); 71 void W25qxxPowerDown(void); 72 void W25qxxWakeup(void); 73 74 #endif 75