- Piezo 6ch 측정 + 센서(배터리, IMU, 온도) 측정: mbb 명령어 추가

- Flash Memory Piezo 측정 파라미터 추가

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
jhChun
2026-03-18 13:54:06 +09:00
parent 96a46a26dd
commit 3ecd81c252
12 changed files with 507 additions and 306 deletions

View File

@@ -791,7 +791,7 @@ dr_adc_err_t dr_adc_burst_capture_transmit(uint8_t freq_option, uint16_t delay_u
if (num_samples == 0 || num_samples > DR_ADC_ECHO_SAMPLES_MAX)
return DR_ADC_ERR_INVALID_PARAM;
if (freq_option > 9) freq_option = 0; /* Invalid -> default 1.8MHz */
if (cycles < 3 || cycles > 9) cycles = 5; /* Valid range: 3~9, default 5 */
if (cycles < 3 || cycles > 7) cycles = 5; /* Valid range: 3~7, default 5 */
if (averaging == 0) averaging = 1; /* Minimum 1 */
if (averaging > 1000) averaging = 1000; /* Maximum 1000 */
if (piezo_ch >= MAA_NUM_CHANNELS) piezo_ch = 0; /* 채널 범위 검증 */
@@ -1018,7 +1018,7 @@ dr_adc_err_t dr_adc_capture_channel_only(uint8_t freq_option, uint16_t delay_us,
if (num_samples == 0 || num_samples > MAA_SAMPLES_MAX)
return DR_ADC_ERR_INVALID_PARAM;
if (freq_option > 3) freq_option = 0;
if (cycles < 3 || cycles > 9) cycles = 5;
if (cycles < 3 || cycles > 7) cycles = 5;
if (averaging == 0) averaging = 1;
if (averaging > 1000) averaging = 1000;
if (piezo_ch > (MAA_NUM_CHANNELS - 1)) piezo_ch = 0;
@@ -1448,6 +1448,13 @@ static void maa_async_send_completion(uint16_t status)
g_maa_ctx.state = MAA_ASYNC_IDLE;
ADC_LOG("maa_async: complete, status=0x%04X", status);
/* 완료 콜백 호출 (mbb? 등에서 센서 측정 체인 트리거용) */
if (g_maa_ctx.on_complete_cb) {
void (*cb)(void) = g_maa_ctx.on_complete_cb;
g_maa_ctx.on_complete_cb = NULL; /* 1회성: 재호출 방지 */
cb();
}
}
/*==============================================================================
@@ -1471,12 +1478,13 @@ dr_adc_err_t maa_async_start(uint8_t freq_option, uint16_t delay_us,
g_maa_ctx.freq_option = freq_option;
g_maa_ctx.delay_us = delay_us;
g_maa_ctx.num_samples = num_samples;
g_maa_ctx.cycles = (cycles < 3 || cycles > 9) ? 5 : cycles;
g_maa_ctx.cycles = (cycles < 3 || cycles > 7) ? 5 : cycles;
g_maa_ctx.averaging = (averaging == 0) ? 1 : ((averaging > 1000) ? 1000 : averaging);
g_maa_ctx.ble_buffer = ble_buffer;
g_maa_ctx.current_ch = 0;
g_maa_ctx.current_pkt = 0;
g_maa_ctx.data_offset = 0;
g_maa_ctx.on_complete_cb = NULL; /* 기본: 콜백 없음 (maa?) */
ADC_LOG("maa_async_start: freq=%u delay=%u samples=%u cycles=%u avg=%u",
freq_option, delay_us, num_samples, g_maa_ctx.cycles, g_maa_ctx.averaging);
@@ -1568,3 +1576,8 @@ void maa_async_set_auto_power(bool on)
g_maa_ctx.auto_powered = on;
}
void maa_async_set_on_complete(void (*cb)(void))
{
g_maa_ctx.on_complete_cb = cb;
}

View File

@@ -191,7 +191,7 @@ dr_adc_err_t dr_adc_measure_echo(dr_adc_echo_t *echo, const dr_adc_echo_config_t
/**
* @brief Piezo burst + Echo capture in one call
* @param cycles Number of burst cycles (3~9)
* @param cycles Number of burst cycles (3~7)
* @param delay_us Delay before capture (us)
* @param num_samples Number of samples to capture
* @param echo Pointer to echo result structure
@@ -455,6 +455,7 @@ typedef struct {
uint16_t total_packets; /**< Total packets for current channel */
uint16_t data_packets; /**< Data packets for current channel */
bool auto_powered; /**< true: 자동 전원 ON → 완료 후 OFF */
void (*on_complete_cb)(void); /**< 비동기 캡처 완료 후 호출될 콜백 (NULL이면 미사용) */
} maa_async_ctx_t;
/**
@@ -466,7 +467,7 @@ typedef struct {
* @param freq_option Frequency: 0=1.8MHz, 1=2.1MHz, 2=2.0MHz, 3=1.7MHz
* @param delay_us Capture delay (us)
* @param num_samples Samples per channel (1~200)
* @param cycles Burst cycles (3~9)
* @param cycles Burst cycles (3~7)
* @param averaging Averaging count (1~1000)
* @param ble_buffer Working buffer (>= 240 bytes)
* @return dr_adc_err_t DR_ADC_OK if started successfully
@@ -507,5 +508,11 @@ void maa_async_abort(void);
*/
void maa_async_set_auto_power(bool on);
/**
* @brief 비동기 캡처 완료 콜백 설정
* raa: 전송 + 전원 OFF 이후 호출된다. NULL이면 콜백 없음.
*/
void maa_async_set_on_complete(void (*cb)(void));
#endif /* DR_ADC121S051_H */