This commit is contained in:
2026-04-30 12:26:09 +09:00
parent 7bc8bbd178
commit 216fe63b44
5 changed files with 63 additions and 49 deletions
@@ -1,11 +1,17 @@
@echo off
setlocal enabledelayedexpansion
setlocal EnableExtensions EnableDelayedExpansion
echo ==========================================
echo MEDiThings Bladder Patch Programming
echo (mergehex + nrfutil 8.x)
echo ==========================================
REM -----------------------------------------------------
REM Create hex output folder
REM -----------------------------------------------------
cd /d "%~dp0"
echo Working directory: %CD%
REM -----------------------------------------------------
REM Create hex output folder
REM -----------------------------------------------------
@@ -85,18 +91,29 @@ REM 6. Detect device SERIAL NUMBER
REM -----------------------------------------------------
echo [6/7] Detecting device serial number...
for /f %%A in ('
powershell -Command "(nrfutil device list --json | Select-String '\"type\":\"info\"' | ConvertFrom-Json).data.devices[0].serialNumber"
') do set SERIALNUMBER=%%A
set "SERIALNUMBER="
if "%SERIALNUMBER%"=="" (
for /f %%A in ('nrfjprog --ids 2^>nul') do (
if not defined SERIALNUMBER set "SERIALNUMBER=%%A"
)
if not defined SERIALNUMBER (
for /f %%A in ('
powershell -NoProfile -Command "(nrfutil device list --json | ConvertFrom-Json).data.devices[0].serialNumber"
') do (
if not defined SERIALNUMBER set "SERIALNUMBER=%%A"
)
)
if not defined SERIALNUMBER (
echo ERROR: No serial number found.
echo Check USB connection and Nordic tools installation.
pause
exit /b 1
)
echo Using Serial Number: %SERIALNUMBER%
echo Flashing: recover erase program reset
echo Flashing: recover ??erase ??program ??reset
REM recover
nrfutil device recover --serial-number %SERIALNUMBER%
@@ -1,5 +1,5 @@
@echo off
setlocal enabledelayedexpansion
setlocal EnableExtensions EnableDelayedExpansion
echo ==========================================
echo MEDiThings Bladder Patch Programming
@@ -116,23 +116,34 @@ REM 6. Detect device SERIAL NUMBER and Flash
REM -----------------------------------------------------
echo [6/6] Detecting device serial number...
for /f %%A in ('
powershell -Command "(nrfutil device list --json | Select-String '\"type\":\"info\"' | ConvertFrom-Json).data.devices[0].serialNumber"
') do set SERIALNUMBER=%%A
set "SERIALNUMBER="
if "%SERIALNUMBER%"=="" (
for /f %%A in ('nrfjprog --ids 2^>nul') do (
if not defined SERIALNUMBER set "SERIALNUMBER=%%A"
)
if not defined SERIALNUMBER (
for /f %%A in ('
powershell -NoProfile -Command "(nrfutil device list --json | ConvertFrom-Json).data.devices[0].serialNumber"
') do (
if not defined SERIALNUMBER set "SERIALNUMBER=%%A"
)
)
if not defined SERIALNUMBER (
echo ERROR: No serial number found.
echo Check USB connection and Nordic tools installation.
pause
exit /b 1
)
echo Using Serial Number: %SERIALNUMBER%
echo Flashing: program reset (NO erase, FDS preserved)
echo Flashing: program ??reset (NO erase, FDS preserved)
REM recover - SKIP to preserve internal flash data
REM erase - SKIP to preserve FDS/fstorage data
REM program (hex 데이터가 있는 영역만 erase, FDS 보존)
REM program (hex ?곗씠?곌? ?덈뒗 ?곸뿭留?erase, FDS 蹂댁〈)
nrfutil device program --firmware hex\firmware_all.hex --options chip_erase_mode=ERASE_RANGES_TOUCHED_BY_FIRMWARE --serial-number %SERIALNUMBER%
if %errorlevel% neq 0 (
echo.
@@ -1,5 +1,5 @@
@echo off
setlocal enabledelayedexpansion
setlocal EnableExtensions EnableDelayedExpansion
echo ==========================================
echo MEDiThings Bladder Patch Programming
@@ -116,12 +116,23 @@ REM 6. Detect device SERIAL NUMBER and Flash
REM -----------------------------------------------------
echo [6/6] Detecting device serial number...
for /f %%A in ('
powershell -Command "(nrfutil device list --json | Select-String '\"type\":\"info\"' | ConvertFrom-Json).data.devices[0].serialNumber"
') do set SERIALNUMBER=%%A
set "SERIALNUMBER="
if "%SERIALNUMBER%"=="" (
for /f %%A in ('nrfjprog --ids 2^>nul') do (
if not defined SERIALNUMBER set "SERIALNUMBER=%%A"
)
if not defined SERIALNUMBER (
for /f %%A in ('
powershell -NoProfile -Command "(nrfutil device list --json | ConvertFrom-Json).data.devices[0].serialNumber"
') do (
if not defined SERIALNUMBER set "SERIALNUMBER=%%A"
)
)
if not defined SERIALNUMBER (
echo ERROR: No serial number found.
echo Check USB connection and Nordic tools installation.
pause
exit /b 1
)
@@ -83,6 +83,7 @@ extern void dr_piezo_power_off(void);
#define BLE_REB_DATA_LEN (BLE_MTU_SIZE - BLE_REB_HEADER_LEN) /* 238 bytes = 119 samples */
#define BLE_RED_DATA_LEN (BLE_MTU_SIZE - BLE_RED_HEADER_LEN) /* 238 bytes = 119 samples */
#define BLE_PACKET_DELAY_MS 100 /* Inter-packet delay - allow BLE TX buffer to drain */
#define DR_ADC_AVG_INTER_BURST_GAP_US 500 /* Gap between averaged bursts to reduce residual echo carry-over */
/* Piezo MUX pins (8ch) */
#define DR_PIEZO_EN_MUXA NRF_GPIO_PIN_MAP(0, 21) /**< MUXA Enable */
@@ -548,24 +549,7 @@ extern void dr_piezo_burst_sw(uint8_t cycles);
/*==============================================================================
* PIEZO CHANNEL SELECTION
*============================================================================*/
/*
* Channel mapping (8ch)
* | EN MUXA | EN MUXB | SEL 0 | SEL 1
* ----------------------------------------------
* CH A0 | 1 | 0 | 0 | 0
* CH A1 | 1 | 0 | 0 | 1
* CH A2 | 1 | 0 | 1 | 0
* CH A3 | 1 | 0 | 1 | 1
* ----------------------------------------------
* CH B3 | 0 | 1 | 0 | 0
* CH B2 | 0 | 1 | 0 | 1
* CH B1 | 0 | 1 | 1 | 0
* CH B0 | 0 | 1 | 1 | 1
*/
/* dr_piezo_select_channel is defined in dr_piezo.c */
extern void dr_piezo_select_channel(uint8_t channel);
/* Channel selection is split into GPIO switch and timer-backed settling wait. */
extern void dr_piezo_select_channel_start(uint8_t channel);
extern void dr_piezo_wait_mux_settled(void);
@@ -681,22 +681,14 @@ void dr_piezo_select_channel_start(uint8_t channel)
nrf_gpio_pin_clear(DR_PIEZO_EN_MUXB); nrf_gpio_pin_set(DR_PIEZO_EN_MUXA);
nrf_gpio_pin_set(DR_PIEZO_MUX_SEL0); nrf_gpio_pin_set(DR_PIEZO_MUX_SEL1);
break;
/*case 4: // B0: EN_MUXA=0, EN_MUXB=1, SEL0=1, SEL1=1
nrf_gpio_pin_clear(DR_PIEZO_EN_MUXA); nrf_gpio_pin_set(DR_PIEZO_EN_MUXB);
nrf_gpio_pin_set(DR_PIEZO_MUX_SEL0); nrf_gpio_pin_set(DR_PIEZO_MUX_SEL1);
break;
case 5: // B1: EN_MUXA=0, EN_MUXB=1, SEL0=0, SEL1=1
nrf_gpio_pin_clear(DR_PIEZO_EN_MUXA); nrf_gpio_pin_set(DR_PIEZO_EN_MUXB);
nrf_gpio_pin_clear(DR_PIEZO_MUX_SEL0); nrf_gpio_pin_set(DR_PIEZO_MUX_SEL1);
break;*/
case 5: // B2: EN_MUXA=0, EN_MUXB=1, SEL0=1, SEL1=0
nrf_gpio_pin_clear(DR_PIEZO_EN_MUXA); nrf_gpio_pin_set(DR_PIEZO_EN_MUXB);
nrf_gpio_pin_set(DR_PIEZO_MUX_SEL0); nrf_gpio_pin_clear(DR_PIEZO_MUX_SEL1);
break;
case 4: // B3: EN_MUXA=0, EN_MUXB=1, SEL0=0, SEL1=0
case 4: // B0: EN_MUXA=0, EN_MUXB=1, SEL0=0, SEL1=0
nrf_gpio_pin_clear(DR_PIEZO_EN_MUXA); nrf_gpio_pin_set(DR_PIEZO_EN_MUXB);
nrf_gpio_pin_clear(DR_PIEZO_MUX_SEL0); nrf_gpio_pin_clear(DR_PIEZO_MUX_SEL1);
break;
case 5: // B1: EN_MUXA=0, EN_MUXB=1, SEL0=1, SEL1=0
nrf_gpio_pin_clear(DR_PIEZO_EN_MUXA); nrf_gpio_pin_set(DR_PIEZO_EN_MUXB);
nrf_gpio_pin_set(DR_PIEZO_MUX_SEL0); nrf_gpio_pin_clear(DR_PIEZO_MUX_SEL1);
break;
}
/* Start one-shot timer for MUX settling (> 1.2ms). */
@@ -1621,4 +1613,3 @@ void dr_piezo_burst_sw_17mhz(uint8_t cycles)
__enable_irq();
}