|
|
@ -9,6 +9,7 @@ |
|
|
|
#include "one_conduction_board.h" |
|
|
|
#include "sample_data_manager.h" |
|
|
|
#include "znordic.h" |
|
|
|
#if 1 |
|
|
|
typedef enum { |
|
|
|
// ´ý»ú |
|
|
|
kdevice_state_standby = 0, |
|
|
@ -165,6 +166,9 @@ static void state_machine_change_to_state(device_state_t state) { |
|
|
|
static uint32_t cur_state_haspassed_ms() { return znordic_haspassed_ms(m_change_to_cur_state_tp); } |
|
|
|
static bool m_poweronflag; |
|
|
|
static void power_on() { |
|
|
|
if (m_poweronflag) { |
|
|
|
return; |
|
|
|
} |
|
|
|
SingleLeadECG_adc_module_init(); |
|
|
|
SingleLeadECG_beep_init(); |
|
|
|
SingleLeadECG_led_init(); |
|
|
@ -448,12 +452,12 @@ void on_service_init(void) { |
|
|
|
zdatachannle_init.data_handler = zdatachannel_data_handler; |
|
|
|
ZERROR_CHECK(zdatachannel_init(&m_zhrs, &zdatachannle_init)); |
|
|
|
} |
|
|
|
|
|
|
|
#if 1 |
|
|
|
void one_conduction_main() { |
|
|
|
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, 20); |
|
|
|
g_nrf_log_tx_pin = 41; |
|
|
|
|
|
|
|
znordic_init(0, 20); |
|
|
|
znordic_init(); |
|
|
|
NRF_LOG_INFO("compile time :%s", __TIME__); |
|
|
|
NRF_LOG_INFO("Version :%d", VERSION); |
|
|
|
NRF_LOG_INFO("Manufacturer :%s", MANUFACTURER_NAME); |
|
|
@ -465,6 +469,8 @@ void one_conduction_main() { |
|
|
|
}; |
|
|
|
zble_module_init(&cfg); |
|
|
|
hwss_init(); |
|
|
|
// power_on(); |
|
|
|
// hwss_start_capture(); |
|
|
|
|
|
|
|
#if 1 |
|
|
|
SingleLeadECG_ecg_io_init(); |
|
|
@ -476,20 +482,130 @@ void one_conduction_main() { |
|
|
|
ZERROR_CHECK(app_timer_start(m_plod_state_event_detect_tmr, APP_TIMER_TICKS(30), NULL)); |
|
|
|
ZERROR_CHECK(app_timer_start(m_charge_event_detect_tmr, APP_TIMER_TICKS(100), NULL)); |
|
|
|
#endif |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
#else |
|
|
|
|
|
|
|
// ZERROR_CHECK(); |
|
|
|
while (true) { |
|
|
|
app_sched_execute(); |
|
|
|
if (NRF_LOG_PROCESS() == false) { |
|
|
|
nrf_pwr_mgmt_run(); |
|
|
|
} |
|
|
|
} |
|
|
|
void one_conduction_main() { |
|
|
|
APP_SCHED_INIT(SCHED_MAX_EVENT_DATA_SIZE, 20); |
|
|
|
g_nrf_log_tx_pin = 41; |
|
|
|
znordic_init(); |
|
|
|
static zble_module_cfg_t cfg = // |
|
|
|
{ |
|
|
|
.deviceName = BLE_NAME, |
|
|
|
.on_service_init = on_service_init, |
|
|
|
}; |
|
|
|
zble_module_init(&cfg); |
|
|
|
hwss_init(); |
|
|
|
|
|
|
|
NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100)); |
|
|
|
NRF_LOG_INTERNAL_FLUSH(); |
|
|
|
|
|
|
|
// SingleLeadECG_ecg_init(); |
|
|
|
// SingleLeadECG_adc_module_init(); |
|
|
|
SingleLeadECG_beep_init(); |
|
|
|
SingleLeadECG_led_init(); |
|
|
|
SingleLeadECG_ecg_init(); |
|
|
|
SingleLeadECG_battery_init(); |
|
|
|
// hwss_init(); |
|
|
|
// sample_data_mgr_init(); |
|
|
|
// dsp_mgr_init(); |
|
|
|
// zble_module_start_adv(); |
|
|
|
|
|
|
|
hwss_start_capture(); |
|
|
|
|
|
|
|
// znordic_loop(); |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
#endif |
|
|
|
|
|
|
|
// ZERROR_CHECK(app_timer_start(m_state_machine_driver_tmr, APP_TIMER_TICKS(5), NULL)); |
|
|
|
// zble_module_start_adv(); |
|
|
|
// dsp_mgr_init(); |
|
|
|
// dsp_mgr_poweron(); |
|
|
|
// dsp_mgr_change_to_sampling(); |
|
|
|
// dsp_mgr_change_to_sampling(); |
|
|
|
|
|
|
|
#else |
|
|
|
#include <stdarg.h> |
|
|
|
#if defined(UART_PRESENT) |
|
|
|
#include "nrf_uart.h" |
|
|
|
#endif |
|
|
|
#if defined(UARTE_PRESENT) |
|
|
|
#include "nrf_uarte.h" |
|
|
|
#endif |
|
|
|
#define UART_TX_BUF_SIZE 256 /**< UART TX buffer size. */ |
|
|
|
#define UART_RX_BUF_SIZE 256 /**< UART RX buffer size. */ |
|
|
|
uint32_t err_code; |
|
|
|
app_uart_comm_params_t const comm_params = // |
|
|
|
{ |
|
|
|
.rx_pin_no = UART_PIN_DISCONNECTED, |
|
|
|
.tx_pin_no = 41, |
|
|
|
.rts_pin_no = UART_PIN_DISCONNECTED, |
|
|
|
.cts_pin_no = UART_PIN_DISCONNECTED, |
|
|
|
.flow_control = APP_UART_FLOW_CONTROL_DISABLED, |
|
|
|
.use_parity = false, |
|
|
|
.baud_rate = NRF_UARTE_BAUDRATE_921600, |
|
|
|
}; |
|
|
|
|
|
|
|
void uart_error_handle(app_uart_evt_t* p_event) {} |
|
|
|
|
|
|
|
void uartinit() { |
|
|
|
APP_UART_FIFO_INIT(&comm_params, UART_RX_BUF_SIZE, UART_TX_BUF_SIZE, uart_error_handle, APP_IRQ_PRIORITY_LOWEST, err_code); |
|
|
|
APP_ERROR_CHECK(err_code); |
|
|
|
} |
|
|
|
|
|
|
|
void zchip_log(const char* fmt, ...) { |
|
|
|
static char tx[256] = {0}; |
|
|
|
va_list args; |
|
|
|
va_start(args, fmt); |
|
|
|
|
|
|
|
vsprintf(tx, fmt, args); |
|
|
|
for (size_t i = 0; i < strlen(tx); i++) { |
|
|
|
app_uart_put(tx[i]); |
|
|
|
} |
|
|
|
|
|
|
|
va_end(args); |
|
|
|
} |
|
|
|
|
|
|
|
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()); |
|
|
|
// ZLOGI("%d,%d,%d", SingleLeadECG_ecg_nlod_get_connected_state(), SingleLeadECG_ecg_plod_get_connected_state(), SingleLeadECG_ecg_plod_get_ecg_val()); |
|
|
|
|
|
|
|
// zchip_log("%d,%d,%d\n", SingleLeadECG_ecg_nlod_get_connected_state(), SingleLeadECG_ecg_plod_get_connected_state(), SingleLeadECG_ecg_plod_get_ecg_val()); |
|
|
|
ZLOGI("%d,%d,%d", SingleLeadECG_ecg_nlod_get_connected_state(), SingleLeadECG_ecg_plod_get_connected_state(), SingleLeadECG_ecg_plod_get_ecg_val()); |
|
|
|
// app_uart_put('c'); |
|
|
|
// app_uart_put('c'); |
|
|
|
// app_uart_put('c'); |
|
|
|
// app_uart_put('c'); |
|
|
|
// app_uart_put('c'); |
|
|
|
// NRF_LOG_INFO("......"); |
|
|
|
} |
|
|
|
void app_event_process_cb(void* p_event_data, uint16_t event_size) {} |
|
|
|
|
|
|
|
extern uint32_t g_nrf_log_tx_pin; |
|
|
|
APP_TIMER_DEF(m_test_tx_timer); |
|
|
|
|
|
|
|
void one_conduction_main() { |
|
|
|
g_nrf_log_tx_pin = 41; |
|
|
|
APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20); |
|
|
|
znordic_init(); |
|
|
|
SingleLeadECG_adc_module_init(); |
|
|
|
hwss_init(); |
|
|
|
|
|
|
|
// uartinit(); |
|
|
|
|
|
|
|
NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100)); |
|
|
|
NRF_LOG_INTERNAL_FLUSH(); |
|
|
|
|
|
|
|
SingleLeadECG_ecg_init(); |
|
|
|
hwss_start_capture(); |
|
|
|
|
|
|
|
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(5), NULL)); |
|
|
|
znordic_loop(); |
|
|
|
} |
|
|
|
#endif |