init.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #include "hm_chipset.h"
  2. #include "hm_config.h"
  3. #include "hm_hci_transport_h4.h"
  4. #include "init.h"
  5. #ifdef HM_USING_STACK_NIMBLE
  6. #include "host/ble_hs_id.h"
  7. #endif
  8. #include <rtthread.h>
  9. static struct hci_trans_h4_config h4_config = {
  10. .uart_config = {
  11. .device_name = "uart3", /* Default value */
  12. .databit = DATA_BITS_8,
  13. .stopbit = STOP_BITS_1,
  14. .parity = PARITY_NONE,
  15. .baudrate = BAUD_RATE_115200, /* Default value */
  16. .flowcontrol = 1, /* Default value */
  17. },
  18. };
  19. static void hm_thread_entry(void *args)
  20. {
  21. hci_trans_h4_init(&h4_config);
  22. hci_trans_h4_open();
  23. hm_chipset_t *chipset_instance = hm_chipset_get_instance();
  24. chipset_instance->init();
  25. #ifdef HM_USING_STACK_NIMBLE
  26. hm_nimble_init();
  27. #endif
  28. #ifdef HM_USING_STACK_BTSTACK
  29. btstack_rtthread_port_init();
  30. #endif
  31. }
  32. static int hm_init(void)
  33. {
  34. rt_thread_t tid = rt_thread_create("hm", hm_thread_entry, NULL, 2048, 10, 10);
  35. rt_thread_startup(tid);
  36. return RT_EOK;
  37. }
  38. INIT_APP_EXPORT(hm_init);