Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions Boards/shimmer_boards.c
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,36 @@ uint8_t ShimBrd_isBoardSrNumber(uint8_t exp_brd_id, uint8_t exp_brd_major, uint8
&& daughterCardIdPage.expansion_brd.exp_brd_minor == exp_brd_minor));
}

uint8_t ShimBrd_isBoardSrNumberGte(uint8_t exp_brd_id, uint8_t exp_brd_major, uint8_t exp_brd_minor)
{
if (!ShimBrd_isDaughterCardIdSet() || daughterCardIdPage.expansion_brd.exp_brd_id != exp_brd_id)
{
return 0;
}
uint8_t brd_major = daughterCardIdPage.expansion_brd.exp_brd_major;
uint8_t brd_minor = daughterCardIdPage.expansion_brd.exp_brd_minor;
return (brd_major > exp_brd_major)
|| (brd_major == exp_brd_major && brd_minor >= exp_brd_minor);
}

uint8_t ShimBrd_isBmp581PresentPerSrNumber(void)
{
/* The BMP581 replaces the BMP390 on up-rev'd Shimmer3R boards. Per DEV-818
* the fitted models are (>= applies to both rev fields):
* SR31-11-2, SR47-8-2, SR48-7-2, SR48-8-2, SR49-4-2
* SR48 (GSR unified) has two lines: rev 7 from .2 AND rev 8 from .2. The
* rev-7 case must be "major == 7 && minor >= 2" (expressed as >= 7.2 AND
* < 8.0) - a plain >= 7.2 would wrongly include SR48-8-0 / SR48-8-1, which do
* not carry the BMP581. Rev 8 is covered by the separate >= 8.2 check. */
return (ShimBrd_isHwId(HW_ID_SHIMMER3R)
&& (ShimBrd_isBoardSrNumberGte(SHIMMER3_IMU, 11, 2)
|| ShimBrd_isBoardSrNumberGte(EXP_BRD_EXG_UNIFIED, 8, 2)
|| (ShimBrd_isBoardSrNumberGte(EXP_BRD_GSR_UNIFIED, 7, 2)
&& !ShimBrd_isBoardSrNumberGte(EXP_BRD_GSR_UNIFIED, 8, 0))
|| ShimBrd_isBoardSrNumberGte(EXP_BRD_GSR_UNIFIED, 8, 2)
|| ShimBrd_isBoardSrNumberGte(EXP_BRD_BR_AMP_UNIFIED, 4, 2)));
}

uint8_t ShimBrd_isHwId(uint8_t hwIdToCheck)
{
return hwId == hwIdToCheck;
Expand Down
2 changes: 2 additions & 0 deletions Boards/shimmer_boards.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ uint8_t ShimBrd_isI2cOnPPGControlledByAdcChip(void);
uint8_t ShimBrd_areMcuAdcsUsedForSensing(void);

uint8_t ShimBrd_isBoardSrNumber(uint8_t exp_brd_id, uint8_t exp_brd_major, uint8_t exp_brd_minor);
uint8_t ShimBrd_isBoardSrNumberGte(uint8_t exp_brd_id, uint8_t exp_brd_major, uint8_t exp_brd_minor);
uint8_t ShimBrd_isBmp581PresentPerSrNumber(void);
uint8_t ShimBrd_isHwId(uint8_t hwIdToCheck);
uint8_t ShimBrd_isExpBrdId(uint8_t expIdToCheck);
uint8_t ShimBrd_checkCorrectStateForBoot0(void);
Expand Down
32 changes: 31 additions & 1 deletion Comms/shimmer_bt_uart.c
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,6 @@ void ShimBt_processCmd(void)
case GET_GYRO_RANGE_COMMAND:
case GET_BMP180_CALIBRATION_COEFFICIENTS_COMMAND:
case GET_BMP280_CALIBRATION_COEFFICIENTS_COMMAND:
case GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND:
case GET_GYRO_SAMPLING_RATE_COMMAND:
case GET_ALT_ACCEL_RANGE_COMMAND:
case GET_PRESSURE_OVERSAMPLING_RATIO_COMMAND:
Expand Down Expand Up @@ -831,6 +830,14 @@ void ShimBt_processCmd(void)
getCmdWaitingResponse = gAction;
break;
}
case GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND:
Comment thread
marknolan marked this conversation as resolved.
{
/* Handled in ShimBt_sendRsp alongside GET_BMP180/BMP280_CALIBRATION_
* COEFFICIENTS_COMMAND: a BMP581 self-compensates (no coefficients) and
* NACKs there; a BMP390 returns its coefficients. */
getCmdWaitingResponse = gAction;
break;
}
case TEST_CONNECTION_COMMAND:
{
break;
Expand Down Expand Up @@ -1877,6 +1884,16 @@ void ShimBt_sendRsp(void)
}
case GET_PRESSURE_CALIBRATION_COEFFICIENTS_COMMAND:
{
#if defined(SHIMMER3R)
/* BMP581 self-compensates - no calibration coefficients, so NACK (like
* the BMP180/BMP280 cases above). The switch-set NACK is turned into a
* clean single-byte NACK by the sendNack fixup after this switch. */
if (isBmp581InUse())
{
sendNack = 1;
break;
}
#endif
bmpCalibByteLen = get_bmp_calib_data_bytes_len();
*(resPacket + packet_length++) = PRESSURE_CALIBRATION_COEFFICIENTS_RESPONSE;
*(resPacket + packet_length++) = 1U + bmpCalibByteLen;
Expand All @@ -1894,6 +1911,7 @@ void ShimBt_sendRsp(void)
*(resPacket + packet_length++) = PRESSURE_SENSOR_BMP390;
}
#elif defined(SHIMMER3R)
/* Only reached when a BMP390 is fitted (BMP581 NACKs above). */
*(resPacket + packet_length++) = PRESSURE_SENSOR_BMP390;
#endif
memcpy(resPacket + packet_length, get_bmp_calib_data_bytes(), bmpCalibByteLen);
Expand Down Expand Up @@ -2181,6 +2199,18 @@ void ShimBt_sendRsp(void)
}
getCmdWaitingResponse = 0;

/* A response case above may set sendNack (an unsupported command for the
* fitted hardware - e.g. a pressure-calibration request on a self-
* compensating sensor). The ACK/NACK byte is written before the switch, so
* honour a switch-set NACK here: overwrite the staged ACK with a NACK and
* drop any response bytes so a clean single-byte NACK is sent. */
if (sendNack)
{
resPacket[0] = NACK_COMMAND_PROCESSED;
packet_length = 1;
sendNack = 0;
}

COMMS_CRC_MODE crcMode = ShimBt_getCrcMode();
if (crcMode != CRC_OFF)
{
Expand Down
3 changes: 2 additions & 1 deletion Comms/shimmer_bt_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,8 @@ enum
{
PRESSURE_SENSOR_BMP180 = 0,
PRESSURE_SENSOR_BMP280 = 1,
PRESSURE_SENSOR_BMP390 = 2
PRESSURE_SENSOR_BMP390 = 2,
PRESSURE_SENSOR_BMP581 = 3
};

enum
Expand Down
5 changes: 4 additions & 1 deletion Configuration/shimmer_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,10 @@ void ShimConfig_configBytePressureOversamplingRatioSet(uint8_t value)
#if defined(SHIMMER3)
value = (value <= BMPX80_OSS_8) ? (value & 0x03) : BMPX80_OSS_1;
#elif defined(SHIMMER3R)
value = (value <= BMP3_OVERSAMPLING_32X) ? value : BMP3_NO_OVERSAMPLING;
/* The BMP581 supports two additional oversampling settings (64x and 128x)
* over the BMP390's maximum of 32x */
uint8_t maxOversamplingRatio = isBmp581InUse() ? BMP5_OVERSAMPLING_128X : BMP3_OVERSAMPLING_32X;
value = (value <= maxOversamplingRatio) ? value : BMP3_NO_OVERSAMPLING;
#endif
storedConfig.pressureOversamplingRatioLsb = value & 0x03;
#if defined(SHIMMER3R)
Expand Down
Loading
Loading