usr.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  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_ble_client.h"
  8. #include "hal_ble_host.h"
  9. #include "hal_mt.h"
  10. #include "hal_battery.h"
  11. #include "hal_led.h"
  12. #include "app_overturn.h"
  13. #include "app_charge.h"
  14. #include "app_power.h"
  15. #include "app_client.h"
  16. #include "app_host.h"
  17. #include "app_game.h"
  18. #include "hal_ble_uart0.h"
  19. #include "app_config.h"
  20. #include "app_ota.h"
  21. #include "app_connect_manage.h"
  22. #include "app_organ.h"
  23. #include "ble_comm.h"
  24. #include "ble_gap.h"
  25. #include "exception.h"
  26. #include "bsp_pwm.h"
  27. #include "bsp_wdt.h"
  28. #include "bsp_adc.h"
  29. #include "tool.h"
  30. #include "app_ImuCalibration.h"
  31. #include "hal_wearshoes.h"
  32. #include "app_math.h"
  33. #include "app_losspack.h"
  34. #include "app_pair.h"
  35. #include "app_switchimu.h"
  36. #include "app_self_checking.h"
  37. #include "exception.h"
  38. #include "tool.h"
  39. #include "app_data_transfer.h"
  40. #include "hal_scan_manage.h"
  41. #include "app_safe.h"
  42. #include "bll_imu.h"
  43. #include "app_flash.h"
  44. #include "app_step.h"
  45. #include "hal_qma.h"
  46. #include "app_detectIsHost.h"
  47. #include "bll_single_line_half_duplex.h"
  48. __weak void usr1_Init(void)
  49. {
  50. slave_init(BLE_Client_Push);
  51. host_init(BLE_Host_Push);
  52. }
  53. void host(char byte)
  54. {
  55. static char value = 0;
  56. int ret;
  57. ret = bll_single_line_half_duplex_is_ready_to_transfer();
  58. SEGGER_RTT_printf(0,"h receive byte:%d ret:%d\n",byte,ret);
  59. if(ret == 0)
  60. {
  61. bll_single_line_half_duplex_transfer_onebyte(value);
  62. SEGGER_RTT_printf(0,"h value:%d\n",value);
  63. value++;
  64. }
  65. }
  66. void slave(char byte)
  67. {
  68. static char value = 0;
  69. int ret;
  70. ret = bll_single_line_half_duplex_is_ready_to_transfer();
  71. SEGGER_RTT_printf(0,"s receive byte:%d ret:%d\n",byte,ret);
  72. if(ret == 0)
  73. {
  74. SEGGER_RTT_printf(0,"bll_single_line_half_duplex_transfer_onebyte(value)%d\n",bll_single_line_half_duplex_transfer_onebyte(value));
  75. SEGGER_RTT_printf(0,"s value:%d\n",value);
  76. value++;
  77. }
  78. }
  79. static void test_Process(void)
  80. {
  81. static int time = 1;
  82. if(time <= 0)return;
  83. static char value = 0;
  84. int ret;
  85. ret = bll_single_line_half_duplex_is_ready_to_transfer();
  86. if(ret == 0)
  87. {
  88. SEGGER_RTT_printf(0,"bll_single_line_half_duplex_transfer_onebyte(value)%d\n",bll_single_line_half_duplex_transfer_onebyte(value));
  89. SEGGER_RTT_printf(0,"value:%d\n",value);
  90. value++;
  91. }
  92. else
  93. {
  94. SEGGER_RTT_printf(0,"ret:%d\n",ret);
  95. }
  96. time--;
  97. }
  98. void PRE_Init(void)
  99. {
  100. // watchdog_init();
  101. // feed_watchdog();
  102. // PWR_Init();
  103. // LED_Init();
  104. // MT_Init();
  105. // Flash_Initialize();
  106. // Exception_Init();
  107. usr1_Init();
  108. SEGGER_RTT_printf(0,"bll_single_line_half_duplex_Init(BLL_SINGLE_LINE_HALF_DUPLEX_ROLE_HOST):%d\n",bll_single_line_half_duplex_Init(BLL_SINGLE_LINE_HALF_DUPLEX_ROLE_HOST));
  109. bll_single_line_half_duplex_receive_register(host);
  110. Process_Start(1000,"test_Process",test_Process);
  111. // bll_single_line_half_duplex_Init(BLL_SINGLE_LINE_HALF_DUPLEX_ROLE_SLAVE);
  112. //
  113. // bll_single_line_half_duplex_receive_register(slave);
  114. }
  115. void USR_Init(void)
  116. {
  117. //Add your code here...
  118. TIME_Init();
  119. // bll_imu_Init();
  120. // ADC_Initialize();
  121. //
  122. // hal_battery_init();
  123. // BLE_Client_Initialize();
  124. // BLE_Host_Initialize();
  125. // hal_wearshoes_Init();
  126. // hal_ble_scan_Init();
  127. // hal_qma_Init();
  128. // //APP
  129. // app_detect_Init();
  130. //
  131. // app_client_Initialize();
  132. // app_host_Initialize();
  133. // app_overturn_Init();
  134. // app_charge_Init();
  135. // app_step_Init();
  136. // app_game_Init();
  137. // app_math_Init();
  138. //
  139. // app_ota_Init();
  140. // app_connect_manage_Init();
  141. // app_switchimu_Init();
  142. // app_data_transfer_Init();
  143. // app_safe_Init();
  144. //
  145. // #if LOSSPACK_ENANBLE
  146. // app_losspack_Init();
  147. // #endif
  148. //
  149. // #if !BleNameHoldOn_ENANBLE
  150. // app_pair_Init();
  151. // #endif
  152. //
  153. //// app_self_checking_Init();
  154. //
  155. // Tool_Init();
  156. }