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:
Remco
2016-03-30 21:34:00 +02:00
parent e46c3838ce
commit c2b96802ce
15 changed files with 43 additions and 2 deletions
+24
View File
@@ -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));
}
+19
View File
@@ -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