diff --git a/.gitignore b/.gitignore index fd9ca40..c00b193 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,6 @@ build/ build_*/ twister-out/ -.vscode/.west/ # West / Zephyr local metadata .zephyr/ @@ -34,7 +33,7 @@ __pycache__/ .pytest_cache/ # Editor / OS -.vscode/ipch/ +.vscode/ .vs/ .idea/ .DS_Store diff --git a/curcuit/VesiScan-Basic_curcuit.pdf b/circuit/VesiScan-Basic_curcuit.pdf similarity index 100% rename from curcuit/VesiScan-Basic_curcuit.pdf rename to circuit/VesiScan-Basic_curcuit.pdf diff --git a/src/ble/ble_service.c b/src/ble/ble_service.c index 7330282..76174d8 100644 --- a/src/ble/ble_service.c +++ b/src/ble/ble_service.c @@ -1,13 +1,6 @@ /******************************************************************************* * @file ble_service.c * @brief BLE NUS service module - * - * Original VesiScan-Basic BLE implementation ported to Zephyr/NCS: - * - NUS (Nordic UART Service) for data exchange - * - Advertising: 40ms interval, 10-min timeout - * - Connection: 15ms interval, 0 latency, 10s supervision timeout - * - TX power +8 dBm, 2M PHY preferred - * - Dev mode: no security / Production mode: bonding + passkey ******************************************************************************/ #include #include diff --git a/src/ble/ble_service.h b/src/ble/ble_service.h index 168a199..f8c6c9b 100644 --- a/src/ble/ble_service.h +++ b/src/ble/ble_service.h @@ -1,8 +1,6 @@ /******************************************************************************* * @file ble_service.h * @brief BLE NUS service module - * - * Nordic UART Service (NUS) based BLE communication ******************************************************************************/ #ifndef BLE_SERVICE_H__ #define BLE_SERVICE_H__ diff --git a/src/dfu/dfu_manager.c b/src/dfu/dfu_manager.c index b2647b1..f5eb96a 100644 --- a/src/dfu/dfu_manager.c +++ b/src/dfu/dfu_manager.c @@ -226,9 +226,7 @@ static enum mgmt_cb_return smp_cmd_status_cb(uint32_t event, enum mgmt_cb_return const struct mgmt_evt_op_cmd_arg *cmd = data; - if (cmd->group == MGMT_GROUP_ID_IMAGE && - (cmd->id == IMG_MGMT_ID_UPLOAD || cmd->id == IMG_MGMT_ID_STATE) && - cmd->err != MGMT_ERR_EOK) + if (cmd->group == MGMT_GROUP_ID_IMAGE && (cmd->id == IMG_MGMT_ID_UPLOAD || cmd->id == IMG_MGMT_ID_STATE) && cmd->err != MGMT_ERR_EOK) { DBG_ERR("[DFU] command failed id=%u err=%d\r\n", cmd->id, cmd->err); diff --git a/src/drivers/battery/battery_adc.c b/src/drivers/battery/battery_adc.c index 7896cbf..81c70d4 100644 --- a/src/drivers/battery/battery_adc.c +++ b/src/drivers/battery/battery_adc.c @@ -1,19 +1,6 @@ /******************************************************************************* * @file battery_adc.c * @brief Battery voltage ADC measurement - * - * ADC 채널 설정은 디바이스트리 overlay에서 관리: - * - AIN2 (P0.04), Single-ended - * - 12-bit 해상도, 1/6 gain, 4X oversample, 40us acq time - * - * 변환 공식: mV = (ADC × 600 / 4095) × 6 × 1.42 - * → 프로젝트 고유 분압비(1.42x) 때문에 adc_raw_to_millivolts_dt() 사용 불가 - * - * 동작 모드: - * - 단독 측정 (msn? 커맨드) → battery_read_mv() 호출 - * - 주기 모니터링 (60초) → 저전압 또는 고온 5회 연속 시 자동 전원 OFF - * - 측정 중(processing) 또는 IMU FIFO 동작 중에는 주기 모니터링 스킵 - * - mbb? 측정 응답 -> parser에서 battery_read_mv() 호출 후 패킷에 포함 ******************************************************************************/ #include #include diff --git a/src/drivers/battery/battery_adc.h b/src/drivers/battery/battery_adc.h index 0323420..1d768e5 100644 --- a/src/drivers/battery/battery_adc.h +++ b/src/drivers/battery/battery_adc.h @@ -1,9 +1,6 @@ /******************************************************************************* * @file battery_adc.h * @brief Battery voltage ADC measurement (Zephyr port) - * - * AIN2 채널, 12-bit, 1/6 gain, 4X oversample - * 저전압(3500mV) 5회 연속 감지 시 자동 전원 OFF ******************************************************************************/ #ifndef BATTERY_ADC_H__ #define BATTERY_ADC_H__ diff --git a/src/drivers/imu/imu_i2c.c b/src/drivers/imu/imu_i2c.c index 67d7e2a..62936fb 100644 --- a/src/drivers/imu/imu_i2c.c +++ b/src/drivers/imu/imu_i2c.c @@ -1,8 +1,6 @@ /******************************************************************************* * @file imu_i2c.c * @brief ICM42670P IMU Driver (Zephyr I2C API) - - * I2C 핀: SCL=P1.14, SDA=P1.15 (overlay에서 설정) ******************************************************************************/ #include diff --git a/src/drivers/imu/imu_i2c.h b/src/drivers/imu/imu_i2c.h index 0c19cfe..e3c6603 100644 --- a/src/drivers/imu/imu_i2c.h +++ b/src/drivers/imu/imu_i2c.h @@ -1,11 +1,6 @@ /******************************************************************************* * @file imu_i2c.h * @brief ICM42670P IMU 드라이버 (Zephyr I2C API) - * - * 핀 배치: - * SCL: P1.14 - * SDA: P1.15 - * I2C 주소: 0x68 ******************************************************************************/ #ifndef IMU_I2C_H__ diff --git a/src/drivers/led/led_control.c b/src/drivers/led/led_control.c index b6d01a0..c72294a 100644 --- a/src/drivers/led/led_control.c +++ b/src/drivers/led/led_control.c @@ -1,9 +1,6 @@ /******************************************************************************* * @file led_control.c * @brief LED direct control driver - * - * k_timer based 2-color LED (green/orange) pattern control - * Simple on/off states use immediate GPIO, complex patterns use state machine ******************************************************************************/ #include #include diff --git a/src/drivers/led/led_control.h b/src/drivers/led/led_control.h index cea9f0f..5dc498d 100644 --- a/src/drivers/led/led_control.h +++ b/src/drivers/led/led_control.h @@ -1,8 +1,6 @@ /******************************************************************************* * @file led_control.h * @brief LED direct control driver - * - * Green (P0.12) + Orange (P0.29) 2-color LED with k_timer based patterns ******************************************************************************/ #ifndef LED_CONTROL_H__ #define LED_CONTROL_H__ diff --git a/src/main.c b/src/main.c index 42708d6..a2805f6 100644 --- a/src/main.c +++ b/src/main.c @@ -1,12 +1,6 @@ /******************************************************************************* * @file main.c - * @brief VesiScan-Basic - * - * - 앱 공통 전역 상태 보관 - * - 부팅 직후 전원 유지 판단 - * - NVS 로드 전 기본값 초기화 - * - 각 모듈 초기화 순서 조립 - * - main loop 유지 + * @brief VesiScan-Basic Zephyr main entry point ******************************************************************************/ #include diff --git a/src/main.h b/src/main.h index c328d39..2839ca9 100644 --- a/src/main.h +++ b/src/main.h @@ -1,6 +1,6 @@ /******************************************************************************* * @file main.h - * @brief VesiScan-Basic + * @brief VesiScan-Basic Zephyr main header ******************************************************************************/ #ifndef MAIN_H__ diff --git a/src/measurement/piezo_measure.c b/src/measurement/piezo_measure.c index 4ce508f..057d209 100644 --- a/src/measurement/piezo_measure.c +++ b/src/measurement/piezo_measure.c @@ -32,7 +32,7 @@ #define PIEZO_CFG_SAMPLES_MAX 117 #define PIEZO_CFG_DELAY_MAX_US 50 -/* piezo_select_channel() 안에서 MUX settle 1.3 ms를 이미 기다린 뒤 analog path/ADC 입력 안정화를 위해 0.5 ms를 한 번 더 기다림 */ +/* piezo_select_channel() 안에서 MUX settle 1.3 ms를 이미 기다린 뒤 analog path/ADC 입력 안정화를 위한 추가 딜레이 */ #define PIEZO_POST_SELECT_SETTLE_US 0 /* burst 사이의 회복 시간 */ @@ -163,21 +163,21 @@ int piezo_measure_start_session(void) int err = piezo_init(); if (err) { - DBG_PRINTF("[PIEZO] init fail err=%d\r\n", err); + DBG_ERR("[PIEZO] init fail err=%d\r\n", err); return ECHO_STATUS_PIEZO; } err = echo_adc_init(); if (err) { - DBG_PRINTF("[ECHO] init fail err=%d\r\n", err); + DBG_ERR("[ECHO] init fail err=%d\r\n", err); return ECHO_STATUS_ADC_INIT; } err = echo_adc_wake(); if (err) { - DBG_PRINTF("[ECHO] wake fail err=%d\r\n", err); + DBG_ERR("[ECHO] wake fail err=%d\r\n", err); return ECHO_STATUS_ADC_INIT; } @@ -214,7 +214,7 @@ int piezo_measure_sweep(void) int err = piezo_select_channel(ch); if (err) { - DBG_PRINTF("[PIEZO] mux fail ch=%d err=%d\r\n", ch, err); + DBG_ERR("[PIEZO] mux fail ch=%d err=%d\r\n", ch, err); return ECHO_STATUS_MUX; } @@ -224,7 +224,7 @@ int piezo_measure_sweep(void) err = echo_adc_wake(); if (err) { - DBG_PRINTF("[ECHO] dummy read fail ch=%d err=%d\r\n", ch, err); + DBG_ERR("[ECHO] dummy read fail ch=%d err=%d\r\n", ch, err); return ECHO_STATUS_CAPTURE; } @@ -232,38 +232,14 @@ int piezo_measure_sweep(void) { piezo_power_on(); k_msleep(PIEZO_POWER_STABILIZE_MS); - - // Dummy burst + ADC caputre - /* - for (uint8_t dummy = 0; dummy < PIEZO_DUMMY_CAPTURE_COUNT; dummy++) - { - k_busy_wait(PIEZO_AVG_INTER_BURST_GAP_US); - - // 실제 측정 신호 흔들림 방지를 위해 dummy 측정에도 IRQ 잠금 적용 - unsigned int key = irq_lock(); - - // burst + delay + capture - piezo_burst_sw_freq(freq, cycles); // 주파수 옵션 있는 burst 함수 - k_busy_wait(capture_delay_us); - err = echo_adc_capture(echo_capture, samples); - - // IRQ 잠금 해제 - irq_unlock(key); - - if (err) - { - DBG_PRINTF("[ECHO] dummy capture fail ch=%d dummy=%d err=%d\r\n", ch, dummy, err); - return ECHO_STATUS_CAPTURE; - } - }*/ - k_busy_wait(PIEZO_AVG_INTER_BURST_GAP_US); piezo_burst_sw_freq(freq, cycles); k_busy_wait(capture_delay_us); err = echo_adc_capture(echo_capture, samples); + if (err) { - //DBG_PRINTF("[ECHO] dummy capture fail ch=%d dummy=%d err=%d\r\n", ch, dummy, err); + DBG_ERR("[ECHO] dummy capture fail ch=%d err=%d\r\n", ch, err); return ECHO_STATUS_CAPTURE; } @@ -291,7 +267,7 @@ int piezo_measure_sweep(void) if (err) { - DBG_PRINTF("[ECHO] capture fail ch=%d avg=%d err=%d\r\n", ch, a, err); + DBG_ERR("[ECHO] capture fail ch=%d avg=%d err=%d\r\n", ch, a, err); return ECHO_STATUS_CAPTURE; } diff --git a/src/measurement/piezo_measure.h b/src/measurement/piezo_measure.h index 7a44281..af50558 100644 --- a/src/measurement/piezo_measure.h +++ b/src/measurement/piezo_measure.h @@ -18,9 +18,6 @@ #define ECHO_STATUS_ADC_INIT 0x0002 #define ECHO_STATUS_MUX 0x0003 #define ECHO_STATUS_CAPTURE 0x0004 -#define ECHO_STATUS_BATT 0x0005 -#define ECHO_STATUS_IMU 0x0006 -#define ECHO_STATUS_TEMP 0x0007 typedef struct {