1 /***************************************************************************//** 2 * \file cyhal_flash.h 3 * 4 * \brief 5 * OBSOLETED: DO NOT USE FLASH APIs IN THE NEW DESIGN. 6 * Provides a high level interface for interacting with the Infineon Flash memory. 7 * This interface abstracts out the chip specific details. If any chip specific 8 * functionality is necessary, or performance is critical the low level functions 9 * can be used directly. 10 * 11 ******************************************************************************** 12 * \copyright 13 * Copyright 2018-2022 Cypress Semiconductor Corporation (an Infineon company) or 14 * an affiliate of Cypress Semiconductor Corporation 15 * 16 * SPDX-License-Identifier: Apache-2.0 17 * 18 * Licensed under the Apache License, Version 2.0 (the "License"); 19 * you may not use this file except in compliance with the License. 20 * You may obtain a copy of the License at 21 * 22 * http://www.apache.org/licenses/LICENSE-2.0 23 * 24 * Unless required by applicable law or agreed to in writing, software 25 * distributed under the License is distributed on an "AS IS" BASIS, 26 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 27 * See the License for the specific language governing permissions and 28 * limitations under the License. 29 *******************************************************************************/ 30 31 #pragma once 32 33 #include <stdint.h> 34 #include <stdbool.h> 35 #include "cy_result.h" 36 #include "cyhal_hw_types.h" 37 38 #if (CYHAL_DRIVER_AVAILABLE_FLASH) 39 #include "cyhal_nvm.h" 40 #endif /* (CYHAL_DRIVER_AVAILABLE_FLASH) */ 41 42 #if defined(__cplusplus) 43 extern "C" { 44 #endif 45 46 47 /* Macros for BWC with Flash HAL 48 * DO NOT USE THEM IN THE NEW DESIGN 49 */ 50 51 /******************************************************************************* 52 * Defines 53 *******************************************************************************/ 54 55 /** Deprecated. Invalid argument */ 56 #define CYHAL_FLASH_RSLT_ERR_ADDRESS (CYHAL_NVM_RSLT_ERR_ADDRESS) 57 /** Deprecated. API is not supported */ 58 #define CYHAL_FLASH_RSLT_ERR_NOT_SUPPORTED (CYHAL_NVM_RSLT_ERR_NOT_SUPPORTED) 59 60 /** Deprecated. Reference to NVM object */ 61 #define cyhal_flash_t cyhal_nvm_t 62 63 /** @brief Deprecated. Information about a single block of flash memory */ 64 typedef struct 65 { 66 uint32_t start_address; //!< Start address of the memory 67 uint32_t size; //!< Size of the flash memory 68 uint32_t sector_size; //!< Sector size of the memory 69 uint32_t page_size; //!< Page size of the memory 70 uint8_t erase_value; //!< The flash erase value 71 } cyhal_flash_block_info_t; 72 73 /** @brief Deprecated. Information about all of the blocks of flash memory */ 74 typedef struct 75 { 76 uint8_t block_count; //!< The number of distinct flash blocks 77 const cyhal_flash_block_info_t *blocks; //!< Array of the distinct flash blocks 78 } cyhal_flash_info_t; 79 80 81 /******************************************************************************* 82 * Functions 83 *******************************************************************************/ 84 85 /** Deprecated. Initialize the \ref cyhal_nvm_t object for accessing flash through the HAL 86 * 87 * @param[out] obj Pointer to a flash object. The caller must allocate the memory 88 * for this object but the init function will initialize its contents. 89 * @return The status of the init request. Returns \ref CY_RSLT_SUCCESS on successful operation. 90 */ 91 #define cyhal_flash_init cyhal_nvm_init 92 93 /** Deprecated. Free resources associated with flash object through the HAL. 94 * 95 * @param[out] obj The flash object. 96 * 97 */ 98 #define cyhal_flash_free cyhal_nvm_free 99 100 /** Deprecated. Gets flash characteristics like the start address, size, erase values etc. 101 * Refer \ref cyhal_flash_info_t for more information. 102 * 103 * @param[in] obj The flash object. 104 * @param[out] info The flash characteristic info. 105 * 106 */ 107 void cyhal_flash_get_info(const cyhal_flash_t *obj, cyhal_flash_info_t *info); 108 109 /** Deprecated. Read data starting at a defined address. 110 * 111 * @param[in] obj The flash object. 112 * @param[in] address Address to begin reading from. 113 * @param[out] data The buffer to read data into. 114 * @param[in] size The number of bytes to read. 115 * @return The status of the read request. Returns \ref CY_RSLT_SUCCESS on successful operation. 116 * 117 */ 118 #define cyhal_flash_read cyhal_nvm_read 119 120 /** Deprecated. Erase one sector starting at a defined address. The address must be at sector boundary. This 121 * will block until the erase operation is complete. 122 * 123 * @see cyhal_flash_get_info() to get the flash characteristics for legal address values and 124 * the page erase size. 125 * 126 * @param[in] obj The flash object 127 * @param[in] address The sector starting address 128 * @return The status of the erase request. Returns \ref CY_RSLT_SUCCESS on successful operation. 129 * 130 */ 131 #define cyhal_flash_erase cyhal_nvm_erase 132 133 /** Deprecated. This function erases the page and writes the new data into the page starting at a defined 134 * address. The address must be at page boundary. This will block until the write operation is 135 * complete. 136 * 137 * @see cyhal_flash_get_info() to get the flash characteristics for legal address values and 138 * the page write size. The provided data buffer must be at least as large as the flash 139 * page_size. 140 * @note Generally the \p data to be written must be located in the SRAM memory region. 141 * 142 * @param[in] obj The flash object 143 * @param[in] address The page starting address 144 * @param[in] data The data to write to the flash 145 * @return The status of the write request. Returns \ref CY_RSLT_SUCCESS on successful operation. 146 * 147 */ 148 #define cyhal_flash_write cyhal_nvm_write 149 150 /** Deprecated. Program one page with given data starting at defined address. The address must be at page 151 * boundary. This will block until the write operation is complete. 152 * \note This function does not erase the page prior to writing. The page must be erased 153 * first via a separate call to erase. 154 * 155 * @see cyhal_flash_get_info() to get the flash characteristics for legal address values and 156 * the total page size. The provided data buffer must be at least as large as the flash 157 * page_size. 158 * @note Generally the \p data to be programmed must be located in the SRAM memory region. 159 * 160 * @param[in] obj The flash object 161 * @param[in] address The sector starting address 162 * @param[in] data The data buffer to be programmed 163 * @return The status of the program request. Returns \ref CY_RSLT_SUCCESS on successful operation. 164 */ 165 #define cyhal_flash_program cyhal_nvm_program 166 167 /** Deprecated. Starts an asynchronous erase of a single sector of flash. Returns immediately and reports 168 * a successful start or reason for failure. The address must be aligned on a sector boundary. 169 * 170 * @see cyhal_flash_get_info() to get the flash characteristics for legal address values and 171 * the page erase size. 172 * 173 * @param[in] obj The Flash object being operated on 174 * @param[in] address The address to start erasing from 175 * @return The status of the start_erase request. 176 * 177 */ 178 #define cyhal_flash_start_erase cyhal_nvm_start_erase 179 180 /** Deprecated. Starts an asynchronous write to a single page of flash. Returns immediately and reports 181 * a successful start or reason for failure. The address must be aligned on a page boundary. 182 * 183 * @see cyhal_flash_get_info() to get the flash characteristics for legal address values and 184 * the page write size. The provided data buffer must be at least as large as the flash 185 * page_size. 186 * @note Generally the \p data to be written must be located in the SRAM memory region. 187 * 188 * @param[in] obj The Flash object being operated on 189 * @param[in] address The address to start writing to 190 * @param[in] data The data to write to flash 191 * @return The status of the start_write request. 192 * 193 */ 194 #define cyhal_flash_start_write cyhal_nvm_start_write 195 196 /** Deprecated. Starts asynchronous programming of a single page of flash. Returns immediately and reports 197 * a successful start or reason for failure. 198 * 199 * \note Perform erase operation prior to calling this. 200 * 201 * @see cyhal_flash_get_info() to get the flash characteristics for legal address values and 202 * the total page size. The provided data buffer must be at least as large as the flash 203 * page_size. 204 * @note Generally the \p data to be programmed must be located in the SRAM memory region. 205 * 206 * @param[in] obj The Flash object being operated on 207 * @param[in] address The address to start programming 208 * @param[in] data The data to write to flash 209 * @return The status of the start_program request. Returns \ref CY_RSLT_SUCCESS on successful operation. 210 */ 211 #define cyhal_flash_start_program cyhal_nvm_start_program 212 213 /** Deprecated. Reports status of the flash operation 214 * 215 * @param[in] obj The Flash object being operated on 216 * @return true if flash operation is complete. false otherwise. 217 */ 218 #define cyhal_flash_is_operation_complete cyhal_nvm_is_operation_complete 219 220 221 #if defined(__cplusplus) 222 } 223 #endif 224 225 #ifdef CYHAL_FLASH_IMPL_HEADER 226 #include CYHAL_FLASH_IMPL_HEADER 227 #endif /* CYHAL_FLASH_IMPL_HEADER */ 228