apply latest local changes

This commit is contained in:
jhChun
2026-03-23 16:22:25 +09:00
parent 35d6956de2
commit be3ebc9a63
16 changed files with 252 additions and 395 deletions

View File

@@ -215,17 +215,17 @@ void TIMER2_IRQHandler(void)
/* 피에조 전원 ON: DC/DC 컨버터 활성화 → ±20V 생성 */
void dr_piezo_power_on(void)
{
nrf_delay_ms(20);
//nrf_delay_ms(20);
nrf_gpio_cfg_output(DR_PIEZO_PWR_EN);
nrf_gpio_pin_set(DR_PIEZO_PWR_EN);
/* Wait for power stabilization */
nrf_delay_ms(10);
nrf_delay_ms(3);
m_power_enabled = true;
DBG_PRINTF("[PIEZO] Power ON: +/-20V ready\r\n");
//DBG_PRINTF("[PIEZO] TX/RX Active: +/-20V ready\r\n");
}
/* 피에조 전원 OFF: TX 비활성화 → MUX 비활성화 → DC/DC 컨버터 차단 */
@@ -243,7 +243,7 @@ void dr_piezo_power_off(void)
m_power_enabled = false;
DBG_PRINTF("[PIEZO] Power OFF\r\n");
//DBG_PRINTF("[PIEZO] Power OFF\r\n");
}
/* 피에조 전원 상태 확인 */
@@ -272,8 +272,6 @@ static void dr_piezo_gpio_init(void)
/* Initialize MUX control pins */
dr_piezo_mux_init();
DBG_PRINTF("[PIEZO] GPIO init done\r\n");
}
/* GPIOTE 초기화: P_OUT/N_OUT을 토글 모드로 설정 (PPI 연결 대상) */
@@ -296,8 +294,6 @@ static void dr_piezo_gpiote_init(void)
NRF_GPIOTE_INITIAL_VALUE_LOW
);
nrf_gpiote_task_enable(GPIOTE_CH_N_OUT);
DBG_PRINTF("[PIEZO] GPIOTE init done\r\n");
}
/*
@@ -345,8 +341,6 @@ static void dr_piezo_timer_init(void)
NVIC_SetPriority(PIEZO_TIMER_IRQn, PIEZO_TIMER_IRQ_PRIORITY);
NVIC_EnableIRQ(PIEZO_TIMER_IRQn);
DBG_PRINTF("[DR_PIEZO] Timer init done (period=%d ticks)\r\n", m_period_ticks);
}
/*
@@ -394,8 +388,6 @@ static void dr_piezo_ppi_init(void)
(uint32_t)&NRF_GPIOTE->TASKS_OUT[GPIOTE_CH_N_OUT]
);
nrf_ppi_channel_enable((nrf_ppi_channel_t)PPI_CH_N_OUT_TOGGLE_1);
DBG_PRINTF("[DR_PIEZO] PPI init done (4 channels)\r\n");
}
/*==============================================================================
@@ -405,8 +397,6 @@ static void dr_piezo_ppi_init(void)
/* TX 드라이버 초기화: GPIO → GPIOTE → Timer → PPI 순서로 설정 */
void dr_piezo_init(void)
{
DBG_PRINTF("[DR_PIEZO] Initializing TX driver...\r\n");
dr_piezo_gpio_init();
dr_piezo_gpiote_init();
dr_piezo_timer_init();
@@ -415,8 +405,6 @@ void dr_piezo_init(void)
m_tx_active = false;
m_remaining_cycles = 0;
m_initialized = true;
DBG_PRINTF("[DR_PIEZO] TX driver ready (2MHz)\r\n");
}
/* TX 드라이버 해제: 타이머 정지, PPI/GPIOTE 비활성화, 모든 핀 LOW */
@@ -441,8 +429,6 @@ void dr_piezo_uninit(void)
m_tx_active = false;
m_initialized = false;
DBG_PRINTF("[DR_PIEZO] TX driver uninitialized\r\n");
}
/*
@@ -538,7 +524,6 @@ void dr_piezo_disable(void)
nrf_gpio_pin_clear(DR_PIEZO_PIN_PE);
nrf_gpio_pin_clear(DR_PIEZO_PIN_P_OUT);
nrf_gpio_pin_clear(DR_PIEZO_PIN_N_OUT);
DBG_PRINTF("[DR_PIEZO] TX disabled\r\n");
}
/* TX 송신 중 여부 확인 (인터럽트 핸들러에서 false로 전환) */
@@ -577,16 +562,6 @@ void dr_piezo_set_frequency(uint32_t freq_hz)
/* MUX 제어 핀 초기화: 4개 핀 모두 High Drive 출력으로 설정, 기본값 LOW */
void dr_piezo_mux_init(void)
{
/* Configure MUX control pins as outputs */
/*nrf_gpio_cfg_output(DR_PIEZO_MUX_SEL1);
nrf_gpio_cfg_output(DR_PIEZO_MUX_SEL2);
nrf_gpio_cfg_output(DR_PIEZO_MUX_SEL3);*/
/*nrf_gpio_cfg_output(DR_PIEZO_EN_MUXA);
nrf_gpio_cfg_output(DR_PIEZO_EN_MUXB);
nrf_gpio_cfg_output(DR_PIEZO_MUX_SEL0);
nrf_gpio_cfg_output(DR_PIEZO_MUX_SEL1);*/
/* Configure pins as output with high drive strength */
nrf_gpio_cfg(
DR_PIEZO_MUX_SEL0,
@@ -624,17 +599,10 @@ void dr_piezo_mux_init(void)
NRF_GPIO_PIN_NOSENSE
);
/* Set MUX selection: P1.13=HIGH, P1.12=LOW, P1.11=LOW */
//nrf_gpio_pin_set(DR_PIEZO_MUX_SEL1); /* P1.13 = HIGH */
//nrf_gpio_pin_clear(DR_PIEZO_MUX_SEL2); /* P1.12 = LOW */
//nrf_gpio_pin_clear(DR_PIEZO_MUX_SEL3); /* P1.11 = LOW */
nrf_gpio_pin_clear(DR_PIEZO_EN_MUXA); /* P0.21 = LOW, Select Channel -> HIGH */
nrf_gpio_pin_clear(DR_PIEZO_EN_MUXB); /* P0.23 = LOW, Select Channel -> HIGH */
nrf_gpio_pin_clear(DR_PIEZO_MUX_SEL0); /* P1.10 = LOW */
nrf_gpio_pin_clear(DR_PIEZO_MUX_SEL1); /* P0.28 = LOW */
DBG_PRINTF("[DR_PIEZO] MUX init done\r\n");
}
@@ -687,7 +655,7 @@ void dr_piezo_select_channel(uint8_t channel)
break;
}
/* Delay for MUX settling (analog path stabilization) */
/* 채널 변경 시 MUX 안정화 시간 필요 (> 1.2ms) */
nrf_delay_us(DR_PIEZO_MUX_SETTLING_US);
}
@@ -735,13 +703,11 @@ void dr_piezo_test_pins(void)
* 시스템 함수 (전원 + TX 드라이버 통합 제어)
*============================================================================*/
/* 시스템 전체 초기화: 전원 ON → TX 드라이버 초기화 */
/* 시스템 전체 초기화: TX 드라이버 초기화 → 전원 ON (부팅 시 1회만 호출) */
void dr_piezo_system_init(void)
{
DBG_PRINTF("[PIEZO] System init...\r\n");
dr_piezo_power_on();
dr_piezo_init();
DBG_PRINTF("[PIEZO] System ready\r\n");
dr_piezo_init(); /* GPIO/GPIOTE/Timer/PPI 먼저 안전 상태로 설정 */
dr_piezo_power_on(); /* 그 다음 DC/DC 전원 인가 */
}
/* 시스템 전체 종료: TX 드라이버 해제 → 전원 OFF */
@@ -749,7 +715,6 @@ void dr_piezo_system_uninit(void)
{
dr_piezo_uninit();
dr_piezo_power_off();
DBG_PRINTF("[DR_PIEZO] System shutdown\r\n");
}
/* 전원 확인 후 버스트 송신 (블로킹: 송신 완료까지 대기) */

View File

@@ -68,9 +68,6 @@
* 전원 제어 핀 (DC/DC 컨버터 +/-20V)
* DR_PIEZO_PWR_EN: HIGH로 설정 시 DC/DC 컨버터가 +/-20V 고전압 생성
*============================================================================*/
//#define DR_PIEZO_PWR_SHDN NRF_GPIO_PIN_MAP(0, 21) /**< SHDN_VPP/VNN (LT3463) */ // P0.21 : PZT_EN_MUXA jhChun 0128
//#define DR_PIEZO_PWR_EN_10V NRF_GPIO_PIN_MAP(0, 22) /**< EN_+10V (MCP1804) */ // P0.22 : NIRS PIN
#define DR_PIEZO_PWR_EN NRF_GPIO_PIN_MAP(1, 9) /** Power Enable jhChun 0128 */
/*==============================================================================
@@ -81,15 +78,10 @@
* N_OUT: Negative Output - 피에조 음극 구동 (P_OUT과 역상)
* 주의: 이전 핀 할당(주석 처리)에서 새 보드 레이아웃으로 변경됨 (jhChun 0128)
*============================================================================*/
//#define DR_PIEZO_PIN_PE NRF_GPIO_PIN_MAP(1, 5) /**< Pulse Enable */
//#define DR_PIEZO_PIN_DMP NRF_GPIO_PIN_MAP(1, 9) /**< Dump control */
//#define DR_PIEZO_PIN_P_OUT NRF_GPIO_PIN_MAP(1, 3) /**< Positive output */
//#define DR_PIEZO_PIN_N_OUT NRF_GPIO_PIN_MAP(1, 2) /**< Negative output */
#define DR_PIEZO_PIN_PE NRF_GPIO_PIN_MAP(0, 25) /**< Pulse Enable */ // P1.05 -> P0.25
#define DR_PIEZO_PIN_DMP NRF_GPIO_PIN_MAP(1, 0) /**< Dump control */ // P1.9 -> P1.0
#define DR_PIEZO_PIN_P_OUT NRF_GPIO_PIN_MAP(1, 7) /**< Positive output */ // P1.3 -> P1.7
#define DR_PIEZO_PIN_N_OUT NRF_GPIO_PIN_MAP(1, 6) /**< Negative output */ // P1.2 -> P1.6 jhChun 0128
#define DR_PIEZO_PIN_DMP NRF_GPIO_PIN_MAP(1, 0) /**< Dump control */ // P1.9 -> P1.0
#define DR_PIEZO_PIN_P_OUT NRF_GPIO_PIN_MAP(1, 7) /**< Positive output */ // P1.3 -> P1.7
#define DR_PIEZO_PIN_N_OUT NRF_GPIO_PIN_MAP(1, 6) /**< Negative output */ // P1.2 -> P1.6 jhChun 0128
/*==============================================================================
* MUX 제어 핀 (에코 신호 경로 선택)
@@ -98,10 +90,6 @@
* EN_MUXA/EN_MUXB: 각 MUX 활성화 (동시에 하나만 HIGH)
* SEL0/SEL1: MUX 내부 4채널 중 하나를 선택하는 주소 비트
*============================================================================*/
//#define DR_PIEZO_MUX_SEL1 NRF_GPIO_PIN_MAP(1, 13) /**< MUX Select 1 (HIGH) */
//#define DR_PIEZO_MUX_SEL2 NRF_GPIO_PIN_MAP(1, 12) /**< MUX Select 2 (LOW) */
//#define DR_PIEZO_MUX_SEL3 NRF_GPIO_PIN_MAP(1, 11) /**< MUX Select 3 (LOW) */
/* Piezo MUX pins (8ch) jhChun 0129 */
#define DR_PIEZO_EN_MUXA NRF_GPIO_PIN_MAP(0, 21) /**< MUXA Enable */
#define DR_PIEZO_EN_MUXB NRF_GPIO_PIN_MAP(0, 23) /**< MUXB Enable */
@@ -123,8 +111,8 @@
#define DR_PIEZO_FREQ_HZ 2100000 /**< Target frequency (set PIEZO_FREQ_MHZ in .c) */
#define DR_PIEZO_DEFAULT_CYCLES 5 /**< Default burst cycles (3~5) */
#define DR_PIEZO_MIN_CYCLES 3
#define DR_PIEZO_MAX_CYCLES 7 /* 3 -> 7 jhChun 26.03.12 */
#define DR_PIEZO_MUX_SETTLING_US 1300 /**< MUX settling delay (us) */
#define DR_PIEZO_MAX_CYCLES 7
#define DR_PIEZO_MUX_SETTLING_US 1300 /**< MUX settling delay (us) */
/*==============================================================================
* 전원 제어 함수