int config_write() { int state; asm volatile ("cpsid i"); state = save_data_to_flash((unsigned long *)&g_cfg, sizeof(g_cfg) / sizeof(long) + 3); asm volatile ("cpsie i"); if (state == FLASH_WRITE_SUCCESS) return 1; return 0; }
/****************************************************************************** * FunctionName : pando_data_set * Description : set the vale of the parameter stored, if the parameter is existing. Else creat the parameter, and save it. * Parameters : key -- the parameter; value -- the value of the parameter. * Returns : the save result *******************************************************************************/ SET_RESULT pando_data_set(char* key, char* value) { struct data_pair * p; p = find_pair_by_key(key); if(p != NULL) { // key exist, update value. pd_strncpy(p->val, value, DATAPAIR_VALUE_LEN); pd_printf("key %s updated...\n", key, p->val); } else { // key not exist, create a new pair. struct data_pair * p = (struct data_pair * )pd_malloc(sizeof(struct data_pair)); pd_strncpy(p->key, key, DATAPAIR_KEY_LEN); pd_strncpy(p->val, value, DATAPAIR_VALUE_LEN); p->next = head; head = p; pd_printf("key %s created..., value %s \n", key, p->val); } save_data_to_flash(); }