OSDN Git Service

RemoteMCUの更新
[mimic/MiMicSDK.git] / projects / app.RemoteMCU / src / cConfiglationStorage.c
diff --git a/projects/app.RemoteMCU/src/cConfiglationStorage.c b/projects/app.RemoteMCU/src/cConfiglationStorage.c
deleted file mode 100644 (file)
index b03024a..0000000
+++ /dev/null
@@ -1,110 +0,0 @@
-#include "NyLPC_flash.h"\r
-#include "NyLPC_httpService.h"\r
-#include "cConfiglationStorage.h"\r
-\r
-/**\r
- * Onchip flashを使ったコンフィギュレーション保存システムです。\r
- */\r
-\r
-\r
-\r
-\r
-#define IP2Int(a0,a1,a2,a3) ((0xff000000&(a0<<24))|(0x00ff0000&(a1<<16))|(0x0000ff00&(a2<<8))|(0x000000ff&(a3)))\r
-/**\r
- * コンフィギュレーションの保存セクタ\r
- */\r
-#define MIMIC_CONFIGLATION_FLASH_SECTOR 29\r
-#define MIMIC_CONFIGLATION_FLASH_SECTOR_ADDR 0x00078000\r
-\r
-/**\r
- * コンフィギュレーション値はホストオーダーで保存する。\r
- */\r
-const struct TMimicConfigulation factory_default=\r
-{\r
-       0xffffffff,\r
-       0x02010203,0x0405ffff,\r
-       IP2Int(192,168,0,39),\r
-       IP2Int(255,255,255,0),\r
-       IP2Int(192,168,0,254),\r
-       80,\r
-       0x0000FFFF\r
-};\r
-\r
-static NyLPC_TBool setUserConfigulation(void);\r
-static NyLPC_TBool hasUserConfigulation(void);\r
-\r
-/**\r
- * ユーザコンフィギュレーションを更新する。\r
- * この関数をコールするときは、割込/FreeRTOSを一時停止すること。\r
- */\r
-NyLPC_TBool cConfiglationStorage_updateConfigulation(const struct TMimicConfigulation* i_congfiglation)\r
-{\r
-       NyLPC_TcOnchipFlashWriter_t s;\r
-       NyLPC_cOnchipFlashWriter_initialize(&s);\r
-       //イレース\r
-       if(!NyLPC_cOnchipFlashWriter_elase(&s,MIMIC_CONFIGLATION_FLASH_SECTOR,MIMIC_CONFIGLATION_FLASH_SECTOR)){\r
-               NyLPC_OnErrorGoto(Error);\r
-       }\r
-       //コンフィギュレーションを書き込む。\r
-       if(!NyLPC_cOnchipFlashWriter_writeSector(&s,MIMIC_CONFIGLATION_FLASH_SECTOR,0x00000000,i_congfiglation,sizeof(struct TMimicConfigulation))){\r
-               NyLPC_OnErrorGoto(Error);\r
-       }\r
-       //ユーザコンフィギュレーションをONにする。\r
-       if(setUserConfigulation()){\r
-               NyLPC_OnErrorGoto(Error);\r
-       }\r
-       NyLPC_cOnchipFlashWriter_finalize(&s);\r
-       return NyLPC_TBool_TRUE;\r
-Error:\r
-       NyLPC_cOnchipFlashWriter_finalize(&s);\r
-       return NyLPC_TBool_FALSE;\r
-}\r
-/**\r
- * コンフィギュレーション値を返す。\r
- */\r
-const struct TMimicConfigulation* cConfiglationStorage_loadMiMicConfigulation(void)\r
-{\r
-       if(hasUserConfigulation()){\r
-               //userコンフィギュレーション読むよ\r
-               return (const struct TMimicConfigulation*)(MIMIC_CONFIGLATION_FLASH_SECTOR_ADDR);\r
-       }else{\r
-               //Userコンフィギュレーションない\r
-               return &factory_default;\r
-       }\r
-}\r
-\r
-\r
-\r
-\r
-/**\r
- * ユーザコンフィギュレーションが存在すると、true.\r
- */\r
-static NyLPC_TBool hasUserConfigulation(void)\r
-{\r
-       volatile const NyLPC_TUInt32* fast_boot=&(factory_default.fast_boot);\r
-       return (*fast_boot)!=0xffffffff;\r
-}\r
-/**\r
- * コンフィギュレーションモードを、ユーザコンフィギュレーションにセットする。\r
- */\r
-static NyLPC_TBool setUserConfigulation(void)\r
-{\r
-       const NyLPC_TUInt32* volatile fast_boot=&(factory_default.fast_boot);\r
-       NyLPC_TUInt32 data=0xFFFFFFFE;\r
-       NyLPC_TcOnchipFlashWriter_t s;\r
-\r
-       if(*fast_boot==0xffffffff){\r
-               //フラグ値のアドレスが4バイトアライメントにあるFlashメモリか確認する。\r
-               if(((NyLPC_TUInt32)fast_boot)%4==0 && (!NyLPC_cOnchipFlashWriter_isOnchipFlash(fast_boot))){\r
-                       //書き込み\r
-                       NyLPC_cOnchipFlashWriter_initialize(&s);\r
-                       NyLPC_cOnchipFlashWriter_write(&s,fast_boot,&data,4);\r
-                       NyLPC_cOnchipFlashWriter_finalize(&s);\r
-               }else{\r
-                       //しくじった\r
-                       return NyLPC_TBool_FALSE;\r
-               }\r
-       }\r
-       return NyLPC_TBool_TRUE;\r
-}\r
-\r