Class to drive the QSPI external memory (N25Q128A device) present on DISCO_L476VG board.

Committer:
bcostm
Date:
Thu Sep 24 07:04:36 2015 +0000
Revision:
0:ea63cbd848a3
Initial version.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:ea63cbd848a3 1 /* Copyright (c) 2010-2011 mbed.org, MIT License
bcostm 0:ea63cbd848a3 2 *
bcostm 0:ea63cbd848a3 3 * Permission is hereby granted, free of charge, to any person obtaining a copy of this software
bcostm 0:ea63cbd848a3 4 * and associated documentation files (the "Software"), to deal in the Software without
bcostm 0:ea63cbd848a3 5 * restriction, including without limitation the rights to use, copy, modify, merge, publish,
bcostm 0:ea63cbd848a3 6 * distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the
bcostm 0:ea63cbd848a3 7 * Software is furnished to do so, subject to the following conditions:
bcostm 0:ea63cbd848a3 8 *
bcostm 0:ea63cbd848a3 9 * The above copyright notice and this permission notice shall be included in all copies or
bcostm 0:ea63cbd848a3 10 * substantial portions of the Software.
bcostm 0:ea63cbd848a3 11 *
bcostm 0:ea63cbd848a3 12 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
bcostm 0:ea63cbd848a3 13 * BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
bcostm 0:ea63cbd848a3 14 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
bcostm 0:ea63cbd848a3 15 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
bcostm 0:ea63cbd848a3 16 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
bcostm 0:ea63cbd848a3 17 */
bcostm 0:ea63cbd848a3 18
bcostm 0:ea63cbd848a3 19 #ifndef __QSPI_DISCO_L476VG_H
bcostm 0:ea63cbd848a3 20 #define __QSPI_DISCO_L476VG_H
bcostm 0:ea63cbd848a3 21
bcostm 0:ea63cbd848a3 22 #ifdef TARGET_DISCO_L476VG
bcostm 0:ea63cbd848a3 23
bcostm 0:ea63cbd848a3 24 #include "mbed.h"
bcostm 0:ea63cbd848a3 25 #include "stm32l476g_discovery_qspi.h"
bcostm 0:ea63cbd848a3 26
bcostm 0:ea63cbd848a3 27 /*
bcostm 0:ea63cbd848a3 28 Class to drive the QSPI external memory (N25Q128A device)
bcostm 0:ea63cbd848a3 29 present on DISCO_L476VG board.
bcostm 0:ea63cbd848a3 30
bcostm 0:ea63cbd848a3 31 Usage:
bcostm 0:ea63cbd848a3 32
bcostm 0:ea63cbd848a3 33 */
bcostm 0:ea63cbd848a3 34 class QSPI_DISCO_L476VG
bcostm 0:ea63cbd848a3 35 {
bcostm 0:ea63cbd848a3 36
bcostm 0:ea63cbd848a3 37 public:
bcostm 0:ea63cbd848a3 38 //! Constructor
bcostm 0:ea63cbd848a3 39 QSPI_DISCO_L476VG();
bcostm 0:ea63cbd848a3 40
bcostm 0:ea63cbd848a3 41 //! Destructor
bcostm 0:ea63cbd848a3 42 ~QSPI_DISCO_L476VG();
bcostm 0:ea63cbd848a3 43
bcostm 0:ea63cbd848a3 44 /**
bcostm 0:ea63cbd848a3 45 * @brief Initializes the QSPI interface.
bcostm 0:ea63cbd848a3 46 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 47 */
bcostm 0:ea63cbd848a3 48 uint8_t Init(void);
bcostm 0:ea63cbd848a3 49
bcostm 0:ea63cbd848a3 50 /**
bcostm 0:ea63cbd848a3 51 * @brief De-Initializes the QSPI interface.
bcostm 0:ea63cbd848a3 52 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 53 */
bcostm 0:ea63cbd848a3 54 uint8_t DeInit(void);
bcostm 0:ea63cbd848a3 55
bcostm 0:ea63cbd848a3 56 /**
bcostm 0:ea63cbd848a3 57 * @brief Reads an amount of data from the QSPI memory.
bcostm 0:ea63cbd848a3 58 * @param pData: Pointer to data to be read
bcostm 0:ea63cbd848a3 59 * @param ReadAddr: Read start address
bcostm 0:ea63cbd848a3 60 * @param Size: Size of data to read
bcostm 0:ea63cbd848a3 61 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 62 */
bcostm 0:ea63cbd848a3 63 uint8_t Read(uint8_t* pData, uint32_t ReadAddr, uint32_t Size);
bcostm 0:ea63cbd848a3 64
bcostm 0:ea63cbd848a3 65 /**
bcostm 0:ea63cbd848a3 66 * @brief Writes an amount of data to the QSPI memory.
bcostm 0:ea63cbd848a3 67 * @param pData: Pointer to data to be written
bcostm 0:ea63cbd848a3 68 * @param WriteAddr: Write start address
bcostm 0:ea63cbd848a3 69 * @param Size: Size of data to write
bcostm 0:ea63cbd848a3 70 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 71 */
bcostm 0:ea63cbd848a3 72 uint8_t Write(uint8_t* pData, uint32_t WriteAddr, uint32_t Size);
bcostm 0:ea63cbd848a3 73
bcostm 0:ea63cbd848a3 74 /**
bcostm 0:ea63cbd848a3 75 * @brief Erases the specified block of the QSPI memory.
bcostm 0:ea63cbd848a3 76 * @param BlockAddress: Block address to erase
bcostm 0:ea63cbd848a3 77 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 78 */
bcostm 0:ea63cbd848a3 79 uint8_t Erase_Block(uint32_t BlockAddress);
bcostm 0:ea63cbd848a3 80
bcostm 0:ea63cbd848a3 81 /**
bcostm 0:ea63cbd848a3 82 * @brief Erases the specified sector of the QSPI memory.
bcostm 0:ea63cbd848a3 83 * @param Sector: Sector address to erase (0 to 255);
bcostm 0:ea63cbd848a3 84 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 85 * @note This function is non blocking meaning that sector erase
bcostm 0:ea63cbd848a3 86 * operation is started but not completed when the function
bcostm 0:ea63cbd848a3 87 * returns. Application has to call GetStatus();
bcostm 0:ea63cbd848a3 88 * to know when the device is available again (i.e. erase operation
bcostm 0:ea63cbd848a3 89 * completed);.
bcostm 0:ea63cbd848a3 90 */
bcostm 0:ea63cbd848a3 91 uint8_t Erase_Sector(uint32_t Sector);
bcostm 0:ea63cbd848a3 92
bcostm 0:ea63cbd848a3 93 /**
bcostm 0:ea63cbd848a3 94 * @brief Erases the entire QSPI memory.
bcostm 0:ea63cbd848a3 95 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 96 */
bcostm 0:ea63cbd848a3 97 uint8_t Erase_Chip(void);
bcostm 0:ea63cbd848a3 98
bcostm 0:ea63cbd848a3 99 /**
bcostm 0:ea63cbd848a3 100 * @brief Reads current status of the QSPI memory.
bcostm 0:ea63cbd848a3 101 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 102 */
bcostm 0:ea63cbd848a3 103 uint8_t GetStatus(void);
bcostm 0:ea63cbd848a3 104
bcostm 0:ea63cbd848a3 105 /**
bcostm 0:ea63cbd848a3 106 * @brief Return the configuration of the QSPI memory.
bcostm 0:ea63cbd848a3 107 * @param pInfo: pointer on the configuration structure
bcostm 0:ea63cbd848a3 108 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 109 */
bcostm 0:ea63cbd848a3 110 uint8_t GetInfo(QSPI_Info* pInfo);
bcostm 0:ea63cbd848a3 111
bcostm 0:ea63cbd848a3 112 /**
bcostm 0:ea63cbd848a3 113 * @brief Configure the QSPI in memory-mapped mode
bcostm 0:ea63cbd848a3 114 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 115 */
bcostm 0:ea63cbd848a3 116 uint8_t EnableMemoryMappedMode(void);
bcostm 0:ea63cbd848a3 117
bcostm 0:ea63cbd848a3 118 /**
bcostm 0:ea63cbd848a3 119 * @brief This function suspends an ongoing erase command.
bcostm 0:ea63cbd848a3 120 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 121 */
bcostm 0:ea63cbd848a3 122 uint8_t SuspendErase(void);
bcostm 0:ea63cbd848a3 123
bcostm 0:ea63cbd848a3 124 /**
bcostm 0:ea63cbd848a3 125 * @brief This function resumes a paused erase command.
bcostm 0:ea63cbd848a3 126 * @retval QSPI memory status
bcostm 0:ea63cbd848a3 127 */
bcostm 0:ea63cbd848a3 128 uint8_t ResumeErase(void);
bcostm 0:ea63cbd848a3 129
bcostm 0:ea63cbd848a3 130 private:
bcostm 0:ea63cbd848a3 131
bcostm 0:ea63cbd848a3 132 };
bcostm 0:ea63cbd848a3 133
bcostm 0:ea63cbd848a3 134 #else
bcostm 0:ea63cbd848a3 135 #error "This class must be used with DISCO_L476VG board only."
bcostm 0:ea63cbd848a3 136 #endif // TARGET_DISCO_L476VG
bcostm 0:ea63cbd848a3 137
bcostm 0:ea63cbd848a3 138 #endif