Browse Source

update

3lead_uart_test_ok_version
zhaohe 1 year ago
parent
commit
6e2a2d9d9a
  1. 85
      app/main.c
  2. 146
      ble_app_uart_c/ble_app_uart_c_pca10100_s122.uvguix.h_zha
  3. 4
      ble_app_uart_c/ble_app_uart_c_pca10100_s122.uvoptx
  4. 4
      ble_app_uart_c/main.c

85
app/main.c

@ -10,6 +10,7 @@
//
#include "app_uart.h"
#include "basic/ssd1306/driver_ssd1306_basic.h"
#include "basic\zdatachannel_service.h"
#include "one_conduction/one_conduction_board.h"
#include "three_lead\three_lead_board.h"
#if defined(UART_PRESENT)
@ -213,7 +214,7 @@ void main() {
/*******************************************************************************
* *
*******************************************************************************/
#if 1
#if 0
extern uint32_t g_nrf_log_tx_pin;
APP_TIMER_DEF(m_test_tx_timer);
@ -313,11 +314,11 @@ void main() {
znordic_loop();
}
#endif
#if 0
#if 1
/*******************************************************************************
* 3-ADS1293- *
*******************************************************************************/
#if 0
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
@ -343,6 +344,84 @@ void main() {
znordic_loop();
}
#endif
extern uint32_t g_nrf_log_tx_pin;
APP_TIMER_DEF(m_test_tx_timer);
static void zdatachanel_send_log(const char* fmt, ...) {
static char tx[256] = {0};
static uint16_t len = 0;
va_list args;
va_start(args, fmt);
len = vsprintf(tx, fmt, args);
zdatachannel_data_send((uint8_t*)tx, &len);
va_end(args);
}
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
zdatachanel_send_log("%d,%d,%d\n", data, data, data);
// static uint8_t tx[9] = {0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09};
// uint16_t p_length = 9;
// zdatachannel_data_send(tx, &p_length);
}
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);
ThreeLeadECG_sdcard_base_init();
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);
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));
zble_module_start_adv();
znordic_loop();
}
#endif
#if 0
/*******************************************************************************
* 3-led测试 *

146
ble_app_uart_c/ble_app_uart_c_pca10100_s122.uvguix.h_zha
File diff suppressed because it is too large
View File

4
ble_app_uart_c/ble_app_uart_c_pca10100_s122.uvoptx

@ -77,7 +77,7 @@
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>1</IsCurrentTarget>
</OPTFL>
<CpuCode>0</CpuCode>
<CpuCode>5</CpuCode>
<DebugOpt>
<uSim>0</uSim>
<uTrg>1</uTrg>
@ -237,7 +237,7 @@
<tvExpOptDlg>0</tvExpOptDlg>
<IsCurrentTarget>0</IsCurrentTarget>
</OPTFL>
<CpuCode>0</CpuCode>
<CpuCode>5</CpuCode>
<DebugOpt>
<uSim>0</uSim>
<uTrg>1</uTrg>

4
ble_app_uart_c/main.c

@ -71,7 +71,7 @@
#define NUS_SERVICE_UUID_TYPE BLE_UUID_TYPE_VENDOR_BEGIN /**< UUID type for the Nordic UART Service (vendor specific). */
#define ECHOBACK_BLE_UART_DATA 1 /**< Echo the UART data that is received over the Nordic UART Service (NUS) back to the sender. */
#define ECHOBACK_BLE_UART_DATA 0 /**< Echo the UART data that is received over the Nordic UART Service (NUS) back to the sender. */
BLE_NUS_C_DEF(m_ble_nus_c); /**< BLE Nordic UART Service (NUS) client instance. */
@ -556,7 +556,7 @@ static void uart_init(void)
.cts_pin_no = CTS_PIN_NUMBER,
.flow_control = APP_UART_FLOW_CONTROL_DISABLED,
.use_parity = false,
.baud_rate = UART_BAUDRATE_BAUDRATE_Baud115200
.baud_rate = UART_BAUDRATE_BAUDRATE_Baud921600
};
APP_UART_FIFO_INIT(&comm_params,

Loading…
Cancel
Save