Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: FXAS21002 FXOS8700Q
pal_plat_internalFlash.cpp
00001 /******************************************************************************* 00002 * Copyright 2016, 2017 ARM Ltd. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http://www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 *******************************************************************************/ 00016 00017 #include "mbed.h" 00018 #include "flash_api.h" 00019 #include "pal.h" 00020 #include "pal_plat_internalFlash.h" 00021 00022 #if ((!defined(PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM)) || (PAL_SIMULATOR_FLASH_OVER_FILE_SYSTEM == 0)) 00023 00024 ////////////////////////////PRIVATE/////////////////////////////////// 00025 PAL_PRIVATE FlashIAP flash; 00026 PAL_PRIVATE palStatus_t pal_platFlashErrorTranslation(int32_t status); 00027 ////////////////////////////END PRIVATE//////////////////////////////// 00028 00029 palStatus_t pal_plat_internalFlashInit(void) 00030 { 00031 uint32_t status = 0; 00032 palStatus_t ret = PAL_SUCCESS; 00033 status = flash.init(); 00034 if (status != 0) 00035 { 00036 ret = pal_platFlashErrorTranslation(status); 00037 } 00038 return ret; 00039 } 00040 00041 00042 palStatus_t pal_plat_internalFlashDeInit(void) 00043 { 00044 uint32_t status = 0; 00045 palStatus_t ret = PAL_SUCCESS; 00046 status = flash.deinit(); 00047 if (status != 0) 00048 { 00049 ret = pal_platFlashErrorTranslation(status); 00050 } 00051 return ret; 00052 } 00053 00054 00055 palStatus_t pal_plat_internalFlashWrite(const size_t size, const uint32_t address, const uint32_t * buffer) 00056 { 00057 uint32_t status = 0; 00058 palStatus_t ret = PAL_SUCCESS; 00059 00060 status = flash.program(buffer, address, size); 00061 if (status != 0) 00062 { 00063 ret = pal_platFlashErrorTranslation(status); 00064 } 00065 return ret; 00066 } 00067 00068 00069 palStatus_t pal_plat_internalFlashRead(const size_t size, const uint32_t address, uint32_t * buffer) 00070 { 00071 uint32_t status = 0; 00072 palStatus_t ret = PAL_SUCCESS; 00073 status = flash.read(buffer, address, size); 00074 if (status != 0) 00075 { 00076 ret = pal_platFlashErrorTranslation(status); 00077 } 00078 return ret; 00079 } 00080 00081 00082 palStatus_t pal_plat_internalFlashErase(uint32_t address, size_t size) 00083 { 00084 uint32_t status = 0; 00085 palStatus_t ret = PAL_SUCCESS; 00086 00087 status = flash.erase(address, size); 00088 if (status != 0) 00089 { 00090 ret = pal_platFlashErrorTranslation(status); 00091 } 00092 return ret; 00093 } 00094 00095 00096 size_t pal_plat_internalFlashGetPageSize(void) 00097 { 00098 size_t ret = flash.get_page_size(); 00099 return ret; 00100 } 00101 00102 00103 size_t pal_plat_internalFlashGetSectorSize(uint32_t address) 00104 { 00105 size_t ret = flash.get_sector_size(address); 00106 return ret; 00107 } 00108 00109 00110 PAL_PRIVATE palStatus_t pal_platFlashErrorTranslation(int32_t status) 00111 { 00112 return PAL_ERR_INTERNAL_FLASH_GENERIC_FAILURE;//ALL mbedOS error are -1 00113 } 00114 00115 #endif
Generated on Tue Jul 12 2022 20:21:01 by
