|
|
@ -501,51 +501,30 @@ static void ads1293_uninit() { |
|
|
|
nrf_drv_spi_uninit(&spi); |
|
|
|
} |
|
|
|
|
|
|
|
void hwss_init(void) { |
|
|
|
#if GPIO_IRQ_TRIGGER_MODE |
|
|
|
void hwss_init(void) {} |
|
|
|
|
|
|
|
void hwss_load(void) { |
|
|
|
ZERROR_CHECK(nrfx_gpiote_init()); |
|
|
|
{ |
|
|
|
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); // 双边沿中断触发 |
|
|
|
nrf_drv_gpiote_in_config_t inConfig = GPIOTE_CONFIG_IN_SENSE_TOGGLE(false); // |
|
|
|
inConfig.pull = NRF_GPIO_PIN_PULLUP; // 默认上拉 |
|
|
|
inConfig.sense = NRF_GPIOTE_POLARITY_HITOLO; // 下降沿触发 |
|
|
|
ZERROR_CHECK(nrfx_gpiote_in_init(ADS1293_READY_PIN, &inConfig, ads1293_ready_pin_irq)); |
|
|
|
} |
|
|
|
|
|
|
|
nrf_gpio_cfg_input(LINE_DET_PIN, NRF_GPIO_PIN_PULLUP); |
|
|
|
#else |
|
|
|
/** |
|
|
|
* @brief 初始化定时器 |
|
|
|
*/ |
|
|
|
nrfx_err_t err; |
|
|
|
nrfx_timer_config_t timer_cfg = { |
|
|
|
.frequency = NRF_TIMER_FREQ_250kHz, |
|
|
|
.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); |
|
|
|
} |
|
|
|
|
|
|
|
ZASSERT(SAMPLE_RATE == 400); |
|
|
|
uint32_t timer_ticks = nrfx_timer_ms_to_ticks(&m_timer, 5); // 200HZ |
|
|
|
ZLOGI("timer_ticks:%d\n", timer_ticks); |
|
|
|
ZASSERT(timer_ticks % 2 == 0); // |
|
|
|
timer_ticks = timer_ticks / 2; // 400HZ |
|
|
|
nrfx_timer_extended_compare(&m_timer, NRF_TIMER_CC_CHANNEL0, timer_ticks, NRF_TIMER_SHORT_COMPARE0_CLEAR_MASK, true); |
|
|
|
#endif |
|
|
|
ads1293_init(); |
|
|
|
} |
|
|
|
void hwss_unload(void) { |
|
|
|
ads1293_uninit(); |
|
|
|
nrfx_gpiote_uninit(); |
|
|
|
nrf_gpio_cfg_default(ADS1293_READY_PIN); |
|
|
|
} |
|
|
|
|
|
|
|
void hwss_load(void) { ads1293_init(); } |
|
|
|
void hwss_unload(void) { ads1293_uninit(); } |
|
|
|
|
|
|
|
uint32_t hwss_started_has_passed_s(void) { return znordic_getpower_on_s() - m_capture_start_s; } |
|
|
|
|
|
|
|
void hwss_start_capture(void) { |
|
|
|
nrf_gpio_cfg_input(LINE_DET_PIN, NRF_GPIO_PIN_PULLUP); |
|
|
|
|
|
|
|
m_drop_state_triggered = false; |
|
|
|
m_work_flag = true; |
|
|
|
m_frame_index = 0; |
|
|
@ -567,9 +546,7 @@ void hwss_start_capture(void) { |
|
|
|
{ |
|
|
|
// 两通道同时开始采集 |
|
|
|
nrf_gpio_pin_clear(ADS1293_SPI_CS0_PIN); |
|
|
|
#if CHANNEL_NUM == 2 |
|
|
|
nrf_gpio_pin_clear(ADS1293_SPI_CS1_PIN); |
|
|
|
#endif |
|
|
|
|
|
|
|
uint8_t txcache[2]; |
|
|
|
txcache[0] = ADS1293_WRITE_BIT & TI_ADS1293_CONFIG_REG; |
|
|
@ -577,23 +554,13 @@ void hwss_start_capture(void) { |
|
|
|
nrf_drv_spi_transfer(&spi, txcache, 2, NULL, 0); |
|
|
|
|
|
|
|
nrf_gpio_pin_set(ADS1293_SPI_CS0_PIN); |
|
|
|
#if CHANNEL_NUM == 2 |
|
|
|
nrf_gpio_pin_set(ADS1293_SPI_CS1_PIN); |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
#if GPIO_IRQ_TRIGGER_MODE |
|
|
|
nrfx_gpiote_in_event_enable(ADS1293_READY_PIN, true); |
|
|
|
#else |
|
|
|
nrfx_timer_enable(&m_timer); |
|
|
|
#endif |
|
|
|
} |
|
|
|
void hwss_stop_capture(void) { |
|
|
|
#if GPIO_IRQ_TRIGGER_MODE |
|
|
|
nrfx_gpiote_in_event_enable(ADS1293_READY_PIN, false); |
|
|
|
#else |
|
|
|
nrfx_timer_disable(&m_timer); |
|
|
|
#endif |
|
|
|
|
|
|
|
m_work_flag = false; |
|
|
|
m_frame_index = 0; |
|
|
@ -621,7 +588,6 @@ void hwss_stop_capture(void) { |
|
|
|
#endif |
|
|
|
} |
|
|
|
|
|
|
|
nrf_gpio_cfg_default(ADS1293_READY_PIN); |
|
|
|
nrf_gpio_cfg_default(LINE_DET_PIN); |
|
|
|
} |
|
|
|
|
|
|
|