Echo ADC fast capture의 샘플별 timeout 카운터 제거
- 수동 CS GPIO 제어 유지 - 샘플 간 CS/SPI 타이밍은 유지하면서 per-samples poling overhead를 줄이기 위함
This commit is contained in:
@@ -30,7 +30,6 @@ static bool echo_adc_initialized;
|
|||||||
/* ADC 원본 수신 버퍼 */
|
/* ADC 원본 수신 버퍼 */
|
||||||
static uint8_t raw_capture[ECHO_ADC_MAX_SAMPLES * 2];
|
static uint8_t raw_capture[ECHO_ADC_MAX_SAMPLES * 2];
|
||||||
|
|
||||||
/* GPIO 포트 레지스터 선택 */
|
|
||||||
static NRF_GPIO_Type *gpio_reg_for_spec(const struct gpio_dt_spec *spec)
|
static NRF_GPIO_Type *gpio_reg_for_spec(const struct gpio_dt_spec *spec)
|
||||||
{
|
{
|
||||||
return (spec->port == DEVICE_DT_GET(DT_NODELABEL(gpio1))) ? NRF_P1 : NRF_P0;
|
return (spec->port == DEVICE_DT_GET(DT_NODELABEL(gpio1))) ? NRF_P1 : NRF_P0;
|
||||||
@@ -112,27 +111,17 @@ static int echo_adc_capture_fast(uint16_t *samples, uint16_t num_samples)
|
|||||||
|
|
||||||
for (uint16_t i = 0; i < num_samples; i++)
|
for (uint16_t i = 0; i < num_samples; i++)
|
||||||
{
|
{
|
||||||
/* CS 하강 후 2바이트 수신 */
|
|
||||||
cs_port->OUTCLR = cs_mask;
|
cs_port->OUTCLR = cs_mask;
|
||||||
spim->RXD.PTR = (uint32_t)&raw_capture[i * 2U];
|
spim->RXD.PTR = (uint32_t)&raw_capture[i * 2U];
|
||||||
spim->EVENTS_END = 0;
|
spim->EVENTS_END = 0;
|
||||||
spim->TASKS_START = 1;
|
spim->TASKS_START = 1;
|
||||||
|
|
||||||
/* 전송 완료 대기 */
|
/* 전송 완료 대기 */
|
||||||
uint32_t timeout = 10000U;
|
while (!spim->EVENTS_END)
|
||||||
while (!spim->EVENTS_END && (timeout > 0U))
|
|
||||||
{
|
{
|
||||||
timeout--;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* CS 복귀 */
|
|
||||||
cs_port->OUTSET = cs_mask;
|
cs_port->OUTSET = cs_mask;
|
||||||
|
|
||||||
if (timeout == 0U)
|
|
||||||
{
|
|
||||||
DBG_PRINTF("[ECHO] fast capture timeout\r\n");
|
|
||||||
return -ETIMEDOUT;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
echo_adc_unpack_samples(samples, num_samples);
|
echo_adc_unpack_samples(samples, num_samples);
|
||||||
@@ -182,7 +171,7 @@ int echo_adc_init(void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo_adc_initialized = true;
|
echo_adc_initialized = true;
|
||||||
DBG_PRINTF("[ECHO] SPIM3 init OK\r\n");
|
//DBG_PRINTF("[ECHO] SPIM3 init OK\r\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user