usr.c 2.9 KB

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