replaced solution of week 1 and 2, extern files added so there are no stream it snippets of code in it. added week 5 FileIO .c and .h file
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
/*Dit is de C File om aan te tonen,
|
||||
hoe je in het niet vluchtig geheugen dingen kan schrijven,
|
||||
en deze nadat je het kastje heb uitgezet weer op kan halen*/
|
||||
|
||||
#include "FileIO.h"
|
||||
|
||||
void load_user_setting(void)
|
||||
{
|
||||
NutNvMemLoad(256, &user_setting, sizeof(user_setting));
|
||||
if(user_setting.first_boot != 1) //check of er al een boot is geweest
|
||||
{
|
||||
user_setting.first_boot = 1;
|
||||
save_user_setting();
|
||||
}
|
||||
else
|
||||
{
|
||||
//doe wat met de data in de struct
|
||||
}
|
||||
}
|
||||
|
||||
void save_user_setting(void)
|
||||
{
|
||||
NutNvMemSave(256, &user_setting, sizeof(user_setting));
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
#ifndef FileIO_DEF
|
||||
#define FileIO_DEF
|
||||
|
||||
/* User settings */
|
||||
|
||||
struct User_Setting
|
||||
{
|
||||
unsigned int first_boot;
|
||||
};
|
||||
|
||||
/* Loads the user settings struct from the non-volatile memory */
|
||||
void load_user_setting(void);
|
||||
|
||||
/* Saves the user settings struct from the non-volatile memory */
|
||||
void save_user_setting(void);
|
||||
|
||||
struct User_Setting user_setting; //always loads first before using this struct
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user