takashi kadono / Mbed OS Nucleo_446

Dependencies:   ssd1331

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers platform_nvm_stub.c Source File

platform_nvm_stub.c

00001 /*
00002  * Copyright (c) 2016 ARM Limited. All rights reserved.
00003  * SPDX-License-Identifier: Apache-2.0
00004  * Licensed under the Apache License, Version 2.0 (the License); you may
00005  * 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, WITHOUT
00012  * 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 "ns_types.h"
00018 #include "platform/arm_hal_nvm.h"
00019 
00020 typedef struct {
00021     platform_nvm_status status;
00022     nvm_callback *saved_callback;
00023     void *saved_context;
00024 } test_platform_nvm_api_data;
00025 
00026 test_platform_nvm_api_data test_data = {0, NULL, NULL};
00027 
00028 
00029 void test_platform_nvm_api_set_retval(platform_nvm_status return_value)
00030 {
00031     test_data.status = return_value;
00032 }
00033 
00034 void test_platform_nvm_api_callback()
00035 {
00036     test_data.saved_callback(test_data.status, test_data.saved_context);
00037 }
00038 
00039 platform_nvm_status platform_nvm_init(nvm_callback *callback, void *context)
00040 {
00041     test_data.saved_callback = callback;
00042     test_data.saved_context = context;
00043     return test_data.status;
00044 }
00045 
00046 platform_nvm_status platform_nvm_finalize(nvm_callback *callback, void *context)
00047 {
00048     (void) callback;
00049     (void) context;
00050     return test_data.status;
00051 }
00052 
00053 platform_nvm_status platform_nvm_key_create(nvm_callback *callback, const char *key_name, uint16_t value_len, uint32_t flags, void *context)
00054 {
00055     (void) key_name;
00056     (void) value_len;
00057     (void) flags;
00058     test_data.saved_callback = callback;
00059     test_data.saved_context = context;
00060     return test_data.status;
00061 }
00062 
00063 platform_nvm_status platform_nvm_key_delete(nvm_callback *callback, const char *key_name, void *context)
00064 {
00065     (void) callback;
00066     (void) key_name;
00067     (void) context;
00068     test_data.saved_callback = callback;
00069     test_data.saved_context = context;
00070     return test_data.status;
00071 }
00072 
00073 platform_nvm_status platform_nvm_write(nvm_callback *callback, const char *key_name, const void *data, uint16_t *data_len, void *context)
00074 {
00075     (void) key_name;
00076     (void) data;
00077     (void) data_len;
00078     test_data.saved_callback = callback;
00079     test_data.saved_context = context;
00080     return test_data.status;
00081 }
00082 
00083 platform_nvm_status platform_nvm_read(nvm_callback *callback, const char *key_name, void *buf, uint16_t *buf_len, void *context)
00084 {
00085     (void) key_name;
00086     (void) buf;
00087     (void) buf_len;
00088     test_data.saved_callback = callback;
00089     test_data.saved_context = context;
00090     return test_data.status;
00091 }
00092 
00093 platform_nvm_status platform_nvm_flush(nvm_callback *callback, void *context)
00094 {
00095     (void) callback;
00096     (void) context;
00097     test_data.saved_callback = callback;
00098     test_data.saved_context = context;
00099     return test_data.status;
00100 }
00101