mirror of
https://github.com/pvvx/RTL00_WEB.git
synced 2025-07-31 20:31:05 +00:00
update
This commit is contained in:
parent
34d3652711
commit
39f77eb92b
1844 changed files with 899433 additions and 7 deletions
16
USDK/component/common/example/dct/README.txt
Normal file
16
USDK/component/common/example/dct/README.txt
Normal file
|
@ -0,0 +1,16 @@
|
|||
DCT example
|
||||
|
||||
Description:
|
||||
This example shows device configuration table API usage, and user can use DCT api to replace file system.
|
||||
|
||||
Configuration:
|
||||
1. [platform_opts.h]
|
||||
#define CONFIG_EXAMPLE_DCT 1
|
||||
|
||||
Execution:
|
||||
it will show:
|
||||
variable0: value0
|
||||
variable1: value1
|
||||
Delete variable0 success.
|
||||
Remaining amount: 61
|
||||
if DCT is correctly used.
|
85
USDK/component/common/example/dct/example_dct.c
Normal file
85
USDK/component/common/example/dct/example_dct.c
Normal file
|
@ -0,0 +1,85 @@
|
|||
#include <FreeRTOS.h>
|
||||
#include <task.h>
|
||||
#include <platform/platform_stdlib.h>
|
||||
#include <basic_types.h>
|
||||
#include <platform_opts.h>
|
||||
#include <dct/dct.h>
|
||||
|
||||
#if CONFIG_EXAMPLE_DCT
|
||||
|
||||
#define DCT_BEGIN_ADDR 0x100000 /*!< DCT begin address of flash, ex: 0x100000 = 1M */
|
||||
#define MODULE_NUM 6 /*!< max number of module */
|
||||
#define VARIABLE_NAME_SIZE 32 /*!< max size of the variable name */
|
||||
#define VARIABLE_VALUE_SIZE 32 /*!< max size of the variable value */
|
||||
|
||||
static char example_dct_module[] = "dct_test_module";
|
||||
static char example_dct_variable0[] = "variable0";
|
||||
static char example_dct_variable1[] = "variable1";
|
||||
static char example_dct_value0[] = "value0";
|
||||
static char example_dct_value1[] = "value1";
|
||||
|
||||
void example_dct_thread(void* param){
|
||||
int32_t ret = -1;
|
||||
dct_handle_t dct_handle;
|
||||
char value[16];
|
||||
|
||||
// format DCT, use for the first time
|
||||
ret = dct_format(DCT_BEGIN_ADDR, MODULE_NUM, VARIABLE_NAME_SIZE, VARIABLE_VALUE_SIZE, 1);
|
||||
|
||||
// initial DCT
|
||||
ret = dct_init(DCT_BEGIN_ADDR);
|
||||
|
||||
// register module
|
||||
ret = dct_register_module(example_dct_module);
|
||||
|
||||
// open module
|
||||
ret = dct_open_module(&dct_handle, example_dct_module);
|
||||
|
||||
if(ret == DCT_SUCCESS){
|
||||
// set test variable 0
|
||||
ret = dct_set_variable(&dct_handle, example_dct_variable0, example_dct_value0);
|
||||
|
||||
// set test variable 1
|
||||
ret = dct_set_variable(&dct_handle, example_dct_variable1, example_dct_value1);
|
||||
|
||||
// get value of test variable 0
|
||||
memset(value, 0, sizeof(value));
|
||||
ret = dct_get_variable(&dct_handle, example_dct_variable0, value, sizeof(value));
|
||||
if(ret == DCT_SUCCESS)
|
||||
printf("%s: %s\n", example_dct_variable0, value);
|
||||
|
||||
// get value of test variable 1
|
||||
memset(value, 0, sizeof(value));
|
||||
ret = dct_get_variable(&dct_handle, example_dct_variable1, value, sizeof(value));
|
||||
if(ret == DCT_SUCCESS)
|
||||
printf("%s: %s\n", example_dct_variable1, value);
|
||||
|
||||
// delete test variable 0
|
||||
ret = dct_delete_variable(&dct_handle, example_dct_variable0);
|
||||
|
||||
// get value of test variable 0
|
||||
memset(value, 0, sizeof(value));
|
||||
ret = dct_get_variable(&dct_handle, example_dct_variable0, value, sizeof(value));
|
||||
if(ret == DCT_ERR_NOT_FIND)
|
||||
printf("Delete %s success.\n", example_dct_variable0);
|
||||
|
||||
// get variable remaining amount
|
||||
ret = dct_remain_variable(&dct_handle);
|
||||
if(ret > 0)
|
||||
printf("Remaining variable amount:%d\n", ret);
|
||||
|
||||
// close module
|
||||
ret = dct_close_module(&dct_handle);
|
||||
}
|
||||
|
||||
vTaskDelete(NULL);
|
||||
}
|
||||
|
||||
|
||||
void example_dct(void)
|
||||
{
|
||||
if(xTaskCreate(example_dct_thread, ((const char*)"example_dct_thread"), 1024, NULL, tskIDLE_PRIORITY + 1, NULL) != pdPASS)
|
||||
printf("\n\r%s xTaskCreate(example_dct_thread) failed", __FUNCTION__);
|
||||
}
|
||||
|
||||
#endif // #if CONFIG_DCT
|
7
USDK/component/common/example/dct/example_dct.h
Normal file
7
USDK/component/common/example/dct/example_dct.h
Normal file
|
@ -0,0 +1,7 @@
|
|||
#ifndef _EXAMPLE_DCT_H
|
||||
#define _EXAMPLE_DCT_H
|
||||
|
||||
void example_dct(void);
|
||||
|
||||
#endif /* _EXAMPLE_DCT_H */
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue