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.

103 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 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 "one_conduction/one_conduction_main.h"
  2. #include "three_conduction/three_conduction_main.h"
  3. int main(void) { one_conduction_main(); }
  4. #if 0
  5. ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/);
  6. APP_TIMER_DEF(m_test_tx_timer);
  7. static const char* hex2str(const uint8_t* data, int32_t len) {
  8. static char rx[64] = {0};
  9. memset(rx, 0, sizeof(rx));
  10. for (int32_t i = 0; i < len; i++) {
  11. sprintf(rx + i * 2, "%02X", data[i]);
  12. }
  13. return rx;
  14. }
  15. void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
  16. /**
  17. * @brief
  18. */
  19. if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
  20. ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length));
  21. }
  22. }
  23. static void ble_evt_handler(ble_evt_t const* p_ble_evt, void* p_context) {
  24. switch (p_ble_evt->header.evt_id) {
  25. case BLE_GAP_EVT_CONNECTED:
  26. ZLOGI("Connected");
  27. break;
  28. case BLE_GAP_EVT_DISCONNECTED:
  29. ZLOGI("Disconnected");
  30. // zble_module_start_adv();
  31. break;
  32. }
  33. }
  34. void on_service_init(void) {
  35. /**
  36. * @brief
  37. */
  38. ZLOGI("init zdatachannel service");
  39. zdatachannel_init_t zdatachannle_init;
  40. memset(&zdatachannle_init, 0, sizeof(zdatachannle_init));
  41. zdatachannle_init.data_handler = zdatachannel_data_handler;
  42. ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init));
  43. }
  44. static void test_tx_timer_cb(void* p_context) {
  45. // static uint32_t data;
  46. // uint16_t txlen = 4;
  47. // data++;
  48. // zdatachannel_data_send((uint8_t*)&data, &txlen);
  49. // ZLOGI("adc channel %d %d", adc_module_heart_elect_channel_read_val(), adc_module_battery_channel_read_val());
  50. ZLOGI("test_tx_timer_cb");
  51. NVIC_SystemReset();
  52. // board_spi_transfer_test();
  53. // uint8_t data[] = {0xAA, 0xBB};
  54. // board_i2c_write(0x3C, data, 2);
  55. // fatfs_test_write();
  56. }
  57. static void board_init() {
  58. // adc_module_init();
  59. // adc_module_battery_channel_init(NRF_SAADC_INPUT_VDD);
  60. // adc_module_heart_elect_channel_init(NRF_SAADC_INPUT_AIN2);
  61. // board_spi_init();
  62. // board_i2c_init();
  63. }
  64. int main(void) {
  65. zsys_init();
  66. NRF_LOG_INFO("compile time :%s", __TIME__);
  67. NRF_LOG_INFO("Version :%d", VERSION);
  68. NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME);
  69. static zble_module_cfg_t cfg = //
  70. {
  71. .deviceName = "iflytop_test_ble",
  72. .on_service_init = on_service_init,
  73. };
  74. zble_module_init(&cfg);
  75. board_init();
  76. // fatfs_init();
  77. NRF_SDH_BLE_OBSERVER(m_ble_observer, 3, ble_evt_handler, NULL);
  78. // ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb));
  79. // ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL));
  80. // pwm_trigger();
  81. // wd_init();
  82. zble_module_start_adv();
  83. zsys_loop();
  84. }
  85. #endif