mbed-os5 only for TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Revision:
1:9db0e321a9f4
Parent:
0:5b88d5760320
--- a/features/storage/blockdevice/HeapBlockDevice.cpp	Tue Dec 17 23:23:45 2019 +0000
+++ b/features/storage/blockdevice/HeapBlockDevice.cpp	Tue Dec 31 06:02:27 2019 +0000
@@ -87,41 +87,37 @@
 
 bd_size_t HeapBlockDevice::get_read_size() const
 {
-    MBED_ASSERT(_blocks != NULL);
     return _read_size;
 }
 
 bd_size_t HeapBlockDevice::get_program_size() const
 {
-    MBED_ASSERT(_blocks != NULL);
     return _program_size;
 }
 
 bd_size_t HeapBlockDevice::get_erase_size() const
 {
-    MBED_ASSERT(_blocks != NULL);
     return _erase_size;
 }
 
 bd_size_t HeapBlockDevice::get_erase_size(bd_addr_t addr) const
 {
-    MBED_ASSERT(_blocks != NULL);
     return _erase_size;
 }
 
 bd_size_t HeapBlockDevice::size() const
 {
-    MBED_ASSERT(_blocks != NULL);
     return _count * _erase_size;
 }
 
 int HeapBlockDevice::read(void *b, bd_addr_t addr, bd_size_t size)
 {
-    MBED_ASSERT(_blocks != NULL);
-    MBED_ASSERT(is_valid_read(addr, size));
     if (!_is_initialized) {
         return BD_ERROR_DEVICE_ERROR;
     }
+    if (!is_valid_read(addr, size)) {
+        return BD_ERROR_DEVICE_ERROR;
+    }
 
     uint8_t *buffer = static_cast<uint8_t *>(b);
 
@@ -145,11 +141,12 @@
 
 int HeapBlockDevice::program(const void *b, bd_addr_t addr, bd_size_t size)
 {
-    MBED_ASSERT(_blocks != NULL);
-    MBED_ASSERT(is_valid_program(addr, size));
     if (!_is_initialized) {
         return BD_ERROR_DEVICE_ERROR;
     }
+    if (!is_valid_program(addr, size)) {
+        return BD_ERROR_DEVICE_ERROR;
+    }
 
     const uint8_t *buffer = static_cast<const uint8_t *>(b);
 
@@ -176,10 +173,12 @@
 
 int HeapBlockDevice::erase(bd_addr_t addr, bd_size_t size)
 {
-    MBED_ASSERT(_blocks != NULL);
-    MBED_ASSERT(is_valid_erase(addr, size));
-    // TODO assert on programming unerased blocks
-
+    if (!_is_initialized) {
+        return BD_ERROR_DEVICE_ERROR;
+    }
+    if (!is_valid_erase(addr, size)) {
+        return BD_ERROR_DEVICE_ERROR;
+    }
     return 0;
 }
 
@@ -189,4 +188,3 @@
 }
 
 } // namespace mbed
-