Browse Source

test_v1

test_filter
zhaohe 1 year ago
parent
commit
b9838ebc8b
  1. 3
      .vscode/settings.json
  2. 2
      app/app.uvprojx
  3. 2
      app/config/sdk_config.h
  4. 117
      app/main.c
  5. 2
      app/src/board/board.h

3
.vscode/settings.json

@ -93,7 +93,8 @@
"heart_wave_sample_service.h": "c",
"device_info_mgr.h": "c",
"znordic_device_info_mgr.h": "c",
"device_state.h": "c"
"device_state.h": "c",
"app_event.h": "c"
},
"files.encoding": "gbk"
}

2
app/app.uvprojx

@ -313,7 +313,7 @@
</ArmAdsMisc>
<Cads>
<interw>1</interw>
<Optim>4</Optim>
<Optim>1</Optim>
<oTime>0</oTime>
<SplitLS>0</SplitLS>
<OneElfS>1</OneElfS>

2
app/config/sdk_config.h

@ -11963,7 +11963,7 @@
// <2=> NRF_SDH_DISPATCH_MODEL_POLLING
#ifndef NRF_SDH_DISPATCH_MODEL
#define NRF_SDH_DISPATCH_MODEL 1
#define NRF_SDH_DISPATCH_MODEL 0
#endif
// </h>

117
app/main.c

@ -20,9 +20,124 @@
#include "nrf_uarte.h"
#endif
#if 1
#if 0
int main() {
one_conduction_main();
return 0;
}
#else
#include "nrfx_timer.h"
ZDATACHANNEL_DEF(m_zhrs, 2 /*优先级*/, 1 /*client num*/); //
static const nrfx_timer_t m_timer = NRFX_TIMER_INSTANCE(1); /**< Timer used for channel sweeps and tx with duty cycle. */
static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {
/**
* @brief
*/
if (p_evt->type == ZDATACHANNEL_EVT_RX_DATA) {
}
}
static void on_service_init(void) {
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));
}
uint16_t adc_val_cache[5] = {0};
int adc_val_index = 0;
void sendpacket_to_pc() {
uint8_t data[255];
// adc_val_cache[0] = 1;
// adc_val_cache[1] = 2;
// adc_val_cache[2] = 3;
// adc_val_cache[3] = 4;
// adc_val_cache[4] = 5;
for (int i = 0; i < adc_val_index; i++) {
data[i * 6 + 0] = 0xA2;
data[i * 6 + 1] = 0x2;
data[i * 6 + 2] = adc_val_cache[i] & 0xff;
data[i * 6 + 3] = adc_val_cache[i] >> 8 & 0xff;
data[i * 6 + 4] = 0x2;
data[i * 6 + 5] = 0xA2;
}
zdatachannel_data_send2(data, 6 * adc_val_index);
}
static void nrfx_timer_event_handler(nrf_timer_event_t event_type, void* p_context) { //
uint16_t val = SingleLeadECG_ecg_plod_get_ecg_val(); // 12bit
/*******************************************************************************
* *
*******************************************************************************/
adc_val_cache[adc_val_index] = val;
adc_val_index++;
if (adc_val_index >= 5) {
if (zdatachannel_is_connected()) {
sendpacket_to_pc();
} else {
}
adc_val_index = 0;
}
static int cnt;
static bool state;
cnt++;
if (zdatachannel_is_connected()) {
SingleLeadECG_led_green_set_state(1);
} else {
if (cnt % 500 == 0) {
SingleLeadECG_led_green_set_state(state);
state = !state;
}
}
}
int main() { //
APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
znordic_init();
NRF_LOG_INFO("compile time :%s", __TIME__);
ztm_t tm;
static zble_module_cfg_t cfg = //
{
.deviceName = "OneLeadTest",
.on_service_init = on_service_init,
};
zble_module_init(&cfg);
SingleLeadECG_adc_module_init();
SingleLeadECG_led_init();
SingleLeadECG_led_green_set_state(0);
zble_module_start_adv();
/*******************************************************************************
* *
*******************************************************************************/
/**
* @brief
*/
nrfx_err_t err;
nrfx_timer_config_t timer_cfg = {
.frequency = NRF_TIMER_FREQ_500kHz,
.mode = NRF_TIMER_MODE_TIMER,
.bit_width = NRF_TIMER_BIT_WIDTH_24,
.p_context = NULL,
.interrupt_priority = NRFX_TIMER_DEFAULT_CONFIG_IRQ_PRIORITY,
};
err = nrfx_timer_init(&m_timer, &timer_cfg, nrfx_timer_event_handler);
if (err != NRFX_SUCCESS) {
NRF_LOG_ERROR("nrfx_timer_init failed with: %d\n", err);
}
uint32_t timer_ticks = nrfx_timer_ms_to_ticks(&m_timer, 5); // 500HZ
nrfx_timer_extended_compare(&m_timer, NRF_TIMER_CC_CHANNEL0, timer_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true);
nrfx_timer_enable(&m_timer);
znordic_loop();
}
#endif

2
app/src/board/board.h

@ -21,6 +21,6 @@
#define AUTOMATIC_SLEEP_TIME 15000
#define SAMPLE_MIN_TIME_S (30.0)
#define ENABLE_SLEEP
// #define ENABLE_SLEEP
#define LITTLE_DATA_BLOCK_FRAME_NUM 5 // 每次多少帧上报一次
Loading…
Cancel
Save