문서 및 로그 정리

This commit is contained in:
2026-09-03 11:01:05 +09:00
parent b0cb5149fd
commit a74cf5110f
15 changed files with 13 additions and 86 deletions
+1 -2
View File
@@ -2,7 +2,6 @@
build/ build/
build_*/ build_*/
twister-out/ twister-out/
.vscode/.west/
# West / Zephyr local metadata # West / Zephyr local metadata
.zephyr/ .zephyr/
@@ -34,7 +33,7 @@ __pycache__/
.pytest_cache/ .pytest_cache/
# Editor / OS # Editor / OS
.vscode/ipch/ .vscode/
.vs/ .vs/
.idea/ .idea/
.DS_Store .DS_Store
-7
View File
@@ -1,13 +1,6 @@
/******************************************************************************* /*******************************************************************************
* @file ble_service.c * @file ble_service.c
* @brief BLE NUS service module * @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 <zephyr/kernel.h> #include <zephyr/kernel.h>
#include <zephyr/bluetooth/bluetooth.h> #include <zephyr/bluetooth/bluetooth.h>
-2
View File
@@ -1,8 +1,6 @@
/******************************************************************************* /*******************************************************************************
* @file ble_service.h * @file ble_service.h
* @brief BLE NUS service module * @brief BLE NUS service module
*
* Nordic UART Service (NUS) based BLE communication
******************************************************************************/ ******************************************************************************/
#ifndef BLE_SERVICE_H__ #ifndef BLE_SERVICE_H__
#define BLE_SERVICE_H__ #define BLE_SERVICE_H__
+1 -3
View File
@@ -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; const struct mgmt_evt_op_cmd_arg *cmd = data;
if (cmd->group == MGMT_GROUP_ID_IMAGE && if (cmd->group == MGMT_GROUP_ID_IMAGE && (cmd->id == IMG_MGMT_ID_UPLOAD || cmd->id == IMG_MGMT_ID_STATE) && cmd->err != MGMT_ERR_EOK)
(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); DBG_ERR("[DFU] command failed id=%u err=%d\r\n", cmd->id, cmd->err);
-13
View File
@@ -1,19 +1,6 @@
/******************************************************************************* /*******************************************************************************
* @file battery_adc.c * @file battery_adc.c
* @brief Battery voltage ADC measurement * @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 <zephyr/kernel.h> #include <zephyr/kernel.h>
#include <zephyr/drivers/adc.h> #include <zephyr/drivers/adc.h>
-3
View File
@@ -1,9 +1,6 @@
/******************************************************************************* /*******************************************************************************
* @file battery_adc.h * @file battery_adc.h
* @brief Battery voltage ADC measurement (Zephyr port) * @brief Battery voltage ADC measurement (Zephyr port)
*
* AIN2 채널, 12-bit, 1/6 gain, 4X oversample
* 저전압(3500mV) 5회 연속 감지 시 자동 전원 OFF
******************************************************************************/ ******************************************************************************/
#ifndef BATTERY_ADC_H__ #ifndef BATTERY_ADC_H__
#define BATTERY_ADC_H__ #define BATTERY_ADC_H__
-2
View File
@@ -1,8 +1,6 @@
/******************************************************************************* /*******************************************************************************
* @file imu_i2c.c * @file imu_i2c.c
* @brief ICM42670P IMU Driver (Zephyr I2C API) * @brief ICM42670P IMU Driver (Zephyr I2C API)
* I2C 핀: SCL=P1.14, SDA=P1.15 (overlay에서 설정)
******************************************************************************/ ******************************************************************************/
#include <zephyr/kernel.h> #include <zephyr/kernel.h>
-5
View File
@@ -1,11 +1,6 @@
/******************************************************************************* /*******************************************************************************
* @file imu_i2c.h * @file imu_i2c.h
* @brief ICM42670P IMU 드라이버 (Zephyr I2C API) * @brief ICM42670P IMU 드라이버 (Zephyr I2C API)
*
* 핀 배치:
* SCL: P1.14
* SDA: P1.15
* I2C 주소: 0x68
******************************************************************************/ ******************************************************************************/
#ifndef IMU_I2C_H__ #ifndef IMU_I2C_H__
-3
View File
@@ -1,9 +1,6 @@
/******************************************************************************* /*******************************************************************************
* @file led_control.c * @file led_control.c
* @brief LED direct control driver * @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 <zephyr/kernel.h> #include <zephyr/kernel.h>
#include <zephyr/drivers/gpio.h> #include <zephyr/drivers/gpio.h>
-2
View File
@@ -1,8 +1,6 @@
/******************************************************************************* /*******************************************************************************
* @file led_control.h * @file led_control.h
* @brief LED direct control driver * @brief LED direct control driver
*
* Green (P0.12) + Orange (P0.29) 2-color LED with k_timer based patterns
******************************************************************************/ ******************************************************************************/
#ifndef LED_CONTROL_H__ #ifndef LED_CONTROL_H__
#define LED_CONTROL_H__ #define LED_CONTROL_H__
+1 -7
View File
@@ -1,12 +1,6 @@
/******************************************************************************* /*******************************************************************************
* @file main.c * @file main.c
* @brief VesiScan-Basic * @brief VesiScan-Basic Zephyr main entry point
*
* - 앱 공통 전역 상태 보관
* - 부팅 직후 전원 유지 판단
* - NVS 로드 전 기본값 초기화
* - 각 모듈 초기화 순서 조립
* - main loop 유지
******************************************************************************/ ******************************************************************************/
#include <zephyr/kernel.h> #include <zephyr/kernel.h>
+1 -1
View File
@@ -1,6 +1,6 @@
/******************************************************************************* /*******************************************************************************
* @file main.h * @file main.h
* @brief VesiScan-Basic * @brief VesiScan-Basic Zephyr main header
******************************************************************************/ ******************************************************************************/
#ifndef MAIN_H__ #ifndef MAIN_H__
+9 -33
View File
@@ -32,7 +32,7 @@
#define PIEZO_CFG_SAMPLES_MAX 117 #define PIEZO_CFG_SAMPLES_MAX 117
#define PIEZO_CFG_DELAY_MAX_US 50 #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 #define PIEZO_POST_SELECT_SETTLE_US 0
/* burst 사이의 회복 시간 */ /* burst 사이의 회복 시간 */
@@ -163,21 +163,21 @@ int piezo_measure_start_session(void)
int err = piezo_init(); int err = piezo_init();
if (err) 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; return ECHO_STATUS_PIEZO;
} }
err = echo_adc_init(); err = echo_adc_init();
if (err) 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; return ECHO_STATUS_ADC_INIT;
} }
err = echo_adc_wake(); err = echo_adc_wake();
if (err) 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; return ECHO_STATUS_ADC_INIT;
} }
@@ -214,7 +214,7 @@ int piezo_measure_sweep(void)
int err = piezo_select_channel(ch); int err = piezo_select_channel(ch);
if (err) 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; return ECHO_STATUS_MUX;
} }
@@ -224,7 +224,7 @@ int piezo_measure_sweep(void)
err = echo_adc_wake(); err = echo_adc_wake();
if (err) 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; return ECHO_STATUS_CAPTURE;
} }
@@ -232,38 +232,14 @@ int piezo_measure_sweep(void)
{ {
piezo_power_on(); piezo_power_on();
k_msleep(PIEZO_POWER_STABILIZE_MS); 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); k_busy_wait(PIEZO_AVG_INTER_BURST_GAP_US);
piezo_burst_sw_freq(freq, cycles); piezo_burst_sw_freq(freq, cycles);
k_busy_wait(capture_delay_us); k_busy_wait(capture_delay_us);
err = echo_adc_capture(echo_capture, samples); err = echo_adc_capture(echo_capture, samples);
if (err) 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; return ECHO_STATUS_CAPTURE;
} }
@@ -291,7 +267,7 @@ int piezo_measure_sweep(void)
if (err) 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; return ECHO_STATUS_CAPTURE;
} }
-3
View File
@@ -18,9 +18,6 @@
#define ECHO_STATUS_ADC_INIT 0x0002 #define ECHO_STATUS_ADC_INIT 0x0002
#define ECHO_STATUS_MUX 0x0003 #define ECHO_STATUS_MUX 0x0003
#define ECHO_STATUS_CAPTURE 0x0004 #define ECHO_STATUS_CAPTURE 0x0004
#define ECHO_STATUS_BATT 0x0005
#define ECHO_STATUS_IMU 0x0006
#define ECHO_STATUS_TEMP 0x0007
typedef struct typedef struct
{ {