usr.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. #include "usr.h"
  2. #include "system.h"
  3. #include "bsp_time.h"
  4. #include "nrf_delay.h"
  5. //Add your code here...
  6. #include "twi_master.h"
  7. #include "hal_imu.h"
  8. #include "hal_ble_client.h"
  9. #include "hal_ble_host.h"
  10. #include "hal_mt.h"
  11. #include "hal_battery.h"
  12. #include "hal_led.h"
  13. #include "app_overturn.h"
  14. #include "app_charge.h"
  15. #include "app_power.h"
  16. #include "app_client.h"
  17. #include "app_host.h"
  18. #include "app_flash.h"
  19. #include "app_step.h"
  20. #include "app_game.h"
  21. #include "hal_ble_uart0.h"
  22. #include "app_config.h"
  23. #include "app_ota.h"
  24. #include "app_connect_manage.h"
  25. #include "app_organ.h"
  26. #include "ble_comm.h"
  27. #include "ble_gap.h"
  28. #include "app_err.h"
  29. #include "bsp_pwm.h"
  30. #include "bsp_wdt.h"
  31. #include "bsp_adc.h"
  32. #include "tool.h"
  33. #include "hal_imu.h"
  34. #include "app_ImuCalibration.h"
  35. #include "hal_wearshoes.h"
  36. #include "app_math.h"
  37. #include "app_losspack.h"
  38. #include "app_pair.h"
  39. #include "app_switchimu.h"
  40. #include "app_self_checking.h"
  41. #include "hal_mode_manage.h"
  42. #include "exception.h"
  43. #include "tool.h"
  44. #include "hal_monitor.h"
  45. #include "app_self_checking_tool.h"
  46. void USR_SetName(void)
  47. {
  48. char buf[16];
  49. memset(buf,0,16);
  50. if(mFlash.isHost){ //
  51. #if GAME_ENANBLE || BleNameHoldOn_ENANBLE
  52. slave_set_adv_name((char *) LEFT_NAME,sizeof(LEFT_NAME));
  53. SEGGER_RTT_printf(0,"scanName(%d):%s\n",sizeof(RIGHT_NAME),RIGHT_NAME);
  54. host_set_scan_name((char *)RIGHT_NAME,sizeof(RIGHT_NAME));
  55. #else
  56. if(mFlash.mClient.isConfig=='C'){ //
  57. 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]);
  58. SEGGER_RTT_printf(0,"scanName(%d):%s\n",strlen(buf),buf);
  59. host_set_scan_name(buf,strlen(buf));
  60. }
  61. #endif
  62. }else{ //
  63. #if GAME_ENANBLE || BleNameHoldOn_ENANBLE
  64. slave_set_adv_name((char *)RIGHT_NAME,sizeof(RIGHT_NAME));
  65. SEGGER_RTT_printf(0,"AdvName(%d):%s\n",sizeof(RIGHT_NAME),RIGHT_NAME);
  66. host_set_scan_name((char *)LAST_NAME,sizeof(LAST_NAME));
  67. #else
  68. if(mFlash.mClient.isConfig=='C'){ //
  69. 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]);
  70. SEGGER_RTT_printf(0,"advName(%d):%s\n",strlen(buf),buf);
  71. slave_set_adv_name(buf,strlen(buf));
  72. }
  73. host_set_scan_name((char *)"12321321312",sizeof("12321321312"));
  74. #endif
  75. }
  76. }
  77. __weak void usr1_Init(void)
  78. {
  79. USR_SetName();
  80. slave_init(BLE_Client_Push);
  81. host_init(BLE_Host_Push);
  82. }
  83. void PRE_Init(void)
  84. {
  85. nrf_gpio_cfg_input(21,NRF_GPIO_PIN_PULLUP);//3?¦Ì?¨°y??¨¦?¨¤-
  86. // PWR_Init();
  87. LED_Init();
  88. // MT_Init();
  89. // Flash_Initialize();
  90. // Exception_Init();
  91. usr1_Init();
  92. }
  93. void USR_Init(void)
  94. {
  95. //Add your code here...
  96. TIME_Init();
  97. // #if WATCHDOG_ENANBLE
  98. // watchdog_init();
  99. // feed_watchdog();
  100. // #endif
  101. // IMU_Initialize(mFlash.isHost);
  102. // ADC_Initialize();
  103. //
  104. // hal_battery_init();
  105. // BLE_Client_Initialize();
  106. // BLE_Host_Initialize();
  107. // hal_wearshoes_Init();
  108. // hal_mode_manage_Init();
  109. // hal_monitor_Init();
  110. // //APP
  111. // app_client_Initialize();
  112. // app_host_Initialize();
  113. // app_overturn_Init();
  114. app_charge_Init();
  115. // app_step_Init();
  116. // app_game_Init();
  117. // app_math_Init();
  118. // app_ota_Init();
  119. app_connect_manage_Init();
  120. // app_switchimu_Init();
  121. //
  122. // #if LOSSPACK_ENANBLE
  123. // app_losspack_Init();
  124. // #endif
  125. //
  126. // #if !BleNameHoldOn_ENANBLE
  127. // app_pair_Init();
  128. // #endif
  129. // app_self_checking_Init();
  130. //
  131. // app_err_Init();
  132. // Tool_Init();
  133. app_self_checking_tool_Init();
  134. }