Skip to content

Commit 511eab0

Browse files
tdk-opensourceijenkins-invn
authored andcommitted
Release 4.6.1.
1 parent 4b90ac0 commit 511eab0

File tree

6 files changed

+169
-32
lines changed

6 files changed

+169
-32
lines changed

invn/soniclib/ch_api.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,11 @@ void ch_meas_get_queue_info(ch_dev_t *dev_ptr, ch_meas_queue_info_t *info_ptr) {
11401140
ch_common_meas_get_queue_info(dev_ptr, info_ptr);
11411141
}
11421142

1143+
void ch_inst_get_seg_info(pmut_transceiver_inst_t *inst_ptr, uint8_t odr, ch_meas_seg_info_t *info_ptr) {
1144+
1145+
ch_common_inst_get_seg_info(inst_ptr, odr, info_ptr);
1146+
}
1147+
11431148
void ch_meas_get_seg_info(ch_dev_t *dev_ptr, uint8_t meas_num, uint8_t seg_num, ch_meas_seg_info_t *info_ptr) {
11441149

11451150
ch_common_meas_get_seg_info(dev_ptr, meas_num, seg_num, info_ptr);

invn/soniclib/ch_common.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ uint8_t ch_common_init(ch_dev_t *dev_ptr, ch_group_t *grp_ptr, uint8_t dev_num,
8080
ret_val = (*fw_init_func)(dev_ptr, &dev_ptr->main_fw_info);
8181
}
8282
#else
83-
dev_ptr->main_fw_init_done = 0;
83+
dev_ptr->main_fw_init_done = 0;
84+
dev_ptr->mq_sanitize_enabled = 1;
8485
/* Call asic f/w init function passed in as parameter */
8586
ret_val = (*fw_init_func)(dev_ptr, &dev_ptr->main_fw_info);
8687
#endif
@@ -2636,10 +2637,7 @@ void ch_common_meas_get_info(ch_dev_t *dev_ptr, uint8_t meas_num, ch_meas_info_t
26362637
info_ptr->odr = (ch_odr_t)meas_ptr->odr;
26372638
}
26382639

2639-
void ch_common_meas_get_seg_info(ch_dev_t *dev_ptr, uint8_t meas_num, uint8_t seg_num, ch_meas_seg_info_t *info_ptr) {
2640-
pmut_transceiver_inst_t *inst_ptr =
2641-
(pmut_transceiver_inst_t *)&(dev_ptr->meas_queue.meas[meas_num].trx_inst[seg_num]);
2642-
ch_odr_t odr = (ch_odr_t)dev_ptr->meas_queue.meas[meas_num].odr;
2640+
void ch_common_inst_get_seg_info(pmut_transceiver_inst_t *inst_ptr, uint8_t odr, ch_meas_seg_info_t *info_ptr) {
26432641
uint16_t cmd_config = inst_ptr->cmd_config;
26442642
ch_meas_seg_type_t seg_type;
26452643

@@ -2664,6 +2662,13 @@ void ch_common_meas_get_seg_info(ch_dev_t *dev_ptr, uint8_t meas_num, uint8_t se
26642662
}
26652663
}
26662664

2665+
void ch_common_meas_get_seg_info(ch_dev_t *dev_ptr, uint8_t meas_num, uint8_t seg_num, ch_meas_seg_info_t *info_ptr) {
2666+
pmut_transceiver_inst_t *inst_ptr =
2667+
(pmut_transceiver_inst_t *)&(dev_ptr->meas_queue.meas[meas_num].trx_inst[seg_num]);
2668+
ch_odr_t odr = (ch_odr_t)dev_ptr->meas_queue.meas[meas_num].odr;
2669+
ch_common_inst_get_seg_info(inst_ptr, odr, info_ptr);
2670+
}
2671+
26672672
void ch_common_meas_get_queue_info(ch_dev_t *dev_ptr, ch_meas_queue_info_t *info_ptr) {
26682673
measurement_queue_t *meas_q_ptr = &(dev_ptr->meas_queue);
26692674

invn/soniclib/ch_driver.c

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1055,41 +1055,43 @@ static uint8_t limit_rx_len(volatile measurement_t *meas, int rx_len, int eof_id
10551055
}
10561056
}
10571057

1058-
//! Adjust the rx length so that it's compatible with continuous RX
1059-
/*! In continuous RX mode, the total RX length must be set to an integer number
1060-
* of RX samples. The number of RX samples given RX length (in SMCLK cycles)
1061-
* depends on the ODR. This function will truncate the RX length such that the
1062-
* new length satisfies the integer number of samples condition.
1063-
*
1064-
* This also prevents glitches with non-continuous RX at certain RX
1065-
* lengths, though not strictly required.
1066-
*
1067-
* \param meas a pointer to a measurement_t. The instructions contained in the
1068-
* measurement_t will be potentially modified by this function.
1069-
* \param rx_len the total rx length in SMCLK cycles
1070-
* \param eof_idx the index of the EOF instruction
1071-
*/
1072-
static uint8_t adjust_rx_len(volatile measurement_t *meas, int rx_len, int eof_idx) {
1073-
const int rx_samples = rx_len >> (11 - meas->odr);
1074-
const int new_rx_len = rx_samples << (11 - meas->odr);
1058+
uint8_t chdrv_adjust_rx_len(volatile pmut_transceiver_inst_t *trx_inst, uint8_t cic_odr, int rx_len, int eof_idx) {
1059+
const int rx_samples = rx_len >> (11 - cic_odr);
1060+
const int new_rx_len = rx_samples << (11 - cic_odr);
10751061
int len_to_cut = rx_len - new_rx_len;
10761062

10771063
CH_LOG_DEBUG("rx_len=%d rx_samples=%d new_rx_len=%d len_to_cut=%d", rx_len, rx_samples, new_rx_len, len_to_cut);
10781064

10791065
if (len_to_cut == 0) {
10801066
// No modification needed for this rx instruction
10811067
return 0;
1082-
} else if (meas->trx_inst[eof_idx - 1].length >= (1 << (11 - meas->odr)) + len_to_cut) {
1068+
} else if (trx_inst[eof_idx - 1].length >= (1 << (11 - cic_odr)) + len_to_cut) {
10831069
// make sure resulting rx instruction will have at least one RX sample left
10841070
// in it after the cut.
1085-
meas->trx_inst[eof_idx - 1].length -= len_to_cut;
1071+
trx_inst[eof_idx - 1].length -= len_to_cut;
10861072
return 0;
10871073
} else {
10881074
// return error otherwise
10891075
return 1;
10901076
}
10911077
}
10921078

1079+
static uint8_t adjust_rx_len(volatile measurement_t *meas, int rx_len, int eof_idx) {
1080+
return chdrv_adjust_rx_len(meas->trx_inst, meas->odr, rx_len, eof_idx);
1081+
}
1082+
1083+
void chdrv_enable_mq_sanitize(ch_dev_t *dev_ptr) {
1084+
dev_ptr->mq_sanitize_enabled = 1;
1085+
}
1086+
1087+
void chdrv_disable_mq_sanitize(ch_dev_t *dev_ptr) {
1088+
dev_ptr->mq_sanitize_enabled = 0;
1089+
}
1090+
1091+
int16_t chdrv_is_mq_sanitize_enabled(const ch_dev_t *dev_ptr) {
1092+
return dev_ptr->mq_sanitize_enabled;
1093+
}
1094+
10931095
//! Sanitize the measurement queue
10941096
/*! This function sanitizes the measurement queue by performing several checks
10951097
* to ensure it is compatible with the selected sensor mode. This function
@@ -1187,12 +1189,14 @@ uint8_t chdrv_meas_queue_write(ch_dev_t *dev_ptr, measurement_queue_t *q_buf_ptr
11871189
if (q_buf_ptr == NULL) {
11881190
q_buf_ptr = &(dev_ptr->meas_queue); // source is local copy in ch_dev_t
11891191
}
1190-
// Note that we do not abort the write when the sanitize funciton returns an
1191-
// error. This is mostly for historical reasons. We have previously allowed
1192-
// writing invalid queues. It is OK to write them so long as they are not
1193-
// used, and it's a bit confusing for us to just arbitrarily set them when
1194-
// the user has not requested it
1195-
meas_queue_sanitize(q_buf_ptr, dev_ptr->current_fw->max_samples);
1192+
if (chdrv_is_mq_sanitize_enabled(dev_ptr)) {
1193+
// Note that we do not abort the write when the sanitize funciton returns an
1194+
// error. This is mostly for historical reasons. We have previously allowed
1195+
// writing invalid queues. It is OK to write them so long as they are not
1196+
// used, and it's a bit confusing for us to just arbitrarily set them when
1197+
// the user has not requested it
1198+
meas_queue_sanitize(q_buf_ptr, dev_ptr->current_fw->max_samples);
1199+
}
11961200
err |= chdrv_burst_write(dev_ptr, meas_queue_addr, (uint8_t *)q_buf_ptr, sizeof(measurement_queue_t));
11971201

11981202
return err;
@@ -2415,9 +2419,18 @@ static inline uint8_t shasta_detect_and_program(ch_dev_t *dev_ptr) {
24152419
if (!ch_err) {
24162420
ch_err = chdrv_read_buf_addr(dev_ptr);
24172421
}
2422+
if (!ch_err) {
2423+
uint16_t ver_major_addr = (uint16_t)(uintptr_t)&dev_ptr->sens_cfg_addr->common.reg_map_format.major;
2424+
uint16_t ver_minor_addr = (uint16_t)(uintptr_t)&dev_ptr->sens_cfg_addr->common.reg_map_format.minor;
2425+
ch_err = chdrv_read_byte(dev_ptr, ver_major_addr, &dev_ptr->reg_fmt_ver_major);
2426+
if (!ch_err) {
2427+
ch_err = chdrv_read_byte(dev_ptr, ver_minor_addr, &dev_ptr->reg_fmt_ver_minor);
2428+
}
2429+
}
24182430

24192431
CH_LOG_INFO("Sensor shared mem addr = 0x%04x", (uint16_t)(uintptr_t)dev_ptr->sens_cfg_addr);
24202432
CH_LOG_INFO("Sensor algo info addr = 0x%04x", (uint16_t)(uintptr_t)dev_ptr->sens_algo_info_addr);
2433+
CH_LOG_INFO("Sensor register map version = %u.%u", dev_ptr->reg_fmt_ver_major, dev_ptr->reg_fmt_ver_minor);
24212434
}
24222435

24232436
/* Copy OTP (one-time-programmable) mem contents to sensor ram and process contents.

invn/soniclib/details/ch_common.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,7 @@ uint8_t ch_common_meas_switch(ch_dev_t *dev_ptr);
262262
uint8_t ch_common_meas_get_last_num(ch_dev_t *dev_ptr);
263263
void ch_common_meas_get_info(ch_dev_t *dev_ptr, uint8_t meas_num, ch_meas_info_t *info_ptr);
264264
void ch_common_meas_get_queue_info(ch_dev_t *dev_ptr, ch_meas_queue_info_t *info_ptr);
265+
void ch_common_inst_get_seg_info(pmut_transceiver_inst_t *inst_ptr, uint8_t odr, ch_meas_seg_info_t *info_ptr);
265266
void ch_common_meas_get_seg_info(ch_dev_t *dev_ptr, uint8_t meas_num, uint8_t seg_num, ch_meas_seg_info_t *info_ptr);
266267
uint8_t ch_common_meas_set_interval(ch_dev_t *dev_ptr, uint8_t meas_num, uint16_t interval_ms);
267268
uint8_t ch_common_meas_set_interval_us(ch_dev_t *dev_ptr, uint8_t meas_num, uint32_t interval_us);

invn/soniclib/details/ch_driver.h

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ extern "C" {
4040
#include <stdlib.h>
4141
#include <math.h>
4242
#include <string.h>
43+
#include <invn/icu_interface/shasta_pmut_instruction.h>
4344

4445
#define CHDRV_I2C_MAX_WRITE_BYTES 256 /*!< maximum number of bytes in a single I2C write */
4546

@@ -1239,6 +1240,89 @@ void chdrv_group_measure_pmut(ch_group_t *grp_ptr);
12391240

12401241
uint8_t chdrv_check_reset_state(ch_dev_t *dev_ptr, uint8_t *reset_state);
12411242

1243+
/**
1244+
* @brief Enable the measurement config sanitization step when loading configs
1245+
*
1246+
* Not all possible measurement configurations are valid. In particular, there
1247+
* are limits on instruction length and specific control flags that need to be
1248+
* set appropriately. This function enables the sanitization, which is on by
1249+
* default.
1250+
*
1251+
* @param[in,out] dev_ptr The device pointer.
1252+
*
1253+
* @return
1254+
*
1255+
* @note See chdrv_disable_mq_sanitize() and chdrv_is_mq_sanitize_enabled().
1256+
* @warning
1257+
*/
1258+
void chdrv_enable_mq_sanitize(ch_dev_t *dev_ptr);
1259+
1260+
/**
1261+
* @brief Disable the measurement config sanitization step when loading configs
1262+
*
1263+
* Not all possible measurement configurations are valid. In particular, there
1264+
* are limits on instruction length and specific control flags that need to be
1265+
* set appropriately. This function disabled the sanitization, which is on by
1266+
* default.
1267+
*
1268+
* This function is intended to be called from ch_common_init(), before the
1269+
* FW specific initialization function. This allows a specific ASIC firmware to
1270+
* change the setting in its initialization function.
1271+
*
1272+
* See chdrv_enable_mq_sanitize().
1273+
*
1274+
* @param[in,out] dev_ptr The device pointer.
1275+
*
1276+
* @return
1277+
*
1278+
* @note See chdrv_enable_mq_sanitize() and chdrv_is_mq_sanitize_enabled().
1279+
* @warning
1280+
*/
1281+
void chdrv_disable_mq_sanitize(ch_dev_t *dev_ptr);
1282+
1283+
/**
1284+
* @brief Check whether the measurement config sanitization is enabled.
1285+
*
1286+
* See chdrv_enable_mq_sanitize().
1287+
*
1288+
* @param[in,out] dev_ptr The device pointer.
1289+
*
1290+
* @return The enabled status of the sanitization.
1291+
*
1292+
* @retval 0 Sanitization disabled.
1293+
* @retval 1 Sanitization enabled.
1294+
*
1295+
* @note
1296+
* @warning
1297+
*/
1298+
int16_t chdrv_is_mq_sanitize_enabled(const ch_dev_t *dev_ptr);
1299+
1300+
/**
1301+
* @brief This function trims the total RX length to remove excess ADC samples
1302+
* that don't result in additional IQ sample
1303+
*
1304+
* The ICU-x0201 parts use an oversampling ADC. The PMUT state machine time-base
1305+
* is in terms of the ADC clock. That is, when you set the length of the instruction,
1306+
* you are specifying the length in ADC clock cycles. There are many values of total RX
1307+
* length that result in the same number of total IQ samples. This function trims
1308+
* the excess RX length.
1309+
*
1310+
* It is required to run this function before loading the config to avoid particular
1311+
* values of RX length that can cause some undesirable or unexpected behavior.
1312+
*
1313+
* @param trx_inst a pointer to a instruction sequence. The instructions will
1314+
* potentially be modified by this function
1315+
* @param rx_len the total rx length in SMCLK cycles
1316+
* @param eof_idx the index of the EOF instruction
1317+
*
1318+
* @return An error code.
1319+
*
1320+
* @retval 0 Success.
1321+
* @retval 1 The trim could not be completed because it would result in a 0 length
1322+
* RX instruction. Either remove the final RX instruction or make it longer.
1323+
*/
1324+
uint8_t chdrv_adjust_rx_len(volatile pmut_transceiver_inst_t *trx_inst, uint8_t cic_odr, int rx_len, int eof_idx);
1325+
12421326
#ifdef __cplusplus
12431327
}
12441328
#endif

invn/soniclib/soniclib.h

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,8 +112,8 @@ extern "C" {
112112
/*============== SonicLib Version Info ===================*/
113113
/* SonicLib API/Driver version */
114114
#define SONICLIB_VER_MAJOR (4) /*!< SonicLib major version. */
115-
#define SONICLIB_VER_MINOR (5) /*!< SonicLib minor version. */
116-
#define SONICLIB_VER_REV (4) /*!< SonicLib revision. */
115+
#define SONICLIB_VER_MINOR (6) /*!< SonicLib minor version. */
116+
#define SONICLIB_VER_REV (1) /*!< SonicLib revision. */
117117
#define SONICLIB_VER_SUFFIX "" /*!< SonicLib version suffix (contains pre-release info) */
118118

119119
/***** DO NOT MODIFY ANY VALUES BEYOND THIS POINT! *****/
@@ -784,6 +784,10 @@ struct ch_dev_t {
784784
ch_clock_cal_t test_clock_cal; /*!< Clock calibration values from factory test */
785785

786786
int16_t data_validation_counter; /*!< Counter value for data validation */
787+
int16_t mq_sanitize_enabled; /* !< Perform mq sanitization step when non-zero */
788+
789+
uint8_t reg_fmt_ver_major; /*!< SW defined register format major version */
790+
uint8_t reg_fmt_ver_minor; /*!< SW defined register format minor version */
787791

788792
/* Sensor measurement queue */
789793
measurement_queue_t meas_queue; /*!< Sensor measurement queue (local copy) */
@@ -3457,6 +3461,31 @@ void ch_meas_get_queue_info(ch_dev_t *dev_ptr, ch_meas_queue_info_t *info_ptr);
34573461
*/
34583462
void ch_meas_get_seg_info(ch_dev_t *dev_ptr, uint8_t meas_num, uint8_t seg_num, ch_meas_seg_info_t *info_ptr);
34593463

3464+
/*!
3465+
* \brief Get configuration information for a measurement segment.
3466+
*
3467+
* \param inst_ptr pointer to the pmut_transciever_t instruction
3468+
* \param odr measurement odr
3469+
* \param info_ptr pointer to ch_meas_seg_info_t structure to be updated
3470+
*
3471+
* \return 0 if success, 1 if error
3472+
*
3473+
* This function obtains configuration information for the measurement segment specified
3474+
* by \a inst_ptr.
3475+
*
3476+
* The ch_meas_seg_info_t structure specified by \a info_ptr will be completed with the
3477+
* settings for the measurement segment, including:
3478+
* - num_rx_samples - length in sample periods (determined by num_cycles and output data rate)
3479+
* - num_cycles - length in cycles
3480+
* - rdy_int_en - sensor will interrupt when ready
3481+
* - done_int_en - sensor will interrupt when done with segment
3482+
* - tx_phase - phase (transmit segments only)
3483+
* - tx_pulse_width - pulse width (transmit segments only)
3484+
* - rx_gain_reduce - gain reduction (receive segments only)
3485+
* - rx_atten - attenuation (receive segments only)
3486+
*/
3487+
void ch_inst_get_seg_info(pmut_transceiver_inst_t *inst_ptr, uint8_t odr, ch_meas_seg_info_t *info_ptr);
3488+
34603489
/*!
34613490
* \brief Set the repeat interval for a measurement, in milliseconds.
34623491
*

0 commit comments

Comments
 (0)