Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into mmosca-dji-no-compat
Browse files Browse the repository at this point in the history
  • Loading branch information
mmosca committed Nov 13, 2024
2 parents 5c670ae + 9fb51e0 commit 100c6ea
Show file tree
Hide file tree
Showing 28 changed files with 552 additions and 715 deletions.
2 changes: 1 addition & 1 deletion docs/Settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -5178,7 +5178,7 @@ Value below which Crossfire SNR Alarm pops-up. (dB)

| Default | Min | Max |
| --- | --- | --- |
| 4 | -20 | 10 |
| 4 | -20 | 99 |

---

Expand Down
8 changes: 4 additions & 4 deletions src/main/cms/cms_menu_osd.c
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ static const OSD_Entry menuCrsfRxEntries[]=
OSD_SETTING_ENTRY("LQ ALARM LEVEL", SETTING_OSD_LINK_QUALITY_ALARM),
OSD_SETTING_ENTRY("SNR ALARM LEVEL", SETTING_OSD_SNR_ALARM),
OSD_SETTING_ENTRY("RX SENSITIVITY", SETTING_OSD_RSSI_DBM_MIN),
OSD_ELEMENT_ENTRY("RX RSSI DBM", OSD_CRSF_RSSI_DBM),
OSD_ELEMENT_ENTRY("RX LQ", OSD_CRSF_LQ),
OSD_ELEMENT_ENTRY("RX SNR ALARM", OSD_CRSF_SNR_DB),
OSD_ELEMENT_ENTRY("TX POWER", OSD_CRSF_TX_POWER),
OSD_ELEMENT_ENTRY("RX RSSI DBM", OSD_RSSI_DBM),
OSD_ELEMENT_ENTRY("RX LQ", OSD_LQ_UPLINK),
OSD_ELEMENT_ENTRY("RX SNR ALARM", OSD_SNR_DB),
OSD_ELEMENT_ENTRY("TX POWER", OSD_TX_POWER_UPLINK),

OSD_BACK_AND_END_ENTRY,
};
Expand Down
5 changes: 5 additions & 0 deletions src/main/common/streambuf.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ uint8_t sbufReadU8(sbuf_t *src)
return *src->ptr++;
}

int8_t sbufReadI8(sbuf_t *src)
{
return *src->ptr++;
}

uint16_t sbufReadU16(sbuf_t *src)
{
uint16_t ret;
Expand Down
1 change: 1 addition & 0 deletions src/main/common/streambuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void sbufWriteU16BigEndian(sbuf_t *dst, uint16_t val);
void sbufWriteU32BigEndian(sbuf_t *dst, uint32_t val);

uint8_t sbufReadU8(sbuf_t *src);
int8_t sbufReadI8(sbuf_t *src);
uint16_t sbufReadU16(sbuf_t *src);
uint32_t sbufReadU32(sbuf_t *src);
void sbufReadData(const sbuf_t *dst, void *data, int len);
Expand Down
17 changes: 16 additions & 1 deletion src/main/drivers/accgyro/accgyro_icm42605.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@

#define ICM42605_RA_GYRO_DATA_X1 0x25
#define ICM42605_RA_ACCEL_DATA_X1 0x1F
#define ICM42605_RA_TEMP_DATA1 0x1D

#define ICM42605_RA_INT_CONFIG 0x14
#define ICM42605_INT1_MODE_PULSED (0 << 2)
Expand Down Expand Up @@ -321,6 +322,20 @@ static bool icm42605GyroRead(gyroDev_t *gyro)
return true;
}

static bool icm42605ReadTemperature(gyroDev_t *gyro, int16_t * temp)
{
uint8_t data[2];

const bool ack = busReadBuf(gyro->busDev, ICM42605_RA_TEMP_DATA1, data, 2);
if (!ack) {
return false;
}
// From datasheet: Temperature in Degrees Centigrade = (TEMP_DATA / 132.48) + 25
*temp = ( int16_val_big_endian(data, 0) / 13.248 ) + 250; // Temperature stored as degC*10

return true;
}

bool icm42605GyroDetect(gyroDev_t *gyro)
{
gyro->busDev = busDeviceInit(BUSTYPE_ANY, DEVHW_ICM42605, gyro->imuSensorToUse, OWNER_MPU);
Expand All @@ -340,7 +355,7 @@ bool icm42605GyroDetect(gyroDev_t *gyro)
gyro->initFn = icm42605AccAndGyroInit;
gyro->readFn = icm42605GyroRead;
gyro->intStatusFn = gyroCheckDataReady;
gyro->temperatureFn = NULL;
gyro->temperatureFn = icm42605ReadTemperature;
gyro->scale = 1.0f / 16.4f; // 16.4 dps/lsb scalefactor
gyro->gyroAlign = gyro->busDev->param;

Expand Down
42 changes: 35 additions & 7 deletions src/main/drivers/barometer/barometer_dps310.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@


#define DPS310_ID_REV_AND_PROD_ID (0x10)
#define SPL07_003_CHIP_ID (0x11)

#define DPS310_RESET_BIT_SOFT_RST (0x09) // 0b1001

Expand Down Expand Up @@ -96,6 +97,8 @@ typedef struct {
int16_t c20; // 16bit
int16_t c21; // 16bit
int16_t c30; // 16bit
int16_t c31; // 12bit
int16_t c40; // 12bit
} calibrationCoefficients_t;

typedef struct {
Expand All @@ -105,6 +108,7 @@ typedef struct {
} baroState_t;

static baroState_t baroState;
static uint8_t chipId[1];


// Helper functions
Expand Down Expand Up @@ -167,7 +171,10 @@ static bool deviceConfigure(busDevice_t * busDev)

// 1. Read the pressure calibration coefficients (c00, c10, c20, c30, c01, c11, and c21) from the Calibration Coefficient register.
// Note: The coefficients read from the coefficient register are 2's complement numbers.
uint8_t coef[18];

unsigned coefficientLength = chipId[0] == SPL07_003_CHIP_ID ? 21 : 18;
uint8_t coef[coefficientLength];

if (!busReadBuf(busDev, DPS310_REG_COEF, coef, sizeof(coef))) {
return false;
}
Expand Down Expand Up @@ -199,6 +206,17 @@ static bool deviceConfigure(busDevice_t * busDev)
// 0x20 c30 [15:8] + 0x21 c30 [7:0]
baroState.calib.c30 = getTwosComplement(((uint32_t)coef[16] << 8) | (uint32_t)coef[17], 16);

if (chipId[0] == SPL07_003_CHIP_ID) {
// 0x23 c31 [3:0] + 0x22 c31 [11:4]
baroState.calib.c31 = getTwosComplement(((uint32_t)coef[18] << 4) | (((uint32_t)coef[19] >> 4) & 0x0F), 12);

// 0x23 c40 [11:8] + 0x24 c40 [7:0]
baroState.calib.c40 = getTwosComplement((((uint32_t)coef[19] & 0x0F) << 8) | (uint32_t)coef[20], 12);
} else {
baroState.calib.c31 = 0;
baroState.calib.c40 = 0;
}

// MEAS_CFG: Make sure the device is in IDLE mode
registerWriteBits(busDev, DPS310_REG_MEAS_CFG, DPS310_MEAS_CFG_MEAS_CTRL_MASK, DPS310_MEAS_CFG_MEAS_IDLE);

Expand All @@ -218,8 +236,12 @@ static bool deviceConfigure(busDevice_t * busDev)
registerSetBits(busDev, DPS310_REG_PRS_CFG, DPS310_PRS_CFG_BIT_PM_RATE_32HZ | DPS310_PRS_CFG_BIT_PM_PRC_16);

// TMP_CFG: temperature measurement rate (32 Hz) and oversampling (16 times)
const uint8_t TMP_COEF_SRCE = registerRead(busDev, DPS310_REG_COEF_SRCE) & DPS310_COEF_SRCE_BIT_TMP_COEF_SRCE;
registerSetBits(busDev, DPS310_REG_TMP_CFG, DPS310_TMP_CFG_BIT_TMP_RATE_32HZ | DPS310_TMP_CFG_BIT_TMP_PRC_16 | TMP_COEF_SRCE);
if (chipId[0] == SPL07_003_CHIP_ID) {
registerSetBits(busDev, DPS310_REG_TMP_CFG, DPS310_TMP_CFG_BIT_TMP_RATE_32HZ | DPS310_TMP_CFG_BIT_TMP_PRC_16);
} else {
const uint8_t TMP_COEF_SRCE = registerRead(busDev, DPS310_REG_COEF_SRCE) & DPS310_COEF_SRCE_BIT_TMP_COEF_SRCE;
registerSetBits(busDev, DPS310_REG_TMP_CFG, DPS310_TMP_CFG_BIT_TMP_RATE_32HZ | DPS310_TMP_CFG_BIT_TMP_PRC_16 | TMP_COEF_SRCE);
}

// CFG_REG: set pressure and temperature result bit-shift (required when the oversampling rate is >8 times)
registerSetBits(busDev, DPS310_REG_CFG_REG, DPS310_CFG_REG_BIT_T_SHIFT | DPS310_CFG_REG_BIT_P_SHIFT);
Expand Down Expand Up @@ -265,9 +287,17 @@ static bool deviceReadMeasurement(baroDev_t *baro)
const float c20 = baroState.calib.c20;
const float c21 = baroState.calib.c21;
const float c30 = baroState.calib.c30;
const float c31 = baroState.calib.c31;
const float c40 = baroState.calib.c40;

// See section 4.9.1, How to Calculate Compensated Pressure Values, of datasheet
baroState.pressure = c00 + Praw_sc * (c10 + Praw_sc * (c20 + Praw_sc * c30)) + Traw_sc * c01 + Traw_sc * Praw_sc * (c11 + Praw_sc * c21);
// baroState.pressure = c00 + Praw_sc * (c10 + Praw_sc * (c20 + Praw_sc * c30)) + Traw_sc * c01 + Traw_sc * Praw_sc * (c11 + Praw_sc * c21);
if (chipId[0] == SPL07_003_CHIP_ID) {
baroState.pressure = c00 + Praw_sc * (c10 + Praw_sc * (c20 + Praw_sc * (c30 + Praw_sc * c40))) + Traw_sc * c01 + Traw_sc * Praw_sc * (c11 + Praw_sc * (c21 + Praw_sc * c31));
} else {
baroState.pressure = c00 + Praw_sc * (c10 + Praw_sc * (c20 + Praw_sc * c30)) + Traw_sc * c01 + Traw_sc * Praw_sc * (c11 + Praw_sc * c21);
}


const float c0 = baroState.calib.c0;
const float c1 = baroState.calib.c1;
Expand Down Expand Up @@ -299,13 +329,11 @@ static bool deviceCalculate(baroDev_t *baro, int32_t *pressure, int32_t *tempera
static bool deviceDetect(busDevice_t * busDev)
{
for (int retry = 0; retry < DETECTION_MAX_RETRY_COUNT; retry++) {
uint8_t chipId[1];

delay(100);

bool ack = busReadBuf(busDev, DPS310_REG_ID, chipId, 1);

if (ack && chipId[0] == DPS310_ID_REV_AND_PROD_ID) {
if (ack && (chipId[0] == DPS310_ID_REV_AND_PROD_ID || chipId[0] == SPL07_003_CHIP_ID)) {
return true;
}
};
Expand Down
2 changes: 2 additions & 0 deletions src/main/drivers/osd_symbols.h
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,8 @@
#define SYM_AH_CH_CENTER 0x166 // 358 Crossair center
#define SYM_FLIGHT_DIST_REMAINING 0x167 // 359 Flight distance reminaing
#define SYM_ODOMETER 0x168 // 360 Odometer
#define SYM_RX_BAND 0x169 // 361 RX Band
#define SYM_RX_MODE 0x16A // 362 RX Mode

#define SYM_AH_CH_TYPE3 0x190 // 400 to 402, crosshair 3
#define SYM_AH_CH_TYPE4 0x193 // 403 to 405, crosshair 4
Expand Down
7 changes: 6 additions & 1 deletion src/main/drivers/uart_inverter.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,12 @@ void uartInverterSet(USART_TypeDef *USARTx, uartInverterLine_e line, bool enable

// UART4
#if defined(INVERTER_PIN_UART4_RX) || defined(INVERTER_PIN_UART4_TX)
if (USARTx == USART4) {
#if defined(STM32F4)
if (USARTx == UART4)
#else
if (USARTx == USART4)
#endif
{
#if defined(INVERTER_PIN_UART4_RX)
rx_pin = IOGetByTag(IO_TAG(INVERTER_PIN_UART4_RX));
#endif
Expand Down
4 changes: 2 additions & 2 deletions src/main/drivers/vtx_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@

#define VTX_SETTINGS_POWER_COUNT 8
#define VTX_SETTINGS_DEFAULT_POWER 1
#define VTX_SETTINGS_MIN_POWER 1
#define VTX_SETTINGS_MIN_POWER 0
#define VTX_SETTINGS_MIN_USER_FREQ 5000
#define VTX_SETTINGS_MAX_USER_FREQ 5999
#define VTX_SETTINGS_FREQCMD
#define VTX_SETTINGS_MAX_POWER (VTX_SETTINGS_POWER_COUNT - VTX_SETTINGS_MIN_POWER + 1)
#define VTX_SETTINGS_MAX_POWER (VTX_SETTINGS_POWER_COUNT - VTX_SETTINGS_MIN_POWER)

#else

Expand Down
Loading

0 comments on commit 100c6ea

Please sign in to comment.