|
|
@ -3,8 +3,10 @@ |
|
|
|
#include "znordic.h" |
|
|
|
// |
|
|
|
|
|
|
|
#include "basic/ssd1306/driver_ssd1306_basic.h" |
|
|
|
#include "one_conduction/one_conduction_board.h" |
|
|
|
#include "three_lead\three_lead_board.h" |
|
|
|
|
|
|
|
#if 0 |
|
|
|
static void test_tx_timer_cb(void* p_context) { |
|
|
|
ZLOGI("test_tx_timer_cb"); |
|
|
|
ThreeLeadECG_sdcard_mount(); |
|
|
@ -25,3 +27,171 @@ void main() { |
|
|
|
ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL)); |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
// EEPROM_TEST |
|
|
|
#if 0 |
|
|
|
static void test_tx_timer_cb(void* p_context) { |
|
|
|
static uint32_t data; |
|
|
|
data++; |
|
|
|
// ZLOGI("test_tx_timer_cb %d", data); |
|
|
|
} |
|
|
|
|
|
|
|
extern uint32_t g_nrf_log_tx_pin; |
|
|
|
APP_TIMER_DEF(m_test_tx_timer); |
|
|
|
|
|
|
|
void main() { |
|
|
|
APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20); |
|
|
|
znordic_init(); |
|
|
|
|
|
|
|
// SingleLeadECG_beep_init(); |
|
|
|
// SingleLeadECG_beep_set_state(false); |
|
|
|
NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100)); |
|
|
|
NRF_LOG_INTERNAL_FLUSH(); |
|
|
|
|
|
|
|
SingleLeadECG_eeprom_init(); |
|
|
|
static uint8_t eepromw_test_data[256]; |
|
|
|
static uint8_t eepromw_rx_data[256]; |
|
|
|
for (size_t i = 0; i < 256; i++) { |
|
|
|
eepromw_test_data[i] = i; |
|
|
|
} |
|
|
|
SingleLeadECG_eeprom_write(0, eepromw_test_data, 256); |
|
|
|
// nrf_delay_ms(20); |
|
|
|
// SingleLeadECG_eeprom_read(0, eepromw_rx_data, 256); |
|
|
|
// for (size_t i = 0; i < 256; i++) { |
|
|
|
// ZLOGI("eepromw_rx_data[%d] = %d", i, eepromw_rx_data[i]); |
|
|
|
// NRF_LOG_INTERNAL_FLUSH(); |
|
|
|
// } |
|
|
|
|
|
|
|
ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb)); |
|
|
|
ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL)); |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
/******************************************************************************* |
|
|
|
* 屏幕测试+LED测试 * |
|
|
|
*******************************************************************************/ |
|
|
|
#if 1 |
|
|
|
static void test_tx_timer_cb(void* p_context) { |
|
|
|
static uint32_t data; |
|
|
|
data++; |
|
|
|
ZLOGI("test_tx_timer_cb %d", data); |
|
|
|
|
|
|
|
SingleLeadECG_led_green_set_state(data % 2 == 0); |
|
|
|
SingleLeadECG_led_blue_set_state(data % 3 == 0); |
|
|
|
} |
|
|
|
|
|
|
|
extern uint32_t g_nrf_log_tx_pin; |
|
|
|
APP_TIMER_DEF(m_test_tx_timer); |
|
|
|
|
|
|
|
void main() { |
|
|
|
APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20); |
|
|
|
znordic_init(); |
|
|
|
|
|
|
|
NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100)); |
|
|
|
NRF_LOG_INTERNAL_FLUSH(); |
|
|
|
|
|
|
|
SingleLeadECG_screen_init(); |
|
|
|
ssd1306_basic_init(SSD1306_INTERFACE_SPI, SSD1306_ADDR_SA0_0); |
|
|
|
ssd1306_basic_display_on(); |
|
|
|
ssd1306_basic_string(0, 0, "123456789123456789123", 21, 0, SSD1306_FONT_12); |
|
|
|
ssd1306_basic_string(0, 16, "123456789123456789123", 21, 0, SSD1306_FONT_12); |
|
|
|
ssd1306_basic_string(0, 32, "123456789123456789123", 21, 0, SSD1306_FONT_12); |
|
|
|
ssd1306_basic_string(0, 48, "123456789123456789123", 21, 0, SSD1306_FONT_12); |
|
|
|
|
|
|
|
SingleLeadECG_led_init(); |
|
|
|
|
|
|
|
ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb)); |
|
|
|
ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(100), NULL)); |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
/******************************************************************************* |
|
|
|
* ECG * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
#if 0 |
|
|
|
static void test_tx_timer_cb(void* p_context) { |
|
|
|
static uint32_t data; |
|
|
|
data++; |
|
|
|
// SingleLeadECG_ecg_nlod_get_connected_state(); |
|
|
|
// SingleLeadECG_ecg_plod_get_connected_state(); |
|
|
|
// SingleLeadECG_ecg_plod_get_ecg_val(); |
|
|
|
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()); |
|
|
|
} |
|
|
|
|
|
|
|
extern uint32_t g_nrf_log_tx_pin; |
|
|
|
APP_TIMER_DEF(m_test_tx_timer); |
|
|
|
|
|
|
|
void main() { |
|
|
|
APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20); |
|
|
|
znordic_init(); |
|
|
|
SingleLeadECG_adc_module_init(); |
|
|
|
|
|
|
|
NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100)); |
|
|
|
NRF_LOG_INTERNAL_FLUSH(); |
|
|
|
|
|
|
|
SingleLeadECG_ecg_init(); |
|
|
|
|
|
|
|
ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb)); |
|
|
|
ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(1000), NULL)); |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
/******************************************************************************* |
|
|
|
* 蓝牙测试 * |
|
|
|
*******************************************************************************/ |
|
|
|
#if 0 |
|
|
|
extern uint32_t g_nrf_log_tx_pin; |
|
|
|
APP_TIMER_DEF(m_test_tx_timer); |
|
|
|
|
|
|
|
ZDATACHANNEL_DEF(m_zhrs, 2 /*回调事件优先级*/, 1 /*client num*/); |
|
|
|
static const char* hex2str(const uint8_t* data, int32_t len) { |
|
|
|
static char rx[64] = {0}; |
|
|
|
memset(rx, 0, sizeof(rx)); |
|
|
|
for (int32_t i = 0; i < len; i++) { |
|
|
|
sprintf(rx + i * 2, "%02X", data[i]); |
|
|
|
} |
|
|
|
return rx; |
|
|
|
} |
|
|
|
|
|
|
|
static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) { |
|
|
|
/** |
|
|
|
* @brief 接收到指令数据 |
|
|
|
*/ |
|
|
|
if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) { |
|
|
|
ZLOGI("rx:%s", hex2str(p_evt->params.rx_data.p_data, p_evt->params.rx_data.length)); |
|
|
|
} |
|
|
|
} |
|
|
|
static void on_service_init(void) { |
|
|
|
/** |
|
|
|
* @brief 数据通道初始化 |
|
|
|
*/ |
|
|
|
ZLOGI("init zdatachannel service"); |
|
|
|
zdatachannel_init_t zdatachannle_init; |
|
|
|
memset(&zdatachannle_init, 0, sizeof(zdatachannle_init)); |
|
|
|
zdatachannle_init.data_handler = zdatachannel_data_handler; |
|
|
|
ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init)); |
|
|
|
} |
|
|
|
|
|
|
|
void main() { |
|
|
|
APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20); |
|
|
|
|
|
|
|
znordic_init(0, 20); |
|
|
|
NRF_LOG_INFO("compile time :%s", __TIME__); |
|
|
|
NRF_LOG_INFO("Version :%d", VERSION); |
|
|
|
NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME); |
|
|
|
|
|
|
|
static zble_module_cfg_t cfg = // |
|
|
|
{ |
|
|
|
.deviceName = BLE_NAME, |
|
|
|
.on_service_init = on_service_init, |
|
|
|
}; |
|
|
|
zble_module_init(&cfg); |
|
|
|
|
|
|
|
zble_module_start_adv(); |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
#endif |