66 lines
1.1 KiB
C
66 lines
1.1 KiB
C
#include "stm32g0xx_hal.h"
|
|
#include <easyflash.h>
|
|
#include <stdlib.h>
|
|
#include <string.h>
|
|
#include "rtthread.h"
|
|
|
|
|
|
// 获取uint32_t 的数值
|
|
uint32_t ef_get_integer(const char * key)
|
|
{
|
|
uint32_t integer = NULL;
|
|
char * value_ptr;
|
|
|
|
/* get the boot count number from Env */
|
|
value_ptr = ef_get_env (key);
|
|
|
|
integer = atoi (value_ptr);
|
|
return integer;
|
|
}
|
|
|
|
// 获取double 的数值
|
|
double ef_get_double(const char * key)
|
|
{
|
|
double ffloat = NULL;
|
|
char * value_ptr;
|
|
|
|
/* get the boot count number from Env */
|
|
value_ptr = ef_get_env (key);
|
|
|
|
ffloat = atof (value_ptr);
|
|
return ffloat;
|
|
}
|
|
|
|
// 获取字符串的数值
|
|
char * ef_get_string(const char * key)
|
|
{
|
|
char * value_ptr;
|
|
|
|
/* get the boot count number from Env */
|
|
value_ptr = ef_get_env (key);
|
|
return value_ptr;
|
|
}
|
|
|
|
|
|
// 存储无符号整
|
|
void ef_save_uint(const char* key, unsigned int value)
|
|
{
|
|
char valuebuff[128];
|
|
rt_sprintf(valuebuff, "%u", value);
|
|
ef_set_env(key, valuebuff);
|
|
ef_save_env();
|
|
}
|
|
|
|
// 存储string类型
|
|
void ef_save_string(const char* key, char* value, int size)
|
|
{
|
|
char valuebuff[128];
|
|
rt_sprintf(valuebuff, "%*.s", size, value);
|
|
//rt_kprintf("%s\r\n",valuebuff);
|
|
ef_set_env(key, valuebuff);
|
|
ef_save_env();
|
|
}
|
|
|
|
|
|
|