You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.7 KiB

1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
1 year ago
  1. #include "basic/zble_module.h"
  2. #include "basic/zdatachannel_service.h"
  3. #include "znordic.h"
  4. //
  5. #include <stdarg.h>
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8. #include <string.h>
  9. //
  10. #include <math.h>
  11. #include "app_scheduler.h"
  12. #include "znordic.h"
  13. #if defined(UART_PRESENT)
  14. #include "nrf_uart.h"
  15. #endif
  16. #if defined(UARTE_PRESENT)
  17. #include "nrf_uarte.h"
  18. #endif
  19. #if 0
  20. int main() {
  21. one_conduction_main();
  22. return 0;
  23. }
  24. #endif
  25. #if 0
  26. extern uint32_t g_nrf_log_tx_pin;
  27. APP_TIMER_DEF(m_report_timer); //
  28. static void tmr_cb(void* p_context) { //
  29. ZLOGI("%d", SingleLeadECG_ecg_plod_get_ecg_val());
  30. }
  31. void main() {
  32. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  33. g_nrf_log_tx_pin = 41;
  34. znordic_init();
  35. NRF_LOG_INFO("compile time :%s", __TIME__);
  36. SingleLeadECG_adc_module_init();
  37. ZERROR_CHECK(app_timer_create(&m_report_timer, APP_TIMER_MODE_REPEATED, tmr_cb));
  38. ZERROR_CHECK(app_timer_start(m_report_timer, APP_TIMER_TICKS(5), NULL));
  39. znordic_loop();
  40. }
  41. #endif
  42. /*******************************************************************************
  43. * 3-ADS1293- *
  44. *******************************************************************************/
  45. extern uint32_t g_nrf_log_tx_pin;
  46. APP_TIMER_DEF(m_test_tx_timer);
  47. ZDATACHANNEL_DEF(m_zhrs, 2 /*�ص��¼�����??*/, 1 /*client num*/);
  48. static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {}
  49. static void zdatachanel_send_log(const char* fmt, ...) {
  50. static char tx[256] = {0};
  51. static uint16_t len = 0;
  52. va_list args;
  53. va_start(args, fmt);
  54. len = vsprintf(tx, fmt, args);
  55. zdatachannel_data_send((uint8_t*)tx, &len);
  56. va_end(args);
  57. }
  58. static void test_tx_timer_cb(void* p_context) {
  59. zdatachanel_send_log("%d\n", SingleLeadECG_ecg_plod_get_ecg_val());
  60. }
  61. static void on_service_init(void) {
  62. /**
  63. * @brief ͨʼ
  64. */
  65. ZLOGI("init zdatachannel service");
  66. zdatachannel_init_t zdatachannle_init;
  67. memset(&zdatachannle_init, 0, sizeof(zdatachannle_init));
  68. zdatachannle_init.data_handler = zdatachannel_data_handler;
  69. ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init));
  70. }
  71. void main() {
  72. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  73. znordic_init(0, 20);
  74. NRF_LOG_INFO("compile time :%s", __TIME__);
  75. static zble_module_cfg_t cfg = //
  76. {
  77. .deviceName = "ecg_test",
  78. .on_service_init = on_service_init,
  79. };
  80. zble_module_init(&cfg);
  81. SingleLeadECG_adc_module_init();
  82. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  83. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(5), NULL));
  84. zble_module_start_adv();
  85. znordic_loop();
  86. }