mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Committer:
kenjiArai
Date:
Tue Dec 31 06:02:27 2019 +0000
Revision:
1:9db0e321a9f4
Parent:
0:5b88d5760320
updated based on mbed-os5.15.0

Who changed what in which revision?

UserRevisionLine numberNew contents of line
kenjiArai 0:5b88d5760320 1 /* mbed Microcontroller Library
kenjiArai 0:5b88d5760320 2 * Copyright (c) 2017 ARM Limited
kenjiArai 0:5b88d5760320 3 *
kenjiArai 0:5b88d5760320 4 * Licensed under the Apache License, Version 2.0 (the "License");
kenjiArai 0:5b88d5760320 5 * you may not use this file except in compliance with the License.
kenjiArai 0:5b88d5760320 6 * You may obtain a copy of the License at
kenjiArai 0:5b88d5760320 7 *
kenjiArai 0:5b88d5760320 8 * http://www.apache.org/licenses/LICENSE-2.0
kenjiArai 0:5b88d5760320 9 *
kenjiArai 0:5b88d5760320 10 * Unless required by applicable law or agreed to in writing, software
kenjiArai 0:5b88d5760320 11 * distributed under the License is distributed on an "AS IS" BASIS,
kenjiArai 0:5b88d5760320 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
kenjiArai 0:5b88d5760320 13 * See the License for the specific language governing permissions and
kenjiArai 0:5b88d5760320 14 * limitations under the License.
kenjiArai 0:5b88d5760320 15 */
kenjiArai 0:5b88d5760320 16
kenjiArai 0:5b88d5760320 17 #include "ProfilingBlockDevice.h"
kenjiArai 0:5b88d5760320 18 #include "stddef.h"
kenjiArai 0:5b88d5760320 19
kenjiArai 0:5b88d5760320 20 namespace mbed {
kenjiArai 0:5b88d5760320 21
kenjiArai 0:5b88d5760320 22 ProfilingBlockDevice::ProfilingBlockDevice(BlockDevice *bd)
kenjiArai 0:5b88d5760320 23 : _bd(bd)
kenjiArai 0:5b88d5760320 24 , _read_count(0)
kenjiArai 0:5b88d5760320 25 , _program_count(0)
kenjiArai 0:5b88d5760320 26 , _erase_count(0)
kenjiArai 0:5b88d5760320 27 {
kenjiArai 0:5b88d5760320 28 }
kenjiArai 0:5b88d5760320 29
kenjiArai 0:5b88d5760320 30 int ProfilingBlockDevice::init()
kenjiArai 0:5b88d5760320 31 {
kenjiArai 0:5b88d5760320 32 return _bd->init();
kenjiArai 0:5b88d5760320 33 }
kenjiArai 0:5b88d5760320 34
kenjiArai 0:5b88d5760320 35 int ProfilingBlockDevice::deinit()
kenjiArai 0:5b88d5760320 36 {
kenjiArai 0:5b88d5760320 37 return _bd->deinit();
kenjiArai 0:5b88d5760320 38 }
kenjiArai 0:5b88d5760320 39
kenjiArai 0:5b88d5760320 40 int ProfilingBlockDevice::sync()
kenjiArai 0:5b88d5760320 41 {
kenjiArai 0:5b88d5760320 42 return _bd->sync();
kenjiArai 0:5b88d5760320 43 }
kenjiArai 0:5b88d5760320 44
kenjiArai 0:5b88d5760320 45 int ProfilingBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size)
kenjiArai 0:5b88d5760320 46 {
kenjiArai 0:5b88d5760320 47 int err = _bd->read(b, addr, size);
kenjiArai 0:5b88d5760320 48 if (!err) {
kenjiArai 0:5b88d5760320 49 _read_count += size;
kenjiArai 0:5b88d5760320 50 }
kenjiArai 0:5b88d5760320 51 return err;
kenjiArai 0:5b88d5760320 52 }
kenjiArai 0:5b88d5760320 53
kenjiArai 0:5b88d5760320 54 int ProfilingBlockDevice::program(const void *b, bd_addr_t addr, bd_size_t size)
kenjiArai 0:5b88d5760320 55 {
kenjiArai 0:5b88d5760320 56 int err = _bd->program(b, addr, size);
kenjiArai 0:5b88d5760320 57 if (!err) {
kenjiArai 0:5b88d5760320 58 _program_count += size;
kenjiArai 0:5b88d5760320 59 }
kenjiArai 0:5b88d5760320 60 return err;
kenjiArai 0:5b88d5760320 61 }
kenjiArai 0:5b88d5760320 62
kenjiArai 0:5b88d5760320 63 int ProfilingBlockDevice::erase(bd_addr_t addr, bd_size_t size)
kenjiArai 0:5b88d5760320 64 {
kenjiArai 0:5b88d5760320 65 int err = _bd->erase(addr, size);
kenjiArai 0:5b88d5760320 66 if (!err) {
kenjiArai 0:5b88d5760320 67 _erase_count += size;
kenjiArai 0:5b88d5760320 68 }
kenjiArai 0:5b88d5760320 69 return err;
kenjiArai 0:5b88d5760320 70 }
kenjiArai 0:5b88d5760320 71
kenjiArai 0:5b88d5760320 72 bd_size_t ProfilingBlockDevice::get_read_size() const
kenjiArai 0:5b88d5760320 73 {
kenjiArai 0:5b88d5760320 74 return _bd->get_read_size();
kenjiArai 0:5b88d5760320 75 }
kenjiArai 0:5b88d5760320 76
kenjiArai 0:5b88d5760320 77 bd_size_t ProfilingBlockDevice::get_program_size() const
kenjiArai 0:5b88d5760320 78 {
kenjiArai 0:5b88d5760320 79 return _bd->get_program_size();
kenjiArai 0:5b88d5760320 80 }
kenjiArai 0:5b88d5760320 81
kenjiArai 0:5b88d5760320 82 bd_size_t ProfilingBlockDevice::get_erase_size() const
kenjiArai 0:5b88d5760320 83 {
kenjiArai 0:5b88d5760320 84 return _bd->get_erase_size();
kenjiArai 0:5b88d5760320 85 }
kenjiArai 0:5b88d5760320 86
kenjiArai 0:5b88d5760320 87 bd_size_t ProfilingBlockDevice::get_erase_size(bd_addr_t addr) const
kenjiArai 0:5b88d5760320 88 {
kenjiArai 0:5b88d5760320 89 return _bd->get_erase_size(addr);
kenjiArai 0:5b88d5760320 90 }
kenjiArai 0:5b88d5760320 91
kenjiArai 0:5b88d5760320 92 int ProfilingBlockDevice::get_erase_value() const
kenjiArai 0:5b88d5760320 93 {
kenjiArai 0:5b88d5760320 94 return _bd->get_erase_value();
kenjiArai 0:5b88d5760320 95 }
kenjiArai 0:5b88d5760320 96
kenjiArai 0:5b88d5760320 97 bd_size_t ProfilingBlockDevice::size() const
kenjiArai 0:5b88d5760320 98 {
kenjiArai 0:5b88d5760320 99 return _bd->size();
kenjiArai 0:5b88d5760320 100 }
kenjiArai 0:5b88d5760320 101
kenjiArai 0:5b88d5760320 102 void ProfilingBlockDevice::reset()
kenjiArai 0:5b88d5760320 103 {
kenjiArai 0:5b88d5760320 104 _read_count = 0;
kenjiArai 0:5b88d5760320 105 _program_count = 0;
kenjiArai 0:5b88d5760320 106 _erase_count = 0;
kenjiArai 0:5b88d5760320 107 }
kenjiArai 0:5b88d5760320 108
kenjiArai 0:5b88d5760320 109 bd_size_t ProfilingBlockDevice::get_read_count() const
kenjiArai 0:5b88d5760320 110 {
kenjiArai 0:5b88d5760320 111 return _read_count;
kenjiArai 0:5b88d5760320 112 }
kenjiArai 0:5b88d5760320 113
kenjiArai 0:5b88d5760320 114 bd_size_t ProfilingBlockDevice::get_program_count() const
kenjiArai 0:5b88d5760320 115 {
kenjiArai 0:5b88d5760320 116 return _program_count;
kenjiArai 0:5b88d5760320 117 }
kenjiArai 0:5b88d5760320 118
kenjiArai 0:5b88d5760320 119 bd_size_t ProfilingBlockDevice::get_erase_count() const
kenjiArai 0:5b88d5760320 120 {
kenjiArai 0:5b88d5760320 121 return _erase_count;
kenjiArai 0:5b88d5760320 122 }
kenjiArai 0:5b88d5760320 123
kenjiArai 0:5b88d5760320 124 const char *ProfilingBlockDevice::get_type() const
kenjiArai 0:5b88d5760320 125 {
kenjiArai 0:5b88d5760320 126 if (_bd != NULL) {
kenjiArai 0:5b88d5760320 127 return _bd->get_type();
kenjiArai 0:5b88d5760320 128 }
kenjiArai 0:5b88d5760320 129
kenjiArai 0:5b88d5760320 130 return NULL;
kenjiArai 0:5b88d5760320 131 }
kenjiArai 0:5b88d5760320 132
kenjiArai 0:5b88d5760320 133 } // namespace mbed
kenjiArai 0:5b88d5760320 134