func_bt.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include "include.h"
  2. #include "func.h"
  3. #if FUNC_BT_EN
  4. AT(.text.app.proc.bt)
  5. void func_bt_sub_process(void)
  6. {
  7. ble_app_proc();
  8. }
  9. AT(.text.app.proc.bt)
  10. void func_bt_process(void)
  11. {
  12. func_process();
  13. func_bt_sub_process();
  14. #if SYS_OFF_TIME
  15. if(sys_cb.pwroff_delay == 0) {
  16. func_cb.sta = FUNC_PWROFF;
  17. return;
  18. }
  19. #endif
  20. #if SYS_SLEEP_LEVEL
  21. if(sleep_process(bt_is_sleep)) {
  22. }
  23. #endif
  24. }
  25. AT(.text.func.bt)
  26. void func_bt_init(void)
  27. {
  28. bsp_ble_init();
  29. }
  30. AT(.text.func.bt)
  31. void func_bt_enter(void)
  32. {
  33. msg_queue_clear();
  34. #if LE_FCC_TEST_EN
  35. ble_set_work_mode(MODE_FCC_TEST);
  36. #elif LE_BQB_RF_EN
  37. ble_set_work_mode(MODE_BQB_RF_BLE);
  38. #else
  39. ble_set_work_mode(MODE_WIRELESS); //MODE_NORMAL
  40. #endif
  41. func_bt_init();
  42. }
  43. AT(.text.func.bt)
  44. void func_bt_exit(void)
  45. {
  46. bt_off();
  47. ble_set_work_mode(MODE_NORMAL);
  48. func_cb.last = FUNC_BT;
  49. }
  50. AT(.text.func.bt)
  51. void func_bt(void)
  52. {
  53. printf("%s\n", __func__);
  54. func_bt_enter();
  55. while (func_cb.sta == FUNC_BT) {
  56. func_bt_process();
  57. func_bt_message(msg_dequeue());
  58. }
  59. func_bt_exit();
  60. }
  61. #endif //FUNC_BT_EN