minifds_test.c 6.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. //#include "hal_minifds.h"
  2. //#include "nrf_sdh_soc.h"
  3. //void minifds_sys_evt_handler(uint32_t sys_evt, void *p_context)
  4. //{
  5. // // UNUSED_PARAMETER(p_context);
  6. // MINIFDS_PRINT(" NRF_EVT_FLASH_OPERATION_SUCCESS,");
  7. // if ((sys_evt != NRF_EVT_FLASH_OPERATION_SUCCESS) && (sys_evt != NRF_EVT_FLASH_OPERATION_ERROR))
  8. // {
  9. // /* Ignore any non-flash events. */
  10. // return;
  11. // }
  12. // switch (sys_evt)
  13. // {
  14. // case NRF_EVT_FLASH_OPERATION_SUCCESS:
  15. // MINIFDS_PRINT(" NRF_EVT_FLASH_OPERATION_SUCCESS,");
  16. // break;
  17. // case NRF_EVT_FLASH_OPERATION_ERROR:
  18. // break;
  19. // }
  20. //}
  21. ///* Define a nrf_sdh_soc event observer to receive SoftDevice system events. */
  22. //NRF_SDH_SOC_OBSERVER(m_sys_obs, 0, minifds_sys_evt_handler, NULL);
  23. //DEFINE_MINIINF(minifds, 0x00074000UL, 0x00078000UL, sdflash_write, sdflash_page_erase);
  24. //unsigned char reckd[256];
  25. //void add_pcs(cli_t *p_cli, unsigned short argc, char **argv)
  26. //{
  27. // char recalue = 0;
  28. // static unsigned char key = 1;
  29. // for (int i = 0; i < sizeof(reckd); i++)
  30. // {
  31. // reckd[i] = 0x11;
  32. // }
  33. // reckd[sizeof(reckd) - 1] = 0x0B;
  34. // recalue = minfds_record_add(&minifds, key++, reckd, 100);
  35. // cli_printf(p_cli, " %d =minfds_record_add(&minifds,2,reckd,sizeof(reckd))", recalue);
  36. //}
  37. //CLI_CMD_REGISTER(add, "Cli cmd history", add_pcs);
  38. //void update_pcs(cli_t *p_cli, unsigned short argc, char **argv)
  39. //{
  40. // char recalue = 0;
  41. // for (int i = 0; i < sizeof(reckd); i++)
  42. // {
  43. // reckd[i] = 0x11;
  44. // }
  45. // reckd[sizeof(reckd) - 1] = 0x0B;
  46. // recalue = minfds_record_update(&minifds, 2, reckd, sizeof(reckd));
  47. // cli_printf(p_cli, " %d =minfds_record_update(&minifds,2,reckd,sizeof(reckd))", recalue);
  48. //}
  49. //CLI_CMD_REGISTER(update, "Cli cmd history", update_pcs);
  50. //void del_pcs(cli_t *p_cli, unsigned short argc, char **argv)
  51. //{
  52. // char recalue = 0;
  53. // unsigned char reckd[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  54. // recalue = minfds_record_delete(&minifds, 2);
  55. // cli_printf(p_cli, " %d =minfds_record_delete(&minifds,2,reckd,sizeof(reckd))", recalue);
  56. //}
  57. //CLI_CMD_REGISTER(del, "Cli cmd history", del_pcs);
  58. //void da_pcs(cli_t *p_cli, unsigned short argc, char **argv)
  59. //{
  60. // char recalue = 0;
  61. // unsigned char reckd[] = {1, 2, 3, 4, 5, 6, 7, 8, 9};
  62. // recalue = minfds_record_delete_all(&minifds);
  63. // cli_printf(p_cli, " %d =minfds_record_delete(&minifds,2,reckd,sizeof(reckd))", recalue);
  64. //}
  65. //CLI_CMD_REGISTER(da, "Cli cmd history", da_pcs);
  66. //void find_pcs(cli_t *p_cli, unsigned short argc, char **argv)
  67. //{
  68. // char recalue = 0;
  69. // unsigned char reckd[64] = {0};
  70. // length_t length = 0;
  71. // recalue = minfds_record_find(&minifds, 2, reckd, &length);
  72. // cli_printf(p_cli, " %d = minfds_record_find", recalue);
  73. // for (unsigned int i = 0; i < length; i++)
  74. // {
  75. // MINIFDS_PRINT("0x%2x ", reckd[i]);
  76. // }
  77. // MINIFDS_PRINT("\r\n");
  78. //}
  79. //CLI_CMD_REGISTER(find, "Cli cmd history", find_pcs);
  80. //void gc_pcs(cli_t *p_cli, unsigned short argc, char **argv)
  81. //{
  82. // minfds_gc(&minifds);
  83. //}
  84. //CLI_CMD_REGISTER(gc, "Cli cmd history", gc_pcs);
  85. //void cb_pcs(cli_t *p_cli, unsigned short argc, char **argv)
  86. //{
  87. // printctb(&minifds);
  88. //}
  89. //CLI_CMD_REGISTER(cb, "Cli cmd history", cb_pcs);
  90. //void scan_pcs(cli_t *p_cli, unsigned short argc, char **argv)
  91. //{
  92. // minfds_Scan(&minifds);
  93. //}
  94. //CLI_CMD_REGISTER(scan, "Cli cmd history", scan_pcs);
  95. //unsigned char getrng(void)
  96. //{
  97. // unsigned char value;
  98. // NRF_RNG->CONFIG = 1;
  99. // NRF_RNG->TASKS_START = 1;
  100. // NRF_RNG->EVENTS_VALRDY = 0;
  101. // while (NRF_RNG->EVENTS_VALRDY == 0)
  102. // ;
  103. // value = NRF_RNG->VALUE;
  104. // NRF_RNG->TASKS_STOP = 1;
  105. // NRF_RNG->INTENCLR = 0;
  106. // NRF_RNG->CONFIG = 0;
  107. // return value;
  108. //}
  109. //void minifdstest_pcs(cli_t *p_cli, unsigned short argc, char **argv)
  110. //{
  111. // static unsigned char key = 1;
  112. // length_t length = getrng();
  113. // char rec = 0;
  114. // int count = 0;
  115. // minfds_record_delete_all(&minifds);
  116. // unsigned char readbuff[256];
  117. // while (rec == 0)
  118. // {
  119. //// do{
  120. // length = getrng();
  121. //// length = length<<8;
  122. //// length |= getrng();}while(length<4096+4096);
  123. // for (int i = 0; i < length; i++)
  124. // {
  125. // reckd[i] = getrng();
  126. // }
  127. // if (getrng() > 128)
  128. // {
  129. // rec = minfds_record_add(&minifds, key++, reckd, length);
  130. //print_record(reckd, length);
  131. // if (rec == 0)
  132. // {
  133. // rec = minfds_record_find(&minifds, key-1, readbuff, &length);
  134. // print_record(readbuff, length);
  135. // if(memcmp(reckd,readbuff,length)!=0)
  136. // {
  137. // MINIFDS_PRINT("-----------------------------------------------------------------------------ERROR- read f-------------- %d\r\n", count);
  138. // }
  139. //
  140. // count++;
  141. // if (minifds.record_count != count)
  142. // {
  143. // MINIFDS_PRINT("-----------------------------------------------------------------------------ERROR--------------- %d\r\n", count);
  144. // }
  145. // }
  146. // if (rec == MINIFDS_ERR_NOT_FREE_CAPACITY)
  147. // {
  148. // rec = minfds_record_delete_all(&minifds);
  149. // key = 1;
  150. // if (rec == 0)
  151. // {
  152. // count = 0;
  153. // }
  154. // }
  155. // }
  156. // else
  157. // {
  158. // minfds_record_update(&minifds, getrng(), reckd, length);
  159. // }
  160. // }
  161. // MINIFDS_PRINT("minifdstest_pcs(cli_t* p_cli, unsigned short argc, char** argv) %d\r\n", count);
  162. // key = 1;
  163. // // minfds_Scan(&minifds);
  164. //}
  165. //CLI_CMD_REGISTER(minifdstest_pcs, "Cli cmd history", minifdstest_pcs);
  166. //char fds4k_read_words(const unsigned int addr, unsigned int *p_words, unsigned short length_words)
  167. //{
  168. // for (unsigned int i = 0; i < length_words; i++)
  169. // {
  170. // p_words[i] = *((unsigned int *)(addr + i * 4));
  171. // }
  172. // return 0;
  173. //}
  174. //void fds4k_print_cli_pcs(cli_t *p_cli, unsigned short argc, char **argv)
  175. //{
  176. // unsigned int temp[4];
  177. // unsigned int addr = minifds.start_addr;
  178. // for (unsigned int i = 0; i < (minifds.end_addr - minifds.start_addr) / 16 + 3; i++)
  179. // {
  180. // if (fds4k_read_words(addr, temp, 4) == 0)
  181. // {
  182. // MINIFDS_PRINT("%4d 0x%8x 0x%8x 0x%8x 0x%8x 0x%8x \r\n", i, addr, temp[0], temp[1], temp[2], temp[3]);
  183. // for (int k = 0; k < 0xffff; k++)
  184. // ;
  185. // }
  186. // addr += 16;
  187. // }
  188. //}
  189. //CLI_CMD_REGISTER(fds_printf, "Cli cmd history", fds4k_print_cli_pcs);
  190. //int main(void)
  191. //{
  192. // minfds_init(&minifds);
  193. // while (1)
  194. // {
  195. // cli_process(&clirtt);
  196. // }
  197. //}