BSP library for DISCO-STM32F746NG board. Added support for on-board QSPI Flash memory MICRO N25Q128A. Ported from library BSP_DISCO_L476VG.

Dependents:   DISCO-F746NG_QSPI

Fork of BSP_DISCO_F746NG by ST

Committer:
capsavon
Date:
Sun Nov 15 15:30:42 2015 +0000
Revision:
3:99a7fc4794c7
Parent:
1:6c23a7cf204c
Cleaned useless commentaries (initial library values).; Tested with lower prescaler values -> doesn't work, keeping 3.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
capsavon 1:6c23a7cf204c 1 /**
capsavon 1:6c23a7cf204c 2 ******************************************************************************
capsavon 1:6c23a7cf204c 3 * @file n25q128a.h
capsavon 1:6c23a7cf204c 4 * @author MCD Application Team
capsavon 1:6c23a7cf204c 5 * @version V1.0.0
capsavon 1:6c23a7cf204c 6 * @date 29-May-2015
capsavon 1:6c23a7cf204c 7 * @brief This file contains all the description of the N25Q128A QSPI memory.
capsavon 1:6c23a7cf204c 8 ******************************************************************************
capsavon 1:6c23a7cf204c 9 * @attention
capsavon 1:6c23a7cf204c 10 *
capsavon 1:6c23a7cf204c 11 * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
capsavon 1:6c23a7cf204c 12 *
capsavon 1:6c23a7cf204c 13 * Redistribution and use in source and binary forms, with or without modification,
capsavon 1:6c23a7cf204c 14 * are permitted provided that the following conditions are met:
capsavon 1:6c23a7cf204c 15 * 1. Redistributions of source code must retain the above copyright notice,
capsavon 1:6c23a7cf204c 16 * this list of conditions and the following disclaimer.
capsavon 1:6c23a7cf204c 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
capsavon 1:6c23a7cf204c 18 * this list of conditions and the following disclaimer in the documentation
capsavon 1:6c23a7cf204c 19 * and/or other materials provided with the distribution.
capsavon 1:6c23a7cf204c 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
capsavon 1:6c23a7cf204c 21 * may be used to endorse or promote products derived from this software
capsavon 1:6c23a7cf204c 22 * without specific prior written permission.
capsavon 1:6c23a7cf204c 23 *
capsavon 1:6c23a7cf204c 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
capsavon 1:6c23a7cf204c 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
capsavon 1:6c23a7cf204c 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
capsavon 1:6c23a7cf204c 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
capsavon 1:6c23a7cf204c 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
capsavon 1:6c23a7cf204c 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
capsavon 1:6c23a7cf204c 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
capsavon 1:6c23a7cf204c 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
capsavon 1:6c23a7cf204c 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
capsavon 1:6c23a7cf204c 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
capsavon 1:6c23a7cf204c 34 *
capsavon 1:6c23a7cf204c 35 ******************************************************************************
capsavon 1:6c23a7cf204c 36 */
capsavon 1:6c23a7cf204c 37
capsavon 1:6c23a7cf204c 38 /* Define to prevent recursive inclusion -------------------------------------*/
capsavon 1:6c23a7cf204c 39 #ifndef __N25Q128A_H
capsavon 1:6c23a7cf204c 40 #define __N25Q128A_H
capsavon 1:6c23a7cf204c 41
capsavon 1:6c23a7cf204c 42 #ifdef __cplusplus
capsavon 1:6c23a7cf204c 43 extern "C" {
capsavon 1:6c23a7cf204c 44 #endif
capsavon 1:6c23a7cf204c 45
capsavon 1:6c23a7cf204c 46 /* Includes ------------------------------------------------------------------*/
capsavon 1:6c23a7cf204c 47
capsavon 1:6c23a7cf204c 48 /** @addtogroup BSP
capsavon 1:6c23a7cf204c 49 * @{
capsavon 1:6c23a7cf204c 50 */
capsavon 1:6c23a7cf204c 51
capsavon 1:6c23a7cf204c 52 /** @addtogroup Components
capsavon 1:6c23a7cf204c 53 * @{
capsavon 1:6c23a7cf204c 54 */
capsavon 1:6c23a7cf204c 55
capsavon 1:6c23a7cf204c 56 /** @addtogroup n25q128a
capsavon 1:6c23a7cf204c 57 * @{
capsavon 1:6c23a7cf204c 58 */
capsavon 1:6c23a7cf204c 59
capsavon 1:6c23a7cf204c 60 /** @defgroup N25Q128A_Exported_Types
capsavon 1:6c23a7cf204c 61 * @{
capsavon 1:6c23a7cf204c 62 */
capsavon 1:6c23a7cf204c 63
capsavon 1:6c23a7cf204c 64 /**
capsavon 1:6c23a7cf204c 65 * @}
capsavon 1:6c23a7cf204c 66 */
capsavon 1:6c23a7cf204c 67
capsavon 1:6c23a7cf204c 68 /** @defgroup N25Q128A_Exported_Constants
capsavon 1:6c23a7cf204c 69 * @{
capsavon 1:6c23a7cf204c 70 */
capsavon 1:6c23a7cf204c 71
capsavon 1:6c23a7cf204c 72 /**
capsavon 1:6c23a7cf204c 73 * @brief N25Q128A Configuration
capsavon 1:6c23a7cf204c 74 */
capsavon 1:6c23a7cf204c 75 #define N25Q128A_FLASH_SIZE 0x1000000 /* 128 MBits => 16MBytes */
capsavon 1:6c23a7cf204c 76 #define N25Q128A_SECTOR_SIZE 0x10000 /* 256 sectors of 64KBytes */
capsavon 1:6c23a7cf204c 77 #define N25Q128A_SUBSECTOR_SIZE 0x1000 /* 4096 subsectors of 4kBytes */
capsavon 1:6c23a7cf204c 78 #define N25Q128A_PAGE_SIZE 0x100 /* 65536 pages of 256 bytes */
capsavon 1:6c23a7cf204c 79
capsavon 1:6c23a7cf204c 80 #define N25Q128A_DUMMY_CYCLES_READ 8
capsavon 1:6c23a7cf204c 81 #define N25Q128A_DUMMY_CYCLES_READ_QUAD 10
capsavon 1:6c23a7cf204c 82
capsavon 1:6c23a7cf204c 83 #define N25Q128A_BULK_ERASE_MAX_TIME 250000
capsavon 1:6c23a7cf204c 84 #define N25Q128A_SECTOR_ERASE_MAX_TIME 3000
capsavon 1:6c23a7cf204c 85 #define N25Q128A_SUBSECTOR_ERASE_MAX_TIME 800
capsavon 1:6c23a7cf204c 86
capsavon 1:6c23a7cf204c 87 /**
capsavon 1:6c23a7cf204c 88 * @brief N25Q128A Commands
capsavon 1:6c23a7cf204c 89 */
capsavon 1:6c23a7cf204c 90 /* Reset Operations */
capsavon 1:6c23a7cf204c 91 #define RESET_ENABLE_CMD 0x66
capsavon 1:6c23a7cf204c 92 #define RESET_MEMORY_CMD 0x99
capsavon 1:6c23a7cf204c 93
capsavon 1:6c23a7cf204c 94 /* Identification Operations */
capsavon 1:6c23a7cf204c 95 #define READ_ID_CMD 0x9E
capsavon 1:6c23a7cf204c 96 #define READ_ID_CMD2 0x9F
capsavon 1:6c23a7cf204c 97 #define MULTIPLE_IO_READ_ID_CMD 0xAF
capsavon 1:6c23a7cf204c 98 #define READ_SERIAL_FLASH_DISCO_PARAM_CMD 0x5A
capsavon 1:6c23a7cf204c 99
capsavon 1:6c23a7cf204c 100 /* Read Operations */
capsavon 1:6c23a7cf204c 101 #define READ_CMD 0x03
capsavon 1:6c23a7cf204c 102 #define FAST_READ_CMD 0x0B
capsavon 1:6c23a7cf204c 103 #define DUAL_OUT_FAST_READ_CMD 0x3B
capsavon 1:6c23a7cf204c 104 #define DUAL_INOUT_FAST_READ_CMD 0xBB
capsavon 1:6c23a7cf204c 105 #define QUAD_OUT_FAST_READ_CMD 0x6B
capsavon 1:6c23a7cf204c 106 #define QUAD_INOUT_FAST_READ_CMD 0xEB
capsavon 1:6c23a7cf204c 107
capsavon 1:6c23a7cf204c 108 /* Write Operations */
capsavon 1:6c23a7cf204c 109 #define WRITE_ENABLE_CMD 0x06
capsavon 1:6c23a7cf204c 110 #define WRITE_DISABLE_CMD 0x04
capsavon 1:6c23a7cf204c 111
capsavon 1:6c23a7cf204c 112 /* Register Operations */
capsavon 1:6c23a7cf204c 113 #define READ_STATUS_REG_CMD 0x05
capsavon 1:6c23a7cf204c 114 #define WRITE_STATUS_REG_CMD 0x01
capsavon 1:6c23a7cf204c 115
capsavon 1:6c23a7cf204c 116 #define READ_LOCK_REG_CMD 0xE8
capsavon 1:6c23a7cf204c 117 #define WRITE_LOCK_REG_CMD 0xE5
capsavon 1:6c23a7cf204c 118
capsavon 1:6c23a7cf204c 119 #define READ_FLAG_STATUS_REG_CMD 0x70
capsavon 1:6c23a7cf204c 120 #define CLEAR_FLAG_STATUS_REG_CMD 0x50
capsavon 1:6c23a7cf204c 121
capsavon 1:6c23a7cf204c 122 #define READ_NONVOL_CFG_REG_CMD 0xB5
capsavon 1:6c23a7cf204c 123 #define WRITE_NONVOL_CFG_REG_CMD 0xB1
capsavon 1:6c23a7cf204c 124
capsavon 1:6c23a7cf204c 125 #define READ_VOL_CFG_REG_CMD 0x85
capsavon 1:6c23a7cf204c 126 #define WRITE_VOL_CFG_REG_CMD 0x81
capsavon 1:6c23a7cf204c 127
capsavon 1:6c23a7cf204c 128 #define READ_ENHANCED_VOL_CFG_REG_CMD 0x65
capsavon 1:6c23a7cf204c 129 #define WRITE_ENHANCED_VOL_CFG_REG_CMD 0x61
capsavon 1:6c23a7cf204c 130
capsavon 1:6c23a7cf204c 131 /* Program Operations */
capsavon 1:6c23a7cf204c 132 #define PAGE_PROG_CMD 0x02
capsavon 1:6c23a7cf204c 133 #define DUAL_IN_FAST_PROG_CMD 0xA2
capsavon 1:6c23a7cf204c 134 #define EXT_DUAL_IN_FAST_PROG_CMD 0xD2
capsavon 1:6c23a7cf204c 135 #define QUAD_IN_FAST_PROG_CMD 0x32
capsavon 1:6c23a7cf204c 136 #define EXT_QUAD_IN_FAST_PROG_CMD 0x12
capsavon 1:6c23a7cf204c 137
capsavon 1:6c23a7cf204c 138 /* Erase Operations */
capsavon 1:6c23a7cf204c 139 #define SUBSECTOR_ERASE_CMD 0x20
capsavon 1:6c23a7cf204c 140 #define SECTOR_ERASE_CMD 0xD8
capsavon 1:6c23a7cf204c 141 #define BULK_ERASE_CMD 0xC7
capsavon 1:6c23a7cf204c 142
capsavon 1:6c23a7cf204c 143 #define PROG_ERASE_RESUME_CMD 0x7A
capsavon 1:6c23a7cf204c 144 #define PROG_ERASE_SUSPEND_CMD 0x75
capsavon 1:6c23a7cf204c 145
capsavon 1:6c23a7cf204c 146 /* One-Time Programmable Operations */
capsavon 1:6c23a7cf204c 147 #define READ_OTP_ARRAY_CMD 0x4B
capsavon 1:6c23a7cf204c 148 #define PROG_OTP_ARRAY_CMD 0x42
capsavon 1:6c23a7cf204c 149
capsavon 1:6c23a7cf204c 150 /**
capsavon 1:6c23a7cf204c 151 * @brief N25Q128A Registers
capsavon 1:6c23a7cf204c 152 */
capsavon 1:6c23a7cf204c 153 /* Status Register */
capsavon 1:6c23a7cf204c 154 #define N25Q128A_SR_WIP ((uint8_t)0x01) /*!< Write in progress */
capsavon 1:6c23a7cf204c 155 #define N25Q128A_SR_WREN ((uint8_t)0x02) /*!< Write enable latch */
capsavon 1:6c23a7cf204c 156 #define N25Q128A_SR_BLOCKPR ((uint8_t)0x5C) /*!< Block protected against program and erase operations */
capsavon 1:6c23a7cf204c 157 #define N25Q128A_SR_PRBOTTOM ((uint8_t)0x20) /*!< Protected memory area defined by BLOCKPR starts from top or bottom */
capsavon 1:6c23a7cf204c 158 #define N25Q128A_SR_SRWREN ((uint8_t)0x80) /*!< Status register write enable/disable */
capsavon 1:6c23a7cf204c 159
capsavon 1:6c23a7cf204c 160 /* Nonvolatile Configuration Register */
capsavon 1:6c23a7cf204c 161 #define N25Q128A_NVCR_LOCK ((uint16_t)0x0001) /*!< Lock nonvolatile configuration register */
capsavon 1:6c23a7cf204c 162 #define N25Q128A_NVCR_DUAL ((uint16_t)0x0004) /*!< Dual I/O protocol */
capsavon 1:6c23a7cf204c 163 #define N25Q128A_NVCR_QUAB ((uint16_t)0x0008) /*!< Quad I/O protocol */
capsavon 1:6c23a7cf204c 164 #define N25Q128A_NVCR_RH ((uint16_t)0x0010) /*!< Reset/hold */
capsavon 1:6c23a7cf204c 165 #define N25Q128A_NVCR_ODS ((uint16_t)0x01C0) /*!< Output driver strength */
capsavon 1:6c23a7cf204c 166 #define N25Q128A_NVCR_XIP ((uint16_t)0x0E00) /*!< XIP mode at power-on reset */
capsavon 1:6c23a7cf204c 167 #define N25Q128A_NVCR_NB_DUMMY ((uint16_t)0xF000) /*!< Number of dummy clock cycles */
capsavon 1:6c23a7cf204c 168
capsavon 1:6c23a7cf204c 169 /* Volatile Configuration Register */
capsavon 1:6c23a7cf204c 170 #define N25Q128A_VCR_WRAP ((uint8_t)0x03) /*!< Wrap */
capsavon 1:6c23a7cf204c 171 #define N25Q128A_VCR_XIP ((uint8_t)0x08) /*!< XIP */
capsavon 1:6c23a7cf204c 172 #define N25Q128A_VCR_NB_DUMMY ((uint8_t)0xF0) /*!< Number of dummy clock cycles */
capsavon 1:6c23a7cf204c 173
capsavon 1:6c23a7cf204c 174 /* Enhanced Volatile Configuration Register */
capsavon 1:6c23a7cf204c 175 #define N25Q128A_EVCR_ODS ((uint8_t)0x07) /*!< Output driver strength */
capsavon 1:6c23a7cf204c 176 #define N25Q128A_EVCR_VPPA ((uint8_t)0x08) /*!< Vpp accelerator */
capsavon 1:6c23a7cf204c 177 #define N25Q128A_EVCR_RH ((uint8_t)0x10) /*!< Reset/hold */
capsavon 1:6c23a7cf204c 178 #define N25Q128A_EVCR_DUAL ((uint8_t)0x40) /*!< Dual I/O protocol */
capsavon 1:6c23a7cf204c 179 #define N25Q128A_EVCR_QUAD ((uint8_t)0x80) /*!< Quad I/O protocol */
capsavon 1:6c23a7cf204c 180
capsavon 1:6c23a7cf204c 181 /* Flag Status Register */
capsavon 1:6c23a7cf204c 182 #define N25Q128A_FSR_PRERR ((uint8_t)0x02) /*!< Protection error */
capsavon 1:6c23a7cf204c 183 #define N25Q128A_FSR_PGSUS ((uint8_t)0x04) /*!< Program operation suspended */
capsavon 1:6c23a7cf204c 184 #define N25Q128A_FSR_VPPERR ((uint8_t)0x08) /*!< Invalid voltage during program or erase */
capsavon 1:6c23a7cf204c 185 #define N25Q128A_FSR_PGERR ((uint8_t)0x10) /*!< Program error */
capsavon 1:6c23a7cf204c 186 #define N25Q128A_FSR_ERERR ((uint8_t)0x20) /*!< Erase error */
capsavon 1:6c23a7cf204c 187 #define N25Q128A_FSR_ERSUS ((uint8_t)0x40) /*!< Erase operation suspended */
capsavon 1:6c23a7cf204c 188 #define N25Q128A_FSR_READY ((uint8_t)0x80) /*!< Ready or command in progress */
capsavon 1:6c23a7cf204c 189
capsavon 1:6c23a7cf204c 190 /**
capsavon 1:6c23a7cf204c 191 * @}
capsavon 1:6c23a7cf204c 192 */
capsavon 1:6c23a7cf204c 193
capsavon 1:6c23a7cf204c 194 /** @defgroup N25Q128A_Exported_Functions
capsavon 1:6c23a7cf204c 195 * @{
capsavon 1:6c23a7cf204c 196 */
capsavon 1:6c23a7cf204c 197 /**
capsavon 1:6c23a7cf204c 198 * @}
capsavon 1:6c23a7cf204c 199 */
capsavon 1:6c23a7cf204c 200
capsavon 1:6c23a7cf204c 201 /**
capsavon 1:6c23a7cf204c 202 * @}
capsavon 1:6c23a7cf204c 203 */
capsavon 1:6c23a7cf204c 204
capsavon 1:6c23a7cf204c 205 /**
capsavon 1:6c23a7cf204c 206 * @}
capsavon 1:6c23a7cf204c 207 */
capsavon 1:6c23a7cf204c 208
capsavon 1:6c23a7cf204c 209 /**
capsavon 1:6c23a7cf204c 210 * @}
capsavon 1:6c23a7cf204c 211 */
capsavon 1:6c23a7cf204c 212
capsavon 1:6c23a7cf204c 213 #ifdef __cplusplus
capsavon 1:6c23a7cf204c 214 }
capsavon 1:6c23a7cf204c 215 #endif
capsavon 1:6c23a7cf204c 216
capsavon 1:6c23a7cf204c 217 #endif /* __N25Q128A_H */
capsavon 1:6c23a7cf204c 218
capsavon 1:6c23a7cf204c 219 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/