1 /* 2 * Copyright (c) 2022 Winner Microelectronics Co., Ltd. All rights reserved. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 /** 17 * @file wm_fls_gd25qxx.h 18 * 19 * @brief wm gd25qxx flash driver 20 * 21 * @author dave 22 * 23 * @copyright (c) 2015 Winner Microelectronics Co., Ltd. 24 */ 25 26 #ifndef TLS_EXSPIFLS_H 27 #define TLS_EXSPIFLS_H 28 29 #define SPI_SCLK (10000000) /** 10MHz. */ 30 #define FLASH_TOTAL_SIZE (1024*1024) 31 #define PAGE_SIZE 256 32 #define PROGRAM_SIZE 256 33 #define PAGE_ADDR_OFFSET 8 34 #define SECTOR_SIZE 4096 35 36 /** 37 * command code define. 38 */ 39 #define EXSPIFLASH_WRITE_ENABLE (0x06) /** Global write enable */ 40 #define EXSPIFLASH_WRITE_DISABLE (0x04) /** Global write disable */ 41 #define EXSPIFLASH_READ_SR1 (0x05) /** Read flash status register s0~s7 */ 42 #define EXSPIFLASH_READ_SR2 (0x35) /** Read flash status register s8~s15 */ 43 #define EXSPIFLASH_WRITE_SR (0x01) /** Write flash status register s0~s15 */ 44 #define EXSPIFLASH_PAGE_PROGRAM (0x02) /** program one page */ 45 #define EXSPIFLASH_DATA_READ (0x03) /** read data from specified address */ 46 #define EXSPIFLASH_DATA_FAST_READ (0x0b) /** fast read data from specified address */ 47 #define EXSPIFLASH_SECTOR_ERASE (0x20) /** Sector erase */ 48 #define EXSPIFLASH_BLOCK32_ERASE (0x52) /** 32KB Block erase(128 pages) */ 49 #define EXSPIFLASH_BLOCK64_ERASE (0xd8) /** 64kb Block erase(256 pages) */ 50 #define EXSPIFLASH_CHIP_ERASE (0xc7) /** Chip erase */ 51 #define EXSPIFLASH_FLASH_DEVICEID (0x90) /** Read flash manufacturer/device ID */ 52 #define EXSPIFLASH_FLASH_ID (0x9f) /** Read flash ID */ 53 54 #define FLASH_STATUS_BUSY (1 << 0) 55 #define FLASH_STATUS_WEL (1 << 1) 56 57 /** 58 * @brief This function is used to install gd25qxx driver. 59 * 60 * @param[in] None 61 * 62 * @retval TLS_FLS_STATUS_OK if write flash success 63 * @retval TLS_FLS_STATUS_EPERM if flash struct point is null 64 * @retval TLS_FLS_STATUS_ENODRV if flash driver is not installed 65 * @retval TLS_FLS_STATUS_EINVAL if argument is invalid 66 * @retval TLS_FLS_STATUS_EIO if io error 67 * @retval TLS_FLS_STATUS_EEXIST if driver is already existed 68 * 69 * @note None 70 */ 71 int tls_spifls_drv_install(void); 72 73 #endif /* TLS_FLS_GD25QXX_H */ 74