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::read(void *b, bd_addr_t addr, bd_size_t size) 00039 { 00040 int err = _bd->read(b, addr, size); 00041 if (!err) { 00042 _read_count += size; 00043 } 00044 return err; 00045 } 00046 00047 int ProfilingBlockDevice::program(const void *b, bd_addr_t addr, bd_size_t size) 00048 { 00049 int err = _bd->program(b, addr, size); 00050 if (!err) { 00051 _program_count += size; 00052 } 00053 return err; 00054 } 00055 00056 int ProfilingBlockDevice::erase(bd_addr_t addr, bd_size_t size) 00057 { 00058 int err = _bd->erase(addr, size); 00059 if (!err) { 00060 _erase_count += size; 00061 } 00062 return err; 00063 } 00064 00065 bd_size_t ProfilingBlockDevice::get_read_size() const 00066 { 00067 return _bd->get_read_size(); 00068 } 00069 00070 bd_size_t ProfilingBlockDevice::get_program_size() const 00071 { 00072 return _bd->get_program_size(); 00073 } 00074 00075 bd_size_t ProfilingBlockDevice::get_erase_size() const 00076 { 00077 return _bd->get_erase_size(); 00078 } 00079 00080 bd_size_t ProfilingBlockDevice::size() const 00081 { 00082 return _bd->size(); 00083 } 00084 00085 void ProfilingBlockDevice::reset() 00086 { 00087 _read_count = 0; 00088 _program_count = 0; 00089 _erase_count = 0; 00090 } 00091 00092 bd_size_t ProfilingBlockDevice::get_read_count() const 00093 { 00094 return _read_count; 00095 } 00096 00097 bd_size_t ProfilingBlockDevice::get_program_count() const 00098 { 00099 return _program_count; 00100 } 00101 00102 bd_size_t ProfilingBlockDevice::get_erase_count() const 00103 { 00104 return _erase_count; 00105 }
Generated on Thu Jul 14 2022 14:36:21 by
