5.2.1 - Updated I2C files
Dependents: mbed-TFT-example-NCS36510 mbed-Accelerometer-example-NCS36510 mbed-Accelerometer-example-NCS36510
TESTS/storage_abstraction/basicAPI/basicAPI.cpp@0:098463de4c5d, 2017-01-25 (annotated)
- Committer:
- group-onsemi
- Date:
- Wed Jan 25 20:34:15 2017 +0000
- Revision:
- 0:098463de4c5d
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
group-onsemi | 0:098463de4c5d | 1 | /* |
group-onsemi | 0:098463de4c5d | 2 | * Copyright (c) 2006-2016, ARM Limited, All Rights Reserved |
group-onsemi | 0:098463de4c5d | 3 | * SPDX-License-Identifier: Apache-2.0 |
group-onsemi | 0:098463de4c5d | 4 | * |
group-onsemi | 0:098463de4c5d | 5 | * Licensed under the Apache License, Version 2.0 (the "License"); you may |
group-onsemi | 0:098463de4c5d | 6 | * not use this file except in compliance with the License. |
group-onsemi | 0:098463de4c5d | 7 | * You may obtain a copy of the License at |
group-onsemi | 0:098463de4c5d | 8 | * |
group-onsemi | 0:098463de4c5d | 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
group-onsemi | 0:098463de4c5d | 10 | * |
group-onsemi | 0:098463de4c5d | 11 | * Unless required by applicable law or agreed to in writing, software |
group-onsemi | 0:098463de4c5d | 12 | * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
group-onsemi | 0:098463de4c5d | 13 | * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
group-onsemi | 0:098463de4c5d | 14 | * See the License for the specific language governing permissions and |
group-onsemi | 0:098463de4c5d | 15 | * limitations under the License. |
group-onsemi | 0:098463de4c5d | 16 | */ |
group-onsemi | 0:098463de4c5d | 17 | |
group-onsemi | 0:098463de4c5d | 18 | #if !DEVICE_STORAGE |
group-onsemi | 0:098463de4c5d | 19 | #error [NOT_SUPPORTED] Storage not supported for this target |
group-onsemi | 0:098463de4c5d | 20 | #endif |
group-onsemi | 0:098463de4c5d | 21 | |
group-onsemi | 0:098463de4c5d | 22 | #ifndef AVOID_GREENTEA |
group-onsemi | 0:098463de4c5d | 23 | #include "greentea-client/test_env.h" |
group-onsemi | 0:098463de4c5d | 24 | #endif |
group-onsemi | 0:098463de4c5d | 25 | #include "utest/utest.h" |
group-onsemi | 0:098463de4c5d | 26 | #include "unity/unity.h" |
group-onsemi | 0:098463de4c5d | 27 | |
group-onsemi | 0:098463de4c5d | 28 | #include "storage_abstraction/Driver_Storage.h" |
group-onsemi | 0:098463de4c5d | 29 | |
group-onsemi | 0:098463de4c5d | 30 | #include <string.h> |
group-onsemi | 0:098463de4c5d | 31 | #include <inttypes.h> |
group-onsemi | 0:098463de4c5d | 32 | |
group-onsemi | 0:098463de4c5d | 33 | using namespace utest::v1; |
group-onsemi | 0:098463de4c5d | 34 | |
group-onsemi | 0:098463de4c5d | 35 | extern ARM_DRIVER_STORAGE ARM_Driver_Storage_MTD_K64F; |
group-onsemi | 0:098463de4c5d | 36 | ARM_DRIVER_STORAGE *drv = &ARM_Driver_Storage_MTD_K64F; |
group-onsemi | 0:098463de4c5d | 37 | |
group-onsemi | 0:098463de4c5d | 38 | /* temporary buffer to hold data for testing. */ |
group-onsemi | 0:098463de4c5d | 39 | static const unsigned BUFFER_SIZE = 16384; |
group-onsemi | 0:098463de4c5d | 40 | static uint8_t buffer[BUFFER_SIZE]; |
group-onsemi | 0:098463de4c5d | 41 | |
group-onsemi | 0:098463de4c5d | 42 | /* forward declaration */ |
group-onsemi | 0:098463de4c5d | 43 | void initializationCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation); |
group-onsemi | 0:098463de4c5d | 44 | |
group-onsemi | 0:098463de4c5d | 45 | /* |
group-onsemi | 0:098463de4c5d | 46 | * Most tests need some basic initialization of the driver before proceeding |
group-onsemi | 0:098463de4c5d | 47 | * with their operations. |
group-onsemi | 0:098463de4c5d | 48 | */ |
group-onsemi | 0:098463de4c5d | 49 | static control_t preambleForBasicInitialization(void) |
group-onsemi | 0:098463de4c5d | 50 | { |
group-onsemi | 0:098463de4c5d | 51 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 52 | |
group-onsemi | 0:098463de4c5d | 53 | int32_t rc = drv->Initialize(initializationCompleteCallback); |
group-onsemi | 0:098463de4c5d | 54 | TEST_ASSERT(rc >= ARM_DRIVER_OK); |
group-onsemi | 0:098463de4c5d | 55 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 56 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 57 | return CaseTimeout(200) + CaseRepeatAll; |
group-onsemi | 0:098463de4c5d | 58 | } else { |
group-onsemi | 0:098463de4c5d | 59 | TEST_ASSERT(rc == 1); |
group-onsemi | 0:098463de4c5d | 60 | return CaseRepeatAll; |
group-onsemi | 0:098463de4c5d | 61 | } |
group-onsemi | 0:098463de4c5d | 62 | } |
group-onsemi | 0:098463de4c5d | 63 | |
group-onsemi | 0:098463de4c5d | 64 | template<typename T> |
group-onsemi | 0:098463de4c5d | 65 | static void verifyBytePattern(uint64_t addr, size_t sizeofData, T bytePattern) |
group-onsemi | 0:098463de4c5d | 66 | { |
group-onsemi | 0:098463de4c5d | 67 | /* we're limited by BUFFER_SIZE in how much we can verify in a single iteration; |
group-onsemi | 0:098463de4c5d | 68 | * the variable 'amountBeingVerified' captures the size being verified in each |
group-onsemi | 0:098463de4c5d | 69 | * iteration. */ |
group-onsemi | 0:098463de4c5d | 70 | size_t amountBeingVerified = sizeofData; |
group-onsemi | 0:098463de4c5d | 71 | if (amountBeingVerified > BUFFER_SIZE) { |
group-onsemi | 0:098463de4c5d | 72 | amountBeingVerified = BUFFER_SIZE; |
group-onsemi | 0:098463de4c5d | 73 | } |
group-onsemi | 0:098463de4c5d | 74 | TEST_ASSERT((amountBeingVerified % sizeof(T)) == 0); |
group-onsemi | 0:098463de4c5d | 75 | |
group-onsemi | 0:098463de4c5d | 76 | while (sizeofData) { |
group-onsemi | 0:098463de4c5d | 77 | int32_t rc = drv->ReadData(addr, buffer, amountBeingVerified); |
group-onsemi | 0:098463de4c5d | 78 | TEST_ASSERT_EQUAL(amountBeingVerified, rc); |
group-onsemi | 0:098463de4c5d | 79 | for (size_t index = 0; index < amountBeingVerified / sizeof(T); index++) { |
group-onsemi | 0:098463de4c5d | 80 | // if (bytePattern != ((const T *)buffer)[index]) { |
group-onsemi | 0:098463de4c5d | 81 | // printf("%u: expected %x, found %x\n", index, bytePattern, ((const T *)buffer)[index]); |
group-onsemi | 0:098463de4c5d | 82 | // } |
group-onsemi | 0:098463de4c5d | 83 | TEST_ASSERT_EQUAL(bytePattern, ((const T *)buffer)[index]); |
group-onsemi | 0:098463de4c5d | 84 | } |
group-onsemi | 0:098463de4c5d | 85 | |
group-onsemi | 0:098463de4c5d | 86 | sizeofData -= amountBeingVerified; |
group-onsemi | 0:098463de4c5d | 87 | addr += amountBeingVerified; |
group-onsemi | 0:098463de4c5d | 88 | } |
group-onsemi | 0:098463de4c5d | 89 | } |
group-onsemi | 0:098463de4c5d | 90 | |
group-onsemi | 0:098463de4c5d | 91 | void test_getVersion() |
group-onsemi | 0:098463de4c5d | 92 | { |
group-onsemi | 0:098463de4c5d | 93 | ARM_DRIVER_VERSION version = drv->GetVersion(); |
group-onsemi | 0:098463de4c5d | 94 | |
group-onsemi | 0:098463de4c5d | 95 | TEST_ASSERT_EQUAL(version.api, ARM_STORAGE_API_VERSION); |
group-onsemi | 0:098463de4c5d | 96 | TEST_ASSERT_EQUAL(version.drv, ARM_DRIVER_VERSION_MAJOR_MINOR(1,00)); |
group-onsemi | 0:098463de4c5d | 97 | } |
group-onsemi | 0:098463de4c5d | 98 | |
group-onsemi | 0:098463de4c5d | 99 | void test_getCapabilities() |
group-onsemi | 0:098463de4c5d | 100 | { |
group-onsemi | 0:098463de4c5d | 101 | TEST_ASSERT(sizeof(ARM_STORAGE_CAPABILITIES) == sizeof(uint32_t)); |
group-onsemi | 0:098463de4c5d | 102 | |
group-onsemi | 0:098463de4c5d | 103 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 104 | TEST_ASSERT_EQUAL(0, capabilities.reserved); |
group-onsemi | 0:098463de4c5d | 105 | } |
group-onsemi | 0:098463de4c5d | 106 | |
group-onsemi | 0:098463de4c5d | 107 | void test_getInfo() |
group-onsemi | 0:098463de4c5d | 108 | { |
group-onsemi | 0:098463de4c5d | 109 | ARM_STORAGE_INFO info = {}; |
group-onsemi | 0:098463de4c5d | 110 | int32_t rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 111 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 112 | |
group-onsemi | 0:098463de4c5d | 113 | TEST_ASSERT_EQUAL(0, info.security.reserved1); |
group-onsemi | 0:098463de4c5d | 114 | TEST_ASSERT_EQUAL(0, info.security.reserved2); |
group-onsemi | 0:098463de4c5d | 115 | TEST_ASSERT((info.program_cycles == ARM_STORAGE_PROGRAM_CYCLES_INFINITE) || (info.program_cycles > 0)); |
group-onsemi | 0:098463de4c5d | 116 | TEST_ASSERT(info.total_storage > 0); |
group-onsemi | 0:098463de4c5d | 117 | } |
group-onsemi | 0:098463de4c5d | 118 | |
group-onsemi | 0:098463de4c5d | 119 | void initializationCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation) |
group-onsemi | 0:098463de4c5d | 120 | { |
group-onsemi | 0:098463de4c5d | 121 | printf("init complete callback\n"); |
group-onsemi | 0:098463de4c5d | 122 | TEST_ASSERT_EQUAL(1, status); |
group-onsemi | 0:098463de4c5d | 123 | TEST_ASSERT_EQUAL(operation, ARM_STORAGE_OPERATION_INITIALIZE); |
group-onsemi | 0:098463de4c5d | 124 | |
group-onsemi | 0:098463de4c5d | 125 | Harness::validate_callback(); |
group-onsemi | 0:098463de4c5d | 126 | } |
group-onsemi | 0:098463de4c5d | 127 | |
group-onsemi | 0:098463de4c5d | 128 | control_t test_initialize(const size_t call_count) |
group-onsemi | 0:098463de4c5d | 129 | { |
group-onsemi | 0:098463de4c5d | 130 | static const unsigned REPEAT_INSTANCES = 3; |
group-onsemi | 0:098463de4c5d | 131 | printf("in test_initialize with call_count %u\n", call_count); |
group-onsemi | 0:098463de4c5d | 132 | |
group-onsemi | 0:098463de4c5d | 133 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 134 | |
group-onsemi | 0:098463de4c5d | 135 | int32_t rc = drv->Initialize(initializationCompleteCallback); |
group-onsemi | 0:098463de4c5d | 136 | TEST_ASSERT(rc >= ARM_DRIVER_OK); |
group-onsemi | 0:098463de4c5d | 137 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 138 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 139 | return (call_count < REPEAT_INSTANCES) ? (CaseTimeout(200) + CaseRepeatAll) : (control_t) CaseNext; |
group-onsemi | 0:098463de4c5d | 140 | } |
group-onsemi | 0:098463de4c5d | 141 | |
group-onsemi | 0:098463de4c5d | 142 | TEST_ASSERT(rc == 1); |
group-onsemi | 0:098463de4c5d | 143 | return (call_count < REPEAT_INSTANCES) ? CaseRepeatAll : CaseNext; |
group-onsemi | 0:098463de4c5d | 144 | } |
group-onsemi | 0:098463de4c5d | 145 | |
group-onsemi | 0:098463de4c5d | 146 | void uninitializationCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation) |
group-onsemi | 0:098463de4c5d | 147 | { |
group-onsemi | 0:098463de4c5d | 148 | printf("uninit complete callback\n"); |
group-onsemi | 0:098463de4c5d | 149 | TEST_ASSERT_EQUAL(status, ARM_DRIVER_OK); |
group-onsemi | 0:098463de4c5d | 150 | TEST_ASSERT_EQUAL(operation, ARM_STORAGE_OPERATION_UNINITIALIZE); |
group-onsemi | 0:098463de4c5d | 151 | |
group-onsemi | 0:098463de4c5d | 152 | Harness::validate_callback(); |
group-onsemi | 0:098463de4c5d | 153 | } |
group-onsemi | 0:098463de4c5d | 154 | |
group-onsemi | 0:098463de4c5d | 155 | control_t test_uninitialize(const size_t call_count) |
group-onsemi | 0:098463de4c5d | 156 | { |
group-onsemi | 0:098463de4c5d | 157 | static const unsigned REPEAT_INSTANCES = 3; |
group-onsemi | 0:098463de4c5d | 158 | printf("in test_uninitialize with call_count %u\n", call_count); |
group-onsemi | 0:098463de4c5d | 159 | |
group-onsemi | 0:098463de4c5d | 160 | /* update the completion callback. */ |
group-onsemi | 0:098463de4c5d | 161 | if (call_count == 1) { |
group-onsemi | 0:098463de4c5d | 162 | /* Achieve basic initialization for the driver before anything else. */ |
group-onsemi | 0:098463de4c5d | 163 | return preambleForBasicInitialization(); |
group-onsemi | 0:098463de4c5d | 164 | } |
group-onsemi | 0:098463de4c5d | 165 | |
group-onsemi | 0:098463de4c5d | 166 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 167 | |
group-onsemi | 0:098463de4c5d | 168 | int32_t rc = drv->Uninitialize(); |
group-onsemi | 0:098463de4c5d | 169 | if (call_count > 2) { |
group-onsemi | 0:098463de4c5d | 170 | /* the driver should return some error for repeated un-initialization. */ |
group-onsemi | 0:098463de4c5d | 171 | TEST_ASSERT(rc < ARM_DRIVER_OK); |
group-onsemi | 0:098463de4c5d | 172 | return (call_count < REPEAT_INSTANCES) ? CaseRepeatAll : CaseNext; |
group-onsemi | 0:098463de4c5d | 173 | } |
group-onsemi | 0:098463de4c5d | 174 | TEST_ASSERT(rc >= ARM_DRIVER_OK); |
group-onsemi | 0:098463de4c5d | 175 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 176 | /* asynchronous operation */ |
group-onsemi | 0:098463de4c5d | 177 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 178 | return CaseTimeout(200) + CaseRepeatAll; |
group-onsemi | 0:098463de4c5d | 179 | } |
group-onsemi | 0:098463de4c5d | 180 | |
group-onsemi | 0:098463de4c5d | 181 | /* synchronous operation */ |
group-onsemi | 0:098463de4c5d | 182 | TEST_ASSERT(rc == 1); |
group-onsemi | 0:098463de4c5d | 183 | return (call_count < REPEAT_INSTANCES) ? CaseRepeatAll : CaseNext; |
group-onsemi | 0:098463de4c5d | 184 | } |
group-onsemi | 0:098463de4c5d | 185 | |
group-onsemi | 0:098463de4c5d | 186 | void powerControlCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation) |
group-onsemi | 0:098463de4c5d | 187 | { |
group-onsemi | 0:098463de4c5d | 188 | printf("power control complete callback\n"); |
group-onsemi | 0:098463de4c5d | 189 | TEST_ASSERT_EQUAL(status, ARM_DRIVER_OK); |
group-onsemi | 0:098463de4c5d | 190 | TEST_ASSERT_EQUAL(operation, ARM_STORAGE_OPERATION_POWER_CONTROL); |
group-onsemi | 0:098463de4c5d | 191 | |
group-onsemi | 0:098463de4c5d | 192 | Harness::validate_callback(); |
group-onsemi | 0:098463de4c5d | 193 | } |
group-onsemi | 0:098463de4c5d | 194 | |
group-onsemi | 0:098463de4c5d | 195 | control_t test_powerControl(const size_t call_count) |
group-onsemi | 0:098463de4c5d | 196 | { |
group-onsemi | 0:098463de4c5d | 197 | static const unsigned REPEAT_INSTANCES = 2; |
group-onsemi | 0:098463de4c5d | 198 | printf("in test_powerControl with call_count %u\n", call_count); |
group-onsemi | 0:098463de4c5d | 199 | |
group-onsemi | 0:098463de4c5d | 200 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 201 | |
group-onsemi | 0:098463de4c5d | 202 | if (call_count == 1) { |
group-onsemi | 0:098463de4c5d | 203 | /* Achieve basic initialization for the driver before anything else. */ |
group-onsemi | 0:098463de4c5d | 204 | return preambleForBasicInitialization(); |
group-onsemi | 0:098463de4c5d | 205 | } |
group-onsemi | 0:098463de4c5d | 206 | |
group-onsemi | 0:098463de4c5d | 207 | /* Update the completion callback to 'powerControlCompleteCallback'. */ |
group-onsemi | 0:098463de4c5d | 208 | if (call_count == 2) { |
group-onsemi | 0:098463de4c5d | 209 | int32_t rc = drv->Initialize(powerControlCompleteCallback); |
group-onsemi | 0:098463de4c5d | 210 | TEST_ASSERT(rc == 1); /* Expect synchronous completion of initialization; the system must have been |
group-onsemi | 0:098463de4c5d | 211 | * initialized by the previous iteration. */ |
group-onsemi | 0:098463de4c5d | 212 | } |
group-onsemi | 0:098463de4c5d | 213 | |
group-onsemi | 0:098463de4c5d | 214 | int32_t rc = drv->PowerControl(ARM_POWER_FULL); |
group-onsemi | 0:098463de4c5d | 215 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 216 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 217 | return (call_count < REPEAT_INSTANCES) ? CaseTimeout(200) + CaseRepeatAll: CaseTimeout(200); |
group-onsemi | 0:098463de4c5d | 218 | } else { |
group-onsemi | 0:098463de4c5d | 219 | TEST_ASSERT(rc == 1); |
group-onsemi | 0:098463de4c5d | 220 | return (call_count < REPEAT_INSTANCES) ? CaseRepeatAll : CaseNext; |
group-onsemi | 0:098463de4c5d | 221 | } |
group-onsemi | 0:098463de4c5d | 222 | } |
group-onsemi | 0:098463de4c5d | 223 | |
group-onsemi | 0:098463de4c5d | 224 | void readDataCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation) |
group-onsemi | 0:098463de4c5d | 225 | { |
group-onsemi | 0:098463de4c5d | 226 | printf("ReadData complete callback\n"); |
group-onsemi | 0:098463de4c5d | 227 | TEST_ASSERT_EQUAL(status, ARM_DRIVER_OK); |
group-onsemi | 0:098463de4c5d | 228 | TEST_ASSERT_EQUAL(operation, ARM_STORAGE_OPERATION_READ_DATA); |
group-onsemi | 0:098463de4c5d | 229 | |
group-onsemi | 0:098463de4c5d | 230 | Harness::validate_callback(); |
group-onsemi | 0:098463de4c5d | 231 | } |
group-onsemi | 0:098463de4c5d | 232 | |
group-onsemi | 0:098463de4c5d | 233 | control_t test_readData(const size_t call_count) |
group-onsemi | 0:098463de4c5d | 234 | { |
group-onsemi | 0:098463de4c5d | 235 | static const unsigned REPEAT_INSTANCES = 5; |
group-onsemi | 0:098463de4c5d | 236 | printf("in test_readData with call_count %u\n", call_count); |
group-onsemi | 0:098463de4c5d | 237 | |
group-onsemi | 0:098463de4c5d | 238 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 239 | |
group-onsemi | 0:098463de4c5d | 240 | if (call_count == 1) { |
group-onsemi | 0:098463de4c5d | 241 | /* Achieve basic initialization for the driver before anything else. */ |
group-onsemi | 0:098463de4c5d | 242 | return preambleForBasicInitialization(); |
group-onsemi | 0:098463de4c5d | 243 | } |
group-onsemi | 0:098463de4c5d | 244 | |
group-onsemi | 0:098463de4c5d | 245 | /* Update the completion callback to 'readDataCompleteCallback'. */ |
group-onsemi | 0:098463de4c5d | 246 | int32_t rc; |
group-onsemi | 0:098463de4c5d | 247 | if (call_count == 2) { |
group-onsemi | 0:098463de4c5d | 248 | rc = drv->Initialize(readDataCompleteCallback); |
group-onsemi | 0:098463de4c5d | 249 | TEST_ASSERT(rc == 1); /* Expect synchronous completion of initialization; the system must have been |
group-onsemi | 0:098463de4c5d | 250 | * initialized by the previous iteration. */ |
group-onsemi | 0:098463de4c5d | 251 | } |
group-onsemi | 0:098463de4c5d | 252 | |
group-onsemi | 0:098463de4c5d | 253 | /* Get the first block. */ |
group-onsemi | 0:098463de4c5d | 254 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 255 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 256 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 257 | TEST_ASSERT(firstBlock.size > 0); |
group-onsemi | 0:098463de4c5d | 258 | |
group-onsemi | 0:098463de4c5d | 259 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 260 | rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 261 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 262 | |
group-onsemi | 0:098463de4c5d | 263 | TEST_ASSERT(info.program_unit <= BUFFER_SIZE); |
group-onsemi | 0:098463de4c5d | 264 | TEST_ASSERT(firstBlock.size >= (REPEAT_INSTANCES - 1) * info.program_unit); |
group-onsemi | 0:098463de4c5d | 265 | |
group-onsemi | 0:098463de4c5d | 266 | /* choose an increasing address for each iteration. */ |
group-onsemi | 0:098463de4c5d | 267 | uint64_t addr = firstBlock.addr + (call_count - 1) * info.program_unit; |
group-onsemi | 0:098463de4c5d | 268 | size_t sizeofData = info.program_unit; |
group-onsemi | 0:098463de4c5d | 269 | |
group-onsemi | 0:098463de4c5d | 270 | rc = drv->ReadData(addr, buffer, sizeofData); |
group-onsemi | 0:098463de4c5d | 271 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 272 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 273 | return (call_count < REPEAT_INSTANCES) ? CaseTimeout(200) + CaseRepeatAll: CaseTimeout(200); |
group-onsemi | 0:098463de4c5d | 274 | } else { |
group-onsemi | 0:098463de4c5d | 275 | TEST_ASSERT(rc > 0); |
group-onsemi | 0:098463de4c5d | 276 | return (call_count < REPEAT_INSTANCES) ? CaseRepeatAll : CaseNext; |
group-onsemi | 0:098463de4c5d | 277 | } |
group-onsemi | 0:098463de4c5d | 278 | } |
group-onsemi | 0:098463de4c5d | 279 | |
group-onsemi | 0:098463de4c5d | 280 | void programDataCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation) |
group-onsemi | 0:098463de4c5d | 281 | { |
group-onsemi | 0:098463de4c5d | 282 | TEST_ASSERT(status >= 0); |
group-onsemi | 0:098463de4c5d | 283 | static unsigned programIteration = 0; |
group-onsemi | 0:098463de4c5d | 284 | |
group-onsemi | 0:098463de4c5d | 285 | static const uint32_t BYTE_PATTERN = 0xAA551122; |
group-onsemi | 0:098463de4c5d | 286 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 287 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 288 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 289 | |
group-onsemi | 0:098463de4c5d | 290 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 291 | int32_t rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 292 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 293 | |
group-onsemi | 0:098463de4c5d | 294 | const uint64_t addr = firstBlock.addr + programIteration * firstBlock.attributes.erase_unit; |
group-onsemi | 0:098463de4c5d | 295 | size_t sizeofData = info.program_unit; |
group-onsemi | 0:098463de4c5d | 296 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 297 | |
group-onsemi | 0:098463de4c5d | 298 | TEST_ASSERT((operation == ARM_STORAGE_OPERATION_ERASE) || (operation == ARM_STORAGE_OPERATION_PROGRAM_DATA)); |
group-onsemi | 0:098463de4c5d | 299 | if (operation == ARM_STORAGE_OPERATION_ERASE) { |
group-onsemi | 0:098463de4c5d | 300 | // printf("programming %u bytes at address %lu with pattern 0x%" PRIx32 "\n", sizeofData, (uint32_t)addr, BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 301 | |
group-onsemi | 0:098463de4c5d | 302 | size_t sizeofData = info.program_unit; |
group-onsemi | 0:098463de4c5d | 303 | TEST_ASSERT(BUFFER_SIZE >= sizeofData); |
group-onsemi | 0:098463de4c5d | 304 | TEST_ASSERT((sizeofData % sizeof(uint32_t)) == 0); |
group-onsemi | 0:098463de4c5d | 305 | for (size_t index = 0; index < sizeofData / sizeof(uint32_t); index++) { |
group-onsemi | 0:098463de4c5d | 306 | ((uint32_t *)buffer)[index] = BYTE_PATTERN; |
group-onsemi | 0:098463de4c5d | 307 | } |
group-onsemi | 0:098463de4c5d | 308 | |
group-onsemi | 0:098463de4c5d | 309 | status = drv->ProgramData(addr, buffer, sizeofData); |
group-onsemi | 0:098463de4c5d | 310 | if (status < ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 311 | return; /* failure. this will trigger a timeout and cause test failure. */ |
group-onsemi | 0:098463de4c5d | 312 | } |
group-onsemi | 0:098463de4c5d | 313 | if (status == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 314 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 315 | return; /* We've successfully pended a programData operation; we'll have another |
group-onsemi | 0:098463de4c5d | 316 | * invocation of this callback when programming completes. */ |
group-onsemi | 0:098463de4c5d | 317 | } |
group-onsemi | 0:098463de4c5d | 318 | } |
group-onsemi | 0:098463de4c5d | 319 | |
group-onsemi | 0:098463de4c5d | 320 | /* We come here either because of completion for program-data or as a very |
group-onsemi | 0:098463de4c5d | 321 | * unlikely fall through from synchronous completion of program-data (above). */ |
group-onsemi | 0:098463de4c5d | 322 | |
group-onsemi | 0:098463de4c5d | 323 | #ifndef __CC_ARM |
group-onsemi | 0:098463de4c5d | 324 | printf("verifying programmed sector at addr %lu\n", (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 325 | #endif |
group-onsemi | 0:098463de4c5d | 326 | verifyBytePattern(addr, sizeofData, BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 327 | ++programIteration; |
group-onsemi | 0:098463de4c5d | 328 | |
group-onsemi | 0:098463de4c5d | 329 | Harness::validate_callback(); |
group-onsemi | 0:098463de4c5d | 330 | } |
group-onsemi | 0:098463de4c5d | 331 | |
group-onsemi | 0:098463de4c5d | 332 | control_t test_programDataUsingProgramUnit(const size_t call_count) |
group-onsemi | 0:098463de4c5d | 333 | { |
group-onsemi | 0:098463de4c5d | 334 | static const unsigned REPEAT_INSTANCES = 5; |
group-onsemi | 0:098463de4c5d | 335 | printf("in test_programDataUsingProgramUnit with call_count %u\n", call_count); |
group-onsemi | 0:098463de4c5d | 336 | |
group-onsemi | 0:098463de4c5d | 337 | if (call_count == 1) { |
group-onsemi | 0:098463de4c5d | 338 | /* Achieve basic initialization for the driver before anything else. */ |
group-onsemi | 0:098463de4c5d | 339 | return preambleForBasicInitialization(); |
group-onsemi | 0:098463de4c5d | 340 | } |
group-onsemi | 0:098463de4c5d | 341 | |
group-onsemi | 0:098463de4c5d | 342 | /* Get the first block. */ |
group-onsemi | 0:098463de4c5d | 343 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 344 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 345 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 346 | TEST_ASSERT(firstBlock.size > 0); |
group-onsemi | 0:098463de4c5d | 347 | |
group-onsemi | 0:098463de4c5d | 348 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 349 | int32_t rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 350 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 351 | |
group-onsemi | 0:098463de4c5d | 352 | TEST_ASSERT(info.program_unit <= firstBlock.attributes.erase_unit); |
group-onsemi | 0:098463de4c5d | 353 | TEST_ASSERT(firstBlock.size >= (REPEAT_INSTANCES - 1) * firstBlock.attributes.erase_unit); |
group-onsemi | 0:098463de4c5d | 354 | |
group-onsemi | 0:098463de4c5d | 355 | /* initialize the buffer to hold the pattern. */ |
group-onsemi | 0:098463de4c5d | 356 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 357 | |
group-onsemi | 0:098463de4c5d | 358 | /* Update the completion callback to 'programDataCompleteCallback'. */ |
group-onsemi | 0:098463de4c5d | 359 | if (call_count == 2) { |
group-onsemi | 0:098463de4c5d | 360 | int32_t rc = drv->Initialize(programDataCompleteCallback); |
group-onsemi | 0:098463de4c5d | 361 | TEST_ASSERT(rc == 1); /* Expect synchronous completion of initialization; the system must have been |
group-onsemi | 0:098463de4c5d | 362 | * initialized by the previous iteration. */ |
group-onsemi | 0:098463de4c5d | 363 | } |
group-onsemi | 0:098463de4c5d | 364 | |
group-onsemi | 0:098463de4c5d | 365 | /* choose an increasing address for each iteration. */ |
group-onsemi | 0:098463de4c5d | 366 | uint64_t addr = firstBlock.addr + (call_count - 2) * firstBlock.attributes.erase_unit; |
group-onsemi | 0:098463de4c5d | 367 | |
group-onsemi | 0:098463de4c5d | 368 | /* erase the sector at 'addr' */ |
group-onsemi | 0:098463de4c5d | 369 | printf("erasing sector at addr %lu\n", (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 370 | rc = drv->Erase(addr, firstBlock.attributes.erase_unit); |
group-onsemi | 0:098463de4c5d | 371 | TEST_ASSERT(rc >= 0); |
group-onsemi | 0:098463de4c5d | 372 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 373 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 374 | return (call_count < REPEAT_INSTANCES) ? CaseTimeout(200) + CaseRepeatAll: CaseTimeout(200); |
group-onsemi | 0:098463de4c5d | 375 | } else { |
group-onsemi | 0:098463de4c5d | 376 | TEST_ASSERT_EQUAL(firstBlock.attributes.erase_unit, rc); |
group-onsemi | 0:098463de4c5d | 377 | verifyBytePattern(addr, firstBlock.attributes.erase_unit, info.erased_value ? (uint8_t)0xFF : (uint8_t)0); |
group-onsemi | 0:098463de4c5d | 378 | |
group-onsemi | 0:098463de4c5d | 379 | static const uint32_t BYTE_PATTERN = 0xAA551122; |
group-onsemi | 0:098463de4c5d | 380 | size_t sizeofData = info.program_unit; |
group-onsemi | 0:098463de4c5d | 381 | TEST_ASSERT(BUFFER_SIZE >= sizeofData); |
group-onsemi | 0:098463de4c5d | 382 | TEST_ASSERT((sizeofData % sizeof(uint32_t)) == 0); |
group-onsemi | 0:098463de4c5d | 383 | for (size_t index = 0; index < sizeofData / sizeof(uint32_t); index++) { |
group-onsemi | 0:098463de4c5d | 384 | ((uint32_t *)buffer)[index] = BYTE_PATTERN; |
group-onsemi | 0:098463de4c5d | 385 | } |
group-onsemi | 0:098463de4c5d | 386 | |
group-onsemi | 0:098463de4c5d | 387 | /* program the sector at addr */ |
group-onsemi | 0:098463de4c5d | 388 | // printf("programming %u bytes at address %lu with pattern 0x%" PRIx32 "\n", sizeofData, (uint32_t)addr, BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 389 | rc = drv->ProgramData((uint32_t)addr, buffer, sizeofData); |
group-onsemi | 0:098463de4c5d | 390 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 391 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 392 | return (call_count < REPEAT_INSTANCES) ? CaseTimeout(200) + CaseRepeatAll: CaseTimeout(200); |
group-onsemi | 0:098463de4c5d | 393 | } else { |
group-onsemi | 0:098463de4c5d | 394 | TEST_ASSERT(rc > 0); |
group-onsemi | 0:098463de4c5d | 395 | |
group-onsemi | 0:098463de4c5d | 396 | printf("verifying programmed sector at addr %lu\n", (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 397 | verifyBytePattern(addr, sizeofData, BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 398 | |
group-onsemi | 0:098463de4c5d | 399 | return (call_count < REPEAT_INSTANCES) ? CaseRepeatAll : CaseNext; |
group-onsemi | 0:098463de4c5d | 400 | } |
group-onsemi | 0:098463de4c5d | 401 | } |
group-onsemi | 0:098463de4c5d | 402 | } |
group-onsemi | 0:098463de4c5d | 403 | |
group-onsemi | 0:098463de4c5d | 404 | void programDataOptimalCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation) |
group-onsemi | 0:098463de4c5d | 405 | { |
group-onsemi | 0:098463de4c5d | 406 | TEST_ASSERT(status >= 0); |
group-onsemi | 0:098463de4c5d | 407 | static unsigned programIteration = 0; |
group-onsemi | 0:098463de4c5d | 408 | |
group-onsemi | 0:098463de4c5d | 409 | static const uint8_t BYTE_PATTERN = 0xAA; |
group-onsemi | 0:098463de4c5d | 410 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 411 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 412 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 413 | const uint64_t addr = firstBlock.addr + programIteration * firstBlock.attributes.erase_unit; |
group-onsemi | 0:098463de4c5d | 414 | |
group-onsemi | 0:098463de4c5d | 415 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 416 | int32_t rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 417 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 418 | |
group-onsemi | 0:098463de4c5d | 419 | size_t sizeofData = info.optimal_program_unit; |
group-onsemi | 0:098463de4c5d | 420 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 421 | |
group-onsemi | 0:098463de4c5d | 422 | TEST_ASSERT((operation == ARM_STORAGE_OPERATION_ERASE) || (operation == ARM_STORAGE_OPERATION_PROGRAM_DATA)); |
group-onsemi | 0:098463de4c5d | 423 | if (operation == ARM_STORAGE_OPERATION_ERASE) { |
group-onsemi | 0:098463de4c5d | 424 | #ifndef __CC_ARM |
group-onsemi | 0:098463de4c5d | 425 | printf("programming %u bytes at address %lu with pattern 0x%x\n", sizeofData, (uint32_t)addr, BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 426 | #endif |
group-onsemi | 0:098463de4c5d | 427 | size_t sizeofData = info.optimal_program_unit; |
group-onsemi | 0:098463de4c5d | 428 | TEST_ASSERT(BUFFER_SIZE >= sizeofData); |
group-onsemi | 0:098463de4c5d | 429 | memset(buffer, BYTE_PATTERN, sizeofData); |
group-onsemi | 0:098463de4c5d | 430 | |
group-onsemi | 0:098463de4c5d | 431 | status = drv->ProgramData(addr, buffer, sizeofData); |
group-onsemi | 0:098463de4c5d | 432 | if (status < ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 433 | return; /* failure. this will trigger a timeout and cause test failure. */ |
group-onsemi | 0:098463de4c5d | 434 | } |
group-onsemi | 0:098463de4c5d | 435 | if (status == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 436 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 437 | return; /* We've successfully pended a programData operation; we'll have another |
group-onsemi | 0:098463de4c5d | 438 | * invocation of this callback when programming completes. */ |
group-onsemi | 0:098463de4c5d | 439 | } |
group-onsemi | 0:098463de4c5d | 440 | } |
group-onsemi | 0:098463de4c5d | 441 | |
group-onsemi | 0:098463de4c5d | 442 | /* We come here either because of completion for program-data or as a very |
group-onsemi | 0:098463de4c5d | 443 | * unlikely fall through from synchronous completion of program-data (above). */ |
group-onsemi | 0:098463de4c5d | 444 | |
group-onsemi | 0:098463de4c5d | 445 | #ifndef __CC_ARM |
group-onsemi | 0:098463de4c5d | 446 | printf("verifying programmed sector at addr %lu\n", (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 447 | #endif |
group-onsemi | 0:098463de4c5d | 448 | verifyBytePattern(addr, sizeofData, BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 449 | ++programIteration; |
group-onsemi | 0:098463de4c5d | 450 | |
group-onsemi | 0:098463de4c5d | 451 | Harness::validate_callback(); |
group-onsemi | 0:098463de4c5d | 452 | } |
group-onsemi | 0:098463de4c5d | 453 | |
group-onsemi | 0:098463de4c5d | 454 | control_t test_programDataUsingOptimalProgramUnit(const size_t call_count) |
group-onsemi | 0:098463de4c5d | 455 | { |
group-onsemi | 0:098463de4c5d | 456 | static const unsigned REPEAT_INSTANCES = 5; |
group-onsemi | 0:098463de4c5d | 457 | printf("in test_programDataUsingOptimalProgramUnit with call_count %u\n", call_count); |
group-onsemi | 0:098463de4c5d | 458 | |
group-onsemi | 0:098463de4c5d | 459 | if (call_count == 1) { |
group-onsemi | 0:098463de4c5d | 460 | /* Achieve basic initialization for the driver before anything else. */ |
group-onsemi | 0:098463de4c5d | 461 | return preambleForBasicInitialization(); |
group-onsemi | 0:098463de4c5d | 462 | } |
group-onsemi | 0:098463de4c5d | 463 | |
group-onsemi | 0:098463de4c5d | 464 | /* Get the first block. */ |
group-onsemi | 0:098463de4c5d | 465 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 466 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 467 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 468 | TEST_ASSERT(firstBlock.size > 0); |
group-onsemi | 0:098463de4c5d | 469 | |
group-onsemi | 0:098463de4c5d | 470 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 471 | int32_t rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 472 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 473 | |
group-onsemi | 0:098463de4c5d | 474 | TEST_ASSERT(info.optimal_program_unit <= firstBlock.attributes.erase_unit); |
group-onsemi | 0:098463de4c5d | 475 | TEST_ASSERT(firstBlock.size >= (REPEAT_INSTANCES - 1) * firstBlock.attributes.erase_unit); |
group-onsemi | 0:098463de4c5d | 476 | |
group-onsemi | 0:098463de4c5d | 477 | /* initialize the buffer to hold the pattern. */ |
group-onsemi | 0:098463de4c5d | 478 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 479 | |
group-onsemi | 0:098463de4c5d | 480 | /* Update the completion callback to 'programDataCompleteCallback'. */ |
group-onsemi | 0:098463de4c5d | 481 | if (call_count == 2) { |
group-onsemi | 0:098463de4c5d | 482 | int32_t rc = drv->Initialize(programDataOptimalCompleteCallback); |
group-onsemi | 0:098463de4c5d | 483 | TEST_ASSERT(rc == 1); /* Expect synchronous completion of initialization; the system must have been |
group-onsemi | 0:098463de4c5d | 484 | * initialized by the previous iteration. */ |
group-onsemi | 0:098463de4c5d | 485 | } |
group-onsemi | 0:098463de4c5d | 486 | |
group-onsemi | 0:098463de4c5d | 487 | /* choose an increasing address for each iteration. */ |
group-onsemi | 0:098463de4c5d | 488 | uint64_t addr = firstBlock.addr + (call_count - 2) * firstBlock.attributes.erase_unit; |
group-onsemi | 0:098463de4c5d | 489 | |
group-onsemi | 0:098463de4c5d | 490 | /* erase the sector at 'addr' */ |
group-onsemi | 0:098463de4c5d | 491 | printf("erasing sector at addr %lu\n", (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 492 | rc = drv->Erase(addr, firstBlock.attributes.erase_unit); |
group-onsemi | 0:098463de4c5d | 493 | TEST_ASSERT(rc >= 0); |
group-onsemi | 0:098463de4c5d | 494 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 495 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 496 | return (call_count < REPEAT_INSTANCES) ? CaseTimeout(200) + CaseRepeatAll: CaseTimeout(200); |
group-onsemi | 0:098463de4c5d | 497 | } else { |
group-onsemi | 0:098463de4c5d | 498 | TEST_ASSERT_EQUAL(firstBlock.attributes.erase_unit, rc); |
group-onsemi | 0:098463de4c5d | 499 | verifyBytePattern(addr, firstBlock.attributes.erase_unit, info.erased_value ? (uint8_t)0xFF : (uint8_t)0); |
group-onsemi | 0:098463de4c5d | 500 | |
group-onsemi | 0:098463de4c5d | 501 | static const uint8_t BYTE_PATTERN = 0xAA; |
group-onsemi | 0:098463de4c5d | 502 | size_t sizeofData = info.optimal_program_unit; |
group-onsemi | 0:098463de4c5d | 503 | TEST_ASSERT(BUFFER_SIZE >= sizeofData); |
group-onsemi | 0:098463de4c5d | 504 | memset(buffer, BYTE_PATTERN, sizeofData); |
group-onsemi | 0:098463de4c5d | 505 | |
group-onsemi | 0:098463de4c5d | 506 | /* program the sector at addr */ |
group-onsemi | 0:098463de4c5d | 507 | printf("programming %u bytes at address %lu with pattern 0x%x\n", sizeofData, (uint32_t)addr, BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 508 | rc = drv->ProgramData((uint32_t)addr, buffer, sizeofData); |
group-onsemi | 0:098463de4c5d | 509 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 510 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 511 | return (call_count < REPEAT_INSTANCES) ? CaseTimeout(200) + CaseRepeatAll: CaseTimeout(200); |
group-onsemi | 0:098463de4c5d | 512 | } else { |
group-onsemi | 0:098463de4c5d | 513 | TEST_ASSERT_EQUAL(sizeofData, rc); |
group-onsemi | 0:098463de4c5d | 514 | |
group-onsemi | 0:098463de4c5d | 515 | printf("verifying programmed sector at addr %lu\n", (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 516 | verifyBytePattern(addr, sizeofData, BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 517 | |
group-onsemi | 0:098463de4c5d | 518 | return (call_count < REPEAT_INSTANCES) ? CaseRepeatAll : CaseNext; |
group-onsemi | 0:098463de4c5d | 519 | } |
group-onsemi | 0:098463de4c5d | 520 | } |
group-onsemi | 0:098463de4c5d | 521 | } |
group-onsemi | 0:098463de4c5d | 522 | |
group-onsemi | 0:098463de4c5d | 523 | void test_eraseWithInvalidParameters(void) |
group-onsemi | 0:098463de4c5d | 524 | { |
group-onsemi | 0:098463de4c5d | 525 | int32_t rc; |
group-onsemi | 0:098463de4c5d | 526 | |
group-onsemi | 0:098463de4c5d | 527 | rc = drv->Erase(0, 0); |
group-onsemi | 0:098463de4c5d | 528 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 529 | |
group-onsemi | 0:098463de4c5d | 530 | /* operate before the start of the first block. */ |
group-onsemi | 0:098463de4c5d | 531 | ARM_STORAGE_BLOCK block; |
group-onsemi | 0:098463de4c5d | 532 | rc = drv->GetNextBlock(NULL, &block); /* get the first block */ |
group-onsemi | 0:098463de4c5d | 533 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 534 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&block)); |
group-onsemi | 0:098463de4c5d | 535 | TEST_ASSERT(block.size > 0); |
group-onsemi | 0:098463de4c5d | 536 | rc = drv->Erase(block.addr - 1, BUFFER_SIZE); |
group-onsemi | 0:098463de4c5d | 537 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 538 | |
group-onsemi | 0:098463de4c5d | 539 | /* operate at an address past the end of the last block */ |
group-onsemi | 0:098463de4c5d | 540 | uint64_t endAddr = block.addr + block.size; |
group-onsemi | 0:098463de4c5d | 541 | for (; ARM_STORAGE_VALID_BLOCK(&block); drv->GetNextBlock(&block, &block)) { |
group-onsemi | 0:098463de4c5d | 542 | endAddr = block.addr + block.size; |
group-onsemi | 0:098463de4c5d | 543 | } |
group-onsemi | 0:098463de4c5d | 544 | rc = drv->Erase(endAddr + 1, BUFFER_SIZE); |
group-onsemi | 0:098463de4c5d | 545 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 546 | |
group-onsemi | 0:098463de4c5d | 547 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 548 | rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 549 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 550 | |
group-onsemi | 0:098463de4c5d | 551 | drv->GetNextBlock(NULL, &block); /* get the first block */ |
group-onsemi | 0:098463de4c5d | 552 | TEST_ASSERT(block.size >= block.attributes.erase_unit); |
group-onsemi | 0:098463de4c5d | 553 | TEST_ASSERT((block.size % block.attributes.erase_unit) == 0); |
group-onsemi | 0:098463de4c5d | 554 | |
group-onsemi | 0:098463de4c5d | 555 | rc = drv->Erase(block.addr + 1, block.attributes.erase_unit); |
group-onsemi | 0:098463de4c5d | 556 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 557 | rc = drv->Erase(block.addr, block.attributes.erase_unit - 1); |
group-onsemi | 0:098463de4c5d | 558 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 559 | rc = drv->Erase(block.addr, block.attributes.erase_unit + 1); |
group-onsemi | 0:098463de4c5d | 560 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 561 | rc = drv->Erase(block.addr, block.attributes.erase_unit / 2); |
group-onsemi | 0:098463de4c5d | 562 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 563 | } |
group-onsemi | 0:098463de4c5d | 564 | |
group-onsemi | 0:098463de4c5d | 565 | template<size_t ERASE_UNITS_PER_ITERATION> |
group-onsemi | 0:098463de4c5d | 566 | void eraseCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation) |
group-onsemi | 0:098463de4c5d | 567 | { |
group-onsemi | 0:098463de4c5d | 568 | static unsigned eraseIteration = 0; |
group-onsemi | 0:098463de4c5d | 569 | #ifndef __CC_ARM |
group-onsemi | 0:098463de4c5d | 570 | printf("erase<%u> complete callback: iteration %u\n", ERASE_UNITS_PER_ITERATION, eraseIteration); |
group-onsemi | 0:098463de4c5d | 571 | #endif |
group-onsemi | 0:098463de4c5d | 572 | TEST_ASSERT_EQUAL(operation, ARM_STORAGE_OPERATION_ERASE); |
group-onsemi | 0:098463de4c5d | 573 | |
group-onsemi | 0:098463de4c5d | 574 | /* test that the actual sector has been erased */ |
group-onsemi | 0:098463de4c5d | 575 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 576 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 577 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 578 | TEST_ASSERT_EQUAL(ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit, status); |
group-onsemi | 0:098463de4c5d | 579 | |
group-onsemi | 0:098463de4c5d | 580 | const uint64_t addr = firstBlock.addr + eraseIteration * ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit; |
group-onsemi | 0:098463de4c5d | 581 | ++eraseIteration; |
group-onsemi | 0:098463de4c5d | 582 | |
group-onsemi | 0:098463de4c5d | 583 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 584 | int32_t rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 585 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 586 | |
group-onsemi | 0:098463de4c5d | 587 | //printf("testing erased sector at addr %lu", (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 588 | verifyBytePattern(addr, ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit, info.erased_value ? (uint8_t)0xFF : (uint8_t)0); |
group-onsemi | 0:098463de4c5d | 589 | |
group-onsemi | 0:098463de4c5d | 590 | Harness::validate_callback(); |
group-onsemi | 0:098463de4c5d | 591 | } |
group-onsemi | 0:098463de4c5d | 592 | |
group-onsemi | 0:098463de4c5d | 593 | template <size_t ERASE_UNITS_PER_ITERATION> |
group-onsemi | 0:098463de4c5d | 594 | control_t test_erase(const size_t call_count) |
group-onsemi | 0:098463de4c5d | 595 | { |
group-onsemi | 0:098463de4c5d | 596 | static const unsigned REPEAT_INSTANCES = 5; |
group-onsemi | 0:098463de4c5d | 597 | printf("in test_erase<%u> with call_count %u\n", ERASE_UNITS_PER_ITERATION, call_count); |
group-onsemi | 0:098463de4c5d | 598 | |
group-onsemi | 0:098463de4c5d | 599 | if (call_count == 1) { |
group-onsemi | 0:098463de4c5d | 600 | /* Achieve basic initialization for the driver before anything else. */ |
group-onsemi | 0:098463de4c5d | 601 | return preambleForBasicInitialization(); |
group-onsemi | 0:098463de4c5d | 602 | } |
group-onsemi | 0:098463de4c5d | 603 | |
group-onsemi | 0:098463de4c5d | 604 | /* Get the first block. */ |
group-onsemi | 0:098463de4c5d | 605 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 606 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 607 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 608 | TEST_ASSERT(firstBlock.size > 0); |
group-onsemi | 0:098463de4c5d | 609 | if (firstBlock.size < ((call_count - 1) * ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit)) { |
group-onsemi | 0:098463de4c5d | 610 | printf("firstBlock isn't large enough to support instance %u of test_erase<%u>\n", call_count, ERASE_UNITS_PER_ITERATION); |
group-onsemi | 0:098463de4c5d | 611 | return CaseNext; |
group-onsemi | 0:098463de4c5d | 612 | } |
group-onsemi | 0:098463de4c5d | 613 | |
group-onsemi | 0:098463de4c5d | 614 | /* Update the completion callback to 'eraseCompleteCallback'. */ |
group-onsemi | 0:098463de4c5d | 615 | if (call_count == 2) { |
group-onsemi | 0:098463de4c5d | 616 | int32_t rc = drv->Initialize(eraseCompleteCallback<ERASE_UNITS_PER_ITERATION>); |
group-onsemi | 0:098463de4c5d | 617 | TEST_ASSERT(rc == 1); /* Expect synchronous completion of initialization; the system must have been |
group-onsemi | 0:098463de4c5d | 618 | * initialized by the previous iteration. */ |
group-onsemi | 0:098463de4c5d | 619 | } |
group-onsemi | 0:098463de4c5d | 620 | |
group-onsemi | 0:098463de4c5d | 621 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 622 | |
group-onsemi | 0:098463de4c5d | 623 | /* choose an increasing address for each iteration. */ |
group-onsemi | 0:098463de4c5d | 624 | uint64_t addr = firstBlock.addr + (call_count - 2) * ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit; |
group-onsemi | 0:098463de4c5d | 625 | |
group-onsemi | 0:098463de4c5d | 626 | printf("erasing %lu bytes at addr %lu\n", (ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit), (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 627 | int32_t rc = drv->Erase(addr, ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit); |
group-onsemi | 0:098463de4c5d | 628 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 629 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 630 | return (call_count < REPEAT_INSTANCES) ? CaseTimeout(200) + CaseRepeatAll: CaseTimeout(200); |
group-onsemi | 0:098463de4c5d | 631 | } else { |
group-onsemi | 0:098463de4c5d | 632 | TEST_ASSERT_EQUAL(ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit, rc); |
group-onsemi | 0:098463de4c5d | 633 | |
group-onsemi | 0:098463de4c5d | 634 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 635 | rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 636 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 637 | |
group-onsemi | 0:098463de4c5d | 638 | /* test that the actual sector has been erased */ |
group-onsemi | 0:098463de4c5d | 639 | printf("testing erased sector at addr %lu\n", (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 640 | verifyBytePattern(addr, ERASE_UNITS_PER_ITERATION * firstBlock.attributes.erase_unit, (uint8_t)0xFF); |
group-onsemi | 0:098463de4c5d | 641 | |
group-onsemi | 0:098463de4c5d | 642 | return (call_count < REPEAT_INSTANCES) ? CaseRepeatAll : CaseNext; |
group-onsemi | 0:098463de4c5d | 643 | } |
group-onsemi | 0:098463de4c5d | 644 | } |
group-onsemi | 0:098463de4c5d | 645 | |
group-onsemi | 0:098463de4c5d | 646 | void eraseChipCompleteCallback(int32_t status, ARM_STORAGE_OPERATION operation) |
group-onsemi | 0:098463de4c5d | 647 | { |
group-onsemi | 0:098463de4c5d | 648 | #ifndef __CC_ARM |
group-onsemi | 0:098463de4c5d | 649 | printf("eraseChip complete callback\n"); |
group-onsemi | 0:098463de4c5d | 650 | #endif |
group-onsemi | 0:098463de4c5d | 651 | TEST_ASSERT_EQUAL(status, ARM_DRIVER_OK); |
group-onsemi | 0:098463de4c5d | 652 | TEST_ASSERT_EQUAL(operation, ARM_STORAGE_OPERATION_ERASE_ALL); |
group-onsemi | 0:098463de4c5d | 653 | |
group-onsemi | 0:098463de4c5d | 654 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 655 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 656 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 657 | uint64_t addr = firstBlock.addr; |
group-onsemi | 0:098463de4c5d | 658 | |
group-onsemi | 0:098463de4c5d | 659 | /* test that the flash has been erased */ |
group-onsemi | 0:098463de4c5d | 660 | #ifndef __CC_ARM |
group-onsemi | 0:098463de4c5d | 661 | printf("testing erased chip\n"); |
group-onsemi | 0:098463de4c5d | 662 | #endif |
group-onsemi | 0:098463de4c5d | 663 | unsigned index = 0; |
group-onsemi | 0:098463de4c5d | 664 | static const unsigned MAX_VERIFY_ITERATIONS = 5; |
group-onsemi | 0:098463de4c5d | 665 | while ((index < MAX_VERIFY_ITERATIONS) && (addr < (firstBlock.addr + firstBlock.size))) { |
group-onsemi | 0:098463de4c5d | 666 | // printf("testing erased chip at addr %lu\n", (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 667 | verifyBytePattern(addr, firstBlock.attributes.erase_unit, (uint8_t)0xFF); |
group-onsemi | 0:098463de4c5d | 668 | |
group-onsemi | 0:098463de4c5d | 669 | index++; |
group-onsemi | 0:098463de4c5d | 670 | addr += firstBlock.attributes.erase_unit; |
group-onsemi | 0:098463de4c5d | 671 | } |
group-onsemi | 0:098463de4c5d | 672 | |
group-onsemi | 0:098463de4c5d | 673 | Harness::validate_callback(); |
group-onsemi | 0:098463de4c5d | 674 | } |
group-onsemi | 0:098463de4c5d | 675 | |
group-onsemi | 0:098463de4c5d | 676 | control_t test_eraseAll(const size_t call_count) |
group-onsemi | 0:098463de4c5d | 677 | { |
group-onsemi | 0:098463de4c5d | 678 | static const unsigned REPEAT_INSTANCES = 5; |
group-onsemi | 0:098463de4c5d | 679 | printf("in test_eraseAll with call_count %u\n", call_count); |
group-onsemi | 0:098463de4c5d | 680 | |
group-onsemi | 0:098463de4c5d | 681 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 682 | if (!capabilities.erase_all) { |
group-onsemi | 0:098463de4c5d | 683 | printf("chip erase not supported on this flash\n"); |
group-onsemi | 0:098463de4c5d | 684 | return CaseNext; |
group-onsemi | 0:098463de4c5d | 685 | } |
group-onsemi | 0:098463de4c5d | 686 | |
group-onsemi | 0:098463de4c5d | 687 | if (call_count == 1) { |
group-onsemi | 0:098463de4c5d | 688 | /* Achieve basic initialization for the driver before anything else. */ |
group-onsemi | 0:098463de4c5d | 689 | return preambleForBasicInitialization(); |
group-onsemi | 0:098463de4c5d | 690 | } |
group-onsemi | 0:098463de4c5d | 691 | |
group-onsemi | 0:098463de4c5d | 692 | /* Update the completion callback to 'eraseChipCompleteCallback'. */ |
group-onsemi | 0:098463de4c5d | 693 | if (call_count == 2) { |
group-onsemi | 0:098463de4c5d | 694 | int32_t rc = drv->Initialize(eraseChipCompleteCallback); |
group-onsemi | 0:098463de4c5d | 695 | TEST_ASSERT(rc == 1); /* Expect synchronous completion of initialization; the system must have been |
group-onsemi | 0:098463de4c5d | 696 | * initialized by the previous iteration. */ |
group-onsemi | 0:098463de4c5d | 697 | } |
group-onsemi | 0:098463de4c5d | 698 | |
group-onsemi | 0:098463de4c5d | 699 | /* Get the first block. */ |
group-onsemi | 0:098463de4c5d | 700 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 701 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 702 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 703 | TEST_ASSERT(firstBlock.size > 0); |
group-onsemi | 0:098463de4c5d | 704 | uint64_t addr = firstBlock.addr; |
group-onsemi | 0:098463de4c5d | 705 | printf("erasing chip\n"); |
group-onsemi | 0:098463de4c5d | 706 | |
group-onsemi | 0:098463de4c5d | 707 | int32_t rc = drv->EraseAll(); |
group-onsemi | 0:098463de4c5d | 708 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 709 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 710 | return (call_count < REPEAT_INSTANCES) ? CaseTimeout(200) + CaseRepeatAll: CaseTimeout(200); |
group-onsemi | 0:098463de4c5d | 711 | } else { |
group-onsemi | 0:098463de4c5d | 712 | TEST_ASSERT(rc == 1); |
group-onsemi | 0:098463de4c5d | 713 | |
group-onsemi | 0:098463de4c5d | 714 | /* test that the flash has been erased */ |
group-onsemi | 0:098463de4c5d | 715 | unsigned index = 0; |
group-onsemi | 0:098463de4c5d | 716 | static const unsigned MAX_VERIFY_ITERATIONS = 5; |
group-onsemi | 0:098463de4c5d | 717 | while ((index < MAX_VERIFY_ITERATIONS) && (addr < (firstBlock.addr + firstBlock.size))) { |
group-onsemi | 0:098463de4c5d | 718 | //printf("testing erased chip at addr %lu", (uint32_t)addr); |
group-onsemi | 0:098463de4c5d | 719 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 720 | rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 721 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 722 | |
group-onsemi | 0:098463de4c5d | 723 | verifyBytePattern(addr, firstBlock.attributes.erase_unit, info.erased_value ? (uint8_t)0xFF : (uint8_t)0); |
group-onsemi | 0:098463de4c5d | 724 | |
group-onsemi | 0:098463de4c5d | 725 | index++; |
group-onsemi | 0:098463de4c5d | 726 | addr += firstBlock.attributes.erase_unit; |
group-onsemi | 0:098463de4c5d | 727 | } |
group-onsemi | 0:098463de4c5d | 728 | |
group-onsemi | 0:098463de4c5d | 729 | return (call_count < REPEAT_INSTANCES) ? CaseRepeatAll : CaseNext; |
group-onsemi | 0:098463de4c5d | 730 | } |
group-onsemi | 0:098463de4c5d | 731 | } |
group-onsemi | 0:098463de4c5d | 732 | |
group-onsemi | 0:098463de4c5d | 733 | void test_programDataWithInvalidParameters(void) |
group-onsemi | 0:098463de4c5d | 734 | { |
group-onsemi | 0:098463de4c5d | 735 | int32_t rc; |
group-onsemi | 0:098463de4c5d | 736 | |
group-onsemi | 0:098463de4c5d | 737 | rc = drv->ProgramData(0, NULL, 0); |
group-onsemi | 0:098463de4c5d | 738 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 739 | rc = drv->ProgramData(0, buffer, 0); |
group-onsemi | 0:098463de4c5d | 740 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 741 | rc = drv->ProgramData(0, NULL, BUFFER_SIZE); |
group-onsemi | 0:098463de4c5d | 742 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 743 | |
group-onsemi | 0:098463de4c5d | 744 | /* operate before the start of the first block. */ |
group-onsemi | 0:098463de4c5d | 745 | ARM_STORAGE_BLOCK block; |
group-onsemi | 0:098463de4c5d | 746 | rc = drv->GetNextBlock(NULL, &block); /* get the first block */ |
group-onsemi | 0:098463de4c5d | 747 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 748 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&block)); |
group-onsemi | 0:098463de4c5d | 749 | TEST_ASSERT(block.size > 0); |
group-onsemi | 0:098463de4c5d | 750 | rc = drv->ProgramData(block.addr - 1, buffer, BUFFER_SIZE); |
group-onsemi | 0:098463de4c5d | 751 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 752 | |
group-onsemi | 0:098463de4c5d | 753 | /* operate at an address past the end of the last block */ |
group-onsemi | 0:098463de4c5d | 754 | uint64_t endAddr = block.addr + block.size; |
group-onsemi | 0:098463de4c5d | 755 | for (; ARM_STORAGE_VALID_BLOCK(&block); drv->GetNextBlock(&block, &block)) { |
group-onsemi | 0:098463de4c5d | 756 | endAddr = block.addr + block.size; |
group-onsemi | 0:098463de4c5d | 757 | } |
group-onsemi | 0:098463de4c5d | 758 | rc = drv->ProgramData(endAddr + 1, buffer, BUFFER_SIZE); |
group-onsemi | 0:098463de4c5d | 759 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 760 | |
group-onsemi | 0:098463de4c5d | 761 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 762 | rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 763 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 764 | if (info.program_unit <= 1) { |
group-onsemi | 0:098463de4c5d | 765 | return; /* if program_unit is 1 (or 0), we can't proceed with any alignment tests */ |
group-onsemi | 0:098463de4c5d | 766 | } |
group-onsemi | 0:098463de4c5d | 767 | |
group-onsemi | 0:098463de4c5d | 768 | drv->GetNextBlock(NULL, &block); /* get the first block */ |
group-onsemi | 0:098463de4c5d | 769 | |
group-onsemi | 0:098463de4c5d | 770 | TEST_ASSERT(block.size >= info.program_unit); |
group-onsemi | 0:098463de4c5d | 771 | |
group-onsemi | 0:098463de4c5d | 772 | rc = drv->ProgramData(block.addr + 1, buffer, info.program_unit); |
group-onsemi | 0:098463de4c5d | 773 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 774 | rc = drv->ProgramData(block.addr, buffer, info.program_unit - 1); |
group-onsemi | 0:098463de4c5d | 775 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 776 | rc = drv->ProgramData(block.addr, buffer, info.program_unit + 1); |
group-onsemi | 0:098463de4c5d | 777 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 778 | rc = drv->ProgramData(block.addr, buffer, info.program_unit / 2); |
group-onsemi | 0:098463de4c5d | 779 | TEST_ASSERT_EQUAL(ARM_DRIVER_ERROR_PARAMETER, rc); |
group-onsemi | 0:098463de4c5d | 780 | } |
group-onsemi | 0:098463de4c5d | 781 | |
group-onsemi | 0:098463de4c5d | 782 | template <size_t N_UNITS> |
group-onsemi | 0:098463de4c5d | 783 | void programDataWithMultipleProgramUnitsCallback(int32_t status, ARM_STORAGE_OPERATION operation) |
group-onsemi | 0:098463de4c5d | 784 | { |
group-onsemi | 0:098463de4c5d | 785 | TEST_ASSERT(status >= ARM_DRIVER_OK); |
group-onsemi | 0:098463de4c5d | 786 | |
group-onsemi | 0:098463de4c5d | 787 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 788 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 789 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 790 | TEST_ASSERT(firstBlock.size > 0); |
group-onsemi | 0:098463de4c5d | 791 | |
group-onsemi | 0:098463de4c5d | 792 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 793 | int32_t rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 794 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 795 | |
group-onsemi | 0:098463de4c5d | 796 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 797 | |
group-onsemi | 0:098463de4c5d | 798 | size_t rangeNeededForTest = (N_UNITS * info.program_unit); |
group-onsemi | 0:098463de4c5d | 799 | /* round-up range to the nearest erase_unit */ |
group-onsemi | 0:098463de4c5d | 800 | rangeNeededForTest = ((rangeNeededForTest + firstBlock.attributes.erase_unit - 1) / firstBlock.attributes.erase_unit) * firstBlock.attributes.erase_unit; |
group-onsemi | 0:098463de4c5d | 801 | |
group-onsemi | 0:098463de4c5d | 802 | static const uint32_t BYTE_PATTERN = 0xABCDEF00; |
group-onsemi | 0:098463de4c5d | 803 | |
group-onsemi | 0:098463de4c5d | 804 | if (operation == ARM_STORAGE_OPERATION_ERASE) { |
group-onsemi | 0:098463de4c5d | 805 | TEST_ASSERT_EQUAL(rangeNeededForTest, status); |
group-onsemi | 0:098463de4c5d | 806 | TEST_ASSERT((N_UNITS * info.program_unit) <= BUFFER_SIZE); |
group-onsemi | 0:098463de4c5d | 807 | |
group-onsemi | 0:098463de4c5d | 808 | /* setup byte pattern in buffer */ |
group-onsemi | 0:098463de4c5d | 809 | if (info.program_unit >= sizeof(BYTE_PATTERN)) { |
group-onsemi | 0:098463de4c5d | 810 | for (size_t index = 0; index < ((N_UNITS * info.program_unit) / sizeof(BYTE_PATTERN)); index++) { |
group-onsemi | 0:098463de4c5d | 811 | ((uint32_t *)buffer)[index] = BYTE_PATTERN; |
group-onsemi | 0:098463de4c5d | 812 | } |
group-onsemi | 0:098463de4c5d | 813 | } else { |
group-onsemi | 0:098463de4c5d | 814 | for (size_t index = 0; index < ((N_UNITS * info.program_unit)); index++) { |
group-onsemi | 0:098463de4c5d | 815 | buffer[index] = ((const uint8_t *)&BYTE_PATTERN)[0]; |
group-onsemi | 0:098463de4c5d | 816 | } |
group-onsemi | 0:098463de4c5d | 817 | } |
group-onsemi | 0:098463de4c5d | 818 | |
group-onsemi | 0:098463de4c5d | 819 | #ifndef __CC_ARM |
group-onsemi | 0:098463de4c5d | 820 | printf("Callback: programming %lu bytes at address %lu with pattern 0x%lx\n", (N_UNITS * info.program_unit), (uint32_t)firstBlock.addr, BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 821 | #endif |
group-onsemi | 0:098463de4c5d | 822 | rc = drv->ProgramData(firstBlock.addr, buffer, (N_UNITS * info.program_unit)); |
group-onsemi | 0:098463de4c5d | 823 | TEST_ASSERT(rc >= ARM_DRIVER_OK); |
group-onsemi | 0:098463de4c5d | 824 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 825 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 826 | return; /* We've successfully pended a programData operation; we'll have another |
group-onsemi | 0:098463de4c5d | 827 | * invocation of this callback when programming completes. */ |
group-onsemi | 0:098463de4c5d | 828 | } |
group-onsemi | 0:098463de4c5d | 829 | |
group-onsemi | 0:098463de4c5d | 830 | status = rc; |
group-onsemi | 0:098463de4c5d | 831 | } |
group-onsemi | 0:098463de4c5d | 832 | |
group-onsemi | 0:098463de4c5d | 833 | TEST_ASSERT_EQUAL((N_UNITS * info.program_unit), status); |
group-onsemi | 0:098463de4c5d | 834 | |
group-onsemi | 0:098463de4c5d | 835 | #ifndef __CC_ARM |
group-onsemi | 0:098463de4c5d | 836 | printf("Callback: verifying programmed sector at addr %lu\n", (uint32_t)firstBlock.addr); |
group-onsemi | 0:098463de4c5d | 837 | #endif |
group-onsemi | 0:098463de4c5d | 838 | if (info.program_unit >= sizeof(BYTE_PATTERN)) { |
group-onsemi | 0:098463de4c5d | 839 | verifyBytePattern(firstBlock.addr, (N_UNITS * info.program_unit), BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 840 | } else { |
group-onsemi | 0:098463de4c5d | 841 | verifyBytePattern(firstBlock.addr, (N_UNITS * info.program_unit), ((const uint8_t *)&BYTE_PATTERN)[0]); |
group-onsemi | 0:098463de4c5d | 842 | } |
group-onsemi | 0:098463de4c5d | 843 | |
group-onsemi | 0:098463de4c5d | 844 | Harness::validate_callback(); |
group-onsemi | 0:098463de4c5d | 845 | } |
group-onsemi | 0:098463de4c5d | 846 | |
group-onsemi | 0:098463de4c5d | 847 | template<size_t N_UNITS> |
group-onsemi | 0:098463de4c5d | 848 | control_t test_programDataWithMultipleProgramUnits(const size_t call_count) |
group-onsemi | 0:098463de4c5d | 849 | { |
group-onsemi | 0:098463de4c5d | 850 | int32_t rc; |
group-onsemi | 0:098463de4c5d | 851 | printf("in test_programDataWithMultipleProgramUnits<%u> with call_count %u\n", N_UNITS, call_count); |
group-onsemi | 0:098463de4c5d | 852 | |
group-onsemi | 0:098463de4c5d | 853 | if (call_count == 1) { |
group-onsemi | 0:098463de4c5d | 854 | /* Achieve basic initialization for the driver before anything else. */ |
group-onsemi | 0:098463de4c5d | 855 | return preambleForBasicInitialization(); |
group-onsemi | 0:098463de4c5d | 856 | } |
group-onsemi | 0:098463de4c5d | 857 | |
group-onsemi | 0:098463de4c5d | 858 | /* Update the completion callback to 'programDataWithMultipleProgramUnitsCallback'. */ |
group-onsemi | 0:098463de4c5d | 859 | if (call_count == 2) { |
group-onsemi | 0:098463de4c5d | 860 | rc = drv->Initialize(programDataWithMultipleProgramUnitsCallback<N_UNITS>); |
group-onsemi | 0:098463de4c5d | 861 | TEST_ASSERT(rc == 1); /* Expect synchronous completion of initialization; the system must have been |
group-onsemi | 0:098463de4c5d | 862 | * initialized by the previous iteration. */ |
group-onsemi | 0:098463de4c5d | 863 | |
group-onsemi | 0:098463de4c5d | 864 | ARM_STORAGE_BLOCK firstBlock; |
group-onsemi | 0:098463de4c5d | 865 | drv->GetNextBlock(NULL, &firstBlock); /* get first block */ |
group-onsemi | 0:098463de4c5d | 866 | TEST_ASSERT(ARM_STORAGE_VALID_BLOCK(&firstBlock)); |
group-onsemi | 0:098463de4c5d | 867 | TEST_ASSERT(firstBlock.size > 0); |
group-onsemi | 0:098463de4c5d | 868 | |
group-onsemi | 0:098463de4c5d | 869 | ARM_STORAGE_INFO info; |
group-onsemi | 0:098463de4c5d | 870 | int32_t rc = drv->GetInfo(&info); |
group-onsemi | 0:098463de4c5d | 871 | TEST_ASSERT_EQUAL(ARM_DRIVER_OK, rc); |
group-onsemi | 0:098463de4c5d | 872 | |
group-onsemi | 0:098463de4c5d | 873 | ARM_STORAGE_CAPABILITIES capabilities = drv->GetCapabilities(); |
group-onsemi | 0:098463de4c5d | 874 | |
group-onsemi | 0:098463de4c5d | 875 | size_t rangeNeededForTest = (N_UNITS * info.program_unit); |
group-onsemi | 0:098463de4c5d | 876 | /* round-up range to the nearest erase_unit */ |
group-onsemi | 0:098463de4c5d | 877 | rangeNeededForTest = ((rangeNeededForTest + firstBlock.attributes.erase_unit - 1) / firstBlock.attributes.erase_unit) * firstBlock.attributes.erase_unit; |
group-onsemi | 0:098463de4c5d | 878 | if (firstBlock.size < rangeNeededForTest) { |
group-onsemi | 0:098463de4c5d | 879 | printf("first block not large enough; rangeNeededForTest: %u\n", rangeNeededForTest); |
group-onsemi | 0:098463de4c5d | 880 | return CaseNext; /* first block isn't large enough for the intended operation */ |
group-onsemi | 0:098463de4c5d | 881 | } |
group-onsemi | 0:098463de4c5d | 882 | |
group-onsemi | 0:098463de4c5d | 883 | if (rangeNeededForTest > BUFFER_SIZE) { |
group-onsemi | 0:098463de4c5d | 884 | printf("buffer (%u) not large enough; rangeNeededForTest: %u\n", BUFFER_SIZE, rangeNeededForTest); |
group-onsemi | 0:098463de4c5d | 885 | return CaseNext; |
group-onsemi | 0:098463de4c5d | 886 | } |
group-onsemi | 0:098463de4c5d | 887 | |
group-onsemi | 0:098463de4c5d | 888 | // printf("erasing %u bytes at addr %lu\n", rangeNeededForTest, (uint32_t)firstBlock.addr); |
group-onsemi | 0:098463de4c5d | 889 | rc = drv->Erase(firstBlock.addr, rangeNeededForTest); |
group-onsemi | 0:098463de4c5d | 890 | TEST_ASSERT(rc >= 0); |
group-onsemi | 0:098463de4c5d | 891 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 892 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 893 | return CaseTimeout(500); |
group-onsemi | 0:098463de4c5d | 894 | } else { |
group-onsemi | 0:098463de4c5d | 895 | TEST_ASSERT_EQUAL(rangeNeededForTest, rc); |
group-onsemi | 0:098463de4c5d | 896 | |
group-onsemi | 0:098463de4c5d | 897 | /* setup byte pattern in buffer */ |
group-onsemi | 0:098463de4c5d | 898 | static const uint32_t BYTE_PATTERN = 0xABCDEF00; |
group-onsemi | 0:098463de4c5d | 899 | if (info.program_unit >= sizeof(BYTE_PATTERN)) { |
group-onsemi | 0:098463de4c5d | 900 | for (size_t index = 0; index < ((N_UNITS * info.program_unit) / sizeof(BYTE_PATTERN)); index++) { |
group-onsemi | 0:098463de4c5d | 901 | ((uint32_t *)buffer)[index] = BYTE_PATTERN; |
group-onsemi | 0:098463de4c5d | 902 | } |
group-onsemi | 0:098463de4c5d | 903 | } else { |
group-onsemi | 0:098463de4c5d | 904 | for (size_t index = 0; index < ((N_UNITS * info.program_unit)); index++) { |
group-onsemi | 0:098463de4c5d | 905 | buffer[index] = ((const uint8_t *)&BYTE_PATTERN)[0]; |
group-onsemi | 0:098463de4c5d | 906 | } |
group-onsemi | 0:098463de4c5d | 907 | } |
group-onsemi | 0:098463de4c5d | 908 | |
group-onsemi | 0:098463de4c5d | 909 | printf("programming %lu bytes at address %lu with pattern 0x%lx\n", (N_UNITS * info.program_unit), (uint32_t)firstBlock.addr, BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 910 | rc = drv->ProgramData(firstBlock.addr, buffer, (N_UNITS * info.program_unit)); |
group-onsemi | 0:098463de4c5d | 911 | TEST_ASSERT(rc >= 0); |
group-onsemi | 0:098463de4c5d | 912 | if (rc == ARM_DRIVER_OK) { |
group-onsemi | 0:098463de4c5d | 913 | TEST_ASSERT_EQUAL(1, capabilities.asynchronous_ops); |
group-onsemi | 0:098463de4c5d | 914 | return CaseTimeout(500); |
group-onsemi | 0:098463de4c5d | 915 | } else { |
group-onsemi | 0:098463de4c5d | 916 | TEST_ASSERT_EQUAL((N_UNITS * info.program_unit), rc); |
group-onsemi | 0:098463de4c5d | 917 | |
group-onsemi | 0:098463de4c5d | 918 | printf("verifying programmed sector at addr %lu\n", (uint32_t)firstBlock.addr); |
group-onsemi | 0:098463de4c5d | 919 | if (info.program_unit >= sizeof(BYTE_PATTERN)) { |
group-onsemi | 0:098463de4c5d | 920 | verifyBytePattern(firstBlock.addr, (N_UNITS * info.program_unit), BYTE_PATTERN); |
group-onsemi | 0:098463de4c5d | 921 | } else { |
group-onsemi | 0:098463de4c5d | 922 | verifyBytePattern(firstBlock.addr, (N_UNITS * info.program_unit), ((const uint8_t *)&BYTE_PATTERN)[0]); |
group-onsemi | 0:098463de4c5d | 923 | } |
group-onsemi | 0:098463de4c5d | 924 | |
group-onsemi | 0:098463de4c5d | 925 | return CaseNext; |
group-onsemi | 0:098463de4c5d | 926 | } |
group-onsemi | 0:098463de4c5d | 927 | } |
group-onsemi | 0:098463de4c5d | 928 | } |
group-onsemi | 0:098463de4c5d | 929 | |
group-onsemi | 0:098463de4c5d | 930 | return CaseNext; |
group-onsemi | 0:098463de4c5d | 931 | } |
group-onsemi | 0:098463de4c5d | 932 | |
group-onsemi | 0:098463de4c5d | 933 | #ifndef AVOID_GREENTEA |
group-onsemi | 0:098463de4c5d | 934 | // Custom setup handler required for proper Greentea support |
group-onsemi | 0:098463de4c5d | 935 | utest::v1::status_t greentea_setup(const size_t number_of_cases) |
group-onsemi | 0:098463de4c5d | 936 | { |
group-onsemi | 0:098463de4c5d | 937 | GREENTEA_SETUP(60, "default_auto"); |
group-onsemi | 0:098463de4c5d | 938 | // Call the default reporting function |
group-onsemi | 0:098463de4c5d | 939 | return greentea_test_setup_handler(number_of_cases); |
group-onsemi | 0:098463de4c5d | 940 | } |
group-onsemi | 0:098463de4c5d | 941 | #else |
group-onsemi | 0:098463de4c5d | 942 | status_t default_setup(const size_t) |
group-onsemi | 0:098463de4c5d | 943 | { |
group-onsemi | 0:098463de4c5d | 944 | return STATUS_CONTINUE; |
group-onsemi | 0:098463de4c5d | 945 | } |
group-onsemi | 0:098463de4c5d | 946 | #endif |
group-onsemi | 0:098463de4c5d | 947 | |
group-onsemi | 0:098463de4c5d | 948 | // Specify all your test cases here |
group-onsemi | 0:098463de4c5d | 949 | Case cases[] = { |
group-onsemi | 0:098463de4c5d | 950 | Case("get version", test_getVersion), |
group-onsemi | 0:098463de4c5d | 951 | Case("get capabilities", test_getCapabilities), |
group-onsemi | 0:098463de4c5d | 952 | Case("get info", test_getInfo), |
group-onsemi | 0:098463de4c5d | 953 | Case("initialize", test_initialize), |
group-onsemi | 0:098463de4c5d | 954 | Case("uninitialize", test_uninitialize), |
group-onsemi | 0:098463de4c5d | 955 | Case("power control", test_powerControl), |
group-onsemi | 0:098463de4c5d | 956 | Case("erase all", test_eraseAll), |
group-onsemi | 0:098463de4c5d | 957 | Case("read data", test_readData), |
group-onsemi | 0:098463de4c5d | 958 | Case("erase with invalid parameters", test_eraseWithInvalidParameters), |
group-onsemi | 0:098463de4c5d | 959 | Case("erase single unit", test_erase<1>), |
group-onsemi | 0:098463de4c5d | 960 | Case("erase two units", test_erase<2>), |
group-onsemi | 0:098463de4c5d | 961 | Case("erase four units", test_erase<4>), |
group-onsemi | 0:098463de4c5d | 962 | Case("erase eight units", test_erase<8>), |
group-onsemi | 0:098463de4c5d | 963 | Case("program data with invalid parameters", test_programDataWithInvalidParameters), |
group-onsemi | 0:098463de4c5d | 964 | Case("program data using program_unit", test_programDataUsingProgramUnit), |
group-onsemi | 0:098463de4c5d | 965 | Case("program data using optimal_program_unit", test_programDataUsingOptimalProgramUnit), |
group-onsemi | 0:098463de4c5d | 966 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<1>), |
group-onsemi | 0:098463de4c5d | 967 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<2>), |
group-onsemi | 0:098463de4c5d | 968 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<7>), |
group-onsemi | 0:098463de4c5d | 969 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<8>), |
group-onsemi | 0:098463de4c5d | 970 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<9>), |
group-onsemi | 0:098463de4c5d | 971 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<31>), |
group-onsemi | 0:098463de4c5d | 972 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<32>), |
group-onsemi | 0:098463de4c5d | 973 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<33>), |
group-onsemi | 0:098463de4c5d | 974 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<127>), |
group-onsemi | 0:098463de4c5d | 975 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<128>), |
group-onsemi | 0:098463de4c5d | 976 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<129>), |
group-onsemi | 0:098463de4c5d | 977 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<1023>), |
group-onsemi | 0:098463de4c5d | 978 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<1024>), |
group-onsemi | 0:098463de4c5d | 979 | Case("program data with multiple program units", test_programDataWithMultipleProgramUnits<1025>), |
group-onsemi | 0:098463de4c5d | 980 | }; |
group-onsemi | 0:098463de4c5d | 981 | |
group-onsemi | 0:098463de4c5d | 982 | // Declare your test specification with a custom setup handler |
group-onsemi | 0:098463de4c5d | 983 | #ifndef AVOID_GREENTEA |
group-onsemi | 0:098463de4c5d | 984 | Specification specification(greentea_setup, cases); |
group-onsemi | 0:098463de4c5d | 985 | #else |
group-onsemi | 0:098463de4c5d | 986 | Specification specification(default_setup, cases); |
group-onsemi | 0:098463de4c5d | 987 | #endif |
group-onsemi | 0:098463de4c5d | 988 | |
group-onsemi | 0:098463de4c5d | 989 | int main(int argc, char** argv) |
group-onsemi | 0:098463de4c5d | 990 | { |
group-onsemi | 0:098463de4c5d | 991 | // Run the test specification |
group-onsemi | 0:098463de4c5d | 992 | Harness::run(specification); |
group-onsemi | 0:098463de4c5d | 993 | } |