takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers flash_set.cpp Source File

flash_set.cpp

Go to the documentation of this file.
00001 /*
00002  * mbed Microcontroller Library
00003  * Copyright (c) 2006-2016 ARM Limited
00004  *
00005  * Licensed under the Apache License, Version 2.0 (the "License");
00006  * you may not use this file except in compliance with the License.
00007  * You may obtain a copy of the License at
00008  *
00009  *     http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  *
00017  */
00018 
00019 /** @file flash_set.cpp Test tool to set flash to some data
00020  */
00021 
00022 #include "mbed.h"
00023 #include "cfstore_config.h"
00024 #include "Driver_Common.h"
00025 #include "cfstore_debug.h"
00026 #include "cfstore_test.h"
00027 #include "configuration_store.h"
00028 #include "utest/utest.h"
00029 #include "unity/unity.h"
00030 #include "greentea-client/test_env.h"
00031 #include "cfstore_utest.h"
00032 
00033 #include <stdio.h>
00034 #include <stdlib.h>
00035 #include <string.h>
00036 #include <inttypes.h>
00037 
00038 using namespace utest::v1;
00039 
00040 
00041 
00042 
00043 /**
00044  * @brief   add ~50 KVs and store them in flash
00045  *
00046  * @return on success returns CaseNext to continue to next test case, otherwise will assert on errors.
00047  */
00048 static control_t cfstore_flash_set_test_01_end(const size_t call_count)
00049 {
00050     int32_t ret = ARM_DRIVER_ERROR;
00051     ARM_CFSTORE_FMODE flags;
00052     ARM_CFSTORE_DRIVER* drv = &cfstore_driver;
00053     ARM_CFSTORE_CAPABILITIES caps = cfstore_driver.GetCapabilities();
00054 
00055     CFSTORE_FENTRYLOG("%s:entered\n", __func__);
00056     (void) call_count;
00057     memset(&flags, 0, sizeof(flags));
00058 
00059     CFSTORE_LOG("caps.asynchronous_ops : %d\n", (int) caps.asynchronous_ops);
00060     ret = cfstore_test_init_1();
00061     if(ret < ARM_DRIVER_OK){
00062         CFSTORE_ERRLOG("%s:Error: failed to write data to falsh.", __func__);
00063     }
00064     ret = drv->Flush();
00065     if(ret < ARM_DRIVER_OK){
00066         CFSTORE_ERRLOG("%s:Flush() call failed (ret=%d).\r\n", __func__, (int) ret);
00067     }
00068 #ifdef CFSTORE_DEBUG
00069     ret = cfstore_test_dump();
00070     if(ret < ARM_DRIVER_OK){
00071         CFSTORE_ERRLOG("Error: failed to dump CFSTORE contents%s", "\n");
00072     }
00073 #endif /* CFSTORE_DEBUG */
00074     ret = drv->Uninitialize();
00075     if(ret < ARM_DRIVER_OK){
00076         CFSTORE_ERRLOG("Error: failed to Uninitialize() CFSTORE%s", "\n");
00077     }
00078     return CaseNext;
00079 }
00080 
00081 /// @cond CFSTORE_DOXYGEN_DISABLE
00082 utest::v1::status_t greentea_setup(const size_t number_of_cases)
00083 {
00084     GREENTEA_SETUP(100, "default_auto");
00085     return greentea_test_setup_handler(number_of_cases);
00086 }
00087 
00088 Case cases[] = {
00089            /*          1         2         3         4         5         6        7  */
00090            /* 1234567890123456789012345678901234567890123456789012345678901234567890 */
00091         Case("FLASH_SET_test_01_start", cfstore_utest_default_start),
00092         Case("FLASH_SET_test_01_end", cfstore_flash_set_test_01_end),
00093 };
00094 
00095 
00096 /* Declare your test specification with a custom setup handler */
00097 Specification specification(greentea_setup, cases);
00098 
00099 int main()
00100 {
00101     return !Harness::run(specification);
00102 }
00103 /// @endcond