app_flash - 副本 (3) - 副本.c 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. #include "app_flash.h"
  2. #include "bsp_wdt.h"
  3. #include "exception.h"
  4. #include "system.h"
  5. #include "hal_minifds.h"
  6. #include "nrf_sdh_soc.h"
  7. #include "app_step.h"
  8. #include "nrf_pwr_mgmt.h"
  9. #include "bsp_flash.h"
  10. /*************************************
  11. *DEFINITION
  12. */
  13. #define FLASH_HEAD 0xAA5555AA
  14. #define FLASH_START_ADDR_INFOR 0x00074000UL
  15. #define FLASH_END_ADDR_INFOR 0x00076000UL
  16. #define FLASH_ADDR_INFOR_PAGENUM 2
  17. #define FLASH_START_ADDR_STEP 0x00076000UL
  18. #define FLASH_END_ADDR_STEP 0x00077FFFUL
  19. #define FLASH_ADDR_STEP_PAGENUM 2
  20. #define MaxLength(a,b) a>b?a:b
  21. typedef struct t_mflash_param_type{
  22. const char *name; //参数名字
  23. void *value; //数据指针
  24. const uint8_t length; //数据长度
  25. }mflash_param_type;
  26. #define MAX_mflash_param_LENGTH 28
  27. const mflash_param_type All_Falsh_value[MAX_mflash_param_LENGTH]={
  28. {"inforhead",&mFlash.head,4},//不可调整
  29. {"ErrStartCnt",&mFlash.ErrStartCnt,1},
  30. {"macHost",mFlash.macHost,6},
  31. {"IsHost",&mFlash.isHost,1},
  32. {"startTime",mFlash.mStep.startTime,8},
  33. {"stepCur",mFlash.mStep.stepCur,8},
  34. {"step",mFlash.mStep.step,8},
  35. {"step_num",&mFlash.mStep.step_num,4},
  36. {"C_isConfig",&mFlash.mClient.isConfig,1},
  37. {"C_hard",&mFlash.mClient.hardVersion,4},
  38. {"C_sotf",&mFlash.mClient.sotfVersion,2},
  39. {"C_macAddr",&mFlash.mClient.macAddr,6},
  40. {"Errorflag",&mFlash.mFlashLog.Errorflag,1},
  41. {"logData",mFlash.mFlashLog.logData,50},
  42. {"PB_BR_V2E",&mFlash.mbattercb_t.preBestResult_Voltage2power,4},
  43. {"PB_BR_C2P",&mFlash.mbattercb_t.preBestResult_chargeV2P_f,4},
  44. {"PB_P_MAH",&mFlash.mbattercb_t.P_mAh,4},
  45. {"PB_KG", &mFlash.mbattercb_t.kg,4},
  46. {"PP2", &mFlash.mbattercb_t.P2,4},
  47. {"PP1", &mFlash.mbattercb_t.P1,4},
  48. {"PCAP_MAH",&mFlash.mbattercb_t.Battery_capacity_mAh,4},
  49. {"PTP4056",&mFlash.mbattercb_t.adc_tp4056_power,4},
  50. {"PINIT", &mFlash.mbattercb_t.init,1},
  51. {"PSTA", &mFlash.mbattercb_t.sta,1},
  52. {"PCV2P_INIT",&mFlash.mbattercb_t.chargeV2P_f_init,1},
  53. {"PV2P_INIT",&mFlash.mbattercb_t.Voltage2power_init,1},
  54. {"Safe_cnt",&mFlash.Safe_cnt,1},
  55. {"RestartCnt",&mFlash.RestartCnt,1}
  56. };
  57. DEFINE_MINIINF(information, FLASH_START_ADDR_INFOR, FLASH_END_ADDR_INFOR, sdflash_write, sdflash_page_erase);
  58. Flash_t mFlash={0};
  59. const uint8_t oldflashdata[] ={
  60. 0x01,0X00,0XE8,0X0E,0X69,0X6E,0X66,0X6F,0X72,0X68,0X65,0X61,0X64,0X3A,0XAA,0X55,0X55,0XAA,0X00,0X00,0X00,0X00,0X09,0X0E,0X6D,0X61,0X63,0X48,0X6F,0X73,0X74,0X3A,
  61. 0x00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X03,0X00,0X95,0X08,0X49,0X73,0X48,0X6F,0X73,0X74,0X3A,0X01,0X00,0X00,0XF7,0X12,0X73,0X74,0X61,0X72,0X74,0X54,0X69,0X6D,
  62. 0x65,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X20,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
  63. 0x00,0X00,0XF6,0X0D,0X73,0X74,0X65,0X70,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XA5,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  64. 0x3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X0E,0X0C,0X43,0X5F,0X69,0X73,0X43,0X6F,0X6E,0X66,0X69,0X67,0X3A,0X00,0X00,0X00,0X7B,0X0B,0X43,0X5F,0X68,0X61,
  65. 0x72,0X64,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X98,0X09,0X43,0X5F,0X73,0X6F,0X74,0X66,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X88,0X10,0X43,0X5F,0X6D,0X61,
  66. 0x63,0X41,0X64,0X64,0X72,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X0C,0X00,0XDE,0X0B,0X45,0X72,0X72,0X6F,0X72,0X66,0X6C,0X61,0X67,0X3A,0X00,0X00,0X0D,0X00,0XF6,0X3A,
  67. 0x6C,0X6F,0X67,0X44,0X61,0X74,0X61,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
  68. 0x00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X20,0X00,0X00,0XEB,0X0E,
  69. 0x50,0X42,0X5F,0X42,0X52,0X5F,0X56,0X32,0X45,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XE3,0X0E,0X50,0X42,0X5F,0X42,0X52,0X5F,0X43,0X32,0X50,0X3A,0X00,0X00,
  70. 0x00,0X00,0X00,0X00,0X00,0X00,0XB0,0X0D,0X50,0X42,0X5F,0X50,0X5F,0X4D,0X41,0X48,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XBD,0X0A,0X50,0X42,0X5F,0X4B,
  71. 0x47,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X0C,0X08,0X50,0X50,0X32,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X0B,0X08,0X50,0X50,0X31,0X3A,0X00,0X00,0X00,0X00,
  72. 0x00,0X00,0X93,0X0D,0X50,0X43,0X41,0X50,0X5F,0X4D,0X41,0X48,0X3A,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XFD,0X0C,0X50,0X54,0X50,0X34,0X30,0X35,0X36,0X3A,
  73. 0x00,0X00,0X00,0X00,0X00,0X00,0XBE,0X07,0X50,0X49,0X4E,0X49,0X54,0X3A,0X00,0X3A,0X00,0X00,0X72,0X06,0X50,0X53,0X54,0X41,0X3A,0X00,0X00,0X3A,0X00,0X00,0X38,0X0C,
  74. 0x50,0X43,0X56,0X32,0X50,0X5F,0X49,0X4E,0X49,0X54,0X3A,0X00,0X19,0X00,0XF5,0X0B,0X50,0X56,0X32,0X50,0X5F,0X49,0X4E,0X49,0X54,0X3A,0X00,0X00,0X1A,0X00,0X5D,0X0A,
  75. 0x53,0X61,0X66,0X65,0X5F,0X63,0X6E,0X74,0X3A,0X00,0X00,0X00,0X00,0X00,0X44,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X00,0X02,0X00,0X57,0X0E,
  76. 0x6D,0X61,0X63,0X48,0X6F,0X73,0X74,0X3A,0X4B,0X1E,0X15,0X45,0XAA,0XE1,0X00,0X20,0X08,0X00,0X51,0X0C,0X43,0X5F,0X69,0X73,0X43,0X6F,0X6E,0X66,0X69,0X67,0X3A,0X43,
  77. 0x00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X45,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,
  78. 0x6E,0X74,0X3A,0X01,0X00,0X00,0XE6,0X12,0X73,0X74,0X61,0X72,0X74,0X54,0X69,0X6D,0X65,0X3A,0X00,0X00,0X01,0X81,0X66,0XCE,0X39,0X00,0X04,0X00,0X00,0X00,0X55,0X10,
  79. 0x73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,0X6C,0X03,0X00,0X00,0XAD,0X19,0X00,0X00,0X00,0X00,0X2B,0X0D,0X73,0X74,0X65,0X70,0X3A,0X6C,0X03,0X00,0X00,0XAD,0X19,0X00,
  80. 0x00,0X19,0X00,0X00,0X00,0X00,0XA6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X01,0X00,0X00,0X00,0X19,0X00,0X00,0X09,0X00,0X7F,0X0B,0X43,0X5F,0X68,0X61,
  81. 0x72,0X64,0X3A,0X01,0X02,0X01,0X00,0X43,0X0A,0X00,0X99,0X09,0X43,0X5F,0X73,0X6F,0X74,0X66,0X3A,0X01,0X00,0X01,0X00,0X43,0X00,0X00,0X74,0X10,0X43,0X5F,0X6D,0X61,
  82. 0x63,0X41,0X64,0X64,0X72,0X3A,0XC4,0X96,0X94,0X5F,0X18,0X87,0X00,0X00,0X12,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,0X8E,0X05,0X00,0X00,0X44,0X1B,0X00,0X00,
  83. 0x00,0X00,0XE8,0X0D,0X73,0X74,0X65,0X70,0X3A,0X8E,0X05,0X00,0X00,0X44,0X1B,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XA5,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,
  84. 0xDC,0X05,0X00,0X00,0X89,0X1B,0X00,0X00,0X00,0X00,0X7B,0X0D,0X73,0X74,0X65,0X70,0X3A,0XDC,0X05,0X00,0X00,0X89,0X1B,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XA7,0X0D,
  85. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X02,0X00,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XA8,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X03,0X00,0X00,
  86. 0x00,0X1B,0X00,0X00,0X00,0X00,0XA9,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X04,0X00,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XAA,0X0D,0X73,0X74,0X65,0X70,
  87. 0x5F,0X6E,0X75,0X6D,0X3A,0X05,0X00,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XAB,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X06,0X00,0X00,0X00,0X1B,0X00,0X00,
  88. 0x00,0X00,0XAC,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X07,0X00,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XAD,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  89. 0x3A,0X08,0X00,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XAE,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X09,0X00,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XAF,0X0D,
  90. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0A,0X00,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XB0,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0B,0X00,0X00,
  91. 0x00,0X1B,0X00,0X00,0X00,0X00,0XB1,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0C,0X00,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XB2,0X0D,0X73,0X74,0X65,0X70,
  92. 0x5F,0X6E,0X75,0X6D,0X3A,0X0D,0X00,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0XB3,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0E,0X00,0X00,0X00,0X1B,0X00,0X00,
  93. 0x00,0X00,0XB4,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0F,0X00,0X00,0X00,0X1B,0X00,0X00,0X00,0X00,0X0D,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,
  94. 0xD1,0X07,0X00,0X00,0XF9,0X1C,0X00,0X00,0X00,0X00,0XE3,0X0D,0X73,0X74,0X65,0X70,0X3A,0XD1,0X07,0X00,0X00,0XF9,0X1C,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XB5,0X0D,
  95. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X10,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0X41,0X12,0X73,0X74,0X61,0X72,0X74,0X54,0X69,0X6D,0X65,0X3A,0X00,0X00,
  96. 0x01,0X81,0X6A,0X3D,0X21,0X00,0X04,0X00,0X00,0X00,0X17,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,0XD7,0X07,0X00,0X00,0XFD,0X1C,0X00,0X00,0X00,0X00,0XED,0X0D,
  97. 0x73,0X74,0X65,0X70,0X3A,0XD7,0X07,0X00,0X00,0XFD,0X1C,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XA6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X01,0X00,0X00,
  98. 0x00,0X1C,0X00,0X00,0X00,0X00,0XA7,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X02,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XA8,0X0D,0X73,0X74,0X65,0X70,
  99. 0x5F,0X6E,0X75,0X6D,0X3A,0X03,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XA9,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X04,0X00,0X00,0X00,0X1C,0X00,0X00,
  100. 0x00,0X00,0XAA,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X05,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XAB,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  101. 0x3A,0X06,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XAC,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X07,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XAD,0X0D,
  102. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X08,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XAE,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X09,0X00,0X00,
  103. 0x00,0X1C,0X00,0X00,0X00,0X00,0XAF,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0A,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XB0,0X0D,0X73,0X74,0X65,0X70,
  104. 0x5F,0X6E,0X75,0X6D,0X3A,0X0B,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XB1,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0C,0X00,0X00,0X00,0X1C,0X00,0X00,
  105. 0x00,0X00,0XB2,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0D,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XB3,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  106. 0x3A,0X0E,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XB4,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0F,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XB5,0X0D,
  107. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X10,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XB6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X11,0X00,0X00,
  108. 0x00,0X1C,0X00,0X00,0X00,0X00,0XB7,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X12,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XB8,0X0D,0X73,0X74,0X65,0X70,
  109. 0x5F,0X6E,0X75,0X6D,0X3A,0X13,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XB9,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X14,0X00,0X00,0X00,0X1C,0X00,0X00,
  110. 0x00,0X00,0XBA,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X15,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XBB,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  111. 0x3A,0X16,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XBC,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X17,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XBD,0X0D,
  112. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X18,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XBE,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X19,0X00,0X00,
  113. 0x00,0X1C,0X00,0X00,0X00,0X00,0XBF,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X1A,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XB1,0X0E,0X50,0X42,0X5F,0X42,
  114. 0x52,0X5F,0X56,0X32,0X45,0X3A,0X0C,0XC2,0XB5,0X43,0X00,0X00,0X00,0X00,0X7C,0X0A,0X50,0X42,0X5F,0X4B,0X47,0X3A,0X00,0X00,0X80,0X3F,0X00,0X00,0X00,0X00,0X7A,0X08,
  115. 0x50,0X50,0X32,0X3A,0X30,0X08,0XF5,0X41,0X00,0X00,0XCA,0X08,0X50,0X50,0X31,0X3A,0XA0,0XEA,0XF4,0X41,0X00,0X00,0XBC,0X0C,0X50,0X54,0X50,0X34,0X30,0X35,0X36,0X3A,
  116. 0xA0,0XEA,0XF4,0X41,0X16,0X00,0XC1,0X07,0X50,0X49,0X4E,0X49,0X54,0X3A,0X03,0X3A,0X17,0X00,0X73,0X06,0X50,0X53,0X54,0X41,0X3A,0X01,0X03,0X3A,0X00,0X00,0X39,0X0C,
  117. 0x50,0X43,0X56,0X32,0X50,0X5F,0X49,0X4E,0X49,0X54,0X3A,0X01,0X00,0X00,0X44,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X00,0X00,0X00,0X73,0X10,
  118. 0x43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X45,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X01,
  119. 0x00,0X00,0X6D,0X12,0X73,0X74,0X61,0X72,0X74,0X54,0X69,0X6D,0X65,0X3A,0X00,0X00,0X01,0X81,0X6F,0X9A,0X6B,0X80,0X00,0X00,0X00,0X00,0XA5,0X0D,0X73,0X74,0X65,0X70,
  120. 0x5F,0X6E,0X75,0X6D,0X3A,0X00,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0X67,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,
  121. 0x00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X67,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,
  122. 0x72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,0X00,0X00,0XE2,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,0XD7,0X07,0X00,0X00,0XE0,0X04,0X00,0X00,0X00,0X00,0X73,0X10,
  123. 0x43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X17,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,0XD7,0X07,0X00,0X00,
  124. 0xFD,0X1C,0X00,0X00,0X00,0X00,0X67,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,0X00,0X00,0XE2,0X10,0X73,0X74,0X65,0X70,
  125. 0x43,0X75,0X72,0X3A,0XD7,0X07,0X00,0X00,0XE0,0X04,0X00,0X00,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,
  126. 0x00,0X00,0X17,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,0XD7,0X07,0X00,0X00,0XFD,0X1C,0X00,0X00,0X00,0X00,0XA6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  127. 0x3A,0X01,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0X98,0X0E,0X50,0X42,0X5F,0X42,0X52,0X5F,0X56,0X32,0X45,0X3A,0X72,0X43,0XB5,0X43,0X00,0X00,0X00,0X00,0X15,0X08,
  128. 0x50,0X50,0X32,0X3A,0XC8,0X0D,0XF3,0X41,0X00,0X00,0XC6,0X08,0X50,0X50,0X31,0X3A,0XC4,0XC5,0XF1,0X41,0X00,0X00,0XB8,0X0C,0X50,0X54,0X50,0X34,0X30,0X35,0X36,0X3A,
  129. 0xC4,0XC5,0XF1,0X41,0X00,0X00,0X44,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X00,0X00,0X00,0X67,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,
  130. 0x72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,0X00,0X00,0X45,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X01,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,
  131. 0x63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X67,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,
  132. 0x00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X67,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,
  133. 0x72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X67,0X10,
  134. 0x43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,
  135. 0xFF,0X94,0X96,0XC4,0X00,0X00,0X67,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,
  136. 0x63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X67,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,
  137. 0x00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X67,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,
  138. 0x72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X67,0X10,
  139. 0x43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0XE2,0X3A,0XC6,0X00,0X00,0XA7,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X02,0X00,0X00,
  140. 0x00,0X1C,0X00,0X00,0X00,0X00,0XA8,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X03,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,
  141. 0x63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X5F,0X12,0X73,0X74,0X61,0X72,0X74,0X54,0X69,0X6D,0X65,0X3A,0X00,0X00,0X01,0X81,0X70,0X3F,
  142. 0x37,0X00,0X04,0X00,0X00,0X00,0X18,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,0XD7,0X07,0X00,0X00,0XFE,0X1C,0X00,0X00,0X00,0X00,0XEE,0X0D,0X73,0X74,0X65,0X70,
  143. 0x3A,0XD7,0X07,0X00,0X00,0XFE,0X1C,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XA6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X01,0X00,0X00,0X00,0X1C,0X00,0X00,
  144. 0x00,0X00,0X74,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XC4,0X96,0X94,0X5F,0X18,0X87,0X00,0X00,0X56,0X0E,0X50,0X42,0X5F,0X42,0X52,0X5F,0X56,0X32,
  145. 0x45,0X3A,0XD0,0XA4,0XB4,0X43,0X00,0X00,0X00,0X00,0X1D,0X0E,0X50,0X42,0X5F,0X42,0X52,0X5F,0X43,0X32,0X50,0X3A,0X6E,0XD0,0XB9,0X43,0X00,0X00,0X00,0X00,0XD3,0X0D,
  146. 0x50,0X42,0X5F,0X50,0X5F,0X4D,0X41,0X48,0X3A,0XD7,0X5F,0XAC,0X41,0X43,0X00,0X00,0X00,0X00,0X10,0X08,0X50,0X50,0X32,0X3A,0X40,0X93,0XF0,0X41,0X00,0X00,0X2E,0X08,
  147. 0x50,0X50,0X31,0X3A,0XD7,0X5F,0XAC,0X41,0X00,0X00,0X1A,0X0D,0X50,0X43,0X41,0X50,0X5F,0X4D,0X41,0X48,0X3A,0XDC,0XD3,0X96,0X42,0X43,0X00,0X00,0X00,0X00,0X20,0X0C,
  148. 0x50,0X54,0X50,0X34,0X30,0X35,0X36,0X3A,0XD7,0X5F,0XAC,0X41,0X18,0X00,0X38,0X0C,0X50,0X43,0X56,0X32,0X50,0X5F,0X49,0X4E,0X49,0X54,0X3A,0X00,0X00,0X00,0X44,0X0C,
  149. 0x52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X00,0X00,0X00,0XA7,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X02,0X00,0X00,0X00,0X1C,0X00,0X00,
  150. 0x00,0X00,0X45,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X01,0X00,0X00,0X7B,0X0E,0X50,0X42,0X5F,0X42,0X52,0X5F,0X56,0X32,0X45,0X3A,0XFB,0X9E,
  151. 0xB4,0X43,0X00,0X00,0X00,0X00,0XA4,0X08,0X50,0X50,0X32,0X3A,0XEC,0X7B,0XF0,0X41,0X00,0X00,0X44,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X00,
  152. 0x00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X45,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,
  153. 0x6E,0X74,0X3A,0X01,0X00,0X00,0XA6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X01,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0X74,0X10,0X43,0X5F,0X6D,0X61,
  154. 0x63,0X41,0X64,0X64,0X72,0X3A,0XC4,0X96,0X94,0X5F,0X18,0X87,0X00,0X00,0XA7,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X02,0X00,0X00,0X00,0X1C,0X00,0X00,
  155. 0x00,0X00,0XDB,0X0E,0X50,0X42,0X5F,0X42,0X52,0X5F,0X56,0X32,0X45,0X3A,0XD7,0X22,0XB4,0X43,0X00,0X00,0X00,0X00,0XA7,0X0E,0X50,0X42,0X5F,0X42,0X52,0X5F,0X43,0X32,
  156. 0x50,0X3A,0X02,0XC6,0XB9,0X43,0X00,0X00,0X00,0X00,0X7F,0X0D,0X50,0X42,0X5F,0X50,0X5F,0X4D,0X41,0X48,0X3A,0X46,0X9C,0XAC,0X41,0X43,0X00,0X00,0X11,0X00,0XBD,0X0A,
  157. 0x50,0X42,0X5F,0X4B,0X47,0X3A,0X00,0X00,0X00,0X00,0X9C,0XAC,0X00,0X00,0X2F,0X08,0X50,0X50,0X32,0X3A,0X10,0X2B,0XA7,0X41,0X00,0X00,0X74,0X08,0X50,0X50,0X31,0X3A,
  158. 0x15,0X6D,0XA6,0X41,0X00,0X00,0X31,0X0D,0X50,0X43,0X41,0X50,0X5F,0X4D,0X41,0X48,0X3A,0XBD,0X08,0X97,0X42,0X43,0X00,0X00,0X00,0X00,0X66,0X0C,0X50,0X54,0X50,0X34,
  159. 0x30,0X35,0X36,0X3A,0X15,0X6D,0XA6,0X41,0X00,0X00,0X44,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X00,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,
  160. 0x63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X45,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X01,0X00,0X00,0XC2,0X10,
  161. 0x43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X0F,0X61,0XCD,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,
  162. 0xFF,0X94,0X96,0XC4,0X00,0X00,0XC2,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X0F,0X61,0XCD,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,
  163. 0x63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X04,0X00,0X04,0X12,0X73,0X74,0X61,0X72,0X74,0X54,0X69,0X6D,0X65,0X3A,0X00,0X00,0X01,0X81,0X70,0X76,
  164. 0x25,0X80,0X00,0X00,0X00,0X00,0XA5,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X00,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0XC2,0X10,0X43,0X5F,0X6D,0X61,
  165. 0x63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X0F,0X61,0XCD,0X00,0X00,0XFE,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,0XD7,0X07,0X00,0X00,0X00,0X00,0X00,0X00,
  166. 0x00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X18,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,
  167. 0xD7,0X07,0X00,0X00,0XFE,0X1C,0X00,0X00,0X00,0X00,0XA6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X01,0X00,0X00,0X00,0X1C,0X00,0X00,0X00,0X00,0X74,0X10,
  168. 0x43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XC4,0X96,0X94,0X5F,0X18,0X87,0X00,0X00,0X02,0X0E,0X50,0X42,0X5F,0X42,0X52,0X5F,0X56,0X32,0X45,0X3A,0X40,0XE1,
  169. 0xB3,0X43,0X00,0X00,0X00,0X00,0XD1,0X0E,0X50,0X42,0X5F,0X42,0X52,0X5F,0X43,0X32,0X50,0X3A,0X67,0X8B,0XB9,0X43,0X00,0X00,0X00,0X00,0XD9,0X0D,0X50,0X42,0X5F,0X50,
  170. 0x5F,0X4D,0X41,0X48,0X3A,0X96,0XAC,0XA6,0X41,0X43,0X00,0X00,0X00,0X00,0XAD,0X08,0X50,0X50,0X32,0X3A,0X25,0X95,0XA6,0X41,0X00,0X00,0XAC,0X08,0X50,0X50,0X31,0X3A,
  171. 0x25,0X95,0XA6,0X41,0X00,0X00,0X8B,0X0D,0X50,0X43,0X41,0X50,0X5F,0X4D,0X41,0X48,0X3A,0X86,0X9A,0X96,0X42,0X43,0X00,0X00,0X00,0X00,0X9E,0X0C,0X50,0X54,0X50,0X34,
  172. 0x30,0X35,0X36,0X3A,0X25,0X95,0XA6,0X41,0X00,0X00,0X44,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X00,0X00,0X00,0X73,0X10,0X43,0X5F,0X6D,0X61,
  173. 0x63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,0XFF,0X94,0X96,0XC4,0X00,0X00,0X45,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X01,0X00,0X00,0X74,0X10,
  174. 0x43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XC4,0X96,0X94,0X5F,0X18,0X87,0X0B,0X00,0X67,0X10,0X43,0X5F,0X6D,0X61,0X63,0X41,0X64,0X64,0X72,0X3A,0XFF,0XFF,
  175. 0xFF,0XE2,0X3A,0XC6,0X05,0X00,0XE2,0X10,0X73,0X74,0X65,0X70,0X43,0X75,0X72,0X3A,0XD7,0X07,0X00,0X00,0XE0,0X04,0X00,0X00,0X06,0X00,0XB8,0X0D,0X73,0X74,0X65,0X70,
  176. 0x3A,0XD7,0X07,0X00,0X00,0XE0,0X04,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XA7,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X02,0X00,0X00,0X00,0X04,0X00,0X00,
  177. 0x00,0X00,0XA8,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X03,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XA9,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  178. 0x3A,0X04,0X00,0X00,0X00,0X04,0X00,0X00,0X0E,0X00,0X5B,0X0E,0X50,0X42,0X5F,0X42,0X52,0X5F,0X56,0X32,0X45,0X3A,0X60,0X02,0XCB,0X43,0X00,0X00,0X0F,0X00,0X9C,0X0E,
  179. 0x50,0X42,0X5F,0X42,0X52,0X5F,0X43,0X32,0X50,0X3A,0X05,0XA0,0XD1,0X43,0X00,0X00,0X10,0X00,0X9B,0X0D,0X50,0X42,0X5F,0X50,0X5F,0X4D,0X41,0X48,0X3A,0X1A,0XC6,0XC9,
  180. 0x42,0X43,0X00,0X00,0X12,0X00,0XA7,0X08,0X50,0X50,0X32,0X3A,0XC9,0XDC,0XB4,0X42,0X13,0X00,0X06,0X08,0X50,0X50,0X31,0X3A,0X29,0XDC,0XB4,0X42,0X14,0X00,0X6E,0X0D,
  181. 0x50,0X43,0X41,0X50,0X5F,0X4D,0X41,0X48,0X3A,0X9F,0X5B,0X9E,0X43,0X43,0X00,0X00,0X15,0X00,0XF8,0X0C,0X50,0X54,0X50,0X34,0X30,0X35,0X36,0X3A,0X29,0XDC,0XB4,0X42,
  182. 0x00,0X00,0X44,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X00,0X00,0X00,0XAA,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X05,0X00,0X00,
  183. 0x00,0X04,0X00,0X00,0X1B,0X00,0X45,0X0C,0X52,0X65,0X73,0X74,0X61,0X72,0X74,0X43,0X6E,0X74,0X3A,0X01,0X00,0X00,0XAB,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  184. 0x3A,0X06,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XAC,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X07,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XAD,0X0D,
  185. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X08,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XAE,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X09,0X00,0X00,
  186. 0x00,0X04,0X00,0X00,0X00,0X00,0XAF,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0A,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XB0,0X0D,0X73,0X74,0X65,0X70,
  187. 0x5F,0X6E,0X75,0X6D,0X3A,0X0B,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XB1,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0C,0X00,0X00,0X00,0X04,0X00,0X00,
  188. 0x00,0X00,0XB2,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0D,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XB3,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  189. 0x3A,0X0E,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XB4,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X0F,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XB5,0X0D,
  190. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X10,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XB6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X11,0X00,0X00,
  191. 0x00,0X04,0X00,0X00,0X00,0X00,0XB7,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X12,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XB8,0X0D,0X73,0X74,0X65,0X70,
  192. 0x5F,0X6E,0X75,0X6D,0X3A,0X13,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XB9,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X14,0X00,0X00,0X00,0X04,0X00,0X00,
  193. 0x00,0X00,0XBA,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X15,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XBB,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  194. 0x3A,0X16,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XBC,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X17,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XBD,0X0D,
  195. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X18,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XBE,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X19,0X00,0X00,
  196. 0x00,0X04,0X00,0X00,0X00,0X00,0XBF,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X1A,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XC0,0X0D,0X73,0X74,0X65,0X70,
  197. 0x5F,0X6E,0X75,0X6D,0X3A,0X1B,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XC1,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X1C,0X00,0X00,0X00,0X04,0X00,0X00,
  198. 0x00,0X00,0XC2,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X1D,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XC3,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  199. 0x3A,0X1E,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XC4,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X1F,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XC5,0X0D,
  200. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X20,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XC6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X21,0X00,0X00,
  201. 0x00,0X04,0X00,0X00,0X00,0X00,0XC7,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X22,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XC8,0X0D,0X73,0X74,0X65,0X70,
  202. 0x5F,0X6E,0X75,0X6D,0X3A,0X23,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XC9,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X24,0X00,0X00,0X00,0X04,0X00,0X00,
  203. 0x00,0X00,0XCA,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X25,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XCB,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  204. 0x3A,0X26,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XCC,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X27,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XCD,0X0D,
  205. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X28,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XCE,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X29,0X00,0X00,
  206. 0x00,0X04,0X00,0X00,0X00,0X00,0XCF,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X2A,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XD0,0X0D,0X73,0X74,0X65,0X70,
  207. 0x5F,0X6E,0X75,0X6D,0X3A,0X2B,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XD1,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X2C,0X00,0X00,0X00,0X04,0X00,0X00,
  208. 0x00,0X00,0XD2,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X2D,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XD3,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  209. 0x3A,0X2E,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XD4,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X2F,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XD5,0X0D,
  210. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X30,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XD6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X31,0X00,0X00,
  211. 0x00,0X04,0X00,0X00,0X00,0X00,0XD7,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X32,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XD8,0X0D,0X73,0X74,0X65,0X70,
  212. 0x5F,0X6E,0X75,0X6D,0X3A,0X33,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XD9,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X34,0X00,0X00,0X00,0X04,0X00,0X00,
  213. 0x00,0X00,0XDA,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X35,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XDB,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  214. 0x3A,0X36,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XDC,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X37,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XDD,0X0D,
  215. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X38,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XDE,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X39,0X00,0X00,
  216. 0x00,0X04,0X00,0X00,0X00,0X00,0XDF,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X3A,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XE0,0X0D,0X73,0X74,0X65,0X70,
  217. 0x5F,0X6E,0X75,0X6D,0X3A,0X3B,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XE1,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X3C,0X00,0X00,0X00,0X04,0X00,0X00,
  218. 0x00,0X00,0XE2,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X3D,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XE3,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,
  219. 0x3A,0X3E,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XE4,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X3F,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XE5,0X0D,
  220. 0x73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X40,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XE6,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X41,0X00,0X00,
  221. 0x00,0X04,0X00,0X00,0X00,0X00,0XE7,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X42,0X00,0X00,0X00,0X04,0X00,0X00,0X00,0X00,0XE8,0X0D,0X73,0X74,0X65,0X70,
  222. 0x5F,0X6E,0X75,0X6D,0X3A,0X43,0X00,0X00,0X00,0X04,0X00,0X00,0X07,0X00,0XE9,0X0D,0X73,0X74,0X65,0X70,0X5F,0X6E,0X75,0X6D,0X3A,0X44,0X00,0X00,0X00,0X04,0X00,0X00,
  223. };
  224. /****************************************************接口****************************************************/
  225. void Flash_Initialize(void)
  226. {
  227. uint16_t i = 0;
  228. uint8_t length =0;
  229. minfds_init(&information);
  230. //读取文件头
  231. i=0;
  232. if(MINIFDS_SUCCESS == pm_get_length(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),&length)){
  233. if(length == All_Falsh_value[i].length){
  234. pm_find(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),(uint8_t *)All_Falsh_value[i].value,&length);
  235. }
  236. }
  237. DEBUG_LOG("Flash head read(%04X).\n",mFlash.head);
  238. if(mFlash.head !=FLASH_HEAD){ DEBUG_LOG("Flash first init(%04X),write infomation to flash.\n",mFlash.head);
  239. Flash_DeleteAllInfor();
  240. Flash_DeleteAllStep();
  241. memset((uint8_t*)(&mFlash),0,sizeof(Flash_t));
  242. uint32_t flash_data;
  243. mFlash.head = FLASH_HEAD;
  244. mFlash.isHost = _IS_HOST;
  245. for(i =0;i<MAX_mflash_param_LENGTH;i++){
  246. pm_add(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),(uint8_t *)All_Falsh_value[i].value,All_Falsh_value[i].length);
  247. }
  248. mFlash.head =0;
  249. for(i =0;i<MAX_mflash_param_LENGTH;i++){
  250. if(MINIFDS_SUCCESS == pm_get_length(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),&length)){
  251. if(length == All_Falsh_value[i].length)
  252. {
  253. pm_find(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),(uint8_t *)All_Falsh_value[i].value,&length);
  254. }
  255. }
  256. }
  257. //
  258. DEBUG_LOG("Flash head second read(%04X).\n",mFlash.head);
  259. if(mFlash.head != FLASH_HEAD){
  260. DEBUG_LOG("Flash write head fail.\n");
  261. Except_TxError(EXCEPT_FLASH,"Flash write head fail");
  262. return;
  263. }
  264. DEBUG_LOG("System reset...\n",mFlash.head);
  265. for(uint8_t i =0;i<6;i++){
  266. nrf_delay_ms(500);
  267. feed_watchdog();
  268. }
  269. NVIC_SystemReset();
  270. }
  271. i=1;
  272. if(MINIFDS_SUCCESS == pm_get_length(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),&length)){
  273. if(length == All_Falsh_value[i].length){
  274. pm_find(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),(uint8_t *)All_Falsh_value[i].value,&length);
  275. }
  276. }
  277. //连续五次重启的情况下,清空所有的flash数据,仅保留配对信息
  278. // if(mFlash.ErrStartCnt >= 5){
  279. // uint8_t macAddr_L[6];
  280. // uint8_t macAddr_R[6];
  281. // uint32_t hardVersion;
  282. // uint16_t sotfVersion;
  283. // uint8_t isConfig;
  284. // uint8_t isHost;
  285. // uint8_t RestartCnt;
  286. //
  287. // memcpy(macAddr_L,mFlash.macHost,sizeof(mFlash.macHost));
  288. // memcpy(macAddr_R,mFlash.mClient.macAddr,sizeof(mFlash.mClient.macAddr));
  289. // hardVersion = mFlash.mClient.hardVersion;
  290. // sotfVersion = mFlash.mClient.sotfVersion;
  291. // isConfig = mFlash.mClient.isConfig;
  292. // isHost = mFlash.isHost;
  293. // RestartCnt = mFlash.RestartCnt;
  294. //
  295. // memset((uint8_t*)(&mFlash),0,sizeof(Flash_t));
  296. //
  297. // mFlash.head = FLASH_HEAD;
  298. // memcpy(mFlash.macHost,macAddr_L,sizeof(mFlash.macHost));
  299. // memcpy(mFlash.mClient.macAddr,macAddr_R,sizeof(mFlash.mClient.macAddr));
  300. // mFlash.mClient.hardVersion = hardVersion;
  301. // mFlash.mClient.sotfVersion = sotfVersion;
  302. // mFlash.mClient.isConfig = isConfig ;
  303. // mFlash.isHost = isHost;
  304. // mFlash.RestartCnt = RestartCnt;
  305. //
  306. // Flash_DeleteAllInfor();
  307. // Flash_DeleteAllStep();
  308. // mFlash.ErrStartCnt =0;
  309. //
  310. // for(i =0;i<MAX_mflash_param_LENGTH;i++){
  311. // pm_add(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),(uint8_t *)All_Falsh_value[i].value,All_Falsh_value[i].length);
  312. // }
  313. // DEBUG_LOG("mBackup.ErrorStartFlag >= 5!!!!!!!!!!!\n");
  314. // NVIC_SystemReset();
  315. // }
  316. // else{
  317. // mFlash.ErrStartCnt++;
  318. // if(Flash_SaveInfomation() != ZONE_OP_SUCCESS)Except_TxError(EXCEPT_FLASH,"save ErrStartCnt fail");
  319. // }
  320. for(i =0;i<MAX_mflash_param_LENGTH;i++){
  321. if(MINIFDS_SUCCESS == pm_get_length(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),&length)){
  322. if(length == All_Falsh_value[i].length){
  323. pm_find(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),(uint8_t *)All_Falsh_value[i].value,&length);
  324. }
  325. else{
  326. pm_delete(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name));
  327. pm_add(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),(uint8_t *)All_Falsh_value[i].value,All_Falsh_value[i].length);
  328. }
  329. }
  330. else pm_add(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),(uint8_t *)All_Falsh_value[i].value,All_Falsh_value[i].length);
  331. }
  332. DEBUG_LOG("err code :%s\n",mFlash.mFlashLog.logData);
  333. DEBUG_LOG("Flash init ok.\n");
  334. //TestHalFlashInterface();
  335. }
  336. /**
  337. @brief 设置清空flash的标志
  338. @param 无
  339. @return 无
  340. */
  341. static uint8_t FlashStep_ClearFlag =0;
  342. void flash_SetClearStepFlag(void){
  343. FlashStep_ClearFlag =1;
  344. }
  345. uint32_t flash_GetStep_StartAddress(void){
  346. return FLASH_START_ADDR_STEP;
  347. }
  348. /**
  349. @brief 存储步数
  350. @param 无
  351. @return 错误代码
  352. */
  353. uint32_t Flash_SaveStep(void)
  354. {
  355. flash_OPER_Result err_code;
  356. uint32_t flash_data;
  357. #define Max_Hour PAGE_INT_SIZE * FLASH_ADDR_STEP_PAGENUM
  358. if(mFlash.mStep.step_num < Max_Hour)
  359. {
  360. // mFlash.mStep.stepCur[0] +=1 ;
  361. uint32_t step = app_step_GetStep_L() + app_step_GetStep_R(); //获取左右鞋步数
  362. flash_data = ((step<<24 & 0xff000000) | (step<<8 & 0x00ff0000) | (step>>8 & 0x0000ff00) | (step>>24 & 0x000000ff));
  363. //清空步数的flash step内容
  364. if(1 == FlashStep_ClearFlag){
  365. if(Flash_DeleteAllStep() != ZONE_OP_SUCCESS){
  366. Except_TxError(EXCEPT_DATEStep,"clear step fail");
  367. return ZONE_ERROR_WRITE_FAIL;
  368. }
  369. mFlash.mStep.step_num = 0;
  370. FlashStep_ClearFlag = 0;
  371. }
  372. DEBUG_LOG("step %d,flash_data:%d,step_num:%d\n",step, flash_data,mFlash.mStep.step_num);
  373. err_code = sdflash_write((uint32_t*)(FLASH_START_ADDR_STEP + (mFlash.mStep.step_num * 4)), &flash_data, 1);
  374. if(err_code != FLASH_OP_SUCCESS)return ZONE_ERROR_WRITE_FAIL;
  375. mFlash.mStep.step_num++;
  376. mFlash.mStep.step[0] = mFlash.mStep.stepCur[0];
  377. mFlash.mStep.step[1] = mFlash.mStep.stepCur[1];
  378. if(Flash_SaveInfomation() != ZONE_OP_SUCCESS){
  379. Except_TxError(EXCEPT_FLASH,"save information fail");
  380. }
  381. uint8_t i=4;
  382. uint8_t length =0;
  383. for(;i<5;i++){
  384. if(MINIFDS_SUCCESS == pm_get_length(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),&length)){
  385. if(length == All_Falsh_value[i].length){
  386. if(MINIFDS_SUCCESS == pm_find(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),(uint8_t *)All_Falsh_value[i].value,&length))
  387. {
  388. DEBUG_LOG(">>>>>>>>%s value:%d\n",All_Falsh_value[i].name,mFlash.mStep.stepCur[0]);
  389. }
  390. }
  391. }
  392. }
  393. }
  394. else return ZONE_ERROR_WRITE_FAIL;
  395. return ZONE_OP_SUCCESS;
  396. }
  397. /**
  398. @brief 删除所有步数
  399. @param 无
  400. @return 错误代码
  401. */
  402. uint32_t Flash_DeleteAllStep(void)
  403. {
  404. uint32_t errcode = ZONE_OP_SUCCESS;
  405. uint32_t pag_addr = 0;
  406. for(uint8_t i=0;i<FLASH_ADDR_STEP_PAGENUM;i++){
  407. pag_addr = (FLASH_START_ADDR_STEP +i*FLASH_PAGE_SIZE);
  408. errcode = sdflash_page_erase(pag_addr);
  409. if(errcode != NRF_SUCCESS)
  410. return ZONE_ERROR_ERASE_FAIL;
  411. }
  412. return ZONE_OP_SUCCESS;
  413. }
  414. /**
  415. @brief 删除infromation的数据
  416. @param 无
  417. @return 错误代码
  418. */
  419. uint32_t Flash_DeleteAllInfor(void)
  420. {
  421. uint32_t errcode = ZONE_OP_SUCCESS;
  422. uint32_t pag_addr = 0;
  423. for(uint8_t i=0;i<FLASH_ADDR_INFOR_PAGENUM;i++){
  424. pag_addr = (FLASH_START_ADDR_INFOR +i*FLASH_PAGE_SIZE);
  425. errcode = sdflash_page_erase(pag_addr);
  426. if(errcode != NRF_SUCCESS)
  427. return ZONE_ERROR_ERASE_FAIL;
  428. }
  429. return ZONE_OP_SUCCESS;
  430. }
  431. /**
  432. @brief 读取一个区域中指定位置的数据
  433. @param destination_addr[in] - 读取区域的地址
  434. @param pData[in] - 指向存储的buff
  435. @param dataLen[in] - 读取的长度,单位字节
  436. @return 错误代码
  437. */
  438. uint32_t flash_Data_Read(uint32_t addr, uint32_t *pData, uint32_t dataLen){
  439. if(pData != NULL && dataLen != 0){
  440. if(addr < START_FSTORAGE_ADDR || addr >= END_FSTORAGE_ADDR){
  441. return ZONE_ERROR_ADDRESS_FAIL;
  442. }
  443. else
  444. memcpy(pData, (uint32_t*)addr, dataLen);
  445. }
  446. return ZONE_OP_SUCCESS;
  447. }
  448. /**
  449. @brief 存储基本信息
  450. @param 无
  451. @return 错误代码
  452. */
  453. uint32_t Flash_SaveInfomation(void)
  454. {
  455. char result =0;
  456. for(uint8_t i =0;i<MAX_mflash_param_LENGTH;i++){
  457. result = pm_update(&information,All_Falsh_value[i].name,strlen(All_Falsh_value[i].name),(uint8_t *)All_Falsh_value[i].value,All_Falsh_value[i].length);
  458. if(result != MINIFDS_SUCCESS){
  459. DEBUG_LOG("Flash_SaveInfomation fail name %s,result %d\r\n",All_Falsh_value[i].name,result);
  460. return ZONE_ERROR_WRITE_FAIL;
  461. }
  462. }
  463. return ZONE_OP_SUCCESS;
  464. }
  465. /**
  466. @brief 保存日志信息
  467. @param[in] id Fault identifier. See @ref NRF_FAULT_IDS.
  468. @param[in] pc The program counter of the instruction that triggered the fault, or 0 if
  469. unavailable.
  470. @param[in] info Optional additional information regarding the fault. The value of the @p id
  471. parameter dictates how to interpret this parameter. Refer to the documentation
  472. for each fault identifier (@ref NRF_FAULT_IDS and @ref APP_ERROR_FAULT_IDS) for
  473. details about interpreting @p info.
  474. @return 错误代码
  475. */
  476. uint32_t Flash_SaveLog(uint32_t id, uint32_t pc, uint32_t info)
  477. {
  478. memset((uint8_t*)(&mFlash.mFlashLog),0,sizeof(FlashLog));
  479. mFlash.mFlashLog.Errorflag =1;
  480. switch (id)
  481. {
  482. #if defined(SOFTDEVICE_PRESENT) && SOFTDEVICE_PRESENT
  483. case NRF_FAULT_ID_SD_ASSERT:
  484. memcpy(mFlash.mFlashLog.logData,"SD: ASSERTION FAILED\r\n",MaxLength(sizeof("SD: ASSERTION FAILED\r\n"),sizeof(mFlash.mFlashLog.logData)));
  485. break;
  486. case NRF_FAULT_ID_APP_MEMACC:
  487. memcpy(mFlash.mFlashLog.logData,"SD: INVALID MEMORY ACCESS\r\n",MaxLength(sizeof("SD: INVALID MEMORY ACCESS\r\n"),sizeof(mFlash.mFlashLog.logData)));
  488. break;
  489. #endif
  490. case NRF_FAULT_ID_SDK_ASSERT:
  491. {
  492. assert_info_t * p_info = (assert_info_t *)info;
  493. sprintf((char *)mFlash.mFlashLog.logData,"ASSERTION FAILED %s:%u\r\n",
  494. p_info->p_file_name,
  495. p_info->line_num);
  496. break;
  497. }
  498. case NRF_FAULT_ID_SDK_ERROR:
  499. {
  500. error_info_t * p_info = (error_info_t *)info;
  501. sprintf((char *)mFlash.mFlashLog.logData,"error:%u,%s:%u\r\n",
  502. p_info->err_code,
  503. p_info->p_file_name,
  504. p_info->line_num);
  505. DEBUG_LOG(">>>>>err code :%d,%s",p_info->err_code,mFlash.mFlashLog.logData);
  506. break;
  507. }
  508. default:
  509. sprintf((char *)mFlash.mFlashLog.logData,"UNKNOWN FAULT 0x%08X\n", pc);
  510. break;
  511. }
  512. return Flash_SaveInfomation();
  513. }
  514. /**
  515. @brief 测试halflash接口
  516. @param 无
  517. @return 无
  518. */
  519. void TestHalFlashInterface(void)
  520. {
  521. // uint2_t i;
  522. // Flash_t m_testflash;
  523. // FlashBackup_t m_testbackup;
  524. // //测试基本信息和备份信息的写入和读取
  525. // for(i=0;i<10000;i++)
  526. // {
  527. // mFlash.mStep.step_num = i;
  528. // DEBUG_LOG("Flash_SaveInfomation[%d]:%d \n",i,Flash_SaveInfomation());
  529. //
  530. // DEBUG_LOG("Flash_SaveBackup[%d]:%d \n",i,Flash_SaveBackup());
  531. // }
  532. //
  533. // DEBUG_LOG("Flash_GetInfomation[%d]:%d \n",i,Flash_GetInfomation(&m_testflash));
  534. // DEBUG_LOG("m_testflash:%d \n",m_testflash.mStep.num);
  535. //
  536. // DEBUG_LOG("Flash_GetBackup[%d]:%d \n",i,Flash_GetBackup(&m_testbackup));
  537. // DEBUG_LOG("m_testbackup:%d \n",m_testbackup.hardVersion);
  538. }