테스트용 함수 삭제
This commit is contained in:
@@ -71,11 +71,25 @@ extern void dr_piezo_power_off(void);
|
||||
/*==============================================================================
|
||||
* PRIVATE DEFINES
|
||||
*============================================================================*/
|
||||
|
||||
/* Extract pin number from NRF_GPIO_PIN_MAP (lower 5 bits) */
|
||||
#define DR_PIN_NUM(pin) ((pin) & 0x1F)
|
||||
#define DR_PIN_PORT(pin) (((pin) >> 5) & 0x01)
|
||||
|
||||
/* BLE packet constants */
|
||||
#define BLE_MTU_SIZE 244 /* ATT MTU 247 - 3 (ATT header) = 244 */
|
||||
#define BLE_REB_HEADER_LEN 6 /* "reb:" tag(4) + num_samples(2) */
|
||||
#define BLE_RED_HEADER_LEN 6 /* "red:" tag(4) + pkt_idx(2) */
|
||||
#define BLE_RDB_HEADER_LEN 8 /* "rdb:" tag(4) + num_samples(2) + compressed_size(2) */
|
||||
#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 */
|
||||
|
||||
/* Piezo MUX pins (8ch) */
|
||||
#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_SEL1 NRF_GPIO_PIN_MAP(0, 28) /**< MUX Select 1 */
|
||||
#define DR_PIEZO_MUX_SEL0 NRF_GPIO_PIN_MAP(1, 10) /**< MUX Select 0 */
|
||||
|
||||
/*==============================================================================
|
||||
* PRIVATE VARIABLES
|
||||
*============================================================================*/
|
||||
@@ -133,8 +147,6 @@ dr_adc_err_t dr_adc_init(void)
|
||||
{
|
||||
nrfx_err_t err;
|
||||
|
||||
ADC_LOG("ADC121S051 init (HW SPI, SPIM3)...");
|
||||
|
||||
nrfx_spim_config_t config = NRFX_SPIM_DEFAULT_CONFIG;
|
||||
config.sck_pin = DR_ADC_PIN_SCLK; /* P0.14 */
|
||||
config.mosi_pin = NRFX_SPIM_PIN_NOT_USED;/* not used (read-only ADC) */
|
||||
@@ -146,7 +158,7 @@ dr_adc_err_t dr_adc_init(void)
|
||||
config.ss_active_high = false; /* CS active LOW */
|
||||
|
||||
err = nrfx_spim_init(&m_spim, &config, NULL, NULL);
|
||||
ADC_LOG("SPIM3 init result: 0x%08X (%s)", err, (err == NRFX_SUCCESS) ? "OK" : "FAIL");
|
||||
|
||||
if (err != NRFX_SUCCESS)
|
||||
{
|
||||
return DR_ADC_ERR_NOT_INIT;
|
||||
@@ -160,8 +172,6 @@ dr_adc_err_t dr_adc_init(void)
|
||||
|
||||
m_initialized = true;
|
||||
|
||||
ADC_LOG("ADC121S051 ready (VREF=%dmV, HW SPI)", m_vref_mv);
|
||||
|
||||
return DR_ADC_OK;
|
||||
}
|
||||
|
||||
@@ -173,10 +183,7 @@ void dr_adc_uninit(void)
|
||||
}
|
||||
|
||||
nrfx_spim_uninit(&m_spim);
|
||||
|
||||
m_initialized = false;
|
||||
|
||||
ADC_LOG("ADC121S051 uninitialized");
|
||||
}
|
||||
|
||||
bool dr_adc_is_initialized(void)
|
||||
@@ -350,8 +357,7 @@ dr_adc_err_t dr_adc_measure_echo(dr_adc_echo_t *echo, const dr_adc_echo_config_t
|
||||
return dr_adc_analyze_echo(m_echo_buffer, cfg.num_samples, echo, cfg.threshold_raw);
|
||||
}
|
||||
|
||||
dr_adc_err_t dr_adc_burst_and_capture(uint8_t cycles, uint16_t delay_us,
|
||||
uint16_t num_samples, dr_adc_echo_t *echo)
|
||||
dr_adc_err_t dr_adc_burst_and_capture(uint8_t cycles, uint16_t delay_us, uint16_t num_samples, dr_adc_echo_t *echo)
|
||||
{
|
||||
(void)cycles; /* Not used - ADC test only */
|
||||
|
||||
@@ -407,8 +413,7 @@ const uint16_t* dr_adc_get_echo_buffer(void)
|
||||
return m_echo_buffer;
|
||||
}
|
||||
|
||||
dr_adc_err_t dr_adc_analyze_echo(const uint16_t *buffer, uint16_t num_samples,
|
||||
dr_adc_echo_t *echo, uint16_t threshold)
|
||||
dr_adc_err_t dr_adc_analyze_echo(const uint16_t *buffer, uint16_t num_samples, dr_adc_echo_t *echo, uint16_t threshold)
|
||||
{
|
||||
if (buffer == NULL || echo == NULL)
|
||||
{
|
||||
@@ -522,57 +527,6 @@ uint32_t dr_adc_get_vref(void)
|
||||
return m_vref_mv;
|
||||
}
|
||||
|
||||
/*==============================================================================
|
||||
* PUBLIC FUNCTIONS - DEBUG
|
||||
*============================================================================*/
|
||||
|
||||
bool dr_adc_test(void)
|
||||
{
|
||||
if (!m_initialized)
|
||||
{
|
||||
ADC_LOG("Test FAIL: not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint16_t raw;
|
||||
dr_adc_err_t err = dr_adc_read_raw(&raw);
|
||||
|
||||
if (err != DR_ADC_OK)
|
||||
{
|
||||
ADC_LOG("Test FAIL: read error %d", err);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (raw > DR_ADC_MAX_VALUE)
|
||||
{
|
||||
ADC_LOG("Test FAIL: invalid value %d", raw);
|
||||
return false;
|
||||
}
|
||||
|
||||
ADC_LOG("Test PASS: raw=%d (%dmV)", raw, dr_adc_raw_to_mv(raw));
|
||||
return true;
|
||||
}
|
||||
|
||||
void dr_adc_print_buffer(const uint16_t *buffer, uint16_t num_samples)
|
||||
{
|
||||
#ifdef DEBUG_ADC
|
||||
if (buffer == NULL || num_samples == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
ADC_LOG("Echo buffer (%d samples):", num_samples);
|
||||
|
||||
for (uint16_t i = 0; i < num_samples; i++)
|
||||
{
|
||||
ADC_LOG("[%3d] %4d (%4dmV)", i, buffer[i], dr_adc_raw_to_mv(buffer[i]));
|
||||
}
|
||||
#else
|
||||
(void)buffer;
|
||||
(void)num_samples;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*==============================================================================
|
||||
* BLE TRANSMISSION
|
||||
*============================================================================*/
|
||||
@@ -591,26 +545,11 @@ extern void dr_sd_delay_ms(uint32_t ms);
|
||||
/* External piezo burst function */
|
||||
extern void dr_piezo_burst_sw(uint8_t cycles);
|
||||
|
||||
/* BLE packet constants */
|
||||
#define BLE_MTU_SIZE 244 /* ATT MTU 247 - 3 (ATT header) = 244 */
|
||||
#define BLE_REB_HEADER_LEN 6 /* "reb:" tag(4) + num_samples(2) */
|
||||
#define BLE_RED_HEADER_LEN 6 /* "red:" tag(4) + pkt_idx(2) */
|
||||
#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 */
|
||||
|
||||
/*==============================================================================
|
||||
* PIEZO CHANNEL SELECTION
|
||||
*============================================================================*/
|
||||
|
||||
/* Piezo MUX pins (8ch) */
|
||||
#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_SEL1 NRF_GPIO_PIN_MAP(0, 28) /**< MUX Select 1 */
|
||||
#define DR_PIEZO_MUX_SEL0 NRF_GPIO_PIN_MAP(1, 10) /**< MUX Select 0 */
|
||||
|
||||
/*
|
||||
* Channel mapping (8ch) jhChun 26.01.29
|
||||
* Channel mapping (8ch)
|
||||
|
||||
* | EN MUXA | EN MUXB | SEL 0 | SEL 1
|
||||
* ----------------------------------------------
|
||||
@@ -1124,7 +1063,6 @@ dr_adc_err_t dr_adc_transmit_channel_delta(const dr_maa_channel_t *ch_data, uint
|
||||
ble_buffer[6] = (uint8_t)(compressed_size >> 8);
|
||||
ble_buffer[7] = (uint8_t)(compressed_size & 0xFF);
|
||||
|
||||
#define BLE_RDB_HEADER_LEN 8 /* rdb: tag(4) + num_samples(2) + compressed_size(2) */
|
||||
uint16_t rdb_data_cap = BLE_MTU_SIZE - BLE_RDB_HEADER_LEN; /* 236 bytes */
|
||||
|
||||
uint16_t dst_idx = BLE_RDB_HEADER_LEN;
|
||||
|
||||
@@ -263,19 +263,6 @@ uint32_t dr_adc_get_vref(void);
|
||||
* DEBUG FUNCTIONS
|
||||
*============================================================================*/
|
||||
|
||||
/**
|
||||
* @brief Test ADC communication
|
||||
* @return true if OK
|
||||
*/
|
||||
bool dr_adc_test(void);
|
||||
|
||||
/**
|
||||
* @brief Print echo buffer to debug output
|
||||
* @param buffer Sample buffer
|
||||
* @param num_samples Number of samples
|
||||
*/
|
||||
void dr_adc_print_buffer(const uint16_t *buffer, uint16_t num_samples);
|
||||
|
||||
/*==============================================================================
|
||||
* POWER CONTROL
|
||||
*============================================================================*/
|
||||
|
||||
Reference in New Issue
Block a user