Browse Source

update

3lead_uart_test_ok_version
zhaohe 1 year ago
parent
commit
819cd9265f
  1. 2
      app/app.uvoptx
  2. 2
      app/config/sdk_config.h
  3. 67
      app/main.c
  4. 8
      app/src/one_conduction/one_conduction_board.c

2
app/app.uvoptx

@ -1000,7 +1000,7 @@
<Group> <Group>
<GroupName>nRF_Libraries</GroupName> <GroupName>nRF_Libraries</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>

2
app/config/sdk_config.h

@ -4597,7 +4597,7 @@
#endif #endif
// <o> NRFX_UART0_ENABLED - Enable UART0 instance // <o> NRFX_UART0_ENABLED - Enable UART0 instance
#ifndef NRFX_UART0_ENABLED #ifndef NRFX_UART0_ENABLED
#define NRFX_UART0_ENABLED 0
#define NRFX_UART0_ENABLED 1
#endif #endif
// <o> NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control // <o> NRFX_UART_DEFAULT_CONFIG_HWFC - Hardware Flow Control

67
app/main.c

@ -3,9 +3,22 @@
#include "znordic.h" #include "znordic.h"
// //
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//
#include "app_uart.h"
#include "basic/ssd1306/driver_ssd1306_basic.h" #include "basic/ssd1306/driver_ssd1306_basic.h"
#include "one_conduction/one_conduction_board.h" #include "one_conduction/one_conduction_board.h"
#include "three_lead\three_lead_board.h" #include "three_lead\three_lead_board.h"
#if defined(UART_PRESENT)
#include "nrf_uart.h"
#endif
#if defined(UARTE_PRESENT)
#include "nrf_uarte.h"
#endif
#if 0 #if 0
static void test_tx_timer_cb(void* p_context) { static void test_tx_timer_cb(void* p_context) {
ZLOGI("test_tx_timer_cb"); ZLOGI("test_tx_timer_cb");
@ -72,7 +85,7 @@ void main() {
/******************************************************************************* /*******************************************************************************
* +LED测试 * * +LED测试 *
*******************************************************************************/ *******************************************************************************/
#if 1
#if 0
static void test_tx_timer_cb(void* p_context) { static void test_tx_timer_cb(void* p_context) {
static uint32_t data; static uint32_t data;
data++; data++;
@ -112,31 +125,77 @@ void main() {
* ECG * * ECG *
*******************************************************************************/ *******************************************************************************/
#if 0
#if 1
#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 void test_tx_timer_cb(void* p_context) {
static uint32_t data; static uint32_t data;
data++; data++;
// SingleLeadECG_ecg_nlod_get_connected_state(); // SingleLeadECG_ecg_nlod_get_connected_state();
// SingleLeadECG_ecg_plod_get_connected_state(); // SingleLeadECG_ecg_plod_get_connected_state();
// SingleLeadECG_ecg_plod_get_ecg_val(); // 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 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());
// app_uart_put('c');
// app_uart_put('c');
// app_uart_put('c');
// app_uart_put('c');
// app_uart_put('c');
// NRF_LOG_INFO("......");
} }
extern uint32_t g_nrf_log_tx_pin; extern uint32_t g_nrf_log_tx_pin;
APP_TIMER_DEF(m_test_tx_timer); APP_TIMER_DEF(m_test_tx_timer);
void main() { void main() {
// g_nrf_log_tx_pin = 41;
APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20); APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
znordic_init(); znordic_init();
SingleLeadECG_adc_module_init(); SingleLeadECG_adc_module_init();
uartinit();
NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100)); NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
NRF_LOG_INTERNAL_FLUSH(); NRF_LOG_INTERNAL_FLUSH();
SingleLeadECG_ecg_init(); SingleLeadECG_ecg_init();
ZERROR_CHECK(app_timer_create(&m_test_tx_timer, APP_TIMER_MODE_REPEATED, test_tx_timer_cb)); 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));
ZERROR_CHECK(app_timer_start(m_test_tx_timer, APP_TIMER_TICKS(5), NULL));
znordic_loop(); znordic_loop();
} }
#endif #endif

8
app/src/one_conduction/one_conduction_board.c

@ -28,10 +28,10 @@
#define ECG_NLOD_PIN 3 #define ECG_NLOD_PIN 3
#define ECG_PLOD_PIN 28 #define ECG_PLOD_PIN 28
#define ECG_ADC_PIN NRF_SAADC_INPUT_AIN2
#define ECG_ADC_PIN NRF_SAADC_INPUT_AIN0
#define ECG_ADC_CHANNEL 0 // 不重复即可 #define ECG_ADC_CHANNEL 0 // 不重复即可
#define BATTERY_ADC_PIN NRF_SAADC_INPUT_AIN5
#define BATTERY_ADC_PIN NRF_SAADC_INPUT_AIN3
#define BATTERY_ADC_CHANNEL 1 // 不重复即可 #define BATTERY_ADC_CHANNEL 1 // 不重复即可
#define EEPROM_I2C_SCL_M 15 // I2C SCL引脚 #define EEPROM_I2C_SCL_M 15 // I2C SCL引脚
@ -177,8 +177,8 @@ void SingleLeadECG_ecg_init() {
channel_config.acq_time = NRF_SAADC_ACQTIME_40US; channel_config.acq_time = NRF_SAADC_ACQTIME_40US;
ZERROR_CHECK(nrfx_saadc_channel_init(ECG_ADC_CHANNEL, &channel_config)); ZERROR_CHECK(nrfx_saadc_channel_init(ECG_ADC_CHANNEL, &channel_config));
nrf_gpio_cfg_sense_input(ECG_NLOD_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
nrf_gpio_cfg_sense_input(ECG_PLOD_PIN, NRF_GPIO_PIN_NOPULL, NRF_GPIO_PIN_SENSE_LOW);
nrf_gpio_cfg_sense_input(ECG_NLOD_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
nrf_gpio_cfg_sense_input(ECG_PLOD_PIN, NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
} }
uint32_t SingleLeadECG_ecg_nlod_get_connected_state() { return nrf_gpio_pin_read(ECG_NLOD_PIN); } uint32_t SingleLeadECG_ecg_nlod_get_connected_state() { return nrf_gpio_pin_read(ECG_NLOD_PIN); }

Loading…
Cancel
Save