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.

614 lines
18 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 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 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 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 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 "app_uart.h"
  11. #include "basic/ssd1306/driver_ssd1306_basic.h"
  12. #include "basic\zdatachannel_service.h"
  13. #include "one_conduction/one_conduction_board.h"
  14. #include "three_lead\three_lead_board.h"
  15. #if defined(UART_PRESENT)
  16. #include "nrf_uart.h"
  17. #endif
  18. #if defined(UARTE_PRESENT)
  19. #include "nrf_uarte.h"
  20. #endif
  21. #if 0
  22. static void test_tx_timer_cb(void* p_context) {
  23. static uint32_t data;
  24. data++;
  25. ZLOGI("tim cb %d", data);
  26. // ThreeLeadECG_sdcard_connect2_ext_usb_sdcard_driver_ic_reset();
  27. }
  28. extern uint32_t g_nrf_log_tx_pin;
  29. APP_TIMER_DEF(m_test_tx_timer);
  30. void main() {
  31. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  32. ThreeLeadECG_beep_init();
  33. ThreeLeadECG_sdcard_base_init();
  34. znordic_init();
  35. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  36. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  37. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(3000), NULL));
  38. znordic_loop();
  39. }
  40. #endif
  41. // EEPROM_TEST
  42. #if 0
  43. static void test_tx_timer_cb(void* p_context) {
  44. static uint32_t data;
  45. data++;
  46. // ZLOGI("test_tx_timer_cb %d", data);
  47. static uint8_t eepromw_test_data[256];
  48. static uint8_t eepromw_rx_data[256];
  49. for (size_t i = 0; i < 256; i++) {
  50. eepromw_test_data[i] = i;
  51. }
  52. // SingleLeadECG_eeprom_write(0, eepromw_test_data, 256);
  53. SingleLeadECG_eeprom_read(0, eepromw_rx_data, 256);
  54. // for (size_t i = 0; i < 256; i++) {
  55. // ZLOGI("eepromw_rx_data[%d] = %d", i, eepromw_rx_data[i]);
  56. // NRF_LOG_INTERNAL_FLUSH();
  57. // }
  58. }
  59. extern uint32_t g_nrf_log_tx_pin;
  60. APP_TIMER_DEF(m_test_tx_timer);
  61. void main() {
  62. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  63. znordic_init();
  64. // SingleLeadECG_beep_init();
  65. // SingleLeadECG_beep_set_state(false);
  66. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  67. NRF_LOG_INTERNAL_FLUSH();
  68. SingleLeadECG_eeprom_init();
  69. // nrf_delay_ms(20);
  70. // SingleLeadECG_eeprom_read(0, eepromw_rx_data, 256);
  71. // for (size_t i = 0; i < 256; i++) {
  72. // ZLOGI("eepromw_rx_data[%d] = %d", i, eepromw_rx_data[i]);
  73. // NRF_LOG_INTERNAL_FLUSH();
  74. // }
  75. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  76. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
  77. znordic_loop();
  78. }
  79. #endif
  80. /*******************************************************************************
  81. * +LED测试 *
  82. *******************************************************************************/
  83. #if 0
  84. static void test_tx_timer_cb(void* p_context) {
  85. static uint32_t data;
  86. data++;
  87. ZLOGI("test_tx_timer_cb %d", data);
  88. SingleLeadECG_led_green_set_state(data % 2 == 0);
  89. SingleLeadECG_led_blue_set_state(data % 3 == 0);
  90. }
  91. extern uint32_t g_nrf_log_tx_pin;
  92. APP_TIMER_DEF(m_test_tx_timer);
  93. void main() {
  94. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  95. znordic_init();
  96. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  97. NRF_LOG_INTERNAL_FLUSH();
  98. SingleLeadECG_screen_init();
  99. ssd1306_basic_init(SSD1306_INTERFACE_SPI, SSD1306_ADDR_SA0_0);
  100. ssd1306_basic_display_on();
  101. ssd1306_basic_string(0, 0, "123456789123456789123", 21, 0, SSD1306_FONT_12);
  102. ssd1306_basic_string(0, 16, "123456789123456789123", 21, 0, SSD1306_FONT_12);
  103. ssd1306_basic_string(0, 32, "123456789123456789123", 21, 0, SSD1306_FONT_12);
  104. ssd1306_basic_string(0, 48, "123456789123456789123", 21, 0, SSD1306_FONT_12);
  105. SingleLeadECG_led_init();
  106. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  107. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
  108. znordic_loop();
  109. }
  110. #endif
  111. /*******************************************************************************
  112. * ECG *
  113. *******************************************************************************/
  114. #if 0
  115. #define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */
  116. #define UART_RX_BUF_SIZE 256 /**< UART RX buffer size. */
  117. uint32_t err_code;
  118. app_uart_comm_params_t const comm_params = //
  119. {
  120. .rx_pin_no = UART_PIN_DISCONNECTED,
  121. .tx_pin_no = 41,
  122. .rts_pin_no = UART_PIN_DISCONNECTED,
  123. .cts_pin_no = UART_PIN_DISCONNECTED,
  124. .flow_control = APP_UART_FLOW_CONTROL_DISABLED,
  125. .use_parity = false,
  126. .baud_rate = NRF_UARTE_BAUDRATE_921600,
  127. };
  128. void uart_error_handle(app_uart_evt_t* p_event) {}
  129. void uartinit() {
  130. APP_UART_FIFO_INIT(&comm_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_error_handle, APP_IRQ_PRIORITY_LOWEST, err_code);
  131. APP_ERROR_CHECK(err_code);
  132. }
  133. void zchip_log(const char* fmt, ...) {
  134. static char tx[256] = {0};
  135. va_list args;
  136. va_start(args, fmt);
  137. vsprintf(tx, fmt, args);
  138. for (size_t i = 0; i < strlen(tx); i++) {
  139. app_uart_put(tx[i]);
  140. }
  141. va_end(args);
  142. }
  143. static void test_tx_timer_cb(void* p_context) {
  144. static uint32_t data;
  145. data++;
  146. // SingleLeadECG_ecg_nlod_get_connected_state();
  147. // SingleLeadECG_ecg_plod_get_connected_state();
  148. // SingleLeadECG_ecg_plod_get_ecg_val();
  149. // 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());
  150. // ZLOGI("%d,%d,%d", SingleLeadECG_ecg_nlod_get_connected_state(), SingleLeadECG_ecg_plod_get_connected_state(), SingleLeadECG_ecg_plod_get_ecg_val());
  151. zchip_log("%d,%d,%d\n", SingleLeadECG_ecg_nlod_get_connected_state(), SingleLeadECG_ecg_plod_get_connected_state(), SingleLeadECG_ecg_plod_get_ecg_val());
  152. // app_uart_put('c');
  153. // app_uart_put('c');
  154. // app_uart_put('c');
  155. // app_uart_put('c');
  156. // app_uart_put('c');
  157. // NRF_LOG_INFO("......");
  158. }
  159. extern uint32_t g_nrf_log_tx_pin;
  160. APP_TIMER_DEF(m_test_tx_timer);
  161. void main() {
  162. // g_nrf_log_tx_pin = 41;
  163. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  164. znordic_init();
  165. SingleLeadECG_adc_module_init();
  166. uartinit();
  167. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  168. NRF_LOG_INTERNAL_FLUSH();
  169. SingleLeadECG_ecg_init();
  170. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  171. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(5), NULL));
  172. znordic_loop();
  173. }
  174. #endif
  175. /*******************************************************************************
  176. * *
  177. *******************************************************************************/
  178. #if 0
  179. extern uint32_t g_nrf_log_tx_pin;
  180. APP_TIMER_DEF(m_test_tx_timer);
  181. ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/);
  182. static const char* hex2str(const uint8_t* data, int32_t len) {
  183. static char rx[64] = {0};
  184. memset(rx, 0, sizeof(rx));
  185. for (int32_t i = 0; i < len; i++) {
  186. sprintf(rx + i * 2, "%02X", data[i]);
  187. }
  188. return rx;
  189. }
  190. static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
  191. /**
  192. * @brief
  193. */
  194. if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
  195. ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length));
  196. }
  197. }
  198. static void on_service_init(void) {
  199. /**
  200. * @brief
  201. */
  202. ZLOGI("init zdatachannel service");
  203. zdatachannel_init_t zdatachannle_init;
  204. memset(&zdatachannle_init, 0, sizeof(zdatachannle_init));
  205. zdatachannle_init.data_handler = zdatachannel_data_handler;
  206. ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init));
  207. }
  208. void main() {
  209. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  210. ThreeLeadECG_sdcard_base_init();
  211. znordic_init(0, 20);
  212. NRF_LOG_INFO("compile time :%s", __TIME__);
  213. NRF_LOG_INFO("Version :%d", VERSION);
  214. NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME);
  215. static zble_module_cfg_t cfg = //
  216. {
  217. .deviceName = BLE_NAME,
  218. .on_service_init = on_service_init,
  219. };
  220. zble_module_init(&cfg);
  221. zble_module_start_adv();
  222. znordic_loop();
  223. }
  224. #endif
  225. #if 0
  226. /*******************************************************************************
  227. * ADCTEST *
  228. *******************************************************************************/
  229. static void test_tx_timer_cb(void* p_context) {
  230. static uint32_t data;
  231. data++;
  232. // ZLOGI("test_tx_timer_cb %d", data);
  233. static uint8_t eepromw_test_data[256];
  234. static uint8_t eepromw_rx_data[256];
  235. for (size_t i = 0; i < 256; i++) {
  236. eepromw_test_data[i] = i;
  237. }
  238. int16_t adc = SingleLeadECG_battery_get_adc_val();
  239. int16_t mv = adc * 1.0 / 4096 * 3.6 * 1000 / 2.0 * 3;
  240. ZLOGI("battery:%d", mv);
  241. }
  242. extern uint32_t g_nrf_log_tx_pin;
  243. APP_TIMER_DEF(m_test_tx_timer);
  244. void main() {
  245. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  246. znordic_init();
  247. SingleLeadECG_adc_module_init();
  248. SingleLeadECG_battery_init();
  249. // SingleLeadECG_beep_init();
  250. // SingleLeadECG_beep_set_state(false);
  251. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  252. NRF_LOG_INTERNAL_FLUSH();
  253. // nrf_delay_ms(20);
  254. // SingleLeadECG_eeprom_read(0, eepromw_rx_data, 256);
  255. // for (size_t i = 0; i < 256; i++) {
  256. // ZLOGI("eepromw_rx_data[%d] = %d", i, eepromw_rx_data[i]);
  257. // NRF_LOG_INTERNAL_FLUSH();
  258. // }
  259. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  260. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
  261. znordic_loop();
  262. }
  263. #endif
  264. #if 1
  265. /*******************************************************************************
  266. * 3-ADS1293- *
  267. *******************************************************************************/
  268. #if 0
  269. static void test_tx_timer_cb(void* p_context) {
  270. static uint32_t data;
  271. data++;
  272. ZLOGI("tim cb %d :%d %d", data, ThreeLeadECG_ready_pin_state_get(), ThreeLeadECG_LineInputDet_get_state());
  273. // ThreeLeadECG_sdcard_connect2_ext_usb_sdcard_driver_ic_reset();
  274. }
  275. extern uint32_t g_nrf_log_tx_pin;
  276. APP_TIMER_DEF(m_test_tx_timer);
  277. void main() {
  278. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  279. // ThreeLeadECG_sdcard_base_init();
  280. znordic_init();
  281. ThreeLeadECG_ecg_init();
  282. ThreeLeadECG_LineInputDet_init();
  283. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  284. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  285. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(3000), NULL));
  286. znordic_loop();
  287. }
  288. #endif
  289. extern uint32_t g_nrf_log_tx_pin;
  290. APP_TIMER_DEF(m_test_tx_timer);
  291. static void zdatachanel_send_log(const char* fmt, ...) {
  292. static char tx[256] = {0};
  293. static uint16_t len = 0;
  294. va_list args;
  295. va_start(args, fmt);
  296. len = vsprintf(tx, fmt, args);
  297. zdatachannel_data_send((uint8_t*)tx, &len);
  298. va_end(args);
  299. }
  300. static const char* dumplodstate(uint16_t lodstate) {
  301. static char buf[64];
  302. memset(buf, 0, sizeof(buf));
  303. /**
  304. * @brief
  305. * 1111_0000_0000_0000
  306. */
  307. sprintf(buf, "%d%d%d%d_%d%d%d%d_%d%d%d%d_%d%d%d%d", //
  308. lodstate >> 15 & 0x1, lodstate >> 14 & 0x1, lodstate >> 13 & 0x1, lodstate >> 12 & 0x1, //
  309. lodstate >> 11 & 0x1, lodstate >> 10 & 0x1, lodstate >> 9 & 0x1, lodstate >> 8 & 0x1, //
  310. lodstate >> 7 & 0x1, lodstate >> 6 & 0x1, lodstate >> 5 & 0x1, lodstate >> 4 & 0x1, //
  311. lodstate >> 3 & 0x1, lodstate >> 2 & 0x1, lodstate >> 1 & 0x1, lodstate >> 0 & 0x1);
  312. return buf;
  313. }
  314. static void test_tx_timer_cb(void* p_context) {
  315. static uint32_t data;
  316. data++;
  317. uint16_t val;
  318. ThreeLeadECG_ads1293_get_lod_state(&val);
  319. #if 0
  320. uint32_t sample0;
  321. uint32_t sample1;
  322. uint32_t sample2;
  323. ThreeLeadECG_ads1293_sample(&sample0, &sample1, &sample2);
  324. zdatachanel_send_log("%d,%d,%d\n", sample0, sample1, sample2);
  325. #endif
  326. uint32_t sample0;
  327. uint32_t sample1;
  328. uint32_t sample2;
  329. uint32_t sample10;
  330. uint32_t sample11;
  331. uint32_t sample12;
  332. ThreeLeadECG_ads1293_sample_all(&sample0, &sample1, &sample2, &sample10, &sample11, &sample12);
  333. zdatachanel_send_log("%d,%d,%d,%d,%d,%d\n", sample0, sample1, sample2, sample10, sample11, sample12);
  334. // zdatachanel_send_log("%d,%d,%d\n", data, data, data);
  335. // zdatachanel_send_log("%d %d %s\n", ThreeLeadECG_ready_pin_state_get(), ThreeLeadECG_LineInputDet_get_state(), dumplodstate(val));
  336. // zdatachannel_data_send(tx, &p_length);
  337. }
  338. ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/);
  339. static const char* hex2str(const uint8_t* data, int32_t len) {
  340. static char rx[64] = {0};
  341. memset(rx, 0, sizeof(rx));
  342. for (int32_t i = 0; i < len; i++) {
  343. sprintf(rx + i * 2, "%02X", data[i]);
  344. }
  345. return rx;
  346. }
  347. // void cmd_remove_note(char* input, int inputlen) {
  348. // bool detect_note = false;
  349. // for (int i = 0; i < inputlen; i++) {
  350. // if (!detect_note && input[i] == '#') {
  351. // detect_note = true;
  352. // }
  353. // if (detect_note) {
  354. // input[i] = 0;
  355. // }
  356. // }
  357. // }
  358. // void cmd_prase_cmd(char* input, int inputlen, int32_t* argc, char* argv[]) {
  359. // for (int i = 0; input[i] == 0 || i < inputlen; i++) {
  360. // if (input[i] == ' ' || input[i] == '\r' || input[i] == '\n') {
  361. // input[i] = 0;
  362. // }
  363. // }
  364. // int j = 0;
  365. // for (int i = 0; input[i] == 0 || i < inputlen; i++) {
  366. // if (input[i] != 0 && j == 0) {
  367. // argv[*argc] = &input[i];
  368. // j = 1;
  369. // *argc = *argc + 1;
  370. // continue;
  371. // }
  372. // if (input[i] == 0 && j == 1) {
  373. // j = 0;
  374. // continue;
  375. // }
  376. // }
  377. // }
  378. char cmdcache[256] = {0};
  379. static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
  380. /**
  381. * @brief
  382. */
  383. if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
  384. }
  385. }
  386. static void on_service_init(void) {
  387. /**
  388. * @brief
  389. */
  390. ZLOGI("init zdatachannel service");
  391. zdatachannel_init_t zdatachannle_init;
  392. memset(&zdatachannle_init, 0, sizeof(zdatachannle_init));
  393. zdatachannle_init.data_handler = zdatachannel_data_handler;
  394. ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init));
  395. }
  396. void main() {
  397. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  398. ThreeLeadECG_sdcard_base_init();
  399. znordic_init(0, 20);
  400. NRF_LOG_INFO("compile time :%s", __TIME__);
  401. NRF_LOG_INFO("Version :%d", VERSION);
  402. NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME);
  403. static zble_module_cfg_t cfg = //
  404. {
  405. .deviceName = BLE_NAME,
  406. .on_service_init = on_service_init,
  407. };
  408. zble_module_init(&cfg);
  409. ThreeLeadECG_ecg_init();
  410. ThreeLeadECG_LineInputDet_init();
  411. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  412. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(5), NULL));
  413. zble_module_start_adv();
  414. znordic_loop();
  415. }
  416. #endif
  417. #if 0
  418. /*******************************************************************************
  419. * 3-led测试 *
  420. *******************************************************************************/
  421. static void test_tx_timer_cb(void* p_context) {
  422. static uint32_t data;
  423. data++;
  424. ZLOGI("test_tx_timer_cb %d", data);
  425. ThreeLeadECG_led_green_set_state(data % 2 == 0);
  426. }
  427. extern uint32_t g_nrf_log_tx_pin;
  428. APP_TIMER_DEF(m_test_tx_timer);
  429. void main() {
  430. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  431. znordic_init();
  432. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  433. NRF_LOG_INTERNAL_FLUSH();
  434. ThreeLeadECG_led_init();
  435. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  436. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
  437. znordic_loop();
  438. }
  439. #endif
  440. #if 0
  441. /*******************************************************************************
  442. * 3- *
  443. *******************************************************************************/
  444. static void test_tx_timer_cb(void* p_context) {
  445. static uint32_t data;
  446. data++;
  447. int16_t mv = ThreeLeadECG_battery_get_adc_val() * 1.0 / 4096 * 3.3 * 1000 / 2.0 * 3;
  448. ZLOGI("battery:%d", mv);
  449. }
  450. extern uint32_t g_nrf_log_tx_pin;
  451. APP_TIMER_DEF(m_test_tx_timer);
  452. void main() {
  453. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  454. znordic_init();
  455. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  456. NRF_LOG_INTERNAL_FLUSH();
  457. ThreeLeadECG_adc_module_init();
  458. ThreeLeadECG_battery_init();
  459. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  460. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
  461. znordic_loop();
  462. }
  463. #endif
  464. #if 0
  465. /*******************************************************************************
  466. * 3-flash测试 *
  467. *******************************************************************************/
  468. static void test_tx_timer_cb(void* p_context) {
  469. static uint32_t data;
  470. data++;
  471. }
  472. extern uint32_t g_nrf_log_tx_pin;
  473. APP_TIMER_DEF(m_test_tx_timer);
  474. void main() {
  475. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  476. znordic_init();
  477. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  478. NRF_LOG_INTERNAL_FLUSH();
  479. ThreeLeadECG_sdcard_base_init();
  480. ThreeLeadECG_sdcard_mount();
  481. ThreeLeadECG_sdcard_umount();
  482. ThreeLeadECG_sdcard_mount();
  483. ThreeLeadECG_sdcard_umount();
  484. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  485. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
  486. znordic_loop();
  487. }
  488. #endif
  489. #if 0
  490. /*******************************************************************************
  491. * 3-flash测试 *
  492. *******************************************************************************/
  493. static void test_tx_timer_cb(void* p_context) {
  494. static uint32_t data;
  495. data++;
  496. ZLOGI("button %d", ThreeLeadECG_button_get_state());
  497. }
  498. extern uint32_t g_nrf_log_tx_pin;
  499. APP_TIMER_DEF(m_test_tx_timer);
  500. void main() {
  501. APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
  502. znordic_init();
  503. NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
  504. NRF_LOG_INTERNAL_FLUSH();
  505. ThreeLeadECG_button_init();
  506. ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  507. ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(300), NULL));
  508. znordic_loop();
  509. }
  510. #endif