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.

196 lines
6.1 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 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 "basic/ssd1306/driver_ssd1306_basic.h"
  6. #include "one_conduction/one_conduction_board.h"
  7. #include "three_lead\three_lead_board.h"
  8. #if 0
  9. static void test_tx_timer_cb(void* p_context) {
  10. ZLOGI("test_tx_timer_cb");
  11. ThreeLeadECG_sdcard_mount();
  12. uint32_t data;
  13. data = 1;
  14. }
  15. extern uint32_t g_nrf_log_tx_pin;
  16. APP_TIMER_DEF(m_test_tx_timer);
  17. void main() {
  18. g_nrf_log_tx_pin = 2;
  19. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  20. znordic_init();
  21. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  22. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_SINGLE_SHOT, test_tx_timer_cb));
  23. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
  24. znordic_loop();
  25. }
  26. #endif
  27. // EEPROM_TEST
  28. #if 0
  29. static void test_tx_timer_cb(void* p_context) {
  30. static uint32_t data;
  31. data++;
  32. // ZLOGI("test_tx_timer_cb %d", data);
  33. }
  34. extern uint32_t g_nrf_log_tx_pin;
  35. APP_TIMER_DEF(m_test_tx_timer);
  36. void main() {
  37. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  38. znordic_init();
  39. // SingleLeadECG_beep_init();
  40. // SingleLeadECG_beep_set_state(false);
  41. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  42. NRF_LOG_INTERNAL_FLUSH();
  43. SingleLeadECG_eeprom_init();
  44. static uint8_t eepromw_test_data[256];
  45. static uint8_t eepromw_rx_data[256];
  46. for (size_t i = 0; i < 256; i++) {
  47. eepromw_test_data[i] = i;
  48. }
  49. SingleLeadECG_eeprom_write(0, eepromw_test_data, 256);
  50. // nrf_delay_ms(20);
  51. // SingleLeadECG_eeprom_read(0, eepromw_rx_data, 256);
  52. // for (size_t i = 0; i < 256; i++) {
  53. // ZLOGI("eepromw_rx_data[%d] = %d", i, eepromw_rx_data[i]);
  54. // NRF_LOG_INTERNAL_FLUSH();
  55. // }
  56. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  57. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
  58. znordic_loop();
  59. }
  60. #endif
  61. /*******************************************************************************
  62. * +LED测试 *
  63. *******************************************************************************/
  64. #if 1
  65. static void test_tx_timer_cb(void* p_context) {
  66. static uint32_t data;
  67. data++;
  68. ZLOGI("test_tx_timer_cb %d", data);
  69. SingleLeadECG_led_green_set_state(data % 2 == 0);
  70. SingleLeadECG_led_blue_set_state(data % 3 == 0);
  71. }
  72. extern uint32_t g_nrf_log_tx_pin;
  73. APP_TIMER_DEF(m_test_tx_timer);
  74. void main() {
  75. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  76. znordic_init();
  77. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  78. NRF_LOG_INTERNAL_FLUSH();
  79. SingleLeadECG_screen_init();
  80. ssd1306_basic_init(SSD1306_INTERFACE_SPI, SSD1306_ADDR_SA0_0);
  81. ssd1306_basic_display_on();
  82. ssd1306_basic_string(0, 0, "123456789123456789123", 21, 0, SSD1306_FONT_12);
  83. ssd1306_basic_string(0, 16, "123456789123456789123", 21, 0, SSD1306_FONT_12);
  84. ssd1306_basic_string(0, 32, "123456789123456789123", 21, 0, SSD1306_FONT_12);
  85. ssd1306_basic_string(0, 48, "123456789123456789123", 21, 0, SSD1306_FONT_12);
  86. SingleLeadECG_led_init();
  87. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  88. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
  89. znordic_loop();
  90. }
  91. #endif
  92. /*******************************************************************************
  93. * ECG *
  94. *******************************************************************************/
  95. #if 0
  96. static void test_tx_timer_cb(void* p_context) {
  97. static uint32_t data;
  98. data++;
  99. // SingleLeadECG_ecg_nlod_get_connected_state();
  100. // SingleLeadECG_ecg_plod_get_connected_state();
  101. // SingleLeadECG_ecg_plod_get_ecg_val();
  102. ZLOGI("%d nlod %d plod %d ecg:%d", data, SingleLeadECG_ecg_nlod_get_connected_state(), SingleLeadECG_ecg_plod_get_connected_state(), SingleLeadECG_ecg_plod_get_ecg_val());
  103. }
  104. extern uint32_t g_nrf_log_tx_pin;
  105. APP_TIMER_DEF(m_test_tx_timer);
  106. void main() {
  107. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  108. znordic_init();
  109. SingleLeadECG_adc_module_init();
  110. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  111. NRF_LOG_INTERNAL_FLUSH();
  112. SingleLeadECG_ecg_init();
  113. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  114. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(1000), NULL));
  115. znordic_loop();
  116. }
  117. #endif
  118. /*******************************************************************************
  119. * *
  120. *******************************************************************************/
  121. #if 0
  122. extern uint32_t g_nrf_log_tx_pin;
  123. APP_TIMER_DEF(m_test_tx_timer);
  124. ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/);
  125. static const char* hex2str(const uint8_t* data, int32_t len) {
  126. static char rx[64] = {0};
  127. memset(rx, 0, sizeof(rx));
  128. for (int32_t i = 0; i < len; i++) {
  129. sprintf(rx + i * 2, "%02X", data[i]);
  130. }
  131. return rx;
  132. }
  133. static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
  134. /**
  135. * @brief
  136. */
  137. if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
  138. ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length));
  139. }
  140. }
  141. static void on_service_init(void) {
  142. /**
  143. * @brief
  144. */
  145. ZLOGI("init zdatachannel service");
  146. zdatachannel_init_t zdatachannle_init;
  147. memset(&zdatachannle_init, 0, sizeof(zdatachannle_init));
  148. zdatachannle_init.data_handler = zdatachannel_data_handler;
  149. ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init));
  150. }
  151. void main() {
  152. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  153. znordic_init(0, 20);
  154. NRF_LOG_INFO("compile time :%s", __TIME__);
  155. NRF_LOG_INFO("Version :%d", VERSION);
  156. NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME);
  157. static zble_module_cfg_t cfg = //
  158. {
  159. .deviceName = BLE_NAME,
  160. .on_service_init = on_service_init,
  161. };
  162. zble_module_init(&cfg);
  163. zble_module_start_adv();
  164. znordic_loop();
  165. }
  166. #endif