|
|
@ -23,8 +23,6 @@ |
|
|
|
int main() { return 0; } |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#if 1 |
|
|
|
|
|
|
|
#define ADS1293_SPI_SCK_PIN (32 + 9) |
|
|
@ -66,37 +64,12 @@ APP_TIMER_DEF(m_report_tmr); |
|
|
|
ZDATACHANNEL_DEF(m_zhrs, 2 /**/, 1 /*client num*/); |
|
|
|
static const nrf_drv_spi_t spi = NRF_DRV_SPI_INSTANCE(2); /**< SPI instance. */ |
|
|
|
static ads1293_t m_ads1293_0; // U2 |
|
|
|
// static ads1293_t m_ads1293_1; // U3 |
|
|
|
static void zdatachanel_send_log(const char* fmt, ...); |
|
|
|
static void three_lead_ecg_ecg_init(); |
|
|
|
static ads1293_t m_ads1293_1; // U3 |
|
|
|
static void zdatachanel_send_log(const char* fmt, ...); |
|
|
|
static void three_lead_ecg_ecg_init(); |
|
|
|
|
|
|
|
uint32_t get_ready_pin_state_get() { return nrf_gpio_pin_read(ADS1293_READY_PIN); } |
|
|
|
|
|
|
|
static void m_report_tmr_cb(void* p_context) { |
|
|
|
static int id = 0; |
|
|
|
id++; |
|
|
|
|
|
|
|
#if 0 |
|
|
|
uint8_t leadoffstate = ads1293_spi_readreg(&m_ads1293_0, TI_ADS1293_ERROR_LOD_REG); |
|
|
|
zdatachanel_send_log("%d%d%d%d_%d%d%d%d\n", // |
|
|
|
leadoffstate >> 7 & 0x1, leadoffstate >> 6 & 0x1, leadoffstate >> 5 & 0x1, leadoffstate >> 4 & 0x1, // |
|
|
|
leadoffstate >> 3 & 0x1, leadoffstate >> 2 & 0x1, leadoffstate >> 1 & 0x1, leadoffstate >> 0 & 0x1); // |
|
|
|
#endif |
|
|
|
|
|
|
|
#if 0 |
|
|
|
uint8_t state = ads1293_spi_readreg(&m_ads1293_0, TI_ADS1293_CONFIG_REG); |
|
|
|
zdatachanel_send_log("ads_%d config:%x\n", m_ads1293_0.id, state); |
|
|
|
#endif |
|
|
|
#if 0 |
|
|
|
static bool state = false; |
|
|
|
bool now = get_ready_pin_state_get(); |
|
|
|
if (state != now) { |
|
|
|
state = now; |
|
|
|
zdatachanel_send_log("%d\n", now); |
|
|
|
} |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
static void on_service_init(void) { |
|
|
|
ZLOGI("init zdatachannel service"); |
|
|
|
zdatachannel_init_t zdatachannle_init; |
|
|
@ -136,6 +109,7 @@ int main() { |
|
|
|
nrf_gpio_cfg_input(LINE_DET_PIN, NRF_GPIO_PIN_PULLUP); |
|
|
|
three_lead_ecg_ecg_init(); |
|
|
|
ads1293_spi_writereg(&m_ads1293_0, TI_ADS1293_CONFIG_REG, 0x01); |
|
|
|
ads1293_spi_writereg(&m_ads1293_1, TI_ADS1293_CONFIG_REG, 0x01); |
|
|
|
|
|
|
|
while (true) { |
|
|
|
app_sched_execute(); |
|
|
@ -153,22 +127,11 @@ int main() { |
|
|
|
ads1293_read_ecg(&m_ads1293_0, 1, &val); |
|
|
|
zdatachanel_send_log("%d\n", val); |
|
|
|
} |
|
|
|
|
|
|
|
// zdatachanel_send_log("%d\n", now); |
|
|
|
} |
|
|
|
// dump_state(); |
|
|
|
#if 0 |
|
|
|
|
|
|
|
#endif |
|
|
|
// dump_state(); |
|
|
|
} |
|
|
|
|
|
|
|
// znordic_loop(); |
|
|
|
} |
|
|
|
|
|
|
|
/******************************************************************************* |
|
|
|
* CODE * |
|
|
|
*******************************************************************************/ |
|
|
|
|
|
|
|
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); |
|
|
@ -192,90 +155,140 @@ static void ads1293_spi_writereg_and_check(ads1293_t* ads, uint8_t addr, uint8_t |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// static adscfg_t prvads0cfg[] = { |
|
|
|
// {0x00, 0x00}, // |
|
|
|
// {0x01, 0x0a}, // |
|
|
|
// {0x02, 0x1a}, // |
|
|
|
// {0x03, 0x00}, // |
|
|
|
// {0x04, 0x00}, // |
|
|
|
// {0x05, 0x00}, // |
|
|
|
// {0x06, 0x04}, // |
|
|
|
// {0x07, 0x0f}, // |
|
|
|
// {0x08, 0xff}, // |
|
|
|
// {0x09, 0x00}, // |
|
|
|
// {0x0a, 0x07}, // |
|
|
|
// {0x0b, 0x00}, // |
|
|
|
// {0x0c, 0x04}, // |
|
|
|
// {0x0d, 0x00}, // |
|
|
|
// {0x0e, 0x00}, // |
|
|
|
// {0x0f, 0x00}, // |
|
|
|
// {0x10, 0x00}, // |
|
|
|
// {0x11, 0x00}, // |
|
|
|
// {0x12, 0x04}, // |
|
|
|
// {0x13, 0x00}, // |
|
|
|
// {0x14, 0x00}, // |
|
|
|
// {0x15, 0x00}, // |
|
|
|
// {0x16, 0x00}, // |
|
|
|
// {0x17, 0x05}, // |
|
|
|
// {0x18, 0x00}, // |
|
|
|
// {0x19, 0x00}, // |
|
|
|
// {0x1a, 0x00}, // |
|
|
|
// {0x1b, 0x00}, // |
|
|
|
// {0x1c, 0x00}, // |
|
|
|
// {0x1d, 0x00}, // |
|
|
|
// {0x21, 0x02}, // |
|
|
|
// {0x22, 0x02}, // |
|
|
|
// {0x23, 0x02}, // |
|
|
|
// {0x24, 0x02}, // |
|
|
|
// {0x25, 0x00}, // |
|
|
|
// {0x26, 0x00}, // |
|
|
|
// {0x27, 0x08}, // |
|
|
|
// {0x28, 0x00}, // |
|
|
|
// {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 prvads0cfg[] = { |
|
|
|
{0x01, 0x11}, // |
|
|
|
{0x02, 0x19}, // |
|
|
|
{0x0A, 0x07}, // |
|
|
|
{0x0C, 0x04}, // |
|
|
|
{0x12, 0x04}, // |
|
|
|
{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 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}, // |
|
|
|
{0x21, 16}, // |
|
|
|
{0x22, 16}, // |
|
|
|
{0x23, 16}, // |
|
|
|
{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}, // |
|
|
|
{0x2F, 0x30}, // |
|
|
|
// |
|
|
|
// {0x06, 0x14}, // LOD |
|
|
|
// {0x07, 0x07}, // |
|
|
|
// {0x08, 0xFF}, // |
|
|
|
{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}, // |
|
|
|
}; |
|
|
|
|
|
|
|
void config_lod(uint8_t aclvl_lod, uint8_t selac_lod, uint8_t shdn_lod, uint8_t acad_lod) { |
|
|
@ -317,12 +330,12 @@ void three_lead_ecg_ecg_init() { |
|
|
|
// 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); |
|
|
|
ads1293_spi_init(&m_ads1293_1, ads1293_spi_tx_rx_1); |
|
|
|
|
|
|
|
uint8_t revid = ads1293_spi_readreg(&m_ads1293_0, TI_ADS1293_REVID_REG); |
|
|
|
zdatachanel_send_log("ads1293_0 revid: %d\n", revid); |
|
|
|
// revid = ads1293_spi_readreg(&m_ads1293_1, TI_ADS1293_REVID_REG); |
|
|
|
// zdatachanel_send_log("ads1293_1 revid: %d\n", revid); |
|
|
|
revid = ads1293_spi_readreg(&m_ads1293_1, TI_ADS1293_REVID_REG); |
|
|
|
zdatachanel_send_log("ads1293_1 revid: %d\n", revid); |
|
|
|
|
|
|
|
zdatachanel_send_log("reset ads1293_0\n"); |
|
|
|
ads1293_spi_writereg(&m_ads1293_0, TI_ADS1293_CONFIG_REG, 0); |
|
|
@ -330,11 +343,10 @@ void three_lead_ecg_ecg_init() { |
|
|
|
|
|
|
|
for (uint16_t i = 0; i < ZARRAY_SIZE(prvads0cfg); i++) { |
|
|
|
ads1293_spi_writereg_and_check(&m_ads1293_0, prvads0cfg[i].add, prvads0cfg[i].data); |
|
|
|
// zdatachanel_send_log("[%d]ads1293_0 write %x:%x\n", i, prvads0cfg[i].add, prvads0cfg[i].data); |
|
|
|
} |
|
|
|
// for (uint16_t i = 0; i < ZARRAY_SIZE(ads1cfg); i++) { |
|
|
|
// ads1293_spi_writereg_and_check(&m_ads1293_1, ads1cfg[i].add, ads1cfg[i].data); |
|
|
|
// } |
|
|
|
for (uint16_t i = 0; i < ZARRAY_SIZE(prvads1cfg); i++) { |
|
|
|
ads1293_spi_writereg_and_check(&m_ads1293_1, prvads1cfg[i].add, prvads1cfg[i].data); |
|
|
|
} |
|
|
|
|
|
|
|
// ads1293_spi_writereg(&m_ads1293_1, TI_ADS1293_CONFIG_REG, 0x01); |
|
|
|
} |
|
|
@ -355,7 +367,6 @@ static void zdatachanel_send_log(const char* fmt, ...) { |
|
|
|
} |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
va_end(args); |
|
|
|
} |
|
|
|
#endif |