Browse Source

update

master
zhaohe 1 year ago
parent
commit
a4bc9fd274
  1. 638
      app/main.hardtest.c
  2. 360
      app/src/ads1293_simple_tester.c
  3. 14
      app/src/basic/ads1293/ads1293.c
  4. 13
      app/src/basic/ads1293/ads1293.h
  5. 4
      app/src/board/board.h
  6. 3
      app/src/main.c
  7. 7785
      bin2/app.hex
  8. 16
      bin2/bl_temp.hex
  9. 16
      bin2/settings.hex
  10. 7801
      bin2/whole.hex
  11. 2
      libznordic

638
app/main.hardtest.c

@ -1,638 +0,0 @@
#include "basic/zble_module.h"
#include "basic/zdatachannel_service.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\zdatachannel_service.h"
#include "one_conduction/one_conduction_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
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
ZLOGI("tim cb %d", data);
// ThreeLeadECG_sdcard_connect2_ext_usb_sdcard_driver_ic_reset();
}
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);
ThreeLeadECG_beep_init();
ThreeLeadECG_sdcard_base_init();
znordic_init();
NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
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(3000), NULL));
znordic_loop();
}
#endif
// EEPROM_TEST
#if 1
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
// ZLOGI("test_tx_timer_cb %d", data);
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);
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();
// }
}
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();
// 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 0
const unsigned char gImage_0[1024] = { /* 0X22,0X01,0X80,0X00,0X40,0X00, */
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0XF0,
0XF8,0XFC,0X1E,0X0E,0X0E,0X0E,0X1E,0XFC,0XF8,0XF0,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X01,
0X03,0X07,0X0F,0X0E,0X0E,0X0E,0X0F,0X07,0X03,0X01,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,0X00,
};
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);
int 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);
// gImage_0
ssd1306_basic_draw_screen(gImage_0);
// for (size_t i = 0; i < 127; i++) {
// for (size_t j = 0; j < 64; j++)
// {
// ssd1306_basic_write_point(i, j, 1);
// }
// }
ssd1306_gram_update(ssd1306_handler());
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
#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());
// 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;
APP_TIMER_DEF(m_test_tx_timer);
void main() {
// g_nrf_log_tx_pin = 41;
APP_SCHED_INIT(APP_TIMER_SCHED_EVENT_DATA_SIZE, 20);
znordic_init();
SingleLeadECG_adc_module_init();
uartinit();
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(5), 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);
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);
zble_module_start_adv();
znordic_loop();
}
#endif
#if 0
/*******************************************************************************
* ADCTEST *
*******************************************************************************/
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
// ZLOGI("test_tx_timer_cb %d", data);
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;
}
int16_t adc = SingleLeadECG_battery_get_adc_val();
int16_t mv = adc * 1.0 / 4096 * 3.6 * 1000 / 2.0 * 3;
ZLOGI("battery:%d", mv);
}
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();
SingleLeadECG_battery_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();
// 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
#if 0
/*******************************************************************************
* 3-ADS1293- *
*******************************************************************************/
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 const char* dumplodstate(uint16_t lodstate) {
static char buf[64];
memset(buf, 0, sizeof(buf));
/**
* @brief
* 1111_0000_0000_0000
*/
sprintf(buf, "%d%d%d%d_%d%d%d%d_%d%d%d%d_%d%d%d%d", //
lodstate >> 15 & 0x1, lodstate >> 14 & 0x1, lodstate >> 13 & 0x1, lodstate >> 12 & 0x1, //
lodstate >> 11 & 0x1, lodstate >> 10 & 0x1, lodstate >> 9 & 0x1, lodstate >> 8 & 0x1, //
lodstate >> 7 & 0x1, lodstate >> 6 & 0x1, lodstate >> 5 & 0x1, lodstate >> 4 & 0x1, //
lodstate >> 3 & 0x1, lodstate >> 2 & 0x1, lodstate >> 1 & 0x1, lodstate >> 0 & 0x1);
return buf;
}
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
uint16_t val;
ThreeLeadECG_ads1293_get_lod_state(&val);
#if 0
uint32_t sample0;
uint32_t sample1;
uint32_t sample2;
ThreeLeadECG_ads1293_sample(&sample0, &sample1, &sample2);
zdatachanel_send_log("%d,%d,%d\n", sample0, sample1, sample2);
#endif
uint32_t sample0;
uint32_t sample1;
uint32_t sample2;
uint32_t sample10;
uint32_t sample11;
uint32_t sample12;
ThreeLeadECG_ads1293_sample_all(&sample0, &sample1, &sample2, &sample10, &sample11, &sample12);
zdatachanel_send_log("%d,%d,%d,%d,%d,%d\n", sample0, sample1, sample2, sample10, sample11, sample12);
// zdatachanel_send_log("%d,%d\n", sample0, sample1);
// zdatachanel_send_log("%d,%d,%d\n", data, data, data);
// zdatachanel_send_log("%d %d %s\n", ThreeLeadECG_ready_pin_state_get(), ThreeLeadECG_LineInputDet_get_state(), dumplodstate(val));
// 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;
}
char cmdcache[256] = {0};
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) {
/**
* @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);
ThreeLeadECG_ecg_init();
ThreeLeadECG_LineInputDet_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(5), NULL));
zble_module_start_adv();
znordic_loop();
}
#endif
#if 0
/*******************************************************************************
* 3-led测试 *
*******************************************************************************/
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
ZLOGI("test_tx_timer_cb %d", data);
ThreeLeadECG_led_green_set_state(data % 2 == 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();
ThreeLeadECG_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
#if 0
/*******************************************************************************
* 3- *
*******************************************************************************/
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
int16_t mv = ThreeLeadECG_battery_get_adc_val() * 1.0 / 4096 * 3.3 * 1000 / 2.0 * 3;
ZLOGI("battery:%d", mv);
}
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();
ThreeLeadECG_adc_module_init();
ThreeLeadECG_battery_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
#if 0
/*******************************************************************************
* 3-flash测试 *
*******************************************************************************/
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
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();
NRF_LOG_INFO("compile time :%s %d", __TIME__, APP_TIMER_TICKS(100));
NRF_LOG_INTERNAL_FLUSH();
ThreeLeadECG_sdcard_base_init();
ThreeLeadECG_sdcard_mount();
ThreeLeadECG_sdcard_umount();
ThreeLeadECG_sdcard_mount();
ThreeLeadECG_sdcard_umount();
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
#if 0
/*******************************************************************************
* 3-flash测试 *
*******************************************************************************/
static void test_tx_timer_cb(void* p_context) {
static uint32_t data;
data++;
ZLOGI("button %d", ThreeLeadECG_button_get_state());
}
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();
ThreeLeadECG_button_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(300), NULL));
znordic_loop();
}
#endif

360
app/src/ads1293_simple_tester.c

@ -0,0 +1,360 @@
#include "znordic.h"
//
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//
#include "app_ble_service.h"
#include "app_event_distribute.h"
#include "basic/ads1293/ads1293.h"
#include "board/board.h"
#include "device_ctrl_service.h"
#include "nrf_drv_gpiote.h"
#include "sample_data_manager_service.h"
#include "zble_module.h"
#include "zdatachannel_service.h"
#include "znordic_device_info_mgr.h"
//
ZDATACHANNEL_DEF(m_zhrs, 2 /*优先级*/, 1 /*client num*/);
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(ADS1293_SPI_INSTANCE); /**< SPI instance. */
static ads1293_t m_ads1293_0; // U2
static ads1293_t m_ads1293_1;
typedef struct {
uint8_t add;
uint8_t data;
} adscfg_t;
static adscfg_t m_prvads0cfg_cache[65];
static adscfg_t m_prvads1cfg_cache[65];
static void zdatachannel_data_handler(zdatachannel_evt_t* p_evt) {}
void blechannel_service_init() {
ZLOGI("init zdatachannel service");
static 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));
}
static void ads1293_spi_tx_rx_0(uint8_t* tx, uint8_t* rx, uint8_t len) {
nrf_gpio_pin_clear(ADS1293_SPI_CS0_PIN);
nrf_drv_spi_transfer(&spi, tx, len, rx, len);
nrf_gpio_pin_set(ADS1293_SPI_CS0_PIN);
}
static void ads1293_spi_tx_rx_1(uint8_t* tx, uint8_t* rx, uint8_t len) {
nrf_gpio_pin_clear(ADS1293_SPI_CS1_PIN);
nrf_drv_spi_transfer(&spi, tx, len, rx, len);
nrf_gpio_pin_set(ADS1293_SPI_CS1_PIN);
}
static void ads1293_spi_writereg_and_check(ads1293_t* ads, uint8_t addr, uint8_t data) {
uint8_t readbak = 0;
// readonly add
readbak = data;
if (addr >= 0x18 && addr <= 0x1E) {
return;
}
if (addr >= 0x30 && addr <= 0x3f) {
return;
}
if (addr == 0x40) {
return;
}
if (addr == 0x50) {
return;
}
ads1293_spi_writereg_and_readbak(ads, addr, data, &readbak);
if (readbak != data) {
ZLOGE("ads_%d write %x failed,w:%x readbak:%x\n", ads->id, addr, data, readbak);
}
}
static void tryloadcfg_from_fatfs(const char* file, adscfg_t* cfg, uint16_t cfgsize, uint16_t* cfg_ret_size) {
//
*cfg_ret_size = 0;
static FIL fd;
FRESULT ff_result = f_open(&fd, (const TCHAR*)file, FA_READ);
if (ff_result != FR_OK) {
ZLOGE("open %s failed\n", file);
return;
}
char line[128];
int niterm = 0;
f_gets(line, 128, &fd);
while (f_gets(line, 128, &fd)) {
uint32_t addr;
uint32_t value;
sscanf(line, "%x,%x", &addr, &value);
cfg[niterm].add = addr;
cfg[niterm].data = value;
niterm++;
if (niterm >= cfgsize) {
break;
}
}
*cfg_ret_size = niterm;
ZLOGI("load %s cfg size:%d\n", file, niterm);
f_close(&fd);
}
uint32_t get_ready_pin_state_get() { return nrf_gpio_pin_read(ADS1293_READY_PIN); }
static adscfg_t m_prvads0cfg[] = //
{
{0x00, 0x00}, {0x01, 0x19}, {0x02, 0x11}, {0x03, 0x00}, {0x04, 0x00}, {0x05, 0x00}, {0x06, 0x00}, {0x07, 0x0f}, {0x08, 0xff}, {0x09, 0x00}, {0x0a, 0x07}, {0x0b, 0x07}, {0x0c, 0x74}, {0x0d, 0x01}, {0x0e, 0x02}, {0x0f, 0x03}, {0x10, 0x04},
{0x11, 0x00}, {0x12, 0x05}, {0x13, 0x39}, {0x14, 0x36}, {0x15, 0x06}, {0x16, 0x00}, {0x17, 0x05}, {0x18, 0x00}, {0x19, 0x00}, {0x1a, 0x00}, {0x1b, 0x00}, {0x1c, 0x00}, {0x1d, 0x00}, {0x21, 0x01}, {0x22, 0x20}, {0x23, 0x20}, {0x24, 0x02},
{0x25, 0x00}, {0x26, 0x00}, {0x27, 0x08}, {0x28, 0x08}, {0x29, 0x00}, {0x2a, 0x00}, {0x2b, 0x00}, {0x2c, 0x00}, {0x2d, 0x00}, {0x2e, 0x33}, {0x2f, 0x30}, {0x30, 0x00}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0x00}, {0x34, 0x00}, {0x35, 0x00},
{0x36, 0x00}, {0x37, 0x00}, {0x38, 0x00}, {0x39, 0x00}, {0x3a, 0x00}, {0x3b, 0x00}, {0x3c, 0x00}, {0x3d, 0x00}, {0x3e, 0x00}, {0x3f, 0x00}, {0x40, 0xff}, {0x50, 0x00}, {0x60, 0x00}, {0x62, 0x00},
};
static adscfg_t m_prvads1cfg[] = //
{
{0x00, 0x00}, {0x01, 0x0c}, {0x02, 0x14}, {0x03, 0x00}, {0x04, 0x00}, {0x05, 0x00}, {0x06, 0x00}, {0x07, 0x0f}, {0x08, 0xff}, {0x09, 0x00}, {0x0a, 0x00}, {0x0b, 0x07}, {0x0c, 0x78}, {0x0d, 0x00}, {0x0e, 0x00}, {0x0f, 0x00}, {0x10, 0x04},
{0x11, 0x00}, {0x12, 0x07}, {0x13, 0x3b}, {0x14, 0x24}, {0x15, 0x04}, {0x16, 0x00}, {0x17, 0x05}, {0x18, 0x00}, {0x19, 0x00}, {0x1a, 0x00}, {0x1b, 0x00}, {0x1c, 0x00}, {0x1d, 0x00}, {0x21, 0x01}, {0x22, 0x20}, {0x23, 0x20}, {0x24, 0x02},
{0x25, 0x00}, {0x26, 0x00}, {0x27, 0x08}, {0x28, 0x40}, {0x29, 0x00}, {0x2a, 0x00}, {0x2b, 0x00}, {0x2c, 0x00}, {0x2d, 0x00}, {0x2e, 0x33}, {0x2f, 0x30}, {0x30, 0x00}, {0x31, 0x00}, {0x32, 0x00}, {0x33, 0x00}, {0x34, 0x00}, {0x35, 0x00},
{0x36, 0x00}, {0x37, 0x00}, {0x38, 0x00}, {0x39, 0x00}, {0x3a, 0x00}, {0x3b, 0x00}, {0x3c, 0x00}, {0x3d, 0x00}, {0x3e, 0x00}, {0x3f, 0x00}, {0x40, 0xff}, {0x50, 0x00}, {0x60, 0x00}, {0x62, 0x00},
};
static void ads1293_init() {
/*******************************************************************************
* SPI初始化 *
*******************************************************************************/
static nrf_drv_spi_config_t spi_config = NRF_DRV_SPI_DEFAULT_CONFIG;
spi_config.ss_pin = NRF_DRV_SPI_PIN_NOT_USED; // NRF_DRV_SPI_PIN_NOT_USED
spi_config.miso_pin = ADS1293_SPI_MISO_PIN;
spi_config.mosi_pin = ADS1293_SPI_MOSI_PIN;
spi_config.sck_pin = ADS1293_SPI_SCK_PIN;
spi_config.frequency = NRF_DRV_SPI_FREQ_8M;
spi_config.mode = NRF_DRV_SPI_MODE_3;
// spi_config.mode =
ZERROR_CHECK(nrf_drv_spi_init(&spi, &spi_config, NULL, NULL));
znrf_gpio_cfg_output(ADS1293_SPI_CS0_PIN, NRF_GPIO_PIN_NOPULL);
znrf_gpio_cfg_output(ADS1293_SPI_CS1_PIN, NRF_GPIO_PIN_NOPULL);
nrf_gpio_pin_set(ADS1293_SPI_CS0_PIN);
nrf_gpio_pin_set(ADS1293_SPI_CS1_PIN);
m_ads1293_0.spi_tx_rx = ads1293_spi_tx_rx_0;
m_ads1293_0.id = 0;
m_ads1293_1.spi_tx_rx = ads1293_spi_tx_rx_1;
m_ads1293_1.id = 1;
ads1293_spi_init(&m_ads1293_0, ads1293_spi_tx_rx_0);
ads1293_spi_init(&m_ads1293_1, ads1293_spi_tx_rx_1);
uint8_t revid = ads1293_spi_readreg(&m_ads1293_0, TI_ADS1293_REVID_REG);
ZLOGI("ads1293_0 revid: %d\n", revid);
revid = ads1293_spi_readreg(&m_ads1293_1, TI_ADS1293_REVID_REG);
ZLOGI("ads1293_1 revid: %d\n", revid);
ads1293_spi_writereg(&m_ads1293_0, TI_ADS1293_CONFIG_REG, 0);
uint16_t cfgsize = 0;
tryloadcfg_from_fatfs("0.cfg", m_prvads0cfg_cache, ZARRAY_SIZE(m_prvads0cfg_cache), &cfgsize);
if (cfgsize > 0) {
ZLOGI("load 0.cfg from fatfs\n");
if (memcmp(m_prvads0cfg_cache, m_prvads0cfg, sizeof(m_prvads0cfg)) != 0) {
ZLOGI("0.cfg is different from default\n");
} else {
ZLOGI("0.cfg is same as default\n");
}
for (uint16_t i = 0; i < cfgsize; i++) {
ads1293_spi_writereg_and_check(&m_ads1293_0, m_prvads0cfg_cache[i].add, m_prvads0cfg_cache[i].data);
}
} else {
for (uint16_t i = 0; i < ZARRAY_SIZE(m_prvads0cfg); i++) {
ads1293_spi_writereg_and_check(&m_ads1293_0, m_prvads0cfg[i].add, m_prvads0cfg[i].data);
}
}
tryloadcfg_from_fatfs("1.cfg", m_prvads1cfg_cache, ZARRAY_SIZE(m_prvads1cfg_cache), &cfgsize);
if (cfgsize > 0) {
ZLOGI("load 1.cfg from fatfs\n");
if (memcmp(m_prvads1cfg_cache, m_prvads1cfg, sizeof(m_prvads1cfg)) != 0) {
ZLOGI("1.cfg is different from default\n");
} else {
ZLOGI("1.cfg is same as default\n");
}
for (uint16_t i = 0; i < cfgsize; i++) {
ads1293_spi_writereg_and_check(&m_ads1293_1, m_prvads1cfg_cache[i].add, m_prvads1cfg_cache[i].data);
}
} else {
for (uint16_t i = 0; i < ZARRAY_SIZE(m_prvads1cfg); i++) {
ads1293_spi_writereg_and_check(&m_ads1293_1, m_prvads1cfg[i].add, m_prvads1cfg[i].data);
}
}
}
static void onServiceInitCB() {
ZLOGI("init zdatachannel service");
static 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 setup();
int main() {
APP_SCHED_INIT(APP_MAX_EVEN_SIZE, APP_EVENT_QUEUE_SIZE);
znordic_init();
NRF_LOG_INFO("compile time :%s", __TIME__);
ZLOGI("CUSTOMER :%d", NRF_UICR->CUSTOMER[0]);
/*******************************************************************************
* *
*******************************************************************************/
static zble_module_cfg_t cfg;
cfg.deviceName = "ADS1293_TESTER";
cfg.on_service_init = onServiceInitCB;
zble_module_init(&cfg);
AppBleService_init();
setup();
}
static ads1293_error_t error0;
static ads1293_error_t error1;
static uint8_t txcache[128];
void send_ads1293_error_state(ads1293_error_t* e0, ads1293_error_t* e1) { //
txcache[0] = 0xA5;
txcache[1] = 0x01;
memcpy(txcache + 2, e0, sizeof(ads1293_error_t));
memcpy(txcache + 2 + sizeof(ads1293_error_t), e1, sizeof(ads1293_error_t));
zdatachannel_data_send2(txcache, 2 + sizeof(ads1293_error_t) * 2);
}
void capture_error_state() {
ads1293_read_error(&m_ads1293_0, &error0);
ads1293_read_error(&m_ads1293_1, &error1);
#if 0
error0.estatus =1;
error0.error_range1 =2;
error0.error_range2 =3;
error0.error_range3 =4;
error0.error_sync =5;
error0.error_misc =6;
error1.estatus =21;
error1.error_range1 =22;
error1.error_range2 =23;
error1.error_range3 =24;
error1.error_sync =25;
error1.error_misc =26;
#endif
send_ads1293_error_state(&error0, &error1);
}
#pragma pack(1)
typedef struct {
uint8_t frameH;
uint32_t sample0;
uint8_t frameE;
} one_ch_cache_t;
typedef struct {
one_ch_cache_t data[3];
} one_frame_cache_t;
typedef struct {
one_frame_cache_t frame[4];
} one_packet_t;
#pragma unpack()
one_packet_t txpacket;
int cache_data_size = 0;
void trigger_capture() {
static uint32_t sample[6];
static uint8_t readystatus[2] = {0};
ads1293_read_ecgs(&m_ads1293_0, &sample[0]);
ads1293_read_ecgs(&m_ads1293_1, &sample[3]);
// TI_ADS1293_DATA_STATUS_REG
// readystatus[0] = ads1293_read_ready_status(&m_ads1293_0);
// readystatus[1] = ads1293_read_ready_status(&m_ads1293_1);
{
txpacket.frame[cache_data_size].data[0].frameH = 0xA1;
txpacket.frame[cache_data_size].data[0].sample0 = sample[0];
txpacket.frame[cache_data_size].data[0].frameE = 0x1A;
txpacket.frame[cache_data_size].data[1].frameH = 0xA2;
txpacket.frame[cache_data_size].data[1].sample0 = sample[3];
txpacket.frame[cache_data_size].data[1].frameE = 0x2A;
txpacket.frame[cache_data_size].data[2].frameH = 0xA3;
txpacket.frame[cache_data_size].data[2].sample0 = sample[4];
txpacket.frame[cache_data_size].data[2].frameE = 0x3A;
cache_data_size++;
if (cache_data_size == 4) {
zdatachannel_data_send2((uint8_t*)&txpacket, sizeof(one_packet_t));
cache_data_size = 0;
}
}
}
uint32_t m_changecount = 0;
static void ads1293_ready_pin_irq(nrfx_gpiote_pin_t pin, nrf_gpiote_polarity_t action) { //
m_changecount++;
trigger_capture();
}
void setup() {
//
zble_module_start_adv();
SampleDataMgr_init();
SampleDataMgr_changeToLocalMode();
ads1293_init();
SampleDataMgr_changeToExtMode();
ads1293_start_conversion(&m_ads1293_0);
ads1293_start_conversion(&m_ads1293_1);
nrf_gpio_cfg_input(ADS1293_READY_PIN, NRF_GPIO_PIN_PULLUP);
{
nrf_gpio_cfg_input(ADS1293_READY_PIN, NRF_GPIO_PIN_PULLUP);
ZERROR_CHECK(nrfx_gpiote_init());
nrf_drv_gpiote_in_config_t inConfig = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false); // 沿
inConfig.pull = NRF_GPIO_PIN_PULLUP; //
inConfig.sense = NRF_GPIOTE_POLARITY_LOTOHI; // 沿
ZERROR_CHECK(nrfx_gpiote_in_init(ADS1293_READY_PIN, &inConfig, ads1293_ready_pin_irq));
nrfx_gpiote_in_event_enable(ADS1293_READY_PIN, true);
}
while (true) {
app_sched_execute();
NRF_LOG_PROCESS();
static bool state = false;
static uint32_t last_ticket = 0;
bool now = get_ready_pin_state_get();
uint32_t nowticket = znordic_getpower_on_s();
// if (state != now) {
// state = now;
// m_changecount++;
// if (now) {
// // trigger_capture();
// }
// }
if (last_ticket != nowticket) {
last_ticket = nowticket;
ZLOGI("%d changecount:%d\n", znordic_getpower_on_ms(), m_changecount);
capture_error_state();
m_changecount = 0;
}
}
}

14
app/src/basic/ads1293/ads1293.c

@ -96,6 +96,18 @@ void ads1293_read_ecgs(ads1293_t* ads, uint32_t* data /*3*/) {
data[2] = ((uint32_t)readbak[6] << 16) + ((uint32_t)readbak[7] << 8) + ((uint32_t)readbak[8] << 0); data[2] = ((uint32_t)readbak[6] << 16) + ((uint32_t)readbak[7] << 8) + ((uint32_t)readbak[8] << 0);
} }
void ads1293_read_error(ads1293_t* ads, ads1293_error_t* error) {
error->lod = 0;
error->estatus = 0;
error->error_range1 = 0;
error->error_range2 = 0;
error->error_range3 = 0;
error->error_sync = 0;
error->error_misc = 0;
ads1293_spi_autoinc_readreg(ads, TI_ADS1293_ERROR_LOD_REG, (uint8_t*)error, 7);
}
void ads1293_start_conversion(ads1293_t* ads) { void ads1293_start_conversion(ads1293_t* ads) {
uint8_t data = 0; uint8_t data = 0;
data = 0x01; data = 0x01;
@ -113,3 +125,5 @@ void ads1293_start_power_off(ads1293_t* ads) {
} }
uint8_t ads1293_read_error_lod(ads1293_t* ads) { return ads1293_spi_readreg(ads, TI_ADS1293_ERROR_LOD_REG); } uint8_t ads1293_read_error_lod(ads1293_t* ads) { return ads1293_spi_readreg(ads, TI_ADS1293_ERROR_LOD_REG); }
uint8_t ads1293_read_ready_status(ads1293_t* ads) { return ads1293_spi_readreg(ads, TI_ADS1293_DATA_STATUS_REG); }

13
app/src/basic/ads1293/ads1293.h

@ -126,4 +126,17 @@ uint8_t ads1293_read_error_lod(ads1293_t* ads);
void ads1293_start_conversion(ads1293_t* ads); void ads1293_start_conversion(ads1293_t* ads);
void ads1293_stop_conversion(ads1293_t* ads); void ads1293_stop_conversion(ads1293_t* ads);
uint8_t ads1293_read_ready_status(ads1293_t* ads);
typedef struct {
uint8_t lod;
uint8_t estatus;
uint8_t error_range1;
uint8_t error_range2;
uint8_t error_range3;
uint8_t error_sync;
uint8_t error_misc;
} ads1293_error_t;
void ads1293_read_error(ads1293_t* ads, ads1293_error_t* error);
#endif // HEADER_FILE_TI_ADS1293_H #endif // HEADER_FILE_TI_ADS1293_H

4
app/src/board/board.h

@ -40,12 +40,12 @@
/******************************************************************************* /*******************************************************************************
* °´¼ü * * °´¼ü *
*******************************************************************************/ *******************************************************************************/
#define BUTTON_PIN 0
#define BUTTON_PIN 18
/******************************************************************************* /*******************************************************************************
* ·äÃùÆ÷ * * ·äÃùÆ÷ *
*******************************************************************************/ *******************************************************************************/
#define BEEP_PIN 18
#define BEEP_PIN 0
/******************************************************************************* /*******************************************************************************
* µç³ØµçÁ¿ * * µç³ØµçÁ¿ *

3
app/src/main.c

@ -1,3 +1,4 @@
#if 0
#include "znordic.h" #include "znordic.h"
// //
#include <stdarg.h> #include <stdarg.h>
@ -37,3 +38,5 @@ int main() {
*******************************************************************************/ *******************************************************************************/
znordic_loop(); znordic_loop();
} }
#endif
#include "ads1293_simple_tester.c"

7785
bin2/app.hex
File diff suppressed because it is too large
View File

16
bin2/bl_temp.hex

@ -2978,8 +2978,8 @@
:10DA000010D4070018D4070020D4070028D407003A :10DA000010D4070018D4070020D4070028D407003A
:10DA1000000000000090D0030000000000000000A3 :10DA1000000000000090D0030000000000000000A3
:0CDA2000754F0700001000000000080017 :0CDA2000754F0700001000000000080017
:10E0000091A47ACF0200000001000000010000008E
:10E010000000000000000000500F0100D3DF77C4B3
:10E000001189F5BB020000000100000001000000C2
:10E0100000000000000000005CF200004B4111A86D
:10E0200001000000000000000000000000000000EF :10E0200001000000000000000000000000000000EF
:10E0300000000000000000000000000000000000E0 :10E0300000000000000000000000000000000000E0
:10E0400000000000000000000000000000000000D0 :10E0400000000000000000000000000000000000D0
@ -3015,12 +3015,12 @@
:10E2200000000000000000000000000000000000EE :10E2200000000000000000000000000000000000EE
:10E2300000000000000000000000000000000000DE :10E2300000000000000000000000000000000000DE
:10E2400000000000000000000000000000000000CE :10E2400000000000000000000000000000000000CE
:10E250000000000000000000000000004A37F9BC88
:10E25000000000000000000000000000388FD9CF4F
:10E2600000000000000000000000000000000000AE :10E2600000000000000000000000000000000000AE
:10E27000000000000000000000000000000000009E :10E27000000000000000000000000000000000009E
:10E28000000000000000000000000000000000008E :10E28000000000000000000000000000000000008E
:10E29000000000000000000000000000000000007E :10E29000000000000000000000000000000000007E
:10E2A0000001D3DF77C40000000000000000000080
:10E2A00000014B4111A80000000000000000000028
:10E2B000000000000000000000000000000000005E :10E2B000000000000000000000000000000000005E
:10E2C000000000000000000000000000000000004E :10E2C000000000000000000000000000000000004E
:10E2D000000000000000000000000000000000003E :10E2D000000000000000000000000000000000003E
@ -3029,8 +3029,8 @@
:10E30000000000000000000000000000000000000D :10E30000000000000000000000000000000000000D
:10E3100000000000000000000000000000000000FD :10E3100000000000000000000000000000000000FD
:04E32000000000FFFA :04E32000000000FFFA
:10F0000091A47ACF0200000001000000010000007E
:10F010000000000000000000500F0100D3DF77C4A3
:10F000001189F5BB020000000100000001000000B2
:10F0100000000000000000005CF200004B4111A85D
:10F0200001000000000000000000000000000000DF :10F0200001000000000000000000000000000000DF
:10F0300000000000000000000000000000000000D0 :10F0300000000000000000000000000000000000D0
:10F0400000000000000000000000000000000000C0 :10F0400000000000000000000000000000000000C0
@ -3066,12 +3066,12 @@
:10F2200000000000000000000000000000000000DE :10F2200000000000000000000000000000000000DE
:10F2300000000000000000000000000000000000CE :10F2300000000000000000000000000000000000CE
:10F2400000000000000000000000000000000000BE :10F2400000000000000000000000000000000000BE
:10F250000000000000000000000000004A37F9BC78
:10F25000000000000000000000000000388FD9CF3F
:10F26000000000000000000000000000000000009E :10F26000000000000000000000000000000000009E
:10F27000000000000000000000000000000000008E :10F27000000000000000000000000000000000008E
:10F28000000000000000000000000000000000007E :10F28000000000000000000000000000000000007E
:10F29000000000000000000000000000000000006E :10F29000000000000000000000000000000000006E
:10F2A0000001D3DF77C40000000000000000000070
:10F2A00000014B4111A80000000000000000000018
:10F2B000000000000000000000000000000000004E :10F2B000000000000000000000000000000000004E
:10F2C000000000000000000000000000000000003E :10F2C000000000000000000000000000000000003E
:10F2D000000000000000000000000000000000002E :10F2D000000000000000000000000000000000002E

16
bin2/settings.hex

@ -1,6 +1,6 @@
:020000040007F3 :020000040007F3
:10E0000091A47ACF0200000001000000010000008E
:10E010000000000000000000500F0100D3DF77C4B3
:10E000001189F5BB020000000100000001000000C2
:10E0100000000000000000005CF200004B4111A86D
:10E0200001000000000000000000000000000000EF :10E0200001000000000000000000000000000000EF
:10E0300000000000000000000000000000000000E0 :10E0300000000000000000000000000000000000E0
:10E0400000000000000000000000000000000000D0 :10E0400000000000000000000000000000000000D0
@ -36,12 +36,12 @@
:10E2200000000000000000000000000000000000EE :10E2200000000000000000000000000000000000EE
:10E2300000000000000000000000000000000000DE :10E2300000000000000000000000000000000000DE
:10E2400000000000000000000000000000000000CE :10E2400000000000000000000000000000000000CE
:10E250000000000000000000000000004A37F9BC88
:10E25000000000000000000000000000388FD9CF4F
:10E2600000000000000000000000000000000000AE :10E2600000000000000000000000000000000000AE
:10E27000000000000000000000000000000000009E :10E27000000000000000000000000000000000009E
:10E28000000000000000000000000000000000008E :10E28000000000000000000000000000000000008E
:10E29000000000000000000000000000000000007E :10E29000000000000000000000000000000000007E
:10E2A0000001D3DF77C40000000000000000000080
:10E2A00000014B4111A80000000000000000000028
:10E2B000000000000000000000000000000000005E :10E2B000000000000000000000000000000000005E
:10E2C000000000000000000000000000000000004E :10E2C000000000000000000000000000000000004E
:10E2D000000000000000000000000000000000003E :10E2D000000000000000000000000000000000003E
@ -50,8 +50,8 @@
:10E30000000000000000000000000000000000000D :10E30000000000000000000000000000000000000D
:10E3100000000000000000000000000000000000FD :10E3100000000000000000000000000000000000FD
:04E32000000000FFFA :04E32000000000FFFA
:10F0000091A47ACF0200000001000000010000007E
:10F010000000000000000000500F0100D3DF77C4A3
:10F000001189F5BB020000000100000001000000B2
:10F0100000000000000000005CF200004B4111A85D
:10F0200001000000000000000000000000000000DF :10F0200001000000000000000000000000000000DF
:10F0300000000000000000000000000000000000D0 :10F0300000000000000000000000000000000000D0
:10F0400000000000000000000000000000000000C0 :10F0400000000000000000000000000000000000C0
@ -87,12 +87,12 @@
:10F2200000000000000000000000000000000000DE :10F2200000000000000000000000000000000000DE
:10F2300000000000000000000000000000000000CE :10F2300000000000000000000000000000000000CE
:10F2400000000000000000000000000000000000BE :10F2400000000000000000000000000000000000BE
:10F250000000000000000000000000004A37F9BC78
:10F25000000000000000000000000000388FD9CF3F
:10F26000000000000000000000000000000000009E :10F26000000000000000000000000000000000009E
:10F27000000000000000000000000000000000008E :10F27000000000000000000000000000000000008E
:10F28000000000000000000000000000000000007E :10F28000000000000000000000000000000000007E
:10F29000000000000000000000000000000000006E :10F29000000000000000000000000000000000006E
:10F2A0000001D3DF77C40000000000000000000070
:10F2A00000014B4111A80000000000000000000018
:10F2B000000000000000000000000000000000004E :10F2B000000000000000000000000000000000004E
:10F2C000000000000000000000000000000000003E :10F2C000000000000000000000000000000000003E
:10F2D000000000000000000000000000000000002E :10F2D000000000000000000000000000000000002E

7801
bin2/whole.hex
File diff suppressed because it is too large
View File

2
libznordic

@ -1 +1 @@
Subproject commit 336e39bf85c5eeb9e3662581ecc585dfcfe9bb26
Subproject commit af647e62b4e24b2facf91b0967159e18398fae41
Loading…
Cancel
Save