usr.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  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_ser_imu_mode_manage.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 "exception.h"
  29. #include "bsp_pwm.h"
  30. #include "bsp_wdt.h"
  31. #include "bsp_adc.h"
  32. #include "tool.h"
  33. #include "app_ImuCalibration.h"
  34. #include "hal_wearshoes.h"
  35. #include "app_math.h"
  36. #include "app_losspack.h"
  37. #include "app_pair.h"
  38. #include "app_switchimu.h"
  39. #include "app_self_checking.h"
  40. #include "exception.h"
  41. #include "tool.h"
  42. #include "app_data_transfer.h"
  43. #include "hal_scan_manage.h"
  44. #include "app_safe.h"
  45. void USR_SetName(void)
  46. {
  47. char buf[16];
  48. memset(buf,0,16);
  49. if(mFlash.isHost){ //
  50. #if BleNameHoldOn_ENANBLE
  51. slave_set_adv_name((char *) LEFT_NAME,sizeof(LEFT_NAME));
  52. DEBUG_LOG("scanName(%d):%s\n",sizeof(RIGHT_NAME),RIGHT_NAME);
  53. host_set_scan_name((char *)RIGHT_NAME,sizeof(RIGHT_NAME));
  54. #else
  55. if(mFlash.mClient.isConfig=='C'){ //
  56. 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]);
  57. DEBUG_LOG("scanName(%d):%s\n",strlen(buf),buf);
  58. host_set_scan_name(buf,strlen(buf));
  59. }
  60. #endif
  61. }else{ //
  62. #if BleNameHoldOn_ENANBLE
  63. slave_set_adv_name((char *)RIGHT_NAME,sizeof(RIGHT_NAME));
  64. DEBUG_LOG("AdvName(%d):%s\n",sizeof(RIGHT_NAME),RIGHT_NAME);
  65. host_set_scan_name((char *)LAST_NAME,sizeof(LAST_NAME));
  66. #else
  67. if(mFlash.mClient.isConfig=='C'){ //
  68. 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]);
  69. DEBUG_LOG("advName(%d):%s\n",strlen(buf),buf);
  70. slave_set_adv_name(buf,strlen(buf));
  71. }
  72. host_set_scan_name((char *)"12321321312",sizeof("12321321312"));
  73. #endif
  74. }
  75. }
  76. __weak void usr1_Init(void)
  77. {
  78. USR_SetName();
  79. slave_init(BLE_Client_Push);
  80. host_init(BLE_Host_Push);
  81. }
  82. void PRE_Init(void)
  83. {
  84. watchdog_init();
  85. feed_watchdog();
  86. nrf_gpio_cfg_input(21,NRF_GPIO_PIN_PULLUP);//3?¦Ì?¨°y??¨¦?¨¤-
  87. PWR_Init();
  88. LED_Init();
  89. MT_Init();
  90. Flash_Initialize();
  91. Exception_Init();
  92. usr1_Init();
  93. }
  94. void USR_Init(void)
  95. {
  96. //Add your code here...
  97. TIME_Init();
  98. hal_ser_imu_mode_manage_Init();
  99. ADC_Initialize();
  100. hal_battery_init();
  101. BLE_Client_Initialize();
  102. BLE_Host_Initialize();
  103. hal_wearshoes_Init();
  104. hal_ble_scan_Init();
  105. //APP
  106. app_client_Initialize();
  107. app_host_Initialize();
  108. app_overturn_Init();
  109. app_charge_Init();
  110. app_step_Init();
  111. app_game_Init();
  112. app_math_Init();
  113. app_ota_Init();
  114. app_connect_manage_Init();
  115. app_switchimu_Init();
  116. app_data_transfer_Init();
  117. app_safe_Init();
  118. #if LOSSPACK_ENANBLE
  119. app_losspack_Init();
  120. #endif
  121. #if !BleNameHoldOn_ENANBLE
  122. app_pair_Init();
  123. #endif
  124. app_self_checking_Init();
  125. Tool_Init();
  126. }