VesiScan BASIC origin: Piezo + IMU firmware initial code

- nRF52840 + SoftDevice S140 BLE firmware
- Piezo ultrasound TX driver (2MHz, 8ch MUX)
- ICM42670P IMU 6-axis driver
- Echo AFE chain (ADA2200 + ADC121S051)
- BLE NUS command parser (mpa/mpc/mdc/mec/maa/msp)
- FDS flash config storage
- pc_firm parser and ADC driver included

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Charles Kwon
2026-03-11 10:40:20 +09:00
parent a8ba31871e
commit b3adfd42e6
49 changed files with 8459 additions and 2887 deletions

View File

@@ -27,23 +27,36 @@
/*==============================================================================
* POWER CONTROL PINS (DC/DC Converter +/-20V)
*============================================================================*/
#define DR_PIEZO_PWR_SHDN NRF_GPIO_PIN_MAP(0, 21) /**< SHDN_VPP/VNN (LT3463) */
#define DR_PIEZO_PWR_EN_10V NRF_GPIO_PIN_MAP(0, 22) /**< EN_+10V (MCP1804) */
//#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 */
/*==============================================================================
* TX SIGNAL PINS (MOSFET Driver Control)
*============================================================================*/
#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(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
/*==============================================================================
* MUX CONTROL PINS (Echo Signal Path Selection)
*============================================================================*/
#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) */
//#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 */
#define DR_PIEZO_MUX_SEL0 NRF_GPIO_PIN_MAP(1, 10) /**< MUX Select 0 */
#define DR_PIEZO_MUX_SEL1 NRF_GPIO_PIN_MAP(0, 28) /**< MUX Select 1 */
/*==============================================================================
* CONFIGURATION
@@ -57,6 +70,7 @@
#define DR_PIEZO_DEFAULT_CYCLES 5 /**< Default burst cycles (3~5) */
#define DR_PIEZO_MIN_CYCLES 3
#define DR_PIEZO_MAX_CYCLES 10
#define DR_PIEZO_MUX_SETTLING_US 1300 /**< MUX settling delay (us) */
/*==============================================================================
* POWER CONTROL FUNCTIONS
@@ -126,10 +140,21 @@ void dr_piezo_test_pins(void);
/**
* @brief Initialize MUX control pins for echo signal path
* @note Sets P1.13=HIGH, P1.12=LOW, P1.11=LOW
*/
void dr_piezo_mux_init(void);
/**
* @brief Select piezo channel (0~7) via 8ch MUX
* @param channel Piezo channel number (0~7)
*
* Channel mapping (EN_MUXA, EN_MUXB, SEL0, SEL1):
* CH0=A0(1,0,0,0) CH1=A2(1,0,1,0) CH2=A1(1,0,0,1) CH3=A3(1,0,1,1)
* CH4=B0(0,1,1,1) CH5=B1(0,1,0,1) CH6=B2(0,1,1,0) CH7=B3(0,1,0,0)
*
* @note MUX settling time: 1.3ms delay after switching
*/
void dr_piezo_select_channel(uint8_t channel);
/*==============================================================================
* SYSTEM FUNCTIONS (Power + TX combined)
*============================================================================*/
@@ -171,6 +196,13 @@ void dr_piezo_burst_sw_18mhz(uint8_t cycles);
*/
void dr_piezo_burst_sw_20mhz(uint8_t cycles);
/**
* @brief Software-based burst at 2.2 MHz
* @param cycles Number of cycles (1~20)
* @note Fixed frequency: 2.2 MHz
*/
void dr_piezo_burst_sw_22mhz(uint8_t cycles);
/**
* @brief Software-based burst at 1.7 MHz
* @param cycles Number of cycles (1~20)
@@ -178,5 +210,12 @@ void dr_piezo_burst_sw_20mhz(uint8_t cycles);
*/
void dr_piezo_burst_sw_17mhz(uint8_t cycles);
/**
* @brief Software-based burst at 1.9 MHz
* @param cycles Number of cycles (1~20)
* @note Fixed frequency: 1.9 MHz
*/
void dr_piezo_burst_sw_19mhz(uint8_t cycles);
#endif /* DR_PIEZO_H */