usr.c 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. #include "usr.h"
  2. #include "system.h"
  3. #include "bsp_time.h"
  4. #include "nrf_delay.h"
  5. //ó??§3?ê??ˉí·???t
  6. //Add your code here...
  7. #include "twi_master.h"
  8. #include "hal_imu.h"
  9. #include "hal_ble_client.h"
  10. #include "hal_ble_host.h"
  11. #include "hal_mt.h"
  12. #include "hal_battery.h"
  13. #include "hal_led.h"
  14. #include "app_overturn.h"
  15. #include "app_charge.h"
  16. #include "app_power.h"
  17. #include "app_client.h"
  18. #include "app_host.h"
  19. #include "hal_flash.h"
  20. #include "app_step.h"
  21. #include "app_game.h"
  22. #include "hal_ble_uart0.h"
  23. #include "app_config.h"
  24. #include "app_ota.h"
  25. #include "app_connect_manage.h"
  26. #include "app_organ.h"
  27. #include "ble_comm.h"
  28. #include "ble_gap.h"
  29. #include "app_err.h"
  30. #include "bsp_pwm.h"
  31. #include "bsp_wdt.h"
  32. #include "bsp_adc.h"
  33. #include "tool.h"
  34. #include "hal_imu.h"
  35. #include "app_ImuCalibration.h"
  36. #include "app_wearshoes.h"
  37. #include "app_math.h"
  38. #include "app_losspack.h"
  39. #include "app_pair.h"
  40. #include "app_switchimu.h"
  41. ////host
  42. //char sn1[] = "SH_P0";
  43. //char hn1[] = "SH_L0";
  44. ////client
  45. //char sn2[] = "SH_L0";
  46. //char hn2[] = "SH_N0";
  47. //char* HOST_NAME;
  48. //char* DEVICE_NAME;
  49. void USR_SetName(void)
  50. {
  51. char buf[16];
  52. memset(buf,0,16);
  53. if(mFlash.isHost){ //
  54. #if GAME_ENANBLE || BleNameHoldOn_ENANBLE
  55. slave_set_adv_name((char *) LEFT_NAME,sizeof(LEFT_NAME));
  56. SEGGER_RTT_printf(0,"scanName(%d):%s\n",sizeof(RIGHT_NAME),RIGHT_NAME);
  57. host_set_scan_name((char *)RIGHT_NAME,sizeof(RIGHT_NAME));
  58. #else
  59. if(mFlash.mClient.isConfig=='C'){ //
  60. sprintf(buf,"%02X%02X%02X%02X%02X%02X",mFlash.macHost[0],mFlash.macHost[1],mFlash.macHost[2],mFlash.mClient.macAddr[3],mFlash.mClient.macAddr[4],mFlash.mClient.macAddr[5]);
  61. SEGGER_RTT_printf(0,"scanName(%d):%s\n",strlen(buf),buf);
  62. host_set_scan_name(buf,strlen(buf));
  63. }
  64. #endif
  65. }else{ //
  66. #if GAME_ENANBLE || BleNameHoldOn_ENANBLE
  67. slave_set_adv_name((char *)RIGHT_NAME,sizeof(RIGHT_NAME));
  68. SEGGER_RTT_printf(0,"AdvName(%d):%s\n",sizeof(RIGHT_NAME),RIGHT_NAME);
  69. host_set_scan_name((char *)LAST_NAME,sizeof(LAST_NAME));
  70. #else
  71. if(mFlash.mClient.isConfig=='C'){ //
  72. sprintf(buf,"%02X%02X%02X%02X%02X%02X",mFlash.macHost[0],mFlash.macHost[1],mFlash.macHost[2],mFlash.mClient.macAddr[3],mFlash.mClient.macAddr[4],mFlash.mClient.macAddr[5]);
  73. SEGGER_RTT_printf(0,"advName(%d):%s\n",strlen(buf),buf);
  74. slave_set_adv_name(buf,strlen(buf));
  75. }
  76. host_set_scan_name((char *)"12321321312",sizeof("12321321312"));
  77. #endif
  78. }
  79. }
  80. __weak void usr1_Init(void)
  81. {
  82. USR_SetName();
  83. slave_init(BLE_Client_Push);
  84. host_init(BLE_Host_Push);
  85. }
  86. void PRE_Init(void)
  87. {
  88. nrf_gpio_cfg_input(21,NRF_GPIO_PIN_PULLUP);//3?μ?òy??é?à-
  89. PWR_Init();
  90. LED_Init();
  91. MT_Init();
  92. Flash_Initialize();
  93. JS_RTT_Init();
  94. usr1_Init();
  95. }
  96. void USR_Init(void)
  97. {
  98. //Add your code here...
  99. TIME_Init();
  100. #if WATCHDOG_ENANBLE
  101. watchdog_init();
  102. #endif
  103. Battery_Initialize();
  104. IMU_Initialize();
  105. ADC_Initialize();
  106. Battery_Enable(true);
  107. BLE_Client_Initialize();
  108. BLE_Host_Initialize();
  109. //APP
  110. app_client_Initialize();
  111. app_host_Initialize();
  112. app_overturn_Init();
  113. app_charge_Init();
  114. app_step_Init();
  115. app_game_Init();
  116. app_math_Init();
  117. app_ota_Init();
  118. app_connect_manage_Init();
  119. app_switchimu_Init();
  120. #if LOSSPACK_ENANBLE
  121. app_losspack_Init();
  122. #endif
  123. #if !BleNameHoldOn_ENANBLE
  124. app_pair_init(); //还需测试不同鞋子切换配对。
  125. #endif
  126. #if CALIBRATION_ENANBLE
  127. app_calibration_Init();//待测试
  128. #endif
  129. app_err_Init();
  130. }