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.
ProfilingBlockDevice.cpp
00001 /* mbed Microcontroller Library 00002 * Copyright (c) 2017 ARM Limited 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 "ProfilingBlockDevice.h" 00018 00019 00020 ProfilingBlockDevice::ProfilingBlockDevice(BlockDevice *bd) 00021 : _bd(bd) 00022 , _read_count(0) 00023 , _program_count(0) 00024 , _erase_count(0) 00025 { 00026 } 00027 00028 int ProfilingBlockDevice::init() 00029 { 00030 return _bd->init(); 00031 } 00032 00033 int ProfilingBlockDevice::deinit() 00034 { 00035 return _bd->deinit(); 00036 } 00037 00038 int ProfilingBlockDevice::sync() 00039 { 00040 return _bd->sync(); 00041 } 00042 00043 int ProfilingBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size) 00044 { 00045 int err = _bd->read(b, addr, size); 00046 if (!err) { 00047 _read_count += size; 00048 } 00049 return err; 00050 } 00051 00052 int ProfilingBlockDevice::program(const void *b, bd_addr_t addr, bd_size_t size) 00053 { 00054 int err = _bd->program(b, addr, size); 00055 if (!err) { 00056 _program_count += size; 00057 } 00058 return err; 00059 } 00060 00061 int ProfilingBlockDevice::erase(bd_addr_t addr, bd_size_t size) 00062 { 00063 int err = _bd->erase(addr, size); 00064 if (!err) { 00065 _erase_count += size; 00066 } 00067 return err; 00068 } 00069 00070 bd_size_t ProfilingBlockDevice::get_read_size() const 00071 { 00072 return _bd->get_read_size(); 00073 } 00074 00075 bd_size_t ProfilingBlockDevice::get_program_size() const 00076 { 00077 return _bd->get_program_size(); 00078 } 00079 00080 bd_size_t ProfilingBlockDevice::get_erase_size() const 00081 { 00082 return _bd->get_erase_size(); 00083 } 00084 00085 bd_size_t ProfilingBlockDevice::get_erase_size(bd_addr_t addr) const 00086 { 00087 return _bd->get_erase_size(addr); 00088 } 00089 00090 int ProfilingBlockDevice::get_erase_value() const 00091 { 00092 return _bd->get_erase_value(); 00093 } 00094 00095 bd_size_t ProfilingBlockDevice::size() const 00096 { 00097 return _bd->size(); 00098 } 00099 00100 void ProfilingBlockDevice::reset() 00101 { 00102 _read_count = 0; 00103 _program_count = 0; 00104 _erase_count = 0; 00105 } 00106 00107 bd_size_t ProfilingBlockDevice::get_read_count() const 00108 { 00109 return _read_count; 00110 } 00111 00112 bd_size_t ProfilingBlockDevice::get_program_count() const 00113 { 00114 return _program_count; 00115 } 00116 00117 bd_size_t ProfilingBlockDevice::get_erase_count() const 00118 { 00119 return _erase_count; 00120 }
Generated on Tue Jul 12 2022 14:24:32 by
