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