bt_app_core.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Unlicense OR CC0-1.0
  5. */
  6. #ifndef __BT_APP_CORE_H__
  7. #define __BT_APP_CORE_H__
  8. #include <stdint.h>
  9. #include <stdbool.h>
  10. #include <stdio.h>
  11. /* log tag */
  12. #define BT_APP_CORE_TAG "BT_APP_CORE"
  13. /* signal for `bt_app_work_dispatch` */
  14. #define BT_APP_SIG_WORK_DISPATCH (0x01)
  15. extern uint8_t s_volume;
  16. /**
  17. * @brief handler for the dispatched work
  18. *
  19. * @param [in] event event id
  20. * @param [in] param handler parameter
  21. */
  22. typedef void (* bt_app_cb_t) (uint16_t event, void *param);
  23. /* message to be sent */
  24. typedef struct {
  25. uint16_t sig; /*!< signal to bt_app_task */
  26. uint16_t event; /*!< message event id */
  27. bt_app_cb_t cb; /*!< context switch callback */
  28. void *param; /*!< parameter area needs to be last */
  29. } bt_app_msg_t;
  30. /**
  31. * @brief parameter deep-copy function to be customized
  32. *
  33. * @param [out] p_dest pointer to destination data
  34. * @param [in] p_src pointer to source data
  35. * @param [in] len data length in byte
  36. */
  37. typedef void (* bt_app_copy_cb_t) (void *p_dest, void *p_src, int len);
  38. /**
  39. * @brief work dispatcher for the application task
  40. *
  41. * @param [in] p_cback callback function
  42. * @param [in] event event id
  43. * @param [in] p_params callback paramters
  44. * @param [in] param_len parameter length in byte
  45. * @param [in] p_copy_cback parameter deep-copy function
  46. *
  47. * @return true if work dispatch successfully, false otherwise
  48. */
  49. bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback);
  50. /**
  51. * @brief start up the application task
  52. */
  53. void bt_app_task_start_up(void);
  54. /**
  55. * @brief shut down the application task
  56. */
  57. void bt_app_task_shut_down(void);
  58. /**
  59. * @brief start up the is task
  60. */
  61. void bt_i2s_task_start_up(void);
  62. /**
  63. * @brief shut down the I2S task
  64. */
  65. void bt_i2s_task_shut_down(void);
  66. /**
  67. * @brief write data to ringbuffer
  68. *
  69. * @param [in] data pointer to data stream
  70. * @param [in] size data length in byte
  71. *
  72. * @return size if writteen ringbuffer successfully, 0 others
  73. */
  74. size_t write_ringbuf(const uint8_t *data, size_t size);
  75. #endif /* __BT_APP_CORE_H__ */