hm_chipset.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #ifndef HM_CHIPSET_H
  2. #define HM_CHIPSET_H
  3. #include <stdint.h>
  4. #ifdef __cplusplus
  5. extern "C" {
  6. #endif
  7. typedef struct hm_chipset {
  8. char *name;
  9. /**
  10. * @brief User default init.
  11. *
  12. * @return int
  13. * @retval HM_SUCCESS Chipset init success.
  14. * @retval HM_CHIPSET_INIT_ERROR Chipset init error.
  15. */
  16. int (*init)(void);
  17. } hm_chipset_t;
  18. /**
  19. * @brief Get hci middleware chipset instance.
  20. *
  21. * @return hm_chipset_t*
  22. * @retval Non-NULL Chipset instance.
  23. * @retval NULL Error.
  24. */
  25. extern hm_chipset_t* hm_chipset_get_instance(void);
  26. /**
  27. * @brief Send a hci command, used in chipset module.
  28. *
  29. * @param buf Buffer to store a hci command.
  30. * @param size HCI command size with bytes.
  31. *
  32. * @return int
  33. * @retval HM_SUCCESS Send success.
  34. * @retval -HM_NO_MEMORY Command memory pool is not enough.
  35. * @retval -HM_UART_SEND_ERR Uart send command error.
  36. */
  37. extern int chip_hci_cmd_send(uint8_t *buf, uint16_t size);
  38. /**
  39. * @brief Read a hci event, used in chipset module.
  40. * This function will block until a hci event received or wait time timeout.
  41. * Usually used in chipset init.
  42. *
  43. * @param buf Buffer to store a hci event.
  44. * @param size Buffer size.
  45. * @param ms Waitting time in ms. Specially,
  46. * RT_WAITING_NO means no wait,
  47. * RT_WAITING_FOREVER means wait forever.
  48. *
  49. * @return int
  50. * @retval HM_SUCCESS Read hci event success.
  51. * @retval -HM_TIMEOUT Timeout.
  52. */
  53. extern int chip_hci_event_read(uint8_t *buf, uint16_t size, int ms);
  54. /**
  55. * @brief This function will continually send HCI-Reset-Command until
  56. * remote chipset respond a HCI-Somplete-Command-Event.
  57. *
  58. * @note Because a chipset may not be ready, if we only send a reset command,
  59. * remote chipset may not respond any event. So we should continually
  60. * send reset command in chipset init start and end.
  61. */
  62. extern void chip_send_hci_reset_cmd_until_ack(void);
  63. #ifdef __cplusplus
  64. }
  65. #endif
  66. #endif /* HM_CHIPSET_H */